From 2fef6d48e81483bbf490e677bd4fb01f1b8d08bb Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 22:28:22 +0000 Subject: [PATCH] Update maplibre-gl to version 5.18.0 --- config/importmap.rb | 2 +- vendor/javascript/maplibre-gl.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/importmap.rb b/config/importmap.rb index 3fbfe028..d7aa5883 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.17.0 +pin "maplibre-gl", preload: false # @5.18.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 8d2f15cd..5f2e477f 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 l={}; +var e=typeof globalThis!=="undefined"?globalThis:typeof self!=="undefined"?self:global;var c={}; /** * MapLibre GL JS - * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.17.0/LICENSE.txt - */(function(e,c){l=c()})(0,(function(){var l={};var c={};function d(e,d,p){c[e]=p;if(e==="index"){var f="var sharedModule = {}; ("+c.shared+")(sharedModule); ("+c.worker+")(sharedModule);";var m={};c.shared(m);c.index(l,m);typeof window!=="undefined"&&l.setWorkerUrl(window.URL.createObjectURL(new Blob([f],{type:"text/javascript"})));return l}}d("shared",["exports"],(function(l){function c(e,l,c,d){return new(c||(c=Promise))((function(p,f){function m(e){try{g(d.next(e))}catch(e){f(e)}}function _(e){try{g(d.throw(e))}catch(e){f(e)}}function g(e){var l;e.done?p(e.value):(l=e.value,l instanceof c?l:new c((function(e){e(l)}))).then(m,_)}g((d=d.apply(e,l||[])).next())}))}function d(l,c){(this||e).x=l,(this||e).y=c}function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var f,m;"function"==typeof SuppressedError&&SuppressedError,d.prototype={clone(){return new d((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,l){return this.clone()._rotateAround(e,l)},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(l){return(this||e).x===l.x&&(this||e).y===l.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(l){const c=l.x-(this||e).x,d=l.y-(this||e).y;return c*c+d*d},angle(){return Math.atan2((this||e).y,(this||e).x)},angleTo(l){return Math.atan2((this||e).y-l.y,(this||e).x-l.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(l,c){return Math.atan2((this||e).x*c-(this||e).y*l,(this||e).x*l+(this||e).y*c)},_matMult(l){const c=l[2]*(this||e).x+l[3]*(this||e).y;return(this||e).x=l[0]*(this||e).x+l[1]*(this||e).y,(this||e).y=c,this||e},_add(l){return(this||e).x+=l.x,(this||e).y+=l.y,this||e},_sub(l){return(this||e).x-=l.x,(this||e).y-=l.y,this||e},_mult(l){return(this||e).x*=l,(this||e).y*=l,this||e},_div(l){return(this||e).x/=l,(this||e).y/=l,this||e},_multByPoint(l){return(this||e).x*=l.x,(this||e).y*=l.y,this||e},_divByPoint(l){return(this||e).x/=l.x,(this||e).y/=l.y,this||e},_unit(){return this._div(this.mag()),this||e},_perp(){const l=(this||e).y;return(this||e).y=(this||e).x,(this||e).x=-l,this||e},_rotate(l){const c=Math.cos(l),d=Math.sin(l),p=d*(this||e).x+c*(this||e).y;return(this||e).x=c*(this||e).x-d*(this||e).y,(this||e).y=p,this||e},_rotateAround(l,c){const d=Math.cos(l),p=Math.sin(l),f=c.y+p*((this||e).x-c.x)+d*((this||e).y-c.y);return(this||e).x=c.x+d*((this||e).x-c.x)-p*((this||e).y-c.y),(this||e).y=f,this||e},_round(){return(this||e).x=Math.round((this||e).x),(this||e).y=Math.round((this||e).y),this||e},constructor:d},d.convert=function(e){if(e instanceof d)return e;if(Array.isArray(e))return new d(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new d(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var _=function(){if(m)return f;function l(l,c,d,p){(this||e).cx=3*l,(this||e).bx=3*(d-l)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*c,(this||e).by=3*(p-c)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=l,(this||e).p1y=c,(this||e).p2x=d,(this||e).p2y=p}return m=1,f=l,l.prototype={sampleCurveX:function(l){return(((this||e).ax*l+(this||e).bx)*l+(this||e).cx)*l},sampleCurveY:function(l){return(((this||e).ay*l+(this||e).by)*l+(this||e).cy)*l},sampleCurveDerivativeX:function(l){return(3*(this||e).ax*l+2*(this||e).bx)*l+(this||e).cx},solveCurveX:function(e,l){if(void 0===l&&(l=1e-6),e<0)return 0;if(e>1)return 1;for(var c=e,d=0;d<8;d++){var p=this.sampleCurveX(c)-e;if(Math.abs(p)p?m=c:_=c,c=.5*(_-m)+m;return c},solve:function(e,l){return this.sampleCurveY(this.solveCurveX(e,l))}},f}(),g=p(_);let y,b;function T(){return null==y&&(y="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),y}function S(){if(null==b&&(b=!1,T())){const e=5,l=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(l){for(let c=0;c4&&void 0!==arguments[4]?arguments[4]:"zyx",f=Math.PI/360;l*=f,d*=f,c*=f;var m=Math.sin(l),_=Math.cos(l),g=Math.sin(c),y=Math.cos(c),b=Math.sin(d),T=Math.cos(d);switch(p){case"xyz":e[0]=m*y*T+_*g*b,e[1]=_*g*T-m*y*b,e[2]=_*y*b+m*g*T,e[3]=_*y*T-m*g*b;break;case"xzy":e[0]=m*y*T-_*g*b,e[1]=_*g*T-m*y*b,e[2]=_*y*b+m*g*T,e[3]=_*y*T+m*g*b;break;case"yxz":e[0]=m*y*T+_*g*b,e[1]=_*g*T-m*y*b,e[2]=_*y*b-m*g*T,e[3]=_*y*T+m*g*b;break;case"yzx":e[0]=m*y*T+_*g*b,e[1]=_*g*T+m*y*b,e[2]=_*y*b-m*g*T,e[3]=_*y*T-m*g*b;break;case"zxy":e[0]=m*y*T-_*g*b,e[1]=_*g*T+m*y*b,e[2]=_*y*b+m*g*T,e[3]=_*y*T-m*g*b;break;case"zyx":e[0]=m*y*T-_*g*b,e[1]=_*g*T+m*y*b,e[2]=_*y*b-m*g*T,e[3]=_*y*T+m*g*b;break;default:throw new Error("Unknown angle order "+p)}return e}function Q(){var e=new I(2);return I!=Float32Array&&(e[0]=0,e[1]=0),e}function J(e,l){var c=new I(2);return c[0]=e,c[1]=l,c}L(),G=new I(4),I!=Float32Array&&(G[0]=0,G[1]=0,G[2]=0,G[3]=0),L(),B(1,0,0),B(0,1,0),Z(),Z(),C(),Q();const re=8192;function oe(e,l,c){return l*(re/(e.tileSize*Math.pow(2,c-e.tileID.overscaledZ)))}function le(e,l){return(e%l+l)%l}function ce(e,l,c){return e*(1-c)+l*c}function he(e){if(e<=0)return 0;if(e>=1)return 1;const l=e*e,c=l*e;return 4*(e<.5?c:3*(e-l)+c-.75)}function ue(e,l,c,d){const p=new g(e,l,c,d);return e=>p.solve(e)}const pe=ue(.25,.1,.25,1);function fe(e,l,c){return Math.min(c,Math.max(l,e))}function me(e,l,c){const d=c-l,p=((e-l)%d+d)%d+l;return p===l?c:p}function ge(e,...l){for(const c of l)for(const l in c)e[l]=c[l];return e}let ye=1;function xe(l,c,d){const p={};for(const d in l)p[d]=c.call(this||e,l[d],d,l);return p}function ve(l,c,d){const p={};for(const d in l)c.call(this||e,l[d],d,l)&&(p[d]=l[d]);return p}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,l,c){return(c.y-e.y)*(l.x-e.x)>(l.y-e.y)*(c.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(l,d,p,f,m){return c(this||e,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(l,{timestamp:0});try{const c=null==e?void 0:e.format;if(!c||!c.startsWith("BGR")&&!c.startsWith("RGB"))throw new Error(`Unrecognized format ${c}`);const _=c.startsWith("BGR"),g=new Uint8ClampedArray(f*m*4);if(yield e.copyTo(g,function(e,l,c,d,p){const f=4*Math.max(-l,0),m=(Math.max(0,c)-c)*d*4+f,_=4*d,g=Math.max(0,l),y=Math.max(0,c);return{rect:{x:g,y:y,width:Math.min(e.width,l+d)-g,height:Math.min(e.height,c+p)-y},layout:[{offset:m,stride:_}]}}(l,d,p,f,m)),_)for(let e=0;e{e.removeEventListener(l,c,d)}}}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,l,c,d){super(`AJAXError: ${l} (${e}): ${c}`),this.status=e,this.statusText=l,this.url=c,this.body=d}}const _t=()=>Ee(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,yt=function(l,d){if(/:\/\//.test(l.url)&&!/^https?:|^file:/.test(l.url)){const e=at(l.url);if(e)return e(l,d);if(Ee(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:l,targetMapId:ft},d)}if(!(/^file:/.test(p=l.url)||/^file:/.test(_t())&&!/^\w+:/.test(p))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(l,d){return c(this||e,void 0,void 0,(function*(){const e=new Request(l.url,{method:l.method||"GET",body:l.body,credentials:l.credentials,headers:l.headers,cache:l.cache,referrer:_t(),signal:d.signal});let c,p;"json"!==l.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{c=yield fetch(e)}catch(e){if(rt(e))throw e;throw new ct(0,e.message,l.url,new Blob)}if(!c.ok){const e=yield c.blob();throw new ct(c.status,c.statusText,l.url,e)}p="arrayBuffer"===l.type||"image"===l.type?c.arrayBuffer():"json"===l.type?c.json():c.text();const f=yield p;return d.signal.throwIfAborted(),{data:f,cacheControl:c.headers.get("Cache-Control"),expires:c.headers.get("Expires")}}))}(l,d);if(Ee(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:l,mustQueue:!0,targetMapId:ft},d)}var p;return function(e,l){return new Promise(((c,d)=>{var p;const f=new XMLHttpRequest;f.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(f.responseType="arraybuffer");for(const l in e.headers)f.setRequestHeader(l,e.headers[l]);"json"===e.type&&(f.responseType="text",(null===(p=e.headers)||void 0===p?void 0:p.Accept)||f.setRequestHeader("Accept","application/json")),f.withCredentials="include"===e.credentials,f.onerror=()=>{d(new Error(f.statusText))},f.onload=()=>{if(!l.signal.aborted)if((f.status>=200&&f.status<300||0===f.status)&&null!==f.response){let l=f.response;if("json"===e.type)try{l=JSON.parse(f.response)}catch(e){return void d(e)}c({data:l,cacheControl:f.getResponseHeader("Cache-Control"),expires:f.getResponseHeader("Expires")})}else{const l=new Blob([f.response],{type:f.getResponseHeader("Content-Type")});d(new ct(f.status,f.statusText,e.url,l))}},l.signal.addEventListener("abort",(()=>{f.abort(),d(new st(l.signal.reason))})),f.send(e.body)}))}(l,d)};function vt(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const l=new URL(e),c=window.location;return l.protocol===c.protocol&&l.host===c.host}function bt(e,l,c){c[e]&&-1!==c[e].indexOf(l)||(c[e]=c[e]||[],c[e].push(l))}function wt(e,l,c){if(c&&c[e]){const d=c[e].indexOf(l);-1!==d&&c[e].splice(d,1)}}class mt{constructor(e,l={}){ge(this,l),this.type=e}}class gt extends mt{constructor(e,l={}){super("error",ge({error:e},l))}}class xt{on(e,l){return this._listeners=this._listeners||{},bt(e,l,this._listeners),{unsubscribe:()=>{this.off(e,l)}}}off(e,l){return wt(e,l,this._listeners),wt(e,l,this._oneTimeListeners),this}once(e,l){return l?(this._oneTimeListeners=this._oneTimeListeners||{},bt(e,l,this._oneTimeListeners),this):new Promise((l=>this.once(e,l)))}fire(e,l){"string"==typeof e&&(e=new mt(e,l||{}));const c=e.type;if(this.listens(c)){e.target=this;const l=this._listeners&&this._listeners[c]?this._listeners[c].slice():[];for(const c of l)c.call(this,e);const d=this._oneTimeListeners&&this._oneTimeListeners[c]?this._oneTimeListeners[c].slice():[];for(const l of d)wt(c,l,this._oneTimeListeners),l.call(this,e);const p=this._eventedParent;p&&(ge(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),p.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,l){return this._eventedParent=e,this._eventedParentData=l,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,l){const c={};for(const l in e)"ref"!==l&&(c[l]=e[l]);return Mt.forEach((e=>{e in l&&(c[e]=l[e])})),c}function Lt(e,l){if(Array.isArray(e)){if(!Array.isArray(l)||e.length!==l.length)return!1;for(let c=0;c`:"value"===e.itemType.kind?"array":`array<${l}>`}return e.kind}const Ai=[ni,li,ci,ui,pi,fi,yi,mi,Ei(_i),xi,bi,vi,wi,Ii];function Li(e,l){if("error"===l.kind)return null;if("array"===e.kind){if("array"===l.kind&&(0===l.N&&"value"===l.itemType.kind||!Li(e.itemType,l.itemType))&&("number"!=typeof e.N||e.N===l.N))return null}else{if(e.kind===l.kind)return null;if("value"===e.kind)for(const e of Ai)if(!Li(e,l))return null}return`Expected ${Ci(e)} but found ${Ci(l)} instead.`}function Fi(e,l){return l.some((l=>l.kind===e.kind))}function Oi(e,l){return l.some((l=>"null"===l?null===e:"array"===l?Array.isArray(e):"object"===l?e&&!Array.isArray(e)&&"object"==typeof e:l===typeof e))}function Vi(e,l){return"array"===e.kind&&"array"===l.kind?e.itemType.kind===l.itemType.kind&&"number"==typeof e.N:e.kind===l.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,l,c,d]){let p,f;const m=Qi((.2225045*(e=Ki(e))+.7168786*(l=Ki(l))+.0606169*(c=Ki(c)))/1);e===l&&l===c?p=f=m:(p=Qi((.4360747*e+.3850649*l+.1430804*c)/ji),f=Qi((.0139322*e+.0971045*l+.7141733*c)/Ni));const _=116*m-16;return[_<0?0:_,500*(p-m),200*(m-f),d]}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,l,c,d]){let p=(e+16)/116,f=isNaN(l)?p:p+l/500,m=isNaN(c)?p:p-c/200;return p=1*ur(p),f=ji*ur(f),m=Ni*ur(m),[ar(3.1338561*f-1.6168667*p-.4906146*m),ar(-.9787684*f+1.9161415*p+.033454*m),ar(.0719453*f-.2289914*p+1.4052427*m),d]}function ar(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function ur(e){return e>Ui?e*e*e:qi*(e-Gi)}const gr=Object.hasOwn||function(e,l){return Object.prototype.hasOwnProperty.call(e,l)};function vr(e,l){return gr(e,l)?e[l]:void 0}function wr(e){return parseInt(e.padEnd(2,e),16)/255}function Cr(e,l){return Dr(l?e/100:e,0,1)}function Dr(e,l,c){return Math.min(Math.max(l,e),c)}function zr(e){return!e.some(Number.isNaN)}const kr={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 Lr(e,l,c){return e+c*(l-e)}function qr(e,l,c){return e.map(((e,d)=>Lr(e,l[d],c)))}class Te{constructor(e,l,c,d=1,p=!0){this.r=e,this.g=l,this.b=c,this.a=d,p||(this.r*=d,this.g*=d,this.b*=d,d||this.overwriteGetter("rgb",[e,l,c,d]))}static parse(e){if(e instanceof Te)return e;if("string"!=typeof e)return;const l=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const l=vr(kr,e);if(l){const[e,c,d]=l;return[e/255,c/255,d/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const l=e.length<6?1:2;let c=1;return[wr(e.slice(c,c+=l)),wr(e.slice(c,c+=l)),wr(e.slice(c,c+=l)),wr(e.slice(c,c+l)||"ff")]}if(e.startsWith("rgb")){const l=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(l){const[e,c,d,p,f,m,_,g,y,b,T,S]=l,P=[p||" ",_||" ",b].join("");if(" "===P||" /"===P||",,"===P||",,,"===P){const e=[d,m,y].join(""),l="%%%"===e?100:""===e?255:0;if(l){const e=[Dr(+c/l,0,1),Dr(+f/l,0,1),Dr(+g/l,0,1),T?Cr(+T,S):1];if(zr(e))return e}}return}}const c=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(c){const[e,l,d,p,f,m,_,g,y]=c,b=[d||" ",f||" ",_].join("");if(" "===b||" /"===b||",,"===b||",,,"===b){const e=[+l,Dr(+p,0,100),Dr(+m,0,100),g?Cr(+g,y):1];if(zr(e))return function([e,l,c,d]){function p(d){const p=(d+e/30)%12,f=l*Math.min(c,1-c);return c-f*Math.max(-1,Math.min(p-3,9-p,1))}return e=Xi(e),l/=100,c/=100,[p(0),p(8),p(4),d]}(e)}}}(e);return l?new Te(...l,!1):void 0}get rgb(){const{r:e,g:l,b:c,a:d}=this,p=d||1/0;return this.overwriteGetter("rgb",[e/p,l/p,c/p,d])}get hcl(){return this.overwriteGetter("hcl",function(e){const[l,c,d,p]=Yi(e),f=Math.sqrt(c*c+d*d);return[Math.round(1e4*f)?Xi(Math.atan2(d,c)*Hi):NaN,f,l,p]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Yi(this.rgb))}overwriteGetter(e,l){return Object.defineProperty(this,e,{value:l}),l}toString(){const[e,l,c,d]=this.rgb;return`rgba(${[e,l,c].map((e=>Math.round(255*e))).join(",")},${d})`}static interpolate(e,l,c,d="rgb"){switch(d){case"rgb":{const[d,p,f,m]=qr(e.rgb,l.rgb,c);return new Te(d,p,f,m,!1)}case"hcl":{const[d,p,f,m]=e.hcl,[_,g,y,b]=l.hcl;let T,S;if(isNaN(d)||isNaN(_))isNaN(d)?isNaN(_)?T=NaN:(T=_,1!==f&&0!==f||(S=g)):(T=d,1!==y&&0!==y||(S=p));else{let e=_-d;_>d&&e>180?e-=360:_180&&(e+=360),T=d+c*e}const[P,I,C,R]=function([e,l,c,d]){return e=isNaN(e)?0:e*Wi,Ji([c,Math.cos(e)*l,Math.sin(e)*l,d])}([T,null!=S?S:Lr(p,g,c),Lr(f,y,c),Lr(m,b,c)]);return new Te(P,I,C,R,!1)}case"lab":{const[d,p,f,m]=Ji(qr(e.lab,l.lab,c));return new Te(d,p,f,m,!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,l,c){this.sensitivity=e?l?"variant":"case":l?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,l){return this.collator.compare(e,l)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const $r=["bottom","center","top"];class Fe{constructor(e,l,c,d,p,f){this.text=e,this.image=l,this.scale=c,this.fontStack=d,this.textColor=p,this.verticalAlign=f}}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 l of e)if("number"!=typeof l)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,l,c){return new ze(qr(e.values,l.values,c))}}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 l of e)if("number"!=typeof l)return;return new Pe(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,l,c){return new Pe(qr(e.values,l.values,c))}}class Be{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Be)return e;if("string"==typeof e){const l=Te.parse(e);if(!l)return;return new Be([l])}if(!Array.isArray(e))return;const l=[];for(const c of e){if("string"!=typeof c)return;const e=Te.parse(c);if(!e)return;l.push(e)}return new Be(l)}toString(){return JSON.stringify(this.values)}static interpolate(e,l,c,d="rgb"){const p=[];if(e.values.length!=l.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${l.values.length}), cannot interpolate.`);for(let f=0;f=0&&e<=255&&"number"==typeof l&&l>=0&&l<=255&&"number"==typeof c&&c>=0&&c<=255?void 0===d||"number"==typeof d&&d>=0&&d<=1?null:`Invalid rgba value [${[e,l,c,d].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof d?[e,l,c,d]:[e,l,c]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function tn(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 l of e)if(!tn(l))return!1;return!0}if("object"==typeof e){for(const l in e)if(!tn(e[l]))return!1;return!0}return!1}function rn(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 l=e.length;let c;for(const l of e){const e=rn(l);if(c){if(c===e)continue;c=_i;break}c=e}return Ei(c||_i,l)}return mi}function nn(e){const l=typeof e;return null===e?"":"string"===l||"number"===l||"boolean"===l?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,l){this.type=e,this.value=l}static parse(e,l){if(2!==e.length)return l.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!tn(e[1]))return l.error("invalid value");const c=e[1];let d=rn(c);const p=l.expectedType;return"array"!==d.kind||0!==d.N||!p||"array"!==p.kind||"number"==typeof p.N&&0!==p.N||(d=p),new je(d,c)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const sn={string:ci,number:li,boolean:ui,object:mi};class Xe{constructor(e,l){this.type=e,this.args=l}static parse(e,l){if(e.length<2)return l.error("Expected at least one argument.");let c,d=1;const p=e[0];if("array"===p){let p,f;if(e.length>2){const c=e[1];if("string"!=typeof c||!(c in sn)||"object"===c)return l.error('The item type argument of "array" must be one of string, number, boolean',1);p=sn[c],d++}else p=_i;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return l.error('The length argument to "array" must be a positive integer literal',2);f=e[2],d++}c=Ei(p,f)}else{if(!sn[p])throw new Error(`Types doesn't contain name = ${p}`);c=sn[p]}const f=[];for(;de.outputDefined()))}}const an={"to-boolean":ui,"to-color":pi,"to-number":li,"to-string":ci};class Ze{constructor(e,l){this.type=e,this.args=l}static parse(e,l){if(e.length<2)return l.error("Expected at least one argument.");const c=e[0];if(!an[c])throw new Error(`Can't parse ${c} as it is not part of the known types`);if(("to-boolean"===c||"to-string"===c)&&2!==e.length)return l.error("Expected one argument.");const d=an[c],p=[];for(let c=1;c4?`Invalid rgba value ${JSON.stringify(l)}: expected an array containing either three or four numeric values.`:en(l[0],l[1],l[2],l[3]),!c))return new Te(l[0]/255,l[1]/255,l[2]/255,l[3])}throw new Ve(c||`Could not parse color from value '${"string"==typeof l?l:JSON.stringify(l)}'`)}case"padding":{let l;for(const c of this.args){l=c.evaluate(e);const d=ze.parse(l);if(d)return d}throw new Ve(`Could not parse padding from value '${"string"==typeof l?l:JSON.stringify(l)}'`)}case"numberArray":{let l;for(const c of this.args){l=c.evaluate(e);const d=Pe.parse(l);if(d)return d}throw new Ve(`Could not parse numberArray from value '${"string"==typeof l?l:JSON.stringify(l)}'`)}case"colorArray":{let l;for(const c of this.args){l=c.evaluate(e);const d=Be.parse(l);if(d)return d}throw new Ve(`Could not parse colorArray from value '${"string"==typeof l?l:JSON.stringify(l)}'`)}case"variableAnchorOffsetCollection":{let l;for(const c of this.args){l=c.evaluate(e);const d=Le.parse(l);if(d)return d}throw new Ve(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof l?l:JSON.stringify(l)}'`)}case"number":{let l=null;for(const c of this.args){if(l=c.evaluate(e),null===l)return 0;const d=Number(l);if(!isNaN(d))return d}throw new Ve(`Could not convert ${JSON.stringify(l)} to number.`)}case"formatted":return De.fromString(nn(this.args[0].evaluate(e)));case"resolvedImage":return Oe.fromString(nn(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return nn(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const ln=["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?ln[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 l=this._parseColorCache.get(e);return l||(l=Te.parse(e),this._parseColorCache.set(e,l)),l}}class We{constructor(e,l,c=[],d,p=new Bt,f=[]){this.registry=e,this.path=c,this.key=c.map((e=>`[${e}]`)).join(""),this.scope=p,this.errors=f,this.expectedType=d,this._isConstant=l}parse(e,l,c,d,p={}){return l?this.concat(l,c,d)._parse(e,p):this._parse(e,p)}_parse(e,l){function c(e,l,c){return"assert"===c?new Xe(l,[e]):"coerce"===c?new Ze(l,[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 d=e[0];if("string"!=typeof d)return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const p=this.registry[d];if(p){let d=p.parse(e,this);if(!d)return null;if(this.expectedType){const e=this.expectedType,p=d.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==p.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(p.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(p.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(p.kind)||"colorArray"===e.kind&&["value","string","array"].includes(p.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(p.kind))d=c(d,e,l.typeAnnotation||"coerce");else if(this.checkSubtype(e,p))return null}else d=c(d,e,l.typeAnnotation||"assert")}if(!(d instanceof je)&&"resolvedImage"!==d.type.kind&&this._isConstant(d)){const l=new Ke;try{d=new je(d.type,d.evaluate(l))}catch(e){return this.error(e.message),null}}return d}return this.error(`Unknown expression "${d}". 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,l,c){const d="number"==typeof e?this.path.concat(e):this.path,p=c?this.scope.concat(c):this.scope;return new We(this.registry,this._isConstant,d,l||null,p,this.errors)}error(e,...l){const c=`${this.key}${l.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Pt(c,e))}checkSubtype(e,l){const c=Li(e,l);return c&&this.error(c),c}}class Je{constructor(e,l){this.type=l.type,this.bindings=[].concat(e),this.result=l}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const l of this.bindings)e(l[1]);e(this.result)}static parse(e,l){if(e.length<4)return l.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const c=[];for(let d=1;d=c.length)throw new Ve(`Array index out of bounds: ${l} > ${c.length-1}.`);if(l!==Math.floor(l))throw new Ve(`Array index must be an integer, but found ${l} instead.`);return c[l]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class er{constructor(e,l){this.type=ui,this.needle=e,this.haystack=l}static parse(e,l){if(3!==e.length)return l.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const c=l.parse(e[1],1,_i),d=l.parse(e[2],2,_i);return c&&d?Fi(c.type,[ui,ci,li,ni,_i])?new er(c,d):l.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(c.type)} instead`):null}evaluate(e){const l=this.needle.evaluate(e),c=this.haystack.evaluate(e);if(!c)return!1;if(!Oi(l,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(rn(l))} instead.`);if(!Oi(c,["string","array"]))throw new Ve(`Expected second argument to be of type array or string, but found ${Ci(rn(c))} instead.`);return c.indexOf(l)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class rr{constructor(e,l,c){this.type=li,this.needle=e,this.haystack=l,this.fromIndex=c}static parse(e,l){if(e.length<=2||e.length>=5)return l.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const c=l.parse(e[1],1,_i),d=l.parse(e[2],2,_i);if(!c||!d)return null;if(!Fi(c.type,[ui,ci,li,ni,_i]))return l.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(c.type)} instead`);if(4===e.length){const p=l.parse(e[3],3,li);return p?new rr(c,d,p):null}return new rr(c,d)}evaluate(e){const l=this.needle.evaluate(e),c=this.haystack.evaluate(e);if(!Oi(l,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(rn(l))} instead.`);let d;if(this.fromIndex&&(d=this.fromIndex.evaluate(e)),Oi(c,["string"])){const e=c.indexOf(l,d);return-1===e?-1:[...c.slice(0,e)].length}if(Oi(c,["array"]))return c.indexOf(l,d);throw new Ve(`Expected second argument to be of type array or string, but found ${Ci(rn(c))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class nr{constructor(e,l,c,d,p,f){this.inputType=e,this.type=l,this.input=c,this.cases=d,this.outputs=p,this.otherwise=f}static parse(e,l){if(e.length<5)return l.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return l.error("Expected an even number of arguments.");let c,d;l.expectedType&&"value"!==l.expectedType.kind&&(d=l.expectedType);const p={},f=[];for(let m=2;mNumber.MAX_SAFE_INTEGER)return y.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return y.error("Numeric branch labels must be integer values.");if(c){if(y.checkSubtype(c,rn(e)))return null}else c=rn(e);if(void 0!==p[String(e)])return y.error("Branch labels must be unique.");p[String(e)]=f.length}const b=l.parse(g,m,d);if(!b)return null;d=d||b.type,f.push(b)}const m=l.parse(e[1],1,_i);if(!m)return null;const _=l.parse(e[e.length-1],e.length-1,d);return _?"value"!==m.type.kind&&l.concat(1).checkSubtype(c,m.type)?null:new nr(c,d,m,p,f,_):null}evaluate(e){const l=this.input.evaluate(e);return(rn(l)===this.inputType&&this.outputs[this.cases[l]]||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,l,c){this.type=e,this.branches=l,this.otherwise=c}static parse(e,l){if(e.length<4)return l.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return l.error("Expected an odd number of arguments.");let c;l.expectedType&&"value"!==l.expectedType.kind&&(c=l.expectedType);const d=[];for(let p=1;pl.outputDefined()))&&this.otherwise.outputDefined()}}class sr{constructor(e,l,c,d){this.type=e,this.input=l,this.beginIndex=c,this.endIndex=d}static parse(e,l){if(e.length<=2||e.length>=5)return l.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const c=l.parse(e[1],1,_i),d=l.parse(e[2],2,li);if(!c||!d)return null;if(!Fi(c.type,[Ei(_i),ci,_i]))return l.error(`Expected first argument to be of type array or string, but found ${Ci(c.type)} instead`);if(4===e.length){const p=l.parse(e[3],3,li);return p?new sr(c.type,c,d,p):null}return new sr(c.type,c,d)}evaluate(e){const l=this.input.evaluate(e),c=this.beginIndex.evaluate(e);let d;if(this.endIndex&&(d=this.endIndex.evaluate(e)),Oi(l,["string"]))return[...l].slice(c,d).join("");if(Oi(l,["array"]))return l.slice(c,d);throw new Ve(`Expected first argument to be of type array or string, but found ${Ci(rn(l))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function cn(e,l){const c=e.length-1;let d,p,f=0,m=c,_=0;for(;f<=m;)if(_=Math.floor((f+m)/2),d=e[_],p=e[_+1],d<=l){if(_===c||ll))throw new Ve("Input is not a number.");m=_-1}return 0}class or{constructor(e,l,c){this.type=e,this.input=l,this.labels=[],this.outputs=[];for(const[e,l]of c)this.labels.push(e),this.outputs.push(l)}static parse(e,l){if(e.length-1<4)return l.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return l.error("Expected an even number of arguments.");const c=l.parse(e[1],1,li);if(!c)return null;const d=[];let p=null;l.expectedType&&"value"!==l.expectedType.kind&&(p=l.expectedType);for(let c=1;c=f)return l.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',_);const y=l.parse(m,g,p);if(!y)return null;p=p||y.type,d.push([f,y])}return new or(p,c,d)}evaluate(e){const l=this.labels,c=this.outputs;if(1===l.length)return c[0].evaluate(e);const d=this.input.evaluate(e);if(d<=l[0])return c[0].evaluate(e);const p=l.length;return d>=l[p-1]?c[p-1].evaluate(e):c[cn(l,d)].evaluate(e)}eachChild(e){e(this.input);for(const l of this.outputs)e(l)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function hn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var un,dn,pn=function(){if(dn)return un;function l(l,c,d,p){(this||e).cx=3*l,(this||e).bx=3*(d-l)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*c,(this||e).by=3*(p-c)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=l,(this||e).p1y=c,(this||e).p2x=d,(this||e).p2y=p}return dn=1,un=l,l.prototype={sampleCurveX:function(l){return(((this||e).ax*l+(this||e).bx)*l+(this||e).cx)*l},sampleCurveY:function(l){return(((this||e).ay*l+(this||e).by)*l+(this||e).cy)*l},sampleCurveDerivativeX:function(l){return(3*(this||e).ax*l+2*(this||e).bx)*l+(this||e).cx},solveCurveX:function(e,l){if(void 0===l&&(l=1e-6),e<0)return 0;if(e>1)return 1;for(var c=e,d=0;d<8;d++){var p=this.sampleCurveX(c)-e;if(Math.abs(p)p?m=c:_=c,c=.5*(_-m)+m;return c},solve:function(e,l){return this.sampleCurveY(this.solveCurveX(e,l))}},un}(),fn=hn(pn);class fr{constructor(e,l,c,d,p){this.type=e,this.operator=l,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[];for(const[e,l]of p)this.labels.push(e),this.outputs.push(l)}static interpolationFactor(e,l,c,d){let p=0;if("exponential"===e.name)p=mn(l,e.base,c,d);else if("linear"===e.name)p=mn(l,1,c,d);else if("cubic-bezier"===e.name){const f=e.controlPoints;p=new fn(f[0],f[1],f[2],f[3]).solve(mn(l,1,c,d))}return p}static parse(e,l){let[c,d,p,...f]=e;if(!Array.isArray(d)||0===d.length)return l.error("Expected an interpolation type expression.",1);if("linear"===d[0])d={name:"linear"};else if("exponential"===d[0]){const e=d[1];if("number"!=typeof e)return l.error("Exponential interpolation requires a numeric base.",1,1);d={name:"exponential",base:e}}else{if("cubic-bezier"!==d[0])return l.error(`Unknown interpolation type ${String(d[0])}`,1,0);{const e=d.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return l.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);d={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return l.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return l.error("Expected an even number of arguments.");if(p=l.parse(p,2,li),!p)return null;const m=[];let _=null;"interpolate-hcl"!==c&&"interpolate-lab"!==c||l.expectedType==vi?l.expectedType&&"value"!==l.expectedType.kind&&(_=l.expectedType):_=pi;for(let e=0;e=c)return l.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',p);const y=l.parse(d,g,_);if(!y)return null;_=_||y.type,m.push([c,y])}return Vi(_,li)||Vi(_,fi)||Vi(_,pi)||Vi(_,xi)||Vi(_,bi)||Vi(_,vi)||Vi(_,Ii)||Vi(_,Ei(li))?new fr(_,c,d,p,m):l.error(`Type ${Ci(_)} is not interpolatable.`)}evaluate(e){const l=this.labels,c=this.outputs;if(1===l.length)return c[0].evaluate(e);const d=this.input.evaluate(e);if(d<=l[0])return c[0].evaluate(e);const p=l.length;if(d>=l[p-1])return c[p-1].evaluate(e);const f=cn(l,d),m=fr.interpolationFactor(this.interpolation,d,l[f],l[f+1]),_=c[f].evaluate(e),g=c[f+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Lr(_,g,m);case"color":return Te.interpolate(_,g,m);case"padding":return ze.interpolate(_,g,m);case"colorArray":return Be.interpolate(_,g,m);case"numberArray":return Pe.interpolate(_,g,m);case"variableAnchorOffsetCollection":return Le.interpolate(_,g,m);case"array":return qr(_,g,m);case"projectionDefinition":return Re.interpolate(_,g,m)}case"interpolate-hcl":switch(this.type.kind){case"color":return Te.interpolate(_,g,m,"hcl");case"colorArray":return Be.interpolate(_,g,m,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Te.interpolate(_,g,m,"lab");case"colorArray":return Be.interpolate(_,g,m,"lab")}}}eachChild(e){e(this.input);for(const l of this.outputs)e(l)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function mn(e,l,c,d){const p=d-c,f=e-c;return 0===p?0:1===l?f/p:(Math.pow(l,f)-1)/(Math.pow(l,p)-1)}const _n={color:Te.interpolate,number:Lr,padding:ze.interpolate,numberArray:Pe.interpolate,colorArray:Be.interpolate,variableAnchorOffsetCollection:Le.interpolate,array:qr};class mr{constructor(e,l){this.type=e,this.args=l}static parse(e,l){if(e.length<2)return l.error("Expected at least one argument.");let c=null;const d=l.expectedType;d&&"value"!==d.kind&&(c=d);const p=[];for(const d of e.slice(1)){const e=l.parse(d,1+p.length,c,void 0,{typeAnnotation:"omit"});if(!e)return null;c=c||e.type,p.push(e)}if(!c)throw new Error("No output type");const f=d&&p.some((e=>Li(d,e.type)));return new mr(f?_i:c,p)}evaluate(e){let l,c=null,d=0;for(const p of this.args)if(d++,c=p.evaluate(e),c&&c instanceof Oe&&!c.available&&(l||(l=c.name),c=null,d===this.args.length&&(c=l)),null!==c)break;return c}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function gn(e,l){return"=="===e||"!="===e?"boolean"===l.kind||"string"===l.kind||"number"===l.kind||"null"===l.kind||"value"===l.kind:"string"===l.kind||"number"===l.kind||"value"===l.kind}function yn(e,l,c,d){return 0===d.compare(l,c)}function xn(e,l,c){const d="=="!==e&&"!="!==e;return class i{constructor(e,l,c){this.type=ui,this.lhs=e,this.rhs=l,this.collator=c,this.hasUntypedArgument="value"===e.type.kind||"value"===l.type.kind}static parse(e,l){if(3!==e.length&&4!==e.length)return l.error("Expected two or three arguments.");const c=e[0];let p=l.parse(e[1],1,_i);if(!p)return null;if(!gn(c,p.type))return l.concat(1).error(`"${c}" comparisons are not supported for type '${Ci(p.type)}'.`);let f=l.parse(e[2],2,_i);if(!f)return null;if(!gn(c,f.type))return l.concat(2).error(`"${c}" comparisons are not supported for type '${Ci(f.type)}'.`);if(p.type.kind!==f.type.kind&&"value"!==p.type.kind&&"value"!==f.type.kind)return l.error(`Cannot compare types '${Ci(p.type)}' and '${Ci(f.type)}'.`);d&&("value"===p.type.kind&&"value"!==f.type.kind?p=new Xe(f.type,[p]):"value"!==p.type.kind&&"value"===f.type.kind&&(f=new Xe(p.type,[f])));let m=null;if(4===e.length){if("string"!==p.type.kind&&"string"!==f.type.kind&&"value"!==p.type.kind&&"value"!==f.type.kind)return l.error("Cannot use collator to compare non-string types.");if(m=l.parse(e[3],3,gi),!m)return null}return new i(p,f,m)}evaluate(p){const f=this.lhs.evaluate(p),m=this.rhs.evaluate(p);if(d&&this.hasUntypedArgument){const l=rn(f),c=rn(m);if(l.kind!==c.kind||"string"!==l.kind&&"number"!==l.kind)throw new Ve(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${l.kind}, ${c.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const e=rn(f),c=rn(m);if("string"!==e.kind||"string"!==c.kind)return l(p,f,m)}return this.collator?c(p,f,m,this.collator.evaluate(p)):l(p,f,m)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const vn=xn("==",(function(e,l,c){return l===c}),yn),bn=xn("!=",(function(e,l,c){return l!==c}),(function(e,l,c,d){return!yn(0,l,c,d)})),wn=xn("<",(function(e,l,c){return l",(function(e,l,c){return l>c}),(function(e,l,c,d){return d.compare(l,c)>0})),Sn=xn("<=",(function(e,l,c){return l<=c}),(function(e,l,c,d){return d.compare(l,c)<=0})),Pn=xn(">=",(function(e,l,c){return l>=c}),(function(e,l,c,d){return d.compare(l,c)>=0}));class Er{constructor(e,l,c){this.type=gi,this.locale=c,this.caseSensitive=e,this.diacriticSensitive=l}static parse(e,l){if(2!==e.length)return l.error("Expected one argument.");const c=e[1];if("object"!=typeof c||Array.isArray(c))return l.error("Collator options argument must be an object.");const d=l.parse(void 0!==c["case-sensitive"]&&c["case-sensitive"],1,ui);if(!d)return null;const p=l.parse(void 0!==c["diacritic-sensitive"]&&c["diacritic-sensitive"],1,ui);if(!p)return null;let f=null;return c.locale&&(f=l.parse(c.locale,1,ci),!f)?null:new Er(d,p,f)}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,l,c,d,p){this.type=ci,this.number=e,this.locale=l,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=p}static parse(e,l){if(3!==e.length)return l.error("Expected two arguments.");const c=l.parse(e[1],1,li);if(!c)return null;const d=e[2];if("object"!=typeof d||Array.isArray(d))return l.error("NumberFormat options argument must be an object.");let p=null;if(d.locale&&(p=l.parse(d.locale,1,ci),!p))return null;let f=null;if(d.currency&&(f=l.parse(d.currency,1,ci),!f))return null;let m=null;if(d["min-fraction-digits"]&&(m=l.parse(d["min-fraction-digits"],1,li),!m))return null;let _=null;return d["max-fraction-digits"]&&(_=l.parse(d["max-fraction-digits"],1,li),!_)?null:new Tr(c,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,l){if(e.length<2)return l.error("Expected at least one argument.");const c=e[1];if(!Array.isArray(c)&&"object"==typeof c)return l.error("First argument must be an image or text section.");const d=[];let p=!1;for(let c=1;c<=e.length-1;++c){const f=e[c];if(p&&"object"==typeof f&&!Array.isArray(f)){p=!1;let e=null;if(f["font-scale"]&&(e=l.parse(f["font-scale"],1,li),!e))return null;let c=null;if(f["text-font"]&&(c=l.parse(f["text-font"],1,Ei(ci)),!c))return null;let m=null;if(f["text-color"]&&(m=l.parse(f["text-color"],1,pi),!m))return null;let _=null;if(f["vertical-align"]){if("string"==typeof f["vertical-align"]&&!$r.includes(f["vertical-align"]))return l.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${f["vertical-align"]}' instead.`);if(_=l.parse(f["vertical-align"],1,ci),!_)return null}const g=d[d.length-1];g.scale=e,g.font=c,g.textColor=m,g.verticalAlign=_}else{const f=l.parse(e[c],1,_i);if(!f)return null;const m=f.type.kind;if("string"!==m&&"value"!==m&&"null"!==m&&"resolvedImage"!==m)return l.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");p=!0,d.push({content:f,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Ir(d)}evaluate(e){return new De(this.sections.map((l=>{const c=l.content.evaluate(e);return rn(c)===wi?new Fe("",c,null,null,null,l.verticalAlign?l.verticalAlign.evaluate(e):null):new Fe(nn(c),null,l.scale?l.scale.evaluate(e):null,l.font?l.font.evaluate(e).join(","):null,l.textColor?l.textColor.evaluate(e):null,l.verticalAlign?l.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const l of this.sections)e(l.content),l.scale&&e(l.scale),l.font&&e(l.font),l.textColor&&e(l.textColor),l.verticalAlign&&e(l.verticalAlign)}outputDefined(){return!1}}class Mr{constructor(e){this.type=wi,this.input=e}static parse(e,l){if(2!==e.length)return l.error("Expected two arguments.");const c=l.parse(e[1],1,ci);return c?new Mr(c):l.error("No image name provided.")}evaluate(e){const l=this.input.evaluate(e),c=Oe.fromString(l);return c&&e.availableImages&&(c.available=e.availableImages.indexOf(l)>-1),c}eachChild(e){e(this.input)}outputDefined(){return!1}}class Fr{constructor(e){this.type=li,this.input=e}static parse(e,l){if(2!==e.length)return l.error(`Expected 1 argument, but found ${e.length-1} instead.`);const c=l.parse(e[1],1);return c?"array"!==c.type.kind&&"string"!==c.type.kind&&"value"!==c.type.kind?l.error(`Expected argument of type string or array, but found ${Ci(c.type)} instead.`):new Fr(c):null}evaluate(e){const l=this.input.evaluate(e);if("string"==typeof l)return[...l].length;if(Array.isArray(l))return l.length;throw new Ve(`Expected value to be of type string or array, but found ${Ci(rn(l))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const In=8192;function En(e,l){const c=(180+e[0])/360,d=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,p=Math.pow(2,l.z);return[Math.round(c*p*In),Math.round(d*p*In)]}function Cn(e,l){const c=Math.pow(2,l.z);return[(p=(e[0]/In+l.x)/c,360*p-180),(d=(e[1]/In+l.y)/c,360/Math.PI*Math.atan(Math.exp((180-360*d)*Math.PI/180))-90)];var d,p}function An(e,l){e[0]=Math.min(e[0],l[0]),e[1]=Math.min(e[1],l[1]),e[2]=Math.max(e[2],l[0]),e[3]=Math.max(e[3],l[1])}function Dn(e,l){return!(e[0]<=l[0]||e[2]>=l[2]||e[1]<=l[1]||e[3]>=l[3])}function kn(e,l,c){const d=e[0]-l[0],p=e[1]-l[1],f=e[0]-c[0],m=e[1]-c[1];return d*m-f*p==0&&d*f<=0&&p*m<=0}function Rn(e,l,c,d){return 0!=(p=[d[0]-c[0],d[1]-c[1]])[0]*(f=[l[0]-e[0],l[1]-e[1]])[1]-p[1]*f[0]&&!(!Nn(e,l,c,d)||!Nn(c,d,e,l));var p,f}function Ln(e,l,c){for(const d of c)for(let c=0;c(p=e)[1]!=(m=_[l+1])[1]>p[1]&&p[0]<(m[0]-f[0])*(p[1]-f[1])/(m[1]-f[1])+f[0]&&(d=!d)}var p,f,m;return d}function On(e,l){for(const c of l)if(Bn(e,c))return!0;return!1}function Vn(e,l){for(const c of e)if(!Bn(c,l))return!1;for(let c=0;c0&&_<0||m<0&&_>0}function Gn(e,l,c){const d=[];for(let p=0;pc[2]){const l=.5*d;let p=e[0]-c[0]>l?-d:c[0]-e[0]>l?d:0;0===p&&(p=e[0]-c[2]>l?-d:c[2]-e[0]>l?d:0),e[0]+=p}An(l,e)}function Zn(e,l,c,d){const p=Math.pow(2,d.z)*In,f=[d.x*In,d.y*In],m=[];for(const d of e)for(const e of d){const d=[e.x+f[0],e.y+f[1]];qn(d,l,c,p),m.push(d)}return m}function $n(e,l,c,d){const p=Math.pow(2,d.z)*In,f=[d.x*In,d.y*In],m=[];for(const c of e){const e=[];for(const d of c){const c=[d.x+f[0],d.y+f[1]];An(l,c),e.push(c)}m.push(e)}if(l[2]-l[0]<=p/2){(_=l)[0]=_[1]=1/0,_[2]=_[3]=-1/0;for(const e of m)for(const d of e)qn(d,l,c,p)}var _;return m}class Hr{constructor(e,l){this.type=ui,this.geojson=e,this.geometries=l}static parse(e,l){if(2!==e.length)return l.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(tn(e[1])){const l=e[1];if("FeatureCollection"===l.type){const e=[];for(const c of l.features){const{type:l,coordinates:d}=c.geometry;"Polygon"===l&&e.push(d),"MultiPolygon"===l&&e.push(...d)}if(e.length)return new Hr(l,{type:"MultiPolygon",coordinates:e})}else if("Feature"===l.type){const e=l.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Hr(l,l.geometry)}else if("Polygon"===l.type||"MultiPolygon"===l.type)return new Hr(l,l)}return l.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,l){const c=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],p=e.canonicalID();if("Polygon"===l.type){const f=Gn(l.coordinates,d,p),m=Zn(e.geometry(),c,d,p);if(!Dn(c,d))return!1;for(const e of m)if(!Bn(e,f))return!1}if("MultiPolygon"===l.type){const f=Un(l.coordinates,d,p),m=Zn(e.geometry(),c,d,p);if(!Dn(c,d))return!1;for(const e of m)if(!On(e,f))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,l){const c=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],p=e.canonicalID();if("Polygon"===l.type){const f=Gn(l.coordinates,d,p),m=$n(e.geometry(),c,d,p);if(!Dn(c,d))return!1;for(const e of m)if(!Vn(e,f))return!1}if("MultiPolygon"===l.type){const f=Un(l.coordinates,d,p),m=$n(e.geometry(),c,d,p);if(!Dn(c,d))return!1;for(const e of m)if(!jn(e,f))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Wn=class{constructor(e=[],l=(e,l)=>el?1:0){if(this.data=e,this.length=this.data.length,this.compare=l,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],l=this.data.pop();return--this.length>0&&(this.data[0]=l,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:l,compare:c}=this,d=l[e];for(;e>0;){const p=e-1>>1,f=l[p];if(c(d,f)>=0)break;l[e]=f,e=p}l[e]=d}_down(e){const{data:l,compare:c}=this,d=this.length>>1,p=l[e];for(;e=0)break;l[e]=l[d],e=d}l[e]=p}};function Hn(e,l,c=0,d=e.length-1,p=Yn){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);Hn(e,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=e[l];let m=c,_=d;for(Xn(e,c,l),p(e[d],f)>0&&Xn(e,c,d);m<_;){for(Xn(e,m,_),m++,_--;p(e[m],f)<0;)m++;for(;p(e[_],f)>0;)_--}0===p(e[c],f)?Xn(e,c,_):(_++,Xn(e,_,d)),_<=l&&(c=_+1),l<=_&&(d=_-1)}}function Xn(e,l,c){const d=e[l];e[l]=e[c],e[c]=d}function Yn(e,l){return el?1:0}function Kn(e,l){if(e.length<=1)return[e];const c=[];let d,p;for(const l of e){const e=Jn(l);0!==e&&(l.area=Math.abs(e),void 0===p&&(p=e<0),p===e<0?(d&&c.push(d),d=[l]):d.push(l))}if(d&&c.push(d),l>1)for(let e=0;e1?(g=e[_+1][0],y=e[_+1][1]):S>0&&(g+=b/this.kx*S,y+=T/this.ky*S)),b=this.wrap(l[0]-g)*this.kx,T=(l[1]-y)*this.ky;const P=b*b+T*T;P180;)e-=360;return e}}function os(e,l){return l[0]-e[0]}function ls(e){return e[1]-e[0]+1}function us(e,l){return e[1]>=e[0]&&e[1]e[1])return[null,null];const c=ls(e);if(l){if(2===c)return[e,null];const l=Math.floor(c/2);return[[e[0],e[0]+l],[e[0]+l,e[1]]]}if(1===c)return[e,null];const d=Math.floor(c/2)-1;return[[e[0],e[0]+d],[e[0]+d+1,e[1]]]}function ps(e,l){if(!us(l,e.length))return[1/0,1/0,-1/0,-1/0];const c=[1/0,1/0,-1/0,-1/0];for(let d=l[0];d<=l[1];++d)An(c,e[d]);return c}function fs(e){const l=[1/0,1/0,-1/0,-1/0];for(const c of e)for(const e of c)An(l,e);return l}function _s(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function gs(e,l,c){if(!_s(e)||!_s(l))return NaN;let d=0,p=0;return e[2]l[2]&&(d=e[0]-l[2]),e[1]>l[3]&&(p=e[1]-l[3]),e[3]=d)return d;if(Dn(p,f)){if(Ms(e,l))return 0}else if(Ms(l,e))return 0;let m=1/0;for(const d of e)for(let e=0,p=d.length,f=p-1;e0;){const p=m.pop();if(p[0]>=f)continue;const g=p[1],y=l?50:100;if(ls(g)<=y){if(!us(g,e.length))return NaN;if(l){const l=Ss(e,g,c,d);if(isNaN(l)||0===l)return l;f=Math.min(f,l)}else for(let l=g[0];l<=g[1];++l){const p=Ts(e[l],c,d);if(f=Math.min(f,p),0===f)return 0}}else{const c=ds(g,l);Es(m,f,d,e,_,c[0]),Es(m,f,d,e,_,c[1])}}return f}function zs(e,l,c,d,p,f=1/0){let m=Math.min(f,p.distance(e[0],c[0]));if(0===m)return m;const _=new Wn([[0,[0,e.length-1],[0,c.length-1]]],os);for(;_.length>0;){const f=_.pop();if(f[0]>=m)continue;const g=f[1],y=f[2],b=l?50:100,T=d?50:100;if(ls(g)<=b&&ls(y)<=T){if(!us(g,e.length)&&us(y,c.length))return NaN;let f;if(l&&d)f=bs(e,g,c,y,p),m=Math.min(m,f);else if(l&&!d){const l=e.slice(g[0],g[1]+1);for(let e=y[0];e<=y[1];++e)if(f=ys(c[e],l,p),m=Math.min(m,f),0===m)return m}else if(!l&&d){const l=c.slice(y[0],y[1]+1);for(let c=g[0];c<=g[1];++c)if(f=ys(e[c],l,p),m=Math.min(m,f),0===m)return m}else f=ws(e,g,c,y,p),m=Math.min(m,f)}else{const f=ds(g,l),b=ds(y,d);As(_,m,p,e,c,f[0],b[0]),As(_,m,p,e,c,f[0],b[1]),As(_,m,p,e,c,f[1],b[0]),As(_,m,p,e,c,f[1],b[1])}}return m}function ks(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,l){this.type=li,this.geojson=e,this.geometries=l}static parse(e,l){if(2!==e.length)return l.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(tn(e[1])){const l=e[1];if("FeatureCollection"===l.type)return new Mn(l,l.features.map((e=>ks(e.geometry))).flat());if("Feature"===l.type)return new Mn(l,ks(l.geometry));if("type"in l&&"coordinates"in l)return new Mn(l,ks(l))}return l.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,l){const c=e.geometry(),d=c.flat().map((l=>Cn([l.x,l.y],e.canonical)));if(0===c.length)return NaN;const p=new on(d[0][1]);let f=1/0;for(const e of l){switch(e.type){case"Point":f=Math.min(f,zs(d,!1,[e.coordinates],!1,p,f));break;case"LineString":f=Math.min(f,zs(d,!1,e.coordinates,!0,p,f));break;case"Polygon":f=Math.min(f,Ds(d,!1,e.coordinates,p,f))}if(0===f)return f}return f}(e,this.geometries);if("LineString"===e.geometryType())return function(e,l){const c=e.geometry(),d=c.flat().map((l=>Cn([l.x,l.y],e.canonical)));if(0===c.length)return NaN;const p=new on(d[0][1]);let f=1/0;for(const e of l){switch(e.type){case"Point":f=Math.min(f,zs(d,!0,[e.coordinates],!1,p,f));break;case"LineString":f=Math.min(f,zs(d,!0,e.coordinates,!0,p,f));break;case"Polygon":f=Math.min(f,Ds(d,!0,e.coordinates,p,f))}if(0===f)return f}return f}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,l){const c=e.geometry();if(0===c.length||0===c[0].length)return NaN;const d=Kn(c,0).map((l=>l.map((l=>l.map((l=>Cn([l.x,l.y],e.canonical))))))),p=new on(d[0][0][0][1]);let f=1/0;for(const e of l)for(const l of d){switch(e.type){case"Point":f=Math.min(f,Ds([e.coordinates],!1,l,p,f));break;case"LineString":f=Math.min(f,Ds(e.coordinates,!0,l,p,f));break;case"Polygon":f=Math.min(f,Is(l,e.coordinates,p,f))}if(0===f)return f}return f}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Fn{constructor(e){this.type=_i,this.key=e}static parse(e,l){if(2!==e.length)return l.error(`Expected 1 argument, but found ${e.length-1} instead.`);const c=e[1];return null==c?l.error("Global state property must be defined."):"string"!=typeof c?l.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Fn(c)}evaluate(e){var l;const c=null===(l=e.globals)||void 0===l?void 0:l.globalState;return c&&0!==Object.keys(c).length?vr(c,this.key):null}eachChild(){}outputDefined(){return!1}}const Fs={"==":vn,"!=":bn,">":Tn,"<":wn,">=":Pn,"<=":Sn,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,l,c,d){this.name=e,this.type=l,this._evaluate=c,this.args=d}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,l){const c=e[0],d=zn.definitions[c];if(!d)return l.error(`Unknown expression "${c}". If you wanted a literal array, use ["literal", [...]].`,0);const p=Array.isArray(d)?d[0]:d.type,f=Array.isArray(d)?[[d[1],d[2]]]:d.overloads,m=f.filter((([l])=>!Array.isArray(l)||l.length===e.length-1));let _=null;for(const[d,f]of m){_=new We(l.registry,ro,l.path,null,l.scope);const m=[];let g=!1;for(let l=1;l{return l=e,Array.isArray(l)?`(${l.map(Ci).join(", ")})`:`(${Ci(l.type)}...)`;var l})).join(" | "),d=[];for(let c=1;c{c=l?c&&ro(e):c&&e instanceof je})),!!c&&lo(e)&&ho(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function lo(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 l=!0;return e.eachChild((e=>{l&&!lo(e)&&(l=!1)})),l}function co(e){if(e instanceof zn&&"feature-state"===e.name)return!1;let l=!0;return e.eachChild((e=>{l&&!co(e)&&(l=!1)})),l}function ho(e,l){if(e instanceof zn&&l.indexOf(e.name)>=0)return!1;let c=!0;return e.eachChild((e=>{c&&!ho(e,l)&&(c=!1)})),c}function uo(e){return{result:"success",value:e}}function po(e){return{result:"error",value:e}}function fo(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function mo(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function yo(e){return!!e.expression&&e.expression.interpolated}function xo(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function vo(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&rn(e)===mi}function bo(e){return e}function Eo(e,l){const c=e.stops&&"object"==typeof e.stops[0][0],d=c||!(c||void 0!==e.property),p=e.type||(yo(l)?"exponential":"interval"),f=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}}(l);if(f&&((e=ri({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],f(e[1])]))),e.default=f(e.default?e.default:l.default)),e.colorSpace&&"rgb"!==(m=e.colorSpace)&&"hcl"!==m&&"lab"!==m)throw new Error(`Unknown color space: "${e.colorSpace}"`);var m;const _=function(e){switch(e){case"exponential":return Lo;case"interval":return Ro;case"categorical":return ko;case"identity":return Oo;default:throw new Error(`Unknown function type "${e}"`)}}(p);let g,y;if("categorical"===p){g=Object.create(null);for(const l of e.stops)g[l[0]]=l[1];y=typeof e.stops[0][0]}if(c){const c={},d=[];for(let l=0;le[0])),evaluate:({zoom:c},d)=>Lo({stops:p,base:e.base},l,c).evaluate(c,d)}}if(d){const c="exponential"===p?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:c,interpolationFactor:fr.interpolationFactor.bind(void 0,c),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:c})=>_(e,l,c,g,y)}}return{kind:"source",evaluate(c,d){const p=d&&d.properties?d.properties[e.property]:void 0;return void 0===p?Co(e.default,l.default):_(e,l,p,g,y)}}}function Co(e,l,c){return void 0!==e?e:void 0!==l?l:void 0!==c?c:void 0}function ko(e,l,c,d,p){return Co(typeof c===p?d[c]:void 0,e.default,l.default)}function Ro(e,l,c){if("number"!==xo(c))return Co(e.default,l.default);const d=e.stops.length;if(1===d)return e.stops[0][1];if(c<=e.stops[0][0])return e.stops[0][1];if(c>=e.stops[d-1][0])return e.stops[d-1][1];const p=cn(e.stops.map((e=>e[0])),c);return e.stops[p][1]}function Lo(e,l,c){const d=void 0!==e.base?e.base:1;if("number"!==xo(c))return Co(e.default,l.default);const p=e.stops.length;if(1===p)return e.stops[0][1];if(c<=e.stops[0][0])return e.stops[0][1];if(c>=e.stops[p-1][0])return e.stops[p-1][1];const f=cn(e.stops.map((e=>e[0])),c),m=function(e,l,c,d){const p=d-c,f=e-c;return 0===p?0:1===l?f/p:(Math.pow(l,f)-1)/(Math.pow(l,p)-1)}(c,d,e.stops[f][0],e.stops[f+1][0]),_=e.stops[f][1],g=e.stops[f+1][1],y=_n[l.type]||bo;return"function"==typeof _.evaluate?{evaluate(...l){const c=_.evaluate.apply(void 0,l),d=g.evaluate.apply(void 0,l);if(void 0!==c&&void 0!==d)return y(c,d,m,e.colorSpace)}}:y(_,g,m,e.colorSpace)}function Oo(e,l,c){switch(l.type){case"color":c=Te.parse(c);break;case"formatted":c=De.fromString(c.toString());break;case"resolvedImage":c=Oe.fromString(c.toString());break;case"padding":c=ze.parse(c);break;case"colorArray":c=Be.parse(c);break;case"numberArray":c=Pe.parse(c);break;default:xo(c)===l.type||"enum"===l.type&&l.values[c]||(c=void 0)}return Co(c,e.default,l.default)}zn.register(Fs,{error:[{kind:"error"},[ci],(e,[l])=>{throw new Ve(l.evaluate(e))}],typeof:[ci,[_i],(e,[l])=>Ci(rn(l.evaluate(e)))],"to-rgba":[Ei(li,4),[pi],(e,[l])=>{const[c,d,p,f]=l.evaluate(e).rgb;return[255*c,255*d,255*p,f]}],rgb:[pi,[li,li,li],Bs],rgba:[pi,[li,li,li,li],Bs],has:{type:ui,overloads:[[[ci],(e,[l])=>Vs(l.evaluate(e),e.properties())],[[ci,mi],(e,[l,c])=>Vs(l.evaluate(e),c.evaluate(e))]]},get:{type:_i,overloads:[[[ci],(e,[l])=>Ws(l.evaluate(e),e.properties())],[[ci,mi],(e,[l,c])=>Ws(l.evaluate(e),c.evaluate(e))]]},"feature-state":[_i,[ci],(e,[l])=>Ws(l.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,Js(li),(e,l)=>{let c=0;for(const d of l)c+=d.evaluate(e);return c}],"*":[li,Js(li),(e,l)=>{let c=1;for(const d of l)c*=d.evaluate(e);return c}],"-":{type:li,overloads:[[[li,li],(e,[l,c])=>l.evaluate(e)-c.evaluate(e)],[[li],(e,[l])=>-l.evaluate(e)]]},"/":[li,[li,li],(e,[l,c])=>l.evaluate(e)/c.evaluate(e)],"%":[li,[li,li],(e,[l,c])=>l.evaluate(e)%c.evaluate(e)],ln2:[li,[],()=>Math.LN2],pi:[li,[],()=>Math.PI],e:[li,[],()=>Math.E],"^":[li,[li,li],(e,[l,c])=>Math.pow(l.evaluate(e),c.evaluate(e))],sqrt:[li,[li],(e,[l])=>Math.sqrt(l.evaluate(e))],log10:[li,[li],(e,[l])=>Math.log(l.evaluate(e))/Math.LN10],ln:[li,[li],(e,[l])=>Math.log(l.evaluate(e))],log2:[li,[li],(e,[l])=>Math.log(l.evaluate(e))/Math.LN2],sin:[li,[li],(e,[l])=>Math.sin(l.evaluate(e))],cos:[li,[li],(e,[l])=>Math.cos(l.evaluate(e))],tan:[li,[li],(e,[l])=>Math.tan(l.evaluate(e))],asin:[li,[li],(e,[l])=>Math.asin(l.evaluate(e))],acos:[li,[li],(e,[l])=>Math.acos(l.evaluate(e))],atan:[li,[li],(e,[l])=>Math.atan(l.evaluate(e))],min:[li,Js(li),(e,l)=>Math.min(...l.map((l=>l.evaluate(e))))],max:[li,Js(li),(e,l)=>Math.max(...l.map((l=>l.evaluate(e))))],abs:[li,[li],(e,[l])=>Math.abs(l.evaluate(e))],round:[li,[li],(e,[l])=>{const c=l.evaluate(e);return c<0?-Math.round(-c):Math.round(c)}],floor:[li,[li],(e,[l])=>Math.floor(l.evaluate(e))],ceil:[li,[li],(e,[l])=>Math.ceil(l.evaluate(e))],"filter-==":[ui,[ci,_i],(e,[l,c])=>e.properties()[l.value]===c.value],"filter-id-==":[ui,[_i],(e,[l])=>e.id()===l.value],"filter-type-==":[ui,[ci],(e,[l])=>e.geometryType()===l.value],"filter-<":[ui,[ci,_i],(e,[l,c])=>{const d=e.properties()[l.value],p=c.value;return typeof d==typeof p&&d{const c=e.id(),d=l.value;return typeof c==typeof d&&c":[ui,[ci,_i],(e,[l,c])=>{const d=e.properties()[l.value],p=c.value;return typeof d==typeof p&&d>p}],"filter-id->":[ui,[_i],(e,[l])=>{const c=e.id(),d=l.value;return typeof c==typeof d&&c>d}],"filter-<=":[ui,[ci,_i],(e,[l,c])=>{const d=e.properties()[l.value],p=c.value;return typeof d==typeof p&&d<=p}],"filter-id-<=":[ui,[_i],(e,[l])=>{const c=e.id(),d=l.value;return typeof c==typeof d&&c<=d}],"filter->=":[ui,[ci,_i],(e,[l,c])=>{const d=e.properties()[l.value],p=c.value;return typeof d==typeof p&&d>=p}],"filter-id->=":[ui,[_i],(e,[l])=>{const c=e.id(),d=l.value;return typeof c==typeof d&&c>=d}],"filter-has":[ui,[_i],(e,[l])=>l.value in e.properties()],"filter-has-id":[ui,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[ui,[Ei(ci)],(e,[l])=>l.value.indexOf(e.geometryType())>=0],"filter-id-in":[ui,[Ei(_i)],(e,[l])=>l.value.indexOf(e.id())>=0],"filter-in-small":[ui,[ci,Ei(_i)],(e,[l,c])=>c.value.indexOf(e.properties()[l.value])>=0],"filter-in-large":[ui,[ci,Ei(_i)],(e,[l,c])=>function(e,l,c,d){for(;c<=d;){const p=c+d>>1;if(l[p]===e)return!0;l[p]>e?d=p-1:c=p+1}return!1}(e.properties()[l.value],c.value,0,c.value.length-1)],all:{type:ui,overloads:[[[ui,ui],(e,[l,c])=>l.evaluate(e)&&c.evaluate(e)],[Js(ui),(e,l)=>{for(const c of l)if(!c.evaluate(e))return!1;return!0}]]},any:{type:ui,overloads:[[[ui,ui],(e,[l,c])=>l.evaluate(e)||c.evaluate(e)],[Js(ui),(e,l)=>{for(const c of l)if(c.evaluate(e))return!0;return!1}]]},"!":[ui,[ui],(e,[l])=>!l.evaluate(e)],"is-supported-script":[ui,[ci],(e,[l])=>{const c=e.globals&&e.globals.isSupportedScript;return!c||c(l.evaluate(e))}],upcase:[ci,[ci],(e,[l])=>l.evaluate(e).toUpperCase()],downcase:[ci,[ci],(e,[l])=>l.evaluate(e).toLowerCase()],concat:[ci,Js(_i),(e,l)=>l.map((l=>nn(l.evaluate(e)))).join("")],"resolved-locale":[ci,[gi],(e,[l])=>l.evaluate(e).resolvedLocale()]});class ei{constructor(e,l,c){this.expression=e,this._warningHistory={},this._evaluator=new Ke,this._defaultValue=l?function(e){if("color"===e.type&&vo(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}}(l):null,this._enumValues=l&&"enum"===l.type?l.values:null,this._globalState=c}evaluateWithoutErrorHandling(e,l,c,d,p,f){return this._globalState&&(e=$o(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=l,this._evaluator.featureState=c,this._evaluator.canonical=d,this._evaluator.availableImages=p||null,this._evaluator.formattedSection=f,this.expression.evaluate(this._evaluator)}evaluate(e,l,c,d,p,f){this._globalState&&(e=$o(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=l||null,this._evaluator.featureState=c||null,this._evaluator.canonical=d,this._evaluator.availableImages=p||null,this._evaluator.formattedSection=f||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 No(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Fs}function Go(e,l,c){const d=new We(Fs,ro,[],l?function(e){const l={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(l[e.value]||_i,e.length):l[e.type]}(l):void 0),p=d.parse(e,void 0,void 0,void 0,l&&"string"===l.type?{typeAnnotation:"coerce"}:void 0);return p?uo(new ei(p,l,c)):po(d.errors)}class ii{constructor(e,l,c){this.kind=e,this._styleExpression=l,this.isStateDependent="constant"!==e&&!co(l.expression),this.globalStateRefs=Zo(l.expression),this._globalState=c}evaluateWithoutErrorHandling(e,l,c,d,p,f){return this._globalState&&(e=$o(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,l,c,d,p,f)}evaluate(e,l,c,d,p,f){return this._globalState&&(e=$o(e,this._globalState)),this._styleExpression.evaluate(e,l,c,d,p,f)}}class si{constructor(e,l,c,d,p){this.kind=e,this.zoomStops=c,this._styleExpression=l,this.isStateDependent="camera"!==e&&!co(l.expression),this.globalStateRefs=Zo(l.expression),this.interpolationType=d,this._globalState=p}evaluateWithoutErrorHandling(e,l,c,d,p,f){return this._globalState&&(e=$o(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,l,c,d,p,f)}evaluate(e,l,c,d,p,f){return this._globalState&&(e=$o(e,this._globalState)),this._styleExpression.evaluate(e,l,c,d,p,f)}interpolationFactor(e,l,c){return this.interpolationType?fr.interpolationFactor(this.interpolationType,e,l,c):0}}function Uo(e,l,c){const d=Go(e,l,c);if("error"===d.result)return d;const p=d.value.expression,f=lo(p);if(!f&&!fo(l))return po([new Pt("","data expressions not supported")]);const m=ho(p,["zoom"]);if(!m&&!mo(l))return po([new Pt("","zoom expressions not supported")]);const _=qo(p);return _||m?_ instanceof Pt?po([_]):_ instanceof fr&&!yo(l)?po([new Pt("",'"interpolate" expressions cannot be used with this property')]):uo(_?new si(f?"camera":"composite",d.value,_.labels,_ instanceof fr?_.interpolation:void 0,c):new ii(f?"constant":"source",d.value,c)):po([new Pt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class oi{constructor(e,l){this._parameters=e,this._specification=l,ri(this,Eo(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 qo(e){let l=null;if(e instanceof Je)l=qo(e.result);else if(e instanceof mr){for(const c of e.args)if(l=qo(c),l)break}else(e instanceof or||e instanceof fr)&&e.input instanceof zn&&"zoom"===e.input.name&&(l=e);return l instanceof Pt||e.eachChild((e=>{const c=qo(e);c instanceof Pt?l=c:!l&&c?l=new Pt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):l&&c&&l!==c&&(l=new Pt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),l}function Zo(e,l=new Set){return e instanceof Fn&&l.add(e.key),e.eachChild((e=>{Zo(e,l)})),l}function $o(e,l){const{zoom:c,heatmapDensity:d,elevation:p,lineProgress:f,isSupportedScript:m,accumulated:_}=null!=e?e:{};return{zoom:c,heatmapDensity:d,elevation:p,lineProgress:f,isSupportedScript:m,accumulated:_,globalState:l}}function Xo(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 l of e.slice(1))if(!Xo(l)&&"boolean"!=typeof l)return!1;return!0;default:return!0}}const Yo={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Ko(e,l){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Xo(e)||(e=ta(e));const c=Go(e,Yo,l);if("error"===c.result)throw new Error(c.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,l,d)=>c.value.evaluate(e,l,{},d),needGeometry:Jo(e),getGlobalStateRefs:()=>Zo(c.value.expression)}}function Qo(e,l){return el?1:0}function Jo(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let l=1;l"===l||"<="===l||">="===l?ia(e[1],e[2],l):"any"===l?(c=e.slice(1),["any"].concat(c.map(ta))):"all"===l?["all"].concat(e.slice(1).map(ta)):"none"===l?["all"].concat(e.slice(1).map(ta).map(tl)):"in"===l?na(e[1],e.slice(2)):"!in"===l?tl(na(e[1],e.slice(2))):"has"===l?el(e[1]):"!has"!==l||tl(el(e[1]));var c}function ia(e,l,c){switch(e){case"$type":return[`filter-type-${c}`,l];case"$id":return[`filter-id-${c}`,l];default:return[`filter-${c}`,e,l]}}function na(e,l){if(0===l.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",l]];case"$id":return["filter-id-in",["literal",l]];default:return l.length>200&&!l.some((e=>typeof e!=typeof l[0]))?["filter-in-large",e,["literal",l.sort(Qo)]]:["filter-in-small",e,["literal",l]]}}function el(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function tl(e){return["!",e]}function il(e){const l=typeof e;if("number"===l||"boolean"===l||"string"===l||null==e)return JSON.stringify(e);if(Array.isArray(e)){let l="[";for(const c of e)l+=`${il(c)},`;return`${l}]`}const c=Object.keys(e).sort();let d="{";for(let l=0;ld.maximum?[new Dt(l,c,`${c} is greater than the maximum value ${d.maximum}`)]:[]}function hl(e){const l=e.valueSpec,c=sl(e.value.type);let d,p,f,m={};const _="categorical"!==c&&void 0===e.value.property,g=!_,y="array"===xo(e.value.stops)&&"array"===xo(e.value.stops[0])&&"object"===xo(e.value.stops[0][0]),b=al({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"===c)return[new Dt(e.key,e.value,'identity function may not have a "stops" property')];let l=[];const d=e.value;return l=l.concat(ll({key:e.key,value:d,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:T})),"array"===xo(d)&&0===d.length&&l.push(new Dt(e.key,d,"array must have at least one stop")),l},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:l,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===c&&_&&b.push(new Dt(e.key,e.value,'missing required property "property"')),"identity"===c||e.value.stops||b.push(new Dt(e.key,e.value,'missing required property "stops"')),"exponential"===c&&e.valueSpec.expression&&!yo(e.valueSpec)&&b.push(new Dt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(g&&!fo(e.valueSpec)?b.push(new Dt(e.key,e.value,"property functions not supported")):_&&!mo(e.valueSpec)&&b.push(new Dt(e.key,e.value,"zoom functions not supported"))),"categorical"!==c&&!y||void 0!==e.value.property||b.push(new Dt(e.key,e.value,'"property" property is required')),b;function T(e){let c=[];const d=e.value,_=e.key;if("array"!==xo(d))return[new Dt(_,d,`array expected, ${xo(d)} found`)];if(2!==d.length)return[new Dt(_,d,`array length 2 expected, length ${d.length} found`)];if(y){if("object"!==xo(d[0]))return[new Dt(_,d,`object expected, ${xo(d[0])} found`)];if(void 0===d[0].zoom)return[new Dt(_,d,"object stop key must have zoom")];if(void 0===d[0].value)return[new Dt(_,d,"object stop key must have value")];if(f&&f>sl(d[0].zoom))return[new Dt(_,d[0].zoom,"stop zoom values must appear in ascending order")];sl(d[0].zoom)!==f&&(f=sl(d[0].zoom),p=void 0,m={}),c=c.concat(al({key:`${_}[0]`,value:d[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:cl,value:S}}))}else c=c.concat(S({key:`${_}[0]`,value:d[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},d));return No(ol(d[1]))?c.concat([new Dt(`${_}[1]`,d[1],"expressions are not allowed in function stops.")]):c.concat(e.validateSpec({key:`${_}[1]`,value:d[1],valueSpec:l,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function S(e,f){const _=xo(e.value),g=sl(e.value),y=null!==e.value?e.value:f;if(d){if(_!==d)return[new Dt(e.key,y,`${_} stop domain type must match previous stop domain type ${d}`)]}else d=_;if("number"!==_&&"string"!==_&&"boolean"!==_)return[new Dt(e.key,y,"stop domain value must be a number, string, or boolean")];if("number"!==_&&"categorical"!==c){let d=`number expected, ${_} found`;return fo(l)&&void 0===c&&(d+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Dt(e.key,y,d)]}return"categorical"!==c||"number"!==_||isFinite(g)&&Math.floor(g)===g?"categorical"!==c&&"number"===_&&void 0!==p&&gnew Dt(`${e.key}${l.key}`,e.value,l.message)));const c=l.value.expression||l.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!c.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&&!co(c))return[new Dt(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!co(c))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(!ho(c,["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&&!lo(c))return[new Dt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function dl(e){const l=e.key,c=e.value,d=xo(c);return"string"!==d?[new Dt(l,c,`color expected, ${d} found`)]:Te.parse(String(c))?[]:[new Dt(l,c,`color expected, "${c}" found`)]}function pl(e){const l=e.key,c=e.value,d=e.valueSpec,p=[];return Array.isArray(d.values)?-1===d.values.indexOf(sl(c))&&p.push(new Dt(l,c,`expected one of [${d.values.join(", ")}], ${JSON.stringify(c)} found`)):-1===Object.keys(d.values).indexOf(sl(c))&&p.push(new Dt(l,c,`expected one of [${Object.keys(d.values).join(", ")}], ${JSON.stringify(c)} found`)),p}function fl(e){return Xo(ol(e.value))?ul(ri({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):gl(e)}function gl(e){const l=e.value,c=e.key;if("array"!==xo(l))return[new Dt(c,l,`array expected, ${xo(l)} found`)];const d=e.styleSpec;let p,f=[];if(l.length<1)return[new Dt(c,l,"filter array must have at least 1 element")];switch(f=f.concat(pl({key:`${c}[0]`,value:l[0],valueSpec:d.filter_operator,style:e.style,styleSpec:e.styleSpec})),sl(l[0])){case"<":case"<=":case">":case">=":l.length>=2&&"$type"===sl(l[1])&&f.push(new Dt(c,l,`"$type" cannot be use with operator "${l[0]}"`));case"==":case"!=":3!==l.length&&f.push(new Dt(c,l,`filter array for operator "${l[0]}" must have 3 elements`));case"in":case"!in":l.length>=2&&(p=xo(l[1]),"string"!==p&&f.push(new Dt(`${c}[1]`,l[1],`string expected, ${p} found`)));for(let m=2;m{e in c&&l.push(new Dt(d,c[e],`"${e}" is prohibited for ref layers`))})),p.layers.forEach((l=>{sl(l.id)===_&&(e=l)})),e?e.ref?l.push(new Dt(d,c.ref,"ref cannot reference another ref layer")):m=sl(e.type):l.push(new Dt(d,c.ref,`ref layer "${_}" not found`))}else if("background"!==m)if(c.source){const e=p.sources&&p.sources[c.source],f=e&&sl(e.type);e?"vector"===f&&"raster"===m?l.push(new Dt(d,c.source,`layer "${c.id}" requires a raster source`)):"raster-dem"!==f&&"hillshade"===m||"raster-dem"!==f&&"color-relief"===m?l.push(new Dt(d,c.source,`layer "${c.id}" requires a raster-dem source`)):"raster"===f&&"raster"!==m?l.push(new Dt(d,c.source,`layer "${c.id}" requires a vector source`)):"vector"!==f||c["source-layer"]?"raster-dem"===f&&"hillshade"!==m&&"color-relief"!==m?l.push(new Dt(d,c.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==m||!c.paint||!c.paint["line-gradient"]||"geojson"===f&&e.lineMetrics||l.push(new Dt(d,c,`layer "${c.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):l.push(new Dt(d,c,`layer "${c.id}" must specify a "source-layer"`)):l.push(new Dt(d,c.source,`source "${c.source}" not found`))}else l.push(new Dt(d,c,'missing required property "source"'));return l=l.concat(al({key:d,value:c,valueSpec:f.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${d}.type`,value:c.type,valueSpec:f.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:c,objectKey:"type"}),filter:fl,layout:e=>al({layer:c,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>bl(ri({layerType:m},e))}}),paint:e=>al({layer:c,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>vl(ri({layerType:m},e))}})}})),l}function Tl(e){const l=e.value,c=e.key,d=xo(l);return"string"!==d?[new Dt(c,l,`string expected, ${d} found`)]:[]}const Il={promoteId:function({key:e,value:l}){if("string"===xo(l))return Tl({key:e,value:l});{const c=[];for(const d in l)c.push(...Tl({key:`${e}.${d}`,value:l[d]}));return c}}};function Cl(e){const l=e.value,c=e.key,d=e.styleSpec,p=e.style,f=e.validateSpec;if(!l.type)return[new Dt(c,l,'"type" is required')];const m=sl(l.type);let _;switch(m){case"vector":case"raster":return _=al({key:c,value:l,valueSpec:d[`source_${m.replace("-","_")}`],style:e.style,styleSpec:d,objectElementValidators:Il,validateSpec:f}),_;case"raster-dem":return _=function(e){var l;const c=null!==(l=e.sourceName)&&void 0!==l?l:"",d=e.value,p=e.styleSpec,f=p.source_raster_dem,m=e.style;let _=[];const g=xo(d);if(void 0===d)return _;if("object"!==g)return _.push(new Dt("source_raster_dem",d,`object expected, ${g} found`)),_;const y="custom"===sl(d.encoding),b=["redFactor","greenFactor","blueFactor","baseShift"],T=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const l in d)!y&&b.includes(l)?_.push(new Dt(l,d[l],`In "${c}": "${l}" is only valid when "encoding" is set to "custom". ${T} encoding found`)):f[l]?_=_.concat(e.validateSpec({key:l,value:d[l],valueSpec:f[l],validateSpec:e.validateSpec,style:m,styleSpec:p})):_.push(new Dt(l,d[l],`unknown property "${l}"`));return _}({sourceName:c,value:l,style:e.style,styleSpec:d,validateSpec:f}),_;case"geojson":if(_=al({key:c,value:l,valueSpec:d.source_geojson,style:p,styleSpec:d,validateSpec:f,objectElementValidators:Il}),l.cluster)for(const e in l.clusterProperties){const[d,p]=l.clusterProperties[e],f="string"==typeof d?[d,["accumulated"],["get",e]]:d;_.push(...ul({key:`${c}.${e}.map`,value:p,expressionContext:"cluster-map"})),_.push(...ul({key:`${c}.${e}.reduce`,value:f,expressionContext:"cluster-reduce"}))}return _;case"video":return al({key:c,value:l,valueSpec:d.source_video,style:p,validateSpec:f,styleSpec:d});case"image":return al({key:c,value:l,valueSpec:d.source_image,style:p,validateSpec:f,styleSpec:d});case"canvas":return[new Dt(c,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return pl({key:`${c}.type`,value:l.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Al(e){const l=e.value,c=e.styleSpec,d=c.light,p=e.style;let f=[];const m=xo(l);if(void 0===l)return f;if("object"!==m)return f=f.concat([new Dt("light",l,`object expected, ${m} found`)]),f;for(const m in l){const _=m.match(/^(.*)-transition$/);f=f.concat(_&&d[_[1]]&&d[_[1]].transition?e.validateSpec({key:m,value:l[m],valueSpec:c.transition,validateSpec:e.validateSpec,style:p,styleSpec:c}):d[m]?e.validateSpec({key:m,value:l[m],valueSpec:d[m],validateSpec:e.validateSpec,style:p,styleSpec:c}):[new Dt(m,l[m],`unknown property "${m}"`)])}return f}function Dl(e){const l=e.value,c=e.styleSpec,d=c.sky,p=e.style,f=xo(l);if(void 0===l)return[];if("object"!==f)return[new Dt("sky",l,`object expected, ${f} found`)];let m=[];for(const f in l)m=m.concat(d[f]?e.validateSpec({key:f,value:l[f],valueSpec:d[f],style:p,styleSpec:c}):[new Dt(f,l[f],`unknown property "${f}"`)]);return m}function kl(e){const l=e.value,c=e.styleSpec,d=c.terrain,p=e.style;let f=[];const m=xo(l);if(void 0===l)return f;if("object"!==m)return f=f.concat([new Dt("terrain",l,`object expected, ${m} found`)]),f;for(const m in l)f=f.concat(d[m]?e.validateSpec({key:m,value:l[m],valueSpec:d[m],validateSpec:e.validateSpec,style:p,styleSpec:c}):[new Dt(m,l[m],`unknown property "${m}"`)]);return f}function Rl(e){let l=[];const c=e.value,d=e.key;if(Array.isArray(c)){const p=[],f=[];for(const m in c)c[m].id&&p.includes(c[m].id)&&l.push(new Dt(d,c,`all the sprites' ids must be unique, but ${c[m].id} is duplicated`)),p.push(c[m].id),c[m].url&&f.includes(c[m].url)&&l.push(new Dt(d,c,`all the sprites' URLs must be unique, but ${c[m].url} is duplicated`)),f.push(c[m].url),l=l.concat(al({key:`${d}[${m}]`,value:c[m],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return l}return Tl({key:d,value:c})}function Ll(e){return Boolean(e)&&e.constructor===Object}function Fl(e){return Ll(e.value)?[]:[new Dt(e.key,e.value,`object expected, ${xo(e.value)} found`)]}const Bl={"*":()=>[],array:ll,boolean:function(e){const l=e.value,c=e.key,d=xo(l);return"boolean"!==d?[new Dt(c,l,`boolean expected, ${d} found`)]:[]},number:cl,color:dl,constants:nl,enum:pl,filter:fl,function:hl,layer:wl,object:al,source:Cl,light:Al,sky:Dl,terrain:kl,projection:function(e){const l=e.value,c=e.styleSpec,d=c.projection,p=e.style,f=xo(l);if(void 0===l)return[];if("object"!==f)return[new Dt("projection",l,`object expected, ${f} found`)];let m=[];for(const f in l)m=m.concat(d[f]?e.validateSpec({key:f,value:l[f],valueSpec:d[f],style:p,styleSpec:c}):[new Dt(f,l[f],`unknown property "${f}"`)]);return m},projectionDefinition:function(e){const l=e.key;let c=e.value;c=c instanceof String?c.valueOf():c;const d=xo(c);return"array"!==d||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(c)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(c)?["array","string"].includes(d)?[]:[new Dt(l,c,`projection expected, invalid type "${d}" found`)]:[new Dt(l,c,`projection expected, invalid array ${JSON.stringify(c)} found`)]},string:Tl,formatted:function(e){return 0===Tl(e).length?[]:ul(e)},resolvedImage:function(e){return 0===Tl(e).length?[]:ul(e)},padding:function(e){const l=e.key,c=e.value;if("array"===xo(c)){if(c.length<1||c.length>4)return[new Dt(l,c,`padding requires 1 to 4 values; ${c.length} values found`)];const d={type:"number"};let p=[];for(let f=0;f[]}})),e.constants&&(c=c.concat(nl({key:"constants",value:e.constants}))),Ul(c)}function Gl(e){return function(l){return e(Object.assign({},l,{validateSpec:Ol}))}}function Ul(e){return[].concat(e).sort(((e,l)=>e.line-l.line))}function ql(l){return function(...c){return Ul(l.apply(this||e,c))}}Nl.source=ql(Gl(Cl)),Nl.sprite=ql(Gl(Rl)),Nl.glyphs=ql(Gl(jl)),Nl.light=ql(Gl(Al)),Nl.sky=ql(Gl(Dl)),Nl.terrain=ql(Gl(kl)),Nl.state=ql(Gl(Fl)),Nl.layer=ql(Gl(wl)),Nl.filter=ql(Gl(fl)),Nl.paintProperty=ql(Gl(vl)),Nl.layoutProperty=ql(Gl(bl));const Zl={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class rs{constructor(e,l){this._globalState=l,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 l=Go(e,Zl,this._globalState);if("error"===l.result)throw this._literalValue="visible",this._compiledValue=void 0,new Error(l.value.map((e=>`${e.key}: ${e.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=l.value,this._globalStateRefs=Zo(l.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const $l=Tt,Wl=Nl,Hl=Wl.light,Xl=Wl.sky,Yl=Wl.paintProperty,Kl=Wl.layoutProperty;function Ql(e,l){let c=!1;if(l&&l.length)for(const d of l)e.fire(new gt(new Error(d.message))),c=!0;return c}class cs{constructor(e,l,c){const d=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const p=new Int32Array(this.arrayBuffer);e=p[0],this.d=(l=p[1])+2*(c=p[2]);for(let e=0;e=y[g+0]&&d>=y[g+1])?(m[T]=!0,f.push(p[T])):m[T]=!1}}}}_forEachCell(e,l,c,d,p,f,m,_){const g=this._convertToCellCoord(e),y=this._convertToCellCoord(l),b=this._convertToCellCoord(c),T=this._convertToCellCoord(d);for(let S=g;S<=b;S++)for(let g=y;g<=T;g++){const y=this.d*g+S;if((!_||_(this._convertFromCellCoord(S),this._convertFromCellCoord(g),this._convertFromCellCoord(S+1),this._convertFromCellCoord(g+1)))&&p.call(this,e,l,c,d,y,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,l=3+this.cells.length+1+1;let c=0;for(let e=0;e=0)continue;const f=e[d];p[d]=Jl[c].shallow.indexOf(d)>=0?f:oc(f,l)}e instanceof Error&&(p.message=e.message)}if(p.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==c&&(p.$name=c),p}function lc(e){if(sc(e))return e;if(Array.isArray(e))return e.map(lc);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const l=nc(e)||"Object";if(!Jl[l])throw new Error(`can't deserialize unregistered class ${l}`);const{klass:c}=Jl[l];if(!c)throw new Error(`can't deserialize unregistered class ${l}`);if(c.deserialize)return c.deserialize(e);const d=Object.create(c.prototype);for(const c of Object.keys(e)){if("$name"===c)continue;const p=e[c];d[c]=Jl[l].shallow.indexOf(c)>=0?p:lc(p)}return d}class xs{constructor(){this.first=!0}update(e,l){const c=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=c,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=c,!0):(this.lastFloorZoom>c?(this.lastIntegerZoom=c+1,this.lastIntegerZoomTime=l):this.lastFloorZoom{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}})).filter((e=>e));return new RegExp(l.join("|"),"u")}const mc=fc(["Arab","Dupl","Mong","Ougr","Syrc"]);function _c(e){return!mc.test(String.fromCodePoint(e))}function gc(e){return!(hc(e)||(l=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(l))));var l}const yc=fc(["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 xc(e){return yc.test(String.fromCodePoint(e))}function vc(e,l){return!(!l&&xc(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function bc(e){for(const l of e)if(xc(l.codePointAt(0)))return!0;return!1}const wc=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(wc.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,l){return c(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const c=e.pluginURL,d=new Promise((e=>{this.loadScriptResolve=e}));l(c);const p=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([d,p]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:c};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${c}`)}))}};class Ps{constructor(e,l){this.isSupportedScript=Pc,this.zoom=e,l?(this.now=l.now||0,this.fadeDuration=l.fadeDuration||0,this.zoomHistory=l.zoomHistory||new xs,this.transition=l.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,l=e-Math.floor(e),c=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:l+(1-l)*c}:{fromScale:.5,toScale:1,t:1-(1-c)*l}}}function Pc(e){return function(e,l){for(const c of e)if(!vc(c.codePointAt(0),l))return!1;return!0}(e,"loaded"===wc.getRTLTextPluginStatus())}const Mc="-transition";class Cs{constructor(e,l,c){this.property=e,this.value=l,this.expression=function(e,l,c){if(vo(e))return new oi(e,l);if(No(e)){const d=Uo(e,l,c);if("error"===d.result)throw new Error(d.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return d.value}{let c=e;return"color"===l.type&&"string"==typeof e?c=Te.parse(e):"padding"!==l.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==l.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==l.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===l.type&&Array.isArray(e)?c=Le.parse(e):"projectionDefinition"===l.type&&"string"==typeof e&&(c=Re.parse(e)):c=Be.parse(e):c=Pe.parse(e):c=ze.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>c}}}(void 0===l?e.specification.default:l,e.specification,c)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,l,c){return this.property.possiblyEvaluate(this,e,l,c)}}class Ls{constructor(e,l){this.property=e,this.value=new Cs(e,void 0,l)}transitioned(e,l){return new Rs(this.property,this.value,l,ge({},e.transition,this.transition),e.now)}untransitioned(){return new Rs(this.property,this.value,null,{},0)}}class Os{constructor(e,l){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=l}getValue(e){return be(this._values[e].value.value)}setValue(e,l){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===l?void 0:be(l),this._globalState)}getTransition(e){return be(this._values[e].transition)}setTransition(e,l){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ls(this._values[e].property,this._globalState)),this._values[e].transition=be(l)||void 0}serialize(){const e={};for(const l of Object.keys(this._values)){const c=this.getValue(l);void 0!==c&&(e[l]=c);const d=this.getTransition(l);void 0!==d&&(e[`${l}${Mc}`]=d)}return e}transitioned(e,l){const c=new Ns(this._properties);for(const d of Object.keys(this._values))c._values[d]=this._values[d].transitioned(e,l._values[d]);return c}untransitioned(){const e=new Ns(this._properties);for(const l of Object.keys(this._values))e._values[l]=this._values[l].untransitioned();return e}}class Rs{constructor(e,l,c,d,p){this.property=e,this.value=l,this.begin=p+d.delay||0,this.end=this.begin+d.duration||0,e.specification.transition&&(d.delay||d.duration)&&(this.prior=c)}possiblyEvaluate(e,l,c){const d=e.now||0,p=this.value.possiblyEvaluate(e,l,c),f=this.prior;if(f){if(d>this.end)return this.prior=null,p;if(this.value.isDataDriven())return this.prior=null,p;if(dd.zoomHistory.lastIntegerZoom?{from:e,to:l}:{from:c,to:l}}interpolate(e){return e}}class Ys{constructor(e){this.specification=e}possiblyEvaluate(e,l,c,d){if(void 0!==e.value){if("constant"===e.expression.kind){const p=e.expression.evaluate(l,null,{},c,d);return this._calculate(p,p,p,l)}return this._calculate(e.expression.evaluate(new Ps(Math.floor(l.zoom-1),l)),e.expression.evaluate(new Ps(Math.floor(l.zoom),l)),e.expression.evaluate(new Ps(Math.floor(l.zoom+1),l)),l)}}_calculate(e,l,c,d){return d.zoom>d.zoomHistory.lastIntegerZoom?{from:e,to:l}:{from:c,to:l}}interpolate(e){return e}}class Zs{constructor(e){this.specification=e}possiblyEvaluate(e,l,c,d){return!!e.expression.evaluate(l,null,{},c,d)}interpolate(){return!1}}class Hs{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const l in e){const c=e[l];c.specification.overridable&&this.overridableProperties.push(l);const d=this.defaultPropertyValues[l]=new Cs(c,void 0,void 0),p=this.defaultTransitionablePropertyValues[l]=new Ls(c,void 0);this.defaultTransitioningPropertyValues[l]=p.untransitioned(),this.defaultPossiblyEvaluatedValues[l]=d.possiblyEvaluate({})}}}ec("DataDrivenProperty",Gs),ec("DataConstantProperty",js),ec("CrossFadedDataDrivenProperty",Xs),ec("CrossFadedProperty",Ys),ec("ColorRampProperty",Zs);class Ks extends xt{constructor(e,l,c){if(super(),this.id=e.id,this.type=e.type,this._globalState=c,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(e,l){return new rs(e,l)}(this.visibility,c),"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=Ko(e.filter,c)),l.layout&&(this._unevaluatedLayout=new $s(l.layout,c)),l.paint)){this._transitionablePaint=new Os(l.paint,c);for(const l in e.paint)this.setPaintProperty(l,e.paint[l],{validate:!1});for(const l in e.layout)this.setLayoutProperty(l,e.layout[l],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new qs(l.paint)}}setFilter(e){this.filter=e,this._featureFilter=Ko(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 l of this._visibilityExpression.getGlobalStateRefs())e.add(l);if(this._unevaluatedLayout)for(const l in this._unevaluatedLayout._values){const c=this._unevaluatedLayout._values[l];for(const l of c.getGlobalStateRefs())e.add(l)}for(const l of this._featureFilter.getGlobalStateRefs())e.add(l);return e}getPaintAffectingGlobalStateRefs(){var e;const l=new globalThis.Map;if(this._transitionablePaint)for(const c in this._transitionablePaint._values){const d=this._transitionablePaint._values[c].value;for(const p of d.getGlobalStateRefs()){const f=null!==(e=l.get(p))&&void 0!==e?e:[];f.push({name:c,value:d.value}),l.set(p,f)}}return l}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,l,c={}){if(null==l||!this._validate(Kl,`layers.${this.id}.layout.${e}`,e,l,c))return"visibility"===e?(this.visibility=l,this._visibilityExpression.setValue(l),void this.recalculateVisibility()):void this._unevaluatedLayout.setValue(e,l)}getPaintProperty(e){return e.endsWith(Mc)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,l,c={}){if(null!=l&&this._validate(Yl,`layers.${this.id}.paint.${e}`,e,l,c))return!1;if(e.endsWith(Mc))return this._transitionablePaint.setTransition(e.slice(0,-11),l||void 0),!1;{const c=this._transitionablePaint._values[e],d="cross-faded-data-driven"===c.property.specification["property-type"],p=c.value.isDataDriven(),f=c.value;this._transitionablePaint.setValue(e,l),this._handleSpecialPaintPropertyUpdate(e);const m=this._transitionablePaint._values[e].value;return m.isDataDriven()||p||d||this._handleOverridablePaintPropertyUpdate(e,f,m)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,l,c){return!1}isHidden(e=this.minzoom,l=!1){return!!(this.minzoom&&e<(l?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,l){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,l)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,l)}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,l)=>!(void 0===e||"layout"===l&&!Object.keys(e).length||"paint"===l&&!Object.keys(e).length)))}_validate(e,l,c,d,p={}){return(!p||!1!==p.validate)&&Ql(this,e.call(Wl,{key:l,layerType:this.type,objectKey:c,value:d,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 l=this.paint.get(e);if(l instanceof Us&&fo(l.property.specification)&&("source"===l.value.kind||"composite"===l.value.kind)&&l.value.isStateDependent)return!0}return!1}}let Ic;var Ec={get paint(){return Ic=Ic||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,l){super(e,Ec,l)}}const Cc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ea{constructor(e,l){this._structArray=e,this._pos1=l*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,l){return e._trim(),l&&(e.isTransferred=!0,l.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const l=Object.create(this.prototype);return l.arrayBuffer=e.arrayBuffer,l.length=e.length,l.capacity=e.arrayBuffer.byteLength/l.bytesPerElement,l._refreshViews(),l}_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 l=this.uint8;this._refreshViews(),l&&this.uint8.set(l)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Ac(e,l=1){let c=0,d=0;return{members:e.map((e=>{const p=Cc[e.type].BYTES_PER_ELEMENT,f=c=Dc(c,Math.max(l,p)),m=e.components||1;return d=Math.max(d,p),c+=p*m,{name:e.name,type:e.type,components:m,offset:f}})),size:Dc(c,Math.max(d,l)),alignment:l}}function Dc(e,l){return Math.ceil(e/l)*l}class sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,l)}emplace(e,l,c){const d=2*e;return this.int16[d+0]=l,this.int16[d+1]=c,e}}sa.prototype.bytesPerElement=4,ec("StructArrayLayout2i4",sa);class aa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,c){const d=this.length;return this.resize(d+1),this.emplace(d,e,l,c)}emplace(e,l,c,d){const p=3*e;return this.int16[p+0]=l,this.int16[p+1]=c,this.int16[p+2]=d,e}}aa.prototype.bytesPerElement=6,ec("StructArrayLayout3i6",aa);class oa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,c,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,l,c,d)}emplace(e,l,c,d,p){const f=4*e;return this.int16[f+0]=l,this.int16[f+1]=c,this.int16[f+2]=d,this.int16[f+3]=p,e}}oa.prototype.bytesPerElement=8,ec("StructArrayLayout4i8",oa);class la extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,c,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,l,c,d,p,f)}emplace(e,l,c,d,p,f,m){const _=6*e;return this.int16[_+0]=l,this.int16[_+1]=c,this.int16[_+2]=d,this.int16[_+3]=p,this.int16[_+4]=f,this.int16[_+5]=m,e}}la.prototype.bytesPerElement=12,ec("StructArrayLayout2i4i12",la);class ua extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,c,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,l,c,d,p,f)}emplace(e,l,c,d,p,f,m){const _=4*e,g=8*e;return this.int16[_+0]=l,this.int16[_+1]=c,this.uint8[g+4]=d,this.uint8[g+5]=p,this.uint8[g+6]=f,this.uint8[g+7]=m,e}}ua.prototype.bytesPerElement=8,ec("StructArrayLayout2i4ub8",ua);class ca extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,l)}emplace(e,l,c){const d=2*e;return this.float32[d+0]=l,this.float32[d+1]=c,e}}ca.prototype.bytesPerElement=8,ec("StructArrayLayout2f8",ca);class ha extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,c,d,p,f,m,_,g,y){const b=this.length;return this.resize(b+1),this.emplace(b,e,l,c,d,p,f,m,_,g,y)}emplace(e,l,c,d,p,f,m,_,g,y,b){const T=10*e;return this.uint16[T+0]=l,this.uint16[T+1]=c,this.uint16[T+2]=d,this.uint16[T+3]=p,this.uint16[T+4]=f,this.uint16[T+5]=m,this.uint16[T+6]=_,this.uint16[T+7]=g,this.uint16[T+8]=y,this.uint16[T+9]=b,e}}ha.prototype.bytesPerElement=20,ec("StructArrayLayout10ui20",ha);class pa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,c,d,p,f,m,_){const g=this.length;return this.resize(g+1),this.emplace(g,e,l,c,d,p,f,m,_)}emplace(e,l,c,d,p,f,m,_,g){const y=8*e;return this.uint16[y+0]=l,this.uint16[y+1]=c,this.uint16[y+2]=d,this.uint16[y+3]=p,this.uint16[y+4]=f,this.uint16[y+5]=m,this.uint16[y+6]=_,this.uint16[y+7]=g,e}}pa.prototype.bytesPerElement=16,ec("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,l,c,d,p,f,m,_,g,y,b,T){const S=this.length;return this.resize(S+1),this.emplace(S,e,l,c,d,p,f,m,_,g,y,b,T)}emplace(e,l,c,d,p,f,m,_,g,y,b,T,S){const P=12*e;return this.int16[P+0]=l,this.int16[P+1]=c,this.int16[P+2]=d,this.int16[P+3]=p,this.uint16[P+4]=f,this.uint16[P+5]=m,this.uint16[P+6]=_,this.uint16[P+7]=g,this.int16[P+8]=y,this.int16[P+9]=b,this.int16[P+10]=T,this.int16[P+11]=S,e}}fa.prototype.bytesPerElement=24,ec("StructArrayLayout4i4ui4i24",fa);class da extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,c){const d=this.length;return this.resize(d+1),this.emplace(d,e,l,c)}emplace(e,l,c,d){const p=3*e;return this.float32[p+0]=l,this.float32[p+1]=c,this.float32[p+2]=d,e}}da.prototype.bytesPerElement=12,ec("StructArrayLayout3f12",da);class ya extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const l=this.length;return this.resize(l+1),this.emplace(l,e)}emplace(e,l){return this.uint32[1*e+0]=l,e}}ya.prototype.bytesPerElement=4,ec("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,l,c,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,e,l,c,d,p,f,m,_,g)}emplace(e,l,c,d,p,f,m,_,g,y){const b=10*e,T=5*e;return this.int16[b+0]=l,this.int16[b+1]=c,this.int16[b+2]=d,this.int16[b+3]=p,this.int16[b+4]=f,this.int16[b+5]=m,this.uint32[T+3]=_,this.uint16[b+8]=g,this.uint16[b+9]=y,e}}ma.prototype.bytesPerElement=20,ec("StructArrayLayout6i1ul2ui20",ma);class ga extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,c,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,l,c,d,p,f)}emplace(e,l,c,d,p,f,m){const _=6*e;return this.int16[_+0]=l,this.int16[_+1]=c,this.int16[_+2]=d,this.int16[_+3]=p,this.int16[_+4]=f,this.int16[_+5]=m,e}}ga.prototype.bytesPerElement=12,ec("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,l,c,d,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,l,c,d,p)}emplace(e,l,c,d,p,f){const m=4*e,_=8*e;return this.float32[m+0]=l,this.float32[m+1]=c,this.float32[m+2]=d,this.int16[_+6]=p,this.int16[_+7]=f,e}}xa.prototype.bytesPerElement=16,ec("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,l,c,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,l,c,d,p,f)}emplace(e,l,c,d,p,f,m){const _=16*e,g=4*e,y=8*e;return this.uint8[_+0]=l,this.uint8[_+1]=c,this.float32[g+1]=d,this.float32[g+2]=p,this.int16[y+6]=f,this.int16[y+7]=m,e}}va.prototype.bytesPerElement=16,ec("StructArrayLayout2ub2f2i16",va);class ba extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,c){const d=this.length;return this.resize(d+1),this.emplace(d,e,l,c)}emplace(e,l,c,d){const p=3*e;return this.uint16[p+0]=l,this.uint16[p+1]=c,this.uint16[p+2]=d,e}}ba.prototype.bytesPerElement=6,ec("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,l,c,d,p,f,m,_,g,y,b,T,S,P,I,C,R){const L=this.length;return this.resize(L+1),this.emplace(L,e,l,c,d,p,f,m,_,g,y,b,T,S,P,I,C,R)}emplace(e,l,c,d,p,f,m,_,g,y,b,T,S,P,I,C,R,L){const F=24*e,B=12*e,O=48*e;return this.int16[F+0]=l,this.int16[F+1]=c,this.uint16[F+2]=d,this.uint16[F+3]=p,this.uint32[B+2]=f,this.uint32[B+3]=m,this.uint32[B+4]=_,this.uint16[F+10]=g,this.uint16[F+11]=y,this.uint16[F+12]=b,this.float32[B+7]=T,this.float32[B+8]=S,this.uint8[O+36]=P,this.uint8[O+37]=I,this.uint8[O+38]=C,this.uint32[B+10]=R,this.int16[F+22]=L,e}}wa.prototype.bytesPerElement=48,ec("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,l,c,d,p,f,m,_,g,y,b,T,S,P,I,C,R,L,F,B,O,V,j,G,U,q,Z,W){const Q=this.length;return this.resize(Q+1),this.emplace(Q,e,l,c,d,p,f,m,_,g,y,b,T,S,P,I,C,R,L,F,B,O,V,j,G,U,q,Z,W)}emplace(e,l,c,d,p,f,m,_,g,y,b,T,S,P,I,C,R,L,F,B,O,V,j,G,U,q,Z,W,Q){const J=32*e,re=16*e;return this.int16[J+0]=l,this.int16[J+1]=c,this.int16[J+2]=d,this.int16[J+3]=p,this.int16[J+4]=f,this.int16[J+5]=m,this.int16[J+6]=_,this.int16[J+7]=g,this.uint16[J+8]=y,this.uint16[J+9]=b,this.uint16[J+10]=T,this.uint16[J+11]=S,this.uint16[J+12]=P,this.uint16[J+13]=I,this.uint16[J+14]=C,this.uint16[J+15]=R,this.uint16[J+16]=L,this.uint16[J+17]=F,this.uint16[J+18]=B,this.uint16[J+19]=O,this.uint16[J+20]=V,this.uint16[J+21]=j,this.uint16[J+22]=G,this.uint32[re+12]=U,this.float32[re+13]=q,this.float32[re+14]=Z,this.uint16[J+30]=W,this.uint16[J+31]=Q,e}}_a.prototype.bytesPerElement=64,ec("StructArrayLayout8i15ui1ul2f2ui64",_a);class Sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const l=this.length;return this.resize(l+1),this.emplace(l,e)}emplace(e,l){return this.float32[1*e+0]=l,e}}Sa.prototype.bytesPerElement=4,ec("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,l,c){const d=this.length;return this.resize(d+1),this.emplace(d,e,l,c)}emplace(e,l,c,d){const p=3*e;return this.uint16[6*e+0]=l,this.float32[p+1]=c,this.float32[p+2]=d,e}}Aa.prototype.bytesPerElement=12,ec("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,l,c){const d=this.length;return this.resize(d+1),this.emplace(d,e,l,c)}emplace(e,l,c,d){const p=4*e;return this.uint32[2*e+0]=l,this.uint16[p+2]=c,this.uint16[p+3]=d,e}}ka.prototype.bytesPerElement=8,ec("StructArrayLayout1ul2ui8",ka);class Ea extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,l)}emplace(e,l,c){const d=2*e;return this.uint16[d+0]=l,this.uint16[d+1]=c,e}}Ea.prototype.bytesPerElement=4,ec("StructArrayLayout2ui4",Ea);class Ta extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const l=this.length;return this.resize(l+1),this.emplace(l,e)}emplace(e,l){return this.uint16[1*e+0]=l,e}}Ta.prototype.bytesPerElement=2,ec("StructArrayLayout1ui2",Ta);class Ia extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,c,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,l,c,d)}emplace(e,l,c,d,p){const f=4*e;return this.float32[f+0]=l,this.float32[f+1]=c,this.float32[f+2]=d,this.float32[f+3]=p,e}}Ia.prototype.bytesPerElement=16,ec("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 d(this.anchorPointX,this.anchorPointY)}}Ma.prototype.size=20;class Fa extends ma{get(e){return new Ma(this,e)}}ec("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)}}ec("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)}}ec("SymbolInstanceArray",Ba);class Va extends Sa{getoffsetX(e){return this.float32[1*e+0]}}ec("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]}}ec("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)}}ec("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)}}ec("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 zc=Ac([{name:"a_pos",components:2,type:"Int16"}],4),{members:kc}=zc;class io{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,l,c,d){const p=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||!p||p.vertexLength+e>io.MAX_VERTEX_ARRAY_LENGTH||p.sortKey!==d?this.createNewSegment(l,c,d):p}createNewSegment(e,l,c){const d={vertexOffset:e.length,primitiveOffset:l.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==c&&(d.sortKey=c),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(d),d}getOrCreateLatestSegment(e,l,c){return this.prepareSegment(0,e,l,c)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const l in e.vaos)e.vaos[l].destroy()}static simpleSegment(e,l,c,d){return new io([{vertexOffset:e,primitiveOffset:l,vertexLength:c,primitiveLength:d,vaos:{},sortKey:0}])}}function Rc(e,l){return 256*(e=fe(Math.floor(e),0,255))+fe(Math.floor(l),0,255)}io.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ec("SegmentVector",io);const Lc=Ac([{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"}]),Fc=Ac([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var Bc,Oc,Vc,Nc={exports:{}},Gc={exports:{}},Uc={exports:{}},Zc=function(){if(Vc)return Nc.exports;Vc=1;var e=(Bc||(Bc=1,Gc.exports=function(e,l){var c,d,p,f,m,_,g,y;for(d=e.length-(c=3&e.length),p=l,m=3432918353,_=461845907,y=0;y>>16)*m&65535)<<16)&4294967295)<<15|g>>>17))*_+(((g>>>16)*_&65535)<<16)&4294967295)<<13|p>>>19))+((5*(p>>>16)&65535)<<16)&4294967295))+((58964+(f>>>16)&65535)<<16);switch(g=0,c){case 3:g^=(255&e.charCodeAt(y+2))<<16;case 2:g^=(255&e.charCodeAt(y+1))<<8;case 1:p^=g=(65535&(g=(g=(65535&(g^=255&e.charCodeAt(y)))*m+(((g>>>16)*m&65535)<<16)&4294967295)<<15|g>>>17))*_+(((g>>>16)*_&65535)<<16)&4294967295}return p^=e.length,p=2246822507*(65535&(p^=p>>>16))+((2246822507*(p>>>16)&65535)<<16)&4294967295,p=3266489909*(65535&(p^=p>>>13))+((3266489909*(p>>>16)&65535)<<16)&4294967295,(p^=p>>>16)>>>0}),Gc.exports),l=(Oc||(Oc=1,Uc.exports=function(e,l){for(var c,d=e.length,p=l^d,f=0;d>=4;)c=1540483477*(65535&(c=255&e.charCodeAt(f)|(255&e.charCodeAt(++f))<<8|(255&e.charCodeAt(++f))<<16|(255&e.charCodeAt(++f))<<24))+((1540483477*(c>>>16)&65535)<<16),p=1540483477*(65535&p)+((1540483477*(p>>>16)&65535)<<16)^(c=1540483477*(65535&(c^=c>>>24))+((1540483477*(c>>>16)&65535)<<16)),d-=4,++f;switch(d){case 3:p^=(255&e.charCodeAt(f+2))<<16;case 2:p^=(255&e.charCodeAt(f+1))<<8;case 1:p=1540483477*(65535&(p^=255&e.charCodeAt(f)))+((1540483477*(p>>>16)&65535)<<16)}return p=1540483477*(65535&(p^=p>>>13))+((1540483477*(p>>>16)&65535)<<16),(p^=p>>>15)>>>0}),Uc.exports);return Nc.exports=e,Nc.exports.murmur3=e,Nc.exports.murmur2=l,Nc.exports}(),$c=p(Zc);class go{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,l,c,d){this.ids.push(Wc(e)),this.positions.push(l,c,d)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const l=Wc(e);let c=0,d=this.ids.length-1;for(;c>1;this.ids[e]>=l?d=e:c=e+1}const p=[];for(;this.ids[c]===l;)p.push({index:this.positions[3*c],start:this.positions[3*c+1],end:this.positions[3*c+2]}),c++;return p}static serialize(e,l){const c=new Float64Array(e.ids),d=new Uint32Array(e.positions);return Hc(c,d,0,c.length-1),l&&l.push(c.buffer,d.buffer),{ids:c,positions:d}}static deserialize(e){const l=new go;return l.ids=e.ids,l.positions=e.positions,l.indexed=!0,l}}function Wc(e){const l=+e;return!isNaN(l)&&l<=Number.MAX_SAFE_INTEGER?l:$c(String(e))}function Hc(e,l,c,d){for(;c>1];let f=c-1,m=d+1;for(;;){do{f++}while(e[f]p);if(f>=m)break;Xc(e,f,m),Xc(l,3*f,3*m),Xc(l,3*f+1,3*m+1),Xc(l,3*f+2,3*m+2)}m-c`u_${e}`)),this.type=c}setUniform(e,l,c){e.set(c.constantOr(this.value))}getBinding(e,l,c){return"color"===this.type?new Ao(e,l):new _o(e,l)}}class Io{constructor(e,l){this.uniformNames=l.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,l){this.pixelRatioFrom=l.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=l.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,l){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,l.y,l.height,l.width]}setUniform(e,l,c,d){let p=null;"u_pattern_to"===d?p=this.patternTo:"u_pattern_from"===d?p=this.patternFrom:"u_dasharray_to"===d?p=this.dashTo:"u_dasharray_from"===d?p=this.dashFrom:"u_pixel_ratio_to"===d?p=this.pixelRatioTo:"u_pixel_ratio_from"===d&&(p=this.pixelRatioFrom),null!==p&&e.set(p)}getBinding(e,l,c){return"u_pattern"===c.substr(0,9)||"u_dasharray_"===c.substr(0,12)?new So(e,l):new _o(e,l)}}class Mo{constructor(e,l,c,d){this.expression=e,this.type=c,this.maxValue=0,this.paintVertexAttributes=l.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===c?2:1,offset:0}))),this.paintVertexArray=new d}populatePaintArray(e,l,c){const d=this.paintVertexArray.length,p=this.expression.evaluate(new Ps(0,c),l,{},c.canonical,[],c.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(d,e,p)}updatePaintArray(e,l,c,d,p){const f=this.expression.evaluate(new Ps(0,p),c,d);this._setPaintValue(e,l,f)}_setPaintValue(e,l,c){if("color"===this.type){const d=Kc(c);for(let c=e;c`u_${e}_t`)),this.type=c,this.useIntegerZoom=d,this.zoom=p,this.maxValue=0,this.paintVertexAttributes=l.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===c?4:2,offset:0}))),this.paintVertexArray=new f}populatePaintArray(e,l,c){const d=this.expression.evaluate(new Ps(this.zoom,c),l,{},c.canonical,[],c.formattedSection),p=this.expression.evaluate(new Ps(this.zoom+1,c),l,{},c.canonical,[],c.formattedSection),f=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(f,e,d,p)}updatePaintArray(e,l,c,d,p){const f=this.expression.evaluate(new Ps(this.zoom,p),c,d),m=this.expression.evaluate(new Ps(this.zoom+1,p),c,d);this._setPaintValue(e,l,f,m)}_setPaintValue(e,l,c,d){if("color"===this.type){const p=Kc(c),f=Kc(d);for(let c=e;c`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const l in this.binders){const c=this.binders[l];if(c instanceof Mo||c instanceof Fo)for(let l=0;l!0){this.programConfigurations={};for(const d of e)this.programConfigurations[d.id]=new Bo(d,l,c);this.needsUpload=!1,this._featureMap=new go,this._bufferOffset=0}populatePaintArrays(e,l,c,d){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(e,l,d);void 0!==l.id&&this._featureMap.add(l.id,c,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,l,c,d){for(const p of c)this.needsUpload=this.programConfigurations[p.id].updatePaintArrays(e,this._featureMap,l,p,d)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const l in this.programConfigurations)this.programConfigurations[l].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Qc(e,l){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(`${l}-`,"").replace(/-/g,"_")]}function Jc(e,l,c){const d={color:{source:ca,composite:Ia},number:{source:Sa,composite:ca}},p=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 p&&p[c]||d[l][c]}ec("ConstantBinder",To),ec("CrossFadedConstantBinder",Io),ec("SourceExpressionBinder",Mo),ec("CrossFadedPatternBinder",zo),ec("CrossFadedDasharrayBinder",Po),ec("CompositeExpressionBinder",Fo),ec("ProgramConfiguration",Bo,{omit:["_buffers"]}),ec("ProgramConfigurationSet",Vo);const eh=Math.pow(2,14)-1,th=-eh-1;function ih(e){const l=re/e.extent,c=e.loadGeometry();for(let e=0;ec.x+1||fc.y+1)&&Se("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return c}function rh(e,l){return{type:e.type,id:e.id,properties:e.properties,geometry:l?ih(e):[]}}const nh=-32768;function sh(e,l,c,d,p){e.emplaceBack(nh+8*l+d,nh+8*c+p)}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,l,c){const d=this.layers[0],p=[];let f=null,m=!1,_="heatmap"===d.type;if("circle"===d.type){const e=d;f=e.layout.get("circle-sort-key"),m=!f.isConstant(),_=_||"map"===e.paint.get("circle-pitch-alignment")}const g=_?l.subdivisionGranularity.circle:1;for(const{feature:l,id:d,index:_,sourceLayerIndex:g}of e){const e=this.layers[0]._featureFilter.needGeometry,y=rh(l,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),y,c))continue;const b=m?f.evaluate(y,{},c):void 0,T={id:d,properties:l.properties,type:l.type,sourceLayerIndex:g,index:_,geometry:e?y.geometry:ih(l),patterns:{},sortKey:b};p.push(T)}m&&p.sort(((e,l)=>e.sortKey-l.sortKey));for(const d of p){const{geometry:p,index:f,sourceLayerIndex:m}=d,_=e[f].feature;this.addFeature(d,p,f,c,g),l.featureIndex.insert(_,p,f,m,this.index)}}update(e,l,c){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,{imagePositions:c})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,kc),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,l,c,d,p=1){let f;switch(p){case 1:f=[0,7];break;case 3:f=[0,2,5,7];break;case 5:f=[0,1,3,4,6,7];break;case 7:f=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${p}; valid values are 1, 3, 5, 7.`)}const m=f.length;for(const c of l)for(const l of c){const c=l.x,d=l.y;if(c<0||c>=re||d<0||d>=re)continue;const p=this.segments.prepareSegment(m*m,this.layoutVertexArray,this.indexArray,e.sortKey),_=p.vertexLength;for(let e=0;e1){if(uh(e,l))return!0;for(let d=0;d1?c:c.sub(l)._mult(p)._add(l))}function vh(e,l){let c,d,p,f=!1;for(let m=0;ml.y!=p.y>l.y&&l.x<(p.x-d.x)*(l.y-d.y)/(p.y-d.y)+d.x&&(f=!f)}return f}function bh(e,l){let c=!1;for(let d=0,p=e.length-1;dl.y!=m.y>l.y&&l.x<(m.x-f.x)*(l.y-f.y)/(m.y-f.y)+f.x&&(c=!c)}return c}function Th(e,l,c){const d=c[0],p=c[2];if(e.xp.x&&l.x>p.x||e.yp.y&&l.y>p.y)return!1;const f=Me(e,l,c[0]);return f!==Me(e,l,c[1])||f!==Me(e,l,c[2])||f!==Me(e,l,c[3])}function Ph(e,l,c){const d=l.paint.get(e).value;return"constant"===d.kind?d.value:c.programConfigurations.get(l.id).getMaxValue(e)}function Mh(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Ih(e,l,c,p,f){if(!l[0]&&!l[1])return e;const m=d.convert(l)._mult(f);"viewport"===c&&m._rotate(-p);const _=[];for(let l=0;lBh(e,l,c,d)))}(g,p,m,_),P=y),Fh({queryGeometry:S,size:P,transform:p,unwrappedTileID:m,getElevation:_,pitchAlignment:T,pitchScale:b},d)}}class ml extends jo{}let $h;ec("HeatmapBucket",ml,{omit:["layers"]});var eu={get paint(){return $h=$h||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 tu(e,{width:l,height:c},d,p){if(p){if(p instanceof Uint8ClampedArray)p=new Uint8Array(p.buffer);else if(p.length!==l*c*d)throw new RangeError(`mismatched image size. expected: ${p.length} but got: ${l*c*d}`)}else p=new Uint8Array(l*c*d);return e.width=l,e.height=c,e.data=p,e}function iu(e,{width:l,height:c},d){if(l===e.width&&c===e.height)return;const p=tu({},{width:l,height:c},d);ru(e,p,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,l),height:Math.min(e.height,c)},d),e.width=l,e.height=c,e.data=p.data}function ru(e,l,c,d,p,f){if(0===p.width||0===p.height)return l;if(p.width>e.width||p.height>e.height||c.x>e.width-p.width||c.y>e.height-p.height)throw new RangeError("out of range source coordinates for image copy");if(p.width>l.width||p.height>l.height||d.x>l.width-p.width||d.y>l.height-p.height)throw new RangeError("out of range destination coordinates for image copy");const m=e.data,_=l.data;if(m===_)throw new Error("srcData equals dstData, so image is already copied");for(let g=0;g{l[e.evaluationKey]=m;const _=e.expression.evaluate(l);p.setPixel(d/4/c,f/4,_)};if(e.clips)for(let l=0,p=0;lthis.max&&(this.max=c),c=this.dim+1||l<-1||l>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${l}, dim: ${this.dim}`);return(l+1)*this.stride+(e+1)}unpack(e,l,c){return e*this.redFactor+l*this.greenFactor+c*this.blueFactor-this.baseShift}pack(e){return uu(e,this.getUnpackVector())}getPixels(){return new Sl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,l,c){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let d=l*this.dim,p=l*this.dim+this.dim,f=c*this.dim,m=c*this.dim+this.dim;switch(l){case-1:d=p-1;break;case 1:p=d+1}switch(c){case-1:f=m-1;break;case 1:m=f+1}const _=-l*this.dim,g=-c*this.dim;for(let l=f;l0)for(let p=l;p=l;p-=d)f=Wu(p/d|0,e[p],e[p+1],f);return f&&ju(f,f.next)&&(Hu(f),f=f.next),f}function xu(e,l){if(!e)return e;l||(l=e);let c,d=e;do{if(c=!1,d.steiner||!ju(d,d.next)&&0!==Ou(d.prev,d,d.next))d=d.next;else{if(Hu(d),d=l=d.prev,d===d.next)break;c=!0}}while(c||d!==l);return l}function vu(e,l,c,d,p,f,m){if(!e)return;!m&&f&&function(e,l,c,d){let p=e;do{0===p.z&&(p.z=Du(p.x,p.y,l,c,d)),p.prevZ=p.prev,p.nextZ=p.next,p=p.next}while(p!==e);p.prevZ.nextZ=null,p.prevZ=null,function(e){let l,c=1;do{let d,p=e;e=null;let f=null;for(l=0;p;){l++;let m=p,_=0;for(let e=0;e0||g>0&&m;)0!==_&&(0===g||!m||p.z<=m.z)?(d=p,p=p.nextZ,_--):(d=m,m=m.nextZ,g--),f?f.nextZ=d:e=d,d.prevZ=f,f=d;p=m}f.nextZ=null,c*=2}while(l>1)}(p)}(e,d,p,f);let _=e;for(;e.prev!==e.next;){const g=e.prev,y=e.next;if(f?Tu(e,d,p,f):bu(e))l.push(g.i,e.i,y.i),Hu(e),e=y.next,_=y.next;else if((e=y)===_){m?1===m?vu(e=Su(xu(e),l),l,c,d,p,f,2):2===m&&Iu(e,l,c,d,p,f):vu(xu(e),l,c,d,p,f,1);break}}}function bu(e){const l=e.prev,c=e,d=e.next;if(Ou(l,c,d)>=0)return!1;const p=l.x,f=c.x,m=d.x,_=l.y,g=c.y,y=d.y,b=Math.min(p,f,m),T=Math.min(_,g,y),S=Math.max(p,f,m),P=Math.max(_,g,y);let I=d.next;for(;I!==l;){if(I.x>=b&&I.x<=S&&I.y>=T&&I.y<=P&&Fu(p,_,f,g,m,y,I.x,I.y)&&Ou(I.prev,I,I.next)>=0)return!1;I=I.next}return!0}function Tu(e,l,c,d){const p=e.prev,f=e,m=e.next;if(Ou(p,f,m)>=0)return!1;const _=p.x,g=f.x,y=m.x,b=p.y,T=f.y,S=m.y,P=Math.min(_,g,y),I=Math.min(b,T,S),C=Math.max(_,g,y),R=Math.max(b,T,S),L=Du(P,I,l,c,d),F=Du(C,R,l,c,d);let B=e.prevZ,O=e.nextZ;for(;B&&B.z>=L&&O&&O.z<=F;){if(B.x>=P&&B.x<=C&&B.y>=I&&B.y<=R&&B!==p&&B!==m&&Fu(_,b,g,T,y,S,B.x,B.y)&&Ou(B.prev,B,B.next)>=0)return!1;if(B=B.prevZ,O.x>=P&&O.x<=C&&O.y>=I&&O.y<=R&&O!==p&&O!==m&&Fu(_,b,g,T,y,S,O.x,O.y)&&Ou(O.prev,O,O.next)>=0)return!1;O=O.nextZ}for(;B&&B.z>=L;){if(B.x>=P&&B.x<=C&&B.y>=I&&B.y<=R&&B!==p&&B!==m&&Fu(_,b,g,T,y,S,B.x,B.y)&&Ou(B.prev,B,B.next)>=0)return!1;B=B.prevZ}for(;O&&O.z<=F;){if(O.x>=P&&O.x<=C&&O.y>=I&&O.y<=R&&O!==p&&O!==m&&Fu(_,b,g,T,y,S,O.x,O.y)&&Ou(O.prev,O,O.next)>=0)return!1;O=O.nextZ}return!0}function Su(e,l){let c=e;do{const d=c.prev,p=c.next.next;!ju(d,p)&&Nu(d,c,c.next,p)&&Zu(d,p)&&Zu(p,d)&&(l.push(d.i,c.i,p.i),Hu(c),Hu(c.next),c=e=p),c=c.next}while(c!==e);return xu(c)}function Iu(e,l,c,d,p,f){let m=e;do{let e=m.next.next;for(;e!==m.prev;){if(m.i!==e.i&&Bu(m,e)){let _=$u(m,e);return m=xu(m,m.next),_=xu(_,_.next),vu(m,l,c,d,p,f,0),void vu(_,l,c,d,p,f,0)}e=e.next}m=m.next}while(m!==e)}function Eu(e,l){let c=e.x-l.x;return 0===c&&(c=e.y-l.y,0===c)&&(c=(e.next.y-e.y)/(e.next.x-e.x)-(l.next.y-l.y)/(l.next.x-l.x)),c}function Cu(e,l){const c=function(e,l){let c=l;const d=e.x,p=e.y;let f,m=-1/0;if(ju(e,c))return c;do{if(ju(e,c.next))return c.next;if(p<=c.y&&p>=c.next.y&&c.next.y!==c.y){const e=c.x+(p-c.y)*(c.next.x-c.x)/(c.next.y-c.y);if(e<=d&&e>m&&(m=e,f=c.x=c.x&&c.x>=g&&d!==c.x&&Lu(pf.x||c.x===f.x&&Au(f,c)))&&(f=c,b=l)}c=c.next}while(c!==_);return f}(e,l);if(!c)return l;const d=$u(c,e);return xu(d,d.next),xu(c,c.next)}function Au(e,l){return Ou(e.prev,e,l.prev)<0&&Ou(l.next,e,e.next)<0}function Du(e,l,c,d,p){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-c)*p|0)|e<<8))|e<<4))|e<<2))|e<<1))|(l=1431655765&((l=858993459&((l=252645135&((l=16711935&((l=(l-d)*p|0)|l<<8))|l<<4))|l<<2))|l<<1))<<1}function zu(e){let l=e,c=e;do{(l.x=(e-m)*(f-_)&&(e-m)*(d-_)>=(c-m)*(l-_)&&(c-m)*(f-_)>=(p-m)*(d-_)}function Fu(e,l,c,d,p,f,m,_){return!(e===m&&l===_)&&Lu(e,l,c,d,p,f,m,_)}function Bu(e,l){return e.next.i!==l.i&&e.prev.i!==l.i&&!function(e,l){let c=e;do{if(c.i!==e.i&&c.next.i!==e.i&&c.i!==l.i&&c.next.i!==l.i&&Nu(c,c.next,e,l))return!0;c=c.next}while(c!==e);return!1}(e,l)&&(Zu(e,l)&&Zu(l,e)&&function(e,l){let c=e,d=!1;const p=(e.x+l.x)/2,f=(e.y+l.y)/2;do{c.y>f!=c.next.y>f&&c.next.y!==c.y&&p<(c.next.x-c.x)*(f-c.y)/(c.next.y-c.y)+c.x&&(d=!d),c=c.next}while(c!==e);return d}(e,l)&&(Ou(e.prev,e,l.prev)||Ou(e,l.prev,l))||ju(e,l)&&Ou(e.prev,e,e.next)>0&&Ou(l.prev,l,l.next)>0)}function Ou(e,l,c){return(l.y-e.y)*(c.x-l.x)-(l.x-e.x)*(c.y-l.y)}function ju(e,l){return e.x===l.x&&e.y===l.y}function Nu(e,l,c,d){const p=qu(Ou(e,l,c)),f=qu(Ou(e,l,d)),m=qu(Ou(c,d,e)),_=qu(Ou(c,d,l));return p!==f&&m!==_||!(0!==p||!Uu(e,c,l))||!(0!==f||!Uu(e,d,l))||!(0!==m||!Uu(c,e,d))||!(0!==_||!Uu(c,l,d))}function Uu(e,l,c){return l.x<=Math.max(e.x,c.x)&&l.x>=Math.min(e.x,c.x)&&l.y<=Math.max(e.y,c.y)&&l.y>=Math.min(e.y,c.y)}function qu(e){return e>0?1:e<0?-1:0}function Zu(e,l){return Ou(e.prev,e,e.next)<0?Ou(e,l,e.next)>=0&&Ou(e,e.prev,l)>=0:Ou(e,l,e.prev)<0||Ou(e,e.next,l)<0}function $u(e,l){const c=Xu(e.i,e.x,e.y),d=Xu(l.i,l.x,l.y),p=e.next,f=l.prev;return e.next=l,l.prev=e,c.next=p,p.prev=c,d.next=c,c.prev=d,f.next=d,d.prev=f,d}function Wu(e,l,c,d){const p=Xu(e,l,c);return d?(p.next=d.next,p.prev=d,d.next.prev=p,d.next=p):(p.prev=p,p.next=p),p}function Hu(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 Xu(e,l,c){return{i:e,x:l,y:c,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class hu{constructor(e,l){if(l>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=l}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||l>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const c=0|Math.round(e),d=0|Math.round(l),p=this._getKey(c,d);if(this._vertexDictionary.has(p))return this._vertexDictionary.get(p);const f=this._vertexBuffer.length/2;return this._vertexDictionary.set(p,f),this._vertexBuffer.push(c,d),f}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,l){const c=[];for(let d=0;d0?(c.push(p),c.push(m),c.push(f)):(c.push(p),c.push(f),c.push(m))}return c}(this._vertexBuffer,e);const l=[],c=e.length;for(let d=0;d=1||B<=0)||C&&(_p)){y>=d&&y<=p&&f.push(c[(e+1)%3]);continue}!C&&F>0&&f.push(this._vertexToIndex(m+S*F,_+P*F));const O=m+S*Math.max(F,0),V=m+S*Math.min(B,1);I||this._generateIntraEdgeVertices(f,m,_,g,y,O,V),!C&&B<1&&f.push(this._vertexToIndex(m+S*B,_+P*B)),(C||y>=d&&y<=p)&&f.push(c[(e+1)%3]),!C&&(y<=d||y>=p)&&this._generateInterEdgeVertices(f,m,_,g,y,b,T,V,d,p)}return f}_generateIntraEdgeVertices(e,l,c,d,p,f,m){const _=d-l,g=p-c,y=0===g,b=y?Math.min(l,d):Math.min(f,m),T=y?Math.max(l,d):Math.max(f,m),S=Math.floor(b/this._granularityCellSize)+1,P=Math.ceil(T/this._granularityCellSize)-1;if(y?l=S;d--){const p=d*this._granularityCellSize;e.push(this._vertexToIndex(p,c+g*(p-l)/_))}}_generateInterEdgeVertices(e,l,c,d,p,f,m,_,g,y){const b=p-c,T=f-d,S=m-p,P=(g-p)/S,I=(y-p)/S,C=Math.min(P,I),R=Math.max(P,I),L=d+T*C;let F=Math.floor(Math.min(L,_)/this._granularityCellSize)+1,B=Math.ceil(Math.max(L,_)/this._granularityCellSize)-1,O=_=1||R<=0){const e=c-m,d=f+(l-f)*Math.min((g-m)/e,(y-m)/e);F=Math.floor(Math.min(d,_)/this._granularityCellSize)+1,B=Math.ceil(Math.max(d,_)/this._granularityCellSize)-1,O=_0?y:g;if(O)for(let l=F;l<=B;l++)e.push(this._vertexToIndex(l*this._granularityCellSize,j));else for(let l=B;l>=F;l--)e.push(this._vertexToIndex(l*this._granularityCellSize,j))}_generateOutline(e){const l=[];for(const c of e){const e=Ju(c,this._granularity,!0),d=this._pointArrayToIndices(e),p=[];for(let e=1;ep!=(f===Yu)?(e.push(l),e.push(c),e.push(this._vertexToIndex(d,f)),e.push(c),e.push(this._vertexToIndex(p,f)),e.push(this._vertexToIndex(d,f))):(e.push(c),e.push(l),e.push(this._vertexToIndex(d,f)),e.push(this._vertexToIndex(p,f)),e.push(c),e.push(this._vertexToIndex(d,f)))}_fillPoles(e,l,c){const d=this._vertexBuffer,p=re,f=e.length;for(let m=2;m80*c){_=e[0],g=e[1];let l=_,d=g;for(let f=c;fl&&(l=c),p>d&&(d=p)}y=Math.max(l-_,d-g),y=0!==y?32767/y:0}return vu(f,m,c,_,g,y,0),m}(c,d),l=this._convertIndices(c,e);p=this._subdivideTrianglesScanline(l)}catch(e){console.error(e)}let f=[];return l&&(f=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(p),{verticesFlattened:this._vertexBuffer,indicesTriangles:p,indicesLineList:f}}_convertIndices(e,l){const c=[];for(let d=0;d0?(Math.floor(F/_)+1)*_:(Math.ceil(F/_)-1)*_,l=C>0?(Math.floor(B/_)+1)*_:(Math.ceil(B/_)-1)*_,c=Math.abs(F-e),p=Math.abs(B-l),f=Math.abs(F-b),m=Math.abs(B-T),y=S?c/R:Number.POSITIVE_INFINITY,O=P?p/L:Number.POSITIVE_INFINITY;if((f<=c||!S)&&(m<=p||!P))break;if(y=0?m-1:f-1,p=(_+1)%f,g=e[2*l[d]],y=e[2*l[p]],b=e[2*l[m]],T=e[2*l[m]+1],S=e[2*l[_]+1];let P=!1;if(gy)P=!1;else{const c=S-T,f=-(e[2*l[_]]-b),m=T((y-b)*c+(e[2*l[p]+1]-T)*f)*m&&(P=!0)}if(P){const e=l[d],p=l[m],g=l[_];e!==p&&e!==g&&p!==g&&c.push(g,p,e),m--,m<0&&(m=f-1)}else{const e=l[p],d=l[m],g=l[_];e!==d&&e!==g&&d!==g&&c.push(g,d,e),_++,_>=f&&(_=0)}if(d===p)break}}function td(e,l,c,d,p,f,m,_,g){const y=p.length/2,b=m&&_&&g;if(yio.MAX_VERTEX_ARRAY_LENGTH&&(y=e.createNewSegment(l,c),g=_.count,C=!0,R=!0,L=!0,b=0);const F=id(m,d,f,_,S,C,y),B=id(m,d,f,_,P,R,y),O=id(m,d,f,_,I,L,y);c.emplaceBack(b+F-g,b+B-g,b+O-g),y.primitiveLength++}}(l,c,d,p,f,e),b&&function(e,l,c,d,p,f){const m=[];for(let e=0;eio.MAX_VERTEX_ARRAY_LENGTH&&(y=e.createNewSegment(l,c),g=_.count,I=!0,C=!0,b=0);const R=id(m,d,f,_,p,I,y),L=id(m,d,f,_,T,C,y);c.emplaceBack(b+R-g,b+L-g),y.primitiveLength++}}}(m,c,_,p,g,e),l.forceNewSegmentOnNextPrepare(),null==m||m.forceNewSegmentOnNextPrepare()}function id(e,l,c,d,p,f,m){if(f){const f=d.count;return c(l[2*p],l[2*p+1]),e[p]=d.count,d.count++,m.vertexLength++,f}return e[p]}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,l,c){this.hasDependencies=mu("fill",this.layers,l);const d=this.layers[0].layout.get("fill-sort-key"),p=!d.isConstant(),f=[];for(const{feature:m,id:_,index:g,sourceLayerIndex:y}of e){const e=this.layers[0]._featureFilter.needGeometry,b=rh(m,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),b,c))continue;const T=p?d.evaluate(b,{},c,l.availableImages):void 0,S={id:_,properties:m.properties,type:m.type,sourceLayerIndex:y,index:g,geometry:e?b.geometry:ih(m),patterns:{},sortKey:T};f.push(S)}p&&f.sort(((e,l)=>e.sortKey-l.sortKey));for(const d of f){const{geometry:p,index:f,sourceLayerIndex:m}=d;if(this.hasDependencies){const e=_u("fill",this.layers,d,{zoom:this.zoom},l);this.patternFeatures.push(e)}else this.addFeature(d,p,f,c,{},l.subdivisionGranularity);l.featureIndex.insert(e[f].feature,p,f,m,this.index)}}update(e,l,c){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,{imagePositions:c})}addFeatures(e,l,c){for(const d of this.patternFeatures)this.addFeature(d,d.geometry,d.index,l,c,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,fu),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,l,c,d,p,f){for(const e of Kn(l,500)){const l=Qu(e,d,f.fill.getGranularityForZoomLevel(d.z)),c=this.layoutVertexArray;td(((e,l)=>{c.emplaceBack(e,l)}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles,this.segments2,this.indexArray2,l.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,c,{imagePositions:p,canonical:d})}}let rd,nd;ec("FillBucket",wu,{omit:["layers","patternFeatures"]});var sd={get paint(){return nd=nd||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 rd=rd||new Hs({"fill-sort-key":new Gs(Tt.layout_fill["fill-sort-key"])})}};class ku extends Ks{constructor(e,l){super(e,sd,l)}recalculate(e,l){super.recalculate(e,l);const c=this.paint._values["fill-outline-color"];"constant"===c.value.kind&&void 0===c.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new wu(e)}queryRadius(){return Mh(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:l,transform:c,pixelsToTileUnits:d}){return lh(Ih(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-c.bearingInRadians,d),l)}isTileClipped(){return!0}}const od=Ac([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),ad=Ac([{name:"a_centroid",components:2,type:"Int16"}],4),{members:cd}=od;class Mu{constructor(e,l,c,d,p){this.properties={},this.extent=c,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=d,this._values=p,e.readFields(hd,this,l)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const l=e.readVarint()+e.pos,c=[];let p,f=1,m=0,_=0,g=0;for(;e.pos>3}if(m--,1===f||2===f)_+=e.readSVarint(),g+=e.readSVarint(),1===f&&(p&&c.push(p),p=[]),p&&p.push(new d(_,g));else{if(7!==f)throw new Error(`unknown command ${f}`);p&&p.push(p[0].clone())}}return p&&c.push(p),c}bbox(){const e=this._pbf;e.pos=this._geometry;const l=e.readVarint()+e.pos;let c=1,d=0,p=0,f=0,m=1/0,_=-1/0,g=1/0,y=-1/0;for(;e.pos>3}if(d--,1===c||2===c)p+=e.readSVarint(),f+=e.readSVarint(),p_&&(_=p),fy&&(y=f);else if(7!==c)throw new Error(`unknown command ${c}`)}return[m,g,_,y]}toGeoJSON(e,l,c){const d=this.extent*Math.pow(2,c),p=this.extent*e,f=this.extent*l,m=this.loadGeometry();function _(e){return[360*(e.x+p)/d-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+f)/d)*Math.PI))-90]}function g(e){return e.map(_)}let y;if(1===this.type){const e=[];for(const l of m)e.push(l[0]);const l=g(e);y=1===e.length?{type:"Point",coordinates:l[0]}:{type:"MultiPoint",coordinates:l}}else if(2===this.type){const e=m.map(g);y=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=dd(m),l=[];for(const c of e)l.push(c.map(g));y=1===l.length?{type:"Polygon",coordinates:l[0]}:{type:"MultiPolygon",coordinates:l}}}const b={type:"Feature",geometry:y,properties:this.properties};return null!=this.id&&(b.id=this.id),b}}function hd(e,l,c){1===e?l.id=c.readVarint():2===e?function(e,l){const c=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 l=this._pbf.readVarint()+this._pbf.pos;return new Mu(this._pbf,l,this.extent,this._keys,this._values)}}function fd(e,l,c){15===e?l.version=c.readVarint():1===e?l.name=c.readString():5===e?l.extent=c.readVarint():2===e?l._features.push(c.pos):3===e?l._keys.push(c.readString()):4===e&&l._values.push(function(e){let l=null;const c=e.readVarint()+e.pos;for(;e.pos>3;l=1===c?e.readString():2===c?e.readFloat():3===c?e.readDouble():4===c?e.readVarint64():5===c?e.readVarint():6===c?e.readSVarint():7===c?e.readBoolean():null}if(null==l)throw new Error("unknown feature value");return l}(c))}class Vu{constructor(e,l){this.layers=e.readFields(md,{},l)}}function md(e,l,c){if(3===e){const e=new Pu(c,c.readVarint()+c.pos);e.length&&(l[e.name]=e)}}const _d=Math.pow(2,13);function gd(e,l,c,d,p,f,m,_){e.emplaceBack(l,c,2*Math.floor(d*_d)+m,p*_d*2,f*_d*2,Math.round(_))}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,l,c){this.features=[],this.hasDependencies=mu("fill-extrusion",this.layers,l);for(const{feature:d,id:p,index:f,sourceLayerIndex:m}of e){const e=this.layers[0]._featureFilter.needGeometry,_=rh(d,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),_,c))continue;const g={id:p,sourceLayerIndex:m,index:f,geometry:e?_.geometry:ih(d),properties:d.properties,type:d.type,patterns:{}};this.hasDependencies?this.features.push(_u("fill-extrusion",this.layers,g,{zoom:this.zoom},l)):this.addFeature(g,g.geometry,f,c,{},l.subdivisionGranularity),l.featureIndex.insert(d,g.geometry,f,m,this.index,!0)}}addFeatures(e,l,c){for(const d of this.features){const{geometry:p}=d;this.addFeature(d,p,d.index,l,c,e.subdivisionGranularity)}}update(e,l,c){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,{imagePositions:c})}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,cd),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,ad.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,l,c,d,p,f){for(const c of Kn(l,500)){const l={x:0,y:0,sampleCount:0},p=this.layoutVertexArray.length;this.processPolygon(l,d,e,c,f);const m=this.layoutVertexArray.length-p,_=Math.floor(l.x/l.sampleCount),g=Math.floor(l.y/l.sampleCount);for(let e=0;e{gd(y,e,l,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,g.verticesFlattened,g.indicesTriangles)}_generateSideFaces(e,l){let c=0;for(let d=1;dio.MAX_VERTEX_ARRAY_LENGTH&&(l.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const m=p.sub(f)._perp()._unit(),_=f.dist(p);c+_>32768&&(c=0),gd(this.layoutVertexArray,p.x,p.y,m.x,m.y,0,0,c),gd(this.layoutVertexArray,p.x,p.y,m.x,m.y,0,1,c),c+=_,gd(this.layoutVertexArray,f.x,f.y,m.x,m.y,0,0,c),gd(this.layoutVertexArray,f.x,f.y,m.x,m.y,0,1,c);const g=l.segment.vertexLength;this.indexArray.emplaceBack(g,g+2,g+1),this.indexArray.emplaceBack(g+1,g+2,g+3),l.segment.vertexLength+=4,l.segment.primitiveLength+=2}}}function yd(e,l){for(let c=0;cre)||e.y===l.y&&(e.y<0||e.y>re)}function vd(e){return e.every((e=>e.x<0))||e.every((e=>e.x>re))||e.every((e=>e.y<0))||e.every((e=>e.y>re))}let bd;ec("FillExtrusionBucket",Ru,{omit:["layers","features"]});var wd={get paint(){return bd=bd||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,l){super(e,wd,l)}createBucket(e){return new Ru(e)}queryRadius(){return Mh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:l,featureState:c,geometry:p,transform:f,pixelsToTileUnits:m,pixelPosMatrix:_}){const g=Ih(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-f.bearingInRadians,m),y=this.paint.get("fill-extrusion-height").evaluate(l,c),b=this.paint.get("fill-extrusion-base").evaluate(l,c),T=function(e,l){const c=[];for(const p of e){const e=[p.x,p.y,0,1];q(e,e,l),c.push(new d(e[0]/e[3],e[1]/e[3]))}return c}(g,_),S=function(e,l,c,p){const f=[],m=[],_=p[8]*l,g=p[9]*l,y=p[10]*l,b=p[11]*l,T=p[8]*c,S=p[9]*c,P=p[10]*c,I=p[11]*c;for(const l of e){const e=[],c=[];for(const f of l){const l=f.x,m=f.y,C=p[0]*l+p[4]*m+p[12],R=p[1]*l+p[5]*m+p[13],L=p[2]*l+p[6]*m+p[14],F=p[3]*l+p[7]*m+p[15],B=L+y,O=F+b,V=C+T,j=R+S,G=L+P,U=F+I,q=new d((C+_)/O,(R+g)/O);q.z=B/O,e.push(q);const Z=new d(V/U,j/U);Z.z=G/U,c.push(Z)}f.push(e),m.push(c)}return[f,m]}(p,b,y,_);return function(e,l,c){let d=1/0;lh(c,l)&&(d=Pd(c,l[0]));for(let p=0;pe.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,l,c){this.hasDependencies=mu("line",this.layers,l)||this.hasLineDasharray(this.layers);const d=this.layers[0].layout.get("line-sort-key"),p=!d.isConstant(),f=[];for(const{feature:l,id:m,index:_,sourceLayerIndex:g}of e){const e=this.layers[0]._featureFilter.needGeometry,y=rh(l,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),y,c))continue;const b=p?d.evaluate(y,{},c):void 0,T={id:m,properties:l.properties,type:l.type,sourceLayerIndex:g,index:_,geometry:e?y.geometry:ih(l),patterns:{},dashes:{},sortKey:b};f.push(T)}p&&f.sort(((e,l)=>e.sortKey-l.sortKey));for(const d of f){const{geometry:p,index:f,sourceLayerIndex:m}=d;this.hasDependencies?(mu("line",this.layers,l)?_u("line",this.layers,d,{zoom:this.zoom},l):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,d,this.zoom,l),this.patternFeatures.push(d)):this.addFeature(d,p,f,c,{},{},l.subdivisionGranularity),l.featureIndex.insert(e[f].feature,p,f,m,this.index)}}update(e,l,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,{imagePositions:c,dashPositions:d})}addFeatures(e,l,c,d){for(const p of this.patternFeatures)this.addFeature(p,p.geometry,p.index,l,c,d,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,Cd)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Id),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,l,c,d,p,f,m){const _=this.layers[0].layout,g=_.get("line-join").evaluate(e,{}),y=_.get("line-cap"),b=_.get("line-miter-limit"),T=_.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const c of l)this.addLine(c,e,g,y,b,T,d,m);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,c,{imagePositions:p,dashPositions:f,canonical:d})}addLine(e,l,c,d,p,f,m,_){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Ju(e,m?_.line.getGranularityForZoomLevel(m.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let l=0;l=2&&e[y-1].equals(e[y-2]);)y--;let b=0;for(;b0;if(V&&l>b){const e=P.dist(I);if(e>2*T){const l=P.sub(P.sub(I)._mult(T/e)._round());this.updateDistance(I,l),this.addCurrentVertex(l,R,0,0,S),I=l}}const G=I&&C;let U=G?c:g?"butt":d;if(G&&"round"===U&&(Bp&&(U="bevel"),"bevel"===U&&(B>2&&(U="flipbevel"),B100)m=L.mult(-1);else{const e=B*R.add(L).mag()/R.sub(L).mag();m._perp()._mult(e*(j?-1:1))}this.addCurrentVertex(P,m,0,0,S),this.addCurrentVertex(P,m.mult(-1),0,0,S)}else if("bevel"===U||"fakeround"===U){const e=-Math.sqrt(B*B-1),l=j?e:0,c=j?0:e;if(I&&this.addCurrentVertex(P,R,l,c,S),"fakeround"===U){const e=Math.round(180*O/Math.PI/20);for(let l=1;l2*T){const l=P.add(C.sub(P)._mult(T/e)._round());this.updateDistance(P,l),this.addCurrentVertex(l,L,0,0,S),P=l}}}}addCurrentVertex(e,l,c,d,p,f=!1){const m=l.y*d-l.x,_=-l.y-l.x*d;this.addHalfVertex(e,l.x+l.y*c,l.y-l.x*c,f,!1,c,p),this.addHalfVertex(e,m,_,f,!0,-d,p),this.distance>Dd/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,l,c,d,p,f))}addHalfVertex({x:e,y:l},c,d,p,f,m,_){const g=.5*(this.lineClips?this.scaledDistance*(Dd-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(p?1:0),(l<<1)+(f?1:0),Math.round(63*c)+128,Math.round(63*d)+128,1+(0===m?0:m<0?-1:1)|(63&g)<<2,g>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const y=_.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,y,this.e2),_.primitiveLength++),f?this.e2=y:this.e1=y}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,l){this.distance+=e.dist(l),this.updateScaledDistance()}hasLineDasharray(e){for(const l of e){const e=l.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,l,c,d){for(const p of e){const e=p.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const f="round"===p.layout.get("line-cap"),m={dasharray:e.value.evaluate({zoom:c-1},l,{}),round:f},_={dasharray:e.value.evaluate({zoom:c},l,{}),round:f},g={dasharray:e.value.evaluate({zoom:c+1},l,{}),round:f},y=`${m.dasharray.join(",")},${m.round}`,b=`${_.dasharray.join(",")},${_.round}`,T=`${g.dasharray.join(",")},${g.round}`;d.dashDependencies[y]=m,d.dashDependencies[b]=_,d.dashDependencies[T]=g,l.dashes[p.id]={min:y,mid:b,max:T}}}}let zd,kd;ec("LineBucket",tc,{omit:["layers","patternFeatures"]});var Rd={get paint(){return kd=kd||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 zd=zd||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,l){return l=new Ps(Math.floor(l.zoom),{now:l.now,fadeDuration:l.fadeDuration,zoomHistory:l.zoomHistory,transition:l.transition}),super.possiblyEvaluate(e,l)}evaluate(e,l,c,d){return l=ge({},l,{zoom:Math.floor(l.zoom)}),super.evaluate(e,l,c,d)}}let Ld;class ac extends Ks{constructor(e,l){super(e,Rd,l),this.gradientVersion=0,Ld||(Ld=new ic(Rd.paint.properties["line-width"].specification),Ld.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,l){super.recalculate(e,l),this.paint._values["line-floorwidth"]=Ld.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new tc(e)}queryRadius(e){const l=e,c=Fd(Ph("line-width",this,l),Ph("line-gap-width",this,l)),d=Ph("line-offset",this,l);return c/2+Math.abs(d)+Mh(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:l,featureState:c,geometry:p,transform:f,pixelsToTileUnits:m}){const _=Ih(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-f.bearingInRadians,m),g=m/2*Fd(this.paint.get("line-width").evaluate(l,c),this.paint.get("line-gap-width").evaluate(l,c)),y=this.paint.get("line-offset").evaluate(l,c);return y&&(p=function(e,l){const c=[];for(let p=0;p=3)for(let l=0;l0?l+2*e:e}const Bd=Ac([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Od=Ac([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ac([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Vd=Ac([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Ac([{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 jd=Ac([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Nd=Ac([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Gd(e,l,c){return e.sections.forEach((e=>{e.text=function(e,l,c){const d=l.layout.get("text-transform").evaluate(c,{});return"uppercase"===d?e=e.toLocaleUpperCase():"lowercase"===d&&(e=e.toLocaleLowerCase()),wc.applyArabicShaping&&(e=wc.applyArabicShaping(e)),e}(e.text,l,c)})),e}Ac([{name:"triangle",components:3,type:"Uint16"}]),Ac([{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"}]),Ac([{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"}]),Ac([{type:"Float32",name:"offsetX"}]),Ac([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Ac([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var Ud=24;const qd={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Zd={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},$d={40:!0};function Wd(e,l,c,d,p,f){if("fontStack"in l){const d=c[l.fontStack],f=d&&d[e];return f?f.metrics.advance*l.scale+p:0}{const e=d[l.imageName];return e?e.displaySize[0]*l.scale*Ud/f+p:0}}function Hd(e,l,c,d){const p=Math.pow(e-l,2);return d?eMath.max(e,this.sections[l].scale)),0)}getMaxImageSize(e){let l=0,c=0;for(let d=0;dc)))}addImageSection(e){const l=e.image?e.image.name:"";if(0===l.length)return void Se("Can't add FormattedSection with an empty image.");const c=this.getNextImageSectionCharCode();c?(this.text+=String.fromCharCode(c),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:l}),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,l,c,d,p){const f=[],m=this.determineAverageLineWidth(e,l,c,d,p),_=this.hasZeroWidthSpaces();let g=0,y=0;const b=this.text[Symbol.iterator]();let T=b.next();const S=this.text[Symbol.iterator]();S.next();let P=S.next();const I=this.text[Symbol.iterator]();I.next(),I.next();let C=I.next();for(;!T.done;){const l=this.getSection(y),R=T.value.codePointAt(0);if(uc(R)||(g+=Wd(R,l,c,d,e,p)),!P.done){const e=cc(R),c=P.value.codePointAt(0);(Zd[R]||e||"imageName"in l||!C.done&&$d[c])&&f.push(Yd(y+1,g,m,f,Xd(R,c,e&&_),!1))}y++,T=b.next(),P=S.next(),C=I.next()}return Kd(Yd(this.length(),g,m,f,0,!0))}determineAverageLineWidth(e,l,c,d,p){let f=0,m=0;for(const l of this.text){const _=this.getSection(m);f+=Wd(l.codePointAt(0),_,c,d,e,p),m++}return f/Math.max(1,Math.ceil(f/l))}}const Qd=4294967296,Jd=1/Qd,ip="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,l,c=this.length){for(;this.pos>3,p=this.pos;this.type=7&c,e(d,l,this),this.pos===p&&this.skip(c)}return l}readMessage(e,l){return this.readFields(e,l,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)*Qd;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Qd;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 l=this.buf;let c,d;return d=l[this.pos++],c=127&d,d<128?c:(d=l[this.pos++],c|=(127&d)<<7,d<128?c:(d=l[this.pos++],c|=(127&d)<<14,d<128?c:(d=l[this.pos++],c|=(127&d)<<21,d<128?c:(d=l[this.pos],c|=(15&d)<<28,function(e,l,c){const d=c.buf;let p,f;if(f=d[c.pos++],p=(112&f)>>4,f<128)return rp(e,p,l);if(f=d[c.pos++],p|=(127&f)<<3,f<128)return rp(e,p,l);if(f=d[c.pos++],p|=(127&f)<<10,f<128)return rp(e,p,l);if(f=d[c.pos++],p|=(127&f)<<17,f<128)return rp(e,p,l);if(f=d[c.pos++],p|=(127&f)<<24,f<128)return rp(e,p,l);if(f=d[c.pos++],p|=(1&f)<<31,f<128)return rp(e,p,l);throw new Error("Expected varint not more than 10 bytes")}(c,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,l=this.pos;return this.pos=e,e-l>=12&&ip?ip.decode(this.buf.subarray(l,e)):function(e,l,c){let d="",p=l;for(;p239?4:l>223?3:l>191?2:1;if(p+y>c)break;1===y?l<128&&(g=l):2===y?(f=e[p+1],128==(192&f)&&(g=(31&l)<<6|63&f,g<=127&&(g=null))):3===y?(f=e[p+1],m=e[p+2],128==(192&f)&&128==(192&m)&&(g=(15&l)<<12|(63&f)<<6|63&m,(g<=2047||g>=55296&&g<=57343)&&(g=null))):4===y&&(f=e[p+1],m=e[p+2],_=e[p+3],128==(192&f)&&128==(192&m)&&128==(192&_)&&(g=(15&l)<<18|(63&f)<<12|(63&m)<<6|63&_,(g<=65535||g>=1114112)&&(g=null))),null===g?(g=65533,y=1):g>65535&&(g-=65536,d+=String.fromCharCode(g>>>10&1023|55296),g=56320|1023&g),d+=String.fromCharCode(g),p+=y}return d}(this.buf,l,e)}readBytes(){const e=this.readVarint()+this.pos,l=this.buf.subarray(this.pos,e);return this.pos=e,l}readPackedVarint(e=[],l){const c=this.readPackedEnd();for(;this.pos127;);else if(2===l)this.pos=this.readVarint()+this.pos;else if(5===l)this.pos+=4;else{if(1!==l)throw new Error(`Unimplemented type: ${l}`);this.pos+=8}}writeTag(e,l){this.writeVarint(e<<3|l)}realloc(e){let l=this.length||16;for(;l268435455||e<0?function(e,l){let c,d;if(e>=0?(c=e%4294967296|0,d=e/4294967296|0):(c=~(-e%4294967296),d=~(-e/4294967296),4294967295^c?c=c+1|0:(c=0,d=d+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");l.realloc(10),function(e,l,c){c.buf[c.pos++]=127&e|128,e>>>=7,c.buf[c.pos++]=127&e|128,e>>>=7,c.buf[c.pos++]=127&e|128,e>>>=7,c.buf[c.pos++]=127&e|128,c.buf[c.pos]=127&(e>>>=7)}(c,0,l),function(e,l){const c=(7&e)<<4;l.buf[l.pos++]|=c|((e>>>=3)?128:0),e&&(l.buf[l.pos++]=127&e|((e>>>=7)?128:0),e&&(l.buf[l.pos++]=127&e|((e>>>=7)?128:0),e&&(l.buf[l.pos++]=127&e|((e>>>=7)?128:0),e&&(l.buf[l.pos++]=127&e|((e>>>=7)?128:0),e&&(l.buf[l.pos++]=127&e)))))}(d,l)}(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 l=this.pos;this.pos=function(e,l,c){for(let d,p,f=0;f55295&&d<57344){if(!p){d>56319||f+1===l.length?(e[c++]=239,e[c++]=191,e[c++]=189):p=d;continue}if(d<56320){e[c++]=239,e[c++]=191,e[c++]=189,p=d;continue}d=p-55296<<10|d-56320|65536,p=null}else p&&(e[c++]=239,e[c++]=191,e[c++]=189,p=null);d<128?e[c++]=d:(d<2048?e[c++]=d>>6|192:(d<65536?e[c++]=d>>12|224:(e[c++]=d>>18|240,e[c++]=d>>12&63|128),e[c++]=d>>6&63|128),e[c++]=63&d|128)}return c}(this.buf,e,this.pos);const c=this.pos-l;c>=128&&np(l,c,this),this.pos=l-1,this.writeVarint(c),this.pos+=c}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 l=e.length;this.writeVarint(l),this.realloc(l);for(let c=0;c=128&&np(c,d,this),this.pos=c-1,this.writeVarint(d),this.pos+=d}writeMessage(e,l,c){this.writeTag(e,2),this.writeRawMessage(l,c)}writePackedVarint(e,l){l.length&&this.writeMessage(e,sp,l)}writePackedSVarint(e,l){l.length&&this.writeMessage(e,op,l)}writePackedBoolean(e,l){l.length&&this.writeMessage(e,cp,l)}writePackedFloat(e,l){l.length&&this.writeMessage(e,ap,l)}writePackedDouble(e,l){l.length&&this.writeMessage(e,lp,l)}writePackedFixed32(e,l){l.length&&this.writeMessage(e,hp,l)}writePackedSFixed32(e,l){l.length&&this.writeMessage(e,up,l)}writePackedFixed64(e,l){l.length&&this.writeMessage(e,dp,l)}writePackedSFixed64(e,l){l.length&&this.writeMessage(e,pp,l)}writeBytesField(e,l){this.writeTag(e,2),this.writeBytes(l)}writeFixed32Field(e,l){this.writeTag(e,5),this.writeFixed32(l)}writeSFixed32Field(e,l){this.writeTag(e,5),this.writeSFixed32(l)}writeFixed64Field(e,l){this.writeTag(e,1),this.writeFixed64(l)}writeSFixed64Field(e,l){this.writeTag(e,1),this.writeSFixed64(l)}writeVarintField(e,l){this.writeTag(e,0),this.writeVarint(l)}writeSVarintField(e,l){this.writeTag(e,0),this.writeSVarint(l)}writeStringField(e,l){this.writeTag(e,2),this.writeString(l)}writeFloatField(e,l){this.writeTag(e,5),this.writeFloat(l)}writeDoubleField(e,l){this.writeTag(e,1),this.writeDouble(l)}writeBooleanField(e,l){this.writeVarintField(e,+l)}}function rp(e,l,c){return c?4294967296*l+(e>>>0):4294967296*(l>>>0)+(e>>>0)}function np(e,l,c){const d=l<=16383?1:l<=2097151?2:l<=268435455?3:Math.floor(Math.log(l)/(7*Math.LN2));c.realloc(d);for(let l=c.pos-1;l>=e;l--)c.buf[l+d]=c.buf[l]}function sp(e,l){for(let c=0;cl.h-e.h));const d=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(l/.95)),c),h:1/0}];let p=0,f=0;for(const l of e)for(let e=d.length-1;e>=0;e--){const c=d[e];if(!(l.w>c.w||l.h>c.h)){if(l.x=c.x,l.y=c.y,f=Math.max(f,l.y+l.h),p=Math.max(p,l.x+l.w),l.w===c.w&&l.h===c.h){const l=d.pop();l&&eR.toCodeUnitIndex(e)));const e=B(R.toString(),F);for(const l of e){const e=[...l].map((()=>0));L.push(new Sc(l,R.sections,e))}}else if(O){L=[],F=F.map((e=>R.toCodeUnitIndex(e)));let e=0;const l=[];for(const c of R.text)l.push(...Array(c.length).fill(R.sectionIndex[e])),e++;const c=O(R.text,l,F);for(const e of c){const l=[];let c="";for(const d of e[0])l.push(e[1][c.length]),c+=d;L.push(new Sc(e[0],R.sections,l))}}else L=function(e,l){const c=[];let d=0;for(const p of l)c.push(e.substring(d,p)),d=p;return dy){const e=Math.ceil(f/y);p*=e/m,m=e}return{x1:d,y1:p,x2:d+f,y2:p+m}}function Dp(e,l,c,d,p,f){const m=e.image;let _;if(m.content){const e=m.content,l=m.pixelRatio||1;_=[e[0]/l,e[1]/l,m.displaySize[0]-e[2]/l,m.displaySize[1]-e[3]/l]}const g=l.left*f,y=l.right*f;let b,T,S,P;"width"===c||"both"===c?(P=p[0]+g-d[3],T=p[0]+y+d[1]):(P=p[0]+(g+y-m.displaySize[0])/2,T=P+m.displaySize[0]);const I=l.top*f,C=l.bottom*f;return"height"===c||"both"===c?(b=p[1]+I-d[0],S=p[1]+C+d[2]):(b=p[1]+(I+C-m.displaySize[1])/2,S=b+m.displaySize[1]),{image:m,top:b,right:T,bottom:S,left:P,collisionPadding:_}}ec("ImagePosition",qc),ec("ImageAtlas",jc),l.az=void 0,(yp=l.az||(l.az={}))[yp.none=0]="none",yp[yp.horizontal=1]="horizontal",yp[yp.vertical=2]="vertical",yp[yp.horizontalOnly=3]="horizontalOnly";const zp=128,kp=32640;function Fp(e,l){const{expression:c}=l;if("constant"===c.kind)return{kind:"constant",layoutSize:c.evaluate(new Ps(e+1))};if("source"===c.kind)return{kind:"source"};{const{zoomStops:l,interpolationType:d}=c;let p=0;for(;pe.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const c=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fp(this.zoom,c["text-size"]),this.iconSizeData=Fp(this.zoom,c["icon-size"]);const d=this.layers[0].layout,p=d.get("symbol-sort-key"),f=d.get("symbol-z-order");this.canOverlap="never"!==Bp(d,"text-overlap","text-allow-overlap")||"never"!==Bp(d,"icon-overlap","icon-allow-overlap")||d.get("text-ignore-placement")||d.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==f&&!p.isConstant(),this.sortFeaturesByY=("viewport-y"===f||"auto"===f&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===d.get("symbol-placement")&&(this.writingModes=d.get("text-writing-mode").map((e=>l.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,l,c,d,p){for(const f of e)if(l[f.codePointAt(0)]=!0,(c||d)&&p){const e=qd[f];e&&(l[e.codePointAt(0)]=!0)}}populate(e,c,d){const p=this.layers[0],f=p.layout,m=f.get("text-font"),_=f.get("text-field"),g=f.get("icon-image"),y=("constant"!==_.value.kind||_.value.value instanceof De&&!_.value.value.isEmpty()||_.value.value.toString().length>0)&&("constant"!==m.value.kind||m.value.value.length>0),b="constant"!==g.value.kind||!!g.value.value||Object.keys(g.parameters).length>0,T=f.get("symbol-sort-key");if(this.features=[],!y&&!b)return;const S=c.iconDependencies,P=c.glyphDependencies,I=c.availableImages,C=new Ps(this.zoom);for(const{feature:c,id:_,index:g,sourceLayerIndex:R}of e){const e=p._featureFilter.needGeometry,L=rh(c,e);if(!p._featureFilter.filter(C,L,d))continue;let F,B;if(e||(L.geometry=ih(c)),y){const e=p.getValueAndResolveTokens("text-field",L,d,I),l=De.factory(e),c=this.hasRTLText=this.hasRTLText||Gp(l);(!c||"unavailable"===wc.getRTLTextPluginStatus()||c&&wc.isParsed())&&(F=Gd(l,p,L))}if(b){const e=p.getValueAndResolveTokens("icon-image",L,d,I);B=e instanceof Oe?e:Oe.fromString(e)}if(!F&&!B)continue;const O=this.sortFeaturesByKey?T.evaluate(L,{},d):void 0;if(this.features.push({id:_,text:F,icon:B,index:g,sourceLayerIndex:R,geometry:L.geometry,properties:c.properties,type:Mu.types[c.type],sortKey:O}),B&&(S[B.name]=!0),F){const e=m.evaluate(L,{},d).join(","),c="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(l.az.vertical)>=0;for(const l of F.sections)if(l.image)S[l.image.name]=!0;else{const d=dc(F.toString()),p=l.fontStack||e,f=P[p]=P[p]||{};this.calculateGlyphDependencies(l.text,f,c,this.allowVerticalPlacement,d)}}}"line"===f.get("symbol-placement")&&(this.features=function(e){const l={},c={},d=[];let p=0;function f(l){d.push(e[l]),p++}function m(e,l,p){const f=c[e];return delete c[e],c[l]=f,d[f].geometry[0].pop(),d[f].geometry[0]=d[f].geometry[0].concat(p[0]),f}function _(e,c,p){const f=l[c];return delete l[c],l[e]=f,d[f].geometry[0].shift(),d[f].geometry[0]=p[0].concat(d[f].geometry[0]),f}function g(e,l,c){const d=c?l[0][l[0].length-1]:l[0][0];return`${e}:${d.x}:${d.y}`}for(let y=0;ye.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,l)=>e.sortKey-l.sortKey))}update(e,l,c){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,l,this.layers,{imagePositions:c}),this.icon.programConfigurations.updatePaintArrays(e,l,this.layers,{imagePositions:c}))}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,l){const c=this.lineVertexArray.length;if(void 0!==e.segment){let c=e.dist(l[e.segment+1]),d=e.dist(l[e.segment]);const p={};for(let d=e.segment+1;d=0;c--)p[c]={x:l[c].x,y:l[c].y,tileUnitDistanceFromAnchor:d},c>0&&(d+=l[c-1].dist(l[c]));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,l){const c=e.placedSymbolArray.get(l),d=c.vertexStartIndex+4*c.numGlyphs;for(let l=c.vertexStartIndex;ld[e]-d[l]||p[l]-p[e])),f}addToSortKeyRanges(e,l){const c=this.sortKeyRanges[this.sortKeyRanges.length-1];c&&c.sortKey===l?c.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:l,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 l=this.symbolInstances.get(e);this.featureSortOrder.push(l.featureIndex),[l.rightJustifiedTextSymbolIndex,l.centerJustifiedTextSymbolIndex,l.leftJustifiedTextSymbolIndex].forEach(((e,l,c)=>{e>=0&&c.indexOf(e)===l&&this.addIndicesForPlacedSymbol(this.text,e)})),l.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,l.verticalPlacedTextSymbolIndex),l.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,l.placedIconSymbolIndex),l.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,l.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let qp,Zp;ec("SymbolBucket",fh,{omit:["layers","collisionBoxArray","features","compareText"]}),fh.MAX_GLYPHS=65535,fh.addDynamicAttributes=Np;var $p={get paint(){return Zp=Zp||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 qp=qp||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 l=this.defaultValue.property.overrides;if(l&&l.hasOverride(e.formattedSection))return l.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}}ec("FormatSectionOverride",gh,{omit:["defaultValue"]});class xh extends Ks{constructor(e,l){super(e,$p,l)}recalculate(e,l){if(super.recalculate(e,l),"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 l=[];for(const c of e)l.indexOf(c)<0&&l.push(c);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,l,c,d){const p=this.layout.get(e).evaluate(l,{},c,d),f=this._unevaluatedLayout._values[e];return f.isDataDriven()||No(f.value)||!p?p:function(e,l){return l.replace(/{([^{}]+)}/g,((l,c)=>e&&c in e?String(e[c]):""))}(l.properties,p)}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 $p.paint.overridableProperties){if(!xh.hasPaintOverride(this.layout,e))continue;const l=this.paint.get(e),c=new gh(l),d=new ei(c,l.property.specification);let p=null;p="constant"===l.value.kind||"source"===l.value.kind?new ii("source",d):new si("composite",d,l.value.zoomStops),this.paint._values[e]=new Us(l.property,p,l.parameters)}}_handleOverridablePaintPropertyUpdate(e,l,c){return!(!this.layout||l.isDataDriven()||c.isDataDriven())&&xh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,l){const c=e.get("text-field"),d=$p.paint.properties[l];let p=!1;const f=e=>{for(const l of e)if(d.overrides&&d.overrides.hasOverride(l))return void(p=!0)};if("constant"===c.value.kind&&c.value.value instanceof De)f(c.value.value.sections);else if("source"===c.value.kind||"composite"===c.value.kind){const e=l=>{p||(l instanceof je&&rn(l.value)===yi?f(l.value.sections):l instanceof Ir?f(l.sections):l.eachChild(e))},l=c.value;l._styleExpression&&e(l._styleExpression.expression)}return p}}let Hp;var Xp={get paint(){return Hp=Hp||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,l){super(e,Xp,l)}}class _h extends Ks{constructor(e,l){super(e,{},l),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 Yp={once:!0},tf=6371008.8;class Eh{constructor(e,l){if(isNaN(e)||isNaN(l))throw new Error(`Invalid LngLat object: (${e}, ${l})`);if(this.lng=+e,this.lat=+l,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 l=Math.PI/180,c=this.lat*l,d=e.lat*l,p=Math.sin(c)*Math.sin(d)+Math.cos(c)*Math.cos(d)*Math.cos((e.lng-this.lng)*l);return tf*Math.acos(Math.min(p,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 rf=2*Math.PI*tf;function sf(e){return rf*Math.cos(e*Math.PI/180)}function of(e){return(180+e)/360}function af(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function hf(e,l){return e/sf(l)}function df(e){return 360*e-180}function pf(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function ff(e,l){return e*sf(pf(l))}class Vh{constructor(e,l,c=0){this.x=+e,this.y=+l,this.z=+c}static fromLngLat(e,l=0){const c=Eh.convert(e);return new Vh(of(c.lng),af(c.lat),hf(l,c.lat))}toLngLat(){return new Eh(df(this.x),pf(this.y))}toAltitude(){return ff(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/rf*(e=pf(this.y),1/Math.cos(e*Math.PI/180));var e}}function _f(e,l,c){var d=2*Math.PI*6378137/256/Math.pow(2,c);return[e*d-2*Math.PI*6378137/2,l*d-2*Math.PI*6378137/2]}class Lh{constructor(e,l,c){if(!function(e,l,c){return!(e<0||e>25||c<0||c>=Math.pow(2,e)||l<0||l>=Math.pow(2,e))}(e,l,c))throw new Error(`x=${l}, y=${c}, 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=l,this.y=c,this.key=vf(0,e,e,l,c)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,l,c){const d=(f=this.y,m=this.z,_=_f(256*(p=this.x),256*(f=Math.pow(2,m)-f-1),m),g=_f(256*(p+1),256*(f+1),m),_[0]+","+_[1]+","+g[0]+","+g[1]);var p,f,m,_,g;const y=function(e,l,c){let d,p="";for(let f=e;f>0;f--)d=1<1?"@2x":"").replace(/{quadkey}/g,y).replace(/{bbox-epsg-3857}/g,d)}isChildOf(e){const l=this.z-e.z;return l>0&&e.x===this.x>>l&&e.y===this.y>>l}getTilePoint(e){const l=Math.pow(2,this.z);return new d((e.x*l-this.x)*re,(e.y*l-this.y)*re)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Oh{constructor(e,l){this.wrap=e,this.canonical=l,this.key=vf(e,l.z,l.z,l.x,l.y)}}class Rh{constructor(e,l,c,d,p){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${c}`);this.overscaledZ=e,this.wrap=l,this.canonical=new Lh(c,+d,+p),this.key=vf(l,e,c,d,p)}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 l=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>>l,this.canonical.y>>l)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,l){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const c=this.canonical.z-e;return e>this.canonical.z?vf(this.wrap*+l,e,this.canonical.z,this.canonical.x,this.canonical.y):vf(this.wrap*+l,e,e,this.canonical.x>>c,this.canonical.y>>c)}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 l=this.canonical.z-e.canonical.z;return!(l<0)&&e.canonical.x===this.canonical.x>>l&&e.canonical.y===this.canonical.y>>l}children(e){if(this.overscaledZ>=e)return[new Rh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const l=this.canonical.z+1,c=2*this.canonical.x,d=2*this.canonical.y;return[new Rh(l,this.wrap,l,c,d),new Rh(l,this.wrap,l,c+1,d),new Rh(l,this.wrap,l,c,d+1),new Rh(l,this.wrap,l,c+1,d+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.key===c));l>-1&&e.addOrUpdateProperties.splice(l,1)}return(e.removeAllProperties||l.removeAllProperties)&&(c.removeAllProperties=!0),(e.removeProperties||l.removeProperties)&&(c.removeProperties=[...e.removeProperties||[],...l.removeProperties||[]]),(e.addOrUpdateProperties||l.addOrUpdateProperties)&&(c.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...l.addOrUpdateProperties||[]]),(e.newGeometry||l.newGeometry)&&(c.newGeometry=l.newGeometry||e.newGeometry),c}function Tf(e){var l,c;if(!e)return{};const d={};return d.removeAll=e.removeAll,d.remove=new Set(e.remove||[]),d.add=new Map(null===(l=e.add)||void 0===l?void 0:l.map((e=>[e.id,e]))),d.update=new Map(null===(c=e.update)||void 0===c?void 0:c.map((e=>[e.id,e]))),d}ec("CanonicalTileID",Lh),ec("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 l=new jh;return l.extend(e(new d(this.minX,this.minY))),l.extend(e(new d(this.maxX,this.minY))),l.extend(e(new d(this.minX,this.maxY))),l.extend(e(new d(this.maxX,this.maxY))),l}static fromPoints(e){const l=new jh;for(const c of e)l.extend(c);return l}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 l=0;l=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,l,c,d,p){this.type="Feature",this._vectorTileFeature=e,this._x=c,this._y=d,this._z=l,this.properties=e.properties,this.id=p}projectPoint(e,l,c,d){return[360*(e.x+l)/d-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+c)/d)*Math.PI))-90]}projectLine(e,l,c,d){return e.map((e=>this.projectPoint(e,l,c,d)))}get geometry(){if(this._geometry)return this._geometry;const e=this._vectorTileFeature,l=e.extent*Math.pow(2,this._z),c=e.extent*this._x,d=e.extent*this._y,p=e.loadGeometry();switch(e.type){case 1:{const e=[];for(const l of p)e.push(l[0]);const f=this.projectLine(e,c,d,l);this._geometry=1===e.length?{type:"Point",coordinates:f[0]}:{type:"MultiPoint",coordinates:f};break}case 2:{const e=p.map((e=>this.projectLine(e,c,d,l)));this._geometry=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=dd(p),f=[];for(const p of e)f.push(p.map((e=>this.projectLine(e,c,d,l))));this._geometry=1===f.length?{type:"Polygon",coordinates:f[0]}:{type:"MultiPolygon",coordinates:f};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 l in this)"_geometry"!==l&&"_vectorTileFeature"!==l&&"_x"!==l&&"_y"!==l&&"_z"!==l&&(e[l]=this[l]);return e}}class Yh{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,l,c){this._name=e,this.dataBuffer=l,"number"==typeof c?this._size=c:(this.nullabilityBuffer=c,this._size=c.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,l,c,d){super(e,l,d),this.delta=c}}class Jh extends Wh{constructor(e,l,c,d){super(e,Int32Array.of(l),c,d)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class Qh extends Yh{constructor(e,l,c){super(e,Int32Array.of(l),c)}getValueFromBuffer(e){return this.dataBuffer[0]}}class tp{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,l,c,d,p=4096){this._name=e,this._geometryVector=l,this._idVector=c,this._propertyVectors=d,this._extent=p}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 l=0;for(;l>4,p<128)return 4294967296*d+(e>>>0);if(p=l[c.get()],c.increment(),d|=(127&p)<<3,p<128)return 4294967296*d+(e>>>0);if(p=l[c.get()],c.increment(),d|=(127&p)<<10,p<128)return 4294967296*d+(e>>>0);if(p=l[c.get()],c.increment(),d|=(127&p)<<17,p<128)return 4294967296*d+(e>>>0);if(p=l[c.get()],c.increment(),d|=(127&p)<<24,p<128)return 4294967296*d+(e>>>0);if(p=l[c.get()],c.increment(),d|=(1&p)<<31,p<128)return 4294967296*d+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(c,e,l)))))}function Gf(e,l,c,d){throw new Error("FastPFor is not implemented yet.")}function Uf(e){return e>>>1^-(1&e)}function qf(e){return e>>1n^-(1n&e)}function Zf(e,l){let c=0n,d=0,p=l.get();for(;p=64)throw new Error("Varint too long")}return l.set(p),c}function $f(e,l,c){const d=new Int32Array(c);let p=0;for(let c=0;c=4)for(let d=e[0];c>>1^-(1&e[0]),e[1]=e[1]>>>1^-(1&e[1]);const l=e.length/4*4;let c=2;if(l>=4)for(;c>>1^-(1&l))+e[c-2],e[c+1]=(d>>>1^-(1&d))+e[c-1],e[c+2]=(p>>>1^-(1&p))+e[c],e[c+3]=(f>>>1^-(1&f))+e[c+1]}for(;c!=e.length;c+=2)e[c]=(e[c]>>>1^-(1&e[c]))+e[c-2],e[c+1]=(e[c+1]>>>1^-(1&e[c+1]))+e[c-1]}!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(Sf||(Sf={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(Pf||(Pf={})),function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"}(Ef||(Ef={}));class Ap{_dictionaryType;_offsetType;_lengthType;constructor(e,l,c){this._dictionaryType=e,this._offsetType=l,this._lengthType=c}get dictionaryType(){return this._dictionaryType}get offsetType(){return this._offsetType}get lengthType(){return this._lengthType}}function Qf(e,l){const c=function(e,l){const c=e[l.get()],d=Object.values(Ef)[c>>4];let p=null;switch(d){case Ef.DATA:p=new Ap(Object.values(Cf)[15&c]);break;case Ef.OFFSET:p=new Ap(null,Object.values(Af)[15&c]);break;case Ef.LENGTH:p=new Ap(null,null,Object.values(zf)[15&c])}l.increment();const f=e[l.get()],m=Object.values(Sf)[f>>5],_=Object.values(Sf)[f>>2&7],g=Object.values(Pf)[3&f];l.increment();const y=Of(e,l,2),b=y[0];return{physicalStreamType:d,logicalStreamType:p,logicalLevelTechnique1:m,logicalLevelTechnique2:_,physicalLevelTechnique:g,numValues:b,byteLength:y[1],decompressedCount:b}}(e,l);return c.logicalLevelTechnique1===Sf.MORTON?function(e,l,c){const d=Of(l,c,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:d[0],coordinateShift:d[1]}}(c,e,l):Sf.RLE!==c.logicalLevelTechnique1&&Sf.RLE!==c.logicalLevelTechnique2||Pf.NONE===c.physicalLevelTechnique?c:function(e,l,c){const d=Of(l,c,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:d[1],runs:d[0],numRleValues:d[1]}}(c,e,l)}!function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Cf||(Cf={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Af||(Af={})),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"}(zf||(zf={})),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"}(kf||(kf={}));class Ep{values;_size;constructor(e,l){this.values=e,this._size=l}get(e){const l=Math.floor(e/8);return 1==(this.values[l]>>e%8&1)}set(e,l){const c=Math.floor(e/8);this.values[c]=this.values[c]|(l?1:0)<>e%8&1}size(){return this._size}getBuffer(){return this.values}}function Jf(e,l,c,d,p){return function(e,l,c){switch(l.logicalLevelTechnique1){case Sf.DELTA:return l.logicalLevelTechnique2===Sf.RLE?function(e,l,c){const d=new Int32Array(c);let p=0,f=0;for(let c=0;c>>1^-(1&e[0]);const l=e.length/4*4;let c=1;if(l>=4)for(;c>>1^-(1&l))+e[c-1],e[c+1]=(d>>>1^-(1&d))+e[c],e[c+2]=(p>>>1^-(1&p))+e[c+1],e[c+3]=(f>>>1^-(1&f))+e[c+2]}for(;c!=e.length;++c)e[c]=(e[c]>>>1^-(1&e[c]))+e[c-1]}(e),e);case Sf.RLE:return function(e,l,c){return c?function(e,l,c){const d=new Int32Array(c);let p=0;for(let c=0;c>>1^-(1&m),d.fill(m,p,p+f),p+=f}return d}(e,l.runs,l.numRleValues):$f(e,l.runs,l.numRleValues)}(e,l,c);case Sf.MORTON:return Yf(e),e;case Sf.COMPONENTWISE_DELTA:return Kf(e),e;case Sf.NONE:return c&&function(e){for(let l=0;l>>1^-(1&c)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${l.logicalLevelTechnique1}`)}}(tm(e,l,c),c,d)}function em(e,l,c){return function(e,l){if(l.logicalLevelTechnique1===Sf.DELTA&&l.logicalLevelTechnique2===Sf.NONE){const l=function(e){const l=new Int32Array(e.length+1);l[0]=0,l[1]=Uf(e[0]);let c=l[1],d=2;for(;d!=l.length;++d){const p=e[d-1];c+=p>>>1^-(1&p),l[d]=l[d-1]+c}return l}(e);return l}if(l.logicalLevelTechnique1===Sf.RLE&&l.logicalLevelTechnique2===Sf.NONE){const c=function(e,l,c){const d=new Int32Array(c+1);d[0]=0;let p=1,f=d[0];for(let c=0;c>>1^-(1&_);for(let e=p;e>1n^-(1n&e[0]);const l=e.length/4*4;let c=1;if(l>=4)for(;c>1n^-(1n&l))+e[c-1],e[c+1]=(d>>1n^-(1n&d))+e[c],e[c+2]=(p>>1n^-(1n&p))+e[c+1],e[c+3]=(f>>1n^-(1n&f))+e[c+2]}for(;c!=e.length;++c)e[c]=(e[c]>>1n^-(1n&e[c]))+e[c-1]}(e),e);case Sf.RLE:return function(e,l,c){return c?function(e,l,c){const d=new BigInt64Array(c);let p=0;for(let c=0;c>1n^-(1n&m),d.fill(m,p,p+f),p+=f}return d}(e,l.runs,l.numRleValues):Wf(e,l.runs,l.numRleValues)}(e,l,c);case Sf.NONE:return c&&function(e){for(let l=0;l>1n^-(1n&c)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${l.logicalLevelTechnique1}`)}}(Vf(e,l,c.numValues),c,d)}function om(e,l,c,d){const p=Vf(e,l,c.numValues);if(1===p.length){const e=p[0];return d?qf(e):e}return d?function(e){return qf(e[1])}(p):function(e){return e[1]}(p)}function am(e,l,c,d,p){return function(e,l,c,d){switch(l.logicalLevelTechnique1){case Sf.DELTA:return l.logicalLevelTechnique2===Sf.RLE&&(e=$f(e,l.runs,l.numRleValues)),function(e,l){const c=new Int32Array(e.size());let d=0;e.get(0)?(c[0]=e.get(0)?l[0]>>>1^-(1&l[0]):0,d=1):c[0]=0;let p=1;for(;p!=c.length;++p)c[p]=e.get(p)?c[p-1]+(l[d]>>>1^-(1&l[d++])):c[p-1];return c}(d,e);case Sf.RLE:return function(e,l,c,d){const p=l;return c?function(e,l,c){const d=new Int32Array(e.size());let p=0;for(let f=0;f>>1^-(1&_);for(let l=p;l>>1^-(1&e)}else c[p]=0;return c}(d,e):function(e,l){const c=new Int32Array(e.size());let d=0,p=0;for(;p!=c.length;++p)c[p]=e.get(p)?l[d++]:0;return c}(d,e),e;default:throw new Error("The specified Logical level technique is not supported")}}(c.physicalLevelTechnique===Pf.FAST_PFOR?Gf():Of(e,l,c.numValues),c,d,p)}function lm(e,l,c,d){const p=e.logicalLevelTechnique1;if(p===Sf.RLE)return 1===e.runs?kf.CONST:kf.FLAT;const f=l instanceof Ep?l.size():l;if(p===Sf.DELTA&&e.logicalLevelTechnique2===Sf.RLE){const l=e.runs,p=2;if(e.numRleValues!==f)return kf.FLAT;if(1===l)return kf.SEQUENCE;if(2===l){const l=d.get();let f;if(e.physicalLevelTechnique===Pf.VARINT)f=Of(c,d,4);else{const e=d.get();f=new Int32Array(c.buffer,c.byteOffset+e,4)}if(d.set(l),f[2]===p&&f[3]===p)return kf.SEQUENCE}}return 1===e.numValues?kf.CONST:kf.FLAT}class Lp extends Zh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Op extends Wh{constructor(e,l,c,d){super(e,BigInt64Array.of(l),c,d)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class Rp{_geometryOffsets;_partOffsets;_ringOffsets;constructor(e,l,c){this._geometryOffsets=e,this._partOffsets=l,this._ringOffsets=c}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}function cm(e,l,c){return{x:hm(e,l)-c,y:hm(e>>1,l)-c}}function hm(e,l){let c=0;for(let d=0;d>d;return c}!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"}(Rf||(Rf={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(Lf||(Lf={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(Bf||(Bf={}));class Up{createPoint(e){return[[e]]}createMultiPoint(e){return e.map((e=>[e]))}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,l){return[e].concat(l)}createMultiPolygon(e){return e.flat()}}function um(e){const l=new Array(e.numGeometries);let c=1,p=1,f=1,m=0;const _=new Up;let g=0,y=0;const b=e.mortonSettings,T=e.topologyVector,S=T.geometryOffsets,P=T.partOffsets,I=T.ringOffsets,C=e.vertexOffsets,R=e.containsPolygonGeometry(),L=e.vertexBuffer;for(let T=0;T0&&l.push(l[0]),T.push(l)}e[l]=T,f&&y++}break;case Rf.MULTIPOLYGON:{const b=f[y]-f[y-1];y++;const T=[];for(let e=0;e0&&l.push(l[0]),T.push(l)}}e[l]=T}}return e}[Symbol.iterator](){return null}}function ym(e,l,c,d,p,f){return new ef(e,l,c,d,p,f)}class ef extends Qp{_numGeometries;_geometryType;constructor(e,l,c,d,p,f){super(c,d,p,f),this._numGeometries=e,this._geometryType=l}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function xm(e,l,c,d,p){return new nf(e,l,c,d,p)}class nf extends Qp{_geometryTypes;constructor(e,l,c,d,p){super(l,c,d,p),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function vm(e,l,c,d,p){const f=Qf(e,c);let m=null,_=null,g=null,y=null,b=null,T=null,S=null,P=null;if(lm(f,d,e,c)===kf.CONST){const p=im(e,c,f,!1);for(let d=0;dc?l[f++]:1);return d}function wm(e,l,c,d){const p=new Int32Array(l[l.length-1]+1);let f=0;p[0]=f;let m=1,_=0;for(let g=0;g=12?Pm.decode(e.subarray(l,c)):function(e,l,c){let d="",p=l;for(;p239?4:l>223?3:l>191?2:1;if(p+y>c)break;1===y?l<128&&(g=l):2===y?(f=e[p+1],128==(192&f)&&(g=(31&l)<<6|63&f,g<=127&&(g=null))):3===y?(f=e[p+1],m=e[p+2],128==(192&f)&&128==(192&m)&&(g=(15&l)<<12|(63&f)<<6|63&m,(g<=2047||g>=55296&&g<=57343)&&(g=null))):4===y&&(f=e[p+1],m=e[p+2],_=e[p+3],128==(192&f)&&128==(192&m)&&128==(192&_)&&(g=(15&l)<<18|(63&f)<<12|(63&m)<<6|63&_,(g<=65535||g>=1114112)&&(g=null))),null===g?(g=65533,y=1):g>65535&&(g-=65536,d+=String.fromCharCode(g>>>10&1023|55296),g=56320|1023&g),d+=String.fromCharCode(g),p+=y}return d}(e,l,c)}class yf extends Yh{offsetBuffer;constructor(e,l,c,d){super(e,c,d),this.offsetBuffer=l}}class mf extends yf{textEncoder;constructor(e,l,c,d){super(e,l,c,d??l.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return Mm(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class gf extends yf{indexBuffer;textEncoder;constructor(e,l,c,d,p){super(e,c,d,p??l.length),this.indexBuffer=l,this.indexBuffer=l,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const l=this.indexBuffer[e];return Mm(this.dataBuffer,this.offsetBuffer[l],this.offsetBuffer[l+1])}}class xf extends yf{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,l,c,d,p,f,m){super(e,c,d,m),this.indexBuffer=l,this.symbolOffsetBuffer=p,this.symbolTableBuffer=f,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,l,c){const d=[],p=new Array(l.length).fill(0);for(let e=1;e>1n^-(1n&l[0]):0n,d=1):c[0]=0n;let p=1;for(;p!=c.length;++p)c[p]=e.get(p)?c[p-1]+(l[d]>>1n^-(1n&l[d++])):c[p-1];return c}(d,e);case Sf.RLE:return function(e,l,c,d){const p=l;return c?function(e,l,c){const d=new BigInt64Array(e.size());let p=0;for(let f=0;f>1n^-(1n&_);for(let l=p;l>1n^-(1n&e)}else c[p]=0n;return c}(d,e):function(e,l){const c=new BigInt64Array(e.size());let d=0,p=0;for(;p!=c.length;++p)c[p]=e.get(p)?l[d++]:0n;return c}(d,e),e;default:throw new Error("The specified Logical level technique is not supported")}}(Vf(e,l,c.numValues),c,d,p)}(e,l,f,_,d):sm(e,l,f,_);return new Lp(c.name,p,d)}if(m===kf.SEQUENCE){const d=nm(e,l,f);return new Op(c.name,d[0],d[1],f.numRleValues)}{const p=om(e,l,f,_);return new cf(c.name,p,d)}}(l,c,f,g,p);case 7:return function(e,l,c,d){const p=Qf(e,l),f=Em(d)?function(e,l,c,d){const p=l.get(),f=p+d*Float32Array.BYTES_PER_ELEMENT,m=new Uint8Array(e.subarray(p,f)).buffer,_=new Float32Array(m);l.set(f);const g=c.size(),y=new Float32Array(g);let b=0;for(let e=0;e>>0,d=!!(4&c),p=!!(2&c),f=Of(e,l,1)[0]>>>0,m={};if(1&c&&(m.nullable=!0),p){const p={};if(d?(p.type="logicalType",p.logicalType=f):(p.type="physicalType",p.physicalType=f),8&c){const c=Of(e,l,1)[0]>>>0;p.children=new Array(c);for(let d=0;d>>0,d=function(e){switch(e){case 0:case 1:case 2:case 3:{const l={};l.nullable=!!(1&e),l.columnScope=0;const c={};return c.physicalType=e>1?6:4,c.type="physicalType",l.scalarType=c,l.type="scalarType",l}case 4:{const e={nullable:!1,columnScope:0},l={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=l,e}case 30:{const e={nullable:!1,columnScope:0},l={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=l,e}default:return function(e){let l=null;switch(e){case 10:case 11:l=0;break;case 12:case 13:l=1;break;case 14:case 15:l=2;break;case 16:case 17:l=3;break;case 18:case 19:l=4;break;case 20:case 21:l=5;break;case 22:case 23:l=6;break;case 24:case 25:l=7;break;case 26:case 27:l=8;break;case 28:case 29:l=9;break;default:return null}const c={};c.nullable=!!(1&e),c.columnScope=0;const d={type:"physicalType"};return d.physicalType=l,c.type="scalarType",c.scalarType=d,c}(e)}}(c);if(!d)throw new Error(`Unsupported column type code: ${c}`);if(function(e){return e>=10}(c)?d.name=Dm(e,l):c>=0&&c<=3?d.name="id":4===c&&(d.name="geometry"),function(e){return 30===e}(c)){const c=Of(e,l,1)[0]>>>0,p=d.complexType;p.children=new Array(c);for(let d=0;d>>0,f=Of(e,l,1)[0]>>>0;d.columns=new Array(f);for(let c=0;c=4)for(;c>>0,f=d.get()+l;if(f>e.length)throw new Error(`Block overruns tile: ${f} > ${e.length}`);if(1!=Of(e,d,1)[0]>>>0){d.set(f);continue}const m=Rm(e,d),_=m[1],g=m[0].featureTables[0];let y=null,b=null;const T=[];let S=0;for(const l of g.columns){const p=l.name;if("id"===p){let f=null;if(l.nullable){const l=Qf(e,d),c=d.get(),p=Tm(e,l.numValues,d);d.set(c+l.byteLength),f=new Ep(p,l.numValues)}const m=Qf(e,d);S=m.decompressedCount,y=Lm(e,l,d,p,m,f??S,c)}else if("geometry"===p){const l=Of(e,d,1)[0];if(0===S){const l=d.get();S=Qf(e,d).decompressedCount,d.set(l)}b=vm(e,l,d,S)}else{const c=Cm(l)?Of(e,d,1)[0]:1;if(0===c&&"scalarType"===l.type)continue;const p=Im(e,d,l,c,S);if(p)if(Array.isArray(p))for(const e of p)T.push(e);else T.push(p)}}const P=new tp(g.name,b,y,T,_);p.push(P),d.set(f)}return p}(new Uint8Array(e));this.layers=l.reduce(((e,l)=>Object.assign(Object.assign({},e),{[l.name]:new Mf(l)})),{})}}class Df{constructor(e,l){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=l,"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=[],l=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const c of l){const l=[];for(const e of c)l.push(new d(e[0],e[1]));e.push(l)}return e}}const Fm="_geojsonTileLayer";function Bm(e,l){l.writeVarintField(15,e.version||1),l.writeStringField(1,e.name||""),l.writeVarintField(5,e.extent||4096);const c={keys:[],values:[],keycache:{},valuecache:{}};for(let d=0;d>31}function Gm(e,l){const c=e.loadGeometry(),d=e.type;let p=0,f=0;for(const m of c){let c=1;1===d&&(c=m.length),l.writeVarint(jm(1,c));const _=3===d?m.length-1:m.length;for(let e=0;e<_;e++){1===e&&1!==d&&l.writeVarint(jm(2,_-1));const c=m[e].x-p,g=m[e].y-f;l.writeVarint(Nm(c)),l.writeVarint(Nm(g)),p+=c,f+=g}3===e.type&&l.writeVarint(jm(7,1))}}function Um(e,l){const c=typeof e;"string"===c?l.writeStringField(1,e):"boolean"===c?l.writeBooleanField(7,e):"number"===c&&(e%1!=0?l.writeDoubleField(3,e):e<0?l.writeSVarintField(6,e):l.writeVarintField(5,e))}class Nf{constructor(e,l){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new cs(re,16,0),this.grid3D=new cs(re,16,0),this.featureIndexArray=new Na,this.promoteId=l}insert(e,l,c,d,p,f){const m=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(c,d,p);const _=f?this.grid3D:this.grid;for(let e=0;e=0&&d[3]>=0&&_.insert(m,d[0],d[1],d[2],d[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():[Fm])),this.vtLayers}query(e,l,c,p){this.loadVTLayers();const f=e.params,m=re/e.tileSize/e.scale,_=Ko(f.filter,f.globalState),g=e.queryGeometry,y=e.queryPadding*m,b=jh.fromPoints(g),T=this.grid.query(b.minX-y,b.minY-y,b.maxX+y,b.maxY+y),S=jh.fromPoints(e.cameraQueryGeometry).expandBy(y),P=this.grid3D.query(S.minX,S.minY,S.maxX,S.maxY,((l,c,p,f)=>function(e,l,c,p,f){for(const d of e)if(l<=d.x&&c<=d.y&&p>=d.x&&f>=d.y)return!0;const m=[new d(l,c),new d(l,f),new d(p,f),new d(p,c)];if(e.length>2)for(const l of m)if(bh(e,l))return!0;for(let l=0;l(S||(S=ih(l)),c.queryIntersectsFeature({queryGeometry:g,feature:l,featureState:d,geometry:S,zoom:this.z,transform:e.transform,pixelsToTileUnits:m,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return I}loadMatchingFeature(e,l,c,d,p,f,m,_,g,y,b){const T=this.bucketLayerIDs[l];if(f&&!T.some((e=>f.has(e))))return;const S=this.sourceLayerCoder.decode(c),P=this.vtLayers[S].feature(d);if(p.needGeometry){const e=rh(P,!0);if(!p.filter(new Ps(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!p.filter(new Ps(this.tileID.overscaledZ),P))return;const I=this.getId(P,S);for(let l=0;l{const m=l instanceof qs?l.get(f):null;return m&&m.evaluate?m.evaluate(c,d,p):m}))}function Zm(e,l){return l-e}function $m(e,l,c,p,f){const m=[];for(let _=0;_=p&&b.x>=p||(_.x>=p?_=new d(p,_.y+(p-_.x)/(b.x-_.x)*(b.y-_.y))._round():b.x>=p&&(b=new d(p,_.y+(p-_.x)/(b.x-_.x)*(b.y-_.y))._round()),_.y>=f&&b.y>=f||(_.y>=f?_=new d(_.x+(f-_.y)/(b.y-_.y)*(b.x-_.x),f)._round():b.y>=f&&(b=new d(_.x+(f-_.y)/(b.y-_.y)*(b.x-_.x),f)._round()),y&&_.equals(y[y.length-1])||(y=[_],m.push(y)),y.push(b)))))}}return m}function Wm(e,l,c,d,p){switch(l){case 1:return function(e,l,c,d){const p=[];for(const f of e)for(const e of f){const f=0===d?e.x:e.y;f>=l&&f<=c&&p.push([e])}return p}(e,c,d,p);case 2:return Xm(e,c,d,p,!1);case 3:return Xm(e,c,d,p,!0)}return[]}function Hm(e,l,c,p,f){const m=0===p?Ym:Km;let _=[];const g=[];for(let d=0;dl&&_.push(m(y,b,l)):T>c?S=l&&(_.push(m(y,b,l)),P=!0),S>c&&T<=c&&(_.push(m(y,b,c)),P=!0),!f&&P&&(g.push(_),_=[])}const y=e.length-1,b=0===p?e[y].x:e[y].y;return b>=l&&b<=c&&_.push(e[y]),f&&_.length>0&&!_[0].equals(_[_.length-1])&&_.push(new d(_[0].x,_[0].y)),_.length>0&&g.push(_),g}function Xm(e,l,c,d,p){const f=[];for(const m of e){const e=Hm(m,l,c,d,p);e.length>0&&f.push(...e)}return f}function Ym(e,l,c){return new d(c,e.y+(c-e.x)/(l.x-e.x)*(l.y-e.y))}function Km(e,l,c){return new d(e.x+(c-e.y)/(l.y-e.y)*(l.x-e.x),c)}ec("FeatureIndex",Nf,{omit:["rawTileData","sourceLayerCoder"]});class Hf extends d{constructor(e,l,c,d){super(e,l),this.angle=c,void 0!==d&&(this.segment=d)}clone(){return new Hf(this.x,this.y,this.angle,this.segment)}}function Qm(e,l,c,d,p){if(void 0===l.segment||0===c)return!0;let f=l,m=l.segment+1,_=0;for(;_>-c/2;){if(m--,m<0)return!1;_-=e[m].dist(f),f=e[m]}_+=e[m].dist(e[m+1]),m++;const g=[];let y=0;for(;_d;)y-=g.shift().angleDelta;if(y>p)return!1;m++,_+=l.dist(c)}return!0}function Jm(e){let l=0;for(let c=0;cy){const b=(y-g)/f,T=_n.number(d.x,p.x,b),S=_n.number(d.y,p.y,b),P=new Hf(T,S,p.angleTo(d),c);return P._round(),!m||Qm(e,P,_,m,l)?P:void 0}g+=f}}function r_(e,l,c,d,p,f,m,_,g){const y=e_(d,f,m),b=t_(d,p),T=b*m,S=0===e[0].x||e[0].x===g||0===e[0].y||e[0].y===g;return l-T=0&&L=0&&F=0&&S+y<=b){const c=new Hf(L,F,C,l);c._round(),d&&!Qm(e,c,f,d,p)||P.push(c)}}T+=I}return _||P.length||m||(P=n_(e,T/2,c,d,p,f,m,!0,g)),P}function s_(e,l,c,p){const f=[],m=e.image,_=m.pixelRatio,g=m.paddedRect.w-2,y=m.paddedRect.h-2;let b={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const T=m.stretchX||[[0,g]],S=m.stretchY||[[0,y]],P=(e,l)=>e+l[1]-l[0],I=T.reduce(P,0),C=S.reduce(P,0),R=g-I,L=y-C;let F=0,B=I,O=0,V=C,j=0,G=R,U=0,q=L;if(m.content&&p){const l=m.content,c=l[2]-l[0],d=l[3]-l[1];(m.textFitWidth||m.textFitHeight)&&(b=Cp(e)),F=o_(T,0,l[0]),O=o_(S,0,l[1]),B=o_(T,l[0],l[2]),V=o_(S,l[1],l[3]),j=l[0]-F,U=l[1]-O,G=c-B,q=d-V}const Z=b.x1,W=b.y1,Q=b.x2-Z,J=b.y2-W,re=(e,p,f,g)=>{const y=l_(e.stretch-F,B,Q,Z),b=c_(e.fixed-j,G,e.stretch,I),T=l_(p.stretch-O,V,J,W),S=c_(p.fixed-U,q,p.stretch,C),P=l_(f.stretch-F,B,Q,Z),R=c_(f.fixed-j,G,f.stretch,I),L=l_(g.stretch-O,V,J,W),re=c_(g.fixed-U,q,g.stretch,C),oe=new d(y,T),le=new d(P,T),ce=new d(P,L),he=new d(y,L),ue=new d(b/_,S/_),pe=new d(R/_,re/_),fe=l*Math.PI/180;if(fe){const e=Math.sin(fe),l=Math.cos(fe),c=[l,-e,e,l];oe._matMult(c),le._matMult(c),he._matMult(c),ce._matMult(c)}const me=e.stretch+e.fixed,ge=p.stretch+p.fixed;return{tl:oe,tr:le,bl:he,br:ce,tex:{x:m.paddedRect.x+1+me,y:m.paddedRect.y+1+ge,w:f.stretch+f.fixed-me,h:g.stretch+g.fixed-ge},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ue,pixelOffsetBR:pe,minFontScaleX:G/_/Q,minFontScaleY:q/_/J,isSDF:c}};if(p&&(m.stretchX||m.stretchY)){const e=a_(T,R,I),l=a_(S,L,C);for(let c=0;c0&&(d=Math.max(10,d),this.circleDiameter=d)}else{const y=(null===(T=m.image)||void 0===T?void 0:T.content)&&(m.image.textFitWidth||m.image.textFitHeight)?Cp(m):{x1:m.left,y1:m.top,x2:m.right,y2:m.bottom};y.y1=y.y1*_-g[0],y.y2=y.y2*_+g[2],y.x1=y.x1*_-g[3],y.x2=y.x2*_+g[1];const S=m.collisionPadding;if(S&&(y.x1-=S[0]*_,y.y1-=S[1]*_,y.x2+=S[2]*_,y.y2+=S[3]*_),b){const e=new d(y.x1,y.y1),l=new d(y.x2,y.y1),c=new d(y.x1,y.y2),p=new d(y.x2,y.y2),f=b*Math.PI/180;e._rotate(f),l._rotate(f),c._rotate(f),p._rotate(f),y.x1=Math.min(e.x,l.x,c.x,p.x),y.x2=Math.max(e.x,l.x,c.x,p.x),y.y1=Math.min(e.y,l.y,c.y,p.y),y.y2=Math.max(e.y,l.y,c.y,p.y)}e.emplaceBack(l.x,l.y,y.x1,y.y1,y.x2,y.y2,c,p,f)}this.boxEndIndex=e.length}}class ud{constructor(e=[],l=(e,l)=>el?1:0){if(this.data=e,this.length=this.data.length,this.compare=l,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],l=this.data.pop();return--this.length>0&&(this.data[0]=l,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:l,compare:c}=this,d=l[e];for(;e>0;){const p=e-1>>1,f=l[p];if(c(d,f)>=0)break;l[e]=f,e=p}l[e]=d}_down(e){const{data:l,compare:c}=this,d=this.length>>1,p=l[e];for(;e=0)break;l[e]=l[d],e=d}l[e]=p}}function h_(e,l=1,c=!1){const p=jh.fromPoints(e[0]),f=Math.min(p.width(),p.height());let m=f/2;const _=new ud([],u_),{minX:g,minY:y,maxX:b,maxY:T}=p;if(0===f)return new d(g,y);for(let l=g;lS.d||!S.d)&&(S=d,c&&console.log("found best %d after %d probes",Math.round(1e4*d.d)/1e4,P)),d.max-S.d<=l||(m=d.h/2,_.push(new d_(d.p.x-m,d.p.y-m,m,e)),_.push(new d_(d.p.x+m,d.p.y-m,m,e)),_.push(new d_(d.p.x-m,d.p.y+m,m,e)),_.push(new d_(d.p.x+m,d.p.y+m,m,e)),P+=4)}return c&&(console.log(`num probes: ${P}`),console.log(`best distance: ${S.d}`)),S.p}function u_(e,l){return l.max-e.max}function d_(l,c,p,f){(this||e).p=new d(l,c),(this||e).h=p,(this||e).d=function(e,l){let c=!1,d=1/0;for(let p=0;pe.y!=_.y>e.y&&e.x<(_.x-p.x)*(e.y-p.y)/(_.y-p.y)+p.x&&(c=!c),d=Math.min(d,yh(e,p,_))}}return(c?1:-1)*Math.sqrt(d)}((this||e).p,f),(this||e).max=(this||e).d+(this||e).h*Math.SQRT2}var p_;l.aP=void 0,(p_=l.aP||(l.aP={}))[p_.center=1]="center",p_[p_.left=2]="left",p_[p_.right=3]="right",p_[p_.top=4]="top",p_[p_.bottom=5]="bottom",p_[p_["top-left"]=6]="top-left",p_[p_["top-right"]=7]="top-right",p_[p_["bottom-left"]=8]="bottom-left",p_[p_["bottom-right"]=9]="bottom-right";const f_=Number.POSITIVE_INFINITY;function m_(e,l){return l[1]!==f_?function(e,l,c){let d=0,p=0;switch(l=Math.abs(l),c=Math.abs(c),e){case"top-right":case"top-left":case"top":p=c-7;break;case"bottom-right":case"bottom-left":case"bottom":p=7-c}switch(e){case"top-right":case"bottom-right":case"right":d=-l;break;case"top-left":case"bottom-left":case"left":d=l}return[d,p]}(e,l[0],l[1]):function(e,l){let c=0,d=0;l<0&&(l=0);const p=l/Math.SQRT2;switch(e){case"top-right":case"top-left":d=p-7;break;case"bottom-right":case"bottom-left":d=7-p;break;case"bottom":d=7-l;break;case"top":d=l-7}switch(e){case"top-right":case"bottom-right":c=-p;break;case"top-left":case"bottom-left":c=p;break;case"left":c=l;break;case"right":c=-l}return[c,d]}(e,l[0])}function __(e,l,c){var d;const p=e.layout,f=null===(d=p.get("text-variable-anchor-offset"))||void 0===d?void 0:d.evaluate(l,{},c);if(f){const e=f.values,l=[];for(let c=0;ce*Ud));d.startsWith("top")?p[1]-=7:d.startsWith("bottom")&&(p[1]+=7),l[c+1]=p}return new Le(l)}const m=p.get("text-variable-anchor");if(m){let d;d=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[p.get("text-radial-offset").evaluate(l,{},c)*Ud,f_]:p.get("text-offset").evaluate(l,{},c).map((e=>e*Ud));const f=[];for(const e of m)f.push(e,m_(e,d));return new Le(f)}return null}function g_(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 y_(e,c,d,p,f,m,_,g,y,b,T,S){let P=m.textMaxSize.evaluate(c,{});void 0===P&&(P=_);const I=e.layers[0].layout,C=I.get("icon-offset").evaluate(c,{},T),R=v_(d.horizontal),L=_/24,F=e.tilePixelRatio*L,B=e.tilePixelRatio*P/24,O=e.tilePixelRatio*g,V=e.tilePixelRatio*I.get("symbol-spacing"),j=I.get("text-padding")*e.tilePixelRatio,G=function(e,l,c,d=1){const p=e.get("icon-padding").evaluate(l,{},c),f=p&&p.values;return[f[0]*d,f[1]*d,f[2]*d,f[3]*d]}(I,c,T,e.tilePixelRatio),U=I.get("text-max-angle")/180*Math.PI,q="viewport"!==I.get("text-rotation-alignment")&&"point"!==I.get("symbol-placement"),Z="map"===I.get("icon-rotation-alignment")&&"point"!==I.get("symbol-placement"),W=I.get("symbol-placement"),Q=V/2,J=I.get("icon-text-fit");let oe;p&&"none"!==J&&(e.allowVerticalPlacement&&d.vertical&&(oe=Dp(p,d.vertical,J,I.get("icon-text-fit-padding"),C,L)),R&&(p=Dp(p,R,J,I.get("icon-text-fit-padding"),C,L)));const le=T?S.line.getGranularityForZoomLevel(T.z):1,ce=(g,S)=>{S.x<0||S.x>=re||S.y<0||S.y>=re||function(e,c,d,p,f,m,_,g,y,b,T,S,P,I,C,R,L,F,B,O,V,j,G,U,q){const Z=e.addToLineVertexArray(c,d);let W,Q,J,re,oe=0,le=0,ce=0,he=0,ue=-1,pe=-1;const fe={};let me=$c("");if(e.allowVerticalPlacement&&p.vertical){const e=g.layout.get("text-rotate").evaluate(V,{},U)+90;J=new ld(y,c,b,T,S,p.vertical,P,I,C,e),_&&(re=new ld(y,c,b,T,S,_,L,F,C,e))}if(f){const d=g.layout.get("icon-rotate").evaluate(V,{}),p="none"!==g.layout.get("icon-text-fit"),m=s_(f,d,G,p),P=_?s_(_,d,G,p):void 0;Q=new ld(y,c,b,T,S,f,L,F,!1,d),oe=4*m.length;const I=e.iconSizeData;let C=null;"source"===I.kind?(C=[zp*g.layout.get("icon-size").evaluate(V,{})],C[0]>kp&&Se(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===I.kind&&(C=[zp*j.compositeIconSizes[0].evaluate(V,{},U),zp*j.compositeIconSizes[1].evaluate(V,{},U)],(C[0]>kp||C[1]>kp)&&Se(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,m,C,O,B,V,l.az.none,c,Z.lineStartIndex,Z.lineLength,-1,U),ue=e.icon.placedSymbolArray.length-1,P&&(le=4*P.length,e.addSymbols(e.icon,P,C,O,B,V,l.az.vertical,c,Z.lineStartIndex,Z.lineLength,-1,U),pe=e.icon.placedSymbolArray.length-1)}const ge=Object.keys(p.horizontal);for(const d of ge){const f=p.horizontal[d];if(!W){me=$c(f.text);const e=g.layout.get("text-rotate").evaluate(V,{},U);W=new ld(y,c,b,T,S,f,P,I,C,e)}const _=1===f.positionedLines.length;if(ce+=x_(e,c,f,m,g,C,V,R,Z,p.vertical?l.az.horizontal:l.az.horizontalOnly,_?ge:[d],fe,ue,j,U),_)break}p.vertical&&(he+=x_(e,c,p.vertical,m,g,C,V,R,Z,l.az.vertical,["vertical"],fe,pe,j,U));const ye=W?W.boxStartIndex:e.collisionBoxArray.length,xe=W?W.boxEndIndex:e.collisionBoxArray.length,ve=J?J.boxStartIndex:e.collisionBoxArray.length,be=J?J.boxEndIndex:e.collisionBoxArray.length,we=Q?Q.boxStartIndex:e.collisionBoxArray.length,Me=Q?Q.boxEndIndex:e.collisionBoxArray.length,Ee=re?re.boxStartIndex:e.collisionBoxArray.length,Ce=re?re.boxEndIndex:e.collisionBoxArray.length;let Ae=-1;const Ne=(e,l)=>e&&e.circleDiameter?Math.max(e.circleDiameter,l):l;Ae=Ne(W,Ae),Ae=Ne(J,Ae),Ae=Ne(Q,Ae),Ae=Ne(re,Ae);const Ge=Ae>-1?1:0;Ge&&(Ae*=q/Ud),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!==V.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,V.sortKey);const Ue=__(g,V,U),[qe,$e]=function(e,c){const d=e.length,p=null==c?void 0:c.values;if((null==p?void 0:p.length)>0)for(let c=0;c=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,b,ce,he,oe,le,Ge,0,P,Ae,qe,$e)}(e,S,g,d,p,f,oe,e.layers[0],e.collisionBoxArray,c.index,c.sourceLayerIndex,e.index,F,[j,j,j,j],q,y,O,G,Z,C,c,m,b,T,_)};if("line"===W)for(const l of $m(c.geometry,0,0,re,re)){const c=Ju(l,le),f=r_(c,V,U,d.vertical||R,p,24,B,e.overscaling,re);for(const l of f)R&&b_(e,R.text,Q,l)||ce(c,l)}else if("line-center"===W){for(const e of c.geometry)if(e.length>1){const l=Ju(e,le),c=i_(l,U,d.vertical||R,p,24,B);c&&ce(l,c)}}else if("Polygon"===c.type)for(const e of Kn(c.geometry,0)){const l=h_(e,16);ce(Ju(e[0],le,!0),new Hf(l.x,l.y,0))}else if("LineString"===c.type)for(const e of c.geometry){const l=Ju(e,le);ce(l,new Hf(l[0].x,l[0].y,0))}else if("Point"===c.type)for(const e of c.geometry)for(const l of e)ce([l],new Hf(l.x,l.y,0))}function x_(e,l,c,p,f,m,_,g,y,b,T,S,P,I,C){const R=function(e,l,c,p,f,m,_,g){const y=p.layout.get("text-rotate").evaluate(m,{})*Math.PI/180,b=[];for(const e of l.positionedLines)for(const p of e.positionedGlyphs){if(!p.rect)continue;const m=p.rect||{};let T=4,S=!0,P=1,I=0;const C=(f||g)&&p.vertical,R=p.metrics.advance*p.scale/2;if(g&&l.verticalizable&&(I=e.lineOffset/2-(p.imageName?-(Ud-p.metrics.width*p.scale)/2:(p.scale-1)*Ud)),p.imageName){const e=_[p.imageName];S=e.sdf,P=e.pixelRatio,T=1/P}const L=f?[p.x+R,p.y]:[0,0];let F=f?[0,0]:[p.x+R+c[0],p.y+c[1]-I],B=[0,0];C&&(B=F,F=[0,0]);const O=p.metrics.isDoubleResolution?2:1,V=(p.metrics.left-T)*p.scale-R+F[0],j=(-p.metrics.top-T)*p.scale+F[1],G=V+m.w/O*p.scale/P,U=j+m.h/O*p.scale/P,q=new d(V,j),Z=new d(G,j),W=new d(V,U),Q=new d(G,U);if(C){const e=new d(-R,R- -17),l=-Math.PI/2,c=12-R,f=new d(22-c,-(p.imageName?c:0)),m=new d(...B);q._rotateAround(l,e)._add(f)._add(m),Z._rotateAround(l,e)._add(f)._add(m),W._rotateAround(l,e)._add(f)._add(m),Q._rotateAround(l,e)._add(f)._add(m)}if(y){const e=Math.sin(y),l=Math.cos(y),c=[l,-e,e,l];q._matMult(c),Z._matMult(c),W._matMult(c),Q._matMult(c)}const J=new d(0,0),re=new d(0,0);b.push({tl:q,tr:Z,bl:W,br:Q,tex:m,writingMode:l.writingMode,glyphOffset:L,sectionIndex:p.sectionIndex,isSDF:S,pixelOffsetTL:J,pixelOffsetBR:re,minFontScaleX:0,minFontScaleY:0})}return b}(0,c,g,f,m,_,p,e.allowVerticalPlacement),L=e.textSizeData;let F=null;"source"===L.kind?(F=[zp*f.layout.get("text-size").evaluate(_,{})],F[0]>kp&&Se(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===L.kind&&(F=[zp*I.compositeTextSizes[0].evaluate(_,{},C),zp*I.compositeTextSizes[1].evaluate(_,{},C)],(F[0]>kp||F[1]>kp)&&Se(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,R,F,g,m,_,b,l,y.lineStartIndex,y.lineLength,P,C);for(const l of T)S[l]=e.text.placedSymbolArray.length-1;return 4*R.length}function v_(e){for(const l in e)return e[l];return null}function b_(e,l,c,d){const p=e.compareText;if(l in p){const e=p[l];for(let l=e.length-1;l>=0;l--)if(d.dist(e[l])>4;if(1!==d)throw new Error(`Got v${d} data when expected v1.`);const p=w_[15&c];if(!p)throw new Error("Unrecognized array type.");const[f]=new Uint16Array(e,2,1),[m]=new Uint32Array(e,4,1);return new Sd(m,f,p,e)}constructor(e,l=64,c=Float64Array,d){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+l,2),65535),this.ArrayType=c,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const p=w_.indexOf(this.ArrayType),f=2*e*this.ArrayType.BYTES_PER_ELEMENT,m=e*this.IndexArrayType.BYTES_PER_ELEMENT,_=(8-m%8)%8;if(p<0)throw new Error(`Unexpected typed array class: ${c}.`);d&&d instanceof ArrayBuffer?(this.data=d,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+m+_,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+f+m+_),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+m+_,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+p]),new Uint16Array(this.data,2,1)[0]=l,new Uint32Array(this.data,4,1)[0]=e)}add(e,l){const c=this._pos>>1;return this.ids[c]=c,this.coords[this._pos++]=e,this.coords[this._pos++]=l,c}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return T_(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,l,c,d){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:p,coords:f,nodeSize:m}=this,_=[0,p.length-1,0],g=[];for(;_.length;){const y=_.pop()||0,b=_.pop()||0,T=_.pop()||0;if(b-T<=m){for(let m=T;m<=b;m++){const _=f[2*m],y=f[2*m+1];_>=e&&_<=c&&y>=l&&y<=d&&g.push(p[m])}continue}const S=T+b>>1,P=f[2*S],I=f[2*S+1];P>=e&&P<=c&&I>=l&&I<=d&&g.push(p[S]),(0===y?e<=P:l<=I)&&(_.push(T),_.push(S-1),_.push(1-y)),(0===y?c>=P:d>=I)&&(_.push(S+1),_.push(b),_.push(1-y))}return g}within(e,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],_=[],g=c*c;for(;m.length;){const y=m.pop()||0,b=m.pop()||0,T=m.pop()||0;if(b-T<=f){for(let c=T;c<=b;c++)I_(p[2*c],p[2*c+1],e,l)<=g&&_.push(d[c]);continue}const S=T+b>>1,P=p[2*S],I=p[2*S+1];I_(P,I,e,l)<=g&&_.push(d[S]),(0===y?e-c<=P:l-c<=I)&&(m.push(T),m.push(S-1),m.push(1-y)),(0===y?e+c>=P:l+c>=I)&&(m.push(S+1),m.push(b),m.push(1-y))}return _}}function T_(e,l,c,d,p,f){if(p-d<=c)return;const m=d+p>>1;S_(e,l,m,d,p,f),T_(e,l,c,d,m-1,1-f),T_(e,l,c,m+1,p,1-f)}function S_(e,l,c,d,p,f){for(;p>d;){if(p-d>600){const m=p-d+1,_=c-d+1,g=Math.log(m),y=.5*Math.exp(2*g/3),b=.5*Math.sqrt(g*y*(m-y)/m)*(_-m/2<0?-1:1);S_(e,l,c,Math.max(d,Math.floor(c-_*y/m+b)),Math.min(p,Math.floor(c+(m-_)*y/m+b)),f)}const m=l[2*c+f];let _=d,g=p;for(P_(e,l,d,c),l[2*p+f]>m&&P_(e,l,d,p);_m;)g--}l[2*d+f]===m?P_(e,l,d,g):(g++,P_(e,l,g,p)),g<=c&&(d=g+1),c<=g&&(p=g-1)}}function P_(e,l,c,d){M_(e,c,d),M_(l,2*c,2*d),M_(l,2*c+1,2*d+1)}function M_(e,l,c){const d=e[l];e[l]=e[c],e[c]=d}function I_(e,l,c,d){const p=e-c,f=l-d;return p*p+f*f}var E_;l.cI=void 0,(E_=l.cI||(l.cI={})).create="create",E_.load="load",E_.fullLoad="fullLoad";let C_=null,A_=[];const D_=1e3/60,z_="loadTime",k_="fullLoadTime",R_={mark(e){performance.mark(e)},frame(e){const l=e;null!=C_&&A_.push(l-C_),C_=l},clearMetrics(){C_=null,A_=[],performance.clearMeasures(z_),performance.clearMeasures(k_);for(const e in l.cI)performance.clearMarks(l.cI[e])},getPerformanceMetrics(){performance.measure(z_,l.cI.create,l.cI.load),performance.measure(k_,l.cI.create,l.cI.fullLoad);const e=performance.getEntriesByName(z_)[0].duration,c=performance.getEntriesByName(k_)[0].duration,d=A_.length,p=1/(A_.reduce(((e,l)=>e+l),0)/d/1e3),f=A_.filter((e=>e>D_)).reduce(((e,l)=>e+(l-D_)/D_),0);return{loadTime:e,fullLoadTime:c,fps:p,percentDroppedFrames:f/(d+f)*100,totalFrames:d}}};l.$=T,l.A=I,l.B=Ql,l.C=Wl,l.D=js,l.E=xt,l.F=function([e,l,c]){return l+=90,l*=Math.PI/180,c*=Math.PI/180,{x:e*Math.cos(l)*Math.sin(c),y:e*Math.sin(l)*Math.sin(c),z:e*Math.cos(c)}},l.G=_n,l.H=Ps,l.I=qc,l.J=Xl,l.K=function(e){if(null==Ce){const l=e.navigator?e.navigator.userAgent:null;Ce=!!e.safari||!(!l||!(/\b(iPad|iPhone|iPod)\b/.test(l)||l.match("Safari")&&!l.match("Chrome")))}return Ce},l.L=class{constructor(e,l){this.target=e,this.mapId=l,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,l){this.messageHandlers[e]=l}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,l){return new Promise(((c,d)=>{const p=Math.round(1e18*Math.random()).toString(36).substring(0,10),f=l?$e(l.signal,"abort",(()=>{null==f||f.unsubscribe(),delete this.resolveRejects[p];const l={id:p,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(l)}),Yp):null;this.resolveRejects[p]={resolve:e=>{null==f||f.unsubscribe(),c(e)},reject:e=>{null==f||f.unsubscribe(),d(e)}};const m=[],_=Object.assign(Object.assign({},e),{id:p,sourceMapId:this.mapId,origin:location.origin,data:oc(e.data,m)});this.target.postMessage(_,{transfer:m})}))}receive(e){const l=e.data,c=l.id;if(!("file://"!==l.origin&&"file://"!==location.origin&&"resource://android"!==l.origin&&"resource://android"!==location.origin&&l.origin!==location.origin||l.targetMapId&&this.mapId!==l.targetMapId)){if(""===l.type){delete this.tasks[c];const e=this.abortControllers[c];return delete this.abortControllers[c],void(e&&e.abort())}if(Ee(self)||l.mustQueue)return this.tasks[c]=l,this.taskQueue.push(c),void this.invoker.trigger();this.processTask(c,l)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),l=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),l&&this.processTask(e,l)}processTask(e,l){return c(this,void 0,void 0,(function*(){if(""===l.type){const c=this.resolveRejects[e];if(delete this.resolveRejects[e],!c)return;return void(l.error?c.reject(lc(l.error)):c.resolve(lc(l.data)))}if(!this.messageHandlers[l.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${l.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const c=lc(l.data),d=new AbortController;this.abortControllers[e]=d;try{const p=yield this.messageHandlers[l.type](l.sourceMapId,c,d);this.completeTask(e,null,p)}catch(c){this.completeTask(e,c)}}))}completeTask(e,l,c){const d=[];delete this.abortControllers[e];const p={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:l?oc(l):null,data:oc(c,d)};this.target.postMessage(p,{transfer:d})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},l.M=ft,l.N=function(){var e=new I(16);return I!=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},l.O=function(e,l,c){var d,p,f,m,_,g,y,b,T,S,P,I,C=c[0],R=c[1],L=c[2];return l===e?(e[12]=l[0]*C+l[4]*R+l[8]*L+l[12],e[13]=l[1]*C+l[5]*R+l[9]*L+l[13],e[14]=l[2]*C+l[6]*R+l[10]*L+l[14],e[15]=l[3]*C+l[7]*R+l[11]*L+l[15]):(p=l[1],f=l[2],m=l[3],_=l[4],g=l[5],y=l[6],b=l[7],T=l[8],S=l[9],P=l[10],I=l[11],e[0]=d=l[0],e[1]=p,e[2]=f,e[3]=m,e[4]=_,e[5]=g,e[6]=y,e[7]=b,e[8]=T,e[9]=S,e[10]=P,e[11]=I,e[12]=d*C+_*R+T*L+l[12],e[13]=p*C+g*R+S*L+l[13],e[14]=f*C+y*R+P*L+l[14],e[15]=m*C+b*R+I*L+l[15]),e},l.P=d,l.Q=function(e,l,c){var d=c[0],p=c[1],f=c[2];return e[0]=l[0]*d,e[1]=l[1]*d,e[2]=l[2]*d,e[3]=l[3]*d,e[4]=l[4]*p,e[5]=l[5]*p,e[6]=l[6]*p,e[7]=l[7]*p,e[8]=l[8]*f,e[9]=l[9]*f,e[10]=l[10]*f,e[11]=l[11]*f,e[12]=l[12],e[13]=l[13],e[14]=l[14],e[15]=l[15],e},l.R=Sl,l.S=function(e,l,c){var d=l[0],p=l[1],f=l[2],m=l[3],_=l[4],g=l[5],y=l[6],b=l[7],T=l[8],S=l[9],P=l[10],I=l[11],C=l[12],R=l[13],L=l[14],F=l[15],B=c[0],O=c[1],V=c[2],j=c[3];return e[0]=B*d+O*_+V*T+j*C,e[1]=B*p+O*g+V*S+j*R,e[2]=B*f+O*y+V*P+j*L,e[3]=B*m+O*b+V*I+j*F,e[4]=(B=c[4])*d+(O=c[5])*_+(V=c[6])*T+(j=c[7])*C,e[5]=B*p+O*g+V*S+j*R,e[6]=B*f+O*y+V*P+j*L,e[7]=B*m+O*b+V*I+j*F,e[8]=(B=c[8])*d+(O=c[9])*_+(V=c[10])*T+(j=c[11])*C,e[9]=B*p+O*g+V*S+j*R,e[10]=B*f+O*y+V*P+j*L,e[11]=B*m+O*b+V*I+j*F,e[12]=(B=c[12])*d+(O=c[13])*_+(V=c[14])*T+(j=c[15])*C,e[13]=B*p+O*g+V*S+j*R,e[14]=B*f+O*y+V*P+j*L,e[15]=B*m+O*b+V*I+j*F,e},l.T=zl,l.U=function(e,l){const c={};for(let d=0;d0||(null===(p=c.addOrUpdateProperties)||void 0===p?void 0:p.length)>0;if(!m&&!_)continue;f.push(l.geometry);const g=Object.assign({},l);if(e.set(c.id,g),m&&(f.push(c.newGeometry),g.geometry=c.newGeometry),_){if(g.properties=c.removeAllProperties?{}:Object.assign({},g.properties||{}),c.removeProperties)for(const e of c.removeProperties)delete g.properties[e];if(c.addOrUpdateProperties)for(const{key:e,value:l}of c.addOrUpdateProperties)g.properties[e]=l}}return f},l.a9=Vh,l.aA=function(e,{uSize:l,uSizeT:c},{lowerSize:d,upperSize:p}){return"source"===e.kind?d/zp:"composite"===e.kind?_n.number(d/zp,p/zp,c):l},l.aB=function(e,l){var c=l[0],d=l[1],p=l[2],f=l[3],m=l[4],_=l[5],g=l[6],y=l[7],b=l[8],T=l[9],S=l[10],P=l[11],I=l[12],C=l[13],R=l[14],L=l[15],F=c*_-d*m,B=c*g-p*m,O=c*y-f*m,V=d*g-p*_,j=d*y-f*_,G=p*y-f*g,U=b*C-T*I,q=b*R-S*I,Z=b*L-P*I,W=T*R-S*C,Q=T*L-P*C,J=S*L-P*R,re=F*J-B*Q+O*W+V*Z-j*q+G*U;return re?(e[0]=(_*J-g*Q+y*W)*(re=1/re),e[1]=(p*Q-d*J-f*W)*re,e[2]=(C*G-R*j+L*V)*re,e[3]=(S*j-T*G-P*V)*re,e[4]=(g*Z-m*J-y*q)*re,e[5]=(c*J-p*Z+f*q)*re,e[6]=(R*O-I*G-L*B)*re,e[7]=(b*G-S*O+P*B)*re,e[8]=(m*Q-_*Z+y*U)*re,e[9]=(d*Z-c*Q-f*U)*re,e[10]=(I*j-C*O+L*F)*re,e[11]=(T*O-b*j-P*F)*re,e[12]=(_*q-m*W-g*U)*re,e[13]=(c*W-d*q+p*U)*re,e[14]=(C*B-I*V-R*F)*re,e[15]=(b*V-T*B+S*F)*re,e):null},l.aC=Q,l.aD=function(e){var l=e[0],c=e[1];return Math.sqrt(l*l+c*c)},l.aE=function(e){return e[0]=0,e[1]=0,e},l.aF=function(e,l,c){return e[0]=l[0]*c,e[1]=l[1]*c,e},l.aG=Np,l.aH=q,l.aI=function(e,l,c,p){const f=l.y-e.y,m=l.x-e.x,_=p.y-c.y,g=p.x-c.x,y=_*m-g*f;if(0===y)return null;const b=(g*(e.y-c.y)-_*(e.x-c.x))/y;return new d(e.x+b*m,e.y+b*f)},l.aJ=$m,l.aK=oh,l.aL=function(e){let l=1/0,c=1/0,d=-1/0,p=-1/0;for(const f of e)l=Math.min(l,f.x),c=Math.min(c,f.y),d=Math.max(d,f.x),p=Math.max(p,f.y);return[l,c,d,p]},l.aM=Ud,l.aN=oe,l.aO=function(e,l,c,d,p=!1){if(!c[0]&&!c[1])return[0,0];const f=p?"map"===d?-e.bearingInRadians:0:"viewport"===d?e.bearingInRadians:0;if(f){const e=Math.sin(f),l=Math.cos(f);c=[c[0]*l-c[1]*e,c[0]*e+c[1]*l]}return[p?c[0]:oe(l,c[0],e.zoom),p?c[1]:oe(l,c[1],e.zoom)]},l.aQ=Bp,l.aR=g_,l.aS=vp,l.aT=Sd,l.aU=Ac,l.aV=pu,l.aW=$a,l.aX=io,l.aY=to,l.aZ=Ye,l.a_=ff,l.aa=jh,l.ab=25,l.ac=Lh,l.ad=e=>{const l=window.document.createElement("video");return l.muted=!0,new Promise((c=>{l.onloadstart=()=>{c(l)};for(const c of e){const e=window.document.createElement("source");vt(c)||(l.crossOrigin="Anonymous"),e.src=c,l.appendChild(e)}}))},l.ae=Dt,l.af=function(){return ye++},l.ag=Fa,l.ah=fh,l.ai=Fm,l.aj=Ko,l.ak=rh,l.al=Xh,l.am=function(e){const l={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,c,d,p)=>{const f=d||p;return l[c]=!f||f.toLowerCase(),""})),l["max-age"]){const e=parseInt(l["max-age"],10);isNaN(e)?delete l["max-age"]:l["max-age"]=e}return l},l.an=fe,l.ao=85.051129,l.ap=He,l.aq=function(e){return Math.pow(2,e)},l.ar=R,l.as=hf,l.at=function(e){return Math.log(e)/Math.LN2},l.au=function(e){var l=e[0],c=e[1];return l*l+c*c},l.av=function(e){if(!e.length)return new Set;const l=Math.max(...e.map((e=>e.canonical.z)));let c=1/0,d=-1/0,p=1/0,f=-1/0;const m=[];for(const _ of e){const{x:e,y:g,z:y}=_.canonical,b=Math.pow(2,l-y),T=e*b,S=g*b;m.push({id:_,x:T,y:S}),Td&&(d=T),Sf&&(f=S)}const _=new Set;for(const e of m)e.x!==c&&e.x!==d&&e.y!==p&&e.y!==f||_.add(e.id);return _},l.aw=function(e,l){const c=Math.abs(2*e.wrap)-+(e.wrap<0),d=Math.abs(2*l.wrap)-+(l.wrap<0);return e.overscaledZ-l.overscaledZ||d-c||l.canonical.y-e.canonical.y||l.canonical.x-e.canonical.x},l.ax=class{constructor(e,l){this.max=e,this.onRemove=l,this.reset()}reset(){for(const e in this.data)for(const l of this.data[e])l.timeout&&clearTimeout(l.timeout),this.onRemove(l.value);return this.data={},this.order=[],this}add(e,l,c){const d=e.wrapped().key;void 0===this.data[d]&&(this.data[d]=[]);const p={value:l,timeout:void 0};if(void 0!==c&&(p.timeout=setTimeout((()=>{this.remove(e,p)}),c)),this.data[d].push(p),this.order.push(d),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 l=this.data[e].shift();return l.timeout&&clearTimeout(l.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),l.value}getByKey(e){const l=this.data[e];return l?l[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,l){if(!this.has(e))return this;const c=e.wrapped().key,d=void 0===l?0:this.data[c].indexOf(l),p=this.data[c][d];return this.data[c].splice(d,1),p.timeout&&clearTimeout(p.timeout),0===this.data[c].length&&delete this.data[c],this.onRemove(p.value),this.order.splice(this.order.indexOf(c),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 l=[];for(const c in this.data)for(const d of this.data[c])e(d.value)||l.push(d);for(const e of l)this.remove(e.value.tileID,e)}},l.ay=function(e,l){let c=0,d=0;if("constant"===e.kind)d=e.layoutSize;else if("source"!==e.kind){const{interpolationType:p,minZoom:f,maxZoom:m}=e,_=p?fe(fr.interpolationFactor(p,l,f,m),0,1):0;"camera"===e.kind?d=_n.number(e.minSize,e.maxSize,_):c=_}return{uSizeT:c,uSize:d}},l.b=Ae,l.b$=Ao,l.b0=O,l.b1=function(e){var l=new I(3);return l[0]=e[0],l[1]=e[1],l[2]=e[2],l},l.b2=function(e,l,c){return e[0]=l[0]-c[0],e[1]=l[1]-c[1],e[2]=l[2]-c[2],e},l.b3=function(e,l){var c=l[0],d=l[1],p=l[2],f=c*c+d*d+p*p;return f>0&&(f=1/Math.sqrt(f)),e[0]=l[0]*f,e[1]=l[1]*f,e[2]=l[2]*f,e},l.b4=j,l.b5=function(e,l){return e[0]*l[0]+e[1]*l[1]+e[2]*l[2]},l.b6=function(e,l,c){return e[0]=l[0]*c[0],e[1]=l[1]*c[1],e[2]=l[2]*c[2],e[3]=l[3]*c[3],e},l.b7=F,l.b8=function(e,l,c){const d=l[0]*c[0]+l[1]*c[1]+l[2]*c[2];return 0===d?null:(-(e[0]*c[0]+e[1]*c[1]+e[2]*c[2])-c[3])/d},l.b9=U,l.bA=function(){return new Float64Array(3)},l.bB=W,l.bC=function(e,l,c){var d=c[0],p=c[1],f=c[2],m=c[3],_=l[0],g=l[1],y=l[2],b=p*y-f*g,T=f*_-d*y,S=d*g-p*_;return e[0]=_+m*(b+=b)+p*(S+=S)-f*(T+=T),e[1]=g+m*T+f*b-d*S,e[2]=y+m*S+d*T-p*b,e},l.bD=function(e,l,c){const d=(p=[e[0],e[1],e[2],l[0],l[1],l[2],c[0],c[1],c[2]])[0]*((b=p[8])*(m=p[4])-(_=p[5])*(y=p[7]))+p[1]*(-b*(f=p[3])+_*(g=p[6]))+p[2]*(y*f-m*g);var p,f,m,_,g,y,b;if(0===d)return null;const T=j([],[l[0],l[1],l[2]],[c[0],c[1],c[2]]),S=j([],[c[0],c[1],c[2]],[e[0],e[1],e[2]]),P=j([],[e[0],e[1],e[2]],[l[0],l[1],l[2]]),I=V([],T,-e[3]);return O(I,I,V([],S,-l[3])),O(I,I,V([],P,-c[3])),V(I,I,1/d),I},l.bE=tf,l.bF=function(){return new Float64Array(4)},l.bG=function(e,l,c,d){var p=[],f=[];return p[0]=l[0]-c[0],p[1]=l[1]-c[1],p[2]=l[2]-c[2],f[0]=p[0]*Math.cos(d)-p[1]*Math.sin(d),f[1]=p[0]*Math.sin(d)+p[1]*Math.cos(d),f[2]=p[2],e[0]=f[0]+c[0],e[1]=f[1]+c[1],e[2]=f[2]+c[2],e},l.bH=function(e,l,c,d){var p=[],f=[];return p[0]=l[0]-c[0],p[1]=l[1]-c[1],p[2]=l[2]-c[2],f[0]=p[0],f[1]=p[1]*Math.cos(d)-p[2]*Math.sin(d),f[2]=p[1]*Math.sin(d)+p[2]*Math.cos(d),e[0]=f[0]+c[0],e[1]=f[1]+c[1],e[2]=f[2]+c[2],e},l.bI=function(e,l,c,d){var p=[],f=[];return p[0]=l[0]-c[0],p[1]=l[1]-c[1],p[2]=l[2]-c[2],f[0]=p[2]*Math.sin(d)+p[0]*Math.cos(d),f[1]=p[1],f[2]=p[2]*Math.cos(d)-p[0]*Math.sin(d),e[0]=f[0]+c[0],e[1]=f[1]+c[1],e[2]=f[2]+c[2],e},l.bJ=function(e,l,c){var d=Math.sin(c),p=Math.cos(c),f=l[0],m=l[1],_=l[2],g=l[3],y=l[8],b=l[9],T=l[10],S=l[11];return l!==e&&(e[4]=l[4],e[5]=l[5],e[6]=l[6],e[7]=l[7],e[12]=l[12],e[13]=l[13],e[14]=l[14],e[15]=l[15]),e[0]=f*p-y*d,e[1]=m*p-b*d,e[2]=_*p-T*d,e[3]=g*p-S*d,e[8]=f*d+y*p,e[9]=m*d+b*p,e[10]=_*d+T*p,e[11]=g*d+S*p,e},l.bK=function(e,l){const c=le(e,360),d=le(l,360),p=d-c,f=d>c?p-360:p+360;return Math.abs(p)0?m:-m},l.bN=function(e,l){const c=le(e,2*Math.PI),d=le(l,2*Math.PI);return Math.min(Math.abs(c-d),Math.abs(c-d+2*Math.PI),Math.abs(c-d-2*Math.PI))},l.bO=function(){const e={},l=Tt.$version;for(const c in Tt.$root){const d=Tt.$root[c];if(d.required){let p=null;p="version"===c?l:"array"===d.type?[]:{},null!=p&&(e[c]=p)}}return e},l.bP=_t,l.bQ=xs,l.bR=function e(l,c){if(Array.isArray(l)){if(!Array.isArray(c)||l.length!==c.length)return!1;for(let d=0;d"raster"===e.type,l.bV=be,l.bW=function(e,l){if(!e)return[{command:"setStyle",args:[l]}];let c=[];try{if(!Lt(e.version,l.version))return[{command:"setStyle",args:[l]}];Lt(e.center,l.center)||c.push({command:"setCenter",args:[l.center]}),Lt(e.state,l.state)||c.push({command:"setGlobalState",args:[l.state]}),Lt(e.centerAltitude,l.centerAltitude)||c.push({command:"setCenterAltitude",args:[l.centerAltitude]}),Lt(e.zoom,l.zoom)||c.push({command:"setZoom",args:[l.zoom]}),Lt(e.bearing,l.bearing)||c.push({command:"setBearing",args:[l.bearing]}),Lt(e.pitch,l.pitch)||c.push({command:"setPitch",args:[l.pitch]}),Lt(e.roll,l.roll)||c.push({command:"setRoll",args:[l.roll]}),Lt(e.sprite,l.sprite)||c.push({command:"setSprite",args:[l.sprite]}),Lt(e.glyphs,l.glyphs)||c.push({command:"setGlyphs",args:[l.glyphs]}),Lt(e.transition,l.transition)||c.push({command:"setTransition",args:[l.transition]}),Lt(e.light,l.light)||c.push({command:"setLight",args:[l.light]}),Lt(e.terrain,l.terrain)||c.push({command:"setTerrain",args:[l.terrain]}),Lt(e.sky,l.sky)||c.push({command:"setSky",args:[l.sky]}),Lt(e.projection,l.projection)||c.push({command:"setProjection",args:[l.projection]});const d={},p=[];!function(e,l,c,d){let p;for(p in l=l||{},e=e||{})Object.prototype.hasOwnProperty.call(e,p)&&(Object.prototype.hasOwnProperty.call(l,p)||Ut(p,c,d));for(p in l)Object.prototype.hasOwnProperty.call(l,p)&&(Object.prototype.hasOwnProperty.call(e,p)?Lt(e[p],l[p])||("geojson"===e[p].type&&"geojson"===l[p].type&&Ht(e,l,p)?Ft(c,{command:"setGeoJSONSourceData",args:[p,l[p].data]}):Zt(p,l,c,d)):Ot(p,l,c))}(e.sources,l.sources,p,d);const f=[];e.layers&&e.layers.forEach((e=>{"source"in e&&d[e.source]?c.push({command:"removeLayer",args:[e.id]}):f.push(e)})),c=c.concat(p),function(e,l,c){l=l||[];const d=(e=e||[]).map(Kt),p=l.map(Kt),f=e.reduce(Jt,{}),m=l.reduce(Jt,{}),_=d.slice(),g=Object.create(null);let y,b,T,S,P;for(let e=0,l=0;eP?(p=Math.acos(f),m=Math.sin(p),_=Math.sin((1-d)*p)/m,g=Math.sin(d*p)/m):(_=1-d,g=d),e[0]=_*y+g*I,e[1]=_*b+g*C,e[2]=_*T+g*R,e[3]=_*S+g*L,e},l.bn=function(e){const l=new Float64Array(9);var c,d,p,f,m,_,g,y,b,T,S,P,I,C,R,L,F,B;T=(p=(d=e)[0])*(g=p+p),S=(f=d[1])*g,I=(m=d[2])*g,C=m*(y=f+f),L=(_=d[3])*g,F=_*y,B=_*(b=m+m),(c=l)[0]=1-(P=f*y)-(R=m*b),c[3]=S-B,c[6]=I+F,c[1]=S+B,c[4]=1-T-R,c[7]=C-L,c[2]=I-F,c[5]=C+L,c[8]=1-T-P;const O=Ye(-Math.asin(fe(l[2],-1,1)));let V,j;return Math.hypot(l[5],l[8])<.001?(V=0,j=-Ye(Math.atan2(l[3],l[4]))):(V=Ye(0===l[5]&&0===l[8]?0:Math.atan2(l[5],l[8])),j=Ye(0===l[1]&&0===l[0]?0:Math.atan2(l[1],l[0]))),{roll:V,pitch:O+90,bearing:j}},l.bo=function(e,l){return e.roll==l.roll&&e.pitch==l.pitch&&e.bearing==l.bearing},l.bp=Te,l.bq=_o,l.br=Yu,l.bs=Ku,l.bt=hu,l.bu=ce,l.bv=he,l.bw=Re,l.bx=function(e,l,c,d,p){return ce(d,p,fe((e-l)/(c-l),0,1))},l.by=function(e,l,c,d){return e[0]=l[0]+c[0]*d,e[1]=l[1]+c[1]*d,e[2]=l[2]+c[2]*d,e},l.bz=le,l.c=ot,l.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}},l.c0=class extends wo{constructor(e,l){super(e,l),this.current=Yc}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 l=1;l<16;l++)if(e[l]!==this.current[l]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},l.c1=So,l.c2=class extends wo{constructor(e,l){super(e,l),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]))}},l.c3=class extends wo{constructor(e,l){super(e,l),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]))}},l.c4=C,l.c5=function(e,l){var c=Math.sin(l),d=Math.cos(l);return e[0]=d,e[1]=c,e[2]=0,e[3]=-c,e[4]=d,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},l.c6=function(e,l,c){var d=l[0],p=l[1],f=l[2];return e[0]=d*c[0]+p*c[3]+f*c[6],e[1]=d*c[1]+p*c[4]+f*c[7],e[2]=d*c[2]+p*c[5]+f*c[8],e},l.c7=function(e,l,c,d,p,f,m){var _=1/(l-c),g=1/(d-p),y=1/(f-m);return e[0]=-2*_,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*g,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*y,e[11]=0,e[12]=(l+c)*_,e[13]=(p+d)*g,e[14]=(m+f)*y,e[15]=1,e},l.c8=class extends wo{constructor(e,l){super(e,l),this.current=new Array}set(e){if(e!=this.current){this.current=e;const l=new Float32Array(4*e.length);for(let c=0;c25||d<0||d>=1||c<0||c>=1)},l.cF=function(e,l){return e[0]=l[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},l.cG=class extends aa{},l.cH=R_,l.cJ=ct,l.cK=function(e,l){ot.REGISTERED_PROTOCOLS[e]=l},l.cL=function(e){delete ot.REGISTERED_PROTOCOLS[e]},l.cM=function(e,l){const c={};for(let d=0;de*Ud))}let B=g?"center":p.get("text-justify").evaluate(f,{},e.canonical);const O="point"===p.get("symbol-placement")?p.get("text-max-width").evaluate(f,{},e.canonical)*Ud:1/0,V=()=>{e.bucket.allowVerticalPlacement&&dc(c)&&(C.vertical=xp(R,e.glyphMap,e.glyphPositions,e.imagePositions,T,O,_,I,"left",b,F,l.az.vertical,!0,P,S))};if(!g&&L){const c=new Set;if("auto"===B)for(let e=0;e=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,l)}clear(){this.map.clear()}},l.cY=Vu,l.cZ=Tc,l.c_=Ff,l.ca=class extends xa{},l.cb=Nd,l.cc=class extends ba{},l.cd=su,l.ce=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},l.cf=nu,l.cg=function(e,l,c){var d=l[0],p=l[1],f=l[2],m=c[3]*d+c[7]*p+c[11]*f+c[15];return e[0]=(c[0]*d+c[4]*p+c[8]*f+c[12])/(m=m||1),e[1]=(c[1]*d+c[5]*p+c[9]*f+c[13])/m,e[2]=(c[2]*d+c[6]*p+c[10]*f+c[14])/m,e},l.ch=class extends oa{},l.ci=class extends Ta{},l.cj=function(e,l){return e[0]===l[0]&&e[1]===l[1]&&e[2]===l[2]&&e[3]===l[3]&&e[4]===l[4]&&e[5]===l[5]&&e[6]===l[6]&&e[7]===l[7]&&e[8]===l[8]&&e[9]===l[9]&&e[10]===l[10]&&e[11]===l[11]&&e[12]===l[12]&&e[13]===l[13]&&e[14]===l[14]&&e[15]===l[15]},l.ck=function(e,l){var c=e[0],d=e[1],p=e[2],f=e[3],m=e[4],_=e[5],g=e[6],y=e[7],b=e[8],T=e[9],S=e[10],I=e[11],C=e[12],R=e[13],L=e[14],F=e[15],B=l[0],O=l[1],V=l[2],j=l[3],G=l[4],U=l[5],q=l[6],Z=l[7],W=l[8],Q=l[9],J=l[10],re=l[11],oe=l[12],le=l[13],ce=l[14],he=l[15];return 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-V)<=P*Math.max(1,Math.abs(p),Math.abs(V))&&Math.abs(f-j)<=P*Math.max(1,Math.abs(f),Math.abs(j))&&Math.abs(m-G)<=P*Math.max(1,Math.abs(m),Math.abs(G))&&Math.abs(_-U)<=P*Math.max(1,Math.abs(_),Math.abs(U))&&Math.abs(g-q)<=P*Math.max(1,Math.abs(g),Math.abs(q))&&Math.abs(y-Z)<=P*Math.max(1,Math.abs(y),Math.abs(Z))&&Math.abs(b-W)<=P*Math.max(1,Math.abs(b),Math.abs(W))&&Math.abs(T-Q)<=P*Math.max(1,Math.abs(T),Math.abs(Q))&&Math.abs(S-J)<=P*Math.max(1,Math.abs(S),Math.abs(J))&&Math.abs(I-re)<=P*Math.max(1,Math.abs(I),Math.abs(re))&&Math.abs(C-oe)<=P*Math.max(1,Math.abs(C),Math.abs(oe))&&Math.abs(R-le)<=P*Math.max(1,Math.abs(R),Math.abs(le))&&Math.abs(L-ce)<=P*Math.max(1,Math.abs(L),Math.abs(ce))&&Math.abs(F-he)<=P*Math.max(1,Math.abs(F),Math.abs(he))},l.cl=function(e,l){return e[0]=l[0],e[1]=l[1],e[2]=l[2],e[3]=l[3],e[4]=l[4],e[5]=l[5],e[6]=l[6],e[7]=l[7],e[8]=l[8],e[9]=l[9],e[10]=l[10],e[11]=l[11],e[12]=l[12],e[13]=l[13],e[14]=l[14],e[15]=l[15],e},l.cm=e=>"symbol"===e.type,l.cn=e=>"circle"===e.type,l.co=e=>"heatmap"===e.type,l.cp=e=>"line"===e.type,l.cq=e=>"fill"===e.type,l.cr=e=>"fill-extrusion"===e.type,l.cs=e=>"hillshade"===e.type,l.ct=e=>"color-relief"===e.type,l.cu=e=>"background"===e.type,l.cv=e=>"custom"===e.type,l.cw=ue,l.cx=function(e,l,c){if(l<=0)return e;const d=1/l;return void 0===c||Math.abs(c)<1e-10?Math.round(e*d)/d:(c>0?Math.ceil(e*d-1e-9):Math.floor(e*d+1e-10))/d},l.cy=function(e,l,c){const d=J(l.x-c.x,l.y-c.y),p=J(e.x-c.x,e.y-c.y);var f,m;return Ye(Math.atan2(d[0]*p[1]-d[1]*p[0],(f=d)[0]*(m=p)[0]+f[1]*m[1]))},l.cz=pe,l.d=vt,l.d0=function(l,d,p,f,m){return c(this||e,void 0,void 0,(function*(){if(S())try{return yield Ge(l,d,p,f,m)}catch(e){}return function(e,l,c,d,p){const f=e.width,m=e.height;Ue&&qe||(Ue=new OffscreenCanvas(f,m),qe=Ue.getContext("2d",{willReadFrequently:!0})),Ue.width=f,Ue.height=m,qe.drawImage(e,0,0,f,m);const _=qe.getImageData(l,c,d,p);return qe.clearRect(0,0,f,m),_.data}(l,d,p,f,m)}))},l.d1=Pl,l.d2=p,l.d3=class{constructor(e,l){this.layers={[Fm]:this},this.name=Fm,this.version=l?l.version:1,this.extent=l?l.extent:4096,this.length=e.length,this.features=e}feature(e){return new Df(this.features[e],this.extent)}},l.d4=Go,l.d5=wc,l.e=ge,l.f=e=>c(void 0,void 0,void 0,(function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const l=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(l)}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.`)}})),l.g=at,l.h=e=>new Promise(((l,c)=>{const d=new Image;d.onload=()=>{l(d),URL.revokeObjectURL(d.src),d.onload=null,window.requestAnimationFrame((()=>{d.src=Ne}))},d.onerror=()=>c(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 p=new Blob([new Uint8Array(e)],{type:"image/png"});d.src=e.byteLength?URL.createObjectURL(p):Ne})),l.i=Ee,l.j=(e,l)=>yt(ge(e,{type:"json"}),l),l.k=gt,l.l=mt,l.m=yt,l.n=(e,l)=>yt(ge(e,{type:"arrayBuffer"}),l),l.o=function(e){return new Tc(e).readFields(fp,[])},l.p=gp,l.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))},l.r=_l,l.s=$e,l.t=Hs,l.u=Tt,l.v=$l,l.w=Se,l.x=Os,l.y=Hl,l.z=Mc}));d("worker",["./shared"],(function(e){class t{constructor(e,l){this.keyCache={},e&&this.replace(e,l)}replace(e,l){this._layerConfigs={},this._layers={},this.update(e,[],l)}update(l,c,d){for(const c of l){this._layerConfigs[c.id]=c;const l=this._layers[c.id]=e.bT(c,d);l._featureFilter=e.aj(l.filter,d),this.keyCache[c.id]&&delete this.keyCache[c.id]}for(const e of c)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const p=e.cM(Object.values(this._layerConfigs),this.keyCache);for(const l of p){const c=l.map((e=>this._layers[e.id])),d=c[0];if(d.isHidden())continue;const p=d.source||"";let f=this.familiesBySource[p];f||(f=this.familiesBySource[p]={});const m=d.sourceLayer||e.ai;let _=f[m];_||(_=f[m]=[]),_.push(c)}}}class o{constructor(l){const c={},d=[];for(const e in l){const p=l[e],f=c[e]={};for(const e in p){const l=p[+e];if(!l||0===l.bitmap.width||0===l.bitmap.height)continue;const c={x:0,y:0,w:l.bitmap.width+2,h:l.bitmap.height+2};d.push(c),f[e]={rect:c,metrics:l.metrics}}}const{w:p,h:f}=e.p(d),m=new e.r({width:p||1,height:f||1});for(const d in l){const p=l[d];for(const l in p){const f=p[+l];if(!f||0===f.bitmap.width||0===f.bitmap.height)continue;const _=c[d][l].rect;e.r.copy(f.bitmap,m,{x:0,y:0},{x:_.x+1,y:_.y+1},f.bitmap)}}this.image=m,this.positions=c}}e.cN("GlyphAtlas",o);class s{constructor(l){this.tileID=new e.a2(l.tileID.overscaledZ,l.tileID.wrap,l.tileID.canonical.z,l.tileID.canonical.x,l.tileID.canonical.y),this.uid=l.uid,this.zoom=l.zoom,this.pixelRatio=l.pixelRatio,this.tileSize=l.tileSize,this.source=l.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=l.showCollisionBoxes,this.collectResourceTiming=!!l.collectResourceTiming,this.returnDependencies=!!l.returnDependencies,this.promoteId=l.promoteId,this.inFlightDependencies=[]}parse(c,d,p,f,m){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=c,this.collisionBoxArray=new e.ag;const _=new e.cO(Object.keys(c.layers).sort()),g=new e.cP(this.tileID,this.promoteId);g.bucketLayerIDs=[];const y={},b={featureIndex:g,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:p,subdivisionGranularity:m},T=d.familiesBySource[this.source];for(const d in T){const f=c.layers[d];if(!f)continue;1===f.version&&e.w(`Vector tile source "${this.source}" layer "${d}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const m=_.encode(d),S=[];for(let e=0;ee.id))))}}const S=e.bY(b.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(S).length){const e=new AbortController;this.inFlightDependencies.push(e),P=f.sendAsync({type:"GG",data:{stacks:S,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const I=Object.keys(b.iconDependencies);let C=Promise.resolve({});if(I.length){const e=new AbortController;this.inFlightDependencies.push(e),C=f.sendAsync({type:"GI",data:{icons:I,source:this.source,tileID:this.tileID,type:"icons"}},e)}const R=Object.keys(b.patternDependencies);let L=Promise.resolve({});if(R.length){const e=new AbortController;this.inFlightDependencies.push(e),L=f.sendAsync({type:"GI",data:{icons:R,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const F=b.dashDependencies;let B=Promise.resolve({});if(Object.keys(F).length){const e=new AbortController;this.inFlightDependencies.push(e),B=f.sendAsync({type:"GDA",data:{dashes:F}},e)}const[O,V,j,G]=yield Promise.all([P,C,L,B]),U=new o(O),q=new e.cQ(V,j);for(const c in y){const d=y[c];d instanceof e.ah?(l(d.layers,this.zoom,p),e.cR({bucket:d,glyphMap:O,glyphPositions:U.positions,imageMap:V,imagePositions:q.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:b.subdivisionGranularity})):d.hasDependencies&&(d instanceof e.cS||d instanceof e.cT||d instanceof e.cU)&&(l(d.layers,this.zoom,p),d.addFeatures(b,this.tileID.canonical,q.patternPositions,G))}return this.status="done",{buckets:Object.values(y).filter((e=>!e.isEmpty())),featureIndex:g,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:U.image,imageAtlas:q,dashPositions:G,glyphMap:this.returnDependencies?O:null,iconMap:this.returnDependencies?V:null,glyphPositions:this.returnDependencies?U.positions:null}}))}}function l(l,c,d){const p=new e.H(c);for(const e of l)e.recalculate(p,d)}class n{constructor(e,l,c,d,p){this.type=e,this.properties=c||{},this.extent=p,this.pointsArray=l,this.id=d}loadGeometry(){return this.pointsArray.map((l=>l.map((l=>new e.P(l.x,l.y)))))}}class r{constructor(e,l,c){this.version=2,this._myFeatures=e,this.name=l,this.length=e.length,this.extent=c}feature(e){return this._myFeatures[e]}}class a{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function c(l){let c=e.cV(l);return 0===c.byteOffset&&c.byteLength===c.buffer.byteLength||(c=new Uint8Array(c)),{vectorTile:l,rawData:c.buffer}}function d(l,c,d){const{extent:p}=l,f=Math.pow(2,d.z-c.z),m=(d.x-c.x*f)*p,_=(d.y-c.y*f)*p,g=[];for(let c=0;c0&&b.addLayer(f)}const S=c(b);return this.overzoomedTileResultCache.set(g,S),S}reloadTile(l){return e._(this,void 0,void 0,(function*(){const c=l.uid;if(!this.loaded||!this.loaded[c])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const d=this.loaded[c];if(d.showCollisionBoxes=l.showCollisionBoxes,"parsing"===d.status){const p=yield d.parse(d.vectorTile,this.layerIndex,this.availableImages,this.actor,l.subdivisionGranularity);let f;if(this.fetching[c]){const{rawTileData:d,cacheControl:m,resourceTiming:_}=this.fetching[c];delete this.fetching[c],f=e.e({rawTileData:d.slice(0),encoding:l.encoding},p,m,_)}else f=p;return f}if("done"===d.status&&d.vectorTile)return d.parse(d.vectorTile,this.layerIndex,this.availableImages,this.actor,l.subdivisionGranularity)}))}abortTile(l){return e._(this,void 0,void 0,(function*(){const e=this.loading,c=l.uid;e&&e[c]&&e[c].abort&&(e[c].abort.abort(),delete e[c])}))}removeTile(l){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[l.uid]&&delete this.loaded[l.uid]}))}}class u{constructor(){this.loaded={}}loadTile(l){return e._(this,void 0,void 0,(function*(){const{uid:c,encoding:d,rawImageData:p,redFactor:f,greenFactor:m,blueFactor:_,baseShift:g}=l,y=p.width+2,b=p.height+2,T=e.b(p)?new e.R({width:y,height:b},yield e.d0(p,-1,-1,y,b)):p,S=new e.d1(c,T,d,f,m,_,g);return this.loaded=this.loaded||{},this.loaded[c]=S,S}))}removeTile(e){const l=this.loaded,c=e.uid;l&&l[c]&&delete l[c]}}var p,f,m=function(){if(f)return p;function e(e,c){if(0!==e.length){l(e[0],c);for(var d=1;d=Math.abs(_)?c-g+_:_-g+c,c=g}c+d>=0!=!!l&&e.reverse()}return f=1,p=function l(c,d){var p,f=c&&c.type;if("FeatureCollection"===f)for(p=0;pe},y=Math.fround||(b=new Float32Array(1),e=>(b[0]=+e,b[0]));var b;class x{constructor(e){this.options=Object.assign(Object.create(g),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:l,minZoom:c,maxZoom:d}=this.options;l&&console.time("total time");const p=`prepare ${e.length} points`;l&&console.time(p),this.points=e;const f=[];for(let l=0;l=c;e--){const c=+Date.now();m=this.trees[e]=this._createTree(this._cluster(m,e)),l&&console.log("z%d: %d clusters in %dms",e,m.numItems,+Date.now()-c)}return l&&console.timeEnd("total time"),this}getClusters(e,l){let c=((e[0]+180)%360+360)%360-180;const d=Math.max(-90,Math.min(90,e[1]));let p=180===e[2]?180:((e[2]+180)%360+360)%360-180;const f=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)c=-180,p=180;else if(c>p){const e=this.getClusters([c,d,180,f],l),m=this.getClusters([-180,d,p,f],l);return e.concat(m)}const m=this.trees[this._limitZoom(l)],_=m.range(P(c),I(f),P(p),I(d)),g=m.data,y=[];for(const e of _){const l=this.stride*e;y.push(g[l+5]>1?T(g,l,this.clusterProps):this.points[g[l+3]])}return y}getChildren(e){const l=this._getOriginId(e),c=this._getOriginZoom(e),d="No cluster with the specified id.",p=this.trees[c];if(!p)throw new Error(d);const f=p.data;if(l*this.stride>=f.length)throw new Error(d);const m=this.options.radius/(this.options.extent*Math.pow(2,c-1)),_=p.within(f[l*this.stride],f[l*this.stride+1],m),g=[];for(const l of _){const c=l*this.stride;f[c+4]===e&&g.push(f[c+5]>1?T(f,c,this.clusterProps):this.points[f[c+3]])}if(0===g.length)throw new Error(d);return g}getLeaves(e,l,c){const d=[];return this._appendLeaves(d,e,l=l||10,c=c||0,0),d}getTile(e,l,c){const d=this.trees[this._limitZoom(e)],p=Math.pow(2,e),{extent:f,radius:m}=this.options,_=m/f,g=(c-_)/p,y=(c+1+_)/p,b={features:[]};return this._addTileFeatures(d.range((l-_)/p,g,(l+1+_)/p,y),d.data,l,c,p,b),0===l&&this._addTileFeatures(d.range(1-_/p,g,1,y),d.data,p,c,p,b),l===p-1&&this._addTileFeatures(d.range(0,g,_/p,y),d.data,-1,c,p,b),b.features.length?b:null}getClusterExpansionZoom(e){let l=this._getOriginZoom(e)-1;for(;l<=this.options.maxZoom;){const c=this.getChildren(e);if(l++,1!==c.length)break;e=c[0].properties.cluster_id}return l}_appendLeaves(e,l,c,d,p){const f=this.getChildren(l);for(const l of f){const f=l.properties;if(f&&f.cluster?p+f.point_count<=d?p+=f.point_count:p=this._appendLeaves(e,f.cluster_id,c,d,p):p1;let g,y,b;if(_)g=S(l,e,this.clusterProps),y=l[e],b=l[e+1];else{const c=this.points[l[e+3]];g=c.properties;const[d,p]=c.geometry.coordinates;y=P(d),b=I(p)}const T={type:1,geometry:[[Math.round(this.options.extent*(y*p-c)),Math.round(this.options.extent*(b*p-d))]],tags:g};let C;C=_||this.options.generateId?l[e+3]:this.points[l[e+3]].id,void 0!==C&&(T.id=C),f.features.push(T)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,l){const{radius:c,extent:d,reduce:p,minPoints:f}=this.options,m=c/(d*Math.pow(2,l)),_=e.data,g=[],y=this.stride;for(let c=0;c<_.length;c+=y){if(_[c+2]<=l)continue;_[c+2]=l;const d=_[c],b=_[c+1],T=e.within(_[c],_[c+1],m),S=_[c+5];let P=S;for(const e of T){const c=e*y;_[c+2]>l&&(P+=_[c+5])}if(P>S&&P>=f){let e,f=d*S,m=b*S,I=-1;const C=(c/y<<5)+(l+1)+this.points.length;for(const d of T){const g=d*y;if(_[g+2]<=l)continue;_[g+2]=l;const b=_[g+5];f+=_[g]*b,m+=_[g+1]*b,_[g+4]=C,p&&(e||(e=this._map(_,c,!0),I=this.clusterProps.length,this.clusterProps.push(e)),p(e,this._map(_,g)))}_[c+4]=C,g.push(f/P,m/P,1/0,C,-1,P),p&&g.push(I)}else{for(let e=0;e1)for(const e of T){const c=e*y;if(!(_[c+2]<=l)){_[c+2]=l;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,l,c){if(e[l+5]>1){const d=this.clusterProps[e[l+6]];return c?Object.assign({},d):d}const d=this.points[e[l+3]].properties,p=this.options.map(d);return c&&p===d?Object.assign({},p):p}}function T(e,l,c){return{type:"Feature",id:e[l+3],properties:S(e,l,c),geometry:{type:"Point",coordinates:[(d=e[l],360*(d-.5)),C(e[l+1])]}};var d}function S(e,l,c){const d=e[l+5],p=d>=1e4?`${Math.round(d/1e3)}k`:d>=1e3?Math.round(d/100)/10+"k":d,f=e[l+6],m=-1===f?{}:Object.assign({},c[f]);return Object.assign(m,{cluster:!0,cluster_id:e[l+3],point_count:d,point_count_abbreviated:p})}function P(e){return e/360+.5}function I(e){const l=Math.sin(e*Math.PI/180),c=.5-.25*Math.log((1+l)/(1-l))/Math.PI;return c<0?0:c>1?1:c}function C(e){const l=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(l))/Math.PI-90}function R(e,l,c,d){let p=d;const f=l+(c-l>>1);let m,_=c-l;const g=e[l],y=e[l+1],b=e[c],T=e[c+1];for(let d=l+3;dp)m=d,p=l;else if(l===p){const e=Math.abs(d-f);e<_&&(m=d,_=e)}}p>d&&(m-l>3&&R(e,l,m,d),e[m+2]=p,c-m>3&&R(e,m,c,d))}function L(e,l,c,d,p,f){let m=p-c,_=f-d;if(0!==m||0!==_){const g=((e-c)*m+(l-d)*_)/(m*m+_*_);g>1?(c=p,d=f):g>0&&(c+=m*g,d+=_*g)}return m=e-c,_=l-d,m*m+_*_}function F(e,l,c,d){const p={type:l,geom:c},f={id:null==e?null:e,type:p.type,geometry:p.geom,tags:d,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(p.type){case"Point":case"MultiPoint":case"LineString":B(f,p.geom);break;case"Polygon":B(f,p.geom[0]);break;case"MultiLineString":for(const e of p.geom)B(f,e);break;case"MultiPolygon":for(const e of p.geom)B(f,e[0])}return f}function B(e,l){for(let c=0;c0&&(m+=d?(p*g-_*f)/2:Math.sqrt(Math.pow(_-p,2)+Math.pow(g-f,2))),p=_,f=g}const _=l.length-3;l[2]=1,c>0&&R(l,0,_,c),l[_+2]=1,l.size=Math.abs(m),l.start=0,l.end=l.size}function U(e,l,c,d){for(let p=0;p1?1:c}function W(e,l,c,d,p,f,m,_){if(d/=l,f>=(c/=l)&&m=d)return null;const g=[];for(const l of e){const e=0===p?l.minX:l.minY,f=0===p?l.maxX:l.maxY;if(e>=c&&f=d))switch(l.type){case"Point":case"MultiPoint":{const e=[];if(Q(l.geometry,e,c,d,p),!e.length)continue;g.push(F(l.id,3===e.length?"Point":"MultiPoint",e,l.tags));continue}case"LineString":{const e=[];if(J(l.geometry,e,c,d,p,!1,_.lineMetrics),!e.length)continue;if(_.lineMetrics){for(const c of e)g.push(F(l.id,l.type,c,l.tags));continue}if(e.length>1){g.push(F(l.id,"MultiLineString",e,l.tags));continue}g.push(F(l.id,l.type,e[0],l.tags));continue}case"MultiLineString":{const e=[];if(oe(l.geometry,e,c,d,p,!1),!e.length)continue;if(1===e.length){g.push(F(l.id,"LineString",e[0],l.tags));continue}g.push(F(l.id,l.type,e,l.tags));continue}case"Polygon":{const e=[];if(oe(l.geometry,e,c,d,p,!0),!e.length)continue;g.push(F(l.id,l.type,e,l.tags));continue}case"MultiPolygon":{const e=[];for(const f of l.geometry){const l=[];oe(f,l,c,d,p,!0),l.length&&e.push(l)}if(!e.length)continue;g.push(F(l.id,l.type,e,l.tags));continue}}}return g.length?g:null}function Q(e,l,c,d,p){for(let f=0;f=c&&m<=d&&le(l,e[f],e[f+1],e[f+2])}}function J(e,l,c,d,p,f,m){let _=re(e);const g=0===p?ce:he;let y,b,T=e.start;for(let S=0;Sc&&(b=g(_,P,I,R,L,c),m&&(_.start=T+y*b)):F>d?B=c&&(b=g(_,P,I,R,L,c),O=!0),B>d&&F<=d&&(b=g(_,P,I,R,L,d),O=!0),!f&&O&&(m&&(_.end=T+y*b),l.push(_),_=re(e)),m&&(T+=y)}let S=e.length-3;const P=e[S],I=e[S+1],C=0===p?P:I;C>=c&&C<=d&&le(_,P,I,e[S+2]),S=_.length-3,f&&S>=3&&(_[S]!==_[0]||_[S+1]!==_[1])&&le(_,_[0],_[1],_[2]),_.length&&l.push(_)}function re(e){const l=[];return l.size=e.size,l.start=e.start,l.end=e.end,l}function oe(e,l,c,d,p,f){for(const m of e)J(m,l,c,d,p,f,!1)}function le(e,l,c,d){e.push(l,c,d)}function ce(e,l,c,d,p,f){const m=(f-l)/(d-l);return le(e,f,c+(p-c)*m,1),m}function he(e,l,c,d,p,f){const m=(f-c)/(p-c);return le(e,l+(d-l)*m,f,1),m}function ue(e,l){const c=l.buffer/l.extent;let d=e;const p=W(e,1,-1-c,c,0,-1,2,l),f=W(e,1,1-c,2+c,0,-1,2,l);return p||f?(d=W(e,1,-c,1+c,0,-1,2,l)||[],p&&(d=pe(p,1).concat(d)),f&&(d=d.concat(pe(f,-1))),d):d}function pe(e,l){const c=[];for(const d of e)switch(d.type){case"Point":case"MultiPoint":case"LineString":{const e=fe(d.geometry,l);c.push(F(d.id,d.type,e,d.tags));continue}case"MultiLineString":case"Polygon":{const e=[];for(const c of d.geometry)e.push(fe(c,l));c.push(F(d.id,d.type,e,d.tags));continue}case"MultiPolygon":{const e=[];for(const c of d.geometry){const d=[];for(const e of c)d.push(fe(e,l));e.push(d)}c.push(F(d.id,d.type,e,d.tags));continue}}return c}function fe(e,l){const c=[];c.size=e.size,void 0!==e.start&&(c.start=e.start,c.end=e.end);for(let d=0;d0&&l.size<(p?m:d))return void(c.numPoints+=l.length/3);const _=[];for(let e=0;em)&&(c.numSimplified++,_.push(l[e],l[e+1])),c.numPoints++;p&&function(e,l){let c=0;for(let l=0,d=e.length,p=d-2;l0===l)for(let l=0,c=e.length;l0||l.addOrUpdateProperties?.length>0;if(d){let d=O({type:"FeatureCollection",features:[{type:"Feature",id:e.id,geometry:l.newGeometry,properties:p?we(e.tags,l):e.tags}]},c);return d=ue(d,c),d[0]}if(p){const c={...e};return c.tags=we(c.tags,l),c}return null}function we(e,l){if(l.removeAllProperties)return{};const c={...e||{}};if(l.removeProperties)for(const e of l.removeProperties)delete c[e];if(l.addOrUpdateProperties)for(const{key:e,value:d}of l.addOrUpdateProperties)c[e]=d;return c}const Se={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,debug:0};class te{options;tiles;tileCoords;stats={};total=0;source;constructor(e,l){const c=(l=this.options=Object.assign({},Se,l)).debug;if(c&&console.time("preprocess data"),l.maxZoom<0||l.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(l.promoteId&&l.generateId)throw new Error("promoteId and generateId cannot be used together.");let d=O(e,l);this.tiles={},this.tileCoords=[],c&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",l.indexMaxZoom,l.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),d=ue(d,l),d.length&&this.splitTile(d,0,0,0),l.updateable&&(this.source=d),c&&(d.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(e,l,c,d,p,f,m){const _=[e,l,c,d],g=this.options,y=g.debug;for(;_.length;){d=_.pop(),c=_.pop(),l=_.pop(),e=_.pop();const b=1<1&&console.time("creation"),S=this.tiles[T]=ye(e,l,c,d,g),this.tileCoords.push({z:l,x:c,y:d,id:T}),y)){y>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",l,c,d,S.numFeatures,S.numPoints,S.numSimplified),console.timeEnd("creation"));const e=`z${l}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(S.source=e,null==p){if(l===g.indexMaxZoom||S.numPoints<=g.indexMaxPoints)continue}else{if(l===g.maxZoom||l===p)continue;if(null!=p){const e=p-l;if(c!==f>>e||d!==m>>e)continue}}if(S.source=null,!e.length)continue;y>1&&console.time("clipping");const P=.5*g.buffer/g.extent,I=.5-P,C=.5+P,R=1+P;let L=null,F=null,B=null,O=null;const V=W(e,b,c-P,c+C,0,S.minX,S.maxX,g),j=W(e,b,c+I,c+R,0,S.minX,S.maxX,g);V&&(L=W(V,b,d-P,d+C,1,S.minY,S.maxY,g),F=W(V,b,d+I,d+R,1,S.minY,S.maxY,g)),j&&(B=W(j,b,d-P,d+C,1,S.minY,S.maxY,g),O=W(j,b,d+I,d+R,1,S.minY,S.maxY,g)),y>1&&console.timeEnd("clipping"),_.push(L||[],l+1,2*c,2*d),_.push(F||[],l+1,2*c,2*d+1),_.push(B||[],l+1,2*c+1,2*d),_.push(O||[],l+1,2*c+1,2*d+1)}}getTile(e,l,c){e=+e,l=+l,c=+c;const d=this.options,{extent:p,debug:f}=d;if(e<0||e>24)return null;const m=1<1&&console.log("drilling down to z%d-%d-%d",e,l,c);let g,y=e,b=l,T=c;for(;!g&&y>0;)y--,b>>=1,T>>=1,g=this.tiles[Me(y,b,T)];return g?.source?(f>1&&(console.log("found parent tile z%d-%d-%d",y,b,T),console.time("drilling down")),this.splitTile(g.source,y,b,T,e,l,c),f>1&&console.timeEnd("drilling down"),this.tiles[_]?me(this.tiles[_],p):null):null}invalidateTiles(e){const l=this.options,{debug:c}=l;let d=1/0,p=-1/0,f=1/0,m=-1/0;for(const l of e)d=Math.min(d,l.minX),p=Math.max(p,l.maxX),f=Math.min(f,l.minY),m=Math.max(m,l.maxY);const _=l.buffer/l.extent,g=new Set;for(const l in this.tiles){const y=this.tiles[l],b=1<=S||m=I)continue;let C=!1;for(const l of e)if(l.maxX>=T&&l.minX=P&&l.minY1&&console.log("invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",y.z,y.x,y.y,y.numFeatures,y.numPoints,y.numSimplified);const e=`z${y.z}`;this.stats[e]=(this.stats[e]||0)-1,this.total--}delete this.tiles[l],g.add(l)}}g.size&&(this.tileCoords=this.tileCoords.filter((e=>!g.has(e.id))))}updateData(e){const l=this.options,c=l.debug;if(!l.updateable)throw new Error("to update tile geojson `updateable` option must be set to true");const{affected:d,source:p}=function(e,l,c){const d=function(e){return e?{removeAll:e.removeAll,remove:new Set(e.remove||[]),add:new Map(e.add?.map((e=>[e.id,e]))),update:new Map(e.update?.map((e=>[e.id,e])))}:{remove:new Set,add:new Map,update:new Map}}(l);let p=[];if(d.removeAll&&(p=e,e=[]),d.remove.size||d.add.size){const l=[];for(const c of e){const{id:e}=c;(d.remove.has(e)||d.add.has(e))&&l.push(c)}if(l.length){p.push(...l);const c=new Set(l.map((e=>e.id)));e=e.filter((e=>!c.has(e.id)))}if(d.add.size){let l=O({type:"FeatureCollection",features:Array.from(d.add.values())},c);l=ue(l,c),p.push(...l),e.push(...l)}}if(d.update.size)for(const[l,f]of d.update){const d=e.findIndex((e=>e.id===l));if(-1===d)continue;const m=e[d],_=be(m,f,c);_&&(p.push(m,_),e[d]=_)}return{affected:p,source:e}}(this.source,e,l);if(!d.length)return;this.source=p,c>1&&(console.log("invalidating tiles"),console.time("invalidating")),this.invalidateTiles(d),c>1&&console.timeEnd("invalidating");const[f,m,_]=[0,0,0],g=ye(this.source,f,m,_,this.options);g.source=this.source;const y=Me(f,m,_);if(this.tiles[y]=g,this.tileCoords.push({z:f,x:m,y:_,id:y}),c){const e=`z${f}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}}}function Me(e,l,c){return 32*((1<`${e.key}: ${e.message}`)).join(", "));const p=l.features.filter((e=>d.value.evaluate({zoom:0},e)));return this._toFeatureCollection(p)}_toFeatureCollection(e){return{type:"FeatureCollection",features:e}}removeSource(l){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 Ee(l,c){return c.cluster?new x(function({superclusterOptions:l,clusterProperties:c}){if(!c||!l)return l;const d={},p={},f={accumulated:null,zoom:0},m={properties:null},_=Object.keys(c);for(const l of _){const[f,m]=c[l],_=e.d4(m),g=e.d4("string"==typeof f?[f,["accumulated"],["get",l]]:f);d[l]=_.value,p[l]=g.value}return l.map=e=>{m.properties=e;const l={};for(const e of _)l[e]=d[e].evaluate(f,m);return l},l.reduce=(e,l)=>{m.properties=l;for(const l of _)f.accumulated=e[l],e[l]=p[l].evaluate(f,m)},l}(c)).load(l.features):function(e,l){return new te(e,l)}(l,c.geojsonVtOptions)}class ne{constructor(l){this.self=l,this.actor=new e.L(l),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,l)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=l},this.self.addProtocol=e.cK,this.self.removeProtocol=e.cL,this.self.registerRTLTextPlugin=l=>{e.d5.setMethods(l)},this.actor.registerMessageHandler("LDT",((e,l)=>this._getDEMWorkerSource(e,l.source).loadTile(l))),this.actor.registerMessageHandler("RDT",((l,c)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(l,c.source).removeTile(c)})))),this.actor.registerMessageHandler("GCEZ",((l,c)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(l,c.type,c.source).getClusterExpansionZoom(c)})))),this.actor.registerMessageHandler("GCC",((l,c)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(l,c.type,c.source).getClusterChildren(c)})))),this.actor.registerMessageHandler("GCL",((l,c)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(l,c.type,c.source).getClusterLeaves(c)})))),this.actor.registerMessageHandler("LD",((e,l)=>this._getWorkerSource(e,l.type,l.source).loadData(l))),this.actor.registerMessageHandler("GD",((e,l)=>this._getWorkerSource(e,l.type,l.source).getData())),this.actor.registerMessageHandler("LT",((e,l)=>this._getWorkerSource(e,l.type,l.source).loadTile(l))),this.actor.registerMessageHandler("RT",((e,l)=>this._getWorkerSource(e,l.type,l.source).reloadTile(l))),this.actor.registerMessageHandler("AT",((e,l)=>this._getWorkerSource(e,l.type,l.source).abortTile(l))),this.actor.registerMessageHandler("RMT",((e,l)=>this._getWorkerSource(e,l.type,l.source).removeTile(l))),this.actor.registerMessageHandler("RS",((l,c)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[l]||!this.workerSources[l][c.type]||!this.workerSources[l][c.type][c.source])return;const e=this.workerSources[l][c.type][c.source];delete this.workerSources[l][c.type][c.source],void 0!==e.removeSource&&e.removeSource(c)})))),this.actor.registerMessageHandler("RM",(l=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[l],delete this.availableImages[l],delete this.workerSources[l],delete this.demWorkerSources[l],this.globalStates.delete(l)})))),this.actor.registerMessageHandler("SR",((l,c)=>e._(this,void 0,void 0,(function*(){this.referrer=c})))),this.actor.registerMessageHandler("SRPS",((e,l)=>this._syncRTLPluginState(e,l))),this.actor.registerMessageHandler("IS",((l,c)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(c)})))),this.actor.registerMessageHandler("SI",((e,l)=>this._setImages(e,l))),this.actor.registerMessageHandler("UL",((l,c)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(l).update(c.layers,c.removedIds,this._getGlobalState(l))})))),this.actor.registerMessageHandler("UGS",((l,c)=>e._(this,void 0,void 0,(function*(){const e=this._getGlobalState(l);for(const l in c)e[l]=c[l]})))),this.actor.registerMessageHandler("SL",((l,c)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(l).replace(c,this._getGlobalState(l))}))))}_getGlobalState(e){let l=this.globalStates.get(e);return l||(l={},this.globalStates.set(e,l)),l}_setImages(l,c){return e._(this,void 0,void 0,(function*(){this.availableImages[l]=c;for(const e in this.workerSources[l]){const d=this.workerSources[l][e];for(const e in d)d[e].availableImages=c}}))}_syncRTLPluginState(l,c){return e._(this,void 0,void 0,(function*(){return yield e.d5.syncState(c,this.self.importScripts)}))}_getAvailableImages(e){let l=this.availableImages[e];return l||(l=[]),l}_getLayerIndex(e){let l=this.layerIndexes[e];return l||(l=this.layerIndexes[e]=new t),l}_getWorkerSource(e,l,c){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][l]||(this.workerSources[e][l]={}),!this.workerSources[e][l][c]){const d={sendAsync:(l,c)=>(l.targetMapId=e,this.actor.sendAsync(l,c))};switch(l){case"vector":this.workerSources[e][l][c]=new h(d,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][l][c]=new se(d,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][l][c]=new this.externalWorkerSourceTypes[l](d,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][l][c]}_getDEMWorkerSource(e,l){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][l]||(this.demWorkerSources[e][l]=new u),this.demWorkerSources[e][l]}}return e.i(self)&&(self.worker=new ne(self)),ne}));d("index",["exports","./shared"],(function(l,c){var d="5.17.0";function p(){var e=new c.A(4);return c.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let f,m,_;const g={frame(e,l,d,p){const f=p||window,m=f.requestAnimationFrame((e=>{_(),l(e)})),{unsubscribe:_}=c.s(e.signal,"abort",(()=>{_(),f.cancelAnimationFrame(m),d(new c.a(e.signal.reason))}),!1)},frameAsync(e,l){return new Promise(((c,d)=>{this.frame(e,c,d,l)}))},getImageData(e,l=0){return this.getImageCanvasContext(e).getImageData(-l,-l,e.width+2*l,e.height+2*l)},getImageCanvasContext(e){const l=window.document.createElement("canvas"),c=l.getContext("2d",{willReadFrequently:!0});if(!c)throw new Error("failed to create canvas 2d context");return l.width=e.width,l.height=e.height,c.drawImage(e,0,0,e.width,e.height),c},resolveURL:e=>(f||(f=document.createElement("a")),f.href=e,f.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==_?_:!!matchMedia&&(null==m&&(m=matchMedia("(prefers-reduced-motion: reduce)")),m.matches)},set prefersReducedMotion(e){_=e}},y=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 b(){return y.getCurrentTime()}class h{static testProp(e){if(!h.docStyle)return e[0];for(let l=0;l{window.removeEventListener("click",h.suppressClickInternal,!0)}),0)}static getScale(e){const l=e.getBoundingClientRect();return{x:l.width/e.offsetWidth||1,y:l.height/e.offsetHeight||1,boundingClientRect:l}}static getPoint(e,l,d){const p=l.boundingClientRect;return new c.P((d.clientX-p.left)/l.x-e.clientLeft,(d.clientY-p.top)/l.y-e.clientTop)}static mousePos(e,l){const c=h.getScale(e);return h.getPoint(e,c,l)}static touchPos(e,l){const c=[],d=h.getScale(e);for(let p=0;p{S&&R(S),S=null,C=!0},P.onerror=()=>{I=!0,S=null},P.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(l){let d,p,f,m;l.resetRequestQueue=()=>{d=[],p=0,f=0,m={}},l.addThrottleControl=e=>{const l=f++;return m[l]=e,l},l.removeThrottleControl=e=>{delete m[e],g()},l.getImage=(e,l,p=!0)=>new Promise(((f,m)=>{T.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),c.e(e,{type:"image"}),d.push({abortController:l,requestParameters:e,supportImageRefresh:p,state:"queued",onError:e=>{m(e)},onSuccess:e=>{f(e)}}),g()}));const _=l=>c._(this||e,void 0,void 0,(function*(){l.state="running";const{requestParameters:e,supportImageRefresh:d,onError:f,onSuccess:m,abortController:_}=l,b=!1===d&&!c.i(self)&&!c.g(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((e,l)=>e&&"accept"===l),!0));p++;const T=b?y(e,_):c.m(e,_);try{const e=yield T;delete l.abortController,l.state="completed",e.data instanceof HTMLImageElement||c.b(e.data)?m(e):e.data&&m({data:yield(S=e.data,"function"==typeof createImageBitmap?c.f(S):c.h(S)),cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete l.abortController,f(e)}finally{p--,g()}var S})),g=()=>{const e=(()=>{for(const e of Object.keys(m))if(m[e]())return!0;return!1})()?c.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:c.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let l=p;l0;l++){const e=d.shift();e.abortController.signal.aborted?l--:_(e)}},y=(e,l)=>new Promise(((d,p)=>{const f=new Image,m=e.url,_=e.credentials;_&&"include"===_?f.crossOrigin="use-credentials":(_&&"same-origin"===_||!c.d(m))&&(f.crossOrigin="anonymous"),l.signal.addEventListener("abort",(()=>{f.src="",p(new c.a(l.signal.reason))})),f.fetchPriority="high",f.onload=()=>{f.onerror=f.onload=null,d({data:f})},f.onerror=()=>{f.onerror=f.onload=null,l.signal.aborted||p(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."))},f.src=m}))}(L||(L={})),L.resetRequestQueue();class v{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,l){return this._transformRequestFn&&this._transformRequestFn(e,l)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function F(e){const l=[];if("string"==typeof e)l.push({id:"default",url:e});else if(e&&e.length>0){const c=[];for(const{id:d,url:p}of e){const e=`${d}${p}`;-1===c.indexOf(e)&&(c.push(e),l.push({id:d,url:p}))}}return l}function B(e,l,c){try{const d=new URL(e);return d.pathname+=`${l}${c}`,d.toString()}catch(l){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function O(e){const{userImage:l}=e;return!!(l&&l.render&&l.render())&&(e.data.replace(new Uint8Array(l.data.buffer)),!0)}class w extends c.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new c.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 c.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:l}of this.requestors)l(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const l=this.images[e];if(l&&!l.data&&l.spriteData){const e=l.spriteData;l.data=new c.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),l.spriteData=null}return l}addImage(e,l){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,l)&&(this.images[e]=l)}_validate(e,l){let d=!0;const p=l.data||l.spriteData;return this._validateStretch(l.stretchX,p&&p.width)||(this.fire(new c.k(new Error(`Image "${e}" has invalid "stretchX" value`))),d=!1),this._validateStretch(l.stretchY,p&&p.height)||(this.fire(new c.k(new Error(`Image "${e}" has invalid "stretchY" value`))),d=!1),this._validateContent(l.content,l)||(this.fire(new c.k(new Error(`Image "${e}" has invalid "content" value`))),d=!1),d}_validateStretch(e,l){if(!e)return!0;let c=0;for(const d of e){if(d[0]{let d=!0;if(!this.isLoaded())for(const l of e)this.images[l]||(d=!1);this.isLoaded()||d?l(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:l})}))}_getImagesForIds(e){const l={};for(const d of e){let e=this.getImage(d);e||(this.fire(new c.l("styleimagemissing",{id:d})),e=this.getImage(d)),e?l[d]={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)}:c.w(`Image "${d}" 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 l}getPixelSize(){const{width:e,height:l}=this.atlasImage;return{width:e,height:l}}getPattern(e){const l=this.patterns[e],d=this.getImage(e);if(!d)return null;if(l&&l.position.version===d.version)return l.position;if(l)l.position.version=d.version;else{const l={w:d.data.width+2,h:d.data.height+2,x:0,y:0},p=new c.I(l,d);this.patterns[e]={bin:l,position:p}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const l=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new c.T(e,this.atlasImage,l.RGBA),this.atlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const l in this.patterns)e.push(this.patterns[l].bin);const{w:l,h:d}=c.p(e),p=this.atlasImage;p.resize({width:l||1,height:d||1});for(const e in this.patterns){const{bin:l}=this.patterns[e],d=l.x+1,f=l.y+1,m=this.getImage(e).data,_=m.width,g=m.height;c.R.copy(m,p,{x:0,y:0},{x:d,y:f},{width:_,height:g}),c.R.copy(m,p,{x:0,y:g-1},{x:d,y:f-1},{width:_,height:1}),c.R.copy(m,p,{x:0,y:0},{x:d,y:f+g},{width:_,height:1}),c.R.copy(m,p,{x:_-1,y:0},{x:d-1,y:f},{width:1,height:g}),c.R.copy(m,p,{x:0,y:0},{x:d+_,y:f},{width:1,height:g})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const l of e){if(this.callbackDispatchedThisFrame[l])continue;this.callbackDispatchedThisFrame[l]=!0;const e=this.getImage(l);e||c.w(`Image with ID: "${l}" was not found`),O(e)&&this.updateImage(l,e)}}cloneImages(){const e={};for(const l in this.images){const c=this.images[l];e[l]=Object.assign(Object.assign({},c),{data:c.data?c.data.clone():null})}return e}}const V=1e20;function j(e,l,c,d,p,f,m,_,g){for(let y=l;y-1);g++,f[g]=_,m[g]=y,m[g+1]=V}for(let _=0,g=0;_/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`)).join(",");return new M.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:c,fontWeight:this._fontWeight(l[0]),fontStyle:this._fontStyle(l[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const l={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 c;for(const[d,p]of Object.entries(l))new RegExp(`\\b${d}\\b`,"i").test(e)&&(c=`${p}`);return c}destroy(){for(const e in this.entries){const l=this.entries[e];l.tinySDF&&(l.tinySDF=null),l.ideographTinySDF&&(l.ideographTinySDF=null),l.glyphs={},l.requests={},l.ranges={}}this.entries={}}}M.loadGlyphRange=function(l,d,p,f){return c._(this||e,void 0,void 0,(function*(){const e=256*d,m=e+255,_=f.transformRequest(p.replace("{fontstack}",l).replace("{range}",`${e}-${m}`),"Glyphs"),g=yield c.n(_,new AbortController);if(!g||!g.data)throw new Error(`Could not load glyph range. range: ${d}, ${e}-${m}`);const y={};for(const e of c.o(g.data))y[e.id]=e;return y}))},M.TinySDF=class{constructor({fontSize:e=24,buffer:l=3,radius:c=8,cutoff:d=.25,fontFamily:p="sans-serif",fontWeight:f="normal",fontStyle:m="normal",lang:_=null}={}){this.buffer=l,this.cutoff=d,this.radius=c,this.lang=_;const g=this.size=e+4*l,y=this._createCanvas(g),b=this.ctx=y.getContext("2d",{willReadFrequently:!0});b.font=`${m} ${f} ${e}px ${p}`,b.textBaseline="alphabetic",b.textAlign="left",b.fillStyle="black",this.gridOuter=new Float64Array(g*g),this.gridInner=new Float64Array(g*g),this.f=new Float64Array(g),this.z=new Float64Array(g+1),this.v=new Uint16Array(g)}_createCanvas(e){const l=document.createElement("canvas");return l.width=l.height=e,l}draw(e){const{width:l,actualBoundingBoxAscent:c,actualBoundingBoxDescent:d,actualBoundingBoxLeft:p,actualBoundingBoxRight:f}=this.ctx.measureText(e),m=Math.ceil(c),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(f-p))),g=Math.min(this.size-this.buffer,m+Math.ceil(d)),y=_+2*this.buffer,b=g+2*this.buffer,T=Math.max(y*b,0),S=new Uint8ClampedArray(T),P={data:S,width:y,height:b,glyphWidth:_,glyphHeight:g,glyphTop:m,glyphLeft:0,glyphAdvance:l};if(0===_||0===g)return P;const{ctx:I,buffer:C,gridInner:R,gridOuter:L}=this;this.lang&&(I.lang=this.lang),I.clearRect(C,C,_,g),I.fillText(e,C,C+m);const F=I.getImageData(C,C,_,g);L.fill(V,0,T),R.fill(0,0,T);for(let e=0;e0?e*e:0,R[d]=e<0?e*e:0}}j(L,0,0,y,b,y,this.f,this.v,this.z),j(R,C,C,_,g,y,this.f,this.v,this.z);for(let e=0;e1&&(m=e[++f]);const g=Math.abs(_-m.left),y=Math.abs(_-m.right),b=Math.min(g,y);let T;const S=l/c*(d+1);if(m.isDash){const e=d-Math.abs(S);T=Math.sqrt(b*b+e*e)}else T=d-Math.sqrt(b*b+S*S);this.data[p+_]=Math.max(0,Math.min(255,T+128))}}}addRegularDash(e){for(let l=e.length-1;l>=0;--l){const c=e[l],d=e[l+1];c.zeroLength?e.splice(l,1):d&&d.isDash===c.isDash&&(d.left=c.left,e.splice(l,1))}const l=e[0],c=e[e.length-1];l.isDash===c.isDash&&(l.left=c.left-this.width,c.right=l.right+this.width);const d=this.width*this.nextRow;let p=0,f=e[p];for(let l=0;l1&&(f=e[++p]);const c=Math.abs(l-f.left),m=Math.abs(l-f.right),_=Math.min(c,m);this.data[d+l]=Math.max(0,Math.min(255,(f.isDash?_:-_)+128))}}addDash(e,l){const d=l?7:0,p=2*d+1;if(this.nextRow+p>this.height)return c.w("LineAtlas out of space"),null;let f=0;for(let l=0;l{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[W]}numActive(){return Object.keys(this.active).length}}const Q=Math.floor(g.hardwareConcurrency/2);let J,re;function oe(){return J||(J=new k),J}k.workerCount=c.K(globalThis)?Math.max(Math.min(Q,3),1):1;class N{constructor(e,l){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=l;const d=this.workerPool.acquire(l);for(let e=0;e{e.remove()})),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,l){for(const c of this.actors)c.registerMessageHandler(e,l)}unregisterMessageHandler(e){for(const l of this.actors)l.unregisterMessageHandler(e)}}function le(){return re||(re=new N(oe(),c.M),re.registerMessageHandler("GR",((e,l,d)=>c.m(l,d)))),re}function ce(e,l){const d=c.N();return c.O(d,d,[1,1,0]),c.Q(d,d,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?c.S(d,d,e.calculatePosMatrix(l.toUnwrapped())):d}function he(e,l,c,d,p,f,m){var _;const g=function(e,l,c){if(e)for(const d of e){const e=l[d];if(e&&e.source===c&&"fill-extrusion"===e.type)return!0}else for(const e in l){const d=l[e];if(d.source===c&&"fill-extrusion"===d.type)return!0}return!1}(null!==(_=null==p?void 0:p.layers)&&void 0!==_?_:null,l,e.id),y=f.maxPitchScaleFactor(),b=e.tilesIn(d,y,g);b.sort(ue);const T=[];for(const d of b)T.push({wrappedTileID:d.tileID.wrapped().key,queryResults:d.tile.queryRenderedFeatures(l,c,e.getState(),d.queryGeometry,d.cameraQueryGeometry,d.scale,p,f,y,ce(f,d.tileID),m?(e,l)=>m(d.tileID,e,l):void 0)});return function(e,l){for(const c in e)for(const d of e[c])pe(d,l);return e}(function(e){const l={},c={};for(const d of e){const e=d.queryResults,p=d.wrappedTileID,f=c[p]=c[p]||{};for(const c in e){const d=e[c],p=f[c]=f[c]||{},m=l[c]=l[c]||[];for(const e of d)p[e.featureIndex]||(p[e.featureIndex]=!0,m.push(e))}}return l}(T),e)}function ue(e,l){const c=e.tileID,d=l.tileID;return c.overscaledZ-d.overscaledZ||c.canonical.y-d.canonical.y||c.wrap-d.wrap||c.canonical.x-d.canonical.x}function pe(e,l){const c=e.feature,d=l.getFeatureState(c.layer["source-layer"],c.id);c.source=c.layer.source,c.layer["source-layer"]&&(c.sourceLayer=c.layer["source-layer"]),c.state=d}function fe(l,d,p,f){return c._(this||e,void 0,void 0,(function*(){let e=l;if(l.url?e=(yield c.j(d.transformRequest(l.url,"Source"),p)).data:yield g.frameAsync(p,f),!e)return null;const m=c.U(c.e(e,l),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in e&&e.vector_layers&&(m.vectorLayerIds=e.vector_layers.map((e=>e.id))),m}))}class ${constructor(e,l){e&&(l?this.setSouthWest(e).setNorthEast(l):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 c.V?new c.V(e.lng,e.lat):c.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof c.V?new c.V(e.lng,e.lat):c.V.convert(e),this}extend(e){const l=this._sw,d=this._ne;let p,f;if(e instanceof c.V)p=e,f=e;else{if(!(e instanceof $))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend($.convert(e)):this.extend(c.V.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(c.V.convert(e)):this;if(p=e._sw,f=e._ne,!p||!f)return this}return l||d?(l.lng=Math.min(p.lng,l.lng),l.lat=Math.min(p.lat,l.lat),d.lng=Math.max(f.lng,d.lng),d.lat=Math.max(f.lat,d.lat)):(this._sw=new c.V(p.lng,p.lat),this._ne=new c.V(f.lng,f.lat)),this}getCenter(){return new c.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 c.V(this.getWest(),this.getNorth())}getSouthEast(){return new c.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:l,lat:d}=c.V.convert(e);let p=this._sw.lng<=l&&l<=this._ne.lng;return this._sw.lng>this._ne.lng&&(p=this._sw.lng>=l&&l>=this._ne.lng),this._sw.lat<=d&&d<=this._ne.lat&&p}intersects(e){if(!((e=$.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;const l=Math.abs(this.getEast()-this.getWest()),d=Math.abs(e.getEast()-e.getWest());if(l>=360||d>=360)return!0;const p=c.W(this.getWest(),-180,180),f=c.W(this.getEast(),-180,180),m=c.W(e.getWest(),-180,180),_=c.W(e.getEast(),-180,180),g=p>=f,y=m>=_;return!(!g||!y)||(g?_>=p||m<=f:y?f>=m||p<=_:m<=f&&_>=p)}static convert(e){return e instanceof $?e:e?new $(e):e}static fromLngLat(e,l=0){const d=360*l/40075017,p=d/Math.cos(Math.PI/180*e.lat);return new $(new c.V(e.lng-p,e.lat-d),new c.V(e.lng+p,e.lat+d))}adjustAntiMeridian(){const e=new c.V(this._sw.lng,this._sw.lat),l=new c.V(this._ne.lng,this._ne.lat);return new $(e,e.lng>l.lng?new c.V(l.lng+360,l.lat):l)}}class H{constructor(e,l,c){this.bounds=$.convert(this.validateBounds(e)),this.minzoom=l||0,this.maxzoom=c||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 l=Math.pow(2,e.z),d=Math.floor(c.Y(this.bounds.getWest())*l),p=Math.floor(c.X(this.bounds.getNorth())*l),f=Math.ceil(c.Y(this.bounds.getEast())*l),m=Math.ceil(c.X(this.bounds.getSouth())*l);return e.x>=d&&e.x=p&&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 c.e({},this._options)}loadTile(e){return c._(this,void 0,void 0,(function*(){const l=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),c={request:this.map._requestManager.transformRequest(l,"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)};c.request.collectResourceTiming=this._collectResourceTiming;let d="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((l,c)=>{e.reloadPromise={resolve:l,reject:c}}))}else e.actor=this.dispatcher.getActor(),d="LT";e.abortController=new AbortController;try{const l=yield e.actor.sendAsync({type:d,data:c},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,l)}catch(l){if(delete e.abortController,e.aborted)return;if(l&&404!==l.status)throw l;this._afterTileLoadWorkerResponse(e,null)}}))}_getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const l=e.tileID.scaledTo(this.maxzoom).canonical,c=l.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:l,overzoomRequest:this.map._requestManager.transformRequest(c,"Tile")}}_afterTileLoadWorkerResponse(e,l){if(l&&l.resourceTiming&&(e.resourceTiming=l.resourceTiming),l&&this.map._refreshExpiredTiles&&e.setExpiryData(l),e.loadVectorData(l,this.map.painter),e.reloadPromise){const l=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(l.resolve).catch(l.reject)}}abortTile(e){return c._(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 c._(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 c.E{constructor(e,l,d,p){super(),this.id=e,this.dispatcher=d,this.setEventedParent(p),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=c.e({type:"raster"},l),c.e(this,c.U(l,["url","scheme","tileSize"]))}load(){return c._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new c.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const l=yield fe(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,l&&(c.e(this,l),l.bounds&&(this.tileBounds=new H(l.bounds,this.minzoom,this.maxzoom)),this.fire(new c.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new c.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,c.Z(e)||this.fire(new c.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 c.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return c._(this,void 0,void 0,(function*(){const l=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const d=yield L.getImage(this.map._requestManager.transformRequest(l,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(d&&d.data){this.map._refreshExpiredTiles&&(d.cacheControl||d.expires)&&e.setExpiryData({cacheControl:d.cacheControl,expires:d.expires});const l=this.map.painter.context,p=l.gl,f=d.data;e.texture=this.map.painter.getTileTexture(f.width),e.texture?e.texture.update(f,{useMipmap:!0}):(e.texture=new c.T(l,f,p.RGBA,{useMipmap:!0}),e.texture.bind(p.LINEAR,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(l){if(delete e.abortController,e.aborted)e.state="unloaded";else if(l)throw e.state="errored",l}}))}abortTile(e){return c._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return c._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class Y extends K{constructor(e,l,d,p){super(e,l,d,p),this.type="raster-dem",this.maxzoom=22,this._options=c.e({type:"raster-dem"},l),this.encoding=l.encoding||"mapbox",this.redFactor=l.redFactor,this.greenFactor=l.greenFactor,this.blueFactor=l.blueFactor,this.baseShift=l.baseShift}loadTile(e){return c._(this,void 0,void 0,(function*(){const l=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),d=this.map._requestManager.transformRequest(l,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const l=yield L.getImage(d,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(l&&l.data){const d=l.data;this.map._refreshExpiredTiles&&(l.cacheControl||l.expires)&&e.setExpiryData({cacheControl:l.cacheControl,expires:l.expires});const p=c.b(d)&&c.$()?d:yield this.readImageNow(d),f={type:this.type,uid:e.uid,source:this.id,rawImageData:p,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 l=yield e.actor.sendAsync({type:"LDT",data:f});e.dem=l,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(l){if(delete e.abortController,e.aborted)e.state="unloaded";else if(l)throw e.state="errored",l}}))}readImageNow(e){return c._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&c.a0()){const l=e.width+2,d=e.height+2;try{return new c.R({width:l,height:d},yield c.a1(e,-1,-1,l,d))}catch(e){}}return g.getImageData(e,1)}))}_getNeighboringTiles(e){const l=e.canonical,d=Math.pow(2,l.z),p=(l.x-1+d)%d,f=0===l.x?e.wrap-1:e.wrap,m=(l.x+1+d)%d,_=l.x+1===d?e.wrap+1:e.wrap,g={};return g[new c.a2(e.overscaledZ,f,l.z,p,l.y).key]={backfilled:!1},g[new c.a2(e.overscaledZ,_,l.z,m,l.y).key]={backfilled:!1},l.y>0&&(g[new c.a2(e.overscaledZ,f,l.z,p,l.y-1).key]={backfilled:!1},g[new c.a2(e.overscaledZ,e.wrap,l.z,l.x,l.y-1).key]={backfilled:!1},g[new c.a2(e.overscaledZ,_,l.z,m,l.y-1).key]={backfilled:!1}),l.y+1e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}function ge(e){const l=new $;let c;switch(e.type){case"FeatureCollection":c=e.features.map((e=>me(e.geometry))).flat(1/0);break;case"Feature":c=me(e.geometry);break;default:c=me(e)}if(0==c.length)return l;for(let e=0;ege(e)))}}shouldReloadTile(e,{affectedBounds:l}){if("loading"===e.state)return!0;if("unloaded"===e.state)return!1;const{buffer:d,extent:p}=this.workerOptions.geojsonVtOptions,f=function({x:e,y:l,z:d},p=0){const f=c.a3((e-p)/Math.pow(2,d)),m=c.a4((l+1+p)/Math.pow(2,d)),_=c.a3((e+1+p)/Math.pow(2,d)),g=c.a4((l-p)/Math.pow(2,d));return new $([f,m],[_,g])}(e.tileID.canonical,d/p);for(const e of l)if(f.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return c._(this,void 0,void 0,(function*(){const l=e.actor?"RT":"LT";e.actor=this.actor;const c={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 d=yield this.actor.sendAsync({type:l,data:c},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(d,this.map.painter,"RT"===l)}))}abortTile(e){return c._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return c._(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 c.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 c.E{constructor(e,l,c,d){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=c,this.coordinates=l.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(d),this.options=l}load(e){return c._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new c.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const l=yield L.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,l&&l.data&&(this.image=l.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,c.Z(e)||this.fire(new c.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 c.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 l=e.map(c.a9.fromLngLat);var d;return this.tileID=function(e){const l=c.aa.fromPoints(e),d=l.width(),p=l.height(),f=Math.max(d,p),m=Math.max(0,Math.floor(-Math.log(f)/Math.LN2)),_=Math.pow(2,m);return new c.ac(m,Math.floor((l.minX+l.maxX)/2*_),Math.floor((l.minY+l.maxY)/2*_))}(l),this.terrainTileRanges=this._getOverlappingTileRanges(l),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=l.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((d=this.tileCoords)[1].x-d[0].x)*(d[2].y-d[0].y)-(d[1].y-d[0].y)*(d[2].x-d[0].x)<0,this.fire(new c.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,l=e.gl;this.texture||(this.texture=new c.T(e,this.image,l.RGBA),this.texture.bind(l.LINEAR,l.CLAMP_TO_EDGE));let d=!1;for(const e in this.tiles){const l=this.tiles[e];"loaded"!==l.state&&(l.state="loaded",l.texture=this.texture,d=!0)}d&&this.fire(new c.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return c._(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:l,minY:d,maxX:p,maxY:f}=c.aa.fromPoints(e),m={};for(let e=0;e<=c.ab;e++){const c=Math.pow(2,e),_=Math.floor(l*c),g=Math.floor(d*c),y=Math.floor(p*c),b=Math.floor(f*c),T=(_%c+c)%c,S=y%c,P=Math.floor(_/c),I=Math.floor(y/c);m[e]={minWrap:P,maxWrap:I,minTileXWrapped:T,maxTileXWrapped:S,minTileY:g,maxTileY:b}}return m}}class ie extends te{constructor(e,l,c,d){super(e,l,c,d),this.roundZoom=!0,this.type="video",this.options=l}load(){return c._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const l of e.urls)this.urls.push(this.map._requestManager.transformRequest(l,"Source").url);try{const e=yield c.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 c.k(e))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const l=this.video.seekable;el.end(0)?this.fire(new c.k(new c.ae(`sources.${this.id}`,null,`Playback for this video can be set only between the ${l.start(0)} and ${l.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,l=e.gl;this.texture?this.video.paused||(this.texture.bind(l.LINEAR,l.CLAMP_TO_EDGE),l.texSubImage2D(l.TEXTURE_2D,0,0,0,l.RGBA,l.UNSIGNED_BYTE,this.video)):(this.texture=new c.T(e,this.video,l.RGBA),this.texture.bind(l.LINEAR,l.CLAMP_TO_EDGE));let d=!1;for(const e in this.tiles){const l=this.tiles[e];"loaded"!==l.state&&(l.state="loaded",l.texture=this.texture,d=!0)}d&&this.fire(new c.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,l,d,p){super(e,l,d,p),l.coordinates?Array.isArray(l.coordinates)&&4===l.coordinates.length&&!l.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new c.k(new c.ae(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new c.k(new c.ae(`sources.${e}`,null,'missing required property "coordinates"'))),l.animate&&"boolean"!=typeof l.animate&&this.fire(new c.k(new c.ae(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),l.canvas?"string"==typeof l.canvas||l.canvas instanceof HTMLCanvasElement||this.fire(new c.k(new c.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 c.k(new c.ae(`sources.${e}`,null,'missing required property "canvas"'))),this.options=l,this.animate=void 0===l.animate||l.animate}load(){return c._(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 c.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 l=this.map.painter.context,d=l.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new c.T(l,this.canvas,d.RGBA,{premultiply:!0}),this.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE));let p=!1;for(const e in this.tiles){const l=this.tiles[e];"loaded"!==l.state&&(l.state="loaded",l.texture=this.texture,p=!0)}p&&this.fire(new c.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 c.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 c._(this,arguments,void 0,(function*(e,l=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=g.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!l)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return c._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new c.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,l){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=c.af(),this.uses=0,this.tileSize=l,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:l,fadingParentID:c,fadeEndTime:d}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=l,this.fadingParentID=c,this.fadeEndTime=d}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=b(),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,l,d){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,l){const c={};if(!l)return c;for(const d of e){const e=d.layerIds.map((e=>l.getLayer(e))).filter(Boolean);if(0!==e.length){d.layers=e,d.stateDependentLayerIds&&(d.stateDependentLayers=d.stateDependentLayerIds.map((l=>e.filter((e=>e.id===l))[0])));for(const l of e)c[l.id]=d}}return c}(e.buckets,null==l?void 0:l.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const l=this.buckets[e];if(l instanceof c.ah){if(this.hasSymbolBuckets=!0,!d)break;l.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const l=this.buckets[e];if(l instanceof c.ah&&l.hasRTLText){this.hasRTLText=!0,we().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const c=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,l.style.getLayer(e).queryRadius(c))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new c.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 l in this.buckets){const c=this.buckets[l];c.uploadPending()&&c.upload(e)}const l=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new c.T(e,this.imageAtlas.image,l.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new c.T(e,this.glyphAtlasImage,l.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,l,c,d,p,f,m,_,g,y,b){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:d,cameraQueryGeometry:p,scale:f,tileSize:this.tileSize,pixelPosMatrix:y,transform:_,params:m,queryPadding:this.queryPadding*g,getElevation:b},e,l,c):{}}querySourceFeatures(e,l){const d=this.latestFeatureIndex;if(!d||!d.rawTileData)return;const p=d.loadVTLayers(),f=l&&l.sourceLayer?l.sourceLayer:"",m=p[c.ai]||p[f];if(!m)return;const _=c.aj(null==l?void 0:l.filter,null==l?void 0:l.globalState),{z:g,x:y,y:b}=this.tileID.canonical,T={z:g,x:y,y:b};for(let l=0;le)c=!1;else if(l)if(this.expirationTime({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),O=[],V=[];if(e.renderWorldCopies&&_.allowWorldCopies())for(let e=1;e<=3;e++)O.push(B(-e)),O.push(B(e));for(O.push(B(0));O.length>0;){const P=O.pop(),R=P.x,B=P.y;let j=P.fullyVisible;const G={x:R,y:B,z:P.zoom},U=_.getTileBoundingVolume(G,P.wrap,e.elevation,l);if(!j){const e=$e(d,U,p);if(0===e)continue;j=2===e}const q=_.distanceToTile2d(f.x,f.y,G,U);let Z=y;g&&(Z=(l.calculateTileZoom||et)(e.zoom+c.at(e.tileSize/l.tileSize),q,L,F,e.fov)),Z=(l.roundZoom?Math.round:Math.floor)(Z),Z=Math.max(0,Z);const W=Math.min(Z,T);if(P.wrap=_.getWrap(m,G,P.wrap),P.zoom>=W){if(P.zoom>1),wrap:P.wrap,fullyVisible:j})}return V.sort(((e,l)=>e.distanceSq-l.distanceSq)).map((e=>e.tileID))}const rt=c.aa.fromPoints([new c.P(0,0),new c.P(c.a5,c.a5)]);function ot(e){return"raster"===e||"image"===e||"video"===e}function at(e,l,c,d,p,f,m){if(!l.hasData())return!1;const{tileID:_,fadingRole:g,fadingDirection:y,fadingParentID:b}=l;if(g===Se.Base&&y===Me.Incoming&&b)return c[b.key]=b,!0;const T=Math.max(_.overscaledZ-p,f);for(let p=_.overscaledZ-1;p>=T;p--){const f=_.scaledTo(p),g=e.getLoadedTile(f);if(g)return l.setCrossFadeLogic({fadingRole:Se.Base,fadingDirection:Me.Incoming,fadingParentID:g.tileID,fadeEndTime:d+m}),g.setCrossFadeLogic({fadingRole:Se.Parent,fadingDirection:Me.Departing,fadeEndTime:d+m}),c[f.key]=f,!0}return!1}function ft(e,l,c,d,p,f){if(!l.hasData())return!1;const m=l.tileID.children(p);let _=_t(e,l,m,c,d,p,f);if(_)return!0;for(const g of m)_t(e,l,g.children(p),c,d,p,f)&&(_=!0);return _}function _t(e,l,c,d,p,f,m){if(c[0].overscaledZ>=f)return!1;let _=!1;for(const f of c){const c=e.getLoadedTile(f);if(!c)continue;const{fadingRole:g,fadingDirection:y,fadingParentID:b}=c;g===Se.Base&&y===Me.Departing&&b||(c.setCrossFadeLogic({fadingRole:Se.Base,fadingDirection:Me.Departing,fadingParentID:l.tileID,fadeEndTime:p+m}),l.setCrossFadeLogic({fadingRole:Se.Parent,fadingDirection:Me.Incoming,fadeEndTime:p+m})),d[f.key]=f,_=!0}return _}function yt(e,l,c,d){const p=e.tileID;return!!e.selfFading||!e.hasData()&&!!l.has(p)&&(e.setSelfFadeLogic(c+d),!0)}function vt(e,l){var c;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let d=l.tileID.canonical.x-e.tileID.canonical.x;const p=l.tileID.canonical.y-e.tileID.canonical.y,f=Math.pow(2,e.tileID.canonical.z),m=l.tileID.key;0===d&&0===p||Math.abs(p)>1||(Math.abs(d)>1&&(1===Math.abs(d+f)?d+=f:1===Math.abs(d-f)&&(d-=f)),l.dem&&e.dem&&(e.dem.backfillBorder(l.dem,d,p),(null===(c=e.neighboringTiles)||void 0===c?void 0:c[m])&&(e.neighboringTiles[m].backfilled=!0)))}class Le{constructor(){this._tiles={}}handleWrapJump(e){const l={};for(const c in this._tiles){const d=this._tiles[c];d.tileID=d.tileID.unwrapTo(d.tileID.wrap+e),l[d.tileID.key]=d}this._tiles=l}setFeatureState(e,l){for(const c in this._tiles)this._tiles[c].setFeatureState(e,l)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map((e=>e.tileID)).sort(c.aw).map((e=>e.key)):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,l){this._tiles[e]=l}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){const l=this.getTileById(e.key);return(null==l?void 0:l.hasData())?l:null}isIdRenderable(e,l=!1){var c;return null===(c=this.getTileById(e))||void 0===c?void 0:c.isRenderable(l)}getRenderableIds(e=0,l){const d=[];for(const e of this.getAllIds())this.isIdRenderable(e,l)&&d.push(this.getTileById(e));return l?d.sort(((l,d)=>{const p=l.tileID,f=d.tileID,m=new c.P(p.canonical.x,p.canonical.y)._rotate(-e),_=new c.P(f.canonical.x,f.canonical.y)._rotate(-e);return p.overscaledZ-f.overscaledZ||_.y-m.y||_.x-m.x})).map((e=>e.tileID.key)):d.map((e=>e.tileID)).sort(c.aw).map((e=>e.key))}}class ke extends c.E{constructor(e,l,d){super(),this.id=e,this.dispatcher=d,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((e,l,c,d)=>{const p=new(xe(l.type))(e,l,c,d);if(p.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${p.id}`);return p})(e,l,d,this),this._inViewTiles=new Le,this._outOfViewCache=new c.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,l,d){return c._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,l,d)}catch(l){e.state="errored",404!==l.status?this._source.fire(new c.k(l,{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 c.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 l of this._inViewTiles.getAllTiles())l.upload(e),l.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){var l;return this._inViewTiles.getRenderableIds(null===(l=this.transform)||void 0===l?void 0:l.bearingInRadians,e)}hasRenderableParent(e){const l=e.overscaledZ-1;if(l>=this._source.minzoom){const c=this.getLoadedTile(e.scaledTo(l));if(c)return this._inViewTiles.isIdRenderable(c.tileID.key)}return!1}reload(e,l=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const c of this._inViewTiles.getAllIds()){const d=this._inViewTiles.getTileById(c);l&&!this._source.shouldReloadTile(d,l)||(e?this._reloadTile(c,"expired"):"errored"!==d.state&&this._reloadTile(c,"reloading"))}}}_reloadTile(e,l){return c._(this,void 0,void 0,(function*(){const c=this._inViewTiles.getTileById(e);c&&("loading"!==c.state&&(c.state=l),yield this._loadTile(c,e,l))}))}_tileLoaded(e,l,d){e.timeAdded=b(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===d&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(l,e),"raster-dem"===this.getSource().type&&e.dem&&function(e,l){var c,d;const p=l.getRenderableIds();for(const f of p){if(!e.neighboringTiles||!e.neighboringTiles[f])continue;const p=l.getTileById(f);e.neighboringTiles[f].backfilled||vt(e,p),(null===(d=null===(c=p.neighboringTiles)||void 0===c?void 0:c[e.tileID.key])||void 0===d?void 0:d.backfilled)||vt(p,e)}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new c.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,l){const c=this._getLoadedDescendents(l),d=new Set;for(const p of l){const l=c[p.key];if(!(null==l?void 0:l.length)){d.add(p);continue}const f=p.overscaledZ+ke.maxOverzooming,m=l.filter((e=>e.tileID.overscaledZ<=f));if(!m.length){d.add(p);continue}const _=Math.min(...m.map((e=>e.tileID.overscaledZ))),g=m.filter((e=>e.tileID.overscaledZ===_)).map((e=>e.tileID));for(const l of g)e[l.key]=l;this._areDescendentsComplete(g,_,p.overscaledZ)||d.add(p)}return d}_getLoadedDescendents(e){var l;const c={};for(const d of this._inViewTiles.getAllTiles().filter((e=>e.hasData())))for(const p of e)d.tileID.isChildOf(p)&&(c[l=p.key]||(c[l]=[])).push(d);return c}_areDescendentsComplete(e,l,c){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===l:Math.pow(4,l-c)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){const l=Math.ceil(e.width/this._source.tileSize)+1,d=Math.ceil(e.height/this._source.tileSize)+1,p=Math.floor(l*d*(null===this._maxTileCacheZoomLevels?c.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),f="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,p):p;this._outOfViewCache.setMaxSize(f)}handleWrapJump(e){const l=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);this._prevLng=e,l&&(this._inViewTiles.handleWrapJump(l),this._resetTileReloadTimers())}update(e,l){if(!this._sourceLoaded||this._paused)return;let d;this.transform=e,this.terrain=l,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?d=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new c.a2(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(d=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:l,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(d=d.filter((e=>this._source.hasTile(e))))):d=[],this.usedForTerrain&&(d=this._addTerrainIdealTiles(d));const p=0===d.length&&!this._updated&&this._didEmitContent;this._updated=!0,p&&this.fire(new c.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const f=tt(e,this._source),m=this._updateRetainedTiles(d,f),_=ot(this._source.type);_&&this._rasterFadeDuration>0&&!l&&function(e,l,d,p,f,m,_){const g=b(),y=c.av(l);for(const c of l){const l=e.getTileById(c.key);l.fadingDirection!==Me.Departing&&0!==l.fadeOpacity||l.resetFadeLogic(),at(e,l,d,g,p,f,_)||ft(e,l,d,g,m,_)||yt(l,y,g,_)||l.resetFadeLogic()}}(this._inViewTiles,d,m,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),_?this._cleanUpRasterTiles(m):this._cleanUpVectorTiles(m)}_cleanUpRasterTiles(e){for(const l of this._inViewTiles.getAllIds())e[l]||this._removeTile(l)}_cleanUpVectorTiles(e){for(const l of this._inViewTiles.getAllIds()){const c=this._inViewTiles.getTileById(l);e[l]?c.clearSymbolFadeHold():c.hasSymbolBuckets?c.holdingForSymbolFade()?c.symbolFadeFinished()&&this._removeTile(l):c.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(l)}}_addTerrainIdealTiles(e){const l=[];for(const c of e)if(c.canonical.z>this._source.minzoom){const e=c.scaledTo(c.canonical.z-1);l.push(e);const d=c.scaledTo(Math.max(this._source.minzoom,Math.min(c.canonical.z,5)));l.push(d)}return e.concat(l)}releaseSymbolFadeTiles(){for(const e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,l){var c;const d=new Set;for(const l of e)this._addTile(l).hasData()||d.add(l);const p=e.reduce(((e,l)=>(e[l.key]=l,e)),{}),f=this._retainLoadedChildren(p,d),m={},_=Math.max(l-ke.maxUnderzooming,this._source.minzoom);for(const e of f){let l=this._inViewTiles.getTileById(e.key),d=null==l?void 0:l.wasRequested();for(let f=e.overscaledZ-1;f>=_;--f){const _=e.scaledTo(f);if(m[_.key])break;if(m[_.key]=!0,l=this.getTile(_),!l&&d&&(l=this._addTile(_)),l){const e=l.hasData();if((e||!(null===(c=this.map)||void 0===c?void 0:c.cancelPendingTileRequestsWhileZooming)||d)&&(p[_.key]=_),d=l.wasRequested(),e)break}}}return p}_addTile(e){let l=this._inViewTiles.getTileById(e.key);if(l)return l;l=this._outOfViewCache.getAndRemove(e),l&&(l.resetFadeLogic(),this._setTileReloadTimer(e.key,l),l.tileID=e,this._state.initializeTileState(l,this.map?this.map.painter:null));const d=l;return l||(l=new de(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(l,e.key,l.state)),l.uses++,this._inViewTiles.setTile(e.key,l),d||this._source.fire(new c.l("dataloading",{tile:l,coord:l.tileID,dataType:"source"})),l}_setTileReloadTimer(e,l){this._clearTileReloadTimer(e);const c=l.getExpiryTimeout();c&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),c))}_clearTileReloadTimer(e){const l=this._timers[e];l&&(clearTimeout(l),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 l=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,l)}}refreshTiles(e){for(const l of this._inViewTiles.getAllIds()){const c=this._inViewTiles.getTileById(l);(this._inViewTiles.isIdRenderable(l)||"errored"==c.state)&&e.some((e=>e.equals(c.tileID.canonical)))&&this._reloadTile(l,"expired")}}_removeTile(e){const l=this._inViewTiles.getTileById(e);l&&(l.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),l.uses>0||(l.hasData()&&"reloading"!==l.state?this._outOfViewCache.add(l.tileID,l,l.getExpiryTimeout()):(l.aborted=!0,this._abortTile(l),this._unloadTile(l))))}_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,l,d){const p=[],f=this.transform;if(!f)return p;const m=f.getCoveringTilesDetailsProvider().allowWorldCopies(),_=d?f.getCameraQueryGeometry(e):e,g=e=>f.screenPointToMercatorCoordinate(e,this.terrain),y=this.transformBbox(e,g,!m),b=this.transformBbox(_,g,!m),T=this.getIds(),S=c.aa.fromPoints(b);for(let e=0;ee.getTilePoint(new c.a9(l.x,l.y))));if(l.expandBy(P),l.intersects(rt)){const l=y.map((l=>e.getTilePoint(l))),c=b.map((l=>e.getTilePoint(l)));p.push({tile:d,tileID:m?e:e.unwrapTo(0),queryGeometry:l,cameraQueryGeometry:c,scale:g})}}}return p}transformBbox(e,l,d){let p=e.map(l);if(d){const d=c.aa.fromPoints(e);d.shrinkBy(.001*Math.min(d.width(),d.height()));const f=d.map(l);c.aa.fromPoints(p).covers(f)||(p=p.map((e=>e.x>.5?new c.a9(e.x-1,e.y,e.z):e)))}return p}getVisibleCoordinates(e){const l=this.getRenderableIds(e).map((e=>this._inViewTiles.getTileById(e).tileID));return this.transform&&this.transform.populateCache(l),l}hasTransition(){return!!this._source.hasTransition()||!(!ot(this._source.type)||!function(e,l){if(l<=0)return!1;const c=b();for(const l of e.getAllTiles())if(l.fadeEndTime>=c)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,l,d){this._state.updateState(e=e||c.ai,l,d)}removeFeatureState(e,l,d){this._state.removeFeatureState(e=e||c.ai,l,d)}getFeatureState(e,l){return this._state.getState(e=e||c.ai,l)}setDependencies(e,l,c){const d=this._inViewTiles.getTileById(e);d&&d.setDependencies(l,c)}reloadTilesForDependencies(e,l){for(const c of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(c).hasDependency(e,l)&&this._reloadTile(c,"reloading");this._outOfViewCache.filter((c=>!c.hasDependency(e,l)))}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,l){this.reset(e,l)}reset(e,l){this.points=e||[],this._distances=[0];for(let e=1;e0?(p-m)/_:0;return this.points[f].mult(1-g).add(this.points[l].mult(g))}}function bt(e,l){let c=!0;return"always"===e||"never"!==e&&"never"!==l||(c=!1),c}class Oe{constructor(e,l,c){const d=this.boxCells=[],p=this.circleCells=[];this.xCellCount=Math.ceil(e/c),this.yCellCount=Math.ceil(l/c);for(let e=0;ethis.width||d<0||l>this.height)return[];const _=[];if(e<=0&&l<=0&&this.width<=c&&this.height<=d){if(p)return[{key:null,x1:e,y1:l,x2:c,y2:d}];for(let e=0;e0}hitTestCircle(e,l,c,d,p){const f=e-c,m=e+c,_=l-c,g=l+c;if(m<0||f>this.width||g<0||_>this.height)return!1;const y=[];return this._forEachCell(f,_,m,g,this._queryCellCircle,y,{hitTest:!0,overlapMode:d,circle:{x:e,y:l,radius:c},seenUids:{box:{},circle:{}}},p),y.length>0}_queryCell(e,l,c,d,p,f,m,_){const{seenUids:g,hitTest:y,overlapMode:b}=m,T=this.boxCells[p];if(null!==T){const p=this.bboxes;for(const m of T)if(!g.box[m]){g.box[m]=!0;const T=4*m,S=this.boxKeys[m];if(e<=p[T+2]&&l<=p[T+3]&&c>=p[T+0]&&d>=p[T+1]&&(!_||_(S))&&(!y||!bt(b,S.overlapMode))&&(f.push({key:S,x1:p[T],y1:p[T+1],x2:p[T+2],y2:p[T+3]}),y))return!0}}const S=this.circleCells[p];if(null!==S){const p=this.circles;for(const m of S)if(!g.circle[m]){g.circle[m]=!0;const T=3*m,S=this.circleKeys[m];if(this._circleAndRectCollide(p[T],p[T+1],p[T+2],e,l,c,d)&&(!_||_(S))&&(!y||!bt(b,S.overlapMode))){const e=p[T],l=p[T+1],c=p[T+2];if(f.push({key:S,x1:e-c,y1:l-c,x2:e+c,y2:l+c}),y)return!0}}}return!1}_queryCellCircle(e,l,c,d,p,f,m,_){const{circle:g,seenUids:y,overlapMode:b}=m,T=this.boxCells[p];if(null!==T){const e=this.bboxes;for(const l of T)if(!y.box[l]){y.box[l]=!0;const c=4*l,d=this.boxKeys[l];if(this._circleAndRectCollide(g.x,g.y,g.radius,e[c+0],e[c+1],e[c+2],e[c+3])&&(!_||_(d))&&!bt(b,d.overlapMode))return f.push(!0),!0}}const S=this.circleCells[p];if(null!==S){const e=this.circles;for(const l of S)if(!y.circle[l]){y.circle[l]=!0;const c=3*l,d=this.circleKeys[l];if(this._circlesCollide(e[c],e[c+1],e[c+2],g.x,g.y,g.radius)&&(!_||_(d))&&!bt(b,d.overlapMode))return f.push(!0),!0}}}_forEachCell(e,l,c,d,p,f,m,_){const g=this._convertToXCellCoord(e),y=this._convertToYCellCoord(l),b=this._convertToXCellCoord(c),T=this._convertToYCellCoord(d);for(let S=g;S<=b;S++)for(let g=y;g<=T;g++)if(p.call(this,e,l,c,d,this.xCellCount*g+S,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,l,c,d,p,f){const m=d-e,_=p-l,g=c+f;return g*g>m*m+_*_}_circleAndRectCollide(e,l,c,d,p,f,m){const _=(f-d)/2,g=Math.abs(e-(d+_));if(g>_+c)return!1;const y=(m-p)/2,b=Math.abs(l-(p+y));if(b>y+c)return!1;if(g<=_||b<=y)return!0;const T=g-_,S=b-y;return T*T+S*S<=c*c}}function wt(e,l,d){const f=c.N();if(!e){const{vecSouth:e,vecEast:c}=Mt(l),d=p();d[0]=c[0],d[1]=c[1],d[2]=e[0],d[3]=e[1],m=d,(S=(g=(_=d)[0])*(T=_[3])-(b=_[2])*(y=_[1]))&&(m[0]=T*(S=1/S),m[1]=-y*S,m[2]=-b*S,m[3]=g*S),f[0]=d[0],f[1]=d[1],f[4]=d[2],f[5]=d[3]}var m,_,g,y,b,T,S;return c.Q(f,f,[1/d,1/d,1]),f}function Tt(e,l,d,p){if(e){const e=c.N();if(!l){const{vecSouth:l,vecEast:c}=Mt(d);e[0]=c[0],e[1]=c[1],e[4]=l[0],e[5]=l[1]}return c.Q(e,e,[p,p,1]),e}return d.pixelsToClipSpaceMatrix}function Mt(e){const l=Math.cos(e.rollInRadians),d=Math.sin(e.rollInRadians),p=Math.cos(e.pitchInRadians),f=Math.cos(e.bearingInRadians),m=Math.sin(e.bearingInRadians),_=c.aC();_[0]=-f*p*d-m*l,_[1]=-m*p*d+f*l;const g=c.aD(_);g<1e-9?c.aE(_):c.aF(_,_,1/g);const y=c.aC();y[0]=f*p*l-m*d,y[1]=m*p*l+f*d;const b=c.aD(y);return b<1e-9?c.aE(y):c.aF(y,y,1/b),{vecEast:y,vecSouth:_}}function At(e,l,d,p){let f;p?(f=[e,l,p(e,l),1],c.aH(f,f,d)):(f=[e,l,0,1],mi(f,f,d));const m=f[3];return{point:new c.P(f[0]/m,f[1]/m),signedDistanceFromCamera:m,isOccluded:!1}}function Lt(e,l){return.5+e/l*.5}function Ft(e,l){return e.x>=-l[0]&&e.x<=l[0]&&e.y>=-l[1]&&e.y<=l[1]}function Ot(e,l,d,p,f,m,_,g,y,b,T,S,P){const I=d?e.textSizeData:e.iconSizeData,C=c.ay(I,l.transform.zoom),R=[256/l.width*2+1,256/l.height*2+1],L=d?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;L.clear();const F=e.lineVertexArray,B=d?e.text.placedSymbolArray:e.icon.placedSymbolArray,O=l.transform.width/l.transform.height;let V=!1;for(let d=0;dMath.abs(d.x-l.x)*p?{useVertical:!0}:(e===c.az.vertical?l.yd.x)?{needsFlipping:!0}:null}function Ht(e){const{projectionContext:l,pitchedLabelPlaneMatrixInverse:d,symbol:p,fontSize:f,flip:m,keepUpright:_,glyphOffsetArray:g,dynamicLayoutVertexArray:y,aspectRatio:b,rotateToLine:T}=e,S=f/24,P=p.lineOffsetX*S,I=p.lineOffsetY*S;let C;if(p.numGlyphs>1){const e=p.glyphStartIndex+p.numGlyphs,c=p.lineStartIndex,f=p.lineStartIndex+p.lineLength,y=Ut(S,g,P,I,m,p,T,l);if(!y)return{notEnoughRoom:!0};const R=ri(y.first.point.x,y.first.point.y,l,d),L=ri(y.last.point.x,y.last.point.y,l,d);if(_&&!m){const e=Zt(p.writingMode,R,L,b);if(e)return e}C=[y.first];for(let d=p.glyphStartIndex+1;d0?_.point:Xt(l.tileAnchorPoint,m,e,1,l),y=ri(e.x,e.y,l,d),T=ri(g.x,g.y,l,d),S=Zt(p.writingMode,y,T,b);if(S)return S}const e=ui(S*g.getoffsetX(p.glyphStartIndex),P,I,m,p.segment,p.lineStartIndex,p.lineStartIndex+p.lineLength,l,T);if(!e||l.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};C=[e]}for(const e of C)c.aG(y,e.point,e.angle);return{}}function Xt(e,l,c,d,p){const f=e.add(e.sub(l)._unit()),m=Jt(f.x,f.y,p).point,_=c.sub(m);return c.add(_._mult(d/_.mag()))}function Kt(e,l,d){const p=l.projectionCache;if(p.projections[e])return p.projections[e];const f=new c.P(l.lineVertexArray.getx(e),l.lineVertexArray.gety(e)),m=Jt(f.x,f.y,l);if(m.signedDistanceFromCamera>0)return p.projections[e]=m.point,p.anyProjectionOccluded=p.anyProjectionOccluded||m.isOccluded,m.point;const _=e-d.direction;return Xt(0===d.distanceFromAnchor?l.tileAnchorPoint:new c.P(l.lineVertexArray.getx(_),l.lineVertexArray.gety(_)),f,d.previousVertex,d.absOffsetX-d.distanceFromAnchor+1,l)}function Jt(e,l,c){const d=e+c.translation[0],p=l+c.translation[1];let f;return c.pitchWithMap?(f=At(d,p,c.pitchedLabelPlaneMatrix,c.getElevation),f.isOccluded=!1):(f=c.transform.projectTileCoordinates(d,p,c.unwrappedTileID,c.getElevation),f.point.x=(.5*f.point.x+.5)*c.width,f.point.y=(.5*-f.point.y+.5)*c.height),f}function ri(e,l,d,p){if(d.pitchWithMap){const f=[e,l,0,1];return c.aH(f,f,p),d.transform.projectTileCoordinates(f[0]/f[3],f[1]/f[3],d.unwrappedTileID,d.getElevation).point}return{x:e/d.width*2-1,y:1-l/d.height*2}}function ni(e,l,c){return c.transform.projectTileCoordinates(e,l,c.unwrappedTileID,c.getElevation)}function li(e,l,c){return e._unit()._perp()._mult(l*c)}function ci(e,l,d,p,f,m,_,g,y){if(g.projectionCache.offsets[e])return g.projectionCache.offsets[e];const b=d.add(l);if(e+y.direction=f)return g.projectionCache.offsets[e]=b,b;const T=Kt(e+y.direction,g,y),S=li(T.sub(d),_,y.direction),P=d.add(S),I=T.add(S);return g.projectionCache.offsets[e]=c.aI(m,b,P,I)||b,g.projectionCache.offsets[e]}function ui(e,l,c,d,p,f,m,_,g){const y=d?e-l:e+l;let b=y>0?1:-1,T=0;d&&(b*=-1,T=Math.PI),b<0&&(T+=Math.PI);let S,P=b>0?f+p:f+p+1;_.projectionCache.cachedAnchorPoint?S=_.projectionCache.cachedAnchorPoint:(S=Jt(_.tileAnchorPoint.x,_.tileAnchorPoint.y,_).point,_.projectionCache.cachedAnchorPoint=S);let I,C,R=S,L=S,F=0,B=0;const O=Math.abs(y),V=[];let j;for(;F+B<=O;){if(P+=b,P=m)return null;F+=B,L=R,C=I;const e={absOffsetX:O,direction:b,distanceFromAnchor:F,previousVertex:L};if(R=Kt(P,_,e),0===c)V.push(L),j=R.sub(L);else{let l;const d=R.sub(L);l=0===d.mag()?li(Kt(P+b,_,e).sub(R),c,b):li(d,c,b),C||(C=L.add(l)),I=ci(P,l,R,f,m,C,c,_,e),V.push(C),j=I.sub(C)}B=j.mag()}const G=j._mult((O-F)/B)._add(C||L),U=T+Math.atan2(R.y-L.y,R.x-L.x);return V.push(G),{point:G,angle:g?U:0,path:V}}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,l){for(let c=0;c=1;e--)P.push(m.path[e]);for(let e=1;e<_.path.length;e++)P.push(_.path[e]);const I=2.5*l;if(y){const e=this.projectPathToScreenSpace(P,B);P=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let R=[];if(P.length>0){const e=P[0].clone(),l=P[0].clone();for(let c=1;c=d.x&&l.x<=p.x&&e.y>=d.y&&l.y<=p.y?[P]:l.xp.x||l.yp.y?[]:c.aJ([P],d.x,d.y,p.x,p.y)}for(const c of R){f.reset(c,.25*l);let d=0;d=f.length<=.5*l?1:Math.ceil(f.paddedLength/I)+1;for(let c=0;c{const c=At(e.x,e.y,d,l.getElevation),p=l.transform.projectTileCoordinates(c.point.x,c.point.y,l.unwrappedTileID,l.getElevation);return p.point.x=(.5*p.point.x+.5)*l.width,p.point.y=(.5*-p.point.y+.5)*l.height,p}))}(e,l);return function(e){let l=0,c=0,d=0,p=0;for(let f=0;fc&&(c=p,l=d));return e.slice(l,l+c)}(d)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const l=[],d=new c.aa;for(const p of e){const e=new c.P(p.x+_i,p.y+_i);d.extend(e),l.push(e)}const{minX:p,minY:f,maxX:m,maxY:_}=d,g=this.grid.query(p,f,m,_).concat(this.ignoredGrid.query(p,f,m,_)),y={},b={};for(const e of g){const d=e.key;if(void 0===y[d.bucketInstanceId]&&(y[d.bucketInstanceId]={}),y[d.bucketInstanceId][d.featureIndex])continue;const p=[new c.P(e.x1,e.y1),new c.P(e.x2,e.y1),new c.P(e.x2,e.y2),new c.P(e.x1,e.y2)];c.aK(l,p)&&(y[d.bucketInstanceId][d.featureIndex]=!0,void 0===b[d.bucketInstanceId]&&(b[d.bucketInstanceId]=[]),b[d.bucketInstanceId].push(d.featureIndex))}return b}insertCollisionBox(e,l,c,d,p,f){(c?this.ignoredGrid:this.grid).insert({bucketInstanceId:d,featureIndex:p,collisionGroupID:f,overlapMode:l},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,l,c,d,p,f){const m=c?this.ignoredGrid:this.grid,_={bucketInstanceId:d,featureIndex:p,collisionGroupID:f,overlapMode:l};for(let l=0;l=this.screenRightBoundary||d<_i||l>this.screenBottomBoundary}isInsideGrid(e,l,c,d){return c>=0&&e=0&&lthis.projectAndGetPerspectiveRatio(e.x,e.y,p,y,T)));J=e.some((e=>!e.isOccluded)),Q=e.map((e=>new c.P(e.x,e.y)))}else J=!0;return{box:c.aL(Q),allPointsOccluded:!J}}}class lt{constructor(e,l,c,d){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?l:-l))):d&&c?1:0,this.placed=c}isHidden(){return 0===this.opacity&&!this.placed}}class ct{constructor(e,l,c,d,p){this.text=new lt(e?e.text:null,l,c,p),this.icon=new lt(e?e.icon:null,l,d,p)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class ht{constructor(e,l,c){this.text=e,this.icon=l,this.skipFade=c}}class ut{constructor(e,l,c,d,p){this.bucketInstanceId=e,this.featureIndex=l,this.sourceLayerIndex=c,this.bucketIndex=d,this.tileID=p}}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 l=++this.maxGroupID;this.collisionGroups[e]={ID:l,predicate:e=>e.collisionGroupID===l}}return this.collisionGroups[e]}}function gi(e,l,d,p,f){const{horizontalAlign:m,verticalAlign:_}=c.aS(e);return new c.P(-(m-.5)*l+p[0]*f,-(_-.5)*d+p[1]*f)}class pt{constructor(e,l,c,d,p){this.transform=e.clone(),this.terrain=l,this.collisionIndex=new nt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=c,this.retainedQueryData={},this.collisionGroups=new dt(d),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=p,p&&(p.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const l=this.terrain;return l?(c,d)=>l.getElevation(e,c,d):null}getBucketParts(e,l,d,p){const f=d.getBucket(l),m=d.latestFeatureIndex;if(!f||!m||l.id!==f.layerIds[0])return;const _=d.collisionBoxArray,g=f.layers[0].layout,y=f.layers[0].paint,b=Math.pow(2,this.transform.zoom-d.tileID.overscaledZ),T=d.tileSize/c.a5,S=d.tileID.toUnwrapped(),P="map"===g.get("text-rotation-alignment"),I=c.aN(d,1,this.transform.zoom),C=c.aO(this.collisionIndex.transform,d,y.get("text-translate"),y.get("text-translate-anchor")),R=c.aO(this.collisionIndex.transform,d,y.get("icon-translate"),y.get("icon-translate-anchor")),L=wt(P,this.transform,I);this.retainedQueryData[f.bucketInstanceId]=new ut(f.bucketInstanceId,m,f.sourceLayerIndex,f.index,d.tileID);const F={bucket:f,layout:g,translationText:C,translationIcon:R,unwrappedTileID:S,pitchedLabelPlaneMatrix:L,scale:b,textPixelRatio:T,holdingForFade:d.holdingForSymbolFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:c.ay(f.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(f.sourceID)};if(p)for(const l of f.sortKeyRanges){const{sortKey:c,symbolInstanceStart:d,symbolInstanceEnd:p}=l;e.push({sortKey:c,symbolInstanceStart:d,symbolInstanceEnd:p,parameters:F})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:f.symbolInstances.length,parameters:F})}attemptAnchorPlacement(e,l,d,p,f,m,_,g,y,b,T,S,P,I,C,R,L,F,B,O){const V=c.aP[e.textAnchor],j=[e.textOffset0,e.textOffset1],G=gi(V,d,p,j,f),U=this.collisionIndex.placeCollisionBox(l,S,g,y,b,_,m,R,T.predicate,B,G,O);if((!F||this.collisionIndex.placeCollisionBox(F,S,g,y,b,_,m,L,T.predicate,B,G,O).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:d,height:p,anchor:V,textBoxScale:f,prevAnchor:e},this.markUsedJustification(I,V,P,C),I.allowVerticalPlacement&&(this.markUsedOrientation(I,C,P),this.placedOrientations[P.crossTileID]=C),{shift:G,placedGlyphBoxes:U}}}placeLayerBucketPart(e,l,d){const{bucket:p,layout:f,translationText:m,translationIcon:_,unwrappedTileID:g,pitchedLabelPlaneMatrix:y,textPixelRatio:b,holdingForFade:T,collisionBoxArray:S,partiallyEvaluatedTextSize:P,collisionGroup:I}=e.parameters,C=f.get("text-optional"),R=f.get("icon-optional"),L=c.aQ(f,"text-overlap","text-allow-overlap"),F="always"===L,B=c.aQ(f,"icon-overlap","icon-allow-overlap"),O="always"===B,V="map"===f.get("text-rotation-alignment"),j="map"===f.get("text-pitch-alignment"),G="none"!==f.get("icon-text-fit"),U="viewport-y"===f.get("symbol-z-order"),q=F&&(O||!p.hasIconData()||R),Z=O&&(F||!p.hasTextData()||C);!p.collisionArrays&&S&&p.deserializeCollisionBoxes(S);const W=this.retainedQueryData[p.bucketInstanceId].tileID,Q=this._getTerrainElevationFunc(W),J=this.transform.getFastPathSimpleProjectionMatrix(W),re=(e,S,O)=>{var U,re;if(l[e.crossTileID])return;if(T)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;S.textFeatureIndex?ye=S.textFeatureIndex:e.useRuntimeCollisionCircles&&(ye=e.featureIndex),S.verticalTextFeatureIndex&&(xe=S.verticalTextFeatureIndex);const be=S.textBox;if(be){const l=l=>{let d=c.az.horizontal;if(p.allowVerticalPlacement&&!l&&this.prevPlacement){const l=this.prevPlacement.placedOrientations[e.crossTileID];l&&(this.placedOrientations[e.crossTileID]=l,d=l,this.markUsedOrientation(p,d,e))}return d},f=(l,d)=>{if(p.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&S.verticalTextBox){for(const e of p.writingModes)if(e===c.az.vertical?(ue=d(),pe=ue):ue=l(),ue&&ue.placeable)break}else ue=l()},y=e.textAnchorOffsetStartIndex,T=e.textAnchorOffsetEndIndex;if(T===y){const d=(l,c)=>{const d=this.collisionIndex.placeCollisionBox(l,L,b,W,g,j,V,m,I.predicate,Q,void 0,J);return d&&d.placeable&&(this.markUsedOrientation(p,c,e),this.placedOrientations[e.crossTileID]=c),d};f((()=>d(be,c.az.horizontal)),(()=>{const l=S.verticalTextBox;return p.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&l?d(l,c.az.vertical):{box:null,offscreen:null}})),l(ue&&ue.placeable)}else{let P=c.aP[null===(re=null===(U=this.prevPlacement)||void 0===U?void 0:U.variableOffsets[e.crossTileID])||void 0===re?void 0:re.anchor];const C=(l,c,f)=>{const S=l.x2-l.x1,C=l.y2-l.y1,R=e.textBoxScale,F=G&&"never"===B?c:null;let O=null,U="never"===L?1:2,q="never";P&&U++;for(let c=0;cC(be,S.iconBox,c.az.horizontal)),(()=>{const l=S.verticalTextBox;return p.allowVerticalPlacement&&(!ue||!ue.placeable)&&e.numVerticalGlyphVertices>0&&l?C(l,S.verticalIconBox,c.az.vertical):{box:null,occluded:!0,offscreen:null}})),ue&&(oe=ue.placeable,ce=ue.offscreen);const R=l(ue&&ue.placeable);if(!oe&&this.prevPlacement){const l=this.prevPlacement.variableOffsets[e.crossTileID];l&&(this.variableOffsets[e.crossTileID]=l,this.markUsedJustification(p,l.anchor,e,R))}}}if(fe=ue,oe=fe&&fe.placeable,ce=fe&&fe.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const l=p.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),_=c.aA(p.textSizeData,P,l),b=f.get("text-padding");me=this.collisionIndex.placeCollisionCircles(L,l,p.lineVertexArray,p.glyphOffsetArray,_,g,y,d,j,I.predicate,e.collisionCircleDiameter,b,m,Q),me.circles.length&&me.collisionDetected&&!d&&c.w("Collisions detected, but collision boxes are not shown"),oe=F||me.circles.length>0&&!me.collisionDetected,ce=ce&&me.offscreen}if(S.iconFeatureIndex&&(ve=S.iconFeatureIndex),S.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,B,b,W,g,j,V,_,I.predicate,Q,G&&he?he:void 0,J);pe&&pe.placeable&&S.verticalIconBox?(ge=e(S.verticalIconBox),le=ge.placeable):(ge=e(S.iconBox),le=ge.placeable),ce=ce&&ge.offscreen}const we=C||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Se=R||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,L,f.get("text-ignore-placement"),p.bucketInstanceId,pe&&pe.placeable&&xe?xe:ye,I.ID),Me&&this.collisionIndex.insertCollisionBox(ge.box,B,f.get("icon-ignore-placement"),p.bucketInstanceId,ve,I.ID),me&&oe&&this.collisionIndex.insertCollisionCircles(me.circles,L,f.get("text-ignore-placement"),p.bucketInstanceId,ye,I.ID),d&&this.storeCollisionData(p.bucketInstanceId,O,S,fe,ge,me),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===p.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||p.justReloaded),l[e.crossTileID]=!0};if(U){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const l=p.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=l.length-1;e>=0;--e){const c=l[e];re(p.symbolInstances.get(c),p.collisionArrays[c],c)}}else for(let l=e.symbolInstanceStart;l=0&&(e.text.placedSymbolArray.get(l).crossTileID=f>=0&&l!==f?0:d.crossTileID)}markUsedOrientation(e,l,d){const p=l===c.az.horizontal||l===c.az.horizontalOnly?l:0,f=l===c.az.vertical?l:0,m=[d.leftJustifiedTextSymbolIndex,d.centerJustifiedTextSymbolIndex,d.rightJustifiedTextSymbolIndex];for(const l of m)e.text.placedSymbolArray.get(l).placedOrientation=p;d.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(d.verticalPlacedTextSymbolIndex).placedOrientation=f)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const l=this.prevPlacement;let c=!1;this.prevZoomAdjustment=l?l.zoomAdjustment(this.transform.zoom):0;const d=l?l.symbolFadeChange(e):1,p=l?l.opacities:{},f=l?l.variableOffsets:{},m=l?l.placedOrientations:{};for(const e in this.placements){const l=this.placements[e],f=p[e];f?(this.opacities[e]=new ct(f,d,l.text,l.icon),c=c||l.text!==f.text.placed||l.icon!==f.icon.placed):(this.opacities[e]=new ct(null,d,l.text,l.icon,l.skipFade),c=c||l.text||l.icon)}for(const e in p){const l=p[e];if(!this.opacities[e]){const p=new ct(l,d,!1,!1);p.isHidden()||(this.opacities[e]=p,c=c||l.text.placed||l.icon.placed)}}for(const e in f)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=f[e]);for(const e in m)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=m[e]);if(l&&void 0===l.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");c?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=l?l.lastPlacementChangeTime:e)}updateLayerOpacities(e,l){const c={};for(const d of l){const l=d.getBucket(e);l&&d.latestFeatureIndex&&e.id===l.layerIds[0]&&this.updateBucketOpacities(l,d.tileID,c,d.collisionBoxArray)}}updateBucketOpacities(e,l,d,p){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 f=e.layers[0],m=f.layout,_=new ct(null,0,!1,!1,!0),g=m.get("text-allow-overlap"),y=m.get("icon-allow-overlap"),b=f._unevaluatedLayout.hasValue("text-variable-anchor")||f._unevaluatedLayout.hasValue("text-variable-anchor-offset"),T="map"===m.get("text-rotation-alignment"),S="map"===m.get("text-pitch-alignment"),P="none"!==m.get("icon-text-fit"),I=new ct(null,0,g&&(y||!e.hasIconData()||m.get("icon-optional")),y&&(g||!e.hasTextData()||m.get("text-optional")),!0);!e.collisionArrays&&p&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(p);const C=(e,l,c)=>{for(let d=0;d0,F=this.placedOrientations[p.crossTileID],B=F===c.az.vertical,O=F===c.az.horizontal||F===c.az.horizontalOnly;if(f>0||m>0){const l=Ai(y.text);C(e.text,f,B?Li:l),C(e.text,m,O?Li:l);const c=y.text.isHidden();[p.rightJustifiedTextSymbolIndex,p.centerJustifiedTextSymbolIndex,p.leftJustifiedTextSymbolIndex].forEach((l=>{l>=0&&(e.text.placedSymbolArray.get(l).hidden=c||B?1:0)})),p.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(p.verticalPlacedTextSymbolIndex).hidden=c||O?1:0);const d=this.variableOffsets[p.crossTileID];d&&this.markUsedJustification(e,d.anchor,p,F);const _=this.placedOrientations[p.crossTileID];_&&(this.markUsedJustification(e,"left",p,_),this.markUsedOrientation(e,_,p))}if(L){const l=Ai(y.icon),c=!(P&&p.verticalPlacedIconSymbolIndex&&B);p.placedIconSymbolIndex>=0&&(C(e.icon,p.numIconVertices,c?l:Li),e.icon.placedSymbolArray.get(p.placedIconSymbolIndex).hidden=y.icon.isHidden()),p.verticalPlacedIconSymbolIndex>=0&&(C(e.icon,p.numVerticalIconVertices,c?Li:l),e.icon.placedSymbolArray.get(p.verticalPlacedIconSymbolIndex).hidden=y.icon.isHidden())}const V=R&&R.has(l)?R.get(l):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const d=e.collisionArrays[l];if(d){let l=new c.P(0,0);if(d.textBox||d.verticalTextBox){let c=!0;if(b){const e=this.variableOffsets[g];e?(l=gi(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),T&&l._rotate(S?-this.transform.bearingInRadians:this.transform.bearingInRadians)):c=!1}if(d.textBox||d.verticalTextBox){let p;d.textBox&&(p=B),d.verticalTextBox&&(p=O),yi(e.textCollisionBox.collisionVertexArray,y.text.placed,!c||p,V.text,l.x,l.y)}}if(d.iconBox||d.verticalIconBox){const c=Boolean(!O&&d.verticalIconBox);let p;d.iconBox&&(p=c),d.verticalIconBox&&(p=!c),yi(e.iconCollisionBox.collisionVertexArray,y.icon.placed,p,V.icon,P?l.x:0,P?l.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,l,c,d,p,f){d&&0!==d.length||(d=[0,0,0,0]);const m=d[0]-_i,_=d[1]-_i,g=d[2]-_i,y=d[3]-_i;e.emplaceBack(l?1:0,c?1:0,p||0,f||0,m,_),e.emplaceBack(l?1:0,c?1:0,p||0,f||0,g,_),e.emplaceBack(l?1:0,c?1:0,p||0,f||0,g,y),e.emplaceBack(l?1:0,c?1:0,p||0,f||0,m,y)}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 l=e.placed?1:0,c=Math.floor(127*e.opacity);return c*xi+l*vi+c*bi+l*wi+c*Ii+l*Ei+c*Ci+l}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,l,c,d,p){const f=this._bucketParts;for(;this._currentTileIndexe.sortKey-l.sortKey)));this._currentPartIndex!this._forceFullPlacement&&b()-d>2;for(;this._currentPlacementIndex>=0;){const d=l[e[this._currentPlacementIndex]],f=this.placement.collisionIndex.transform.zoom;if("symbol"===d.type&&(!d.minzoom||d.minzoom<=f)&&(!d.maxzoom||d.maxzoom>f)){if(this._inProgressLayer||(this._inProgressLayer=new Ct(d)),this._inProgressLayer.continuePlacement(c[d.source],this.placement,this._showCollisionBoxes,d,p))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Fi=512/c.a5/2;class Et{constructor(e,l,d){this.tileID=e,this.bucketInstanceId=d,this._symbolsByKey={};const p=new Map;for(let e=0;e({x:Math.floor(e.anchorX*Fi),y:Math.floor(e.anchorY*Fi)}))),crossTileIDs:l.map((e=>e.crossTileID))};if(d.positions.length>128){const e=new c.aT(d.positions.length,16,Uint16Array);for(const{x:l,y:c}of d.positions)e.add(l,c);e.finish(),delete d.positions,d.index=e}this._symbolsByKey[e]=d}}getScaledCoordinates(e,l){const{x:d,y:p,z:f}=this.tileID.canonical,{x:m,y:_,z:g}=l.canonical,y=Fi/Math.pow(2,g-f),b=(_*c.a5+e.anchorY)*y,T=p*c.a5*Fi;return{x:Math.floor((m*c.a5+e.anchorX)*y-d*c.a5*Fi),y:Math.floor(b-T)}}findMatches(e,l,c){const d=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 l=Math.round((e-this.lng)/360);if(0!==l)for(const e in this.indexes){const c=this.indexes[e],d={};for(const e in c){const p=c[e];p.tileID=p.tileID.unwrapTo(p.tileID.wrap+l),d[p.tileID.key]=p}this.indexes[e]=d}this.lng=e}addBucket(e,l,c){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===l.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;ee.overscaledZ)for(const c in p){const f=p[c];f.tileID.isChildOf(e)&&f.findMatches(l.symbolInstances,e,d)}else{const f=p[e.scaledTo(Number(c)).key];f&&f.findMatches(l.symbolInstances,e,d)}}for(let e=0;e{l[e]=!0}));for(const e in this.layerIndexes)l[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,l){const c=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,d=l.match(/in ([\w]+) ([\w]+)/g),p=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),f=l.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),m=f?f.concat(p):p,_={};return{fragmentSource:e=e.replace(c,((e,l,c,d,p)=>(_[p]=!0,"define"===l?`\n#ifndef HAS_UNIFORM_u_${p}\nin ${c} ${d} ${p};\n#else\nuniform ${c} ${d} u_${p};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${p}\n ${c} ${d} ${p} = u_${p};\n#endif\n`))),vertexSource:l=l.replace(c,((e,l,c,d,p)=>{const f="float"===d?"vec2":"vec4",m=p.match(/color/)?"color":f;return _[p]?"define"===l?`\n#ifndef HAS_UNIFORM_u_${p}\nuniform lowp float u_${p}_t;\nin ${c} ${f} a_${p};\nout ${c} ${d} ${p};\n#else\nuniform ${c} ${d} u_${p};\n#endif\n`:"vec4"===m?`\n#ifndef HAS_UNIFORM_u_${p}\n ${p} = a_${p};\n#else\n ${c} ${d} ${p} = u_${p};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${p}\n ${p} = unpack_mix_${m}(a_${p}, u_${p}_t);\n#else\n ${c} ${d} ${p} = u_${p};\n#endif\n`:"define"===l?`\n#ifndef HAS_UNIFORM_u_${p}\nuniform lowp float u_${p}_t;\nin ${c} ${f} a_${p};\n#else\nuniform ${c} ${d} u_${p};\n#endif\n`:"vec4"===m?`\n#ifndef HAS_UNIFORM_u_${p}\n ${c} ${d} ${p} = a_${p};\n#else\n ${c} ${d} ${p} = u_${p};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${p}\n ${c} ${d} ${p} = unpack_mix_${m}(a_${p}, u_${p}_t);\n#else\n ${c} ${d} ${p} = u_${p};\n#endif\n`})),staticAttributes:d,staticUniforms:m}}class kt{constructor(e,l,c){this.vertexBuffer=e,this.indexBuffer=l,this.segments=c}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Ni=c.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 c.aV.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,l,d,p,f){if(this._cachedMesh)return this._cachedMesh;const m=new c.aW;m.emplaceBack(0,0),m.emplaceBack(c.a5,0),m.emplaceBack(0,c.a5),m.emplaceBack(c.a5,c.a5);const _=e.createVertexBuffer(m,Ni.members),g=c.aX.simpleSegment(0,0,4,2),y=new c.aY;y.emplaceBack(1,0,2),y.emplaceBack(1,2,3);const b=e.createIndexBuffer(y);return this._cachedMesh=new kt(_,b,g),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Nt{constructor(e=0,l=0,c=0,d=0){if(isNaN(e)||e<0||isNaN(l)||l<0||isNaN(c)||c<0||isNaN(d)||d<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=l,this.left=c,this.right=d}interpolate(e,l,d){return null!=l.top&&null!=e.top&&(this.top=c.G.number(e.top,l.top,d)),null!=l.bottom&&null!=e.bottom&&(this.bottom=c.G.number(e.bottom,l.bottom,d)),null!=l.left&&null!=e.left&&(this.left=c.G.number(e.left,l.left,d)),null!=l.right&&null!=e.right&&(this.right=c.G.number(e.right,l.right,d)),this}getCenter(e,l){const d=c.an((this.left+e-this.right)/2,0,e),p=c.an((this.top+l-this.bottom)/2,0,l);return new c.P(d,p)}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,l){if(!e.renderWorldCopies||e.lngRange)return;const c=l.lng-e.center.lng;l.lng+=c>180?-360:c<-180?360:0}function $i(e){return Math.max(0,Math.floor(e))}class Gt{constructor(e,l){var d;this.applyConstrain=(e,l)=>null!==this._constrainOverride?this._constrainOverride(e,l):this._callbacks.defaultConstrain(e,l),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==l?void 0:l.renderWorldCopies)||!!(null==l?void 0:l.renderWorldCopies),this._minZoom=(null==l?void 0:l.minZoom)||0,this._maxZoom=(null==l?void 0:l.maxZoom)||22,this._minPitch=null==(null==l?void 0:l.minPitch)?0:null==l?void 0:l.minPitch,this._maxPitch=null==(null==l?void 0:l.maxPitch)?60:null==l?void 0:l.maxPitch,this._constrainOverride=null!==(d=null==l?void 0:l.constrainOverride)&&void 0!==d?d:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new c.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=$i(this._zoom),this._scale=c.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,l,d){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=c.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=!d&&e.autoCalculateNearFarZ,l&&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 c.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const l=c.W(e,-180,180)*Math.PI/180;var d,f,m,_,g,y,b,T,S;this._bearingInRadians!==l&&(this._unmodified=!1,this._bearingInRadians=l,this._calcMatrices(),this._rotationMatrix=p(),d=this._rotationMatrix,m=-this._bearingInRadians,_=(f=this._rotationMatrix)[0],g=f[1],y=f[2],b=f[3],T=Math.sin(m),S=Math.cos(m),d[0]=_*S+y*T,d[1]=g*S+b*T,d[2]=_*-T+y*S,d[3]=g*-T+b*S)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const l=c.an(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==l&&(this._unmodified=!1,this._pitchInRadians=l,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const l=e/180*Math.PI;this._rollInRadians!==l&&(this._unmodified=!1,this._rollInRadians=l,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return c.aZ(this._fovInRadians)}setFov(e){e=c.an(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=c.ap(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const l=this.applyConstrain(this._center,e).zoom;this._zoom!==l&&(this._unmodified=!1,this._zoom=l,this._tileZoom=Math.max(0,Math.floor(l)),this._scale=c.aq(l),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,l){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=l,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,l,c){this._unmodified=!1,this._edgeInsets.interpolate(e,l,c),this.constrainInternal(),this._calcMatrices()}resize(e,l,c=!0){this._width=e,this._height=l,c&&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=[-c.ao,c.ao])}getCameraQueryGeometry(e,l){if(1===l.length)return[l[0],e];{const{minX:d,minY:p,maxX:f,maxY:m}=c.aa.fromPoints(l).extend(e);return[new c.P(d,p),new c.P(f,p),new c.P(f,m),new c.P(d,m),new c.P(d,p)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:l,zoom:c}=this.applyConstrain(this.center,this.zoom);this.setCenter(l),this.setZoom(c),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=c.ar(new Float64Array(16));c.Q(e,e,[this._width/2,-this._height/2,1]),c.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=c.ar(new Float64Array(16)),c.Q(e,e,[1,-1,1]),c.O(e,e,[-1,-1,0]),c.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,l,d,p){const f=void 0!==d?d:this.bearing,m=p=void 0!==p?p:this.pitch,{distanceToCenter:_,clampedElevation:g}=this._distanceToCenterFromAltElevationPitch(l,this.elevation,m),{x:y,y:b}=qe(m,f),T=c.a9.fromLngLat(e,l);let S,P,I=c.a_(1,T.y),C=0;do{if(C+=1,C>10)break;P=_/I,S=new c.a9(T.x+y*P,T.y+b*P),I=1/S.meterInMercatorCoordinateUnits()}while(Math.abs(_-P*I)>1e-12);return{center:S.toLngLat(),elevation:g,zoom:c.at(this.height/2/Math.tan(this.fovInRadians/2)/P/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const l=1/this.worldSize,d=c.as(1,this.center.lat)*this.worldSize,p=c.a9.fromLngLat(this.center,this.elevation),f=p.x/l,m=p.y/l,_=p.z/l,g=this.pitch,y=this.bearing,{x:b,y:T,z:S}=qe(g,y),P=this.cameraToCenterDistance,I=f+P*-b,C=m+P*-T,R=_+P*S,{distanceToCenter:L,clampedElevation:F}=this._distanceToCenterFromAltElevationPitch(R/d,e,g),B=L*d,O=new c.a9((I+b*B)*l,(C+T*B)*l,0).toLngLat(),V=c.as(1,O.lat),j=c.at(this.height/2/Math.tan(this.fovInRadians/2)/L/V/this.tileSize);this._elevation=F,this._center=O,this.setZoom(j)}_distanceToCenterFromAltElevationPitch(e,l,d){const p=-Math.cos(c.ap(d)),f=e-l;let m,_=l;return p*f>=0||Math.abs(p)<.1?(m=1e4,_=e+m*p):m=-f/p,{distanceToCenter:m,clampedElevation:_}}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new c.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=c.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 l=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?(l+=e[d]*this.min[d],c+=e[d]*this.max[d]):(c+=e[d]*this.min[d],l+=e[d]*this.max[d]);return l>=0?2:c<0?0:1}}class qt{distanceToTile2d(e,l,c,d){const p=d.distanceX([e,l]),f=d.distanceY([e,l]);return Math.hypot(p,f)}getWrap(e,l,c){return c}getTileBoundingVolume(e,l,d,p){var f,m;let _=0,g=0;if(null==p?void 0:p.terrain){const y=new c.a2(e.z,l,e.z,e.x,e.y),b=p.terrain.getMinMaxElevation(y);_=null!==(f=b.minElevation)&&void 0!==f?f:Math.min(0,d),g=null!==(m=b.maxElevation)&&void 0!==m?m:Math.max(0,d)}const y=1<p}allowWorldCopies(){return!0}prepareNextFrame(){}}class Wt{constructor(e,l,c){this.points=e,this.planes=l,this.aabb=c}static fromInvProjectionMatrix(e,l=1,d=0,p,f){const m=f?[[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]],_=Math.pow(2,d),g=[[-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((d=>function(e,l,d,p){const f=c.aH([],e,l),m=1/f[3]/d*p;return c.b6(f,f,[m,m,1/f[3],m])}(d,e,l,_)));p&&function(e,l,d,p){const f=p?4:0,m=p?0:4;let _=0;const g=[],y=[];for(let l=0;l<4;l++){const d=c.b2([],e[l+m],e[l+f]),p=c.b7(d);c.a$(d,d,1/p),g.push(p),y.push(d)}for(let l=0;l<4;l++){const p=c.b8(e[l+f],y[l],d);_=null!==p&&p>=0?Math.max(_,p):Math.max(_,g[l])}const b=function(e,l){const d=c.b2([],e[l[0]],e[l[1]]),p=c.b2([],e[l[2]],e[l[1]]),f=[0,0,0,0];return c.b3(f,c.b4([],d,p)),f[3]=-c.b5(f,e[l[0]]),f}(e,l),T=function(e,l){const d=c.b9(e),p=c.ba([],e,1/d),f=c.b2([],l,c.a$([],p,c.b5(l,p))),m=c.b9(f);if(m>0){const e=Math.sqrt(1-p[3]*p[3]),d=c.a$([],p,-p[3]),_=c.b0([],d,c.a$([],f,e/m));return c.bb(l,_)}return null}(d,b);if(null!==T){const e=T/c.b5(y[0],b);_=Math.min(_,e)}for(let l=0;l<4;l++){const c=Math.min(_,g[l]);e[l+m]=[e[l+f][0]+y[l][0]*c,e[l+f][1]+y[l][1]*c,e[l+f][2]+y[l][2]*c,1]}}(g,m[0],p,f);const y=m.map((e=>{const l=c.b2([],g[e[0]],g[e[1]]),d=c.b2([],g[e[2]],g[e[1]]),p=c.b3([],c.b4([],l,d)),f=-c.b5(p,g[e[1]]);return p.concat(f)})),b=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],T=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of g)for(let l=0;l<3;l++)b[l]=Math.min(b[l],e[l]),T[l]=Math.max(T[l],e[l]);return new Wt(g,y,new Vt(b,T))}}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,l,c){return this._helper.interpolatePadding(e,l,c)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,l,c=!0){this._helper.resize(e,l,c)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,l){this._helper.overrideNearFarZ(e,l)}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,l){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,l)=>{l=c.an(+l,this.minZoom,this.maxZoom);const d={center:new c.V(e.lng,e.lat),zoom:l};let p=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===p){const e=180-1e-10;p=[-e,e]}const f=this.tileSize*c.aq(d.zoom);let m=0,_=f,g=0,y=f,b=0,T=0;const{x:S,y:P}=this.size;if(this._helper._latRange){const e=this._helper._latRange;m=c.X(e[1])*f,_=c.X(e[0])*f,_-m_&&(L=_-e)}if(p){const e=(g+y)/2;let l=I;this._helper._renderWorldCopies&&(l=c.W(I,e-f/2,e+f/2));const d=S/2;l-dy&&(R=y-d)}if(void 0!==R||void 0!==L){const e=new c.P(null!=R?R:I,null!=L?L:C);d.center=Ae(f,e).wrap()}return d},this.applyConstrain=(e,l)=>this._helper.applyConstrain(e,l),this._helper=new Gt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,l)=>this.defaultConstrain(e,l)},e),this._coveringTilesDetailsProvider=new qt}clone(){const e=new $t;return e.apply(this,!1),e}apply(e,l,c){this._helper.apply(e,l,c)}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 l=[new c.bc(0,e)];if(this._helper._renderWorldCopies){const d=this.screenPointToMercatorCoordinate(new c.P(0,0)),p=this.screenPointToMercatorCoordinate(new c.P(this._helper._width,0)),f=this.screenPointToMercatorCoordinate(new c.P(this._helper._width,this._helper._height)),m=this.screenPointToMercatorCoordinate(new c.P(0,this._helper._height)),_=Math.floor(Math.min(d.x,p.x,f.x,m.x)),g=Math.floor(Math.max(d.x,p.x,f.x,m.x)),y=1;for(let d=_-y;d<=g+y;d++)0!==d&&l.push(new c.bc(d,e))}return l}getCameraFrustum(){return Wt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const l=this.screenPointToLocation(this.centerPoint,e),c=e?e.getElevationForLngLatZoom(l,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(c)}setLocationAtPoint(e,l){const d=c.as(this.elevation,this.center.lat),p=this.screenPointToMercatorCoordinateAtZ(l,d),f=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,d),m=c.a9.fromLngLat(e),_=new c.a9(m.x-(p.x-f.x),m.y-(p.y-f.y));this.setCenter(null==_?void 0:_.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,l){return l?this.coordinatePoint(c.a9.fromLngLat(e),l.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(c.a9.fromLngLat(e))}screenPointToLocation(e,l){var c;return null===(c=this.screenPointToMercatorCoordinate(e,l))||void 0===c?void 0:c.toLngLat()}screenPointToMercatorCoordinate(e,l){if(l){const c=l.pointCoordinate(e);if(null!=c)return c}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,l){const d=l||0,p=[e.x,e.y,0,1],f=[e.x,e.y,1,1];c.aH(p,p,this._pixelMatrixInverse),c.aH(f,f,this._pixelMatrixInverse);const m=p[3],_=f[3],g=p[1]/m,y=f[1]/_,b=p[2]/m,T=f[2]/_,S=b===T?0:(d-b)/(T-b);return new c.a9(c.G.number(p[0]/m,f[0]/_,S)/this.worldSize,c.G.number(g,y,S)/this.worldSize,d)}coordinatePoint(e,l=0,d=this._pixelMatrix){const p=[e.x*this.worldSize,e.y*this.worldSize,l,1];return c.aH(p,p,d),new c.P(p[0]/p[3],p[1]/p[3])}getBounds(){const e=Math.max(0,this._helper._height/2-Ne(this));return(new $).extend(this.screenPointToLocation(new c.P(0,e))).extend(this.screenPointToLocation(new c.P(this._helper._width,e))).extend(this.screenPointToLocation(new c.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new c.P(0,this._helper._height)))}isPointOnMapSurface(e,l){return l?null!=l.pointCoordinate(e):e.y>this.height/2-Ne(this)}calculatePosMatrix(e,l=!1,d){var p;const f=null!==(p=e.key)&&void 0!==p?p:c.bd(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),m=l?this._alignedPosMatrixCache:this._posMatrixCache;if(m.has(f)){const e=m.get(f);return d?e.f32:e.f64}const _=Ge(e,this.worldSize);c.S(_,l?this._alignedProjMatrix:this._viewProjMatrix,_);const g={f64:_,f32:new Float32Array(_)};return m.set(f,g),d?g.f32:g.f64}calculateFogMatrix(e){const l=e.key,d=this._fogMatrixCacheF32;if(d.has(l))return d.get(l);const p=Ge(e,this.worldSize);return c.S(p,this._fogMatrix,p),d.set(l,new Float32Array(p)),d.get(l)}calculateCenterFromCameraLngLatAlt(e,l,c,d){return this._helper.calculateCenterFromCameraLngLatAlt(e,l,c,d)}_calculateNearFarZIfNeeded(e,l,d){if(!this._helper.autoCalculateNearFarZ)return;const p=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),f=e-p*this._helper._pixelPerMeter/Math.cos(l),m=p<0?f:e,_=Math.PI/2+this.pitchInRadians,g=c.ap(this.fov)*(Math.abs(Math.cos(c.ap(this.roll)))*this.height+Math.abs(Math.sin(c.ap(this.roll)))*this.width)/this.height*(.5+d.y/this.height),y=Math.sin(g)*m/Math.sin(c.an(Math.PI-_-g,.01,Math.PI-.01)),b=Ne(this),T=Math.atan(b/this._helper.cameraToCenterDistance),S=c.ap(.75),P=T>S?2*T*(.5+d.y/(2*b)):S,I=Math.sin(P)*m/Math.sin(c.an(Math.PI-_-P,.01,Math.PI-.01)),C=Math.min(y,I);this._helper._farZ=1.01*(Math.cos(Math.PI/2-l)*C+m),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,l=Ce(this.worldSize,this.center),d=l.x,p=l.y;this._helper._pixelPerMeter=c.as(1,this.center.lat)*this.worldSize;const f=c.ap(Math.min(this.pitch,Ee)),m=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(f));let _;this._calculateNearFarZIfNeeded(m,f,e),_=new Float64Array(16),c.be(_,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),c.aB(this._invProjMatrix,_),_[8]=2*-e.x/this._helper._width,_[9]=2*e.y/this._helper._height,this._projectionMatrix=c.bf(_),c.Q(_,_,[1,-1,1]),c.O(_,_,[0,0,-this._helper.cameraToCenterDistance]),c.bg(_,_,-this.rollInRadians),c.bh(_,_,this.pitchInRadians),c.bg(_,_,-this.bearingInRadians),c.O(_,_,[-d,-p,0]),this._mercatorMatrix=c.Q([],_,[this.worldSize,this.worldSize,this.worldSize]),c.Q(_,_,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=c.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,_),c.O(_,_,[0,0,-this.elevation]),this._viewProjMatrix=_,this._invViewProjMatrix=c.aB([],_);const g=[0,0,-1,1];c.aH(g,g,this._invViewProjMatrix),this._cameraPosition=[g[0]/g[3],g[1]/g[3],g[2]/g[3]],this._fogMatrix=new Float64Array(16),c.be(this._fogMatrix,this.fovInRadians,this.width/this.height,m,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,c.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),c.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),c.bg(this._fogMatrix,this._fogMatrix,-this.rollInRadians),c.bh(this._fogMatrix,this._fogMatrix,this.pitchInRadians),c.bg(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),c.O(this._fogMatrix,this._fogMatrix,[-d,-p,0]),c.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),c.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=c.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,_);const y=this._helper._width%2/2,b=this._helper._height%2/2,T=Math.cos(this.bearingInRadians),S=Math.sin(-this.bearingInRadians),P=d-Math.round(d)+T*y+S*b,I=p-Math.round(p)+T*b+S*y,C=new Float64Array(_);if(c.O(C,C,[P>.5?P-1:P,I>.5?I-1:I,0]),this._alignedProjMatrix=C,_=c.aB(new Float64Array(16),this._pixelMatrix),!_)throw new Error("failed to invert matrix");this._pixelMatrixInverse=_,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new c.P(0,0)),l=[e.x*this.worldSize,e.y*this.worldSize,0,1];return c.aH(l,l,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=c.as(1,this.center.lat)*this.worldSize;return Ue(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,l){const d=c.a9.fromLngLat(e),p=[d.x*this.worldSize,d.y*this.worldSize,l,1];return c.aH(p,p,this._viewProjMatrix),p[2]/p[3]}getProjectionData(e){const{overscaledTileID:l,aligned:d,applyTerrainMatrix:p}=e,f=this._helper.getMercatorTileCoordinates(l),m=l?this.calculatePosMatrix(l,d,!0):null;let _;return _=l&&l.terrainRttPosMatrix32f&&p?l.terrainRttPosMatrix32f:m||c.bi(),{mainMatrix:_,tileMercatorCoords:f,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:_}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,l,c){return 1}transformLightDirection(e){return c.b1(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,l,d,p){const f=this.calculatePosMatrix(d);let m;p?(m=[e,l,p(e,l),1],c.aH(m,m,f)):(m=[e,l,0,1],mi(m,m,f));const _=m[3];return{point:new c.P(m[0]/_,m[1]/_),signedDistanceFromCamera:_,isOccluded:!1}}populateCache(e){for(const l of e)this.calculatePosMatrix(l)}getMatrixForModel(e,l){const d=c.a9.fromLngLat(e,l),p=d.meterInMercatorCoordinateUnits(),f=c.bj();return c.O(f,f,[d.x,d.y,d.z]),c.bg(f,f,Math.PI),c.bh(f,f,Math.PI/2),c.Q(f,f,[-p,p,p]),f}getProjectionDataForCustomLayer(e=!0){const l=new c.a2(0,0,0,0,0),d=this.getProjectionData({overscaledTileID:l,applyGlobeMatrix:e}),p=Ge(l,this.worldSize);c.S(p,this._viewProjMatrix,p),d.tileMercatorCoords=[0,0,1,1];const f=[c.a5,c.a5,this.worldSize/this._helper.pixelsPerMeter],m=c.bk();return c.Q(m,p,f),d.fallbackMatrix=m,d.mainMatrix=m,d}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Wi(){c.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 l=c.bl(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),d=c.bl(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),p=new Float64Array(4);c.bm(p,l,d,e.k);const f=c.bn(p);e.tr.setRoll(f.roll),e.tr.setPitch(f.pitch),e.tr.setBearing(f.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(c.G.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(c.G.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(c.G.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Xi(e,l,d,p,f){const m=f.padding,_=Ce(f.worldSize,d.getNorthWest()),g=Ce(f.worldSize,d.getNorthEast()),y=Ce(f.worldSize,d.getSouthEast()),b=Ce(f.worldSize,d.getSouthWest()),T=c.ap(-p),S=_.rotate(T),P=g.rotate(T),I=y.rotate(T),C=b.rotate(T),R=new c.P(Math.max(S.x,P.x,C.x,I.x),Math.max(S.y,P.y,C.y,I.y)),L=new c.P(Math.min(S.x,P.x,C.x,I.x),Math.min(S.y,P.y,C.y,I.y)),F=R.sub(L),B=(f.width-(m.left+m.right+l.left+l.right))/F.x,O=(f.height-(m.top+m.bottom+l.top+l.bottom))/F.y;if(O<0||B<0)return void Wi();const V=Math.min(c.at(f.scale*Math.min(B,O)),e.maxZoom),j=c.P.convert(e.offset),G=new c.P((l.left-l.right)/2,(l.top-l.bottom)/2).rotate(c.ap(p)),U=j.add(G).mult(f.scale/c.aq(V));return{center:Ae(f.worldSize,_.add(y).div(2).sub(U)),zoom:V,bearing:p}}class Yt{get useGlobeControls(){return!1}handlePanInertia(e,l){const c=e.mag(),d=Math.abs(Ne(l));return{easingOffset:e.mult(Math.min(.75*d/c,1)),easingCenter:l.center}}handleMapControlsRollPitchBearingZoom(e,l){e.bearingDelta&&l.setBearing(l.bearing+e.bearingDelta),e.pitchDelta&&l.setPitch(l.pitch+e.pitchDelta),e.rollDelta&&l.setRoll(l.roll+e.rollDelta),e.zoomDelta&&l.setZoom(l.zoom+e.zoomDelta)}handleMapControlsPan(e,l,c){e.around.distSqr(l.centerPoint)<.01||l.setLocationAtPoint(c,e.around)}cameraForBoxAndBearing(e,l,c,d,p){return Xi(e,l,c,d,p)}handleJumpToCenterZoom(e,l){e.zoom!==(void 0!==l.zoom?+l.zoom:e.zoom)&&e.setZoom(+l.zoom),void 0!==l.center&&e.setCenter(c.V.convert(l.center))}handleEaseTo(e,l){const d=e.zoom,p=e.padding,f={roll:e.roll,pitch:e.pitch,bearing:e.bearing},m={roll:void 0===l.roll?e.roll:l.roll,pitch:void 0===l.pitch?e.pitch:l.pitch,bearing:void 0===l.bearing?e.bearing:l.bearing},_=void 0!==l.zoom,g=!e.isPaddingEqual(l.padding);let y=!1;const b=_?+l.zoom:e.zoom;let T=e.centerPoint.add(l.offsetAsPoint);const S=e.screenPointToLocation(T),{center:P,zoom:I}=e.applyConstrain(c.V.convert(l.center||S),null!=b?b:d);qi(e,P);const C=Ce(e.worldSize,S),R=Ce(e.worldSize,P).sub(C),L=c.aq(I-d);return y=I!==d,{easeFunc:_=>{if(y&&e.setZoom(c.G.number(d,I,_)),c.bo(f,m)||Hi({startEulerAngles:f,endEulerAngles:m,tr:e,k:_,useSlerp:f.roll!=m.roll}),g&&(e.interpolatePadding(p,l.padding,_),T=e.centerPoint.add(l.offsetAsPoint)),l.around)e.setLocationAtPoint(l.around,l.aroundPoint);else{const l=c.aq(e.zoom-d),p=I>d?Math.min(2,L):Math.max(.5,L),f=Math.pow(p,1-_),m=Ae(e.worldSize,C.add(R.mult(_*f)).mult(l));e.setLocationAtPoint(e.renderWorldCopies?m.wrap():m,T)}},isZooming:y,elevationCenter:P}}handleFlyTo(e,l){const d=void 0!==l.zoom,p=e.zoom,f=e.applyConstrain(c.V.convert(l.center||l.locationAtOffset),d?+l.zoom:p),m=f.center,_=f.zoom;qi(e,m);const g=Ce(e.worldSize,l.locationAtOffset),y=Ce(e.worldSize,m).sub(g),b=y.mag(),T=c.aq(_-p);let S;if(void 0!==l.minZoom){const d=Math.min(+l.minZoom,p,_),f=e.applyConstrain(m,d).zoom;S=c.aq(f-p)}return{easeFunc:(l,d,f,b)=>{e.setZoom(1===l?_:p+c.at(d));const T=1===l?m:Ae(e.worldSize,g.add(y.mult(f)).mult(d));e.setLocationAtPoint(e.renderWorldCopies?T.wrap():T,b)},scaleOfZoom:T,targetCenter:m,scaleOfMinZoom:S,pixelPathLength:b}}}class Qt{constructor(e,l,c){this.blendFunction=e,this.blendColor=l,this.mask=c}}Qt.Replace=[1,0],Qt.disabled=new Qt(Qt.Replace,c.bp.transparent,[!1,!1,!1,!1]),Qt.unblended=new Qt(Qt.Replace,c.bp.transparent,[!0,!0,!0,!0]),Qt.alphaBlended=new Qt([1,771],c.bp.transparent,[!0,!0,!0,!0]);const Yi=2305;class ei{constructor(e,l,c){this.enable=e,this.mode=l,this.frontFace=c}}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,l,c){this.func=e,this.mask=l,this.range=c}}ti.ReadOnly=!1,ti.ReadWrite=!0,ti.disabled=new ti(519,ti.ReadOnly,[0,1]);const Ki=7680;class ai{constructor(e,l,c,d,p,f){this.test=e,this.ref=l,this.mask=c,this.fail=d,this.depthFail=p,this.pass=f}}ai.disabled=new ai({func:519,mask:0},0,0,Ki,Ki,Ki);const Qi=new WeakMap;function Ji(e){var l;if(Qi.has(e))return Qi.get(e);{const c=null===(l=e.getParameter(e.VERSION))||void 0===l?void 0:l.startsWith("WebGL 2.0");return Qi.set(e,c),c}}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 l=e.context,d=l.gl;this._texFormat=d.RGBA,this._texType=d.UNSIGNED_BYTE;const p=new c.aW;p.emplaceBack(-1,-1),p.emplaceBack(2,-1),p.emplaceBack(-1,2);const f=new c.aY;f.emplaceBack(0,1,2),this._fullscreenTriangle=new kt(l.createVertexBuffer(p,Ni.members),l.createIndexBuffer(f),c.aX.simpleSegment(0,0,p.length,f.length)),this._resultBuffer=new Uint8Array(4),l.activeTexture.set(d.TEXTURE1);const m=d.createTexture();d.bindTexture(d.TEXTURE_2D,m),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.NEAREST),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.NEAREST),d.texImage2D(d.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=l.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(m),Ji(d)&&(this._pbo=d.createBuffer(),d.bindBuffer(d.PIXEL_PACK_BUFFER,this._pbo),d.bufferData(d.PIXEL_PACK_BUFFER,4,d.STREAM_READ),d.bindBuffer(d.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,l){const c=this._updateCount;return this._readbackQueue?c>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():c>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,l),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,l=e.gl;e.activeTexture.set(l.TEXTURE1),l.bindTexture(l.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,l){const d=this._cachedRenderContext.context,p=d.gl;if(this._bindFramebuffer(),d.viewport.set([0,0,this._texWidth,this._texHeight]),d.clear({color:c.bp.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(d,p.TRIANGLES,ti.disabled,ai.disabled,Qt.unblended,ei.disabled,((e,l)=>({u_input:e,u_output_expected:l}))(e,l),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Ji(p)){p.bindBuffer(p.PIXEL_PACK_BUFFER,this._pbo),p.readBuffer(p.COLOR_ATTACHMENT0),p.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),p.bindBuffer(p.PIXEL_PACK_BUFFER,null);const e=p.fenceSync(p.SYNC_GPU_COMMANDS_COMPLETE,0);p.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 l=e.clientWaitSync(this._readbackQueue.sync,0,0);if(l===e.WAIT_FAILED)return c.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(l===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 l=0;return l+=e[0]/256,l+=e[1]/65536,l+=e[2]/16777216,e[3]<127&&(l=-l),l/128}}const ar=c.a5/128;function ur(e,l){const d=void 0!==e.granularity?Math.max(e.granularity,1):1,p=d+(e.generateBorders?2:0),f=d+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),m=p+1,_=f+1,g=e.generateBorders?-1:0,y=e.generateBorders||e.extendToNorthPole?-1:0,b=d+(e.generateBorders?1:0),T=d+(e.generateBorders||e.extendToSouthPole?1:0),S=m*_,P=p*f*6,I=m*_>65536;if(I&&"16bit"===l)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const C=I||"32bit"===l,R=new Int16Array(2*S);let L=0;for(let l=y;l<=T;l++)for(let p=g;p<=b;p++){let f=p/d*c.a5;-1===p&&(f=-ar),p===d+1&&(f=c.a5+ar);let m=l/d*c.a5;-1===l&&(m=e.extendToNorthPole?c.br:-ar),l===d+1&&(m=e.extendToSouthPole?c.bs:c.a5+ar),R[L++]=f,R[L++]=m}const F=C?new Uint32Array(P):new Uint16Array(P);let B=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,l,c,d,p){return this.currentProjection.getMeshFromTileID(e,l,c,d,p)}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 wr(e){const l=zr(e.worldSize,e.center.lat);return 2*Math.PI*l}function Cr(e,l,d,p,f){const m=1/(1<1e-6){const p=e[0]/d,f=Math.acos(e[2]/d),m=(p>0?f:-f)/Math.PI*180;return new c.V(c.W(m,-180,180),l)}return new c.V(0,l)}function Lr(e){return Math.cos(e*Math.PI/180)}function qr(e,l){const d=Lr(e),p=Lr(l);return c.at(p/d)}function $r(e,l){const d=e.rotate(l.bearingInRadians),p=l.zoom+qr(l.center.lat,0),f=c.bu(1/Lr(l.center.lat),1/Lr(Math.min(Math.abs(l.center.lat),60)),c.bx(p,7,3,0,1)),m=360/wr({worldSize:l.worldSize,center:{lat:l.center.lat}});return new c.V(l.center.lng-d.x*m*f,c.an(l.center.lat+d.y*m,-c.ao,c.ao))}function Kr(e){const l=.5*e,c=Math.sin(l),d=Math.cos(l);return Math.log(c+d)-Math.log(d-c)}function en(e,l,d,p){const f=e.lat+d*p;if(Math.abs(d)>1){const m=(Math.sign(e.lat+d)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,_=Math.abs(e.lat+d)*Math.PI/180,g=Kr(m+p*(_-m)),y=Kr(m),b=Kr(_);return new c.V(e.lng+l*((g-y)/(b-y)),f)}return new c.V(e.lng+l*p,f)}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,l,c,d){const p=`${e.z}_${e.x}_${e.y}_${(null==d?void 0:d.terrain)?"t":""}`,f=this._cache.get(p);if(f)return f;const m=this._cachePrevious.get(p);if(m)return this._cache.set(p,m),m;const _=this._boundingVolumeFactory(e,l,c,d);return this._cache.set(p,_),this._hadAnyChanges=!0,_}}class Pi{constructor(e,l,c,d){this.min=c,this.max=d,this.points=e,this.planes=l}static fromAabb(e,l){const c=[];for(let d=0;d<8;d++)c.push([1&~d?e[0]:l[0],1==(d>>1&1)?l[1]:e[1],1==(d>>2&1)?l[2]:e[2]]);return new Pi(c,[[-1,0,0,l[0]],[1,0,0,-e[0]],[0,-1,0,l[1]],[0,1,0,-e[1]],[0,0,-1,l[2]],[0,0,1,-e[2]]],e,l)}static fromCenterSizeAngles(e,l,d){const p=c.bB([],d[0],d[1],d[2]),f=c.bC([],[l[0],0,0],p),m=c.bC([],[0,l[1],0],p),_=c.bC([],[0,0,l[2]],p),g=[...e],y=[...e];for(let l=0;l<8;l++)for(let c=0;c<3;c++){const d=e[c]+f[c]*(1&~l?-1:1)+m[c]*(1==(l>>1&1)?1:-1)+_[c]*(1==(l>>2&1)?1:-1);g[c]=Math.min(g[c],d),y[c]=Math.max(y[c],d)}const b=[];for(let l=0;l<8;l++){const d=[...e];c.b0(d,d,c.a$([],f,1&~l?-1:1)),c.b0(d,d,c.a$([],m,1==(l>>1&1)?1:-1)),c.b0(d,d,c.a$([],_,1==(l>>2&1)?1:-1)),b.push(d)}return new Pi(b,[[...f,-c.b5(f,b[0])],[...m,-c.b5(m,b[0])],[..._,-c.b5(_,b[0])],[-f[0],-f[1],-f[2],-c.b5(f,b[7])],[-m[0],-m[1],-m[2],-c.b5(m,b[7])],[-_[0],-_[1],-_[2],-c.b5(_,b[7])]],g,y)}intersectsFrustum(e){let l=!0;const c=this.points.length,d=this.planes.length,p=e.planes.length,f=e.points.length;for(let d=0;d=0&&f++}if(0===f)return 0;f=0&&d++}if(0===d)return 0}return 1}intersectsPlane(e){const l=this.points.length;let c=0;for(let d=0;d=0&&c++}return c===l?2:0===c?0:1}}function tn(e,l,c){const d=e-l;return d<0?-d:Math.max(0,d-c)}function rn(e,l,c,d,p){const f=e-c;let m;return m=f<0?Math.min(-f,1+f-p):f>1?Math.min(Math.max(f-p,0),1-f):0,Math.max(m,tn(l,d,p))}class Mi{constructor(){this._boundingVolumeCache=new Ti(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,l,c,d){const p=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,l,c,d){return this._boundingVolumeCache.getTileBoundingVolume(e,l,c,d)}_computeTileBoundingVolume(e,l,d,p){var f,m;let _=0,g=0;if(null==p?void 0:p.terrain){const y=new c.a2(e.z,l,e.z,e.x,e.y),b=p.terrain.getMinMaxElevation(y);_=null!==(f=b.minElevation)&&void 0!==f?f:Math.min(0,d),g=null!==(m=b.maxElevation)&&void 0!==m?m:Math.max(0,d)}if(_/=c.bE,g/=c.bE,_+=1,g+=1,e.z<=0)return Pi.fromAabb([-g,-g,-g],[g,g,g]);if(1===e.z)return Pi.fromAabb([0===e.x?-g:0,0===e.y?0:-g,-g],[0===e.x?0:g,0===e.y?g:0,g]);{const l=[Cr(0,0,e.x,e.y,e.z),Cr(c.a5,0,e.x,e.y,e.z),Cr(c.a5,c.a5,e.x,e.y,e.z),Cr(0,c.a5,e.x,e.y,e.z)],d=[];for(const e of l)d.push(c.a$([],e,g));if(g!==_)for(const e of l)d.push(c.a$([],e,_));0===e.y&&d.push([0,1,0]),e.y===(1<=(1<{const d=c.an(e.lat,-c.ao,c.ao),p=c.an(+l,this.minZoom+qr(0,d),this.maxZoom);return{center:new c.V(e.lng,d),zoom:p}},this.applyConstrain=(e,l)=>this._helper.applyConstrain(e,l),this._helper=new Gt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,l)=>this.defaultConstrain(e,l)},e),this._coveringTilesDetailsProvider=new Mi}clone(){const e=new Si;return e.apply(this,!1),e}apply(e,l,c){this._globeLatitudeErrorCorrectionRadians=c||0,this._helper.apply(e,l)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=c.bA();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:l,applyGlobeMatrix:c}=e,d=this._helper.getMercatorTileCoordinates(l);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:d,clippingPlane:this._cachedClippingPlane,projectionTransition:c?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const l=this.pitchInRadians,d=this.cameraToCenterDistance/e,p=Math.sin(l)*d,f=Math.cos(l)*d+1,m=1/Math.sqrt(p*p+f*f)*1;let _=-p,g=f;const y=Math.sqrt(_*_+g*g);_/=y,g/=y;const b=[0,_,g];c.bG(b,b,[0,0,0],-this.bearingInRadians),c.bH(b,b,[0,0,0],-1*this.center.lat*Math.PI/180),c.bI(b,b,[0,0,0],this.center.lng*Math.PI/180);const T=1/c.b7(b);return c.a$(b,b,T),[...b,-m*T]}isLocationOccluded(e){return!this.isSurfacePointVisible(Dr(e))}transformLightDirection(e){const l=this._helper._center.lng*Math.PI/180,d=this._helper._center.lat*Math.PI/180,p=Math.cos(d),f=[Math.sin(l)*p,Math.sin(d),Math.cos(l)*p],m=[f[2],0,-f[0]],_=[0,0,0];c.b4(_,m,f),c.b3(m,m),c.b3(_,_);const g=[0,0,0];return c.b3(g,[m[0]*e[0]+_[0]*e[1]+f[0]*e[2],m[1]*e[0]+_[1]*e[1]+f[1]*e[2],m[2]*e[0]+_[2]*e[1]+f[2]*e[2]]),g}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,l,d){const p=function(e,l,d){const p=1/(1<f&&(f=l),d_&&(_=d)}const b=[y.lng+m,y.lat+g,y.lng+f,y.lat+_];return this.isSurfacePointOnScreen([0,1,0])&&(b[3]=90,b[0]=-180,b[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(b[1]=-90,b[0]=-180,b[2]=180),new $(b)}calculateCenterFromCameraLngLatAlt(e,l,c,d){return this._helper.calculateCenterFromCameraLngLatAlt(e,l,c,d)}setLocationAtPoint(e,l){const d=Dr(this.unprojectScreenPoint(l)),p=Dr(e),f=c.bA();c.bL(f);const m=c.bA();c.bI(m,d,f,-this.center.lng*Math.PI/180),c.bH(m,m,f,this.center.lat*Math.PI/180);const _=p[0]*p[0]+p[2]*p[2],g=m[0]*m[0];if(_=-L&&I<=L,B=R>=-L&&R<=L;let O,V;if(F&&B){const e=this.center.lng*Math.PI/180,l=this.center.lat*Math.PI/180;c.bN(T,e)+c.bN(I,l)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const l=c.bF();return c.aH(l,[...e,1],this._globeViewProjMatrixNoCorrection),l[0]/=l[3],l[1]/=l[3],l[2]/=l[3],l[0]>-1&&l[0]<1&&l[1]>-1&&l[1]<1&&l[2]>-1&&l[2]<1}rayPlanetIntersection(e,l){const d=c.b5(e,l),p=c.bA(),f=c.bA();c.a$(f,l,d),c.b2(p,e,f);const m=1-c.b5(p,p);if(m<0)return null;const _=c.b5(e,e)-1,g=-d+(d<0?1:-1)*Math.sqrt(m),y=_/g,b=g;return{tMin:Math.min(y,b),tMax:Math.max(y,b)}}unprojectScreenPoint(e){const l=this._cameraPosition,d=this.getRayDirectionFromPixel(e),p=this.rayPlanetIntersection(l,d);if(p){const e=c.bA();c.b0(e,l,[d[0]*p.tMin,d[1]*p.tMin,d[2]*p.tMin]);const f=c.bA();return c.b3(f,e),kr(f)}const f=this._cachedClippingPlane,m=f[0]*d[0]+f[1]*d[1]+f[2]*d[2],_=-c.bb(f,l)/m,g=c.bA();if(_>0)c.b0(g,l,[d[0]*_,d[1]*_,d[2]*_]);else{const e=c.bA();c.b0(e,l,[2*d[0],2*d[1],2*d[2]]);const p=c.bb(this._cachedClippingPlane,e);c.b2(g,e,[this._cachedClippingPlane[0]*p,this._cachedClippingPlane[1]*p,this._cachedClippingPlane[2]*p])}const y=function(e){const l=c.bA();return l[0]=e[0]*-e[3],l[1]=e[1]*-e[3],l[2]=e[2]*-e[3],{center:l,radius:Math.sqrt(1-e[3]*e[3])}}(f);return kr(function(e,l,d){const p=c.bA();c.b2(p,d,e);const f=c.bA();return c.by(f,e,p,l/c.b9(p)),f}(y.center,y.radius,g))}getMatrixForModel(e,l){const d=c.V.convert(e),p=1/c.bE,f=c.bj();return c.bJ(f,f,d.lng/180*Math.PI),c.bh(f,f,-d.lat/180*Math.PI),c.O(f,f,[0,0,1+l/c.bE]),c.bh(f,f,.5*Math.PI),c.Q(f,f,[p,p,p]),f}getProjectionDataForCustomLayer(e=!0){const l=this.getProjectionData({overscaledTileID:new c.a2(0,0,0,0,0),applyGlobeMatrix:e});return l.tileMercatorCoords=[0,0,1,1],l}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,l,c){return this._helper.interpolatePadding(e,l,c)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,l,c=!0){this._helper.resize(e,l,c)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,l){this._helper.overrideNearFarZ(e,l)}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,l){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=l,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,l)=>this.currentTransform.defaultConstrain(e,l),this.applyConstrain=(e,l)=>this._helper.applyConstrain(e,l),this._helper=new Gt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,l)=>this.defaultConstrain(e,l)},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,l){this._helper.apply(e,l),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 l=this._mercatorTransform.getProjectionData(e),c=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?c.mainMatrix:l.mainMatrix,clippingPlane:c.clippingPlane,tileMercatorCoords:c.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:l.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return c.bu(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return c.bu(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,l,d){const p=this._mercatorTransform.getPitchedTextCorrection(e,l,d),f=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,l,d);return c.bu(p,f,this._globeness)}projectTileCoordinates(e,l,c,d){return this.currentTransform.projectTileCoordinates(e,l,c,d)}_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,l){return this.currentTransform.lngLatToCameraDepth(e,l)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,l,c,d){return this._helper.calculateCenterFromCameraLngLatAlt(e,l,c,d)}setLocationAtPoint(e,l){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,l),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,l),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,l){return this.currentTransform.locationToScreenPoint(e,l)}screenPointToMercatorCoordinate(e,l){return this.currentTransform.screenPointToMercatorCoordinate(e,l)}screenPointToLocation(e,l){return this.currentTransform.screenPointToLocation(e,l)}isPointOnMapSurface(e,l){return this.currentTransform.isPointOnMapSurface(e,l)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,l){return this.currentTransform.getMatrixForModel(e,l)}getProjectionDataForCustomLayer(e=!0){const l=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return l;const c=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return c.fallbackMatrix=l.mainMatrix,c}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Ri{get useGlobeControls(){return!0}handlePanInertia(e,l){const d=$r(e,l);return Math.abs(d.lng-l.center.lng)>180&&(d.lng=l.center.lng+179.5*Math.sign(d.lng-l.center.lng)),{easingCenter:d,easingOffset:new c.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,l){const d=e.around,p=l.screenPointToLocation(d);e.bearingDelta&&l.setBearing(l.bearing+e.bearingDelta),e.pitchDelta&&l.setPitch(l.pitch+e.pitchDelta),e.rollDelta&&l.setRoll(l.roll+e.rollDelta);const f=l.zoom;e.zoomDelta&&l.setZoom(l.zoom+e.zoomDelta);const m=l.zoom-f;if(0===m)return;const _=c.bK(l.center.lng,p.lng),g=_/(Math.abs(_/180)+1),y=c.bK(l.center.lat,p.lat),b=l.getRayDirectionFromPixel(d),T=l.cameraPosition,S=-1*c.b5(T,b),P=c.bA();c.b0(P,T,[b[0]*S,b[1]*S,b[2]*S]);const I=c.b7(P)-1,C=Math.exp(.5*-Math.max(I-.3,0)),R=zr(l.worldSize,l.center.lat)/Math.min(l.width,l.height),L=c.bx(R,.9,.5,1,.25),F=(1-c.aq(-m))*Math.min(C,L),B=l.center.lat,O=l.zoom,V=new c.V(l.center.lng+g*F,c.an(l.center.lat+y*F,-c.ao,c.ao));l.setLocationAtPoint(p,d);const j=l.center,G=c.bx(Math.abs(_),45,85,0,1),U=c.bx(R,.75,.35,0,1),q=Math.pow(Math.max(G,U),.25),Z=c.bK(j.lng,V.lng),W=c.bK(j.lat,V.lat);l.setCenter(new c.V(j.lng+Z*q,j.lat+W*q).wrap()),l.setZoom(O+qr(B,l.center.lat))}handleMapControlsPan(e,l,c){if(!e.panDelta)return;const d=l.center.lat,p=l.zoom;l.setCenter($r(e.panDelta,l).wrap()),l.setZoom(p+qr(d,l.center.lat))}cameraForBoxAndBearing(e,l,d,p,f){const m=Xi(e,l,d,p,f),_=l.left/f.width*2-1,g=(f.width-l.right)/f.width*2-1,y=l.top/f.height*-2+1,b=(f.height-l.bottom)/f.height*-2+1,T=c.bK(d.getWest(),d.getEast())<0,S=T?d.getEast():d.getWest(),P=T?d.getWest():d.getEast(),I=Math.max(d.getNorth(),d.getSouth()),C=Math.min(d.getNorth(),d.getSouth()),R=S+.5*c.bK(S,P),L=I+.5*c.bK(I,C),F=f.clone();F.setCenter(m.center),F.setBearing(m.bearing),F.setPitch(0),F.setRoll(0),F.setZoom(m.zoom);const B=F.modelViewProjectionMatrix,O=[Dr(d.getNorthWest()),Dr(d.getNorthEast()),Dr(d.getSouthWest()),Dr(d.getSouthEast()),Dr(new c.V(P,L)),Dr(new c.V(S,L)),Dr(new c.V(R,I)),Dr(new c.V(R,C))],V=Dr(m.center);let j=Number.POSITIVE_INFINITY;for(const e of O)_<0&&(j=Ri.getLesserNonNegativeNonNull(j,Ri.solveVectorScale(e,V,B,"x",_))),g>0&&(j=Ri.getLesserNonNegativeNonNull(j,Ri.solveVectorScale(e,V,B,"x",g))),y>0&&(j=Ri.getLesserNonNegativeNonNull(j,Ri.solveVectorScale(e,V,B,"y",y))),b<0&&(j=Ri.getLesserNonNegativeNonNull(j,Ri.solveVectorScale(e,V,B,"y",b)));if(Number.isFinite(j)&&0!==j)return m.zoom=F.zoom+c.at(j),m;Wi()}handleJumpToCenterZoom(e,l){const d=e.center.lat,p=e.applyConstrain(l.center?c.V.convert(l.center):e.center,e.zoom).center;e.setCenter(p.wrap());const f=void 0!==l.zoom?+l.zoom:e.zoom+qr(d,p.lat);e.zoom!==f&&e.setZoom(f)}handleEaseTo(e,l){const d=e.zoom,p=e.center,f=e.padding,m={roll:e.roll,pitch:e.pitch,bearing:e.bearing},_={roll:void 0===l.roll?e.roll:l.roll,pitch:void 0===l.pitch?e.pitch:l.pitch,bearing:void 0===l.bearing?e.bearing:l.bearing},g=void 0!==l.zoom,y=!e.isPaddingEqual(l.padding);let b=!1;const T=l.center?c.V.convert(l.center):p,S=e.applyConstrain(T,d).center;qi(e,S);const P=e.clone();P.setCenter(S),P.setZoom(g?+l.zoom:d+qr(p.lat,T.lat)),P.setBearing(l.bearing);const I=new c.P(c.an(e.centerPoint.x+l.offsetAsPoint.x,0,e.width),c.an(e.centerPoint.y+l.offsetAsPoint.y,0,e.height));P.setLocationAtPoint(S,I);const C=(l.offset&&l.offsetAsPoint.mag())>0?P.center:S,R=g?+l.zoom:d+qr(p.lat,C.lat),L=d+qr(p.lat,0),F=R+qr(C.lat,0),B=c.bK(p.lng,C.lng),O=c.bK(p.lat,C.lat),V=c.aq(F-L);return b=R!==d,{easeFunc:d=>{if(c.bo(m,_)||Hi({startEulerAngles:m,endEulerAngles:_,tr:e,k:d,useSlerp:m.roll!=_.roll}),y&&e.interpolatePadding(f,l.padding,d),l.around)c.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(l.around,l.aroundPoint);else{const l=F>L?Math.min(2,V):Math.max(.5,V),c=Math.pow(l,1-d),f=en(p,B,O,d*c);e.setCenter(f.wrap())}if(b){const l=c.G.number(L,F,d)+qr(0,e.center.lat);e.setZoom(l)}},isZooming:b,elevationCenter:C}}handleFlyTo(e,l){const d=void 0!==l.zoom,p=e.center,f=e.zoom,m=e.padding,_=!e.isPaddingEqual(l.padding),g=e.applyConstrain(c.V.convert(l.center||l.locationAtOffset),f).center,y=d?+l.zoom:e.zoom+qr(e.center.lat,g.lat),b=e.clone();b.setCenter(g),b.setZoom(y),b.setBearing(l.bearing);const T=new c.P(c.an(e.centerPoint.x+l.offsetAsPoint.x,0,e.width),c.an(e.centerPoint.y+l.offsetAsPoint.y,0,e.height));b.setLocationAtPoint(g,T);const S=b.center;qi(e,S);const P=function(e,l,d){const p=Dr(l),f=Dr(d),m=c.b5(p,f),_=Math.acos(m),g=wr(e);return _/(2*Math.PI)*g}(e,p,S),I=f+qr(p.lat,0),C=y+qr(S.lat,0),R=c.aq(C-I);let L;if("number"==typeof l.minZoom){const d=+l.minZoom+qr(S.lat,0),p=Math.min(d,I,C)+qr(0,S.lat),f=e.applyConstrain(S,p).zoom+qr(S.lat,0);L=c.aq(f-I)}const F=c.bK(p.lng,S.lng),B=c.bK(p.lat,S.lat);return{easeFunc:(d,f,g,b)=>{const T=en(p,F,B,g);_&&e.interpolatePadding(m,l.padding,d);const P=1===d?S:T;e.setCenter(P.wrap());const C=I+c.at(f);e.setZoom(1===d?y:C+qr(0,P.lat))},scaleOfZoom:R,targetCenter:S,scaleOfMinZoom:L,pixelPathLength:P}}static solveVectorScale(e,l,c,d,p){const f="x"===d?[c[0],c[4],c[8],c[12]]:[c[1],c[5],c[9],c[13]],m=[c[3],c[7],c[11],c[15]],_=e[0]*f[0]+e[1]*f[1]+e[2]*f[2],g=e[0]*m[0]+e[1]*m[1]+e[2]*m[2],y=l[0]*f[0]+l[1]*f[1]+l[2]*f[2],b=l[0]*m[0]+l[1]*m[1]+l[2]*m[2];return y+p*g===_+p*b||m[3]*(_-y)+f[3]*(b-g)+_*b==y*g?null:(y+f[3]-p*b-p*m[3])/(y-_-p*b+p*g)}static getLesserNonNegativeNonNull(e,l){return null!==l&&l>=0&&lc.B(e,l&&l.filter((e=>"source.canvas"!==e.identifier))),an=c.bO();class ki extends c.E{constructor(e,l={}){var d,p;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const l=this.tileManagers[e].getSource().type;"vector"!==l&&"geojson"!==l||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new N(oe(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,l)=>this.getGlyphs(e,l))),this.dispatcher.registerMessageHandler("GI",((e,l)=>this.getImages(e,l))),this.dispatcher.registerMessageHandler("GDA",((e,l)=>this.getDashes(e,l))),this.imageManager=new w,this.imageManager.setEventedParent(this);const f=(null===(d=e._container)||void 0===d?void 0:d.lang)||"undefined"!=typeof document&&(null===(p=document.documentElement)||void 0===p?void 0:p.lang)||void 0;this.glyphManager=new M(e._requestManager,l.localIdeographFontFamily,f),this.lineAtlas=new A(256,512),this.crossTileSymbolIndex=new Rt,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",c.bP()),we().on(ve,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const l=this.tileManagers[e.sourceId];if(!l)return;const c=l.getSource();if(c&&c.vectorLayerIds)for(const e in this._layers){const l=this._layers[e];l.source===c.id&&this._validateLayer(l)}}))}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new c.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,l){var d,p,f;this._checkLoaded();const m=null===l?null!==(f=null===(p=null===(d=this.stylesheet.state)||void 0===d?void 0:d[e])||void 0===p?void 0:p.default)&&void 0!==f?f:null:l;if(c.bR(m,this._globalState[e]))return this;this._globalState[e]=m,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const l=[];for(const d in e)!c.bR(this._globalState[d],e[d].default)&&(l.push(d),this._globalState[d]=e[d].default);this._applyGlobalStateChanges(l)}_applyGlobalStateChanges(e){if(0===e.length)return;const l=new Set,c={};for(const d of e){c[d]=this._globalState[d];for(const e in this._layers){const c=this._layers[e],p=c.getLayoutAffectingGlobalStateRefs(),f=c.getPaintAffectingGlobalStateRefs(),m=c.getVisibilityAffectingGlobalStateRefs();if(p.has(d)&&l.add(c.source),f.has(d))for(const{name:e,value:l}of f.get(d))this._updatePaintProperty(c,e,l);(null==m?void 0:m.has(d))&&(c.recalculateVisibility(),this._updateLayer(c))}}this.dispatcher.broadcast("UGS",c);for(const e in this.tileManagers)l.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,l={},d){this.fire(new c.l("dataloading",{dataType:"style"})),l.validate="boolean"!=typeof l.validate||l.validate;const p=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const f=this._loadStyleRequest;c.j(p,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,l,d)})).catch((e=>{this._loadStyleRequest=null,e&&!f.signal.aborted&&this.fire(new c.k(e))}))}loadJSON(e,l={},d){this.fire(new c.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,g.frameAsync(this._frameRequest,this.map._ownerWindow).then((()=>{this._frameRequest=null,l.validate=!1!==l.validate,this._load(e,l,d)})).catch((()=>{}))}loadEmpty(){this.fire(new c.l("dataloading",{dataType:"style"})),this._load(an,{validate:!1})}_load(e,l,d){var p,f;let m=l.transformStyle?l.transformStyle(d,e):e;if(!l.validate||!sn(this,c.C(m))){m=Object.assign({},m),this._loaded=!0,this.stylesheet=m;for(const e in m.sources)this.addSource(e,m.sources[e],{validate:!1});m.sprite?this._loadSprite(m.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(m.glyphs),this._createLayers(),this.light=new z(this.stylesheet.light),this._setProjectionInternal((null===(p=this.stylesheet.projection)||void 0===p?void 0:p.type)||"mercator"),this.sky=new D(this.stylesheet.sky),this.map.setTerrain(null!==(f=this.stylesheet.terrain)&&void 0!==f?f:null),this.fire(new c.l("data",{dataType:"style"})),this.fire(new c.l("style.load"))}}_createLayers(){var e,l,d;const p=c.bS(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",p),this._order=p.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const e of p){const p=c.bT(e,this._globalState);if(p.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=p,c.bU(p)&&this.tileManagers[p.source]){const c=null!==(d=null===(l=e.paint)||void 0===l?void 0:l["raster-fade-duration"])&&void 0!==d?d:p.paint.get("raster-fade-duration");this.tileManagers[p.source].setRasterFadeDuration(c)}}}_loadSprite(e,l=!1,d=void 0){this.imageManager.setLoaded(!1);const p=new AbortController;let f;this._spriteRequest=p,function(e,l,d,p){return c._(this,void 0,void 0,(function*(){const f=F(e),m=d>1?"@2x":"",_={},y={};for(const{id:e,url:d}of f){const f=l.transformRequest(B(d,m,".json"),"SpriteJSON");_[e]=c.j(f,p);const g=l.transformRequest(B(d,m,".png"),"SpriteImage");y[e]=L.getImage(g,p)}return yield Promise.all([...Object.values(_),...Object.values(y)]),function(e,l){return c._(this,void 0,void 0,(function*(){const c={};for(const d in e){c[d]={};const p=g.getImageCanvasContext((yield l[d]).data),f=(yield e[d]).data;for(const e in f){const{width:l,height:m,x:_,y:g,sdf:y,pixelRatio:b,stretchX:T,stretchY:S,content:P,textFitWidth:I,textFitHeight:C}=f[e];c[d][e]={data:null,pixelRatio:b,sdf:y,stretchX:T,stretchY:S,content:P,textFitWidth:I,textFitHeight:C,spriteData:{width:l,height:m,x:_,y:g,context:p}}}}return c}))}(_,y)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const c in e){this._spritesImagesIds[c]=[];const d=this._spritesImagesIds[c]?this._spritesImagesIds[c].filter((l=>!(l in e))):[];for(const e of d)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const d in e[c]){const p="default"===c?d:`${c}:${d}`;this._spritesImagesIds[c].push(p),p in this.imageManager.images?this.imageManager.updateImage(p,e[c][d],!1):this.imageManager.addImage(p,e[c][d]),l&&(this._changedImages[p]=!0)}}})).catch((e=>{this._spriteRequest=null,f=e,p.signal.aborted||this.fire(new c.k(f))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),l&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"})),d&&d(f)}))}_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 c.l("data",{dataType:"style"}))}_validateLayer(e){const l=this.tileManagers[e.source];if(!l)return;const d=e.sourceLayer;if(!d)return;const p=l.getSource();("geojson"===p.type||p.vectorLayerIds&&-1===p.vectorLayerIds.indexOf(d))&&this.fire(new c.k(new Error(`Source layer "${d}" does not exist on source "${p.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,l=!1){const d=this._serializedAllLayers();if(!e||0===e.length)return Object.values(l?c.bV(d):d);const p=[];for(const f of e)if(d[f]){const e=l?c.bV(d[f]):d[f];p.push(e)}return p}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const l=Object.keys(this._layers);for(const c of l){const l=this._layers[c];"custom"!==l.type&&(e[c]=l.serialize())}return e}hasTransitions(){var e,l,c;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(l=this.sky)||void 0===l?void 0:l.hasTransition())return!0;if(null===(c=this.projection)||void 0===c?void 0:c.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 l=this._changed;if(l){const l=Object.keys(this._updatedLayers),c=Object.keys(this._removedLayers);(l.length||c.length)&&this._updateWorkerLayers(l,c);for(const e in this._updatedSources){const l=this._updatedSources[e];if("reload"===l)this._reloadSource(e);else{if("clear"!==l)throw new Error(`Invalid action ${l}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const l in this._updatedPaintProps)this._layers[l].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const d={};for(const e in this.tileManagers){const l=this.tileManagers[e];d[e]=l.used,l.used=!1}for(const l of this._order){const c=this._layers[l];c.recalculate(e,this._availableImages),!c.isHidden(e.zoom)&&c.source&&(this.tileManagers[c.source].used=!0)}for(const e in d){const l=this.tileManagers[e];!!d[e]!=!!l.used&&l.fire(new c.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,l&&this.fire(new c.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const l in this.tileManagers)this.tileManagers[l].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,l){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:l})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,l={}){var d;this._checkLoaded();const p=this.serialize();if(e=l.transformStyle?l.transformStyle(p,e):e,(null===(d=l.validate)||void 0===d||d)&&sn(this,c.C(e)))return!1;(e=c.bV(e)).layers=c.bS(e.layers);const f=c.bW(p,e),m=this._getOperationsToPerform(f);if(m.unimplemented.length>0)throw new Error(`Unimplemented: ${m.unimplemented.join(", ")}.`);if(0===m.operations.length)return!1;for(const e of m.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new c.l("style.load",{style:this})),!0}_getOperationsToPerform(e){const l=[],c=[];for(const d of e)switch(d.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":l.push((()=>this.addLayer.apply(this,d.args)));break;case"removeLayer":l.push((()=>this.removeLayer.apply(this,d.args)));break;case"setPaintProperty":l.push((()=>this.setPaintProperty.apply(this,d.args)));break;case"setLayoutProperty":l.push((()=>this.setLayoutProperty.apply(this,d.args)));break;case"setFilter":l.push((()=>this.setFilter.apply(this,d.args)));break;case"addSource":l.push((()=>this.addSource.apply(this,d.args)));break;case"removeSource":l.push((()=>this.removeSource.apply(this,d.args)));break;case"setLayerZoomRange":l.push((()=>this.setLayerZoomRange.apply(this,d.args)));break;case"setLight":l.push((()=>this.setLight.apply(this,d.args)));break;case"setGeoJSONSourceData":l.push((()=>this.setGeoJSONSourceData.apply(this,d.args)));break;case"setGlyphs":l.push((()=>this.setGlyphs.apply(this,d.args)));break;case"setSprite":l.push((()=>this.setSprite.apply(this,d.args)));break;case"setTerrain":l.push((()=>this.map.setTerrain.apply(this,d.args)));break;case"setSky":l.push((()=>this.setSky.apply(this,d.args)));break;case"setProjection":this.setProjection.apply(this,d.args);break;case"setGlobalState":l.push((()=>this.setGlobalState.apply(this,d.args)));break;case"setTransition":l.push((()=>{}));break;default:c.push(d.command)}return{operations:l,unimplemented:c}}addImage(e,l){if(this.getImage(e))return this.fire(new c.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,l),this._afterImageUpdated(e)}updateImage(e,l){this.imageManager.updateImage(e,l)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new c.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 c.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,l,d={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!l.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(l).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(l.type)>=0&&this._validate(c.C.source,`sources.${e}`,l,null,d))return;this.map&&this.map._collectResourceTiming&&(l.collectResourceTiming=!0);const p=this.tileManagers[e]=new ke(e,l,this.dispatcher);p.style=this,p.setEventedParent(this,(()=>({isSourceLoaded:p.loaded(),source:p.serialize(),sourceId:e}))),p.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 l in this._layers)if(this._layers[l].source===e)return this.fire(new c.k(new Error(`Source "${e}" cannot be removed while layer "${l}" is using it.`)));const l=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],l.fire(new c.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),l.setEventedParent(null),l.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,l){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const c=this.tileManagers[e].getSource();if("geojson"!==c.type)throw new Error(`geojsonSource.type is ${c.type}, which is !== 'geojson`);c.setData(l),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,l,d={}){this._checkLoaded();const p=e.id;if(this.getLayer(p))return void this.fire(new c.k(new Error(`Layer "${p}" already exists on this map.`)));let f;if("custom"===e.type){if(sn(this,c.bX(e)))return;f=c.bT(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(p,e.source),e=c.bV(e),e=c.e(e,{source:p})),this._validate(c.C.layer,`layers.${p}`,e,{arrayIndex:-1},d))return;f=c.bT(e,this._globalState),this._validateLayer(f),f.setEventedParent(this,{layer:{id:p}})}const m=l?this._order.indexOf(l):this._order.length;if(l&&-1===m)this.fire(new c.k(new Error(`Cannot add layer "${p}" before non-existing layer "${l}".`)));else{if(this._order.splice(m,0,p),this._layerOrderChanged=!0,this._layers[p]=f,this._removedLayers[p]&&f.source&&"custom"!==f.type){const e=this._removedLayers[p];delete this._removedLayers[p],e.type!==f.type?this._updatedSources[f.source]="clear":(this._updatedSources[f.source]="reload",this.tileManagers[f.source].pause())}this._updateLayer(f),f.onAdd&&f.onAdd(this.map)}}moveLayer(e,l){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new c.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===l)return;const d=this._order.indexOf(e);this._order.splice(d,1);const p=l?this._order.indexOf(l):this._order.length;l&&-1===p?this.fire(new c.k(new Error(`Cannot move layer "${e}" before non-existing layer "${l}".`))):(this._order.splice(p,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const l=this._layers[e];if(!l)return void this.fire(new c.k(new Error(`Cannot remove non-existing layer "${e}".`)));l.setEventedParent(null);const d=this._order.indexOf(e);this._order.splice(d,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=l,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],l.onRemove&&l.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,l,d){this._checkLoaded();const p=this.getLayer(e);p?p.minzoom===l&&p.maxzoom===d||(null!=l&&(p.minzoom=l),null!=d&&(p.maxzoom=d),this._updateLayer(p)):this.fire(new c.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,l,d={}){this._checkLoaded();const p=this.getLayer(e);if(p){if(!c.bR(p.filter,l))return null==l?(p.setFilter(void 0),void this._updateLayer(p)):void(this._validate(c.C.filter,`layers.${p.id}.filter`,l,null,d)||(p.setFilter(c.bV(l)),this._updateLayer(p)))}else this.fire(new c.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return c.bV(this.getLayer(e).filter)}setLayoutProperty(e,l,d,p={}){this._checkLoaded();const f=this.getLayer(e);f?c.bR(f.getLayoutProperty(l),d)||(f.setLayoutProperty(l,d,p),this._updateLayer(f)):this.fire(new c.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,l){const d=this.getLayer(e);if(d)return d.getLayoutProperty(l);this.fire(new c.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,l,d,p={}){this._checkLoaded();const f=this.getLayer(e);f?c.bR(f.getPaintProperty(l),d)||this._updatePaintProperty(f,l,d,p):this.fire(new c.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,l,d,p={}){e.setPaintProperty(l,d,p)&&this._updateLayer(e),c.bU(e)&&"raster-fade-duration"===l&&this.tileManagers[e.source].setRasterFadeDuration(d),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,l){return this.getLayer(e).getPaintProperty(l)}setFeatureState(e,l){this._checkLoaded();const d=e.source,p=e.sourceLayer,f=this.tileManagers[d];if(void 0===f)return void this.fire(new c.k(new Error(`The source '${d}' does not exist in the map's style.`)));const m=f.getSource().type;"geojson"===m&&p?this.fire(new c.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==m||p?(void 0===e.id&&this.fire(new c.k(new Error("The feature id parameter must be provided."))),f.setFeatureState(p,e.id,l)):this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,l){this._checkLoaded();const d=e.source,p=this.tileManagers[d];if(void 0===p)return void this.fire(new c.k(new Error(`The source '${d}' does not exist in the map's style.`)));const f=p.getSource().type,m="vector"===f?e.sourceLayer:void 0;"vector"!==f||m?l&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new c.k(new Error("A feature id is required to remove its specific state property."))):p.removeFeatureState(m,e.id,l):this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const l=e.source,d=e.sourceLayer,p=this.tileManagers[l];if(void 0!==p)return"vector"!==p.getSource().type||d?(void 0===e.id&&this.fire(new c.k(new Error("The feature id parameter must be provided."))),p.getFeatureState(d,e.id)):void this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new c.k(new Error(`The source '${l}' does not exist in the map's style.`)))}getTransition(){return c.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=c.bY(this.tileManagers,(e=>e.serialize())),l=this._serializeByIds(this._order,!0),d=this.map.getTerrain()||void 0,p=this.stylesheet;return c.bZ({version:p.version,name:p.name,metadata:p.metadata,light:p.light,sky:p.sky,center:p.center,zoom:p.zoom,bearing:p.bearing,pitch:p.pitch,sprite:p.sprite,glyphs:p.glyphs,transition:p.transition,projection:p.projection,sources:e,layers:l,terrain:d},(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 l=e=>"fill-extrusion"===this._layers[e].type,c={},d=[];for(let p=this._order.length-1;p>=0;p--){const f=this._order[p];if(l(f)){c[f]=p;for(const l of e){const e=l[f];if(e)for(const l of e)d.push(l)}}}d.sort(((e,l)=>l.intersectionZ-e.intersectionZ));const p=[];for(let f=this._order.length-1;f>=0;f--){const m=this._order[f];if(l(m))for(let e=d.length-1;e>=0;e--){const l=d[e].feature;if(c[l.layer.id]this.map.terrain.getElevation(e,l,c):void 0));return this.placement&&f.push(function(e,l,c,d,p,f,m){const _={},g=f.queryRenderedSymbols(d),y=[];for(const e of Object.keys(g).map(Number))y.push(m[e]);y.sort(ue);for(const c of y){const d=c.featureIndex.lookupSymbolFeatures(g[c.bucketInstanceId],l,c.bucketIndex,c.sourceLayerIndex,{filterSpec:p.filter,globalState:p.globalState},p.layers,p.availableImages,e);for(const e in d){const l=_[e]=_[e]||[],p=d[e];p.sort(((e,l)=>{const d=c.featureSortOrder;if(d){const c=d.indexOf(e.featureIndex);return d.indexOf(l.featureIndex)-c}return l.featureIndex-e.featureIndex}));for(const e of p)l.push(e)}}return function(e,l,c){for(const d in e)for(const p of e[d])pe(p,c[l[d].source]);return e}(_,e,c)}(this._layers,m,this.tileManagers,e,g,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(f)}querySourceFeatures(e,l){(null==l?void 0:l.filter)&&this._validate(c.C.filter,"querySourceFeatures.filter",l.filter,null,l);const d=this.tileManagers[e];return d?function(e,l){const c=e.getRenderableIds().map((l=>e.getTileByID(l))),d=[],p={};for(let e=0;ee.getTileByID(l))).sort(((e,l)=>l.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(l.tileID)?-1:1)))}const d=this.crossTileSymbolIndex.addLayer(c,_[c.source],e.center.lng);f=f||d}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((p=p||this._layerOrderChanged||0===c)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(b(),e.zoom))&&(this.pauseablePlacement=new It(e,this.map.terrain,this._order,p,l,c,d,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,_),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(b()),m=!0),f&&this.pauseablePlacement.placement.setStale()),m||f)for(const e of this._order){const l=this._layers[e];"symbol"===l.type&&this.placement.updateLayerOpacities(l,_[l.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(b())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,l){return c._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(l.icons);this._updateTilesForChangedImages();const c=this.tileManagers[l.source];return c&&c.setDependencies(l.tileID.key,l.type,l.icons),e}))}getGlyphs(e,l){return c._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(l.stacks),c=this.tileManagers[l.source];return c&&c.setDependencies(l.tileID.key,l.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,l={}){this._checkLoaded(),e&&this._validate(c.C.glyphs,"glyphs",e,null,l)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,l){return c._(this,void 0,void 0,(function*(){const e={};for(const[c,d]of Object.entries(l.dashes))e[c]=this.lineAtlas.getDash(d.dasharray,d.round);return e}))}addSprite(e,l,d={},p){this._checkLoaded();const f=[{id:e,url:l}],m=[...F(this.stylesheet.sprite),...f];this._validate(c.C.sprite,"sprite",m,null,d)||(this.stylesheet.sprite=m,this._loadSprite(f,!0,p))}removeSprite(e){this._checkLoaded();const l=F(this.stylesheet.sprite);if(l.find((l=>l.id===e))){if(this._spritesImagesIds[e])for(const l of this._spritesImagesIds[e])this.imageManager.removeImage(l),this._changedImages[l]=!0;l.splice(l.findIndex((l=>l.id===e)),1),this.stylesheet.sprite=l.length>0?l:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"}))}else this.fire(new c.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return F(this.stylesheet.sprite)}setSprite(e,l={},d){this._checkLoaded(),e&&this._validate(c.C.sprite,"sprite",e,null,l)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,d):(this._unloadSprite(),d&&d(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 l=this.tileManagers[e];l.setEventedParent(null),l.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 l=this._layers[e];l.setEventedParent(null),l.onRemove&&l.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 ln=c.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,l,c,d,p,f,m,_,g){this.context=e;let y=this.boundPaintVertexBuffers.length!==d.length;for(let e=0;!y&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:l,u_fog_color:d?d.properties.get("fog-color"):c.bp.white,u_fog_ground_blend:d?d.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:f?0:d?d.calculateFogBlendOpacity(p):0,u_horizon_color:d?d.properties.get("horizon-color"):c.bp.white,u_horizon_fog_blend:d?d.properties.get("horizon-fog-blend"):1,u_is_globe_mode:f?1:0}),hn={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 un(e){const l=[];for(let c=0;c({u_depth:new c.b_(e,l.u_depth),u_terrain:new c.b_(e,l.u_terrain),u_terrain_dim:new c.bq(e,l.u_terrain_dim),u_terrain_matrix:new c.c0(e,l.u_terrain_matrix),u_terrain_unpack:new c.c1(e,l.u_terrain_unpack),u_terrain_exaggeration:new c.bq(e,l.u_terrain_exaggeration)}))(e,q),this.projectionUniforms=((e,l)=>({u_projection_matrix:new c.c0(e,l.u_projection_matrix),u_projection_tile_mercator_coords:new c.c1(e,l.u_projection_tile_mercator_coords),u_projection_clipping_plane:new c.c1(e,l.u_projection_clipping_plane),u_projection_transition:new c.bq(e,l.u_projection_transition),u_projection_fallback_matrix:new c.c0(e,l.u_projection_fallback_matrix)}))(e,q),this.binderUniforms=d?d.getUniforms(e,q):[]}draw(e,l,c,d,p,f,m,_,g,y,b,T,S,P,I,C,R,L,F){const B=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(c),e.setStencilMode(d),e.setColorMode(p),e.setCullFace(f),_){e.activeTexture.set(B.TEXTURE2),B.bindTexture(B.TEXTURE_2D,_.depthTexture),e.activeTexture.set(B.TEXTURE3),B.bindTexture(B.TEXTURE_2D,_.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(_[e])}if(g)for(const e in g)this.projectionUniforms[hn[e]].set(g[e]);if(m)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(m[e]);C&&C.setUniforms(e,this.binderUniforms,P,{zoom:I});let O=0;switch(l){case B.LINES:O=2;break;case B.TRIANGLES:O=3;break;case B.LINE_STRIP:O=1}for(const c of S.get()){const d=c.vaos||(c.vaos={});(d[y]||(d[y]=new Bi)).bind(e,this,b,C?C.getPaintVertexBuffers():[],T,c.vertexOffset,R,L,F),B.drawElements(l,c.primitiveLength*O,B.UNSIGNED_SHORT,c.primitiveOffset*O*2)}}}function dn(e,l,d){const p=1/c.aN(d,1,l.transform.tileZoom),f=Math.pow(2,d.tileID.overscaledZ),m=d.tileSize*Math.pow(2,l.transform.tileZoom)/f,_=m*(d.tileID.canonical.x+d.tileID.wrap*f),g=m*d.tileID.canonical.y;return{u_image:0,u_texsize:d.imageAtlasTexture.size,u_scale:[p,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[_>>16,g>>16],u_pixel_coord_lower:[65535&_,65535&g]}}const pn=(e,l,d,p)=>{const f=e.style.light,m=f.properties.get("position"),_=[m.x,m.y,m.z],g=c.c4();"viewport"===f.properties.get("anchor")&&c.c5(g,e.transform.bearingInRadians),c.c6(_,_,g);const y=e.transform.transformLightDirection(_),b=f.properties.get("color");return{u_lightpos:_,u_lightpos_globe:y,u_lightintensity:f.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+l,u_opacity:d,u_fill_translate:p}},fn=(e,l,d,p,f,m,_)=>c.e(pn(e,l,d,p),dn(m,e,_),{u_height_factor:-Math.pow(2,f.overscaledZ)/_.tileSize/8}),mn=(e,l,d,p)=>c.e(dn(l,e,d),{u_fill_translate:p}),_n=(e,l)=>({u_world:e,u_fill_translate:l}),gn=(e,l,d,p,f)=>c.e(mn(e,l,d,f),{u_world:p}),yn=(e,l,d,p,f)=>{const m=e.transform;let _,g,y=0;if("map"===d.paint.get("circle-pitch-alignment")){const e=c.aN(l,1,m.zoom);_=!0,g=[e,e],y=e/(c.a5*Math.pow(2,l.tileID.overscaledZ))*2*Math.PI*f}else _=!1,g=m.pixelsToGLUnits;return{u_camera_to_center_distance:m.cameraToCenterDistance,u_scale_with_map:+("map"===d.paint.get("circle-pitch-scale")),u_pitch_with_map:+_,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:g,u_globe_extrude_scale:y,u_translate:p}},xn=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),vn=e=>({u_viewport_size:[e.width,e.height]}),bn=(e,l=1)=>({u_color:e,u_overlay:0,u_overlay_scale:l}),wn=(e,l,d,p)=>{const f=c.aN(e,1,l)/(c.a5*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*p;return{u_extrude_scale:c.aN(e,1,l),u_intensity:d,u_globe_extrude_scale:f}},Tn=(e,l,d,p)=>{const f=c.N();c.c7(f,0,e.width,e.height,0,0,1);const m=e.context.gl;return{u_matrix:f,u_world:[m.drawingBufferWidth,m.drawingBufferHeight],u_image:d,u_color_ramp:p,u_opacity:l.paint.get("heatmap-opacity")}},Sn=(e,l,c)=>{const d=c.paint.get("hillshade-accent-color");let p;switch(c.paint.get("hillshade-method")){case"basic":p=4;break;case"combined":p=1;break;case"igor":p=2;break;case"multidirectional":p=3;break;default:p=0}const f=c.getIlluminationProperties();for(let l=0;l{const d=l.stride,p=c.N();return c.c7(p,0,c.a5,-c.a5,0,0,1),c.O(p,p,[0,-c.a5,0]),{u_matrix:p,u_image:1,u_dimension:[d,d],u_zoom:e.overscaledZ,u_unpack:l.getUnpackVector()}};function In(e,l){const d=Math.pow(2,l.canonical.z),p=l.canonical.y;return[new c.a9(0,p/d).toLngLat().lat,new c.a9(0,(p+1)/d).toLngLat().lat]}const En=(e,l,c=0)=>({u_image:0,u_unpack:l.getUnpackVector(),u_dimension:[l.stride,l.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:c,u_opacity:e.paint.get("color-relief-opacity")}),Cn=(e,l,d,p)=>{const f=e.transform;return{u_translation:Bn(e,l,d),u_ratio:p/c.aN(l,1,f.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]]}},An=(e,l,d,p,f)=>c.e(Cn(e,l,d,p),{u_image:0,u_image_height:f}),Dn=(e,l,d,p,f)=>{const m=e.transform,_=Ln(l,m);return{u_translation:Bn(e,l,d),u_texsize:l.imageAtlasTexture.size,u_ratio:p/c.aN(l,1,m.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[_,f.fromScale,f.toScale],u_fade:f.t,u_units_to_pixels:[1/m.pixelsToGLUnits[0],1/m.pixelsToGLUnits[1]]}},kn=(e,l,d,p,f)=>{const m=Ln(l,e.transform);return c.e(Cn(e,l,d,p),{u_tileratio:m,u_crossfade_from:f.fromScale,u_crossfade_to:f.toScale,u_image:0,u_mix:f.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},Rn=(e,l,d,p,f,m)=>{const _=Ln(l,e.transform);return c.e(Cn(e,l,d,p),{u_image:0,u_image_height:m,u_tileratio:_,u_crossfade_from:f.fromScale,u_crossfade_to:f.toScale,u_image_dash:1,u_mix:f.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function Ln(e,l){return 1/c.aN(e,1,l.tileZoom)}function Bn(e,l,d){return c.aO(e.transform,l,d.paint.get("line-translate"),d.paint.get("line-translate-anchor"))}const On=(e,l,c,d,p)=>{return{u_tl_parent:e,u_scale_parent:l,u_buffer_scale:1,u_fade_t:c.mix,u_opacity:c.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:(m=d.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(f=d.paint.get("raster-contrast"),f>0?1/(1-f):1+f),u_spin_weights:Vn(d.paint.get("raster-hue-rotate")),u_coords_top:[p[0].x,p[0].y,p[1].x,p[1].y],u_coords_bottom:[p[3].x,p[3].y,p[2].x,p[2].y]};var f,m};function Vn(e){e*=Math.PI/180;const l=Math.sin(e),c=Math.cos(e);return[(2*c+1)/3,(-Math.sqrt(3)*l-c+1)/3,(Math.sqrt(3)*l-c+1)/3]}const jn=(e,l,c,d,p,f,m,_,g,y,b,T,S)=>{const P=m.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:l?l.uSizeT:0,u_size:l?l.uSize:0,u_camera_to_center_distance:P.cameraToCenterDistance,u_pitch:P.pitch/360*2*Math.PI,u_rotate_symbol:+c,u_aspect_ratio:P.width/P.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_label_plane_matrix:_,u_coord_matrix:g,u_is_text:+b,u_pitch_with_map:+d,u_is_along_line:p,u_is_variable_anchor:f,u_texsize:T,u_texture:0,u_translation:y,u_pitched_scale:S}},Nn=(e,l,d,p,f,m,_,g,y,b,T,S,P,I)=>{const C=_.transform;return c.e(jn(e,l,d,p,f,m,_,g,y,b,T,S,I),{u_gamma_scale:p?Math.cos(C.pitch*Math.PI/180)*C.cameraToCenterDistance:1,u_device_pixel_ratio:_.pixelRatio,u_is_halo:1})},Gn=(e,l,d,p,f,m,_,g,y,b,T,S,P)=>c.e(Nn(e,l,d,p,f,m,_,g,y,b,!0,T,0,P),{u_texsize_icon:S,u_texture_icon:1}),Un=(e,l)=>({u_opacity:e,u_color:l}),qn=(e,l,d,p,f)=>c.e(function(e,l,d,p){const f=d.imageManager.getPattern(e.from.toString()),m=d.imageManager.getPattern(e.to.toString()),{width:_,height:g}=d.imageManager.getPixelSize(),y=Math.pow(2,p.tileID.overscaledZ),b=p.tileSize*Math.pow(2,d.transform.tileZoom)/y,T=b*(p.tileID.canonical.x+p.tileID.wrap*y),S=b*p.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:f.tl,u_pattern_br_a:f.br,u_pattern_tl_b:m.tl,u_pattern_br_b:m.br,u_texsize:[_,g],u_mix:l.t,u_pattern_size_a:f.displaySize,u_pattern_size_b:m.displaySize,u_scale_a:l.fromScale,u_scale_b:l.toScale,u_tile_units_to_pixels:1/c.aN(p,1,d.transform.tileZoom),u_pixel_coord_upper:[T>>16,S>>16],u_pixel_coord_lower:[65535&T,65535&S]}}(d,f,l,p),{u_opacity:e}),Zn=(e,l)=>{},$n={fillExtrusion:(e,l)=>({u_lightpos:new c.c2(e,l.u_lightpos),u_lightpos_globe:new c.c2(e,l.u_lightpos_globe),u_lightintensity:new c.bq(e,l.u_lightintensity),u_lightcolor:new c.c2(e,l.u_lightcolor),u_vertical_gradient:new c.bq(e,l.u_vertical_gradient),u_opacity:new c.bq(e,l.u_opacity),u_fill_translate:new c.c3(e,l.u_fill_translate)}),fillExtrusionPattern:(e,l)=>({u_lightpos:new c.c2(e,l.u_lightpos),u_lightpos_globe:new c.c2(e,l.u_lightpos_globe),u_lightintensity:new c.bq(e,l.u_lightintensity),u_lightcolor:new c.c2(e,l.u_lightcolor),u_vertical_gradient:new c.bq(e,l.u_vertical_gradient),u_height_factor:new c.bq(e,l.u_height_factor),u_opacity:new c.bq(e,l.u_opacity),u_fill_translate:new c.c3(e,l.u_fill_translate),u_image:new c.b_(e,l.u_image),u_texsize:new c.c3(e,l.u_texsize),u_pixel_coord_upper:new c.c3(e,l.u_pixel_coord_upper),u_pixel_coord_lower:new c.c3(e,l.u_pixel_coord_lower),u_scale:new c.c2(e,l.u_scale),u_fade:new c.bq(e,l.u_fade)}),fill:(e,l)=>({u_fill_translate:new c.c3(e,l.u_fill_translate)}),fillPattern:(e,l)=>({u_image:new c.b_(e,l.u_image),u_texsize:new c.c3(e,l.u_texsize),u_pixel_coord_upper:new c.c3(e,l.u_pixel_coord_upper),u_pixel_coord_lower:new c.c3(e,l.u_pixel_coord_lower),u_scale:new c.c2(e,l.u_scale),u_fade:new c.bq(e,l.u_fade),u_fill_translate:new c.c3(e,l.u_fill_translate)}),fillOutline:(e,l)=>({u_world:new c.c3(e,l.u_world),u_fill_translate:new c.c3(e,l.u_fill_translate)}),fillOutlinePattern:(e,l)=>({u_world:new c.c3(e,l.u_world),u_image:new c.b_(e,l.u_image),u_texsize:new c.c3(e,l.u_texsize),u_pixel_coord_upper:new c.c3(e,l.u_pixel_coord_upper),u_pixel_coord_lower:new c.c3(e,l.u_pixel_coord_lower),u_scale:new c.c2(e,l.u_scale),u_fade:new c.bq(e,l.u_fade),u_fill_translate:new c.c3(e,l.u_fill_translate)}),circle:(e,l)=>({u_camera_to_center_distance:new c.bq(e,l.u_camera_to_center_distance),u_scale_with_map:new c.b_(e,l.u_scale_with_map),u_pitch_with_map:new c.b_(e,l.u_pitch_with_map),u_extrude_scale:new c.c3(e,l.u_extrude_scale),u_device_pixel_ratio:new c.bq(e,l.u_device_pixel_ratio),u_globe_extrude_scale:new c.bq(e,l.u_globe_extrude_scale),u_translate:new c.c3(e,l.u_translate)}),collisionBox:(e,l)=>({u_pixel_extrude_scale:new c.c3(e,l.u_pixel_extrude_scale)}),collisionCircle:(e,l)=>({u_viewport_size:new c.c3(e,l.u_viewport_size)}),debug:(e,l)=>({u_color:new c.b$(e,l.u_color),u_overlay:new c.b_(e,l.u_overlay),u_overlay_scale:new c.bq(e,l.u_overlay_scale)}),depth:Zn,clippingMask:Zn,heatmap:(e,l)=>({u_extrude_scale:new c.bq(e,l.u_extrude_scale),u_intensity:new c.bq(e,l.u_intensity),u_globe_extrude_scale:new c.bq(e,l.u_globe_extrude_scale)}),heatmapTexture:(e,l)=>({u_matrix:new c.c0(e,l.u_matrix),u_world:new c.c3(e,l.u_world),u_image:new c.b_(e,l.u_image),u_color_ramp:new c.b_(e,l.u_color_ramp),u_opacity:new c.bq(e,l.u_opacity)}),hillshade:(e,l)=>({u_image:new c.b_(e,l.u_image),u_latrange:new c.c3(e,l.u_latrange),u_exaggeration:new c.bq(e,l.u_exaggeration),u_altitudes:new c.c9(e,l.u_altitudes),u_azimuths:new c.c9(e,l.u_azimuths),u_accent:new c.b$(e,l.u_accent),u_method:new c.b_(e,l.u_method),u_shadows:new c.c8(e,l.u_shadows),u_highlights:new c.c8(e,l.u_highlights)}),hillshadePrepare:(e,l)=>({u_matrix:new c.c0(e,l.u_matrix),u_image:new c.b_(e,l.u_image),u_dimension:new c.c3(e,l.u_dimension),u_zoom:new c.bq(e,l.u_zoom),u_unpack:new c.c1(e,l.u_unpack)}),colorRelief:(e,l)=>({u_image:new c.b_(e,l.u_image),u_unpack:new c.c1(e,l.u_unpack),u_dimension:new c.c3(e,l.u_dimension),u_elevation_stops:new c.b_(e,l.u_elevation_stops),u_color_stops:new c.b_(e,l.u_color_stops),u_color_ramp_size:new c.b_(e,l.u_color_ramp_size),u_opacity:new c.bq(e,l.u_opacity)}),line:(e,l)=>({u_translation:new c.c3(e,l.u_translation),u_ratio:new c.bq(e,l.u_ratio),u_device_pixel_ratio:new c.bq(e,l.u_device_pixel_ratio),u_units_to_pixels:new c.c3(e,l.u_units_to_pixels)}),lineGradient:(e,l)=>({u_translation:new c.c3(e,l.u_translation),u_ratio:new c.bq(e,l.u_ratio),u_device_pixel_ratio:new c.bq(e,l.u_device_pixel_ratio),u_units_to_pixels:new c.c3(e,l.u_units_to_pixels),u_image:new c.b_(e,l.u_image),u_image_height:new c.bq(e,l.u_image_height)}),linePattern:(e,l)=>({u_translation:new c.c3(e,l.u_translation),u_texsize:new c.c3(e,l.u_texsize),u_ratio:new c.bq(e,l.u_ratio),u_device_pixel_ratio:new c.bq(e,l.u_device_pixel_ratio),u_image:new c.b_(e,l.u_image),u_units_to_pixels:new c.c3(e,l.u_units_to_pixels),u_scale:new c.c2(e,l.u_scale),u_fade:new c.bq(e,l.u_fade)}),lineSDF:(e,l)=>({u_translation:new c.c3(e,l.u_translation),u_ratio:new c.bq(e,l.u_ratio),u_device_pixel_ratio:new c.bq(e,l.u_device_pixel_ratio),u_units_to_pixels:new c.c3(e,l.u_units_to_pixels),u_image:new c.b_(e,l.u_image),u_mix:new c.bq(e,l.u_mix),u_tileratio:new c.bq(e,l.u_tileratio),u_crossfade_from:new c.bq(e,l.u_crossfade_from),u_crossfade_to:new c.bq(e,l.u_crossfade_to),u_lineatlas_width:new c.bq(e,l.u_lineatlas_width),u_lineatlas_height:new c.bq(e,l.u_lineatlas_height)}),lineGradientSDF:(e,l)=>({u_translation:new c.c3(e,l.u_translation),u_ratio:new c.bq(e,l.u_ratio),u_device_pixel_ratio:new c.bq(e,l.u_device_pixel_ratio),u_units_to_pixels:new c.c3(e,l.u_units_to_pixels),u_image:new c.b_(e,l.u_image),u_image_height:new c.bq(e,l.u_image_height),u_tileratio:new c.bq(e,l.u_tileratio),u_crossfade_from:new c.bq(e,l.u_crossfade_from),u_crossfade_to:new c.bq(e,l.u_crossfade_to),u_image_dash:new c.b_(e,l.u_image_dash),u_mix:new c.bq(e,l.u_mix),u_lineatlas_width:new c.bq(e,l.u_lineatlas_width),u_lineatlas_height:new c.bq(e,l.u_lineatlas_height)}),raster:(e,l)=>({u_tl_parent:new c.c3(e,l.u_tl_parent),u_scale_parent:new c.bq(e,l.u_scale_parent),u_buffer_scale:new c.bq(e,l.u_buffer_scale),u_fade_t:new c.bq(e,l.u_fade_t),u_opacity:new c.bq(e,l.u_opacity),u_image0:new c.b_(e,l.u_image0),u_image1:new c.b_(e,l.u_image1),u_brightness_low:new c.bq(e,l.u_brightness_low),u_brightness_high:new c.bq(e,l.u_brightness_high),u_saturation_factor:new c.bq(e,l.u_saturation_factor),u_contrast_factor:new c.bq(e,l.u_contrast_factor),u_spin_weights:new c.c2(e,l.u_spin_weights),u_coords_top:new c.c1(e,l.u_coords_top),u_coords_bottom:new c.c1(e,l.u_coords_bottom)}),symbolIcon:(e,l)=>({u_is_size_zoom_constant:new c.b_(e,l.u_is_size_zoom_constant),u_is_size_feature_constant:new c.b_(e,l.u_is_size_feature_constant),u_size_t:new c.bq(e,l.u_size_t),u_size:new c.bq(e,l.u_size),u_camera_to_center_distance:new c.bq(e,l.u_camera_to_center_distance),u_pitch:new c.bq(e,l.u_pitch),u_rotate_symbol:new c.b_(e,l.u_rotate_symbol),u_aspect_ratio:new c.bq(e,l.u_aspect_ratio),u_fade_change:new c.bq(e,l.u_fade_change),u_label_plane_matrix:new c.c0(e,l.u_label_plane_matrix),u_coord_matrix:new c.c0(e,l.u_coord_matrix),u_is_text:new c.b_(e,l.u_is_text),u_pitch_with_map:new c.b_(e,l.u_pitch_with_map),u_is_along_line:new c.b_(e,l.u_is_along_line),u_is_variable_anchor:new c.b_(e,l.u_is_variable_anchor),u_texsize:new c.c3(e,l.u_texsize),u_texture:new c.b_(e,l.u_texture),u_translation:new c.c3(e,l.u_translation),u_pitched_scale:new c.bq(e,l.u_pitched_scale)}),symbolSDF:(e,l)=>({u_is_size_zoom_constant:new c.b_(e,l.u_is_size_zoom_constant),u_is_size_feature_constant:new c.b_(e,l.u_is_size_feature_constant),u_size_t:new c.bq(e,l.u_size_t),u_size:new c.bq(e,l.u_size),u_camera_to_center_distance:new c.bq(e,l.u_camera_to_center_distance),u_pitch:new c.bq(e,l.u_pitch),u_rotate_symbol:new c.b_(e,l.u_rotate_symbol),u_aspect_ratio:new c.bq(e,l.u_aspect_ratio),u_fade_change:new c.bq(e,l.u_fade_change),u_label_plane_matrix:new c.c0(e,l.u_label_plane_matrix),u_coord_matrix:new c.c0(e,l.u_coord_matrix),u_is_text:new c.b_(e,l.u_is_text),u_pitch_with_map:new c.b_(e,l.u_pitch_with_map),u_is_along_line:new c.b_(e,l.u_is_along_line),u_is_variable_anchor:new c.b_(e,l.u_is_variable_anchor),u_texsize:new c.c3(e,l.u_texsize),u_texture:new c.b_(e,l.u_texture),u_gamma_scale:new c.bq(e,l.u_gamma_scale),u_device_pixel_ratio:new c.bq(e,l.u_device_pixel_ratio),u_is_halo:new c.b_(e,l.u_is_halo),u_translation:new c.c3(e,l.u_translation),u_pitched_scale:new c.bq(e,l.u_pitched_scale)}),symbolTextAndIcon:(e,l)=>({u_is_size_zoom_constant:new c.b_(e,l.u_is_size_zoom_constant),u_is_size_feature_constant:new c.b_(e,l.u_is_size_feature_constant),u_size_t:new c.bq(e,l.u_size_t),u_size:new c.bq(e,l.u_size),u_camera_to_center_distance:new c.bq(e,l.u_camera_to_center_distance),u_pitch:new c.bq(e,l.u_pitch),u_rotate_symbol:new c.b_(e,l.u_rotate_symbol),u_aspect_ratio:new c.bq(e,l.u_aspect_ratio),u_fade_change:new c.bq(e,l.u_fade_change),u_label_plane_matrix:new c.c0(e,l.u_label_plane_matrix),u_coord_matrix:new c.c0(e,l.u_coord_matrix),u_is_text:new c.b_(e,l.u_is_text),u_pitch_with_map:new c.b_(e,l.u_pitch_with_map),u_is_along_line:new c.b_(e,l.u_is_along_line),u_is_variable_anchor:new c.b_(e,l.u_is_variable_anchor),u_texsize:new c.c3(e,l.u_texsize),u_texsize_icon:new c.c3(e,l.u_texsize_icon),u_texture:new c.b_(e,l.u_texture),u_texture_icon:new c.b_(e,l.u_texture_icon),u_gamma_scale:new c.bq(e,l.u_gamma_scale),u_device_pixel_ratio:new c.bq(e,l.u_device_pixel_ratio),u_is_halo:new c.b_(e,l.u_is_halo),u_translation:new c.c3(e,l.u_translation),u_pitched_scale:new c.bq(e,l.u_pitched_scale)}),background:(e,l)=>({u_opacity:new c.bq(e,l.u_opacity),u_color:new c.b$(e,l.u_color)}),backgroundPattern:(e,l)=>({u_opacity:new c.bq(e,l.u_opacity),u_image:new c.b_(e,l.u_image),u_pattern_tl_a:new c.c3(e,l.u_pattern_tl_a),u_pattern_br_a:new c.c3(e,l.u_pattern_br_a),u_pattern_tl_b:new c.c3(e,l.u_pattern_tl_b),u_pattern_br_b:new c.c3(e,l.u_pattern_br_b),u_texsize:new c.c3(e,l.u_texsize),u_mix:new c.bq(e,l.u_mix),u_pattern_size_a:new c.c3(e,l.u_pattern_size_a),u_pattern_size_b:new c.c3(e,l.u_pattern_size_b),u_scale_a:new c.bq(e,l.u_scale_a),u_scale_b:new c.bq(e,l.u_scale_b),u_pixel_coord_upper:new c.c3(e,l.u_pixel_coord_upper),u_pixel_coord_lower:new c.c3(e,l.u_pixel_coord_lower),u_tile_units_to_pixels:new c.bq(e,l.u_tile_units_to_pixels)}),terrain:(e,l)=>({u_texture:new c.b_(e,l.u_texture),u_ele_delta:new c.bq(e,l.u_ele_delta),u_fog_matrix:new c.c0(e,l.u_fog_matrix),u_fog_color:new c.b$(e,l.u_fog_color),u_fog_ground_blend:new c.bq(e,l.u_fog_ground_blend),u_fog_ground_blend_opacity:new c.bq(e,l.u_fog_ground_blend_opacity),u_horizon_color:new c.b$(e,l.u_horizon_color),u_horizon_fog_blend:new c.bq(e,l.u_horizon_fog_blend),u_is_globe_mode:new c.bq(e,l.u_is_globe_mode)}),terrainDepth:(e,l)=>({u_ele_delta:new c.bq(e,l.u_ele_delta)}),terrainCoords:(e,l)=>({u_texture:new c.b_(e,l.u_texture),u_terrain_coords_id:new c.bq(e,l.u_terrain_coords_id),u_ele_delta:new c.bq(e,l.u_ele_delta)}),projectionErrorMeasurement:(e,l)=>({u_input:new c.bq(e,l.u_input),u_output_expected:new c.bq(e,l.u_output_expected)}),atmosphere:(e,l)=>({u_sun_pos:new c.c2(e,l.u_sun_pos),u_atmosphere_blend:new c.bq(e,l.u_atmosphere_blend),u_globe_position:new c.c2(e,l.u_globe_position),u_globe_radius:new c.bq(e,l.u_globe_radius),u_inv_proj_matrix:new c.c0(e,l.u_inv_proj_matrix)}),sky:(e,l)=>({u_sky_color:new c.b$(e,l.u_sky_color),u_horizon_color:new c.b$(e,l.u_horizon_color),u_horizon:new c.c3(e,l.u_horizon),u_horizon_normal:new c.c3(e,l.u_horizon_normal),u_sky_horizon_blend:new c.bq(e,l.u_sky_horizon_blend),u_sky_blend:new c.bq(e,l.u_sky_blend)})};class ba{constructor(e,l,c){this.context=e;const d=e.gl;this.buffer=d.createBuffer(),this.dynamicDraw=Boolean(c),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,l.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||delete l.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const l=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),l.bufferSubData(l.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Wn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class wa{constructor(e,l,c,d){this.length=l.length,this.attributes=c,this.itemSize=l.bytesPerElement,this.dynamicDraw=d,this.context=e;const p=e.gl;this.buffer=p.createBuffer(),e.bindVertexBuffer.set(this.buffer),p.bufferData(p.ARRAY_BUFFER,l.arrayBuffer,this.dynamicDraw?p.DYNAMIC_DRAW:p.STATIC_DRAW),this.dynamicDraw||delete l.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 l=this.context.gl;this.bind(),l.bufferSubData(l.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,l){for(let c=0;c0&&(b.push({circleArray:R,circleOffset:S,coord:P}),T+=R.length/4,S=T),C&&y.draw(m,g.LINES,ti.disabled,ai.disabled,e.colorModeForRenderPass(),ei.disabled,xn(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(P),_.getProjectionData({overscaledTileID:P,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),d.id,C.layoutVertexBuffer,C.indexBuffer,C.segments,null,e.transform.zoom,null,null,C.collisionVertexBuffer)}if(!f||!b.length)return;const P=e.useProgram("collisionCircle"),I=new c.ca;I.resize(4*T),I._trim();let C=0;for(const e of b)for(let l=0;l=0&&(R[L.associatedIconIndex]={shiftedAnchor:Q,angle:J})}else fi(L.numGlyphs,I)}if(y){C.clear();const l=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(g,l,c):null,c="map"===d.layout.get("text-rotation-alignment");Ot(y,e,f,me,ge,F,b,c,g.toUnwrapped(),R.width,R.height,xe,l)}const Se=f&&U||we,Me=B||Se?Kn:F?me:e.transform.clipSpaceToPixelsMatrix,Ee=I&&0!==d.paint.get(f?"text-halo-width":"icon-halo-width").constantOr(1);let Ce;Ce=I?y.iconsInText?Gn(G.kind,J,O,F,B,Se,e,Me,ye,xe,oe,ue,Z):Nn(G.kind,J,O,F,B,Se,e,Me,ye,xe,f,oe,0,Z):jn(G.kind,J,O,F,B,Se,e,Me,ye,xe,f,oe,Z);const Ae={program:Q,buffers:T,uniformValues:Ce,projectionData:ve,atlasTexture:le,atlasTextureIcon:pe,atlasInterpolation:ce,atlasInterpolationIcon:he,isSDF:I,hasHalo:Ee};if(V&&y.canOverlap){j=!0;const e=T.segments.get();for(const l of e)q.push({segments:new c.aX([l]),sortKey:l.sortKey,state:Ae,terrainData:re})}else q.push({segments:T.segments,sortKey:0,state:Ae,terrainData:re})}j&&q.sort(((e,l)=>e.sortKey-l.sortKey));for(const l of q){const c=l.state;if(I.activeTexture.set(C.TEXTURE0),c.atlasTexture.bind(c.atlasInterpolation,C.CLAMP_TO_EDGE),c.atlasTextureIcon&&(I.activeTexture.set(C.TEXTURE1),c.atlasTextureIcon&&c.atlasTextureIcon.bind(c.atlasInterpolationIcon,C.CLAMP_TO_EDGE)),c.isSDF){const p=c.uniformValues;c.hasHalo&&(p.u_is_halo=1,os(c.buffers,l.segments,d,e,c.program,G,T,S,p,c.projectionData,l.terrainData)),p.u_is_halo=0}os(c.buffers,l.segments,d,e,c.program,G,T,S,c.uniformValues,c.projectionData,l.terrainData)}}function os(e,l,c,d,p,f,m,_,g,y,b){const T=d.context;p.draw(T,T.gl.TRIANGLES,f,m,_,ei.backCCW,g,b,y,c.id,e.layoutVertexBuffer,e.indexBuffer,l,c.paint,d.transform.zoom,e.programConfigurations.get(c.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function ls(e,l,d,p,f){const m=e.context,_=m.gl,g=ai.disabled,y=new Qt([_.ONE,_.ONE],c.bp.transparent,[!0,!0,!0,!0]),b=l.getBucket(d);if(!b)return;const T=p.key;let S=d.heatmapFbos.get(T);S||(S=ds(m,l.tileSize,l.tileSize),d.heatmapFbos.set(T,S)),m.bindFramebuffer.set(S.framebuffer),m.viewport.set([0,0,l.tileSize,l.tileSize]),m.clear({color:c.bp.transparent});const P=b.programConfigurations.get(d.id),I=e.useProgram("heatmap",P,!f),C=e.transform.getProjectionData({overscaledTileID:l.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),R=e.style.map.terrain.getTerrainData(p);I.draw(m,_.TRIANGLES,ti.disabled,g,y,ei.disabled,wn(l,e.transform.zoom,d.paint.get("heatmap-intensity"),1),R,C,d.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,d.paint,e.transform.zoom,P)}function us(e,l,c,d,p){const f=e.context,m=f.gl,_=e.transform;f.setColorMode(e.colorModeForRenderPass());const g=ps(f,l),y=c.key,b=l.heatmapFbos.get(y);if(!b)return;f.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,b.colorAttachment.get()),f.activeTexture.set(m.TEXTURE1),g.bind(m.LINEAR,m.CLAMP_TO_EDGE);const T=_.getProjectionData({overscaledTileID:c,applyTerrainMatrix:p,applyGlobeMatrix:!d});e.useProgram("heatmapTexture").draw(f,m.TRIANGLES,ti.disabled,ai.disabled,e.colorModeForRenderPass(),ei.disabled,Tn(e,l,0,1),null,T,l.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,l.paint,_.zoom),b.destroy(),l.heatmapFbos.delete(y)}function ds(e,l,c){var d,p;const f=e.gl,m=f.createTexture();f.bindTexture(f.TEXTURE_2D,m),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.LINEAR),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,f.LINEAR);const _=null!==(d=e.HALF_FLOAT)&&void 0!==d?d:f.UNSIGNED_BYTE,g=null!==(p=e.RGBA16F)&&void 0!==p?p:f.RGBA;f.texImage2D(f.TEXTURE_2D,0,g,l,c,0,f.RGBA,_,null);const y=e.createFramebuffer(l,c,!1,!1);return y.colorAttachment.set(m),y}function ps(e,l){return l.colorRampTexture||(l.colorRampTexture=new c.T(e,l.colorRamp,e.gl.RGBA)),l.colorRampTexture}function fs(e,l,d,p,f,m,_,g){let y=256;if(f.stepInterpolant){const p=l.getSource().maxzoom,f=_.canonical.z===p?Math.ceil(1<20&&S.texParameterf(S.TEXTURE_2D,T.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,T.extTextureFilterAnisotropicMax);const J=e.style.map.terrain&&e.style.map.terrain.getTerrainData(j),re=I.getProjectionData({overscaledTileID:j,aligned:L,applyGlobeMatrix:!y,applyTerrainMatrix:!0}),oe=On(W,Z,Q.fadeMix,c,_),le=C.getMeshFromTileID(T,j.canonical,f,m,"raster");P.draw(T,S.TRIANGLES,d,p?p[j.overscaledZ]:ai.disabled,R,g?ei.frontCCW:ei.backCCW,oe,J,re,c.id,le.vertexBuffer,le.indexBuffer,le.segments)}}function As(e,l,d,p){const f={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===d||p)return f;if(e.fadingParentID){const p=l.getLoadedTile(e.fadingParentID);if(!p)return f;const m=Math.pow(2,p.tileID.overscaledZ-e.tileID.overscaledZ),_=[e.tileID.canonical.x*m%1,e.tileID.canonical.y*m%1],g=function(e,l,d){const p=b(),f=(p-l.timeAdded)/d,m=e.fadingDirection===Me.Incoming,_=c.an((p-e.timeAdded)/d,0,1),g=c.an(1-f,0,1),y=m?_:g;return{tileOpacity:y,parentTileOpacity:m?g:_,fadeMix:{opacity:1,mix:1-y}}}(e,p,d);return{parentTile:p,parentScaleBy:m,parentTopLeft:_,fadeValues:g}}if(e.selfFading){const l=function(e,l){const d=(b()-e.timeAdded)/l,p=c.an(d,0,1);return{tileOpacity:p,fadeMix:{opacity:p,mix:0}}}(e,d);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:l}}return f}const Ds=new c.bp(1,0,0,1),zs=new c.bp(0,1,0,1),ks=new c.bp(0,0,1,1),Fs=new c.bp(1,0,1,1),Bs=new c.bp(0,1,1,1);function Vs(e,l,c,d){Js(e,0,l+c/2,e.transform.width,c,d)}function Ws(e,l,c,d){Js(e,l-c/2,0,c,e.transform.height,d)}function Js(e,l,c,d,p,f){const m=e.context,_=m.gl;_.enable(_.SCISSOR_TEST),_.scissor(l*e.pixelRatio,c*e.pixelRatio,d*e.pixelRatio,p*e.pixelRatio),m.clear({color:f}),_.disable(_.SCISSOR_TEST)}function ro(e,l,d){const p=e.context,f=p.gl,m=e.useProgram("debug"),_=ti.disabled,g=ai.disabled,y=e.colorModeForRenderPass(),b="$debug",T=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d);p.activeTexture.set(f.TEXTURE0);const S=l.getTileByID(d.key).latestRawTileData,P=Math.floor((S&&S.byteLength||0)/1024),I=l.getTile(d).tileSize,C=512/Math.min(I,512)*(d.overscaledZ/e.transform.zoom)*.5;let R=d.canonical.toString();d.overscaledZ!==d.canonical.z&&(R+=` => ${d.overscaledZ}`),function(e,l){e.initDebugOverlayCanvas();const c=e.debugOverlayCanvas,d=e.context.gl,p=e.debugOverlayCanvas.getContext("2d");p.clearRect(0,0,c.width,c.height),p.shadowColor="white",p.shadowBlur=2,p.lineWidth=1.5,p.strokeStyle="white",p.textBaseline="top",p.font="bold 36px Open Sans, sans-serif",p.fillText(l,5,5),p.strokeText(l,5,5),e.debugOverlayTexture.update(c),e.debugOverlayTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE)}(e,`${R} ${P}kB`);const L=e.transform.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!0,applyTerrainMatrix:!0});m.draw(p,f.TRIANGLES,_,g,Qt.alphaBlended,ei.disabled,bn(c.bp.transparent,C),null,L,b,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),m.draw(p,f.LINE_STRIP,_,g,y,ei.disabled,bn(c.bp.red),T,L,b,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function lo(e,l,c,d){const{isRenderingGlobe:p}=d,f=e.context,m=f.gl,_=e.transform,g=e.colorModeForRenderPass(),y=e.getDepthModeFor3D(),b=e.useProgram("terrain");f.bindFramebuffer.set(null),f.viewport.set([0,0,e.width,e.height]);for(const d of c){const c=l.getTerrainMesh(d.tileID),T=e.renderToTexture.getTexture(d),S=l.getTerrainData(d.tileID);f.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,T.texture);const P=l.getMeshFrameDelta(_.zoom),I=_.calculateFogMatrix(d.tileID.toUnwrapped()),C=cn(P,I,e.style.sky,_.pitch,p),R=_.getProjectionData({overscaledTileID:d.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});b.draw(f,m.TRIANGLES,y,ai.disabled,g,ei.backCCW,C,S,R,"terrain",c.vertexBuffer,c.indexBuffer,c.segments)}}function co(e,l){if(!l.mesh){const d=new c.aW;d.emplaceBack(-1,-1),d.emplaceBack(1,-1),d.emplaceBack(1,1),d.emplaceBack(-1,1);const p=new c.aY;p.emplaceBack(0,1,2),p.emplaceBack(0,2,3),l.mesh=new kt(e.createVertexBuffer(d,Ni.members),e.createIndexBuffer(p),c.aX.simpleSegment(0,0,d.length,p.length))}return l.mesh}class Wo{constructor(e,l){this.context=new no(e),this.transform=l,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:c.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,l,c){if(this.width=Math.floor(e*c),this.height=Math.floor(l*c),this.pixelRatio=c,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,l=new c.aW;l.emplaceBack(0,0),l.emplaceBack(c.a5,0),l.emplaceBack(0,c.a5),l.emplaceBack(c.a5,c.a5),this.tileExtentBuffer=e.createVertexBuffer(l,Ni.members),this.tileExtentSegments=c.aX.simpleSegment(0,0,4,2);const d=new c.aW;d.emplaceBack(0,0),d.emplaceBack(c.a5,0),d.emplaceBack(0,c.a5),d.emplaceBack(c.a5,c.a5),this.debugBuffer=e.createVertexBuffer(d,Ni.members),this.debugSegments=c.aX.simpleSegment(0,0,4,5);const p=new c.ch;p.emplaceBack(0,0,0,0),p.emplaceBack(c.a5,0,c.a5,0),p.emplaceBack(0,c.a5,0,c.a5),p.emplaceBack(c.a5,c.a5,c.a5,c.a5),this.rasterBoundsBuffer=e.createVertexBuffer(p,ln.members),this.rasterBoundsSegments=c.aX.simpleSegment(0,0,4,2);const f=new c.aW;f.emplaceBack(0,0),f.emplaceBack(c.a5,0),f.emplaceBack(0,c.a5),f.emplaceBack(c.a5,c.a5),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(f,Ni.members),this.rasterBoundsSegmentsPosOnly=c.aX.simpleSegment(0,0,4,5);const m=new c.aW;m.emplaceBack(0,0),m.emplaceBack(1,0),m.emplaceBack(0,1),m.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(m,Ni.members),this.viewportSegments=c.aX.simpleSegment(0,0,4,2);const _=new c.ci;_.emplaceBack(0),_.emplaceBack(1),_.emplaceBack(3),_.emplaceBack(2),_.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(_);const g=new c.aY;g.emplaceBack(1,0,2),g.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(g);const y=this.context.gl;this.stencilClearMode=new ai({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO),this.tileExtentMesh=new kt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,l=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const d=c.N();c.c7(d,0,this.width,this.height,0,0,1),c.Q(d,d,[l.drawingBufferWidth,l.drawingBufferHeight,0]);const p={mainMatrix:d,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:d};this.useProgram("clippingMask",null,!0).draw(e,l.TRIANGLES,ti.disabled,this.stencilClearMode,Qt.disabled,ei.disabled,null,null,p,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,l,c){if(this.currentStencilSource===e.source||!e.isTileClipped()||!l||!l.length)return;this.currentStencilSource=e.source,this.nextStencilID+l.length>256&&this.clearStencil();const d=this.context;d.setColorMode(Qt.disabled),d.setDepthMode(ti.disabled);const p={};for(const e of l)p[e.key]=this.nextStencilID++;this._renderTileMasks(p,l,c,!0),this._renderTileMasks(p,l,c,!1),this._tileClippingMaskIDs=p}_renderTileMasks(e,l,c,d){const p=this.context,f=p.gl,m=this.style.projection,_=this.transform,g=this.useProgram("clippingMask");for(const y of l){const l=e[y.key],b=this.style.map.terrain&&this.style.map.terrain.getTerrainData(y),T=m.getMeshFromTileID(this.context,y.canonical,d,!0,"stencil"),S=_.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!c,applyTerrainMatrix:!0});g.draw(p,f.TRIANGLES,ti.disabled,new ai({func:f.ALWAYS,mask:0},l,255,f.KEEP,f.KEEP,f.REPLACE),Qt.disabled,c?ei.disabled:ei.backCCW,null,b,S,"$clipping",T.vertexBuffer,T.indexBuffer,T.segments)}}_renderTilesDepthBuffer(){const e=this.context,l=e.gl,c=this.style.projection,d=this.transform,p=this.useProgram("depth"),f=this.getDepthModeFor3D(),m=it(d,{tileSize:d.tileSize});for(const _ of m){const m=this.style.map.terrain&&this.style.map.terrain.getTerrainData(_),g=c.getMeshFromTileID(this.context,_.canonical,!0,!0,"raster"),y=d.getProjectionData({overscaledTileID:_,applyGlobeMatrix:!0,applyTerrainMatrix:!0});p.draw(e,l.TRIANGLES,f,ai.disabled,Qt.disabled,ei.backCCW,null,m,y,"$clipping",g.vertexBuffer,g.indexBuffer,g.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,l=this.context.gl;return new ai({func:l.NOTEQUAL,mask:255},e,255,l.KEEP,l.KEEP,l.REPLACE)}stencilModeForClipping(e){const l=this.context.gl;return new ai({func:l.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,l.KEEP,l.KEEP,l.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const l=this.context.gl,c=e.sort(((e,l)=>l.overscaledZ-e.overscaledZ)),d=c[c.length-1].overscaledZ,p=c[0].overscaledZ-d+1;if(p>1){this.currentStencilSource=void 0,this.nextStencilID+p>256&&this.clearStencil();const e={};for(let c=0;cl.overscaledZ-e.overscaledZ)),d=c[c.length-1].overscaledZ,p=c[0].overscaledZ-d+1;if(this.clearStencil(),p>1){const e={},f={};for(let c=0;c0};for(const e in m){const l=m[e];l.used&&l.prepare(this.context),_[e]=l.getVisibleCoordinates(!1),g[e]=_[e].slice().reverse(),y[e]=l.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:l.showOverdrawInspector?c.bp.black:c.bp.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,l){const c=e.context,d=c.gl,p=((e,l,c)=>{const d=Math.cos(l.rollInRadians),p=Math.sin(l.rollInRadians),f=Ne(l),m=l.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:[(l.width/2-f*p)*c,(l.height/2+f*d)*c],u_horizon_normal:[-p,d],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*l.height/2*c,u_sky_blend:m}})(l,e.style.map.transform,e.pixelRatio),f=new ti(d.LEQUAL,ti.ReadWrite,[0,1]),m=ai.disabled,_=e.colorModeForRenderPass(),g=e.useProgram("sky"),y=co(c,l);g.draw(c,d.TRIANGLES,f,m,_,ei.disabled,p,null,void 0,"sky",y.vertexBuffer,y.indexBuffer,y.segments)}(this,this.style.sky),this._showOverdrawInspector=l.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=f.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[f[this.currentLayer]],l=m[e.source],c=_[e.source];this._renderTileClippingMasks(e,c,!1),this.renderLayer(this,l,e,c,T)}this.renderPass="translucent";let S=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:l,u_globe_position:c,u_globe_radius:d,u_inv_proj_matrix:p}))(y,T,[I[0],I[1],I[2]],S,P),R=co(p,l);m.draw(p,f.TRIANGLES,_,ai.disabled,Qt.alphaBlended,ei.disabled,C,null,null,"atmosphere",R.vertexBuffer,R.indexBuffer,R.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,l){let c=null;const d=Object.values(e._layers).flatMap((c=>c.source&&!c.isHidden(l)?[e.tileManagers[c.source]]:[])),p=d.filter((e=>"vector"===e.getSource().type)),f=d.filter((e=>"vector"!==e.getSource().type)),m=e=>{(!c||c.getSource().maxzoomm(e))),c||f.forEach((e=>m(e))),c}(this.style,this.transform.zoom);e&&function(e,l,c){for(let d=0;dT.getElevation(f,e,l):null;es(m,S,P,y,b,R,l,I,L,c.aO(b,e,_,g),f.toUnwrapped(),d)}}}(p,e,d,l,d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),f),0!==d.paint.get("icon-opacity").constantOr(1)&&ss(e,l,d,p,!1,d.paint.get("icon-translate"),d.paint.get("icon-translate-anchor"),d.layout.get("icon-rotation-alignment"),d.layout.get("icon-pitch-alignment"),d.layout.get("icon-keep-upright"),g,y,_),0!==d.paint.get("text-opacity").constantOr(1)&&ss(e,l,d,p,!0,d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),d.layout.get("text-keep-upright"),g,y,_),l.map.showCollisionBoxes&&(Yn(e,l,d,p,!0),Yn(e,l,d,p,!1))}(e,l,d,p,this.style.placement.variableOffsets,f):c.cn(d)?function(e,l,d,p,f){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:m}=f,_=d.paint.get("circle-opacity"),g=d.paint.get("circle-stroke-width"),y=d.paint.get("circle-stroke-opacity"),b=!d.layout.get("circle-sort-key").isConstant();if(0===_.constantOr(1)&&(0===g.constantOr(1)||0===y.constantOr(1)))return;const T=e.context,S=T.gl,P=e.transform,I=e.getDepthModeForSublayer(0,ti.ReadOnly),C=ai.disabled,R=e.colorModeForRenderPass(),L=[],F=P.getCircleRadiusCorrection();for(let f=0;fe.sortKey-l.sortKey));for(const l of L){const{programConfiguration:c,program:p,layoutVertexBuffer:f,indexBuffer:m,uniformValues:_,terrainData:g,projectionData:y}=l.state;p.draw(T,S.TRIANGLES,I,C,R,ei.backCCW,_,g,y,d.id,f,m,l.segments,d.paint,e.transform.zoom,c)}}(e,l,d,p,f):c.co(d)?function(e,l,d,p,f){if(0===d.paint.get("heatmap-opacity"))return;const m=e.context,{isRenderingToTexture:_,isRenderingGlobe:g}=f;if(e.style.map.terrain){for(const c of p){const p=l.getTile(c);l.hasRenderableParent(c)||("offscreen"===e.renderPass?ls(e,p,d,c,g):"translucent"===e.renderPass&&us(e,d,c,_,g))}m.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,l,d,p){const f=e.context,m=f.gl,_=e.transform,g=ai.disabled,y=new Qt([m.ONE,m.ONE],c.bp.transparent,[!0,!0,!0,!0]);(function(e,l,d){const p=e.gl;e.activeTexture.set(p.TEXTURE1),e.viewport.set([0,0,l.width/4,l.height/4]);let f=d.heatmapFbos.get(c.cd);f?(p.bindTexture(p.TEXTURE_2D,f.colorAttachment.get()),e.bindFramebuffer.set(f.framebuffer)):(f=ds(e,l.width/4,l.height/4),d.heatmapFbos.set(c.cd,f))})(f,e,d),f.clear({color:c.bp.transparent});for(let c=0;c0?l.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const l=this.imageManager.getPattern(e.from.toString()),c=this.imageManager.getPattern(e.to.toString());return!l||!c}useProgram(e,l,c=!1,d=[]){this.cache=this.cache||{};const p=!!this.style.map.terrain,f=this.style.projection,m=c?Vi.projectionMercator:f.shaderPreludeCode,_=c?Gi:f.shaderDefine,g=e+(l?l.cacheKey:"")+`/${c?Ui:f.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(p?"/terrain":"")+(d?`/${d.join("/")}`:"");return this.cache[g]||(this.cache[g]=new Zi(this.context,Vi[e],l,$n[e],this._showOverdrawInspector,p,m,_,d)),this.cache[g]}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 c.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,l;if(this._tileTextures){for(const e in this._tileTextures){const l=this._tileTextures[e];if(l)for(const e of l)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===(l=this.tileExtentMesh.indexBuffer)||void 0===l||l.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const l=this.cache[e];l&&l.program&&this.context.gl.deleteProgram(l.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:l}=this.context.gl;return this.width!==e||this.height!==l}}function ho(l,c){let d,p=!1,f=null,m=null;const _=()=>{f=null,p&&(l.apply(m,d),f=setTimeout(_,c),p=!1)};return(...l)=>(p=!0,m=this||e,d=l,f||_(),f)}class Ho{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let l;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(l=e)})),(l&&l[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const l=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:l,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 l=e.join("/");let c=l;c.split("&").length>0&&(c=c.split("&")[0]),this._hashName&&(c=`${this._hashName}=${l}`);let d=window.location.hash.replace(c,"");d.startsWith("#&")?d=d.slice(0,1)+d.slice(2):"#"===d&&(d="");let p=window.location.href.replace(/(#.+)?$/,d);p=p.replace("&&","&"),window.history.replaceState(window.history.state,null,p)},this._updateHash=ho(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 l=this._map.getCenter(),c=Math.round(100*this._map.getZoom())/100,d=Math.ceil((c*Math.LN2+Math.log(512/360/.5))/Math.LN10),p=Math.pow(10,d),f=Math.round(l.lng*p)/p,m=Math.round(l.lat*p)/p,_=this._map.getBearing(),g=this._map.getPitch();let y="";if(y+=e?`/${f}/${m}/${c}`:`${c}/${m}/${f}`,(_||g)&&(y+="/"+Math.round(10*_)/10),g&&(y+=`/${Math.round(g)}`),this._hashName){const e=this._hashName;let l=!1;const c=window.location.hash.slice(1).split("&").map((c=>{const d=c.split("=")[0];return d===e?(l=!0,`${d}=${y}`):c})).filter((e=>e));return l||c.push(`${e}=${y}`),`#${c.join("&")}`}return`#${y}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new c.V(+e[2],+e[1])}catch(e){return!1}const l=+e[0],d=+(e[3]||0),p=+(e[4]||0);return l>=this._map.getMinZoom()&&l<=this._map.getMaxZoom()&&d>=-180&&d<=180&&p>=this._map.getMinPitch()&&p<=this._map.getMaxPitch()}}const uo={linearity:.3,easing:c.cw(0,0,.3,1)},po=c.e({deceleration:2500,maxSpeed:1400},uo),fo=c.e({deceleration:20,maxSpeed:1400},uo),mo=c.e({deceleration:1e3,maxSpeed:360},uo),yo=c.e({deceleration:1e3,maxSpeed:90},uo),xo=c.e({deceleration:1e3,maxSpeed:360},uo);class tr{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:b(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,l=b();for(;e.length>0&&l-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const l={zoom:0,bearing:0,pitch:0,roll:0,pan:new c.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)l.zoom+=e.zoomDelta||0,l.bearing+=e.bearingDelta||0,l.pitch+=e.pitchDelta||0,l.roll+=e.rollDelta||0,e.panDelta&&l.pan._add(e.panDelta),e.around&&(l.around=e.around),e.pinchAround&&(l.pinchAround=e.pinchAround);const d=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,p={};if(l.pan.mag()){const f=bo(l.pan.mag(),d,c.e({},po,e||{})),m=l.pan.mult(f.amount/l.pan.mag()),_=this._map.cameraHelper.handlePanInertia(m,this._map.transform);p.center=_.easingCenter,p.offset=_.easingOffset,vo(p,f)}if(l.zoom){const e=bo(l.zoom,d,fo),f=c.cx(this._map.transform.zoom+e.amount,this._map.getZoomSnap(),e.amount);p.zoom=f,vo(p,e)}if(l.bearing){const e=bo(l.bearing,d,mo);p.bearing=this._map.transform.bearing+c.an(e.amount,-179,179),vo(p,e)}if(l.pitch){const e=bo(l.pitch,d,yo);p.pitch=this._map.transform.pitch+e.amount,vo(p,e)}if(l.roll){const e=bo(l.roll,d,xo);p.roll=this._map.transform.roll+c.an(e.amount,-179,179),vo(p,e)}if(p.zoom||p.bearing){const e=void 0===l.pinchAround?l.around:l.pinchAround;p.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),c.e(p,{noMoveStart:!0})}}function vo(e,l){(!e.duration||e.durationl.unproject(e))),_=f.reduce(((e,l,c,d)=>e.add(l.div(d.length))),new c.P(0,0));super(e,{points:f,point:_,lngLats:m,lngLat:l.unproject(_),originalEvent:d}),this._defaultPrevented=!1}}class sr extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,l,c){super(e,{originalEvent:c}),this._defaultPrevented=!1}}class nr{constructor(e,l){this._map=e,this._clickTolerance=l.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new sr(e.type,this._map,e))}mousedown(e,l){return this._mousedownPos=l,this._firePreventable(new or(e.type,this._map,e))}mouseup(e){this._map.fire(new or(e.type,this._map,e))}click(e,l){this._mousedownPos&&this._mousedownPos.dist(l)>=this._clickTolerance||this._map.fire(new or(e.type,this._map,e))}dblclick(e){return this._firePreventable(new or(e.type,this._map,e))}mouseover(e){this._map.fire(new or(e.type,this._map,e))}mouseout(e){this._map.fire(new or(e.type,this._map,e))}touchstart(e){return this._firePreventable(new rr(e.type,this._map,e))}touchmove(e){this._map.fire(new rr(e.type,this._map,e))}touchend(e){this._map.fire(new rr(e.type,this._map,e))}touchcancel(e){this._map.fire(new rr(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class lr{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new or(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new or("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new or(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cr{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(c.P.convert(e),this._map.terrain)}}class hr{constructor(e,l){this._map=e,this._tr=new cr(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=l.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,l){this.isEnabled()&&e.shiftKey&&0===e.button&&(h.disableDrag(),this._startPos=this._lastPos=l,this._active=!0)}mousemoveWindow(e,l){if(!this._active)return;const c=l;if(this._lastPos.equals(c)||!this._box&&c.dist(this._startPos)e.fitScreenCoordinates(d,p,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,l){return this._map.fire(new c.l(e,{originalEvent:l}))}}function Eo(e,l){if(e.length!==l.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${l.length}`);const c={};for(let d=0;dthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),d.length===this.numTouches&&(this.centroid=function(e){const l=new c.P(0,0);for(const c of e)l._add(c);return l.div(e.length)}(l),this.touches=Eo(d,l)))}touchmove(e,l,c){if(this.aborted||!this.centroid)return;const d=Eo(c,l);for(const e in this.touches){const l=d[e];(!l||l.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,l,c){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===c.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class _r{constructor(e){this.singleTap=new dr(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,l,c){this.singleTap.touchstart(e,l,c)}touchmove(e,l,c){this.singleTap.touchmove(e,l,c)}touchend(e,l,c){const d=this.singleTap.touchend(e,l,c);if(d){const l=e.timeStamp-this.lastTime<500,c=!this.lastTap||this.lastTap.dist(d)<30;if(l&&c||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=d,this.count===this.numTaps)return this.reset(),d}}}class pr{constructor(e){this._tr=new cr(e),this._zoomIn=new _r({numTouches:1,numTaps:2}),this._zoomOut=new _r({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,l,c){this._zoomIn.touchstart(e,l,c),this._zoomOut.touchstart(e,l,c)}touchmove(e,l,c){this._zoomIn.touchmove(e,l,c),this._zoomOut.touchmove(e,l,c)}touchend(e,l,d){const p=this._zoomIn.touchend(e,l,d),f=this._zoomOut.touchend(e,l,d),m=this._tr;return p?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:l=>l.easeTo({duration:300,zoom:c.cx(m.zoom+1,l.getZoomSnap()),around:m.unproject(p)},{originalEvent:e})}):f?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:l=>l.easeTo({duration:300,zoom:c.cx(m.zoom-1,l.getZoomSnap()),around:m.unproject(f)},{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 mr{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 l=this._moveFunction(...e);if(l.bearingDelta||l.pitchDelta||l.rollDelta||l.around||l.panDelta)return this._active=!0,l}dragStart(e,l){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(l)?l[0]:l,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,l){if(!this.isEnabled())return;const c=this._lastPoint;if(!c)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const d=Array.isArray(l)?l[0]:l;return!this._moved&&d.dist(c)!0}),l=new br){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=l}_executeRelevantHandler(e,l,c){return e instanceof MouseEvent?l(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?c(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 Lo=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class Tr{constructor(e,l){this._clickTolerance=e.clickTolerance||1,this._map=l,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new c.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,l,c){return this._calculateTransform(e,l,c)}touchmove(e,l,c){if(this._active){if(!this._shouldBePrevented(c.length))return e.preventDefault(),this._calculateTransform(e,l,c);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,l,c){this._calculateTransform(e,l,c),this._active&&this._shouldBePrevented(c.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,l,d){d.length>0&&(this._active=!0);const p=Eo(d,l),f=new c.P(0,0),m=new c.P(0,0);let _=0;for(const e in p){const l=p[e],c=this._touches[e];c&&(f._add(l),m._add(l.sub(c)),_++,p[e]=l)}if(this._touches=p,this._shouldBePrevented(_)||!m.mag())return;const g=m.div(_);return this._sum._add(g),this._sum.mag()Math.abs(e.x)}class Rr extends Pr{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,l,c){super.touchstart(e,l,c),this._currentTouchCount=c.length}_start(e){this._lastPoints=e,Uo(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,l,c){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const d=e[0].sub(this._lastPoints[0]),p=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(d,p,c.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(d.y+p.y)/2*-.5}):void 0}gestureBeginsVertically(e,l,c){if(void 0!==this._valid)return this._valid;const d=e.mag()>=2,p=l.mag()>=2;if(!d&&!p)return;if(!d||!p)return void 0===this._firstMove&&(this._firstMove=c),c-this._firstMove<100&&void 0;const f=e.y>0==l.y>0;return Uo(e)&&Uo(l)&&f}}const qo={panStep:100,bearingStep:15,pitchStep:10};class Ar{constructor(e){this._tr=new cr(e);const l=qo;this._panStep=l.panStep,this._bearingStep=l.bearingStep,this._pitchStep=l.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let l=0,d=0,p=0,f=0,m=0;switch(e.keyCode){case 61:case 107:case 171:case 187:l=1;break;case 189:case 109:case 173:l=-1;break;case 37:e.shiftKey?d=-1:(e.preventDefault(),f=-1);break;case 39:e.shiftKey?d=1:(e.preventDefault(),f=1);break;case 38:e.shiftKey?p=1:(e.preventDefault(),m=-1);break;case 40:e.shiftKey?p=-1:(e.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(d=0,p=0),{cameraAnimation:_=>{const g=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:Zo,zoom:l?c.cx(g.zoom+l*(e.shiftKey?2:1),_.getZoomSnap()):g.zoom,bearing:g.bearing+d*this._bearingStep,pitch:g.pitch+p*this._pitchStep,offset:[-f*this._panStep,-m*this._panStep],center:g.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 Zo(e){return e*(2-e)}const $o=4.000244140625,Xo=1/450;class Br{constructor(e,l){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new cr(e),this._triggerRenderFrame=l,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Xo}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 l=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const c=b(),d=c-(this._lastWheelEventTime||0);this._lastWheelEventTime=c,0!==l&&l%$o==0?this._type="wheel":0!==l&&Math.abs(l)<4?this._type="trackpad":d>400?(this._type=null,this._lastValue=l,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(d*l)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,l+=this._lastValue)),e.shiftKey&&l&&(l/=4),this._type&&(this._lastWheelEvent=e,this._delta-=l,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 l=h.mousePos(this._map.getCanvas(),e),d=this._tr;this._aroundPoint=this._aroundCenter?d.transform.locationToScreenPoint(c.V.convert(d.center)):l,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 l=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=l),"number"==typeof this._targetZoom&&(this._targetZoom+=l)}if(0!==this._delta){const l="wheel"===this._type&&Math.abs(this._delta)>$o?this._wheelZoomRate:this._defaultZoomRate;let d=2/(1+Math.exp(-Math.abs(this._delta*l)));this._delta<0&&0!==d&&(d=1/d);const p="number"!=typeof this._targetZoom?e.scale:c.aq(this._targetZoom),f=e.applyConstrain(e.getCameraLngLat(),c.at(p*d)).zoom,m=this._map.getZoomSnap();if("wheel"===this._type&&m>0){const l=c.cx(e.zoom,m);this._targetZoom=c.cx(f,m,f-l)}else this._targetZoom=f;"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const l="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,d=this._startZoom,p=this._easing;let f,m=!1;if("wheel"===this._type&&d&&p){const e=b()-this._lastWheelEventTime,_=Math.min((e+5)/200,1),g=p(_);f=c.G.number(d,l,g),_<1?this._frameId||(this._frameId=!0):m=!0}else f=l,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=f,{noInertia:!0,needsRenderFrame:!m,zoomDelta:f-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let l=c.cz;if(this._prevEase){const e=this._prevEase,d=(b()-e.start)/e.duration,p=e.easing(d+.01)-e.easing(d),f=.27/Math.sqrt(p*p+1e-4)*.01,m=Math.sqrt(.0729-f*f);l=c.cw(f,m,.25,1)}return this._prevEase={start:b(),duration:e,easing:l},l}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Or{constructor(e,l){this._clickZoom=e,this._tapZoom=l}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 jr{constructor(e){this._tr=new cr(e),this.reset()}reset(){this._active=!1}dblclick(e,l){return e.preventDefault(),{cameraAnimation:d=>{d.easeTo({duration:300,zoom:c.cx(this._tr.zoom+(e.shiftKey?-1:1),d.getZoomSnap()),around:this._tr.unproject(l)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Nr{constructor(){this._tap=new _r({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,l,c){if(!this._swipePoint)if(this._tapTime){const d=l[0],p=e.timeStamp-this._tapTime<500,f=this._tapPoint.dist(d)<30;p&&f?c.length>0&&(this._swipePoint=d,this._swipeTouch=c[0].identifier):this.reset()}else this._tap.touchstart(e,l,c)}touchmove(e,l,c){if(this._tapTime){if(this._swipePoint){if(c[0].identifier!==this._swipeTouch)return;const d=l[0],p=d.y-this._swipePoint.y;return this._swipePoint=d,e.preventDefault(),this._active=!0,{zoomDelta:p/128}}}else this._tap.touchmove(e,l,c)}touchend(e,l,c){if(this._tapTime)this._swipePoint&&0===c.length&&this.reset();else{const d=this._tap.touchend(e,l,c);d&&(this._tapTime=e.timeStamp,this._tapPoint=d)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Zr{constructor(e,l,c){this._el=e,this._mousePan=l,this._touchPan=c}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 Ur{constructor(e,l,c,d){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=l,this._mousePitch=c,this._mouseRoll=d}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 Gr{constructor(e,l,c,d){this._el=e,this._touchZoom=l,this._touchRotate=c,this._tapDragZoom=d,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 Vr{constructor(e,l){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=l,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 l=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(l=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const c=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),d=document.createElement("div");d.className="maplibregl-desktop-message",d.textContent=l,this._container.appendChild(d);const p=document.createElement("div");p.className="maplibregl-mobile-message",p.textContent=c,this._container.appendChild(p),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,l){this._enabled&&(this._map.fire(new c.l("cooperativegestureprevented",{gestureType:e,originalEvent:l})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const Yo=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Wr extends c.l{}function Ko(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Hr{get _ownerDocument(){var e;return(null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||document}get _ownerWindow(){var e,l;return(null===(l=null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||void 0===l?void 0:l.defaultView)||window}constructor(e,l){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,l)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const d="renderFrame"===e.type?void 0:e,p={needsRenderFrame:!1},f={},m={};for(const{handlerName:_,handler:g,allowed:y}of this._handlers){if(!g.isEnabled())continue;let b;if(this._blockedByActive(m,y,_))g.reset();else if(g[l||e.type]){if(c.cA(e,l||e.type)){const c=h.mousePos(this._map.getCanvas(),e);b=g[l||e.type](e,c)}else if(c.cB(e,l||e.type)){const c=this._getMapTouches(e.touches),d=h.touchPos(this._map.getCanvas(),c);b=g[l||e.type](e,d,c)}else c.cC(l||e.type)||(b=g[l||e.type](e));this.mergeHandlerResult(p,f,b,_,d),b&&b.needsRenderFrame&&this._triggerRenderFrame()}(b||g.isActive())&&(m[_]=g)}const _={};for(const e in this._previousActiveHandlers)m[e]||(_[e]=d);this._previousActiveHandlers=m,(Object.keys(_).length||Ko(p))&&(this._changes.push([p,f,_]),this._triggerRenderFrame()),(Object.keys(m).length||Ko(p))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:g}=p;g&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],g(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new tr(e),this._bearingSnap=l.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(l);const d=this._el;this._listeners=[[d,"touchstart",{passive:!0}],[d,"touchmove",{passive:!1}],[d,"touchend",void 0],[d,"touchcancel",void 0],[d,"mousedown",void 0],[d,"mousemove",void 0],[d,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[d,"mouseover",void 0],[d,"mouseout",void 0],[d,"dblclick",void 0],[d,"click",void 0],[d,"keydown",{capture:!1}],[d,"keyup",void 0],[d,"wheel",{passive:!1}],[d,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(const[e,l,c]of this._listeners)h.addEventListener(e,l,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,c)}destroy(){for(const[e,l,c]of this._listeners)h.removeEventListener(e,l,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,c)}_addDefaultHandlers(e){const l=this._map,d=l.getCanvasContainer();this._add("mapEvent",new nr(l,e));const p=l.boxZoom=new hr(l,e);this._add("boxZoom",p),e.interactive&&e.boxZoom&&p.enable();const f=l.cooperativeGestures=new Vr(l,e.cooperativeGestures);this._add("cooperativeGestures",f),e.cooperativeGestures&&f.enable();const m=new pr(l),_=new jr(l);l.doubleClickZoom=new Or(_,m),this._add("tapZoom",m),this._add("clickZoom",_),e.interactive&&e.doubleClickZoom&&l.doubleClickZoom.enable();const g=new Nr;this._add("tapDragZoom",g);const y=l.touchPitch=new Rr(l);this._add("touchPitch",y),e.interactive&&e.touchPitch&&l.touchPitch.enable(e.touchPitch);const b=()=>l.project(l.getCenter()),T=function({enable:e,clickTolerance:l,aroundCenter:d=!0,minPixelCenterThreshold:p=100,rotateDegreesPerPixelMoved:f=.8},m){const _=new xr({checkCorrectEvent:e=>0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)&&!e.ctrlKey});return new mr({clickTolerance:l,move:(e,l)=>{const _=m();if(d&&Math.abs(_.y-e.y)>p)return{bearingDelta:c.cy(new c.P(e.x,l.y),l,_)};let g=(l.x-e.x)*f;return d&&l.y<_.y&&(g=-g),{bearingDelta:g}},moveStateManager:_,enable:e,assignEvents:Lo})}(e,b),S=function({enable:e,clickTolerance:l,pitchDegreesPerPixelMoved:c=-.5}){const d=new xr({checkCorrectEvent:e=>0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)});return new mr({clickTolerance:l,move:(e,l)=>({pitchDelta:(l.y-e.y)*c}),moveStateManager:d,enable:e,assignEvents:Lo})}(e),P=function({enable:e,clickTolerance:l,rollDegreesPerPixelMoved:c=.3},d){const p=new xr({checkCorrectEvent:e=>2===h.mouseButton(e)&&e.ctrlKey});return new mr({clickTolerance:l,move:(e,l)=>{const p=d();let f=(l.x-e.x)*c;return l.y0===h.mouseButton(e)&&!e.ctrlKey});return new mr({clickTolerance:l,move:(e,l)=>({around:l,panDelta:l.sub(e)}),activateOnStart:!0,moveStateManager:c,enable:e,assignEvents:Lo})}(e),C=new Tr(e,l);l.dragPan=new Zr(d,I,C),this._add("mousePan",I),this._add("touchPan",C,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&l.dragPan.enable(e.dragPan);const R=new Sr,L=new Mr;l.touchZoomRotate=new Gr(d,L,R,g),this._add("touchRotate",R,["touchPan","touchZoom"]),this._add("touchZoom",L,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&l.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new lr(l));const F=l.scrollZoom=new Br(l,(()=>this._triggerRenderFrame()));this._add("scrollZoom",F,["mousePan"]),e.interactive&&e.scrollZoom&&l.scrollZoom.enable(e.scrollZoom);const B=l.keyboard=new Ar(l);this._add("keyboard",B),e.interactive&&e.keyboard&&l.keyboard.enable()}_add(e,l,c){this._handlers.push({handlerName:e,handler:l,allowed:c}),this._handlersById[e]=l}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(Yo(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,l,c){for(const d in e)if(d!==c&&(!l||l.indexOf(d)<0))return!0;return!1}_getMapTouches(e){const l=[];for(const c of e)this._el.contains(c.target)&&l.push(c);return l}mergeHandlerResult(e,l,d,p,f){if(!d)return;c.e(e,d);const m={handlerName:p,originalEvent:d.originalEvent||f};void 0!==d.zoomDelta&&(l.zoom=m),void 0!==d.panDelta&&(l.drag=m),void 0!==d.rollDelta&&(l.roll=m),void 0!==d.pitchDelta&&(l.pitch=m),void 0!==d.bearingDelta&&(l.rotate=m)}_applyChanges(){const e={},l={},d={};for(const[p,f,m]of this._changes)p.panDelta&&(e.panDelta=(e.panDelta||new c.P(0,0))._add(p.panDelta)),p.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+p.zoomDelta),p.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+p.bearingDelta),p.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+p.pitchDelta),p.rollDelta&&(e.rollDelta=(e.rollDelta||0)+p.rollDelta),void 0!==p.around&&(e.around=p.around),void 0!==p.pinchAround&&(e.pinchAround=p.pinchAround),p.noInertia&&(e.noInertia=p.noInertia),c.e(l,f),c.e(d,m);this._updateMapTransform(e,l,d),this._changes=[]}_updateMapTransform(e,l,c){const d=this._map,p=d._getTransformForUpdate(),f=d.terrain;if(!(Ko(e)||f&&this._terrainMovement))return this._fireEvents(l,c,!0);d._stop(!0);let{panDelta:m,zoomDelta:_,bearingDelta:g,pitchDelta:y,rollDelta:b,around:T,pinchAround:S}=e;void 0!==S&&(T=S),T=T||d.transform.centerPoint,f&&!p.isPointOnMapSurface(T)&&(T=p.centerPoint);const P={panDelta:m,zoomDelta:_,rollDelta:b,pitchDelta:y,bearingDelta:g,around:T};this._map.cameraHelper.useGlobeControls&&!p.isPointOnMapSurface(T)&&(T=p.centerPoint);const I=T.distSqr(p.centerPoint)<.01?p.center:p.screenPointToLocation(m?T.sub(m):T);this._handleMapControls({terrain:f,tr:p,deltasForHelper:P,preZoomAroundLoc:I,combinedEventsInProgress:l,panDelta:m}),d._applyUpdatedTransform(p),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(l,c,!0)}_handleMapControls({terrain:e,tr:l,deltasForHelper:c,preZoomAroundLoc:d,combinedEventsInProgress:p,panDelta:f}){const m=this._map.cameraHelper;if(m.handleMapControlsRollPitchBearingZoom(c,l),e)return m.useGlobeControls?(this._terrainMovement||!p.drag&&!p.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void m.handleMapControlsPan(c,l,d)):this._terrainMovement||!p.drag&&!p.zoom?void(p.drag&&this._terrainMovement&&f?l.setCenter(l.screenPointToLocation(l.centerPoint.sub(f))):m.handleMapControlsPan(c,l,d)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void m.handleMapControlsPan(c,l,d));m.handleMapControlsPan(c,l,d)}_fireEvents(e,l,d){const p=Yo(this._eventsInProgress),f=Yo(e),m={};for(const l in e){const{originalEvent:c}=e[l];this._eventsInProgress[l]||(m[`${l}start`]=c),this._eventsInProgress[l]=e[l]}!p&&f&&this._fireEvent("movestart",f.originalEvent);for(const e in m)this._fireEvent(e,m[e]);f&&this._fireEvent("move",f.originalEvent);for(const l in e){const{originalEvent:c}=e[l];this._fireEvent(l,c)}const _={};let y;for(const e in this._eventsInProgress){const{handlerName:c,originalEvent:d}=this._eventsInProgress[e];this._handlersById[c].isActive()||(delete this._eventsInProgress[e],y=l[c]||d,_[`${e}end`]=y)}for(const e in _)this._fireEvent(e,_[e]);const b=Yo(this._eventsInProgress),T=(p||f)&&!b;if(T&&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(d&&T){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),l=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Wr("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Xr extends c.E{constructor(e,l,c){super(),this._renderFrameCallback=()=>{const e=Math.min((b()-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=c.bearingSnap,this._zoomSnap=c.zoomSnap,this.cameraHelper=l,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(e,l){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=l}getCenter(){return new c.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,l){return this.jumpTo({center:e},l)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,l){return this.jumpTo({elevation:e},l),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,l,d){return e=c.P.convert(e).mult(-1),this.panTo(this.transform.center,c.e({offset:e},l),d)}panTo(e,l,d){return this.easeTo(c.e({center:e},l),d)}getZoom(){return this.transform.zoom}setZoom(e,l){return this.jumpTo({zoom:e},l),this}zoomTo(e,l,d){return this.easeTo(c.e({zoom:e},l),d)}zoomIn(e,l){return this.zoomTo(c.cx(this.getZoom()+1,this._zoomSnap),e,l),this}zoomOut(e,l){return this.zoomTo(c.cx(this.getZoom()-1,this._zoomSnap),e,l),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,l){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new c.l("movestart",l)).fire(new c.l("move",l)).fire(new c.l("moveend",l))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,l){return this.jumpTo({bearing:e},l),this}getPadding(){return this.transform.padding}setPadding(e,l){return this.jumpTo({padding:e},l),this}rotateTo(e,l,d){return this.easeTo(c.e({bearing:e},l),d)}resetNorth(e,l){return this.rotateTo(0,c.e({duration:1e3},e),l),this}resetNorthPitch(e,l){return this.easeTo(c.e({bearing:0,pitch:0,roll:0,duration:1e3},e),l),this}snapToNorth(e,l){return Math.abs(this.getBearing()){R.easeFunc(c),this.terrain&&!e.freezeElevation&&this._updateElevation(c),this._applyUpdatedTransform(d),this._fireMoveEvents(l)}),(c=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(l,c)}),e),this}_prepareEase(e,l,d={}){this._moving=!0,l||d.moving||this.fire(new c.l("movestart",e)),this._zooming&&!d.zooming&&this.fire(new c.l("zoomstart",e)),this._rotating&&!d.rotating&&this.fire(new c.l("rotatestart",e)),this._pitching&&!d.pitching&&this.fire(new c.l("pitchstart",e)),this._rolling&&!d.rolling&&this.fire(new c.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 l=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&l!==this._elevationTarget){const c=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(c-(l-(c*e+this._elevationStart))/(1-e)),this._elevationTarget=l}this.transform.setElevation(c.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 l=e.getCameraLngLat(),c=e.getCameraAltitude(),d=this.terrain?this.terrain.getElevationForLngLatZoom(l,e.zoom):0;if(cthis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&l.push((e=>this.transformCameraUpdate(e))),!l.length)return;const c=e.clone();for(const e of l){const l=c.clone(),{center:d,zoom:p,roll:f,pitch:m,bearing:_,elevation:g}=e(l);d&&l.setCenter(d),void 0!==g&&l.setElevation(g),void 0!==p&&l.setZoom(p),void 0!==f&&l.setRoll(f),void 0!==m&&l.setPitch(m),void 0!==_&&l.setBearing(_),c.apply(l,!1)}this.transform.apply(c,!1)}_fireMoveEvents(e){this.fire(new c.l("move",e)),this._zooming&&this.fire(new c.l("zoom",e)),this._rotating&&this.fire(new c.l("rotate",e)),this._pitching&&this.fire(new c.l("pitch",e)),this._rolling&&this.fire(new c.l("roll",e))}_afterEase(e,l){if(this._easeId&&l&&this._easeId===l)return;delete this._easeId;const d=this._zooming,p=this._rotating,f=this._pitching,m=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,d&&this.fire(new c.l("zoomend",e)),p&&this.fire(new c.l("rotateend",e)),f&&this.fire(new c.l("pitchend",e)),m&&this.fire(new c.l("rollend",e)),this.fire(new c.l("moveend",e))}flyTo(e,l){if(!e.essential&&g.prefersReducedMotion){const d=c.U(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(d,l)}this.stop(),e=c.e({offset:[0,0],speed:1.2,curve:1.42,easing:c.cz},e);const d=this._getTransformForUpdate(),p=d.bearing,f=d.pitch,m=d.roll,_=d.padding,y="bearing"in e?this._normalizeBearing(e.bearing,p):p,b="pitch"in e?+e.pitch:f,T="roll"in e?this._normalizeBearing(e.roll,m):m,S="padding"in e?e.padding:d.padding,P=c.P.convert(e.offset);let I=d.centerPoint.add(P);const C=d.screenPointToLocation(I),R=this.cameraHelper.handleFlyTo(d,{bearing:y,pitch:b,roll:T,padding:S,locationAtOffset:C,offsetAsPoint:P,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let L=e.curve;const F=Math.max(d.width,d.height),B=F/R.scaleOfZoom,O=R.pixelPathLength;"number"==typeof R.scaleOfMinZoom&&(L=Math.sqrt(F/R.scaleOfMinZoom/O*2));const V=L*L;function j(e){const l=(B*B-F*F+(e?-1:1)*V*V*O*O)/(2*(e?B:F)*V*O);return Math.log(Math.sqrt(l*l+1)-l)}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+L*e)},W=function(e){return F*((U(q)*(G(l=q+L*e)/U(l))-G(q))/V)/O;var l},Q=(j(!0)-q)/L;if(Math.abs(O)<2e-6||!isFinite(Q)){if(Math.abs(F-B)<1e-6)return this.easeTo(e,l);const c=B0,Z=e=>Math.exp(c*L*e)}return e.duration="duration"in e?+e.duration:1e3*Q/("screenSpeed"in e?+e.screenSpeed/L:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=p!==y,this._pitching=b!==f,this._rolling=T!==m,this._padding=!d.isPaddingEqual(S),this._prepareEase(l,!1),this.terrain&&this._prepareElevation(R.targetCenter),this._ease((g=>{const C=g*Q,L=1/Z(C),F=W(C);this._rotating&&d.setBearing(c.G.number(p,y,g)),this._pitching&&d.setPitch(c.G.number(f,b,g)),this._rolling&&d.setRoll(c.G.number(m,T,g)),this._padding&&(d.interpolatePadding(_,S,g),I=d.centerPoint.add(P)),R.easeFunc(g,L,F,I),this.terrain&&!e.freezeElevation&&this._updateElevation(g),this._applyUpdatedTransform(d),this._fireMoveEvents(l)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(l)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,l){var c;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,l)}return e||null===(c=this.handlers)||void 0===c||c.stop(!1),this}_ease(e,l,c){!1===c.animate||0===c.duration?(e(1),l()):(this._easeStart=b(),this._easeOptions=c,this._onEaseFrame=e,this._onEaseEnd=l,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,l){e=c.W(e,-180,180);const d=Math.abs(e-l);return Math.abs(e-360-l)MapLibre'};class Yr{constructor(e=Qo){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,l){const c=this._map._getUIString(`AttributionControl.${l}`);e.title=c,e.setAttribute("aria-label",c)}_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 l=this._map.style.tileManagers;for(const c in l){const d=l[c];if(d.used||d.usedForTerrain){const l=d.getSource();l.attribution&&e.indexOf(l.attribution)<0&&e.push(l.attribution)}}e=e.filter((e=>String(e).trim())),e.sort(((e,l)=>e.length-l.length)),e=e.filter(((l,c)=>{for(let d=c+1;d=0)return!1;return!0}));const c=e.join(" | ");c!==this._attribHTML&&(this._attribHTML=c,e.length?(this._innerContainer.innerHTML=h.sanitize(c),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Qr{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const l=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&l.classList.add("maplibregl-compact"):l.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 l=h.create("a","maplibregl-ctrl-logo");return l.target="_blank",l.rel="noopener nofollow",l.href="https://maplibre.org/",l.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),l.setAttribute("rel","noopener nofollow"),this._container.appendChild(l),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 Jr{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const l=++this._id;return this._queue.push({callback:e,id:l,cancelled:!1}),l}remove(e){const l=this._currentlyRunning,c=l?this._queue.concat(l):this._queue;for(const l of c)if(l.id===e)return void(l.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const l=this._currentlyRunning=this._queue;this._queue=[];for(const c of l)if(!c.cancelled&&(c.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Jo=c.aU([{name:"a_pos3d",type:"Int16",components:3}]);class ts extends c.E{constructor(e){super(),this._lastTilesetChange=b(),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,l){this.tileManager.update(e,l),this._renderableTilesKeys=[];const d={};for(const p of it(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:l,calculateTileZoom:this.tileManager._source.calculateTileZoom}))d[p.key]=!0,this._renderableTilesKeys.push(p.key),this._tiles[p.key]||(p.terrainRttPosMatrix32f=new Float64Array(16),c.c7(p.terrainRttPosMatrix32f,0,c.a5,c.a5,0,0,1),this._tiles[p.key]=new de(p,this.tileSize),this._lastTilesetChange=b());for(const e in this._tiles)d[e]||delete this._tiles[e]}freeRtt(e){for(const l in this._tiles){const c=this._tiles[l];(!e||c.tileID.equals(e)||c.tileID.isChildOf(e)||e.isChildOf(c.tileID))&&(c.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,l){return l?this._getTerrainCoordsForTileRanges(e,l):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const l={};for(const d of this._renderableTilesKeys){const p=this._tiles[d].tileID,f=e.clone(),m=c.bk();if(p.canonical.equals(e.canonical))c.c7(m,0,c.a5,c.a5,0,0,1);else if(p.canonical.isChildOf(e.canonical)){const l=p.canonical.z-e.canonical.z,d=p.canonical.x-(p.canonical.x>>l<>l<>l;c.c7(m,0,_,_,0,0,1),c.O(m,m,[-d*_,-f*_,0])}else{if(!e.canonical.isChildOf(p.canonical))continue;{const l=e.canonical.z-p.canonical.z,d=e.canonical.x-(e.canonical.x>>l<>l<>l;c.c7(m,0,c.a5,c.a5,0,0,1),c.O(m,m,[d*_,f*_,0]),c.Q(m,m,[1/2**l,1/2**l,0])}}f.terrainRttPosMatrix32f=new Float32Array(m),l[d]=f}return l}_getTerrainCoordsForTileRanges(e,l){const d={};for(const p of this._renderableTilesKeys){const f=this._tiles[p].tileID;if(!this._isWithinTileRanges(f,l))continue;const m=e.clone(),_=c.bk();if(f.canonical.z===e.canonical.z){const l=e.canonical.x-f.canonical.x+e.wrap*(1<e.canonical.z){const l=f.canonical.z-e.canonical.z,d=f.canonical.x-(f.canonical.x>>l<>l<>l),g=e.canonical.y-(f.canonical.y>>l),y=c.a5>>l;c.c7(_,0,y,y,0,0,1),c.O(_,_,[-d*y+m*c.a5,-p*y+g*c.a5,0])}else{const l=e.canonical.z-f.canonical.z,d=e.canonical.x-(e.canonical.x>>l<>l<>l)-f.canonical.x,g=(e.canonical.y>>l)-f.canonical.y,y=c.a5<c.maxzoom&&(d=c.maxzoom),d=c.minzoom&&!(null==p?void 0:p.dem);)p=this.findTileInCaches(e.scaledTo(d--).key);return p}findTileInCaches(e){let l=this.tileManager.getTileByID(e);return l||(l=this.tileManager._outOfViewCache.getByKey(e),l)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,l){const c=l[e.canonical.z];return!!c&&(e.wrap>c.minWrap||e.wrap=c.minTileXWrapped&&e.canonical.x<=c.maxTileXWrapped&&e.canonical.y>=c.minTileY&&e.canonical.y<=c.maxTileY)}}class is{constructor(e,l,c){this._meshCache={},this.painter=e,this.tileManager=new ts(l),this.options=c,this.exaggeration="number"==typeof c.exaggeration?c.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,l,d,p=c.a5){var f;if(!(l>=0&&l=0&&dd&&(d=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,d)}getElevation(e,l,d,p=c.a5){return this.getDEMElevation(e,l,d,p)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const e=this.painter.context,l=new c.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new c.T(e,l,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new c.T(e,new c.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=c.ar([])}const l=this.tileManager.getSourceTile(e,!0);if(l&&l.dem&&(!l.demTexture||l.needsTerrainPrepare)){const e=this.painter.context;l.demTexture=this.painter.getTileTexture(l.dem.stride),l.demTexture?l.demTexture.update(l.dem.getPixels(),{premultiply:!1}):l.demTexture=new c.T(e,l.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),l.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),l.needsTerrainPrepare=!1}const d=l&&l.toString()+l.tileID.key+e.key;if(d&&!this._demMatrixCache[d]){const d=this.tileManager.getSource().maxzoom;let p=e.canonical.z-l.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=d?p=e.canonical.z-d:c.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const f=e.canonical.x-(e.canonical.x>>p<>p<>8<<4|e>>8,l[c+3]=0;const d=new c.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(l.buffer)),p=new c.T(e,d,e.gl.RGBA,{premultiply:!1});return p.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=p,p}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const l=new Uint8Array(4),d=this.painter.context,p=d.gl,f=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),_=Math.round(this.painter.height/devicePixelRatio);d.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),p.readPixels(f,_-m-1,1,1,p.RGBA,p.UNSIGNED_BYTE,l),d.bindFramebuffer.set(null);const g=l[0]+(l[2]>>4<<8),y=l[1]+((15&l[2])<<8),b=this.coordsIndex[255-l[3]],T=b&&this.tileManager.getTileByID(b);if(!T)return null;const S=this._coordsTextureSize,P=(1<0,p=d&&0===e.canonical.y,f=d&&e.canonical.y===(1<e.id!==l)),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 ta={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class rs{constructor(e,l){this.painter=e,this.terrain=l,this.pool=new as(e.context,30,l.tileManager.tileSize*l.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,l){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter((c=>!e._layers[c].isHidden(l))),this._coordsAscending={};for(const l in e.tileManagers){this._coordsAscending[l]={};const c=e.tileManagers[l].getVisibleCoordinates(),d=e.tileManagers[l].getSource(),p=d instanceof te?d.terrainTileRanges:null;for(const e of c){const c=this.terrain.tileManager.getTerrainCoords(e,p);for(const e in c)this._coordsAscending[l][e]||(this._coordsAscending[l][e]=[]),this._coordsAscending[l][e].push(c[e])}}this._coordsAscendingStr={};for(const l of e._order){const c=e._layers[l],d=c.source;if(ta[c.type]&&!this._coordsAscendingStr[d]){this._coordsAscendingStr[d]={};for(const e in this._coordsAscending[d])this._coordsAscendingStr[d][e]=this._coordsAscending[d][e].map((e=>e.key)).sort().join()}}for(const e of this._renderableTiles)for(const l in this._coordsAscendingStr){const c=this._coordsAscendingStr[l][e.tileID.key];c&&c!==e.rttCoords[l]&&(e.rtt=[])}}renderLayer(e,l){if(e.isHidden(this.painter.transform.zoom))return!1;const d=Object.assign(Object.assign({},l),{isRenderingToTexture:!0}),p=e.type,f=this.painter,m=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(ta[p]&&(this._prevType&&ta[this._prevType]||this._stacks.push([]),this._prevType=p,this._stacks[this._stacks.length-1].push(e.id),!m))return!0;if(ta[this._prevType]||ta[p]&&m){this._prevType=p;const e=this._stacks.length-1,l=this._stacks[e]||[];for(const p of this._renderableTiles){if(this.pool.isFull()&&(lo(this.painter,this.terrain,this._rttTiles,d),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(p),p.rtt[e]){const l=this.pool.getObjectForId(p.rtt[e].id);if(l.stamp===p.rtt[e].stamp){this.pool.useObject(l);continue}}const m=this.pool.getOrCreateFreeObject();this.pool.useObject(m),this.pool.stampObject(m),p.rtt[e]={id:m.id,stamp:m.stamp},f.context.bindFramebuffer.set(m.fbo.framebuffer),f.context.clear({color:c.bp.transparent,stencil:0}),f.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=l;const p=new yr;this._rotatePitchHandler=new mr({clickTolerance:3,move:(e,p)=>{const f=l.getBoundingClientRect(),m=new c.P((f.bottom-f.top)/2,(f.right-f.left)/2);return{bearingDelta:c.cy(new c.P(e.x,p.y),p,m),pitchDelta:d?-.5*(p.y-e.y):void 0}},moveStateManager:p,enable:!0,assignEvents:()=>{}}),this.map=e,h.addEventListener(l,"mousedown",this.mousedown),h.addEventListener(l,"touchstart",this.touchstart,{passive:!1}),h.addEventListener(l,"touchcancel",this.reset)}startMove(e,l){this._rotatePitchHandler.dragStart(e,l),h.disableDrag()}move(e,l){const c=this.map,{bearingDelta:d,pitchDelta:p}=this._rotatePitchHandler.dragMove(e,l)||{};d&&c.setBearing(c.getBearing()+d),p&&c.setPitch(c.getPitch()+p)}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 il;function rl(e,l,d,p=!1){if(p||!d.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const f=new c.V(e.lng,e.lat);if(e=new c.V(e.lng,e.lat),l){const p=new c.V(e.lng-360,e.lat),f=new c.V(e.lng+360,e.lat),m=d.locationToScreenPoint(e).distSqr(l);d.locationToScreenPoint(p).distSqr(l)180;){const l=d.locationToScreenPoint(e);if(l.x>=0&&l.y>=0&&l.x<=d.width&&l.y<=d.height)break;e.lng>d.center.lng?e.lng-=360:e.lng+=360}return e.lng!==f.lng&&d.isPointOnMapSurface(d.locationToScreenPoint(e))?e:f}const nl={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 sl(e,l,c){const d=e.classList;for(const e in nl)d.remove(`maplibregl-${c}-anchor-${e}`);d.add(`maplibregl-${c}-anchor-${l}`)}class ms extends c.E{constructor(e){if(super(),this._onKeyPress=e=>{const l=e.code,c=e.charCode||e.keyCode;"Space"!==l&&"Enter"!==l&&32!==c&&13!==c||this.togglePopup()},this._onMapClick=e=>{const l=e.originalEvent.target,c=this._element;this._popup&&(l===c||c.contains(l))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const l=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!l)&&this._map.once("render",this._update),this._lngLat=rl(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 c="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?c=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let d="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?d="rotateX(0deg)":"map"===this._pitchAlignment&&(d=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),h.setTransform(this._element,`${nl[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${d} ${c}`),g.frameAsync(new AbortController,this._map._ownerWindow).then((()=>{this._updateOpacity(e&&"moveend"===e.type)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){const l=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=l}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 c.l("dragstart"))),this.fire(new c.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 c.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=c.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create("div");const l=h.createNS("http://www.w3.org/2000/svg","svg"),d=41,p=27;l.setAttributeNS(null,"display","block"),l.setAttributeNS(null,"height",`${d}px`),l.setAttributeNS(null,"width",`${p}px`),l.setAttributeNS(null,"viewBox",`0 0 ${p} ${d}`);const f=h.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"stroke","none"),f.setAttributeNS(null,"stroke-width","1"),f.setAttributeNS(null,"fill","none"),f.setAttributeNS(null,"fill-rule","evenodd");const m=h.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const _=h.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const g=[{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 g){const l=h.createNS("http://www.w3.org/2000/svg","ellipse");l.setAttributeNS(null,"opacity","0.04"),l.setAttributeNS(null,"cx","10.5"),l.setAttributeNS(null,"cy","5.80029008"),l.setAttributeNS(null,"rx",e.rx),l.setAttributeNS(null,"ry",e.ry),_.appendChild(l)}const y=h.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"fill",this._color);const b=h.createNS("http://www.w3.org/2000/svg","path");b.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"),y.appendChild(b);const T=h.createNS("http://www.w3.org/2000/svg","g");T.setAttributeNS(null,"opacity","0.25"),T.setAttributeNS(null,"fill","#000000");const S=h.createNS("http://www.w3.org/2000/svg","path");S.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"),T.appendChild(S);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 I=h.createNS("http://www.w3.org/2000/svg","g");I.setAttributeNS(null,"transform","translate(8.0, 8.0)");const C=h.createNS("http://www.w3.org/2000/svg","circle");C.setAttributeNS(null,"fill","#000000"),C.setAttributeNS(null,"opacity","0.25"),C.setAttributeNS(null,"cx","5.5"),C.setAttributeNS(null,"cy","5.5"),C.setAttributeNS(null,"r","5.4999962");const R=h.createNS("http://www.w3.org/2000/svg","circle");R.setAttributeNS(null,"fill","#FFFFFF"),R.setAttributeNS(null,"cx","5.5"),R.setAttributeNS(null,"cy","5.5"),R.setAttributeNS(null,"r","5.4999962"),I.appendChild(C),I.appendChild(R),m.appendChild(_),m.appendChild(y),m.appendChild(T),m.appendChild(P),m.appendChild(I),l.appendChild(m),l.setAttributeNS(null,"height",d*this._scale+"px"),l.setAttributeNS(null,"width",p*this._scale+"px"),this._element.appendChild(l),this._offset=c.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()})),sl(this._element,this._anchor,"marker"),e&&e.className)for(const l of e.className.split(" "))this._element.classList.add(l);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=c.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 l=38.1,c=13.5,d=Math.abs(c)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-l],"bottom-left":[d,-1*(l-c+d)],"bottom-right":[-d,-1*(l-c+d)],left:[c,-1*(l-c)],right:[-c,-1*(l-c)]}: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 l,d;const p=null===(l=this._map)||void 0===l?void 0:l.terrain,f=this._map.transform.isLocationOccluded(this._lngLat);if(!p||f){const e=f?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 m=this._map,_=m.terrain.depthAtPoint(this._pos),g=m.terrain.getElevationForLngLat(this._lngLat,m.transform);if(m.transform.lngLatToCameraDepth(this._lngLat,g)-_<.006)return void(this._element.style.opacity=this._opacity);const y=-this._offset.y/m.transform.pixelsPerMeter,b=Math.sin(m.getPitch()*Math.PI/180)*y,T=m.terrain.depthAtPoint(new c.P(this._pos.x,this._pos.y-this._offset.y)),S=m.transform.lngLatToCameraDepth(this._lngLat,g+b)-T>.006;(null===(d=this._popup)||void 0===d?void 0:d.isOpen())&&S&&this._popup.remove(),this._element.style.opacity=S?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=c.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,l){return(void 0===this._opacity||void 0===e&&void 0===l)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==l&&(this._opacityWhenCovered=l),this._map&&this._updateOpacity(!0),this}}const ol={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let al=0,ll=!1;const cl={maxWidth:100,unit:"metric"};function hl(e,l,c){const d=c&&c.maxWidth||100,p=e._container.clientHeight/2,f=e._container.clientWidth/2,m=e.unproject([f-d/2,p]),_=e.unproject([f+d/2,p]),g=Math.round(e.project(_).x-e.project(m).x),y=Math.min(d,g,e._container.clientWidth),b=m.distanceTo(_);if(c&&"imperial"===c.unit){const c=3.2808*b;c>5280?ul(l,y,c/5280,e._getUIString("ScaleControl.Miles")):ul(l,y,c,e._getUIString("ScaleControl.Feet"))}else c&&"nautical"===c.unit?ul(l,y,b/1852,e._getUIString("ScaleControl.NauticalMiles")):b>=1e3?ul(l,y,b/1e3,e._getUIString("ScaleControl.Kilometers")):ul(l,y,b,e._getUIString("ScaleControl.Meters"))}function ul(e,l,c,d){const p=function(e){const l=Math.pow(10,`${Math.floor(e)}`.length-1);let c=e/l;return c=c>=10?10:c>=5?5:c>=3?3:c>=2?2:c>=1?1:function(e){const l=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*l)/l}(c),l*c}(c);e.style.width=l*(p/c)+"px",e.innerHTML=`${p} ${d}`}const dl={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},pl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function fl(e){if(e){if("number"==typeof e){const l=Math.round(Math.abs(e)/Math.SQRT2);return{center:new c.P(0,0),top:new c.P(0,e),"top-left":new c.P(l,l),"top-right":new c.P(-l,l),bottom:new c.P(0,-e),"bottom-left":new c.P(l,-l),"bottom-right":new c.P(-l,-l),left:new c.P(e,0),right:new c.P(-e,0)}}if(e instanceof c.P||Array.isArray(e)){const l=c.P.convert(e);return{center:l,top:l,"top-left":l,"top-right":l,bottom:l,"bottom-left":l,"bottom-right":l,left:l,right:l}}return{center:c.P.convert(e.center||[0,0]),top:c.P.convert(e.top||[0,0]),"top-left":c.P.convert(e["top-left"]||[0,0]),"top-right":c.P.convert(e["top-right"]||[0,0]),bottom:c.P.convert(e.bottom||[0,0]),"bottom-left":c.P.convert(e["bottom-left"]||[0,0]),"bottom-right":c.P.convert(e["bottom-right"]||[0,0]),left:c.P.convert(e.left||[0,0]),right:c.P.convert(e.right||[0,0])}}return fl(new c.P(0,0))}const gl=d;l.AJAXError=c.cJ,l.Event=c.l,l.Evented=c.E,l.LngLat=c.V,l.MercatorCoordinate=c.a9,l.Point=c.P,l.addProtocol=c.cK,l.config=c.c,l.removeProtocol=c.cL,l.AttributionControl=Yr,l.BoxZoomHandler=hr,l.CanvasSource=ae,l.CooperativeGesturesHandler=Vr,l.DoubleClickZoomHandler=Or,l.DragPanHandler=Zr,l.DragRotateHandler=Ur,l.EdgeInsets=Nt,l.FullscreenControl=class extends c.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let l=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==l?void 0:l.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)l=l.shadowRoot.fullscreenElement;l===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:c.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 c.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new c.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()}},l.GeoJSONSource=ee,l.GeolocateControl=class extends c.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new c.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 c.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const l=new c.V(e.coords.longitude,e.coords.latitude),d=e.coords.accuracy,p=this._map.getBearing(),f=c.e({bearing:p},this.options.fitBoundsOptions),m=$.fromLngLat(l,d);this._map.fitBounds(m,f,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const l=new c.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(l).addTo(this._map),this._userLocationDotMarker.setLngLat(l).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&&ll)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new c.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){c.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 l=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||l||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 c.l("trackuserlocationend")),this.fire(new c.l("userlocationlostfocus")))}))}},this.options=c.e({},ol,e)}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return c._(this,arguments,void 0,(function*(e=!1){if(void 0!==il&&!e)return il;if(void 0===window.navigator.permissions)return il=!!window.navigator.geolocation,il;try{const e=yield window.navigator.permissions.query({name:"geolocation"});il="denied"!==e.state}catch(e){il=!!window.navigator.geolocation}return il}))}().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,al=0,ll=!1}_isOutOfMapMaxBounds(e){const l=this._map.getMaxBounds(),c=e.coords;return l&&(c.longitudel.getEast()||c.latitudel.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 l=this._map.project(e),c=this._map.unproject([l.x+100,l.y]),d=e.distanceTo(c)/100,p=2*this._accuracy/d;this._circleElement.style.width=`${p.toFixed(2)}px`,this._circleElement.style.height=`${p.toFixed(2)}px`}trigger(){if(!this._setup)return c.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 c.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":al--,ll=!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 c.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 c.l("trackuserlocationstart")),this.fire(new c.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"),al++,al>1?(e={maximumAge:6e5,timeout:0},ll=!0):(e=this.options.positionOptions,ll=!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)}},l.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const l=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==l&&l?{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}},l.Hash=Ho,l.ImageSource=te,l.KeyboardHandler=Ar,l.LngLatBounds=$,l.LogoControl=Qr,l.Map=class extends Xr{get _ownerWindow(){var e,l;return(null===(l=null===(e=this._container)||void 0===e?void 0:e.ownerDocument)||void 0===l?void 0:l.defaultView)||window}constructor(e){var l,d;c.cH.mark(c.cI.create);const p=Object.assign(Object.assign(Object.assign({},el),e),{canvasContextAttributes:Object.assign(Object.assign({},el.canvasContextAttributes),e.canvasContextAttributes)});if(null!=p.minZoom&&null!=p.maxZoom&&p.minZoom>p.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=p.minPitch&&null!=p.maxPitch&&p.minPitch>p.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=p.minPitch&&p.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=p.maxPitch&&p.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const f=new $t,m=new Yt;void 0!==p.minZoom&&f.setMinZoom(p.minZoom),void 0!==p.maxZoom&&f.setMaxZoom(p.maxZoom),void 0!==p.minPitch&&f.setMinPitch(p.minPitch),void 0!==p.maxPitch&&f.setMaxPitch(p.maxPitch),void 0!==p.renderWorldCopies&&f.setRenderWorldCopies(p.renderWorldCopies),null!==p.transformConstrain&&f.setConstrainOverride(p.transformConstrain),super(f,m,{bearingSnap:p.bearingSnap,zoomSnap:p.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Jr,this._controls=[],this._mapId=c.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[l]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${l}' 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 c.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 c.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=p.interactive,this._maxTileCacheSize=p.maxTileCacheSize,this._maxTileCacheZoomLevels=p.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},p.canvasContextAttributes),this._trackResize=!0===p.trackResize,this._bearingSnap=p.bearingSnap,this._zoomSnap=p.zoomSnap,this._centerClampedToGround=p.centerClampedToGround,this._refreshExpiredTiles=!0===p.refreshExpiredTiles,this._fadeDuration=p.fadeDuration,this._crossSourceCollisions=!0===p.crossSourceCollisions,this._collectResourceTiming=!0===p.collectResourceTiming,this._locale=Object.assign(Object.assign({},ia),p.locale),this._clickTolerance=p.clickTolerance,this._overridePixelRatio=p.pixelRatio,this._maxCanvasSize=p.maxCanvasSize,this._zoomLevelsToOverscale=p.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=p.transformCameraUpdate,this.transformConstrain=p.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===p.cancelPendingTileRequestsWhileZooming,void 0!==p.reduceMotion&&(g.prefersReducedMotion=p.reduceMotion),this._imageQueueHandle=L.addThrottleControl((()=>this.isMoving())),this._requestManager=new v(p.transformRequest),this._container=this._resolveContainer(p.container),p.maxBounds&&this.setMaxBounds(p.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&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new Hr(this,p),this._hash=p.hash&&new Ho("string"==typeof p.hash&&p.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:p.center,elevation:p.elevation,zoom:p.zoom,bearing:p.bearing,pitch:p.pitch,roll:p.roll}),p.bounds&&(this.resize(),this.fitBounds(p.bounds,c.e({},p.fitBoundsOptions,{duration:0}))));const _="string"==typeof p.style||!("globe"===(null===(d=null===(l=p.style)||void 0===l?void 0:l.projection)||void 0===d?void 0:d.type));this.resize(null,_),this._localIdeographFontFamily=p.localIdeographFontFamily,this._validateStyle=p.validateStyle,p.style&&this.setStyle(p.style,{localIdeographFontFamily:p.localIdeographFontFamily}),p.attributionControl&&this.addControl(new Yr("boolean"==typeof p.attributionControl?void 0:p.attributionControl)),p.maplibreLogo&&this.addControl(new Qr,p.logoPosition),this.on("style.load",(()=>{if(_||this._resizeTransform(),this.transform.unmodified){const e=c.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new c.l(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new c.l(`${e.dataType}dataloading`,e))})),this.on("dataabort",(e=>{this.fire(new c.l("sourcedataabort",e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,l){return this.style.setGlobalStateProperty(e,l),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,l){if(void 0===l&&(l=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new c.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const d=e.onAdd(this);this._controls.push(e);const p=this._controlPositions[l];return-1!==l.indexOf("bottom")?p.insertBefore(d,p.firstChild):p.appendChild(d),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new c.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const l=this._controls.indexOf(e);return l>-1&&this._controls.splice(l,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return it(this.transform,e)}calculateCameraOptionsFromTo(e,l,c,d){return null==d&&this.terrain&&(d=this.terrain.getElevationForLngLat(c,this.transform)),super.calculateCameraOptionsFromTo(e,l,c,d)}resize(e,l=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(l);const d=!this._moving;return d&&(this.stop(),this.fire(new c.l("movestart",e)).fire(new c.l("move",e))),this.fire(new c.l("resize",e)),d&&this.fire(new c.l("moveend",e)),this}_resizeInternal(e=!0){const[l,c]=this._containerDimensions(),d=this._getClampedPixelRatio(l,c);if(this._resizeCanvas(l,c,d),this.painter.resize(l,c,d),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const d=this._getClampedPixelRatio(l,c);this._resizeCanvas(l,c,d),this.painter.resize(l,c,d)}this._resizeTransform(e)}_resizeTransform(e=!0){var l;const[c,d]=this._containerDimensions();this.transform.resize(c,d,e),null===(l=this._requestedCameraState)||void 0===l||l.resize(c,d,e)}_getClampedPixelRatio(e,l){const{0:c,1:d}=this._maxCanvasSize,p=this.getPixelRatio(),f=e*p,m=l*p;return Math.min(f>c?c/f:1,m>d?d/m:1)*p}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 l=this.transform.zoom,d=this._getTransformForUpdate();return d.setMinZoom(e),this._applyUpdatedTransform(d),this._update(),l!==this.transform.zoom&&this.fire(new c.l("zoomstart")).fire(new c.l("zoom")).fire(new c.l("zoomend")).fire(new c.l("movestart")).fire(new c.l("move")).fire(new c.l("moveend")),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 l=this.transform.zoom,d=this._getTransformForUpdate();return d.setMaxZoom(e),this._applyUpdatedTransform(d),this._update(),l!==this.transform.zoom&&this.fire(new c.l("zoomstart")).fire(new c.l("zoom")).fire(new c.l("zoomend")).fire(new c.l("movestart")).fire(new c.l("move")).fire(new c.l("moveend")),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){const l=this.transform.pitch,d=this._getTransformForUpdate();return d.setMinPitch(e),this._applyUpdatedTransform(d),this._update(),l!==this.transform.pitch&&this.fire(new c.l("pitchstart")).fire(new c.l("pitch")).fire(new c.l("pitchend")).fire(new c.l("movestart")).fire(new c.l("move")).fire(new c.l("moveend")),this}throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?60:e)>180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch){const l=this.transform.pitch,d=this._getTransformForUpdate();return d.setMaxPitch(e),this._applyUpdatedTransform(d),this._update(),l!==this.transform.pitch&&this.fire(new c.l("pitchstart")).fire(new c.l("pitch")).fire(new c.l("pitchend")).fire(new c.l("movestart")).fire(new c.l("move")).fire(new c.l("moveend")),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(c.V.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(c.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,l,c){if("mouseenter"===e||"mouseover"===e){let d=!1;const p=p=>{const f=l.filter((e=>this.getLayer(e))),m=0!==f.length?this.queryRenderedFeatures(p.point,{layers:f}):[];m.length?d||(d=!0,c.call(this,new or(e,this,p.originalEvent,{features:m}))):d=!1};return{layers:l,listener:c,delegates:{mousemove:p,mouseout:()=>{d=!1}}}}if("mouseleave"===e||"mouseout"===e){let d=!1;const p=p=>{const f=l.filter((e=>this.getLayer(e)));(0!==f.length?this.queryRenderedFeatures(p.point,{layers:f}):[]).length?d=!0:d&&(d=!1,c.call(this,new or(e,this,p.originalEvent)))},f=l=>{d&&(d=!1,c.call(this,new or(e,this,l.originalEvent)))};return{layers:l,listener:c,delegates:{mousemove:p,mouseout:f}}}{const d=e=>{const d=l.filter((e=>this.getLayer(e))),p=0!==d.length?this.queryRenderedFeatures(e.point,{layers:d}):[];p.length&&(e.features=p,c.call(this,e),delete e.features)};return{layers:l,listener:c,delegates:{[e]:d}}}}_saveDelegatedListener(e,l){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(l)}_removeDelegatedListener(e,l,c){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const d=this._delegatedListeners[e];for(let e=0;el.includes(e)))){for(const e in p.delegates)this.off(e,p.delegates[e]);return void d.splice(e,1)}}}on(e,l,c){if(void 0===c)return super.on(e,l);const d="string"==typeof l?[l]:l,p=this._createDelegatedListener(e,d,c);this._saveDelegatedListener(e,p);for(const e in p.delegates)this.on(e,p.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,d,c)}}}once(e,l,c){if(void 0===c)return super.once(e,l);const d="string"==typeof l?[l]:l,p=this._createDelegatedListener(e,d,c);for(const l in p.delegates){const f=p.delegates[l];p.delegates[l]=(...l)=>{this._removeDelegatedListener(e,d,c),f(...l)}}this._saveDelegatedListener(e,p);for(const e in p.delegates)this.once(e,p.delegates[e]);return this}off(e,l,c){return void 0===c?super.off(e,l):(this._removeDelegatedListener(e,"string"==typeof l?[l]:l,c),this)}queryRenderedFeatures(e,l){if(!this.style)return[];let d;const p=e instanceof c.P||Array.isArray(e),f=p?e:[[0,0],[this.transform.width,this.transform.height]];if(l=l||(p?{}:e)||{},f instanceof c.P||"number"==typeof f[0])d=[c.P.convert(f)];else{const e=c.P.convert(f[0]),l=c.P.convert(f[1]);d=[e,new c.P(l.x,e.y),l,new c.P(e.x,l.y),e]}return this.style.queryRenderedFeatures(d,l,this.transform)}querySourceFeatures(e,l){return this.style.querySourceFeatures(e,l)}setStyle(e,l){return!1!==(l=c.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},l)).diff&&l.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,l),this):(this._localIdeographFontFamily=l.localIdeographFontFamily,this._updateStyle(e,l))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const l=this._locale[e];if(null==l)throw new Error(`Missing UI string '${e}'`);return l}_updateStyle(e,l){var c,d;if(l.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,l)));const p=this.style&&l.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new ki(this,l||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,l,p):this.style.loadJSON(e,l,p),this):(null===(d=null===(c=this.style)||void 0===c?void 0:c.projection)||void 0===d||d.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,l){if("string"==typeof e){const d=this._requestManager.transformRequest(e,"Style");c.j(d,new AbortController).then((e=>{this._updateDiff(e.data,l)})).catch((e=>{e&&this.fire(new c.k(e))}))}else"object"==typeof e&&this._updateDiff(e,l)}_updateDiff(e,l){try{this.style.setState(e,l)&&this._update(!0)}catch(d){c.w(`Unable to perform style diff: ${d.message||d.error||d}. Rebuilding the style from scratch.`),this._updateStyle(e,l)}}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():c.w("There is no style added to the map.")}addSource(e,l){return this._lazyInitEmptyStyle(),this.style.addSource(e,l),this._update(!0)}isSourceLoaded(e){const l=this.style&&this.style.tileManagers[e];if(void 0!==l)return l.loaded();this.fire(new c.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 l=this.style.tileManagers[e.source];if(!l)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&l.reload();for(const l in this.style._layers){const d=this.style._layers[l];"hillshade"===d.type&&d.source===e.source&&c.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"===d.type&&d.source===e.source&&c.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,l,e),this.painter.renderToTexture=new rs(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=l=>{var c;"style"===l.dataType?this.terrain.tileManager.freeRtt():"source"===l.dataType&&l.tile&&(l.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===(c=l.source)||void 0===c?void 0:c.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(l.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 c.l("terrain",{terrain:e})),this}getTerrain(){var e,l;return null!==(l=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==l?l:null}areTilesLoaded(){const e=this.style&&this.style.tileManagers;for(const l of Object.values(e))if(!l.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,l,c){if(c){const d=this.getSource(c);if(!d)throw new Error(`There is no source with ID "${c}", cannot set LOD parameters`);d.calculateTileZoom=Ye(Math.max(1,e),Math.max(1,l))}else for(const c in this.style.tileManagers)this.style.tileManagers[c].getSource().calculateTileZoom=Ye(Math.max(1,e),Math.max(1,l));return this._update(!0),this}refreshTiles(e,l){const d=this.style.tileManagers[e];if(!d)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===l?d.reload(!0):d.refreshTiles(l.map((e=>new c.ac(e.z,e.x,e.y))))}addImage(e,l,d={}){const{pixelRatio:p=1,sdf:f=!1,stretchX:m,stretchY:_,content:y,textFitWidth:b,textFitHeight:T}=d;if(this._lazyInitEmptyStyle(),!(l instanceof HTMLImageElement||c.b(l))){if(void 0===l.width||void 0===l.height)return this.fire(new c.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:d,height:g,data:S}=l,P=l;return this.style.addImage(e,{data:new c.R({width:d,height:g},new Uint8Array(S)),pixelRatio:p,stretchX:m,stretchY:_,content:y,textFitWidth:b,textFitHeight:T,sdf:f,version:0,userImage:P}),P.onAdd&&P.onAdd(this,e),this}}{const{width:d,height:S,data:P}=g.getImageData(l);this.style.addImage(e,{data:new c.R({width:d,height:S},P),pixelRatio:p,stretchX:m,stretchY:_,content:y,textFitWidth:b,textFitHeight:T,sdf:f,version:0})}}updateImage(e,l){const d=this.style.getImage(e);if(!d)return this.fire(new c.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const p=l instanceof HTMLImageElement||c.b(l)?g.getImageData(l):l,{width:f,height:m,data:_}=p;if(void 0===f||void 0===m)return this.fire(new c.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(f!==d.data.width||m!==d.data.height)return this.fire(new c.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const y=!(l instanceof HTMLImageElement||c.b(l));return d.data.replace(_,y),this.style.updateImage(e,d),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new c.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return L.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,l){return this._lazyInitEmptyStyle(),this.style.addLayer(e,l),this._update(!0)}moveLayer(e,l){return this.style.moveLayer(e,l),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,l,c){return this.style.setLayerZoomRange(e,l,c),this._update(!0)}setFilter(e,l,c={}){return this.style.setFilter(e,l,c),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,l,c,d={}){return this.style.setPaintProperty(e,l,c,d),this._update(!0)}getPaintProperty(e,l){return this.style.getPaintProperty(e,l)}setLayoutProperty(e,l,c,d={}){return this.style.setLayoutProperty(e,l,c,d),this._update(!0)}getLayoutProperty(e,l){return this.style.getLayoutProperty(e,l)}setGlyphs(e,l={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,l),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,l,c={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,l,c,(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,l={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,l,(e=>{e||this._update(!0)})),this}setLight(e,l={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,l),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,l={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,l),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,l){return this.style.setFeatureState(e,l),this._update()}removeFeatureState(e,l){return this.style.removeFeatureState(e,l),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,l=0;return this._container&&(e=this._container.clientWidth||400,l=this._container.clientHeight||300),[e,l]}_setupResizeObserver(){var e;let l=!1;const c=ho((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50),d=null!==(e=this._ownerWindow.ResizeObserver)&&void 0!==e?e:ResizeObserver;this._resizeObserver=new d((e=>{l?c(e):l=!0})),this._resizeObserver.observe(this._container)}_resolveContainer(e){if("string"==typeof e){const l=document.getElementById(e);if(!l)throw new Error(`Container '${e}' not found.`);return l}if(e instanceof HTMLElement)return e;if(e&&"object"==typeof e&&1===e.nodeType)return e;throw new Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const l=this._canvasContainer=h.create("div","maplibregl-canvas-container",e);this._interactive&&l.classList.add("maplibregl-interactive"),this._canvas=h.create("canvas","maplibregl-canvas",l),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 c=this._containerDimensions(),d=this._getClampedPixelRatio(c[0],c[1]);this._resizeCanvas(c[0],c[1],d);const p=this._controlContainer=h.create("div","maplibregl-control-container",e),f=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{f[e]=h.create("div",`maplibregl-ctrl-${e} `,p)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,l,c){this._canvas.width=Math.floor(c*e),this._canvas.height=Math.floor(c*l),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${l}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let l=null;this._canvas.addEventListener("webglcontextcreationerror",(c=>{l={requestedAttributes:e},c&&(l.statusMessage=c.statusMessage,l.type=c.type)}),{once:!0});let c=null;if(c=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!c){const e="Failed to initialize WebGL";throw l?(l.message=e,new Error(JSON.stringify(l))):new Error(e)}this.painter=new Wo(c,this.transform),T.testSupport(c)}migrateProjection(e,l){super.migrateProjection(e,l),this.painter.transform=e,this.fire(new c.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 l,d,p,f,m;const _=this._idleTriggered?this._fadeDuration:0,g=(null===(l=this.style.projection)||void 0===l?void 0:l.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let y=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,l=b();this.style.zoomHistory.update(e,l);const d=new c.H(e,{now:l,fadeDuration:_,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),p=d.crossFadingFactor();1===p&&p===this._crossFadingFactor||(y=!0,this._crossFadingFactor=p),this.style.update(d)}const T=(null===(d=this.style.projection)||void 0===d?void 0:d.transitionState)>0!==g;null===(p=this.style.projection)||void 0===p||p.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(f=this.style.projection)||void 0===f?void 0:f.transitionState,null===(m=this.style.projection)||void 0===m?void 0:m.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||T)&&(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,_,this._crossSourceCollisions,T),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:_,showPadding:this.showPadding}),this.fire(new c.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,c.cH.mark(c.cI.load),this.fire(new c.l("load"))),this.style&&(this.style.hasTransitions()||y)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const S=this._sourcesDirty||this._styleDirty||this._placementDirty;return S||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new c.l("idle")),!this._loaded||this._fullyLoaded||S||(this._fullyLoaded=!0,c.cH.mark(c.cI.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&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),L.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const l=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==l?void 0:l.loseContext)&&l.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"),c.cH.clearMetrics(),this._removed=!0,this.fire(new c.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,g.frame(this._frameRequest,(e=>{c.cH.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!c.Z(e)&&!function(e){return e.message===Hn}(e))throw e}}),(()=>{}),this._ownerWindow))}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 na}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},l.MapMouseEvent=or,l.MapTouchEvent=rr,l.MapWheelEvent=sr,l.Marker=ms,l.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),l=e===this._map.getMaxZoom(),c=e===this._map.getMinZoom();this._zoomInButton.disabled=l,this._zoomOutButton.disabled=c,this._zoomInButton.setAttribute("aria-disabled",l.toString()),this._zoomOutButton.setAttribute("aria-disabled",c.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,l)=>{const c=this._map._getUIString(`NavigationControl.${l}`);e.title=c,e.setAttribute("aria-label",c)},this.options=c.e({},tl,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,l){const c=h.create("button",e,this._container);return c.type="button",c.addEventListener("click",l),c}},l.Popup=class extends c.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 c.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=rl(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const l=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 c=this.options.anchor;const d=fl(this.options.offset);if(!c){const e=this._container.offsetWidth,p=this._container.offsetHeight,f=function(e){var l,c,d,p;return e?{top:null!==(l=e.top)&&void 0!==l?l:0,right:null!==(c=e.right)&&void 0!==c?c:0,bottom:null!==(d=e.bottom)&&void 0!==d?d:0,left:null!==(p=e.left)&&void 0!==p?p:0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);let m;m=l.y+d.bottom.ythis._map.transform.height-p-f.bottom?["bottom"]:[],l.xthis._map.transform.width-e/2-f.right&&m.push("right"),c=0===m.length?"bottom":m.join("-")}let p=l.add(d[c]);this.options.subpixelPositioning||(p=p.round()),h.setTransform(this._container,`${nl[c]} translate(${p.x}px,${p.y}px)`),sl(this._container,c,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=c.e(Object.create(dl),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 c.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=c.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 l=document.createDocumentFragment(),c=document.createElement("body");let d;for(c.innerHTML=e;d=c.firstChild,d;)l.appendChild(d);return this.setDOMContent(l)}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(pl);e&&e.focus()}},l.RasterDEMTileSource=Y,l.RasterTileSource=K,l.ScaleControl=class{constructor(e){this._onMove=()=>{hl(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,hl(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},cl),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}},l.ScrollZoomHandler=Br,l.Style=ki,l.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}},l.TwoFingersTouchPitchHandler=Rr,l.TwoFingersTouchRotateHandler=Sr,l.TwoFingersTouchZoomHandler=Mr,l.TwoFingersTouchZoomRotateHandler=Gr,l.VectorTileSource=X,l.VideoSource=ie,l.addSourceType=(e,l)=>c._(void 0,void 0,void 0,(function*(){if(xe(e))throw new Error(`A source type called "${e}" already exists.`);((e,l)=>{ye[e]=l})(e,l)})),l.clearPrewarmedResources=function(){const e=J;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(W),J=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()"))},l.createTileMesh=ur,l.getMaxParallelImageRequests=function(){return c.c.MAX_PARALLEL_IMAGE_REQUESTS},l.getRTLTextPluginStatus=function(){return we().getRTLTextPluginStatus()},l.getVersion=function(){return gl},l.getWorkerCount=function(){return k.workerCount},l.getWorkerUrl=function(){return c.c.WORKER_URL},l.importScriptInWorkers=function(e){return le().broadcast("IS",e)},l.isTimeFrozen=function(){return y.isFrozen()},l.now=b,l.prewarm=function(){oe().acquire(W)},l.restoreNow=function(){y.restoreNow()},l.setMaxParallelImageRequests=function(e){c.c.MAX_PARALLEL_IMAGE_REQUESTS=e},l.setNow=function(e){y.setNow(e)},l.setRTLTextPlugin=function(e,l){return we().setRTLTextPlugin(e,l)},l.setWorkerCount=function(e){k.workerCount=e},l.setWorkerUrl=function(e){c.c.WORKER_URL=e}}));var p=l;return p}));var c=l;export{c as default}; + * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.18.0/LICENSE.txt + */(function(e,u){c=u()})(0,(function(){var c={};var u={};function p(e,p,f){u[e]=f;if(e==="index"){var m="var sharedModule = {}; ("+u.shared+")(sharedModule); ("+u.worker+")(sharedModule);";var g={};u.shared(g);u.index(c,g);typeof window!=="undefined"&&c.setWorkerUrl(window.URL.createObjectURL(new Blob([m],{type:"text/javascript"})));return c}}p("shared",["exports"],(function(c){function u(e,c,u,p){return new(u||(u=Promise))((function(f,m){function g(e){try{x(p.next(e))}catch(e){m(e)}}function y(e){try{x(p.throw(e))}catch(e){m(e)}}function x(e){var c;e.done?f(e.value):(c=e.value,c instanceof u?c:new u((function(e){e(c)}))).then(g,y)}x((p=p.apply(e,c||[])).next())}))}function p(c,u){(this||e).x=c,(this||e).y=u}function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var m,g;"function"==typeof SuppressedError&&SuppressedError,p.prototype={clone(){return new p((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,c){return this.clone()._rotateAround(e,c)},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(c){return(this||e).x===c.x&&(this||e).y===c.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(c){const u=c.x-(this||e).x,p=c.y-(this||e).y;return u*u+p*p},angle(){return Math.atan2((this||e).y,(this||e).x)},angleTo(c){return Math.atan2((this||e).y-c.y,(this||e).x-c.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(c,u){return Math.atan2((this||e).x*u-(this||e).y*c,(this||e).x*c+(this||e).y*u)},_matMult(c){const u=c[2]*(this||e).x+c[3]*(this||e).y;return(this||e).x=c[0]*(this||e).x+c[1]*(this||e).y,(this||e).y=u,this||e},_add(c){return(this||e).x+=c.x,(this||e).y+=c.y,this||e},_sub(c){return(this||e).x-=c.x,(this||e).y-=c.y,this||e},_mult(c){return(this||e).x*=c,(this||e).y*=c,this||e},_div(c){return(this||e).x/=c,(this||e).y/=c,this||e},_multByPoint(c){return(this||e).x*=c.x,(this||e).y*=c.y,this||e},_divByPoint(c){return(this||e).x/=c.x,(this||e).y/=c.y,this||e},_unit(){return this._div(this.mag()),this||e},_perp(){const c=(this||e).y;return(this||e).y=(this||e).x,(this||e).x=-c,this||e},_rotate(c){const u=Math.cos(c),p=Math.sin(c),f=p*(this||e).x+u*(this||e).y;return(this||e).x=u*(this||e).x-p*(this||e).y,(this||e).y=f,this||e},_rotateAround(c,u){const p=Math.cos(c),f=Math.sin(c),m=u.y+f*((this||e).x-u.x)+p*((this||e).y-u.y);return(this||e).x=u.x+p*((this||e).x-u.x)-f*((this||e).y-u.y),(this||e).y=m,this||e},_round(){return(this||e).x=Math.round((this||e).x),(this||e).y=Math.round((this||e).y),this||e},constructor:p},p.convert=function(e){if(e instanceof p)return e;if(Array.isArray(e))return new p(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new p(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var y=function(){if(g)return m;function c(c,u,p,f){(this||e).cx=3*c,(this||e).bx=3*(p-c)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*u,(this||e).by=3*(f-u)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=c,(this||e).p1y=u,(this||e).p2x=p,(this||e).p2y=f}return g=1,m=c,c.prototype={sampleCurveX:function(c){return(((this||e).ax*c+(this||e).bx)*c+(this||e).cx)*c},sampleCurveY:function(c){return(((this||e).ay*c+(this||e).by)*c+(this||e).cy)*c},sampleCurveDerivativeX:function(c){return(3*(this||e).ax*c+2*(this||e).bx)*c+(this||e).cx},solveCurveX:function(e,c){if(void 0===c&&(c=1e-6),e<0)return 0;if(e>1)return 1;for(var u=e,p=0;p<8;p++){var f=this.sampleCurveX(u)-e;if(Math.abs(f)f?g=u:y=u,u=.5*(y-g)+g;return u},solve:function(e,c){return this.sampleCurveY(this.solveCurveX(e,c))}},m}(),x=f(y);let b,T;function S(){return null==b&&(b="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),b}function P(){if(null==T&&(T=!1,S())){const e=5,c=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(c){for(let u=0;u4&&void 0!==arguments[4]?arguments[4]:"zyx",m=Math.PI/360;c*=m,p*=m,u*=m;var g=Math.sin(c),y=Math.cos(c),x=Math.sin(u),b=Math.cos(u),T=Math.sin(p),S=Math.cos(p);switch(f){case"xyz":e[0]=g*b*S+y*x*T,e[1]=y*x*S-g*b*T,e[2]=y*b*T+g*x*S,e[3]=y*b*S-g*x*T;break;case"xzy":e[0]=g*b*S-y*x*T,e[1]=y*x*S-g*b*T,e[2]=y*b*T+g*x*S,e[3]=y*b*S+g*x*T;break;case"yxz":e[0]=g*b*S+y*x*T,e[1]=y*x*S-g*b*T,e[2]=y*b*T-g*x*S,e[3]=y*b*S+g*x*T;break;case"yzx":e[0]=g*b*S+y*x*T,e[1]=y*x*S+g*b*T,e[2]=y*b*T-g*x*S,e[3]=y*b*S-g*x*T;break;case"zxy":e[0]=g*b*S-y*x*T,e[1]=y*x*S+g*b*T,e[2]=y*b*T+g*x*S,e[3]=y*b*S-g*x*T;break;case"zyx":e[0]=g*b*S-y*x*T,e[1]=y*x*S+g*b*T,e[2]=y*b*T-g*x*S,e[3]=y*b*S+g*x*T;break;default:throw new Error("Unknown angle order "+f)}return e}function J(){var e=new C(2);return C!=Float32Array&&(e[0]=0,e[1]=0),e}function re(e,c){var u=new C(2);return u[0]=e,u[1]=c,u}F(),U=new C(4),C!=Float32Array&&(U[0]=0,U[1]=0,U[2]=0,U[3]=0),F(),O(1,0,0),O(0,1,0),W(),W(),R(),J();const se=8192;function le(e,c,u){return c*(se/(e.tileSize*Math.pow(2,u-e.tileID.overscaledZ)))}function ce(e,c){return(e%c+c)%c}function he(e,c,u){return e*(1-u)+c*u}function ue(e){if(e<=0)return 0;if(e>=1)return 1;const c=e*e,u=c*e;return 4*(e<.5?u:3*(e-c)+u-.75)}function pe(e,c,u,p){const f=new x(e,c,u,p);return e=>f.solve(e)}const fe=pe(.25,.1,.25,1);function me(e,c,u){return Math.min(u,Math.max(c,e))}function ge(e,c,u){const p=u-c,f=((e-c)%p+p)%p+c;return f===c?u:f}function ye(e,...c){for(const u of c)for(const c in u)e[c]=u[c];return e}let xe=1;function ve(c,u,p){const f={};for(const p in c)f[p]=u.call(this||e,c[p],p,c);return f}function be(c,u,p){const f={};for(const p in c)u.call(this||e,c[p],p,c)&&(f[p]=c[p]);return f}function we(e){return Array.isArray(e)?e.map(we):"object"==typeof e&&e?ve(e,we):e}const Se={};function Me(e){Se[e]||("undefined"!=typeof console&&console.warn(e),Se[e]=!0)}function Ee(e,c,u){return(u.y-e.y)*(c.x-e.x)>(c.y-e.y)*(u.x-e.x)}function Ce(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Ae=null;function je(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const Ne="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Ge(c,p,f,m,g){return u(this||e,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(c,{timestamp:0});try{const u=null==e?void 0:e.format;if(!u||!u.startsWith("BGR")&&!u.startsWith("RGB"))throw new Error(`Unrecognized format ${u}`);const y=u.startsWith("BGR"),x=new Uint8ClampedArray(m*g*4);if(yield e.copyTo(x,function(e,c,u,p,f){const m=4*Math.max(-c,0),g=(Math.max(0,u)-u)*p*4+m,y=4*p,x=Math.max(0,c),b=Math.max(0,u);return{rect:{x:x,y:b,width:Math.min(e.width,c+p)-x,height:Math.min(e.height,u+f)-b},layout:[{offset:g,stride:y}]}}(c,p,f,m,g)),y)for(let e=0;e{e.removeEventListener(c,u,p)}}}function Ye(e){return e*Math.PI/180}function et(e){return e/Math.PI*180}const tt={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},it={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},rt="AbortError";class st extends Error{constructor(e=rt){super(e instanceof Error?e.message:e),this.name=rt,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function ot(e){return e.name===rt}const at={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ft(e){return at.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const _t="global-dispatcher";class ct extends Error{constructor(e,c,u,p){super(`AJAXError: ${c} (${e}): ${u}`),this.status=e,this.statusText=c,this.url=u,this.body=p}}const yt=()=>Ce(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,vt=function(c,p){if(/:\/\//.test(c.url)&&!/^https?:|^file:/.test(c.url)){const e=ft(c.url);if(e)return e(c,p);if(Ce(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:c,targetMapId:_t},p)}if(!(/^file:/.test(f=c.url)||/^file:/.test(yt())&&!/^\w+:/.test(f))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(c,p){return u(this||e,void 0,void 0,(function*(){const e=new Request(c.url,{method:c.method||"GET",body:c.body,credentials:c.credentials,headers:c.headers,cache:c.cache,referrer:yt(),signal:p.signal});let u,f;"json"!==c.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{u=yield fetch(e)}catch(e){if(ot(e))throw e;throw new ct(0,e.message,c.url,new Blob)}if(!u.ok){const e=yield u.blob();throw new ct(u.status,u.statusText,c.url,e)}f="arrayBuffer"===c.type||"image"===c.type?u.arrayBuffer():"json"===c.type?u.json():u.text();const m=yield f;return p.signal.throwIfAborted(),{data:m,cacheControl:u.headers.get("Cache-Control"),expires:u.headers.get("Expires")}}))}(c,p);if(Ce(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:c,mustQueue:!0,targetMapId:_t},p)}var f;return function(e,c){return new Promise(((u,p)=>{var f;const m=new XMLHttpRequest;m.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(m.responseType="arraybuffer");for(const c in e.headers)m.setRequestHeader(c,e.headers[c]);"json"===e.type&&(m.responseType="text",(null===(f=e.headers)||void 0===f?void 0:f.Accept)||m.setRequestHeader("Accept","application/json")),m.withCredentials="include"===e.credentials,m.onerror=()=>{p(new Error(m.statusText))},m.onload=()=>{if(!c.signal.aborted)if((m.status>=200&&m.status<300||0===m.status)&&null!==m.response){let c=m.response;if("json"===e.type)try{c=JSON.parse(m.response)}catch(e){return void p(e)}u({data:c,cacheControl:m.getResponseHeader("Cache-Control"),expires:m.getResponseHeader("Expires")})}else{const c=new Blob([m.response],{type:m.getResponseHeader("Content-Type")});p(new ct(m.status,m.statusText,e.url,c))}},c.signal.addEventListener("abort",(()=>{m.abort(),p(new st(c.signal.reason))})),m.send(e.body)}))}(c,p)};function bt(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const c=new URL(e),u=window.location;return c.protocol===u.protocol&&c.host===u.host}function wt(e,c,u){u[e]&&-1!==u[e].indexOf(c)||(u[e]=u[e]||[],u[e].push(c))}function Tt(e,c,u){if(u&&u[e]){const p=u[e].indexOf(c);-1!==p&&u[e].splice(p,1)}}class mt{constructor(e,c={}){ye(this,c),this.type=e}}class gt extends mt{constructor(e,c={}){super("error",ye({error:e},c))}}class xt{on(e,c){return this._listeners=this._listeners||{},wt(e,c,this._listeners),{unsubscribe:()=>{this.off(e,c)}}}off(e,c){return Tt(e,c,this._listeners),Tt(e,c,this._oneTimeListeners),this}once(e,c){return c?(this._oneTimeListeners=this._oneTimeListeners||{},wt(e,c,this._oneTimeListeners),this):new Promise((c=>this.once(e,c)))}fire(e,c){"string"==typeof e&&(e=new mt(e,c||{}));const u=e.type;if(this.listens(u)){e.target=this;const c=this._listeners&&this._listeners[u]?this._listeners[u].slice():[];for(const u of c)u.call(this,e);const p=this._oneTimeListeners&&this._oneTimeListeners[u]?this._oneTimeListeners[u].slice():[];for(const c of p)Tt(u,c,this._oneTimeListeners),c.call(this,e);const f=this._eventedParent;f&&(ye(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),f.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,c){return this._eventedParent=e,this._eventedParentData=c,this}}var Mt={$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 At=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Lt(e,c){const u={};for(const c in e)"ref"!==c&&(u[c]=e[c]);return At.forEach((e=>{e in c&&(u[e]=c[e])})),u}function Ft(e,c){if(Array.isArray(e)){if(!Array.isArray(c)||e.length!==c.length)return!1;for(let u=0;u`:"value"===e.itemType.kind?"array":`array<${c}>`}return e.kind}const Li=[li,ci,ui,pi,fi,mi,xi,_i,Ci(gi),vi,wi,bi,Ii,Ei];function Fi(e,c){if("error"===c.kind)return null;if("array"===e.kind){if("array"===c.kind&&(0===c.N&&"value"===c.itemType.kind||!Fi(e.itemType,c.itemType))&&("number"!=typeof e.N||e.N===c.N))return null}else{if(e.kind===c.kind)return null;if("value"===e.kind)for(const e of Li)if(!Fi(e,c))return null}return`Expected ${Ai(e)} but found ${Ai(c)} instead.`}function Oi(e,c){return c.some((c=>c.kind===e.kind))}function Vi(e,c){return c.some((c=>"null"===c?null===e:"array"===c?Array.isArray(e):"object"===c?e&&!Array.isArray(e)&&"object"==typeof e:c===typeof e))}function ji(e,c){return"array"===e.kind&&"array"===c.kind?e.itemType.kind===c.itemType.kind&&"number"==typeof e.N:e.kind===c.kind}const Ni=.96422,Gi=.82521,Ui=4/29,qi=6/29,$i=3*qi*qi,Wi=qi*qi*qi,Hi=Math.PI/180,Xi=180/Math.PI;function Yi(e){return(e%=360)<0&&(e+=360),e}function Ki([e,c,u,p]){let f,m;const g=Ji((.2225045*(e=Qi(e))+.7168786*(c=Qi(c))+.0606169*(u=Qi(u)))/1);e===c&&c===u?f=m=g:(f=Ji((.4360747*e+.3850649*c+.1430804*u)/Ni),m=Ji((.0139322*e+.0971045*c+.7141733*u)/Gi));const y=116*g-16;return[y<0?0:y,500*(f-g),200*(g-m),p]}function Qi(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Ji(e){return e>Wi?Math.pow(e,1/3):e/$i+Ui}function lr([e,c,u,p]){let f=(e+16)/116,m=isNaN(c)?f:f+c/500,g=isNaN(u)?f:f-u/200;return f=1*hr(f),m=Ni*hr(m),g=Gi*hr(g),[cr(3.1338561*m-1.6168667*f-.4906146*g),cr(-.9787684*m+1.9161415*f+.033454*g),cr(.0719453*m-.2289914*f+1.4052427*g),p]}function cr(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function hr(e){return e>qi?e*e*e:$i*(e-Ui)}const ur=Object.hasOwn||function(e,c){return Object.prototype.hasOwnProperty.call(e,c)};function dr(e,c){return ur(e,c)?e[c]:void 0}function pr(e){return parseInt(e.padEnd(2,e),16)/255}function _r(e,c){return gr(c?e/100:e,0,1)}function gr(e,c,u){return Math.min(Math.max(c,e),u)}function yr(e){return!e.some(Number.isNaN)}const xr={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 vr(e,c,u){return e+u*(c-e)}function br(e,c,u){return e.map(((e,p)=>vr(e,c[p],u)))}class Te{constructor(e,c,u,p=1,f=!0){this.r=e,this.g=c,this.b=u,this.a=p,f||(this.r*=p,this.g*=p,this.b*=p,p||this.overwriteGetter("rgb",[e,c,u,p]))}static parse(e){if(e instanceof Te)return e;if("string"!=typeof e)return;const c=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const c=dr(xr,e);if(c){const[e,u,p]=c;return[e/255,u/255,p/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const c=e.length<6?1:2;let u=1;return[pr(e.slice(u,u+=c)),pr(e.slice(u,u+=c)),pr(e.slice(u,u+=c)),pr(e.slice(u,u+c)||"ff")]}if(e.startsWith("rgb")){const c=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(c){const[e,u,p,f,m,g,y,x,b,T,S,P]=c,I=[f||" ",y||" ",T].join("");if(" "===I||" /"===I||",,"===I||",,,"===I){const e=[p,g,b].join(""),c="%%%"===e?100:""===e?255:0;if(c){const e=[gr(+u/c,0,1),gr(+m/c,0,1),gr(+x/c,0,1),S?_r(+S,P):1];if(yr(e))return e}}return}}const u=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(u){const[e,c,p,f,m,g,y,x,b]=u,T=[p||" ",m||" ",y].join("");if(" "===T||" /"===T||",,"===T||",,,"===T){const e=[+c,gr(+f,0,100),gr(+g,0,100),x?_r(+x,b):1];if(yr(e))return function([e,c,u,p]){function f(p){const f=(p+e/30)%12,m=c*Math.min(u,1-u);return u-m*Math.max(-1,Math.min(f-3,9-f,1))}return e=Yi(e),c/=100,u/=100,[f(0),f(8),f(4),p]}(e)}}}(e);return c?new Te(...c,!1):void 0}get rgb(){const{r:e,g:c,b:u,a:p}=this,f=p||1/0;return this.overwriteGetter("rgb",[e/f,c/f,u/f,p])}get hcl(){return this.overwriteGetter("hcl",function(e){const[c,u,p,f]=Ki(e),m=Math.sqrt(u*u+p*p);return[Math.round(1e4*m)?Yi(Math.atan2(p,u)*Xi):NaN,m,c,f]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Ki(this.rgb))}overwriteGetter(e,c){return Object.defineProperty(this,e,{value:c}),c}toString(){const[e,c,u,p]=this.rgb;return`rgba(${[e,c,u].map((e=>Math.round(255*e))).join(",")},${p})`}static interpolate(e,c,u,p="rgb"){switch(p){case"rgb":{const[p,f,m,g]=br(e.rgb,c.rgb,u);return new Te(p,f,m,g,!1)}case"hcl":{const[p,f,m,g]=e.hcl,[y,x,b,T]=c.hcl;let S,P;if(isNaN(p)||isNaN(y))isNaN(p)?isNaN(y)?S=NaN:(S=y,1!==m&&0!==m||(P=x)):(S=p,1!==b&&0!==b||(P=f));else{let e=y-p;y>p&&e>180?e-=360:y180&&(e+=360),S=p+u*e}const[I,C,R,L]=function([e,c,u,p]){return e=isNaN(e)?0:e*Hi,lr([u,Math.cos(e)*c,Math.sin(e)*c,p])}([S,null!=P?P:vr(f,x,u),vr(m,b,u),vr(g,T,u)]);return new Te(I,C,R,L,!1)}case"lab":{const[p,f,m,g]=lr(br(e.lab,c.lab,u));return new Te(p,f,m,g,!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,c,u){this.sensitivity=e?c?"variant":"case":c?"accent":"base",this.locale=u,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,c){return this.collator.compare(e,c)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const wr=["bottom","center","top"];class Fe{constructor(e,c,u,p,f,m){this.text=e,this.image=c,this.scale=u,this.fontStack=p,this.textColor=f,this.verticalAlign=m}}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 c of e)if("number"!=typeof c)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,c,u){return new ze(br(e.values,c.values,u))}}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 c of e)if("number"!=typeof c)return;return new Pe(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,c,u){return new Pe(br(e.values,c.values,u))}}class Be{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Be)return e;if("string"==typeof e){const c=Te.parse(e);if(!c)return;return new Be([c])}if(!Array.isArray(e))return;const c=[];for(const u of e){if("string"!=typeof u)return;const e=Te.parse(u);if(!e)return;c.push(e)}return new Be(c)}toString(){return JSON.stringify(this.values)}static interpolate(e,c,u,p="rgb"){const f=[];if(e.values.length!=c.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${c.values.length}), cannot interpolate.`);for(let m=0;m=0&&e<=255&&"number"==typeof c&&c>=0&&c<=255&&"number"==typeof u&&u>=0&&u<=255?void 0===p||"number"==typeof p&&p>=0&&p<=1?null:`Invalid rgba value [${[e,c,u,p].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof p?[e,c,u,p]:[e,c,u]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Cr(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 c of e)if(!Cr(c))return!1;return!0}if("object"==typeof e){for(const c in e)if(!Cr(e[c]))return!1;return!0}return!1}function Ar(e){if(null===e)return li;if("string"==typeof e)return ui;if("boolean"==typeof e)return pi;if("number"==typeof e)return ci;if(e instanceof Te)return fi;if(e instanceof Re)return mi;if(e instanceof Ie)return yi;if(e instanceof De)return xi;if(e instanceof ze)return vi;if(e instanceof Pe)return wi;if(e instanceof Be)return bi;if(e instanceof Le)return Ei;if(e instanceof Oe)return Ii;if(Array.isArray(e)){const c=e.length;let u;for(const c of e){const e=Ar(c);if(u){if(u===e)continue;u=gi;break}u=e}return Ci(u||gi,c)}return _i}function Dr(e){const c=typeof e;return null===e?"":"string"===c||"number"===c||"boolean"===c?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 qe{constructor(e,c){this.type=e,this.value=c}static parse(e,c){if(2!==e.length)return c.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Cr(e[1]))return c.error("invalid value");const u=e[1];let p=Ar(u);const f=c.expectedType;return"array"!==p.kind||0!==p.N||!f||"array"!==f.kind||"number"==typeof f.N&&0!==f.N||(p=f),new qe(p,u)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const zr={string:ui,number:ci,boolean:pi,object:_i};class Xe{constructor(e,c){this.type=e,this.args=c}static parse(e,c){if(e.length<2)return c.error("Expected at least one argument.");let u,p=1;const f=e[0];if("array"===f){let f,m;if(e.length>2){const u=e[1];if("string"!=typeof u||!(u in zr)||"object"===u)return c.error('The item type argument of "array" must be one of string, number, boolean',1);f=zr[u],p++}else f=gi;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return c.error('The length argument to "array" must be a positive integer literal',2);m=e[2],p++}u=Ci(f,m)}else{if(!zr[f])throw new Error(`Types doesn't contain name = ${f}`);u=zr[f]}const m=[];for(;pe.outputDefined()))}}const kr={"to-boolean":pi,"to-color":fi,"to-number":ci,"to-string":ui};class Ze{constructor(e,c){this.type=e,this.args=c}static parse(e,c){if(e.length<2)return c.error("Expected at least one argument.");const u=e[0];if(!kr[u])throw new Error(`Can't parse ${u} as it is not part of the known types`);if(("to-boolean"===u||"to-string"===u)&&2!==e.length)return c.error("Expected one argument.");const p=kr[u],f=[];for(let u=1;u4?`Invalid rgba value ${JSON.stringify(c)}: expected an array containing either three or four numeric values.`:Pr(c[0],c[1],c[2],c[3]),!u))return new Te(c[0]/255,c[1]/255,c[2]/255,c[3])}throw new Ve(u||`Could not parse color from value '${"string"==typeof c?c:JSON.stringify(c)}'`)}case"padding":{let c;for(const u of this.args){c=u.evaluate(e);const p=ze.parse(c);if(p)return p}throw new Ve(`Could not parse padding from value '${"string"==typeof c?c:JSON.stringify(c)}'`)}case"numberArray":{let c;for(const u of this.args){c=u.evaluate(e);const p=Pe.parse(c);if(p)return p}throw new Ve(`Could not parse numberArray from value '${"string"==typeof c?c:JSON.stringify(c)}'`)}case"colorArray":{let c;for(const u of this.args){c=u.evaluate(e);const p=Be.parse(c);if(p)return p}throw new Ve(`Could not parse colorArray from value '${"string"==typeof c?c:JSON.stringify(c)}'`)}case"variableAnchorOffsetCollection":{let c;for(const u of this.args){c=u.evaluate(e);const p=Le.parse(c);if(p)return p}throw new Ve(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof c?c:JSON.stringify(c)}'`)}case"number":{let c=null;for(const u of this.args){if(c=u.evaluate(e),null===c)return 0;const p=Number(c);if(!isNaN(p))return p}throw new Ve(`Could not convert ${JSON.stringify(c)} to number.`)}case"formatted":return De.fromString(Dr(this.args[0].evaluate(e)));case"resolvedImage":return Oe.fromString(Dr(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return Dr(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Rr=["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?Rr[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 c=this._parseColorCache.get(e);return c||(c=Te.parse(e),this._parseColorCache.set(e,c)),c}}class We{constructor(e,c,u=[],p,f=new Bt,m=[]){this.registry=e,this.path=u,this.key=u.map((e=>`[${e}]`)).join(""),this.scope=f,this.errors=m,this.expectedType=p,this._isConstant=c}parse(e,c,u,p,f={}){return c?this.concat(c,u,p)._parse(e,f):this._parse(e,f)}_parse(e,c){function u(e,c,u){return"assert"===u?new Xe(c,[e]):"coerce"===u?new Ze(c,[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 p=e[0];if("string"!=typeof p)return this.error(`Expression name must be a string, but found ${typeof p} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const f=this.registry[p];if(f){let p=f.parse(e,this);if(!p)return null;if(this.expectedType){const e=this.expectedType,f=p.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==f.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(f.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(f.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(f.kind)||"colorArray"===e.kind&&["value","string","array"].includes(f.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(f.kind))p=u(p,e,c.typeAnnotation||"coerce");else if(this.checkSubtype(e,f))return null}else p=u(p,e,c.typeAnnotation||"assert")}if(!(p instanceof qe)&&"resolvedImage"!==p.type.kind&&this._isConstant(p)){const c=new Ke;try{p=new qe(p.type,p.evaluate(c))}catch(e){return this.error(e.message),null}}return p}return this.error(`Unknown expression "${p}". 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,c,u){const p="number"==typeof e?this.path.concat(e):this.path,f=u?this.scope.concat(u):this.scope;return new We(this.registry,this._isConstant,p,c||null,f,this.errors)}error(e,...c){const u=`${this.key}${c.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Pt(u,e))}checkSubtype(e,c){const u=Fi(e,c);return u&&this.error(u),u}}class Je{constructor(e,c){this.type=c.type,this.bindings=[].concat(e),this.result=c}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const c of this.bindings)e(c[1]);e(this.result)}static parse(e,c){if(e.length<4)return c.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const u=[];for(let p=1;p=u.length)throw new Ve(`Array index out of bounds: ${c} > ${u.length-1}.`);if(c!==Math.floor(c))throw new Ve(`Array index must be an integer, but found ${c} instead.`);return u[c]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class er{constructor(e,c){this.type=pi,this.needle=e,this.haystack=c}static parse(e,c){if(3!==e.length)return c.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const u=c.parse(e[1],1,gi),p=c.parse(e[2],2,gi);return u&&p?Oi(u.type,[pi,ui,ci,li,gi])?new er(u,p):c.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(u.type)} instead`):null}evaluate(e){const c=this.needle.evaluate(e),u=this.haystack.evaluate(e);if(!u)return!1;if(!Vi(c,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(Ar(c))} instead.`);if(!Vi(u,["string","array"]))throw new Ve(`Expected second argument to be of type array or string, but found ${Ai(Ar(u))} instead.`);return u.indexOf(c)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class rr{constructor(e,c,u){this.type=ci,this.needle=e,this.haystack=c,this.fromIndex=u}static parse(e,c){if(e.length<=2||e.length>=5)return c.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const u=c.parse(e[1],1,gi),p=c.parse(e[2],2,gi);if(!u||!p)return null;if(!Oi(u.type,[pi,ui,ci,li,gi]))return c.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(u.type)} instead`);if(4===e.length){const f=c.parse(e[3],3,ci);return f?new rr(u,p,f):null}return new rr(u,p)}evaluate(e){const c=this.needle.evaluate(e),u=this.haystack.evaluate(e);if(!Vi(c,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(Ar(c))} instead.`);let p;if(this.fromIndex&&(p=this.fromIndex.evaluate(e)),Vi(u,["string"])){const e=u.indexOf(c,p);return-1===e?-1:[...u.slice(0,e)].length}if(Vi(u,["array"]))return u.indexOf(c,p);throw new Ve(`Expected second argument to be of type array or string, but found ${Ai(Ar(u))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class nr{constructor(e,c,u,p,f,m){this.inputType=e,this.type=c,this.input=u,this.cases=p,this.outputs=f,this.otherwise=m}static parse(e,c){if(e.length<5)return c.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return c.error("Expected an even number of arguments.");let u,p;c.expectedType&&"value"!==c.expectedType.kind&&(p=c.expectedType);const f={},m=[];for(let g=2;gNumber.MAX_SAFE_INTEGER)return b.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return b.error("Numeric branch labels must be integer values.");if(u){if(b.checkSubtype(u,Ar(e)))return null}else u=Ar(e);if(void 0!==f[String(e)])return b.error("Branch labels must be unique.");f[String(e)]=m.length}const T=c.parse(x,g,p);if(!T)return null;p=p||T.type,m.push(T)}const g=c.parse(e[1],1,gi);if(!g)return null;const y=c.parse(e[e.length-1],e.length-1,p);return y?"value"!==g.type.kind&&c.concat(1).checkSubtype(u,g.type)?null:new nr(u,p,g,f,m,y):null}evaluate(e){const c=this.input.evaluate(e);return(Ar(c)===this.inputType&&this.outputs[this.cases[c]]||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,c,u){this.type=e,this.branches=c,this.otherwise=u}static parse(e,c){if(e.length<4)return c.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return c.error("Expected an odd number of arguments.");let u;c.expectedType&&"value"!==c.expectedType.kind&&(u=c.expectedType);const p=[];for(let f=1;fc.outputDefined()))&&this.otherwise.outputDefined()}}class sr{constructor(e,c,u,p){this.type=e,this.input=c,this.beginIndex=u,this.endIndex=p}static parse(e,c){if(e.length<=2||e.length>=5)return c.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const u=c.parse(e[1],1,gi),p=c.parse(e[2],2,ci);if(!u||!p)return null;if(!Oi(u.type,[Ci(gi),ui,gi]))return c.error(`Expected first argument to be of type array or string, but found ${Ai(u.type)} instead`);if(4===e.length){const f=c.parse(e[3],3,ci);return f?new sr(u.type,u,p,f):null}return new sr(u.type,u,p)}evaluate(e){const c=this.input.evaluate(e),u=this.beginIndex.evaluate(e);let p;if(this.endIndex&&(p=this.endIndex.evaluate(e)),Vi(c,["string"]))return[...c].slice(u,p).join("");if(Vi(c,["array"]))return c.slice(u,p);throw new Ve(`Expected first argument to be of type array or string, but found ${Ai(Ar(c))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Lr(e,c){const u=e.length-1;let p,f,m=0,g=u,y=0;for(;m<=g;)if(y=Math.floor((m+g)/2),p=e[y],f=e[y+1],p<=c){if(y===u||cc))throw new Ve("Input is not a number.");g=y-1}return 0}class or{constructor(e,c,u){this.type=e,this.input=c,this.labels=[],this.outputs=[];for(const[e,c]of u)this.labels.push(e),this.outputs.push(c)}static parse(e,c){if(e.length-1<4)return c.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return c.error("Expected an even number of arguments.");const u=c.parse(e[1],1,ci);if(!u)return null;const p=[];let f=null;c.expectedType&&"value"!==c.expectedType.kind&&(f=c.expectedType);for(let u=1;u=m)return c.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',y);const b=c.parse(g,x,f);if(!b)return null;f=f||b.type,p.push([m,b])}return new or(f,u,p)}evaluate(e){const c=this.labels,u=this.outputs;if(1===c.length)return u[0].evaluate(e);const p=this.input.evaluate(e);if(p<=c[0])return u[0].evaluate(e);const f=c.length;return p>=c[f-1]?u[f-1].evaluate(e):u[Lr(c,p)].evaluate(e)}eachChild(e){e(this.input);for(const c of this.outputs)e(c)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Br(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Or,Vr,jr=function(){if(Vr)return Or;function c(c,u,p,f){(this||e).cx=3*c,(this||e).bx=3*(p-c)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*u,(this||e).by=3*(f-u)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=c,(this||e).p1y=u,(this||e).p2x=p,(this||e).p2y=f}return Vr=1,Or=c,c.prototype={sampleCurveX:function(c){return(((this||e).ax*c+(this||e).bx)*c+(this||e).cx)*c},sampleCurveY:function(c){return(((this||e).ay*c+(this||e).by)*c+(this||e).cy)*c},sampleCurveDerivativeX:function(c){return(3*(this||e).ax*c+2*(this||e).bx)*c+(this||e).cx},solveCurveX:function(e,c){if(void 0===c&&(c=1e-6),e<0)return 0;if(e>1)return 1;for(var u=e,p=0;p<8;p++){var f=this.sampleCurveX(u)-e;if(Math.abs(f)f?g=u:y=u,u=.5*(y-g)+g;return u},solve:function(e,c){return this.sampleCurveY(this.solveCurveX(e,c))}},Or}(),Nr=Br(jr);class fr{constructor(e,c,u,p,f){this.type=e,this.operator=c,this.interpolation=u,this.input=p,this.labels=[],this.outputs=[];for(const[e,c]of f)this.labels.push(e),this.outputs.push(c)}static interpolationFactor(e,c,u,p){let f=0;if("exponential"===e.name)f=Gr(c,e.base,u,p);else if("linear"===e.name)f=Gr(c,1,u,p);else if("cubic-bezier"===e.name){const m=e.controlPoints;f=new Nr(m[0],m[1],m[2],m[3]).solve(Gr(c,1,u,p))}return f}static parse(e,c){let[u,p,f,...m]=e;if(!Array.isArray(p)||0===p.length)return c.error("Expected an interpolation type expression.",1);if("linear"===p[0])p={name:"linear"};else if("exponential"===p[0]){const e=p[1];if("number"!=typeof e)return c.error("Exponential interpolation requires a numeric base.",1,1);p={name:"exponential",base:e}}else{if("cubic-bezier"!==p[0])return c.error(`Unknown interpolation type ${String(p[0])}`,1,0);{const e=p.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return c.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);p={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return c.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return c.error("Expected an even number of arguments.");if(f=c.parse(f,2,ci),!f)return null;const g=[];let y=null;"interpolate-hcl"!==u&&"interpolate-lab"!==u||c.expectedType==bi?c.expectedType&&"value"!==c.expectedType.kind&&(y=c.expectedType):y=fi;for(let e=0;e=u)return c.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',f);const b=c.parse(p,x,y);if(!b)return null;y=y||b.type,g.push([u,b])}return ji(y,ci)||ji(y,mi)||ji(y,fi)||ji(y,vi)||ji(y,wi)||ji(y,bi)||ji(y,Ei)||ji(y,Ci(ci))?new fr(y,u,p,f,g):c.error(`Type ${Ai(y)} is not interpolatable.`)}evaluate(e){const c=this.labels,u=this.outputs;if(1===c.length)return u[0].evaluate(e);const p=this.input.evaluate(e);if(p<=c[0])return u[0].evaluate(e);const f=c.length;if(p>=c[f-1])return u[f-1].evaluate(e);const m=Lr(c,p),g=fr.interpolationFactor(this.interpolation,p,c[m],c[m+1]),y=u[m].evaluate(e),x=u[m+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return vr(y,x,g);case"color":return Te.interpolate(y,x,g);case"padding":return ze.interpolate(y,x,g);case"colorArray":return Be.interpolate(y,x,g);case"numberArray":return Pe.interpolate(y,x,g);case"variableAnchorOffsetCollection":return Le.interpolate(y,x,g);case"array":return br(y,x,g);case"projectionDefinition":return Re.interpolate(y,x,g)}case"interpolate-hcl":switch(this.type.kind){case"color":return Te.interpolate(y,x,g,"hcl");case"colorArray":return Be.interpolate(y,x,g,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Te.interpolate(y,x,g,"lab");case"colorArray":return Be.interpolate(y,x,g,"lab")}}}eachChild(e){e(this.input);for(const c of this.outputs)e(c)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Gr(e,c,u,p){const f=p-u,m=e-u;return 0===f?0:1===c?m/f:(Math.pow(c,m)-1)/(Math.pow(c,f)-1)}const Ur={color:Te.interpolate,number:vr,padding:ze.interpolate,numberArray:Pe.interpolate,colorArray:Be.interpolate,variableAnchorOffsetCollection:Le.interpolate,array:br};class mr{constructor(e,c){this.type=e,this.args=c}static parse(e,c){if(e.length<2)return c.error("Expected at least one argument.");let u=null;const p=c.expectedType;p&&"value"!==p.kind&&(u=p);const f=[];for(const p of e.slice(1)){const e=c.parse(p,1+f.length,u,void 0,{typeAnnotation:"omit"});if(!e)return null;u=u||e.type,f.push(e)}if(!u)throw new Error("No output type");const m=p&&f.some((e=>Fi(p,e.type)));return new mr(m?gi:u,f)}evaluate(e){let c,u=null,p=0;for(const f of this.args)if(p++,u=f.evaluate(e),u&&u instanceof Oe&&!u.available&&(c||(c=u.name),u=null,p===this.args.length&&(u=c)),null!==u)break;return u}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function Zr(e,c){return"=="===e||"!="===e?"boolean"===c.kind||"string"===c.kind||"number"===c.kind||"null"===c.kind||"value"===c.kind:"string"===c.kind||"number"===c.kind||"value"===c.kind}function Wr(e,c,u,p){return 0===p.compare(c,u)}function Xr(e,c,u){const p="=="!==e&&"!="!==e;return class i{constructor(e,c,u){this.type=pi,this.lhs=e,this.rhs=c,this.collator=u,this.hasUntypedArgument="value"===e.type.kind||"value"===c.type.kind}static parse(e,c){if(3!==e.length&&4!==e.length)return c.error("Expected two or three arguments.");const u=e[0];let f=c.parse(e[1],1,gi);if(!f)return null;if(!Zr(u,f.type))return c.concat(1).error(`"${u}" comparisons are not supported for type '${Ai(f.type)}'.`);let m=c.parse(e[2],2,gi);if(!m)return null;if(!Zr(u,m.type))return c.concat(2).error(`"${u}" comparisons are not supported for type '${Ai(m.type)}'.`);if(f.type.kind!==m.type.kind&&"value"!==f.type.kind&&"value"!==m.type.kind)return c.error(`Cannot compare types '${Ai(f.type)}' and '${Ai(m.type)}'.`);p&&("value"===f.type.kind&&"value"!==m.type.kind?f=new Xe(m.type,[f]):"value"!==f.type.kind&&"value"===m.type.kind&&(m=new Xe(f.type,[m])));let g=null;if(4===e.length){if("string"!==f.type.kind&&"string"!==m.type.kind&&"value"!==f.type.kind&&"value"!==m.type.kind)return c.error("Cannot use collator to compare non-string types.");if(g=c.parse(e[3],3,yi),!g)return null}return new i(f,m,g)}evaluate(f){const m=this.lhs.evaluate(f),g=this.rhs.evaluate(f);if(p&&this.hasUntypedArgument){const c=Ar(m),u=Ar(g);if(c.kind!==u.kind||"string"!==c.kind&&"number"!==c.kind)throw new Ve(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${c.kind}, ${u.kind}) instead.`)}if(this.collator&&!p&&this.hasUntypedArgument){const e=Ar(m),u=Ar(g);if("string"!==e.kind||"string"!==u.kind)return c(f,m,g)}return this.collator?u(f,m,g,this.collator.evaluate(f)):c(f,m,g)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const Yr=Xr("==",(function(e,c,u){return c===u}),Wr),Kr=Xr("!=",(function(e,c,u){return c!==u}),(function(e,c,u,p){return!Wr(0,c,u,p)})),Qr=Xr("<",(function(e,c,u){return c",(function(e,c,u){return c>u}),(function(e,c,u,p){return p.compare(c,u)>0})),en=Xr("<=",(function(e,c,u){return c<=u}),(function(e,c,u,p){return p.compare(c,u)<=0})),tn=Xr(">=",(function(e,c,u){return c>=u}),(function(e,c,u,p){return p.compare(c,u)>=0}));class Mr{constructor(e,c,u){this.type=yi,this.locale=u,this.caseSensitive=e,this.diacriticSensitive=c}static parse(e,c){if(2!==e.length)return c.error("Expected one argument.");const u=e[1];if("object"!=typeof u||Array.isArray(u))return c.error("Collator options argument must be an object.");const p=c.parse(void 0!==u["case-sensitive"]&&u["case-sensitive"],1,pi);if(!p)return null;const f=c.parse(void 0!==u["diacritic-sensitive"]&&u["diacritic-sensitive"],1,pi);if(!f)return null;let m=null;return u.locale&&(m=c.parse(u.locale,1,ui),!m)?null:new Mr(p,f,m)}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,c,u,p,f){this.type=ui,this.number=e,this.locale=c,this.currency=u,this.minFractionDigits=p,this.maxFractionDigits=f}static parse(e,c){if(3!==e.length)return c.error("Expected two arguments.");const u=c.parse(e[1],1,ci);if(!u)return null;const p=e[2];if("object"!=typeof p||Array.isArray(p))return c.error("NumberFormat options argument must be an object.");let f=null;if(p.locale&&(f=c.parse(p.locale,1,ui),!f))return null;let m=null;if(p.currency&&(m=c.parse(p.currency,1,ui),!m))return null;let g=null;if(p["min-fraction-digits"]&&(g=c.parse(p["min-fraction-digits"],1,ci),!g))return null;let y=null;return p["max-fraction-digits"]&&(y=c.parse(p["max-fraction-digits"],1,ci),!y)?null:new Tr(u,f,m,g,y)}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=xi,this.sections=e}static parse(e,c){if(e.length<2)return c.error("Expected at least one argument.");const u=e[1];if(!Array.isArray(u)&&"object"==typeof u)return c.error("First argument must be an image or text section.");const p=[];let f=!1;for(let u=1;u<=e.length-1;++u){const m=e[u];if(f&&"object"==typeof m&&!Array.isArray(m)){f=!1;let e=null;if(m["font-scale"]&&(e=c.parse(m["font-scale"],1,ci),!e))return null;let u=null;if(m["text-font"]&&(u=c.parse(m["text-font"],1,Ci(ui)),!u))return null;let g=null;if(m["text-color"]&&(g=c.parse(m["text-color"],1,fi),!g))return null;let y=null;if(m["vertical-align"]){if("string"==typeof m["vertical-align"]&&!wr.includes(m["vertical-align"]))return c.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${m["vertical-align"]}' instead.`);if(y=c.parse(m["vertical-align"],1,ui),!y)return null}const x=p[p.length-1];x.scale=e,x.font=u,x.textColor=g,x.verticalAlign=y}else{const m=c.parse(e[u],1,gi);if(!m)return null;const g=m.type.kind;if("string"!==g&&"value"!==g&&"null"!==g&&"resolvedImage"!==g)return c.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");f=!0,p.push({content:m,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Ir(p)}evaluate(e){return new De(this.sections.map((c=>{const u=c.content.evaluate(e);return Ar(u)===Ii?new Fe("",u,null,null,null,c.verticalAlign?c.verticalAlign.evaluate(e):null):new Fe(Dr(u),null,c.scale?c.scale.evaluate(e):null,c.font?c.font.evaluate(e).join(","):null,c.textColor?c.textColor.evaluate(e):null,c.verticalAlign?c.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const c of this.sections)e(c.content),c.scale&&e(c.scale),c.font&&e(c.font),c.textColor&&e(c.textColor),c.verticalAlign&&e(c.verticalAlign)}outputDefined(){return!1}}class Er{constructor(e){this.type=Ii,this.input=e}static parse(e,c){if(2!==e.length)return c.error("Expected two arguments.");const u=c.parse(e[1],1,ui);return u?new Er(u):c.error("No image name provided.")}evaluate(e){const c=this.input.evaluate(e),u=Oe.fromString(c);return u&&e.availableImages&&(u.available=e.availableImages.indexOf(c)>-1),u}eachChild(e){e(this.input)}outputDefined(){return!1}}class Fr{constructor(e){this.type=ci,this.input=e}static parse(e,c){if(2!==e.length)return c.error(`Expected 1 argument, but found ${e.length-1} instead.`);const u=c.parse(e[1],1);return u?"array"!==u.type.kind&&"string"!==u.type.kind&&"value"!==u.type.kind?c.error(`Expected argument of type string or array, but found ${Ai(u.type)} instead.`):new Fr(u):null}evaluate(e){const c=this.input.evaluate(e);if("string"==typeof c)return[...c].length;if(Array.isArray(c))return c.length;throw new Ve(`Expected value to be of type string or array, but found ${Ai(Ar(c))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const rn=8192;function nn(e,c){const u=(180+e[0])/360,p=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,f=Math.pow(2,c.z);return[Math.round(u*f*rn),Math.round(p*f*rn)]}function sn(e,c){const u=Math.pow(2,c.z);return[(f=(e[0]/rn+c.x)/u,360*f-180),(p=(e[1]/rn+c.y)/u,360/Math.PI*Math.atan(Math.exp((180-360*p)*Math.PI/180))-90)];var p,f}function an(e,c){e[0]=Math.min(e[0],c[0]),e[1]=Math.min(e[1],c[1]),e[2]=Math.max(e[2],c[0]),e[3]=Math.max(e[3],c[1])}function ln(e,c){return!(e[0]<=c[0]||e[2]>=c[2]||e[1]<=c[1]||e[3]>=c[3])}function cn(e,c,u){const p=e[0]-c[0],f=e[1]-c[1],m=e[0]-u[0],g=e[1]-u[1];return p*g-m*f==0&&p*m<=0&&f*g<=0}function hn(e,c,u,p){return 0!=(f=[p[0]-u[0],p[1]-u[1]])[0]*(m=[c[0]-e[0],c[1]-e[1]])[1]-f[1]*m[0]&&!(!_n(e,c,u,p)||!_n(u,p,e,c));var f,m}function un(e,c,u){for(const p of u)for(let u=0;u(f=e)[1]!=(g=y[c+1])[1]>f[1]&&f[0]<(g[0]-m[0])*(f[1]-m[1])/(g[1]-m[1])+m[0]&&(p=!p)}var f,m,g;return p}function pn(e,c){for(const u of c)if(dn(e,u))return!0;return!1}function fn(e,c){for(const u of e)if(!dn(u,c))return!1;for(let u=0;u0&&y<0||g<0&&y>0}function gn(e,c,u){const p=[];for(let f=0;fu[2]){const c=.5*p;let f=e[0]-u[0]>c?-p:u[0]-e[0]>c?p:0;0===f&&(f=e[0]-u[2]>c?-p:u[2]-e[0]>c?p:0),e[0]+=f}an(c,e)}function vn(e,c,u,p){const f=Math.pow(2,p.z)*rn,m=[p.x*rn,p.y*rn],g=[];for(const p of e)for(const e of p){const p=[e.x+m[0],e.y+m[1]];xn(p,c,u,f),g.push(p)}return g}function bn(e,c,u,p){const f=Math.pow(2,p.z)*rn,m=[p.x*rn,p.y*rn],g=[];for(const u of e){const e=[];for(const p of u){const u=[p.x+m[0],p.y+m[1]];an(c,u),e.push(u)}g.push(e)}if(c[2]-c[0]<=f/2){(y=c)[0]=y[1]=1/0,y[2]=y[3]=-1/0;for(const e of g)for(const p of e)xn(p,c,u,f)}var y;return g}class Hr{constructor(e,c){this.type=pi,this.geojson=e,this.geometries=c}static parse(e,c){if(2!==e.length)return c.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Cr(e[1])){const c=e[1];if("FeatureCollection"===c.type){const e=[];for(const u of c.features){const{type:c,coordinates:p}=u.geometry;"Polygon"===c&&e.push(p),"MultiPolygon"===c&&e.push(...p)}if(e.length)return new Hr(c,{type:"MultiPolygon",coordinates:e})}else if("Feature"===c.type){const e=c.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Hr(c,c.geometry)}else if("Polygon"===c.type||"MultiPolygon"===c.type)return new Hr(c,c)}return c.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,c){const u=[1/0,1/0,-1/0,-1/0],p=[1/0,1/0,-1/0,-1/0],f=e.canonicalID();if("Polygon"===c.type){const m=gn(c.coordinates,p,f),g=vn(e.geometry(),u,p,f);if(!ln(u,p))return!1;for(const e of g)if(!dn(e,m))return!1}if("MultiPolygon"===c.type){const m=yn(c.coordinates,p,f),g=vn(e.geometry(),u,p,f);if(!ln(u,p))return!1;for(const e of g)if(!pn(e,m))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,c){const u=[1/0,1/0,-1/0,-1/0],p=[1/0,1/0,-1/0,-1/0],f=e.canonicalID();if("Polygon"===c.type){const m=gn(c.coordinates,p,f),g=bn(e.geometry(),u,p,f);if(!ln(u,p))return!1;for(const e of g)if(!fn(e,m))return!1}if("MultiPolygon"===c.type){const m=yn(c.coordinates,p,f),g=bn(e.geometry(),u,p,f);if(!ln(u,p))return!1;for(const e of g)if(!mn(e,m))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let wn=class{constructor(e=[],c=(e,c)=>ec?1:0){if(this.data=e,this.length=this.data.length,this.compare=c,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],c=this.data.pop();return--this.length>0&&(this.data[0]=c,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:c,compare:u}=this,p=c[e];for(;e>0;){const f=e-1>>1,m=c[f];if(u(p,m)>=0)break;c[e]=m,e=f}c[e]=p}_down(e){const{data:c,compare:u}=this,p=this.length>>1,f=c[e];for(;e=0)break;c[e]=c[p],e=p}c[e]=f}};function Tn(e,c,u=0,p=e.length-1,f=Pn){for(;p>u;){if(p-u>600){const m=p-u+1,g=c-u+1,y=Math.log(m),x=.5*Math.exp(2*y/3),b=.5*Math.sqrt(y*x*(m-x)/m)*(g-m/2<0?-1:1);Tn(e,c,Math.max(u,Math.floor(c-g*x/m+b)),Math.min(p,Math.floor(c+(m-g)*x/m+b)),f)}const m=e[c];let g=u,y=p;for(Sn(e,u,c),f(e[p],m)>0&&Sn(e,u,p);g0;)y--}0===f(e[u],m)?Sn(e,u,y):(y++,Sn(e,y,p)),y<=c&&(u=y+1),c<=y&&(p=y-1)}}function Sn(e,c,u){const p=e[c];e[c]=e[u],e[u]=p}function Pn(e,c){return ec?1:0}function Mn(e,c){if(e.length<=1)return[e];const u=[];let p,f;for(const c of e){const e=Cn(c);0!==e&&(c.area=Math.abs(e),void 0===f&&(f=e<0),f===e<0?(p&&u.push(p),p=[c]):p.push(c))}if(p&&u.push(p),c>1)for(let e=0;e1?(x=e[y+1][0],b=e[y+1][1]):P>0&&(x+=T/this.kx*P,b+=S/this.ky*P)),T=this.wrap(c[0]-x)*this.kx,S=(c[1]-b)*this.ky;const I=T*T+S*S;I180;)e-=360;return e}}function Rn(e,c){return c[0]-e[0]}function Ln(e){return e[1]-e[0]+1}function Bn(e,c){return e[1]>=e[0]&&e[1]e[1])return[null,null];const u=Ln(e);if(c){if(2===u)return[e,null];const c=Math.floor(u/2);return[[e[0],e[0]+c],[e[0]+c,e[1]]]}if(1===u)return[e,null];const p=Math.floor(u/2)-1;return[[e[0],e[0]+p],[e[0]+p+1,e[1]]]}function Vn(e,c){if(!Bn(c,e.length))return[1/0,1/0,-1/0,-1/0];const u=[1/0,1/0,-1/0,-1/0];for(let p=c[0];p<=c[1];++p)an(u,e[p]);return u}function jn(e){const c=[1/0,1/0,-1/0,-1/0];for(const u of e)for(const e of u)an(c,e);return c}function Nn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Gn(e,c,u){if(!Nn(e)||!Nn(c))return NaN;let p=0,f=0;return e[2]c[2]&&(p=e[0]-c[2]),e[1]>c[3]&&(f=e[1]-c[3]),e[3]=p)return p;if(ln(f,m)){if(Xn(e,c))return 0}else if(Xn(c,e))return 0;let g=1/0;for(const p of e)for(let e=0,f=p.length,m=f-1;e0;){const f=g.pop();if(f[0]>=m)continue;const x=f[1],b=c?50:100;if(Ln(x)<=b){if(!Bn(x,e.length))return NaN;if(c){const c=Hn(e,x,u,p);if(isNaN(c)||0===c)return c;m=Math.min(m,c)}else for(let c=x[0];c<=x[1];++c){const f=Wn(e[c],u,p);if(m=Math.min(m,f),0===m)return 0}}else{const u=On(x,c);Kn(g,m,p,e,y,u[0]),Kn(g,m,p,e,y,u[1])}}return m}function es(e,c,u,p,f,m=1/0){let g=Math.min(m,f.distance(e[0],u[0]));if(0===g)return g;const y=new wn([[0,[0,e.length-1],[0,u.length-1]]],Rn);for(;y.length>0;){const m=y.pop();if(m[0]>=g)continue;const x=m[1],b=m[2],T=c?50:100,S=p?50:100;if(Ln(x)<=T&&Ln(b)<=S){if(!Bn(x,e.length)&&Bn(b,u.length))return NaN;let m;if(c&&p)m=Zn(e,x,u,b,f),g=Math.min(g,m);else if(c&&!p){const c=e.slice(x[0],x[1]+1);for(let e=b[0];e<=b[1];++e)if(m=Un(u[e],c,f),g=Math.min(g,m),0===g)return g}else if(!c&&p){const c=u.slice(b[0],b[1]+1);for(let u=x[0];u<=x[1];++u)if(m=Un(e[u],c,f),g=Math.min(g,m),0===g)return g}else m=$n(e,x,u,b,f),g=Math.min(g,m)}else{const m=On(x,c),T=On(b,p);Qn(y,g,f,e,u,m[0],T[0]),Qn(y,g,f,e,u,m[0],T[1]),Qn(y,g,f,e,u,m[1],T[0]),Qn(y,g,f,e,u,m[1],T[1])}}return g}function ns(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 En{constructor(e,c){this.type=ci,this.geojson=e,this.geometries=c}static parse(e,c){if(2!==e.length)return c.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Cr(e[1])){const c=e[1];if("FeatureCollection"===c.type)return new En(c,c.features.map((e=>ns(e.geometry))).flat());if("Feature"===c.type)return new En(c,ns(c.geometry));if("type"in c&&"coordinates"in c)return new En(c,ns(c))}return c.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,c){const u=e.geometry(),p=u.flat().map((c=>sn([c.x,c.y],e.canonical)));if(0===u.length)return NaN;const f=new on(p[0][1]);let m=1/0;for(const e of c){switch(e.type){case"Point":m=Math.min(m,es(p,!1,[e.coordinates],!1,f,m));break;case"LineString":m=Math.min(m,es(p,!1,e.coordinates,!0,f,m));break;case"Polygon":m=Math.min(m,Jn(p,!1,e.coordinates,f,m))}if(0===m)return m}return m}(e,this.geometries);if("LineString"===e.geometryType())return function(e,c){const u=e.geometry(),p=u.flat().map((c=>sn([c.x,c.y],e.canonical)));if(0===u.length)return NaN;const f=new on(p[0][1]);let m=1/0;for(const e of c){switch(e.type){case"Point":m=Math.min(m,es(p,!0,[e.coordinates],!1,f,m));break;case"LineString":m=Math.min(m,es(p,!0,e.coordinates,!0,f,m));break;case"Polygon":m=Math.min(m,Jn(p,!0,e.coordinates,f,m))}if(0===m)return m}return m}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,c){const u=e.geometry();if(0===u.length||0===u[0].length)return NaN;const p=Mn(u,0).map((c=>c.map((c=>c.map((c=>sn([c.x,c.y],e.canonical))))))),f=new on(p[0][0][0][1]);let m=1/0;for(const e of c)for(const c of p){switch(e.type){case"Point":m=Math.min(m,Jn([e.coordinates],!1,c,f,m));break;case"LineString":m=Math.min(m,Jn(e.coordinates,!0,c,f,m));break;case"Polygon":m=Math.min(m,Yn(c,e.coordinates,f,m))}if(0===m)return m}return m}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Fn{constructor(e){this.type=gi,this.key=e}static parse(e,c){if(2!==e.length)return c.error(`Expected 1 argument, but found ${e.length-1} instead.`);const u=e[1];return null==u?c.error("Global state property must be defined."):"string"!=typeof u?c.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Fn(u)}evaluate(e){var c;const u=null===(c=e.globals)||void 0===c?void 0:c.globalState;return u&&0!==Object.keys(u).length?dr(u,this.key):null}eachChild(){}outputDefined(){return!1}}const ss={"==":Yr,"!=":Kr,">":Jr,"<":Qr,">=":tn,"<=":en,array:Xe,at:tr,boolean:Xe,case:ir,coalesce:mr,collator:Mr,format:Ir,image:Er,in:er,"index-of":rr,interpolate:fr,"interpolate-hcl":fr,"interpolate-lab":fr,length:Fr,let:Je,literal:qe,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:En,"global-state":Fn};class zn{constructor(e,c,u,p){this.name=e,this.type=c,this._evaluate=u,this.args=p}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,c){const u=e[0],p=zn.definitions[u];if(!p)return c.error(`Unknown expression "${u}". If you wanted a literal array, use ["literal", [...]].`,0);const f=Array.isArray(p)?p[0]:p.type,m=Array.isArray(p)?[[p[1],p[2]]]:p.overloads,g=m.filter((([c])=>!Array.isArray(c)||c.length===e.length-1));let y=null;for(const[p,m]of g){y=new We(c.registry,fs,c.path,null,c.scope);const g=[];let x=!1;for(let c=1;c{return c=e,Array.isArray(c)?`(${c.map(Ai).join(", ")})`:`(${Ai(c.type)}...)`;var c})).join(" | "),p=[];for(let u=1;u{u=c?u&&fs(e):u&&e instanceof qe})),!!u&&_s(e)&&ys(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function _s(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 En)return!1;let c=!0;return e.eachChild((e=>{c&&!_s(e)&&(c=!1)})),c}function gs(e){if(e instanceof zn&&"feature-state"===e.name)return!1;let c=!0;return e.eachChild((e=>{c&&!gs(e)&&(c=!1)})),c}function ys(e,c){if(e instanceof zn&&c.indexOf(e.name)>=0)return!1;let u=!0;return e.eachChild((e=>{u&&!ys(e,c)&&(u=!1)})),u}function vs(e){return{result:"success",value:e}}function bs(e){return{result:"error",value:e}}function ws(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Ts(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Ss(e){return!!e.expression&&e.expression.interpolated}function Ms(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Is(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Ar(e)===_i}function Es(e){return e}function As(e,c){const u=e.stops&&"object"==typeof e.stops[0][0],p=u||!(u||void 0!==e.property),f=e.type||(Ss(c)?"exponential":"interval"),m=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}}(c);if(m&&((e=ni({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],m(e[1])]))),e.default=m(e.default?e.default:c.default)),e.colorSpace&&"rgb"!==(g=e.colorSpace)&&"hcl"!==g&&"lab"!==g)throw new Error(`Unknown color space: "${e.colorSpace}"`);var g;const y=function(e){switch(e){case"exponential":return Fs;case"interval":return ks;case"categorical":return zs;case"identity":return Bs;default:throw new Error(`Unknown function type "${e}"`)}}(f);let x,b;if("categorical"===f){x=Object.create(null);for(const c of e.stops)x[c[0]]=c[1];b=typeof e.stops[0][0]}if(u){const u={},p=[];for(let c=0;ce[0])),evaluate:({zoom:u},p)=>Fs({stops:f,base:e.base},c,u).evaluate(u,p)}}if(p){const u="exponential"===f?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:u,interpolationFactor:fr.interpolationFactor.bind(void 0,u),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:u})=>y(e,c,u,x,b)}}return{kind:"source",evaluate(u,p){const f=p&&p.properties?p.properties[e.property]:void 0;return void 0===f?Ds(e.default,c.default):y(e,c,f,x,b)}}}function Ds(e,c,u){return void 0!==e?e:void 0!==c?c:void 0!==u?u:void 0}function zs(e,c,u,p,f){return Ds(typeof u===f?p[u]:void 0,e.default,c.default)}function ks(e,c,u){if("number"!==Ms(u))return Ds(e.default,c.default);const p=e.stops.length;if(1===p)return e.stops[0][1];if(u<=e.stops[0][0])return e.stops[0][1];if(u>=e.stops[p-1][0])return e.stops[p-1][1];const f=Lr(e.stops.map((e=>e[0])),u);return e.stops[f][1]}function Fs(e,c,u){const p=void 0!==e.base?e.base:1;if("number"!==Ms(u))return Ds(e.default,c.default);const f=e.stops.length;if(1===f)return e.stops[0][1];if(u<=e.stops[0][0])return e.stops[0][1];if(u>=e.stops[f-1][0])return e.stops[f-1][1];const m=Lr(e.stops.map((e=>e[0])),u),g=function(e,c,u,p){const f=p-u,m=e-u;return 0===f?0:1===c?m/f:(Math.pow(c,m)-1)/(Math.pow(c,f)-1)}(u,p,e.stops[m][0],e.stops[m+1][0]),y=e.stops[m][1],x=e.stops[m+1][1],b=Ur[c.type]||Es;return"function"==typeof y.evaluate?{evaluate(...c){const u=y.evaluate.apply(void 0,c),p=x.evaluate.apply(void 0,c);if(void 0!==u&&void 0!==p)return b(u,p,g,e.colorSpace)}}:b(y,x,g,e.colorSpace)}function Bs(e,c,u){switch(c.type){case"color":u=Te.parse(u);break;case"formatted":u=De.fromString(u.toString());break;case"resolvedImage":u=Oe.fromString(u.toString());break;case"padding":u=ze.parse(u);break;case"colorArray":u=Be.parse(u);break;case"numberArray":u=Pe.parse(u);break;default:Ms(u)===c.type||"enum"===c.type&&c.values[u]||(u=void 0)}return Ds(u,e.default,c.default)}zn.register(ss,{error:[{kind:"error"},[ui],(e,[c])=>{throw new Ve(c.evaluate(e))}],typeof:[ui,[gi],(e,[c])=>Ai(Ar(c.evaluate(e)))],"to-rgba":[Ci(ci,4),[fi],(e,[c])=>{const[u,p,f,m]=c.evaluate(e).rgb;return[255*u,255*p,255*f,m]}],rgb:[fi,[ci,ci,ci],ls],rgba:[fi,[ci,ci,ci,ci],ls],has:{type:pi,overloads:[[[ui],(e,[c])=>us(c.evaluate(e),e.properties())],[[ui,_i],(e,[c,u])=>us(c.evaluate(e),u.evaluate(e))]]},get:{type:gi,overloads:[[[ui],(e,[c])=>ds(c.evaluate(e),e.properties())],[[ui,_i],(e,[c,u])=>ds(c.evaluate(e),u.evaluate(e))]]},"feature-state":[gi,[ui],(e,[c])=>ds(c.evaluate(e),e.featureState||{})],properties:[_i,[],e=>e.properties()],"geometry-type":[ui,[],e=>e.geometryType()],id:[gi,[],e=>e.id()],zoom:[ci,[],e=>e.globals.zoom],"heatmap-density":[ci,[],e=>e.globals.heatmapDensity||0],elevation:[ci,[],e=>e.globals.elevation||0],"line-progress":[ci,[],e=>e.globals.lineProgress||0],accumulated:[gi,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ci,ps(ci),(e,c)=>{let u=0;for(const p of c)u+=p.evaluate(e);return u}],"*":[ci,ps(ci),(e,c)=>{let u=1;for(const p of c)u*=p.evaluate(e);return u}],"-":{type:ci,overloads:[[[ci,ci],(e,[c,u])=>c.evaluate(e)-u.evaluate(e)],[[ci],(e,[c])=>-c.evaluate(e)]]},"/":[ci,[ci,ci],(e,[c,u])=>c.evaluate(e)/u.evaluate(e)],"%":[ci,[ci,ci],(e,[c,u])=>c.evaluate(e)%u.evaluate(e)],ln2:[ci,[],()=>Math.LN2],pi:[ci,[],()=>Math.PI],e:[ci,[],()=>Math.E],"^":[ci,[ci,ci],(e,[c,u])=>Math.pow(c.evaluate(e),u.evaluate(e))],sqrt:[ci,[ci],(e,[c])=>Math.sqrt(c.evaluate(e))],log10:[ci,[ci],(e,[c])=>Math.log(c.evaluate(e))/Math.LN10],ln:[ci,[ci],(e,[c])=>Math.log(c.evaluate(e))],log2:[ci,[ci],(e,[c])=>Math.log(c.evaluate(e))/Math.LN2],sin:[ci,[ci],(e,[c])=>Math.sin(c.evaluate(e))],cos:[ci,[ci],(e,[c])=>Math.cos(c.evaluate(e))],tan:[ci,[ci],(e,[c])=>Math.tan(c.evaluate(e))],asin:[ci,[ci],(e,[c])=>Math.asin(c.evaluate(e))],acos:[ci,[ci],(e,[c])=>Math.acos(c.evaluate(e))],atan:[ci,[ci],(e,[c])=>Math.atan(c.evaluate(e))],min:[ci,ps(ci),(e,c)=>Math.min(...c.map((c=>c.evaluate(e))))],max:[ci,ps(ci),(e,c)=>Math.max(...c.map((c=>c.evaluate(e))))],abs:[ci,[ci],(e,[c])=>Math.abs(c.evaluate(e))],round:[ci,[ci],(e,[c])=>{const u=c.evaluate(e);return u<0?-Math.round(-u):Math.round(u)}],floor:[ci,[ci],(e,[c])=>Math.floor(c.evaluate(e))],ceil:[ci,[ci],(e,[c])=>Math.ceil(c.evaluate(e))],"filter-==":[pi,[ui,gi],(e,[c,u])=>e.properties()[c.value]===u.value],"filter-id-==":[pi,[gi],(e,[c])=>e.id()===c.value],"filter-type-==":[pi,[ui],(e,[c])=>e.geometryType()===c.value],"filter-<":[pi,[ui,gi],(e,[c,u])=>{const p=e.properties()[c.value],f=u.value;return typeof p==typeof f&&p{const u=e.id(),p=c.value;return typeof u==typeof p&&u":[pi,[ui,gi],(e,[c,u])=>{const p=e.properties()[c.value],f=u.value;return typeof p==typeof f&&p>f}],"filter-id->":[pi,[gi],(e,[c])=>{const u=e.id(),p=c.value;return typeof u==typeof p&&u>p}],"filter-<=":[pi,[ui,gi],(e,[c,u])=>{const p=e.properties()[c.value],f=u.value;return typeof p==typeof f&&p<=f}],"filter-id-<=":[pi,[gi],(e,[c])=>{const u=e.id(),p=c.value;return typeof u==typeof p&&u<=p}],"filter->=":[pi,[ui,gi],(e,[c,u])=>{const p=e.properties()[c.value],f=u.value;return typeof p==typeof f&&p>=f}],"filter-id->=":[pi,[gi],(e,[c])=>{const u=e.id(),p=c.value;return typeof u==typeof p&&u>=p}],"filter-has":[pi,[gi],(e,[c])=>c.value in e.properties()],"filter-has-id":[pi,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[pi,[Ci(ui)],(e,[c])=>c.value.indexOf(e.geometryType())>=0],"filter-id-in":[pi,[Ci(gi)],(e,[c])=>c.value.indexOf(e.id())>=0],"filter-in-small":[pi,[ui,Ci(gi)],(e,[c,u])=>u.value.indexOf(e.properties()[c.value])>=0],"filter-in-large":[pi,[ui,Ci(gi)],(e,[c,u])=>function(e,c,u,p){for(;u<=p;){const f=u+p>>1;if(c[f]===e)return!0;c[f]>e?p=f-1:u=f+1}return!1}(e.properties()[c.value],u.value,0,u.value.length-1)],all:{type:pi,overloads:[[[pi,pi],(e,[c,u])=>c.evaluate(e)&&u.evaluate(e)],[ps(pi),(e,c)=>{for(const u of c)if(!u.evaluate(e))return!1;return!0}]]},any:{type:pi,overloads:[[[pi,pi],(e,[c,u])=>c.evaluate(e)||u.evaluate(e)],[ps(pi),(e,c)=>{for(const u of c)if(u.evaluate(e))return!0;return!1}]]},"!":[pi,[pi],(e,[c])=>!c.evaluate(e)],"is-supported-script":[pi,[ui],(e,[c])=>{const u=e.globals&&e.globals.isSupportedScript;return!u||u(c.evaluate(e))}],upcase:[ui,[ui],(e,[c])=>c.evaluate(e).toUpperCase()],downcase:[ui,[ui],(e,[c])=>c.evaluate(e).toLowerCase()],concat:[ui,ps(gi),(e,c)=>c.map((c=>Dr(c.evaluate(e)))).join("")],"resolved-locale":[ui,[yi],(e,[c])=>c.evaluate(e).resolvedLocale()]});class ei{constructor(e,c,u){this.expression=e,this._warningHistory={},this._evaluator=new Ke,this._defaultValue=c?function(e){if("color"===e.type&&Is(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}}(c):null,this._enumValues=c&&"enum"===c.type?c.values:null,this._globalState=u}evaluateWithoutErrorHandling(e,c,u,p,f,m){return this._globalState&&(e=vo(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=c,this._evaluator.featureState=u,this._evaluator.canonical=p,this._evaluator.availableImages=f||null,this._evaluator.formattedSection=m,this.expression.evaluate(this._evaluator)}evaluate(e,c,u,p,f,m){this._globalState&&(e=vo(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=c||null,this._evaluator.featureState=u||null,this._evaluator.canonical=p,this._evaluator.availableImages=f||null,this._evaluator.formattedSection=m||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 Vs(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in ss}function Ws(e,c,u){const p=new We(ss,fs,[],c?function(e){const c={color:fi,string:ui,number:ci,enum:ui,boolean:pi,formatted:xi,padding:vi,numberArray:wi,colorArray:bi,projectionDefinition:mi,resolvedImage:Ii,variableAnchorOffsetCollection:Ei};return"array"===e.type?Ci(c[e.value]||gi,e.length):c[e.type]}(c):void 0),f=p.parse(e,void 0,void 0,void 0,c&&"string"===c.type?{typeAnnotation:"coerce"}:void 0);return f?vs(new ei(f,c,u)):bs(p.errors)}class ii{constructor(e,c,u){this.kind=e,this._styleExpression=c,this.isStateDependent="constant"!==e&&!gs(c.expression),this.globalStateRefs=fo(c.expression),this._globalState=u}evaluateWithoutErrorHandling(e,c,u,p,f,m){return this._globalState&&(e=vo(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,c,u,p,f,m)}evaluate(e,c,u,p,f,m){return this._globalState&&(e=vo(e,this._globalState)),this._styleExpression.evaluate(e,c,u,p,f,m)}}class si{constructor(e,c,u,p,f){this.kind=e,this.zoomStops=u,this._styleExpression=c,this.isStateDependent="camera"!==e&&!gs(c.expression),this.globalStateRefs=fo(c.expression),this.interpolationType=p,this._globalState=f}evaluateWithoutErrorHandling(e,c,u,p,f,m){return this._globalState&&(e=vo(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,c,u,p,f,m)}evaluate(e,c,u,p,f,m){return this._globalState&&(e=vo(e,this._globalState)),this._styleExpression.evaluate(e,c,u,p,f,m)}interpolationFactor(e,c,u){return this.interpolationType?fr.interpolationFactor(this.interpolationType,e,c,u):0}}function Js(e,c,u){const p=Ws(e,c,u);if("error"===p.result)return p;const f=p.value.expression,m=_s(f);if(!m&&!ws(c))return bs([new Pt("","data expressions not supported")]);const g=ys(f,["zoom"]);if(!g&&!Ts(c))return bs([new Pt("","zoom expressions not supported")]);const y=ho(f);return y||g?y instanceof Pt?bs([y]):y instanceof fr&&!Ss(c)?bs([new Pt("",'"interpolate" expressions cannot be used with this property')]):vs(y?new si(m?"camera":"composite",p.value,y.labels,y instanceof fr?y.interpolation:void 0,u):new ii(m?"constant":"source",p.value,u)):bs([new Pt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class oi{constructor(e,c){this._parameters=e,this._specification=c,ni(this,As(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 ho(e){let c=null;if(e instanceof Je)c=ho(e.result);else if(e instanceof mr){for(const u of e.args)if(c=ho(u),c)break}else(e instanceof or||e instanceof fr)&&e.input instanceof zn&&"zoom"===e.input.name&&(c=e);return c instanceof Pt||e.eachChild((e=>{const u=ho(e);u instanceof Pt?c=u:!c&&u?c=new Pt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):c&&u&&c!==u&&(c=new Pt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),c}function fo(e,c=new Set){return e instanceof Fn&&c.add(e.key),e.eachChild((e=>{fo(e,c)})),c}function vo(e,c){const{zoom:u,heatmapDensity:p,elevation:f,lineProgress:m,isSupportedScript:g,accumulated:y}=null!=e?e:{};return{zoom:u,heatmapDensity:p,elevation:f,lineProgress:m,isSupportedScript:g,accumulated:y,globalState:c}}function Co(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 c of e.slice(1))if(!Co(c)&&"boolean"!=typeof c)return!1;return!0;default:return!0}}const ko={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Lo(e,c){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Co(e)||(e=ta(e));const u=Ws(e,ko,c);if("error"===u.result)throw new Error(u.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,c,p)=>u.value.evaluate(e,c,{},p),needGeometry:Ko(e),getGlobalStateRefs:()=>fo(u.value.expression)}}function $o(e,c){return ec?1:0}function Ko(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let c=1;c"===c||"<="===c||">="===c?ia(e[1],e[2],c):"any"===c?(u=e.slice(1),["any"].concat(u.map(ta))):"all"===c?["all"].concat(e.slice(1).map(ta)):"none"===c?["all"].concat(e.slice(1).map(ta).map(tl)):"in"===c?na(e[1],e.slice(2)):"!in"===c?tl(na(e[1],e.slice(2))):"has"===c?el(e[1]):"!has"!==c||tl(el(e[1]));var u}function ia(e,c,u){switch(e){case"$type":return[`filter-type-${u}`,c];case"$id":return[`filter-id-${u}`,c];default:return[`filter-${u}`,e,c]}}function na(e,c){if(0===c.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",c]];case"$id":return["filter-id-in",["literal",c]];default:return c.length>200&&!c.some((e=>typeof e!=typeof c[0]))?["filter-in-large",e,["literal",c.sort($o)]]:["filter-in-small",e,["literal",c]]}}function el(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function tl(e){return["!",e]}function il(e){const c=typeof e;if("number"===c||"boolean"===c||"string"===c||null==e)return JSON.stringify(e);if(Array.isArray(e)){let c="[";for(const u of e)c+=`${il(u)},`;return`${c}]`}const u=Object.keys(e).sort();let p="{";for(let c=0;cp.maximum?[new Dt(c,u,`${u} is greater than the maximum value ${p.maximum}`)]:[]}function hl(e){const c=e.valueSpec,u=sl(e.value.type);let p,f,m,g={};const y="categorical"!==u&&void 0===e.value.property,x=!y,b="array"===Ms(e.value.stops)&&"array"===Ms(e.value.stops[0])&&"object"===Ms(e.value.stops[0][0]),T=al({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"===u)return[new Dt(e.key,e.value,'identity function may not have a "stops" property')];let c=[];const p=e.value;return c=c.concat(ll({key:e.key,value:p,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:S})),"array"===Ms(p)&&0===p.length&&c.push(new Dt(e.key,p,"array must have at least one stop")),c},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:c,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===u&&y&&T.push(new Dt(e.key,e.value,'missing required property "property"')),"identity"===u||e.value.stops||T.push(new Dt(e.key,e.value,'missing required property "stops"')),"exponential"===u&&e.valueSpec.expression&&!Ss(e.valueSpec)&&T.push(new Dt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(x&&!ws(e.valueSpec)?T.push(new Dt(e.key,e.value,"property functions not supported")):y&&!Ts(e.valueSpec)&&T.push(new Dt(e.key,e.value,"zoom functions not supported"))),"categorical"!==u&&!b||void 0!==e.value.property||T.push(new Dt(e.key,e.value,'"property" property is required')),T;function S(e){let u=[];const p=e.value,y=e.key;if("array"!==Ms(p))return[new Dt(y,p,`array expected, ${Ms(p)} found`)];if(2!==p.length)return[new Dt(y,p,`array length 2 expected, length ${p.length} found`)];if(b){if("object"!==Ms(p[0]))return[new Dt(y,p,`object expected, ${Ms(p[0])} found`)];if(void 0===p[0].zoom)return[new Dt(y,p,"object stop key must have zoom")];if(void 0===p[0].value)return[new Dt(y,p,"object stop key must have value")];if(m&&m>sl(p[0].zoom))return[new Dt(y,p[0].zoom,"stop zoom values must appear in ascending order")];sl(p[0].zoom)!==m&&(m=sl(p[0].zoom),f=void 0,g={}),u=u.concat(al({key:`${y}[0]`,value:p[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:cl,value:P}}))}else u=u.concat(P({key:`${y}[0]`,value:p[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},p));return Vs(ol(p[1]))?u.concat([new Dt(`${y}[1]`,p[1],"expressions are not allowed in function stops.")]):u.concat(e.validateSpec({key:`${y}[1]`,value:p[1],valueSpec:c,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function P(e,m){const y=Ms(e.value),x=sl(e.value),b=null!==e.value?e.value:m;if(p){if(y!==p)return[new Dt(e.key,b,`${y} stop domain type must match previous stop domain type ${p}`)]}else p=y;if("number"!==y&&"string"!==y&&"boolean"!==y)return[new Dt(e.key,b,"stop domain value must be a number, string, or boolean")];if("number"!==y&&"categorical"!==u){let p=`number expected, ${y} found`;return ws(c)&&void 0===u&&(p+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Dt(e.key,b,p)]}return"categorical"!==u||"number"!==y||isFinite(x)&&Math.floor(x)===x?"categorical"!==u&&"number"===y&&void 0!==f&&xnew Dt(`${e.key}${c.key}`,e.value,c.message)));const u=c.value.expression||c.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!u.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&&!gs(u))return[new Dt(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!gs(u))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(!ys(u,["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&&!_s(u))return[new Dt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function dl(e){const c=e.key,u=e.value,p=Ms(u);return"string"!==p?[new Dt(c,u,`color expected, ${p} found`)]:Te.parse(String(u))?[]:[new Dt(c,u,`color expected, "${u}" found`)]}function pl(e){const c=e.key,u=e.value,p=e.valueSpec,f=[];return Array.isArray(p.values)?-1===p.values.indexOf(sl(u))&&f.push(new Dt(c,u,`expected one of [${p.values.join(", ")}], ${JSON.stringify(u)} found`)):-1===Object.keys(p.values).indexOf(sl(u))&&f.push(new Dt(c,u,`expected one of [${Object.keys(p.values).join(", ")}], ${JSON.stringify(u)} found`)),f}function fl(e){return Co(ol(e.value))?ul(ni({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):gl(e)}function gl(e){const c=e.value,u=e.key;if("array"!==Ms(c))return[new Dt(u,c,`array expected, ${Ms(c)} found`)];const p=e.styleSpec;let f,m=[];if(c.length<1)return[new Dt(u,c,"filter array must have at least 1 element")];switch(m=m.concat(pl({key:`${u}[0]`,value:c[0],valueSpec:p.filter_operator,style:e.style,styleSpec:e.styleSpec})),sl(c[0])){case"<":case"<=":case">":case">=":c.length>=2&&"$type"===sl(c[1])&&m.push(new Dt(u,c,`"$type" cannot be use with operator "${c[0]}"`));case"==":case"!=":3!==c.length&&m.push(new Dt(u,c,`filter array for operator "${c[0]}" must have 3 elements`));case"in":case"!in":c.length>=2&&(f=Ms(c[1]),"string"!==f&&m.push(new Dt(`${u}[1]`,c[1],`string expected, ${f} found`)));for(let g=2;g{e in u&&c.push(new Dt(p,u[e],`"${e}" is prohibited for ref layers`))})),f.layers.forEach((c=>{sl(c.id)===y&&(e=c)})),e?e.ref?c.push(new Dt(p,u.ref,"ref cannot reference another ref layer")):g=sl(e.type):c.push(new Dt(p,u.ref,`ref layer "${y}" not found`))}else if("background"!==g)if(u.source){const e=f.sources&&f.sources[u.source],m=e&&sl(e.type);e?"vector"===m&&"raster"===g?c.push(new Dt(p,u.source,`layer "${u.id}" requires a raster source`)):"raster-dem"!==m&&"hillshade"===g||"raster-dem"!==m&&"color-relief"===g?c.push(new Dt(p,u.source,`layer "${u.id}" requires a raster-dem source`)):"raster"===m&&"raster"!==g?c.push(new Dt(p,u.source,`layer "${u.id}" requires a vector source`)):"vector"!==m||u["source-layer"]?"raster-dem"===m&&"hillshade"!==g&&"color-relief"!==g?c.push(new Dt(p,u.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==g||!u.paint||!u.paint["line-gradient"]||"geojson"===m&&e.lineMetrics||c.push(new Dt(p,u,`layer "${u.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):c.push(new Dt(p,u,`layer "${u.id}" must specify a "source-layer"`)):c.push(new Dt(p,u.source,`source "${u.source}" not found`))}else c.push(new Dt(p,u,'missing required property "source"'));return c=c.concat(al({key:p,value:u,valueSpec:m.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${p}.type`,value:u.type,valueSpec:m.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:u,objectKey:"type"}),filter:fl,layout:e=>al({layer:u,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>bl(ni({layerType:g},e))}}),paint:e=>al({layer:u,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>vl(ni({layerType:g},e))}})}})),c}function Tl(e){const c=e.value,u=e.key,p=Ms(c);return"string"!==p?[new Dt(u,c,`string expected, ${p} found`)]:[]}const Il={promoteId:function({key:e,value:c}){if("string"===Ms(c))return Tl({key:e,value:c});{const u=[];for(const p in c)u.push(...Tl({key:`${e}.${p}`,value:c[p]}));return u}}};function Cl(e){const c=e.value,u=e.key,p=e.styleSpec,f=e.style,m=e.validateSpec;if(!c.type)return[new Dt(u,c,'"type" is required')];const g=sl(c.type);let y;switch(g){case"vector":case"raster":return y=al({key:u,value:c,valueSpec:p[`source_${g.replace("-","_")}`],style:e.style,styleSpec:p,objectElementValidators:Il,validateSpec:m}),y;case"raster-dem":return y=function(e){var c;const u=null!==(c=e.sourceName)&&void 0!==c?c:"",p=e.value,f=e.styleSpec,m=f.source_raster_dem,g=e.style;let y=[];const x=Ms(p);if(void 0===p)return y;if("object"!==x)return y.push(new Dt("source_raster_dem",p,`object expected, ${x} found`)),y;const b="custom"===sl(p.encoding),T=["redFactor","greenFactor","blueFactor","baseShift"],S=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const c in p)!b&&T.includes(c)?y.push(new Dt(c,p[c],`In "${u}": "${c}" is only valid when "encoding" is set to "custom". ${S} encoding found`)):m[c]?y=y.concat(e.validateSpec({key:c,value:p[c],valueSpec:m[c],validateSpec:e.validateSpec,style:g,styleSpec:f})):y.push(new Dt(c,p[c],`unknown property "${c}"`));return y}({sourceName:u,value:c,style:e.style,styleSpec:p,validateSpec:m}),y;case"geojson":if(y=al({key:u,value:c,valueSpec:p.source_geojson,style:f,styleSpec:p,validateSpec:m,objectElementValidators:Il}),c.cluster)for(const e in c.clusterProperties){const[p,f]=c.clusterProperties[e],m="string"==typeof p?[p,["accumulated"],["get",e]]:p;y.push(...ul({key:`${u}.${e}.map`,value:f,expressionContext:"cluster-map"})),y.push(...ul({key:`${u}.${e}.reduce`,value:m,expressionContext:"cluster-reduce"}))}return y;case"video":return al({key:u,value:c,valueSpec:p.source_video,style:f,validateSpec:m,styleSpec:p});case"image":return al({key:u,value:c,valueSpec:p.source_image,style:f,validateSpec:m,styleSpec:p});case"canvas":return[new Dt(u,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return pl({key:`${u}.type`,value:c.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Al(e){const c=e.value,u=e.styleSpec,p=u.light,f=e.style;let m=[];const g=Ms(c);if(void 0===c)return m;if("object"!==g)return m=m.concat([new Dt("light",c,`object expected, ${g} found`)]),m;for(const g in c){const y=g.match(/^(.*)-transition$/);m=m.concat(y&&p[y[1]]&&p[y[1]].transition?e.validateSpec({key:g,value:c[g],valueSpec:u.transition,validateSpec:e.validateSpec,style:f,styleSpec:u}):p[g]?e.validateSpec({key:g,value:c[g],valueSpec:p[g],validateSpec:e.validateSpec,style:f,styleSpec:u}):[new Dt(g,c[g],`unknown property "${g}"`)])}return m}function Dl(e){const c=e.value,u=e.styleSpec,p=u.sky,f=e.style,m=Ms(c);if(void 0===c)return[];if("object"!==m)return[new Dt("sky",c,`object expected, ${m} found`)];let g=[];for(const m in c)g=g.concat(p[m]?e.validateSpec({key:m,value:c[m],valueSpec:p[m],style:f,styleSpec:u}):[new Dt(m,c[m],`unknown property "${m}"`)]);return g}function kl(e){const c=e.value,u=e.styleSpec,p=u.terrain,f=e.style;let m=[];const g=Ms(c);if(void 0===c)return m;if("object"!==g)return m=m.concat([new Dt("terrain",c,`object expected, ${g} found`)]),m;for(const g in c)m=m.concat(p[g]?e.validateSpec({key:g,value:c[g],valueSpec:p[g],validateSpec:e.validateSpec,style:f,styleSpec:u}):[new Dt(g,c[g],`unknown property "${g}"`)]);return m}function Rl(e){let c=[];const u=e.value,p=e.key;if(Array.isArray(u)){const f=[],m=[];for(const g in u)u[g].id&&f.includes(u[g].id)&&c.push(new Dt(p,u,`all the sprites' ids must be unique, but ${u[g].id} is duplicated`)),f.push(u[g].id),u[g].url&&m.includes(u[g].url)&&c.push(new Dt(p,u,`all the sprites' URLs must be unique, but ${u[g].url} is duplicated`)),m.push(u[g].url),c=c.concat(al({key:`${p}[${g}]`,value:u[g],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return c}return Tl({key:p,value:u})}function Ll(e){return Boolean(e)&&e.constructor===Object}function Fl(e){return Ll(e.value)?[]:[new Dt(e.key,e.value,`object expected, ${Ms(e.value)} found`)]}const Bl={"*":()=>[],array:ll,boolean:function(e){const c=e.value,u=e.key,p=Ms(c);return"boolean"!==p?[new Dt(u,c,`boolean expected, ${p} found`)]:[]},number:cl,color:dl,constants:nl,enum:pl,filter:fl,function:hl,layer:wl,object:al,source:Cl,light:Al,sky:Dl,terrain:kl,projection:function(e){const c=e.value,u=e.styleSpec,p=u.projection,f=e.style,m=Ms(c);if(void 0===c)return[];if("object"!==m)return[new Dt("projection",c,`object expected, ${m} found`)];let g=[];for(const m in c)g=g.concat(p[m]?e.validateSpec({key:m,value:c[m],valueSpec:p[m],style:f,styleSpec:u}):[new Dt(m,c[m],`unknown property "${m}"`)]);return g},projectionDefinition:function(e){const c=e.key;let u=e.value;u=u instanceof String?u.valueOf():u;const p=Ms(u);return"array"!==p||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(u)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(u)?["array","string"].includes(p)?[]:[new Dt(c,u,`projection expected, invalid type "${p}" found`)]:[new Dt(c,u,`projection expected, invalid array ${JSON.stringify(u)} found`)]},string:Tl,formatted:function(e){return 0===Tl(e).length?[]:ul(e)},resolvedImage:function(e){return 0===Tl(e).length?[]:ul(e)},padding:function(e){const c=e.key,u=e.value;if("array"===Ms(u)){if(u.length<1||u.length>4)return[new Dt(c,u,`padding requires 1 to 4 values; ${u.length} values found`)];const p={type:"number"};let f=[];for(let m=0;m[]}})),e.constants&&(u=u.concat(nl({key:"constants",value:e.constants}))),Ul(u)}function Gl(e){return function(c){return e(Object.assign({},c,{validateSpec:Ol}))}}function Ul(e){return[].concat(e).sort(((e,c)=>e.line-c.line))}function ql(c){return function(...u){return Ul(c.apply(this||e,u))}}Nl.source=ql(Gl(Cl)),Nl.sprite=ql(Gl(Rl)),Nl.glyphs=ql(Gl(jl)),Nl.light=ql(Gl(Al)),Nl.sky=ql(Gl(Dl)),Nl.terrain=ql(Gl(kl)),Nl.state=ql(Gl(Fl)),Nl.layer=ql(Gl(wl)),Nl.filter=ql(Gl(fl)),Nl.paintProperty=ql(Gl(vl)),Nl.layoutProperty=ql(Gl(bl));const Zl={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class rs{constructor(e,c){this._globalState=c,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 c=Ws(e,Zl,this._globalState);if("error"===c.result)throw this._literalValue="visible",this._compiledValue=void 0,new Error(c.value.map((e=>`${e.key}: ${e.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=c.value,this._globalStateRefs=fo(c.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const $l=Mt,Wl=Nl,Hl=Wl.light,Xl=Wl.sky,Yl=Wl.paintProperty,Kl=Wl.layoutProperty;function Ql(e,c){let u=!1;if(c&&c.length)for(const p of c)e.fire(new gt(new Error(p.message))),u=!0;return u}class cs{constructor(e,c,u){const p=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const f=new Int32Array(this.arrayBuffer);e=f[0],this.d=(c=f[1])+2*(u=f[2]);for(let e=0;e=b[x+0]&&p>=b[x+1])?(g[S]=!0,m.push(f[S])):g[S]=!1}}}}_forEachCell(e,c,u,p,f,m,g,y){const x=this._convertToCellCoord(e),b=this._convertToCellCoord(c),T=this._convertToCellCoord(u),S=this._convertToCellCoord(p);for(let P=x;P<=T;P++)for(let x=b;x<=S;x++){const b=this.d*x+P;if((!y||y(this._convertFromCellCoord(P),this._convertFromCellCoord(x),this._convertFromCellCoord(P+1),this._convertFromCellCoord(x+1)))&&f.call(this,e,c,u,p,b,m,g,y))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,c=3+this.cells.length+1+1;let u=0;for(let e=0;e=0)continue;const m=e[p];f[p]=Jl[u].shallow.indexOf(p)>=0?m:oc(m,c)}e instanceof Error&&(f.message=e.message)}if(f.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==u&&(f.$name=u),f}function lc(e){if(sc(e))return e;if(Array.isArray(e))return e.map(lc);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const c=nc(e)||"Object";if(!Jl[c])throw new Error(`can't deserialize unregistered class ${c}`);const{klass:u}=Jl[c];if(!u)throw new Error(`can't deserialize unregistered class ${c}`);if(u.deserialize)return u.deserialize(e);const p=Object.create(u.prototype);for(const u of Object.keys(e)){if("$name"===u)continue;const f=e[u];p[u]=Jl[c].shallow.indexOf(u)>=0?f:lc(f)}return p}class xs{constructor(){this.first=!0}update(e,c){const u=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=u,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=u,!0):(this.lastFloorZoom>u?(this.lastIntegerZoom=u+1,this.lastIntegerZoomTime=c):this.lastFloorZoom{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}})).filter((e=>e));return new RegExp(c.join("|"),"u")}const mc=fc(["Arab","Dupl","Mong","Ougr","Syrc"]);function _c(e){return!mc.test(String.fromCodePoint(e))}function gc(e){return!(hc(e)||(c=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(c))));var c}const yc=fc(["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 xc(e){return yc.test(String.fromCodePoint(e))}function vc(e,c){return!(!c&&xc(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function bc(e){for(const c of e)if(xc(c.codePointAt(0)))return!0;return!1}const wc=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(wc.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,c){return u(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const u=e.pluginURL,p=new Promise((e=>{this.loadScriptResolve=e}));c(u);const f=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([p,f]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:u};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${u}`)}))}};class Ps{constructor(e,c){this.isSupportedScript=Pc,this.zoom=e,c?(this.now=c.now||0,this.fadeDuration=c.fadeDuration||0,this.zoomHistory=c.zoomHistory||new xs,this.transition=c.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,c=e-Math.floor(e),u=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:c+(1-c)*u}:{fromScale:.5,toScale:1,t:1-(1-u)*c}}}function Pc(e){return function(e,c){for(const u of e)if(!vc(u.codePointAt(0),c))return!1;return!0}(e,"loaded"===wc.getRTLTextPluginStatus())}const Mc="-transition";class Cs{constructor(e,c,u){this.property=e,this.value=c,this.expression=function(e,c,u){if(Is(e))return new oi(e,c);if(Vs(e)){const p=Js(e,c,u);if("error"===p.result)throw new Error(p.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return p.value}{let u=e;return"color"===c.type&&"string"==typeof e?u=Te.parse(e):"padding"!==c.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==c.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==c.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===c.type&&Array.isArray(e)?u=Le.parse(e):"projectionDefinition"===c.type&&"string"==typeof e&&(u=Re.parse(e)):u=Be.parse(e):u=Pe.parse(e):u=ze.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>u}}}(void 0===c?e.specification.default:c,e.specification,u)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,c,u){return this.property.possiblyEvaluate(this,e,c,u)}}class Ls{constructor(e,c){this.property=e,this.value=new Cs(e,void 0,c)}transitioned(e,c){return new Rs(this.property,this.value,c,ye({},e.transition,this.transition),e.now)}untransitioned(){return new Rs(this.property,this.value,null,{},0)}}class Os{constructor(e,c){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=c}getValue(e){return we(this._values[e].value.value)}setValue(e,c){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===c?void 0:we(c),this._globalState)}getTransition(e){return we(this._values[e].transition)}setTransition(e,c){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ls(this._values[e].property,this._globalState)),this._values[e].transition=we(c)||void 0}serialize(){const e={};for(const c of Object.keys(this._values)){const u=this.getValue(c);void 0!==u&&(e[c]=u);const p=this.getTransition(c);void 0!==p&&(e[`${c}${Mc}`]=p)}return e}transitioned(e,c){const u=new Ns(this._properties);for(const p of Object.keys(this._values))u._values[p]=this._values[p].transitioned(e,c._values[p]);return u}untransitioned(){const e=new Ns(this._properties);for(const c of Object.keys(this._values))e._values[c]=this._values[c].untransitioned();return e}}class Rs{constructor(e,c,u,p,f){this.property=e,this.value=c,this.begin=f+p.delay||0,this.end=this.begin+p.duration||0,e.specification.transition&&(p.delay||p.duration)&&(this.prior=u)}possiblyEvaluate(e,c,u){const p=e.now||0,f=this.value.possiblyEvaluate(e,c,u),m=this.prior;if(m){if(p>this.end)return this.prior=null,f;if(this.value.isDataDriven())return this.prior=null,f;if(pp.zoomHistory.lastIntegerZoom?{from:e,to:c}:{from:u,to:c}}interpolate(e){return e}}class Ys{constructor(e){this.specification=e}possiblyEvaluate(e,c,u,p){if(void 0!==e.value){if("constant"===e.expression.kind){const f=e.expression.evaluate(c,null,{},u,p);return this._calculate(f,f,f,c)}return this._calculate(e.expression.evaluate(new Ps(Math.floor(c.zoom-1),c)),e.expression.evaluate(new Ps(Math.floor(c.zoom),c)),e.expression.evaluate(new Ps(Math.floor(c.zoom+1),c)),c)}}_calculate(e,c,u,p){return p.zoom>p.zoomHistory.lastIntegerZoom?{from:e,to:c}:{from:u,to:c}}interpolate(e){return e}}class Zs{constructor(e){this.specification=e}possiblyEvaluate(e,c,u,p){return!!e.expression.evaluate(c,null,{},u,p)}interpolate(){return!1}}class Hs{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const c in e){const u=e[c];u.specification.overridable&&this.overridableProperties.push(c);const p=this.defaultPropertyValues[c]=new Cs(u,void 0,void 0),f=this.defaultTransitionablePropertyValues[c]=new Ls(u,void 0);this.defaultTransitioningPropertyValues[c]=f.untransitioned(),this.defaultPossiblyEvaluatedValues[c]=p.possiblyEvaluate({})}}}ec("DataDrivenProperty",Gs),ec("DataConstantProperty",qs),ec("CrossFadedDataDrivenProperty",Xs),ec("CrossFadedProperty",Ys),ec("ColorRampProperty",Zs);class Ks extends xt{constructor(e,c,u){if(super(),this.id=e.id,this.type=e.type,this._globalState=u,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(e,c){return new rs(e,c)}(this.visibility,u),"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=Lo(e.filter,u)),c.layout&&(this._unevaluatedLayout=new $s(c.layout,u)),c.paint)){this._transitionablePaint=new Os(c.paint,u);for(const c in e.paint)this.setPaintProperty(c,e.paint[c],{validate:!1});for(const c in e.layout)this.setLayoutProperty(c,e.layout[c],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new js(c.paint)}}setFilter(e){this.filter=e,this._featureFilter=Lo(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 c of this._visibilityExpression.getGlobalStateRefs())e.add(c);if(this._unevaluatedLayout)for(const c in this._unevaluatedLayout._values){const u=this._unevaluatedLayout._values[c];for(const c of u.getGlobalStateRefs())e.add(c)}for(const c of this._featureFilter.getGlobalStateRefs())e.add(c);return e}getPaintAffectingGlobalStateRefs(){var e;const c=new globalThis.Map;if(this._transitionablePaint)for(const u in this._transitionablePaint._values){const p=this._transitionablePaint._values[u].value;for(const f of p.getGlobalStateRefs()){const m=null!==(e=c.get(f))&&void 0!==e?e:[];m.push({name:u,value:p.value}),c.set(f,m)}}return c}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,c,u={}){if(null==c||!this._validate(Kl,`layers.${this.id}.layout.${e}`,e,c,u))return"visibility"===e?(this.visibility=c,this._visibilityExpression.setValue(c),void this.recalculateVisibility()):void this._unevaluatedLayout.setValue(e,c)}getPaintProperty(e){return e.endsWith(Mc)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,c,u={}){if(null!=c&&this._validate(Yl,`layers.${this.id}.paint.${e}`,e,c,u))return!1;if(e.endsWith(Mc))return this._transitionablePaint.setTransition(e.slice(0,-11),c||void 0),!1;{const u=this._transitionablePaint._values[e],p="cross-faded-data-driven"===u.property.specification["property-type"],f=u.value.isDataDriven(),m=u.value;this._transitionablePaint.setValue(e,c),this._handleSpecialPaintPropertyUpdate(e);const g=this._transitionablePaint._values[e].value;return g.isDataDriven()||f||p||this._handleOverridablePaintPropertyUpdate(e,m,g)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,c,u){return!1}isHidden(e=this.minzoom,c=!1){return!!(this.minzoom&&e<(c?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,c){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,c)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,c)}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),be(e,((e,c)=>!(void 0===e||"layout"===c&&!Object.keys(e).length||"paint"===c&&!Object.keys(e).length)))}_validate(e,c,u,p,f={}){return(!f||!1!==f.validate)&&Ql(this,e.call(Wl,{key:c,layerType:this.type,objectKey:u,value:p,styleSpec:Mt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const c=this.paint.get(e);if(c instanceof Us&&ws(c.property.specification)&&("source"===c.value.kind||"composite"===c.value.kind)&&c.value.isStateDependent)return!0}return!1}}let Ic;var Ec={get paint(){return Ic=Ic||new Hs({"raster-opacity":new qs(Mt.paint_raster["raster-opacity"]),"raster-hue-rotate":new qs(Mt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new qs(Mt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new qs(Mt.paint_raster["raster-brightness-max"]),"raster-saturation":new qs(Mt.paint_raster["raster-saturation"]),"raster-contrast":new qs(Mt.paint_raster["raster-contrast"]),"raster-resampling":new qs(Mt.paint_raster["raster-resampling"]),"raster-fade-duration":new qs(Mt.paint_raster["raster-fade-duration"])})}};class Qs extends Ks{constructor(e,c){super(e,Ec,c)}}const Cc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ea{constructor(e,c){this._structArray=e,this._pos1=c*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,c){return e._trim(),c&&(e.isTransferred=!0,c.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const c=Object.create(this.prototype);return c.arrayBuffer=e.arrayBuffer,c.length=e.length,c.capacity=e.arrayBuffer.byteLength/c.bytesPerElement,c._refreshViews(),c}_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 c=this.uint8;this._refreshViews(),c&&this.uint8.set(c)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Ac(e,c=1){let u=0,p=0;return{members:e.map((e=>{const f=Cc[e.type].BYTES_PER_ELEMENT,m=u=Dc(u,Math.max(c,f)),g=e.components||1;return p=Math.max(p,f),u+=f*g,{name:e.name,type:e.type,components:g,offset:m}})),size:Dc(u,Math.max(p,c)),alignment:c}}function Dc(e,c){return Math.ceil(e/c)*c}class sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,c)}emplace(e,c,u){const p=2*e;return this.int16[p+0]=c,this.int16[p+1]=u,e}}sa.prototype.bytesPerElement=4,ec("StructArrayLayout2i4",sa);class aa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,c,u)}emplace(e,c,u,p){const f=3*e;return this.int16[f+0]=c,this.int16[f+1]=u,this.int16[f+2]=p,e}}aa.prototype.bytesPerElement=6,ec("StructArrayLayout3i6",aa);class oa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,c,u,p)}emplace(e,c,u,p,f){const m=4*e;return this.int16[m+0]=c,this.int16[m+1]=u,this.int16[m+2]=p,this.int16[m+3]=f,e}}oa.prototype.bytesPerElement=8,ec("StructArrayLayout4i8",oa);class la extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,c,u,p,f,m)}emplace(e,c,u,p,f,m,g){const y=6*e;return this.int16[y+0]=c,this.int16[y+1]=u,this.int16[y+2]=p,this.int16[y+3]=f,this.int16[y+4]=m,this.int16[y+5]=g,e}}la.prototype.bytesPerElement=12,ec("StructArrayLayout2i4i12",la);class ua extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,c,u,p,f,m)}emplace(e,c,u,p,f,m,g){const y=4*e,x=8*e;return this.int16[y+0]=c,this.int16[y+1]=u,this.uint8[x+4]=p,this.uint8[x+5]=f,this.uint8[x+6]=m,this.uint8[x+7]=g,e}}ua.prototype.bytesPerElement=8,ec("StructArrayLayout2i4ub8",ua);class ca extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,c)}emplace(e,c,u){const p=2*e;return this.float32[p+0]=c,this.float32[p+1]=u,e}}ca.prototype.bytesPerElement=8,ec("StructArrayLayout2f8",ca);class ha extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m,g,y,x,b){const T=this.length;return this.resize(T+1),this.emplace(T,e,c,u,p,f,m,g,y,x,b)}emplace(e,c,u,p,f,m,g,y,x,b,T){const S=10*e;return this.uint16[S+0]=c,this.uint16[S+1]=u,this.uint16[S+2]=p,this.uint16[S+3]=f,this.uint16[S+4]=m,this.uint16[S+5]=g,this.uint16[S+6]=y,this.uint16[S+7]=x,this.uint16[S+8]=b,this.uint16[S+9]=T,e}}ha.prototype.bytesPerElement=20,ec("StructArrayLayout10ui20",ha);class pa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m,g,y){const x=this.length;return this.resize(x+1),this.emplace(x,e,c,u,p,f,m,g,y)}emplace(e,c,u,p,f,m,g,y,x){const b=8*e;return this.uint16[b+0]=c,this.uint16[b+1]=u,this.uint16[b+2]=p,this.uint16[b+3]=f,this.uint16[b+4]=m,this.uint16[b+5]=g,this.uint16[b+6]=y,this.uint16[b+7]=x,e}}pa.prototype.bytesPerElement=16,ec("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,c,u,p,f,m,g,y,x,b,T,S){const P=this.length;return this.resize(P+1),this.emplace(P,e,c,u,p,f,m,g,y,x,b,T,S)}emplace(e,c,u,p,f,m,g,y,x,b,T,S,P){const I=12*e;return this.int16[I+0]=c,this.int16[I+1]=u,this.int16[I+2]=p,this.int16[I+3]=f,this.uint16[I+4]=m,this.uint16[I+5]=g,this.uint16[I+6]=y,this.uint16[I+7]=x,this.int16[I+8]=b,this.int16[I+9]=T,this.int16[I+10]=S,this.int16[I+11]=P,e}}fa.prototype.bytesPerElement=24,ec("StructArrayLayout4i4ui4i24",fa);class da extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,c,u)}emplace(e,c,u,p){const f=3*e;return this.float32[f+0]=c,this.float32[f+1]=u,this.float32[f+2]=p,e}}da.prototype.bytesPerElement=12,ec("StructArrayLayout3f12",da);class ya extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const c=this.length;return this.resize(c+1),this.emplace(c,e)}emplace(e,c){return this.uint32[1*e+0]=c,e}}ya.prototype.bytesPerElement=4,ec("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,c,u,p,f,m,g,y,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,c,u,p,f,m,g,y,x)}emplace(e,c,u,p,f,m,g,y,x,b){const T=10*e,S=5*e;return this.int16[T+0]=c,this.int16[T+1]=u,this.int16[T+2]=p,this.int16[T+3]=f,this.int16[T+4]=m,this.int16[T+5]=g,this.uint32[S+3]=y,this.uint16[T+8]=x,this.uint16[T+9]=b,e}}ma.prototype.bytesPerElement=20,ec("StructArrayLayout6i1ul2ui20",ma);class ga extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,c,u,p,f,m)}emplace(e,c,u,p,f,m,g){const y=6*e;return this.int16[y+0]=c,this.int16[y+1]=u,this.int16[y+2]=p,this.int16[y+3]=f,this.int16[y+4]=m,this.int16[y+5]=g,e}}ga.prototype.bytesPerElement=12,ec("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,c,u,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,c,u,p,f)}emplace(e,c,u,p,f,m){const g=4*e,y=8*e;return this.float32[g+0]=c,this.float32[g+1]=u,this.float32[g+2]=p,this.int16[y+6]=f,this.int16[y+7]=m,e}}xa.prototype.bytesPerElement=16,ec("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,c,u,p,f,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,c,u,p,f,m)}emplace(e,c,u,p,f,m,g){const y=16*e,x=4*e,b=8*e;return this.uint8[y+0]=c,this.uint8[y+1]=u,this.float32[x+1]=p,this.float32[x+2]=f,this.int16[b+6]=m,this.int16[b+7]=g,e}}va.prototype.bytesPerElement=16,ec("StructArrayLayout2ub2f2i16",va);class ba extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,c,u)}emplace(e,c,u,p){const f=3*e;return this.uint16[f+0]=c,this.uint16[f+1]=u,this.uint16[f+2]=p,e}}ba.prototype.bytesPerElement=6,ec("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,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,L){const F=this.length;return this.resize(F+1),this.emplace(F,e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,L)}emplace(e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,L,F){const B=24*e,O=12*e,V=48*e;return this.int16[B+0]=c,this.int16[B+1]=u,this.uint16[B+2]=p,this.uint16[B+3]=f,this.uint32[O+2]=m,this.uint32[O+3]=g,this.uint32[O+4]=y,this.uint16[B+10]=x,this.uint16[B+11]=b,this.uint16[B+12]=T,this.float32[O+7]=S,this.float32[O+8]=P,this.uint8[V+36]=I,this.uint8[V+37]=C,this.uint8[V+38]=R,this.uint32[O+10]=L,this.int16[B+22]=F,e}}wa.prototype.bytesPerElement=48,ec("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,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,L,F,B,O,V,j,G,U,q,Z,W,Q){const J=this.length;return this.resize(J+1),this.emplace(J,e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,L,F,B,O,V,j,G,U,q,Z,W,Q)}emplace(e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,L,F,B,O,V,j,G,U,q,Z,W,Q,J){const re=32*e,se=16*e;return this.int16[re+0]=c,this.int16[re+1]=u,this.int16[re+2]=p,this.int16[re+3]=f,this.int16[re+4]=m,this.int16[re+5]=g,this.int16[re+6]=y,this.int16[re+7]=x,this.uint16[re+8]=b,this.uint16[re+9]=T,this.uint16[re+10]=S,this.uint16[re+11]=P,this.uint16[re+12]=I,this.uint16[re+13]=C,this.uint16[re+14]=R,this.uint16[re+15]=L,this.uint16[re+16]=F,this.uint16[re+17]=B,this.uint16[re+18]=O,this.uint16[re+19]=V,this.uint16[re+20]=j,this.uint16[re+21]=G,this.uint16[re+22]=U,this.uint32[se+12]=q,this.float32[se+13]=Z,this.float32[se+14]=W,this.uint16[re+30]=Q,this.uint16[re+31]=J,e}}_a.prototype.bytesPerElement=64,ec("StructArrayLayout8i15ui1ul2f2ui64",_a);class Sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const c=this.length;return this.resize(c+1),this.emplace(c,e)}emplace(e,c){return this.float32[1*e+0]=c,e}}Sa.prototype.bytesPerElement=4,ec("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,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,c,u)}emplace(e,c,u,p){const f=3*e;return this.uint16[6*e+0]=c,this.float32[f+1]=u,this.float32[f+2]=p,e}}Aa.prototype.bytesPerElement=12,ec("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,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,c,u)}emplace(e,c,u,p){const f=4*e;return this.uint32[2*e+0]=c,this.uint16[f+2]=u,this.uint16[f+3]=p,e}}ka.prototype.bytesPerElement=8,ec("StructArrayLayout1ul2ui8",ka);class Ma extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,c)}emplace(e,c,u){const p=2*e;return this.uint16[p+0]=c,this.uint16[p+1]=u,e}}Ma.prototype.bytesPerElement=4,ec("StructArrayLayout2ui4",Ma);class Ta extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const c=this.length;return this.resize(c+1),this.emplace(c,e)}emplace(e,c){return this.uint16[1*e+0]=c,e}}Ta.prototype.bytesPerElement=2,ec("StructArrayLayout1ui2",Ta);class Ia extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,c,u,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,c,u,p)}emplace(e,c,u,p,f){const m=4*e;return this.float32[m+0]=c,this.float32[m+1]=u,this.float32[m+2]=p,this.float32[m+3]=f,e}}Ia.prototype.bytesPerElement=16,ec("StructArrayLayout4f16",Ia);class Ea 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 p(this.anchorPointX,this.anchorPointY)}}Ea.prototype.size=20;class Fa extends ma{get(e){return new Ea(this,e)}}ec("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)}}ec("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)}}ec("SymbolInstanceArray",Ba);class Va extends Sa{getoffsetX(e){return this.float32[1*e+0]}}ec("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]}}ec("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)}}ec("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)}}ec("FeatureIndexArray",Na);class $a extends sa{}class Ua extends sa{}class ja extends sa{}class qa 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 Ma{}const zc=Ac([{name:"a_pos",components:2,type:"Int16"}],4),{members:kc}=zc;class io{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,c,u,p){const f=this.segments[this.segments.length-1];return e>io.MAX_VERTEX_ARRAY_LENGTH&&Me(`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||!f||f.vertexLength+e>io.MAX_VERTEX_ARRAY_LENGTH||f.sortKey!==p?this.createNewSegment(c,u,p):f}createNewSegment(e,c,u){const p={vertexOffset:e.length,primitiveOffset:c.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==u&&(p.sortKey=u),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(p),p}getOrCreateLatestSegment(e,c,u){return this.prepareSegment(0,e,c,u)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const c in e.vaos)e.vaos[c].destroy()}static simpleSegment(e,c,u,p){return new io([{vertexOffset:e,primitiveOffset:c,vertexLength:u,primitiveLength:p,vaos:{},sortKey:0}])}}function Rc(e,c){return 256*(e=me(Math.floor(e),0,255))+me(Math.floor(c),0,255)}io.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ec("SegmentVector",io);const Lc=Ac([{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"}]),Fc=Ac([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var Bc,Oc,Vc,Nc={exports:{}},Gc={exports:{}},Uc={exports:{}},Zc=function(){if(Vc)return Nc.exports;Vc=1;var e=(Bc||(Bc=1,Gc.exports=function(e,c){var u,p,f,m,g,y,x,b;for(p=e.length-(u=3&e.length),f=c,g=3432918353,y=461845907,b=0;b>>16)*g&65535)<<16)&4294967295)<<15|x>>>17))*y+(((x>>>16)*y&65535)<<16)&4294967295)<<13|f>>>19))+((5*(f>>>16)&65535)<<16)&4294967295))+((58964+(m>>>16)&65535)<<16);switch(x=0,u){case 3:x^=(255&e.charCodeAt(b+2))<<16;case 2:x^=(255&e.charCodeAt(b+1))<<8;case 1:f^=x=(65535&(x=(x=(65535&(x^=255&e.charCodeAt(b)))*g+(((x>>>16)*g&65535)<<16)&4294967295)<<15|x>>>17))*y+(((x>>>16)*y&65535)<<16)&4294967295}return f^=e.length,f=2246822507*(65535&(f^=f>>>16))+((2246822507*(f>>>16)&65535)<<16)&4294967295,f=3266489909*(65535&(f^=f>>>13))+((3266489909*(f>>>16)&65535)<<16)&4294967295,(f^=f>>>16)>>>0}),Gc.exports),c=(Oc||(Oc=1,Uc.exports=function(e,c){for(var u,p=e.length,f=c^p,m=0;p>=4;)u=1540483477*(65535&(u=255&e.charCodeAt(m)|(255&e.charCodeAt(++m))<<8|(255&e.charCodeAt(++m))<<16|(255&e.charCodeAt(++m))<<24))+((1540483477*(u>>>16)&65535)<<16),f=1540483477*(65535&f)+((1540483477*(f>>>16)&65535)<<16)^(u=1540483477*(65535&(u^=u>>>24))+((1540483477*(u>>>16)&65535)<<16)),p-=4,++m;switch(p){case 3:f^=(255&e.charCodeAt(m+2))<<16;case 2:f^=(255&e.charCodeAt(m+1))<<8;case 1:f=1540483477*(65535&(f^=255&e.charCodeAt(m)))+((1540483477*(f>>>16)&65535)<<16)}return f=1540483477*(65535&(f^=f>>>13))+((1540483477*(f>>>16)&65535)<<16),(f^=f>>>15)>>>0}),Uc.exports);return Nc.exports=e,Nc.exports.murmur3=e,Nc.exports.murmur2=c,Nc.exports}(),$c=f(Zc);class go{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,c,u,p){this.ids.push(Wc(e)),this.positions.push(c,u,p)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const c=Wc(e);let u=0,p=this.ids.length-1;for(;u>1;this.ids[e]>=c?p=e:u=e+1}const f=[];for(;this.ids[u]===c;)f.push({index:this.positions[3*u],start:this.positions[3*u+1],end:this.positions[3*u+2]}),u++;return f}static serialize(e,c){const u=new Float64Array(e.ids),p=new Uint32Array(e.positions);return Hc(u,p,0,u.length-1),c&&c.push(u.buffer,p.buffer),{ids:u,positions:p}}static deserialize(e){const c=new go;return c.ids=e.ids,c.positions=e.positions,c.indexed=!0,c}}function Wc(e){const c=+e;return!isNaN(c)&&c<=Number.MAX_SAFE_INTEGER?c:$c(String(e))}function Hc(e,c,u,p){for(;u>1];let m=u-1,g=p+1;for(;;){do{m++}while(e[m]f);if(m>=g)break;Xc(e,m,g),Xc(c,3*m,3*g),Xc(c,3*m+1,3*g+1),Xc(c,3*m+2,3*g+2)}g-u`u_${e}`)),this.type=u}setUniform(e,c,u){e.set(u.constantOr(this.value))}getBinding(e,c,u){return"color"===this.type?new Ao(e,c):new _o(e,c)}}class Io{constructor(e,c){this.uniformNames=c.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,c){this.pixelRatioFrom=c.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=c.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,c){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,c.y,c.height,c.width]}setUniform(e,c,u,p){let f=null;"u_pattern_to"===p?f=this.patternTo:"u_pattern_from"===p?f=this.patternFrom:"u_dasharray_to"===p?f=this.dashTo:"u_dasharray_from"===p?f=this.dashFrom:"u_pixel_ratio_to"===p?f=this.pixelRatioTo:"u_pixel_ratio_from"===p&&(f=this.pixelRatioFrom),null!==f&&e.set(f)}getBinding(e,c,u){return"u_pattern"===u.substr(0,9)||"u_dasharray_"===u.substr(0,12)?new So(e,c):new _o(e,c)}}class Eo{constructor(e,c,u,p){this.expression=e,this.type=u,this.maxValue=0,this.paintVertexAttributes=c.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===u?2:1,offset:0}))),this.paintVertexArray=new p}populatePaintArray(e,c,u){const p=this.paintVertexArray.length,f=this.expression.evaluate(new Ps(0,u),c,{},u.canonical,[],u.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(p,e,f)}updatePaintArray(e,c,u,p,f){const m=this.expression.evaluate(new Ps(0,f),u,p);this._setPaintValue(e,c,m)}_setPaintValue(e,c,u){if("color"===this.type){const p=Kc(u);for(let u=e;u`u_${e}_t`)),this.type=u,this.useIntegerZoom=p,this.zoom=f,this.maxValue=0,this.paintVertexAttributes=c.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===u?4:2,offset:0}))),this.paintVertexArray=new m}populatePaintArray(e,c,u){const p=this.expression.evaluate(new Ps(this.zoom,u),c,{},u.canonical,[],u.formattedSection),f=this.expression.evaluate(new Ps(this.zoom+1,u),c,{},u.canonical,[],u.formattedSection),m=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(m,e,p,f)}updatePaintArray(e,c,u,p,f){const m=this.expression.evaluate(new Ps(this.zoom,f),u,p),g=this.expression.evaluate(new Ps(this.zoom+1,f),u,p);this._setPaintValue(e,c,m,g)}_setPaintValue(e,c,u,p){if("color"===this.type){const f=Kc(u),m=Kc(p);for(let u=e;u`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const c in this.binders){const u=this.binders[c];if(u instanceof Eo||u instanceof Fo)for(let c=0;c!0){this.programConfigurations={};for(const p of e)this.programConfigurations[p.id]=new Bo(p,c,u);this.needsUpload=!1,this._featureMap=new go,this._bufferOffset=0}populatePaintArrays(e,c,u,p){for(const u in this.programConfigurations)this.programConfigurations[u].populatePaintArrays(e,c,p);void 0!==c.id&&this._featureMap.add(c.id,u,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,c,u,p){for(const f of u)this.needsUpload=this.programConfigurations[f.id].updatePaintArrays(e,this._featureMap,c,f,p)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const c in this.programConfigurations)this.programConfigurations[c].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Qc(e,c){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(`${c}-`,"").replace(/-/g,"_")]}function Jc(e,c,u){const p={color:{source:ca,composite:Ia},number:{source:Sa,composite:ca}},f=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 f&&f[u]||p[c][u]}ec("ConstantBinder",To),ec("CrossFadedConstantBinder",Io),ec("SourceExpressionBinder",Eo),ec("CrossFadedPatternBinder",zo),ec("CrossFadedDasharrayBinder",Po),ec("CompositeExpressionBinder",Fo),ec("ProgramConfiguration",Bo,{omit:["_buffers"]}),ec("ProgramConfigurationSet",Vo);const eh=Math.pow(2,14)-1,th=-eh-1;function ih(e){const c=se/e.extent,u=e.loadGeometry();for(let e=0;eu.x+1||mu.y+1)&&Me("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return u}function rh(e,c){return{type:e.type,id:e.id,properties:e.properties,geometry:c?ih(e):[]}}const nh=-32768;function sh(e,c,u,p,f){e.emplaceBack(nh+8*c+p,nh+8*u+f)}class qo{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,c,u){const p=this.layers[0],f=[];let m=null,g=!1,y="heatmap"===p.type;if("circle"===p.type){const e=p;m=e.layout.get("circle-sort-key"),g=!m.isConstant(),y=y||"map"===e.paint.get("circle-pitch-alignment")}const x=y?c.subdivisionGranularity.circle:1;for(const{feature:c,id:p,index:y,sourceLayerIndex:x}of e){const e=this.layers[0]._featureFilter.needGeometry,b=rh(c,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),b,u))continue;const T=g?m.evaluate(b,{},u):void 0,S={id:p,properties:c.properties,type:c.type,sourceLayerIndex:x,index:y,geometry:e?b.geometry:ih(c),patterns:{},sortKey:T};f.push(S)}g&&f.sort(((e,c)=>e.sortKey-c.sortKey));for(const p of f){const{geometry:f,index:m,sourceLayerIndex:g}=p,y=e[m].feature;this.addFeature(p,f,m,u,x),c.featureIndex.insert(y,f,m,g,this.index)}}update(e,c,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,c,this.stateDependentLayers,{imagePositions:u})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,kc),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,c,u,p,f=1){let m;switch(f){case 1:m=[0,7];break;case 3:m=[0,2,5,7];break;case 5:m=[0,1,3,4,6,7];break;case 7:m=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${f}; valid values are 1, 3, 5, 7.`)}const g=m.length;for(const u of c)for(const c of u){const u=c.x,p=c.y;if(u<0||u>=se||p<0||p>=se)continue;const f=this.segments.prepareSegment(g*g,this.layoutVertexArray,this.indexArray,e.sortKey),y=f.vertexLength;for(let e=0;e1){if(uh(e,c))return!0;for(let p=0;p1?u:u.sub(c)._mult(f)._add(c))}function vh(e,c){let u,p,f,m=!1;for(let g=0;gc.y!=f.y>c.y&&c.x<(f.x-p.x)*(c.y-p.y)/(f.y-p.y)+p.x&&(m=!m)}return m}function bh(e,c){let u=!1;for(let p=0,f=e.length-1;pc.y!=g.y>c.y&&c.x<(g.x-m.x)*(c.y-m.y)/(g.y-m.y)+m.x&&(u=!u)}return u}function Th(e,c,u){const p=u[0],f=u[2];if(e.xf.x&&c.x>f.x||e.yf.y&&c.y>f.y)return!1;const m=Ee(e,c,u[0]);return m!==Ee(e,c,u[1])||m!==Ee(e,c,u[2])||m!==Ee(e,c,u[3])}function Ph(e,c,u){const p=c.paint.get(e).value;return"constant"===p.kind?p.value:u.programConfigurations.get(c.id).getMaxValue(e)}function Ih(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Eh(e,c,u,f,m){if(!c[0]&&!c[1])return e;const g=p.convert(c)._mult(m);"viewport"===u&&g._rotate(-f);const y=[];for(let c=0;cBh(e,c,u,p)))}(x,f,g,y),I=b),Fh({queryGeometry:P,size:I,transform:f,unwrappedTileID:g,getElevation:y,pitchAlignment:S,pitchScale:T},p)}}class ml extends qo{}let $h;ec("HeatmapBucket",ml,{omit:["layers"]});var eu={get paint(){return $h=$h||new Hs({"heatmap-radius":new Gs(Mt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Gs(Mt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new qs(Mt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Zs(Mt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new qs(Mt.paint_heatmap["heatmap-opacity"])})}};function tu(e,{width:c,height:u},p,f){if(f){if(f instanceof Uint8ClampedArray)f=new Uint8Array(f.buffer);else if(f.length!==c*u*p)throw new RangeError(`mismatched image size. expected: ${f.length} but got: ${c*u*p}`)}else f=new Uint8Array(c*u*p);return e.width=c,e.height=u,e.data=f,e}function iu(e,{width:c,height:u},p){if(c===e.width&&u===e.height)return;const f=tu({},{width:c,height:u},p);ru(e,f,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,c),height:Math.min(e.height,u)},p),e.width=c,e.height=u,e.data=f.data}function ru(e,c,u,p,f,m){if(0===f.width||0===f.height)return c;if(f.width>e.width||f.height>e.height||u.x>e.width-f.width||u.y>e.height-f.height)throw new RangeError("out of range source coordinates for image copy");if(f.width>c.width||f.height>c.height||p.x>c.width-f.width||p.y>c.height-f.height)throw new RangeError("out of range destination coordinates for image copy");const g=e.data,y=c.data;if(g===y)throw new Error("srcData equals dstData, so image is already copied");for(let x=0;x{c[e.evaluationKey]=g;const y=e.expression.evaluate(c);f.setPixel(p/4/u,m/4,y)};if(e.clips)for(let c=0,f=0;cthis.max&&(this.max=u),u=this.dim+1||c<-1||c>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${c}, dim: ${this.dim}`);return(c+1)*this.stride+(e+1)}unpack(e,c,u){return e*this.redFactor+c*this.greenFactor+u*this.blueFactor-this.baseShift}pack(e){return uu(e,this.getUnpackVector())}getPixels(){return new Sl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,c,u){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let p=c*this.dim,f=c*this.dim+this.dim,m=u*this.dim,g=u*this.dim+this.dim;switch(c){case-1:p=f-1;break;case 1:f=p+1}switch(u){case-1:m=g-1;break;case 1:g=m+1}const y=-c*this.dim,x=-u*this.dim;for(let c=m;c0)for(let f=c;f=c;f-=p)m=Wu(f/p|0,e[f],e[f+1],m);return m&&ju(m,m.next)&&(Hu(m),m=m.next),m}function xu(e,c){if(!e)return e;c||(c=e);let u,p=e;do{if(u=!1,p.steiner||!ju(p,p.next)&&0!==Ou(p.prev,p,p.next))p=p.next;else{if(Hu(p),p=c=p.prev,p===p.next)break;u=!0}}while(u||p!==c);return c}function vu(e,c,u,p,f,m,g){if(!e)return;!g&&m&&function(e,c,u,p){let f=e;do{0===f.z&&(f.z=Du(f.x,f.y,c,u,p)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next}while(f!==e);f.prevZ.nextZ=null,f.prevZ=null,function(e){let c,u=1;do{let p,f=e;e=null;let m=null;for(c=0;f;){c++;let g=f,y=0;for(let e=0;e0||x>0&&g;)0!==y&&(0===x||!g||f.z<=g.z)?(p=f,f=f.nextZ,y--):(p=g,g=g.nextZ,x--),m?m.nextZ=p:e=p,p.prevZ=m,m=p;f=g}m.nextZ=null,u*=2}while(c>1)}(f)}(e,p,f,m);let y=e;for(;e.prev!==e.next;){const x=e.prev,b=e.next;if(m?Tu(e,p,f,m):bu(e))c.push(x.i,e.i,b.i),Hu(e),e=b.next,y=b.next;else if((e=b)===y){g?1===g?vu(e=Su(xu(e),c),c,u,p,f,m,2):2===g&&Mu(e,c,u,p,f,m):vu(xu(e),c,u,p,f,m,1);break}}}function bu(e){const c=e.prev,u=e,p=e.next;if(Ou(c,u,p)>=0)return!1;const f=c.x,m=u.x,g=p.x,y=c.y,x=u.y,b=p.y,T=Math.min(f,m,g),S=Math.min(y,x,b),P=Math.max(f,m,g),I=Math.max(y,x,b);let C=p.next;for(;C!==c;){if(C.x>=T&&C.x<=P&&C.y>=S&&C.y<=I&&Fu(f,y,m,x,g,b,C.x,C.y)&&Ou(C.prev,C,C.next)>=0)return!1;C=C.next}return!0}function Tu(e,c,u,p){const f=e.prev,m=e,g=e.next;if(Ou(f,m,g)>=0)return!1;const y=f.x,x=m.x,b=g.x,T=f.y,S=m.y,P=g.y,I=Math.min(y,x,b),C=Math.min(T,S,P),R=Math.max(y,x,b),L=Math.max(T,S,P),F=Du(I,C,c,u,p),B=Du(R,L,c,u,p);let O=e.prevZ,V=e.nextZ;for(;O&&O.z>=F&&V&&V.z<=B;){if(O.x>=I&&O.x<=R&&O.y>=C&&O.y<=L&&O!==f&&O!==g&&Fu(y,T,x,S,b,P,O.x,O.y)&&Ou(O.prev,O,O.next)>=0)return!1;if(O=O.prevZ,V.x>=I&&V.x<=R&&V.y>=C&&V.y<=L&&V!==f&&V!==g&&Fu(y,T,x,S,b,P,V.x,V.y)&&Ou(V.prev,V,V.next)>=0)return!1;V=V.nextZ}for(;O&&O.z>=F;){if(O.x>=I&&O.x<=R&&O.y>=C&&O.y<=L&&O!==f&&O!==g&&Fu(y,T,x,S,b,P,O.x,O.y)&&Ou(O.prev,O,O.next)>=0)return!1;O=O.prevZ}for(;V&&V.z<=B;){if(V.x>=I&&V.x<=R&&V.y>=C&&V.y<=L&&V!==f&&V!==g&&Fu(y,T,x,S,b,P,V.x,V.y)&&Ou(V.prev,V,V.next)>=0)return!1;V=V.nextZ}return!0}function Su(e,c){let u=e;do{const p=u.prev,f=u.next.next;!ju(p,f)&&Nu(p,u,u.next,f)&&Zu(p,f)&&Zu(f,p)&&(c.push(p.i,u.i,f.i),Hu(u),Hu(u.next),u=e=f),u=u.next}while(u!==e);return xu(u)}function Mu(e,c,u,p,f,m){let g=e;do{let e=g.next.next;for(;e!==g.prev;){if(g.i!==e.i&&Bu(g,e)){let y=$u(g,e);return g=xu(g,g.next),y=xu(y,y.next),vu(g,c,u,p,f,m,0),void vu(y,c,u,p,f,m,0)}e=e.next}g=g.next}while(g!==e)}function Iu(e,c){let u=e.x-c.x;return 0===u&&(u=e.y-c.y,0===u)&&(u=(e.next.y-e.y)/(e.next.x-e.x)-(c.next.y-c.y)/(c.next.x-c.x)),u}function Cu(e,c){const u=function(e,c){let u=c;const p=e.x,f=e.y;let m,g=-1/0;if(ju(e,u))return u;do{if(ju(e,u.next))return u.next;if(f<=u.y&&f>=u.next.y&&u.next.y!==u.y){const e=u.x+(f-u.y)*(u.next.x-u.x)/(u.next.y-u.y);if(e<=p&&e>g&&(g=e,m=u.x=u.x&&u.x>=x&&p!==u.x&&Lu(fm.x||u.x===m.x&&Au(m,u)))&&(m=u,T=c)}u=u.next}while(u!==y);return m}(e,c);if(!u)return c;const p=$u(u,e);return xu(p,p.next),xu(u,u.next)}function Au(e,c){return Ou(e.prev,e,c.prev)<0&&Ou(c.next,e,e.next)<0}function Du(e,c,u,p,f){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-u)*f|0)|e<<8))|e<<4))|e<<2))|e<<1))|(c=1431655765&((c=858993459&((c=252645135&((c=16711935&((c=(c-p)*f|0)|c<<8))|c<<4))|c<<2))|c<<1))<<1}function zu(e){let c=e,u=e;do{(c.x=(e-g)*(m-y)&&(e-g)*(p-y)>=(u-g)*(c-y)&&(u-g)*(m-y)>=(f-g)*(p-y)}function Fu(e,c,u,p,f,m,g,y){return!(e===g&&c===y)&&Lu(e,c,u,p,f,m,g,y)}function Bu(e,c){return e.next.i!==c.i&&e.prev.i!==c.i&&!function(e,c){let u=e;do{if(u.i!==e.i&&u.next.i!==e.i&&u.i!==c.i&&u.next.i!==c.i&&Nu(u,u.next,e,c))return!0;u=u.next}while(u!==e);return!1}(e,c)&&(Zu(e,c)&&Zu(c,e)&&function(e,c){let u=e,p=!1;const f=(e.x+c.x)/2,m=(e.y+c.y)/2;do{u.y>m!=u.next.y>m&&u.next.y!==u.y&&f<(u.next.x-u.x)*(m-u.y)/(u.next.y-u.y)+u.x&&(p=!p),u=u.next}while(u!==e);return p}(e,c)&&(Ou(e.prev,e,c.prev)||Ou(e,c.prev,c))||ju(e,c)&&Ou(e.prev,e,e.next)>0&&Ou(c.prev,c,c.next)>0)}function Ou(e,c,u){return(c.y-e.y)*(u.x-c.x)-(c.x-e.x)*(u.y-c.y)}function ju(e,c){return e.x===c.x&&e.y===c.y}function Nu(e,c,u,p){const f=qu(Ou(e,c,u)),m=qu(Ou(e,c,p)),g=qu(Ou(u,p,e)),y=qu(Ou(u,p,c));return f!==m&&g!==y||!(0!==f||!Uu(e,u,c))||!(0!==m||!Uu(e,p,c))||!(0!==g||!Uu(u,e,p))||!(0!==y||!Uu(u,c,p))}function Uu(e,c,u){return c.x<=Math.max(e.x,u.x)&&c.x>=Math.min(e.x,u.x)&&c.y<=Math.max(e.y,u.y)&&c.y>=Math.min(e.y,u.y)}function qu(e){return e>0?1:e<0?-1:0}function Zu(e,c){return Ou(e.prev,e,e.next)<0?Ou(e,c,e.next)>=0&&Ou(e,e.prev,c)>=0:Ou(e,c,e.prev)<0||Ou(e,e.next,c)<0}function $u(e,c){const u=Xu(e.i,e.x,e.y),p=Xu(c.i,c.x,c.y),f=e.next,m=c.prev;return e.next=c,c.prev=e,u.next=f,f.prev=u,p.next=u,u.prev=p,m.next=p,p.prev=m,p}function Wu(e,c,u,p){const f=Xu(e,c,u);return p?(f.next=p.next,f.prev=p,p.next.prev=f,p.next=f):(f.prev=f,f.next=f),f}function Hu(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 Xu(e,c,u){return{i:e,x:c,y:u,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class hu{constructor(e,c){if(c>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=c}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||c>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const u=0|Math.round(e),p=0|Math.round(c),f=this._getKey(u,p);if(this._vertexDictionary.has(f))return this._vertexDictionary.get(f);const m=this._vertexBuffer.length/2;return this._vertexDictionary.set(f,m),this._vertexBuffer.push(u,p),m}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,c){const u=[];for(let p=0;p0?(u.push(f),u.push(g),u.push(m)):(u.push(f),u.push(m),u.push(g))}return u}(this._vertexBuffer,e);const c=[],u=e.length;for(let p=0;p=1||O<=0)||R&&(yf)){b>=p&&b<=f&&m.push(u[(e+1)%3]);continue}!R&&B>0&&m.push(this._vertexToIndex(g+P*B,y+I*B));const V=g+P*Math.max(B,0),j=g+P*Math.min(O,1);C||this._generateIntraEdgeVertices(m,g,y,x,b,V,j),!R&&O<1&&m.push(this._vertexToIndex(g+P*O,y+I*O)),(R||b>=p&&b<=f)&&m.push(u[(e+1)%3]),!R&&(b<=p||b>=f)&&this._generateInterEdgeVertices(m,g,y,x,b,T,S,j,p,f)}return m}_generateIntraEdgeVertices(e,c,u,p,f,m,g){const y=p-c,x=f-u,b=0===x,T=b?Math.min(c,p):Math.min(m,g),S=b?Math.max(c,p):Math.max(m,g),P=Math.floor(T/this._granularityCellSize)+1,I=Math.ceil(S/this._granularityCellSize)-1;if(b?c=P;p--){const f=p*this._granularityCellSize;e.push(this._vertexToIndex(f,u+x*(f-c)/y))}}_generateInterEdgeVertices(e,c,u,p,f,m,g,y,x,b){const T=f-u,S=m-p,P=g-f,I=(x-f)/P,C=(b-f)/P,R=Math.min(I,C),L=Math.max(I,C),F=p+S*R;let B=Math.floor(Math.min(F,y)/this._granularityCellSize)+1,O=Math.ceil(Math.max(F,y)/this._granularityCellSize)-1,V=y=1||L<=0){const e=u-g,p=m+(c-m)*Math.min((x-g)/e,(b-g)/e);B=Math.floor(Math.min(p,y)/this._granularityCellSize)+1,O=Math.ceil(Math.max(p,y)/this._granularityCellSize)-1,V=y0?b:x;if(V)for(let c=B;c<=O;c++)e.push(this._vertexToIndex(c*this._granularityCellSize,G));else for(let c=O;c>=B;c--)e.push(this._vertexToIndex(c*this._granularityCellSize,G))}_generateOutline(e){const c=[];for(const u of e){const e=Ju(u,this._granularity,!0),p=this._pointArrayToIndices(e),f=[];for(let e=1;ef!=(m===Yu)?(e.push(c),e.push(u),e.push(this._vertexToIndex(p,m)),e.push(u),e.push(this._vertexToIndex(f,m)),e.push(this._vertexToIndex(p,m))):(e.push(u),e.push(c),e.push(this._vertexToIndex(p,m)),e.push(this._vertexToIndex(f,m)),e.push(u),e.push(this._vertexToIndex(p,m)))}_fillPoles(e,c,u){const p=this._vertexBuffer,f=se,m=e.length;for(let g=2;g80*u){y=e[0],x=e[1];let c=y,p=x;for(let m=u;mc&&(c=u),f>p&&(p=f)}b=Math.max(c-y,p-x),b=0!==b?32767/b:0}return vu(m,g,u,y,x,b,0),g}(u,p),c=this._convertIndices(u,e);f=this._subdivideTrianglesScanline(c)}catch(e){console.error(e)}let m=[];return c&&(m=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(f),{verticesFlattened:this._vertexBuffer,indicesTriangles:f,indicesLineList:m}}_convertIndices(e,c){const u=[];for(let p=0;p0?(Math.floor(B/y)+1)*y:(Math.ceil(B/y)-1)*y,c=R>0?(Math.floor(O/y)+1)*y:(Math.ceil(O/y)-1)*y,u=Math.abs(B-e),f=Math.abs(O-c),m=Math.abs(B-T),g=Math.abs(O-S),b=P?u/L:Number.POSITIVE_INFINITY,V=I?f/F:Number.POSITIVE_INFINITY;if((m<=u||!P)&&(g<=f||!I))break;if(b=0?g-1:m-1,f=(y+1)%m,x=e[2*c[p]],b=e[2*c[f]],T=e[2*c[g]],S=e[2*c[g]+1],P=e[2*c[y]+1];let I=!1;if(xb)I=!1;else{const u=P-S,m=-(e[2*c[y]]-T),g=S((b-T)*u+(e[2*c[f]+1]-S)*m)*g&&(I=!0)}if(I){const e=c[p],f=c[g],x=c[y];e!==f&&e!==x&&f!==x&&u.push(x,f,e),g--,g<0&&(g=m-1)}else{const e=c[f],p=c[g],x=c[y];e!==p&&e!==x&&p!==x&&u.push(x,p,e),y++,y>=m&&(y=0)}if(p===f)break}}function td(e,c,u,p,f,m,g,y,x){const b=f.length/2,T=g&&y&&x;if(bio.MAX_VERTEX_ARRAY_LENGTH&&(b=e.createNewSegment(c,u),x=y.count,R=!0,L=!0,F=!0,T=0);const B=id(g,p,m,y,P,R,b),O=id(g,p,m,y,I,L,b),V=id(g,p,m,y,C,F,b);u.emplaceBack(T+B-x,T+O-x,T+V-x),b.primitiveLength++}}(c,u,p,f,m,e),T&&function(e,c,u,p,f,m){const g=[];for(let e=0;eio.MAX_VERTEX_ARRAY_LENGTH&&(b=e.createNewSegment(c,u),x=y.count,C=!0,R=!0,T=0);const L=id(g,p,m,y,f,C,b),F=id(g,p,m,y,S,R,b);u.emplaceBack(T+L-x,T+F-x),b.primitiveLength++}}}(g,u,y,f,x,e),c.forceNewSegmentOnNextPrepare(),null==g||g.forceNewSegmentOnNextPrepare()}function id(e,c,u,p,f,m,g){if(m){const m=p.count;return u(c[2*f],c[2*f+1]),e[f]=p.count,p.count++,g.vertexLength++,m}return e[f]}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 ja,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,c,u){this.hasDependencies=mu("fill",this.layers,c);const p=this.layers[0].layout.get("fill-sort-key"),f=!p.isConstant(),m=[];for(const{feature:g,id:y,index:x,sourceLayerIndex:b}of e){const e=this.layers[0]._featureFilter.needGeometry,T=rh(g,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),T,u))continue;const S=f?p.evaluate(T,{},u,c.availableImages):void 0,P={id:y,properties:g.properties,type:g.type,sourceLayerIndex:b,index:x,geometry:e?T.geometry:ih(g),patterns:{},sortKey:S};m.push(P)}f&&m.sort(((e,c)=>e.sortKey-c.sortKey));for(const p of m){const{geometry:f,index:m,sourceLayerIndex:g}=p;if(this.hasDependencies){const e=_u("fill",this.layers,p,{zoom:this.zoom},c);this.patternFeatures.push(e)}else this.addFeature(p,f,m,u,{},c.subdivisionGranularity);c.featureIndex.insert(e[m].feature,f,m,g,this.index)}}update(e,c,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,c,this.stateDependentLayers,{imagePositions:u})}addFeatures(e,c,u){for(const p of this.patternFeatures)this.addFeature(p,p.geometry,p.index,c,u,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,fu),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,c,u,p,f,m){for(const e of Mn(c,500)){const c=Qu(e,p,m.fill.getGranularityForZoomLevel(p.z)),u=this.layoutVertexArray;td(((e,c)=>{u.emplaceBack(e,c)}),this.segments,this.layoutVertexArray,this.indexArray,c.verticesFlattened,c.indicesTriangles,this.segments2,this.indexArray2,c.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,{imagePositions:f,canonical:p})}}let rd,nd;ec("FillBucket",wu,{omit:["layers","patternFeatures"]});var sd={get paint(){return nd=nd||new Hs({"fill-antialias":new qs(Mt.paint_fill["fill-antialias"]),"fill-opacity":new Gs(Mt.paint_fill["fill-opacity"]),"fill-color":new Gs(Mt.paint_fill["fill-color"]),"fill-outline-color":new Gs(Mt.paint_fill["fill-outline-color"]),"fill-translate":new qs(Mt.paint_fill["fill-translate"]),"fill-translate-anchor":new qs(Mt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Xs(Mt.paint_fill["fill-pattern"])})},get layout(){return rd=rd||new Hs({"fill-sort-key":new Gs(Mt.layout_fill["fill-sort-key"])})}};class ku extends Ks{constructor(e,c){super(e,sd,c)}recalculate(e,c){super.recalculate(e,c);const u=this.paint._values["fill-outline-color"];"constant"===u.value.kind&&void 0===u.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new wu(e)}queryRadius(){return Ih(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:c,transform:u,pixelsToTileUnits:p}){return lh(Eh(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-u.bearingInRadians,p),c)}isTileClipped(){return!0}}const od=Ac([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),ad=Ac([{name:"a_centroid",components:2,type:"Int16"}],4),{members:ld}=od;class Eu{constructor(e,c,u,p,f){this.properties={},this.extent=u,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=p,this._values=f,e.readFields(hd,this,c)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const c=e.readVarint()+e.pos,u=[];let f,m=1,g=0,y=0,x=0;for(;e.pos>3}if(g--,1===m||2===m)y+=e.readSVarint(),x+=e.readSVarint(),1===m&&(f&&u.push(f),f=[]),f&&f.push(new p(y,x));else{if(7!==m)throw new Error(`unknown command ${m}`);f&&f.push(f[0].clone())}}return f&&u.push(f),u}bbox(){const e=this._pbf;e.pos=this._geometry;const c=e.readVarint()+e.pos;let u=1,p=0,f=0,m=0,g=1/0,y=-1/0,x=1/0,b=-1/0;for(;e.pos>3}if(p--,1===u||2===u)f+=e.readSVarint(),m+=e.readSVarint(),fy&&(y=f),mb&&(b=m);else if(7!==u)throw new Error(`unknown command ${u}`)}return[g,x,y,b]}toGeoJSON(e,c,u){const p=this.extent*Math.pow(2,u),f=this.extent*e,m=this.extent*c,g=this.loadGeometry();function y(e){return[360*(e.x+f)/p-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+m)/p)*Math.PI))-90]}function x(e){return e.map(y)}let b;if(1===this.type){const e=[];for(const c of g)e.push(c[0]);const c=x(e);b=1===e.length?{type:"Point",coordinates:c[0]}:{type:"MultiPoint",coordinates:c}}else if(2===this.type){const e=g.map(x);b=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=dd(g),c=[];for(const u of e)c.push(u.map(x));b=1===c.length?{type:"Polygon",coordinates:c[0]}:{type:"MultiPolygon",coordinates:c}}}const T={type:"Feature",geometry:b,properties:this.properties};return null!=this.id&&(T.id=this.id),T}}function hd(e,c,u){1===e?c.id=u.readVarint():2===e?function(e,c){const u=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 c=this._pbf.readVarint()+this._pbf.pos;return new Eu(this._pbf,c,this.extent,this._keys,this._values)}}function fd(e,c,u){15===e?c.version=u.readVarint():1===e?c.name=u.readString():5===e?c.extent=u.readVarint():2===e?c._features.push(u.pos):3===e?c._keys.push(u.readString()):4===e&&c._values.push(function(e){let c=null;const u=e.readVarint()+e.pos;for(;e.pos>3;c=1===u?e.readString():2===u?e.readFloat():3===u?e.readDouble():4===u?e.readVarint64():5===u?e.readVarint():6===u?e.readSVarint():7===u?e.readBoolean():null}if(null==c)throw new Error("unknown feature value");return c}(u))}class Vu{constructor(e,c){this.layers=e.readFields(md,{},c)}}function md(e,c,u){if(3===e){const e=new Pu(u,u.readVarint()+u.pos);e.length&&(c[e.name]=e)}}const _d=Math.pow(2,13);function gd(e,c,u,p,f,m,g,y){e.emplaceBack(c,u,2*Math.floor(p*_d)+g,f*_d*2,m*_d*2,Math.round(y))}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 qa,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,c,u){this.features=[],this.hasDependencies=mu("fill-extrusion",this.layers,c);for(const{feature:p,id:f,index:m,sourceLayerIndex:g}of e){const e=this.layers[0]._featureFilter.needGeometry,y=rh(p,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),y,u))continue;const x={id:f,sourceLayerIndex:g,index:m,geometry:e?y.geometry:ih(p),properties:p.properties,type:p.type,patterns:{}};this.hasDependencies?this.features.push(_u("fill-extrusion",this.layers,x,{zoom:this.zoom},c)):this.addFeature(x,x.geometry,m,u,{},c.subdivisionGranularity),c.featureIndex.insert(p,x.geometry,m,g,this.index,!0)}}addFeatures(e,c,u){for(const p of this.features){const{geometry:f}=p;this.addFeature(p,f,p.index,c,u,e.subdivisionGranularity)}}update(e,c,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,c,this.stateDependentLayers,{imagePositions:u})}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,ld),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,ad.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,c,u,p,f,m){for(const u of Mn(c,500)){const c={x:0,y:0,sampleCount:0},f=this.layoutVertexArray.length;this.processPolygon(c,p,e,u,m);const g=this.layoutVertexArray.length-f,y=Math.floor(c.x/c.sampleCount),x=Math.floor(c.y/c.sampleCount);for(let e=0;e{gd(b,e,c,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,x.verticesFlattened,x.indicesTriangles)}_generateSideFaces(e,c){let u=0;for(let p=1;pio.MAX_VERTEX_ARRAY_LENGTH&&(c.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const g=f.sub(m)._perp()._unit(),y=m.dist(f);u+y>32768&&(u=0),gd(this.layoutVertexArray,f.x,f.y,g.x,g.y,0,0,u),gd(this.layoutVertexArray,f.x,f.y,g.x,g.y,0,1,u),u+=y,gd(this.layoutVertexArray,m.x,m.y,g.x,g.y,0,0,u),gd(this.layoutVertexArray,m.x,m.y,g.x,g.y,0,1,u);const x=c.segment.vertexLength;this.indexArray.emplaceBack(x,x+2,x+1),this.indexArray.emplaceBack(x+1,x+2,x+3),c.segment.vertexLength+=4,c.segment.primitiveLength+=2}}}function yd(e,c){for(let u=0;use)||e.y===c.y&&(e.y<0||e.y>se)}function vd(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 bd;ec("FillExtrusionBucket",Ru,{omit:["layers","features"]});var wd={get paint(){return bd=bd||new Hs({"fill-extrusion-opacity":new qs(Mt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Gs(Mt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new qs(Mt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new qs(Mt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Xs(Mt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Gs(Mt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Gs(Mt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new qs(Mt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Gu extends Ks{constructor(e,c){super(e,wd,c)}createBucket(e){return new Ru(e)}queryRadius(){return Ih(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:c,featureState:u,geometry:f,transform:m,pixelsToTileUnits:g,pixelPosMatrix:y}){const x=Eh(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-m.bearingInRadians,g),b=this.paint.get("fill-extrusion-height").evaluate(c,u),T=this.paint.get("fill-extrusion-base").evaluate(c,u),S=function(e,c){const u=[];for(const f of e){const e=[f.x,f.y,0,1];Z(e,e,c),u.push(new p(e[0]/e[3],e[1]/e[3]))}return u}(x,y),P=function(e,c,u,f){const m=[],g=[],y=f[8]*c,x=f[9]*c,b=f[10]*c,T=f[11]*c,S=f[8]*u,P=f[9]*u,I=f[10]*u,C=f[11]*u;for(const c of e){const e=[],u=[];for(const m of c){const c=m.x,g=m.y,R=f[0]*c+f[4]*g+f[12],L=f[1]*c+f[5]*g+f[13],F=f[2]*c+f[6]*g+f[14],B=f[3]*c+f[7]*g+f[15],O=F+b,V=B+T,j=R+S,G=L+P,U=F+I,q=B+C,Z=new p((R+y)/V,(L+x)/V);Z.z=O/V,e.push(Z);const W=new p(j/q,G/q);W.z=U/q,u.push(W)}m.push(e),g.push(u)}return[m,g]}(f,T,b,y);return function(e,c,u){let p=1/0;lh(u,c)&&(p=Sd(u,c[0]));for(let f=0;fe.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,c,u){this.hasDependencies=mu("line",this.layers,c)||this.hasLineDasharray(this.layers);const p=this.layers[0].layout.get("line-sort-key"),f=!p.isConstant(),m=[];for(const{feature:c,id:g,index:y,sourceLayerIndex:x}of e){const e=this.layers[0]._featureFilter.needGeometry,b=rh(c,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),b,u))continue;const T=f?p.evaluate(b,{},u):void 0,S={id:g,properties:c.properties,type:c.type,sourceLayerIndex:x,index:y,geometry:e?b.geometry:ih(c),patterns:{},dashes:{},sortKey:T};m.push(S)}f&&m.sort(((e,c)=>e.sortKey-c.sortKey));for(const p of m){const{geometry:f,index:m,sourceLayerIndex:g}=p;this.hasDependencies?(mu("line",this.layers,c)?_u("line",this.layers,p,{zoom:this.zoom},c):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,p,this.zoom,c),this.patternFeatures.push(p)):this.addFeature(p,f,m,u,{},{},c.subdivisionGranularity),c.featureIndex.insert(e[m].feature,f,m,g,this.index)}}update(e,c,u,p){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,c,this.stateDependentLayers,{imagePositions:u,dashPositions:p})}addFeatures(e,c,u,p){for(const f of this.patternFeatures)this.addFeature(f,f.geometry,f.index,c,u,p,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,Ed)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Md),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,c,u,p,f,m,g){const y=this.layers[0].layout,x=y.get("line-join").evaluate(e,{}),b=y.get("line-cap"),T=y.get("line-miter-limit"),S=y.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const u of c)this.addLine(u,e,x,b,T,S,p,g);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,{imagePositions:f,dashPositions:m,canonical:p})}addLine(e,c,u,p,f,m,g,y){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Ju(e,g?y.line.getGranularityForZoomLevel(g.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let c=0;c=2&&e[b-1].equals(e[b-2]);)b--;let T=0;for(;T0;if(j&&c>T){const e=I.dist(C);if(e>2*S){const c=I.sub(I.sub(C)._mult(S/e)._round());this.updateDistance(C,c),this.addCurrentVertex(c,L,0,0,P),C=c}}const U=C&&R;let q=U?u:x?"butt":p;if(U&&"round"===q&&(Of&&(q="bevel"),"bevel"===q&&(O>2&&(q="flipbevel"),O100)g=F.mult(-1);else{const e=O*L.add(F).mag()/L.sub(F).mag();g._perp()._mult(e*(G?-1:1))}this.addCurrentVertex(I,g,0,0,P),this.addCurrentVertex(I,g.mult(-1),0,0,P)}else if("bevel"===q||"fakeround"===q){const e=-Math.sqrt(O*O-1),c=G?e:0,u=G?0:e;if(C&&this.addCurrentVertex(I,L,c,u,P),"fakeround"===q){const e=Math.round(180*V/Math.PI/20);for(let c=1;c2*S){const c=I.add(R.sub(I)._mult(S/e)._round());this.updateDistance(I,c),this.addCurrentVertex(c,F,0,0,P),I=c}}}}addCurrentVertex(e,c,u,p,f,m=!1){const g=c.y*p-c.x,y=-c.y-c.x*p;this.addHalfVertex(e,c.x+c.y*u,c.y-c.x*u,m,!1,u,f),this.addHalfVertex(e,g,y,m,!0,-p,f),this.distance>Dd/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,c,u,p,f,m))}addHalfVertex({x:e,y:c},u,p,f,m,g,y){const x=.5*(this.lineClips?this.scaledDistance*(Dd-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(f?1:0),(c<<1)+(m?1:0),Math.round(63*u)+128,Math.round(63*p)+128,1+(0===g?0:g<0?-1:1)|(63&x)<<2,x>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const b=y.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,b,this.e2),y.primitiveLength++),m?this.e2=b:this.e1=b}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,c){this.distance+=e.dist(c),this.updateScaledDistance()}hasLineDasharray(e){for(const c of e){const e=c.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,c,u,p){for(const f of e){const e=f.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const m="round"===f.layout.get("line-cap"),g={dasharray:e.value.evaluate({zoom:u-1},c,{}),round:m},y={dasharray:e.value.evaluate({zoom:u},c,{}),round:m},x={dasharray:e.value.evaluate({zoom:u+1},c,{}),round:m},b=`${g.dasharray.join(",")},${g.round}`,T=`${y.dasharray.join(",")},${y.round}`,S=`${x.dasharray.join(",")},${x.round}`;p.dashDependencies[b]=g,p.dashDependencies[T]=y,p.dashDependencies[S]=x,c.dashes[f.id]={min:b,mid:T,max:S}}}}let zd,kd;ec("LineBucket",tc,{omit:["layers","patternFeatures"]});var Rd={get paint(){return kd=kd||new Hs({"line-opacity":new Gs(Mt.paint_line["line-opacity"]),"line-color":new Gs(Mt.paint_line["line-color"]),"line-translate":new qs(Mt.paint_line["line-translate"]),"line-translate-anchor":new qs(Mt.paint_line["line-translate-anchor"]),"line-width":new Gs(Mt.paint_line["line-width"]),"line-gap-width":new Gs(Mt.paint_line["line-gap-width"]),"line-offset":new Gs(Mt.paint_line["line-offset"]),"line-blur":new Gs(Mt.paint_line["line-blur"]),"line-dasharray":new Xs(Mt.paint_line["line-dasharray"]),"line-pattern":new Xs(Mt.paint_line["line-pattern"]),"line-gradient":new Zs(Mt.paint_line["line-gradient"])})},get layout(){return zd=zd||new Hs({"line-cap":new qs(Mt.layout_line["line-cap"]),"line-join":new Gs(Mt.layout_line["line-join"]),"line-miter-limit":new qs(Mt.layout_line["line-miter-limit"]),"line-round-limit":new qs(Mt.layout_line["line-round-limit"]),"line-sort-key":new Gs(Mt.layout_line["line-sort-key"])})}};class ic extends Gs{possiblyEvaluate(e,c){return c=new Ps(Math.floor(c.zoom),{now:c.now,fadeDuration:c.fadeDuration,zoomHistory:c.zoomHistory,transition:c.transition}),super.possiblyEvaluate(e,c)}evaluate(e,c,u,p){return c=ye({},c,{zoom:Math.floor(c.zoom)}),super.evaluate(e,c,u,p)}}let Ld;class ac extends Ks{constructor(e,c){super(e,Rd,c),this.gradientVersion=0,Ld||(Ld=new ic(Rd.paint.properties["line-width"].specification),Ld.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,c){super.recalculate(e,c),this.paint._values["line-floorwidth"]=Ld.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new tc(e)}queryRadius(e){const c=e,u=Fd(Ph("line-width",this,c),Ph("line-gap-width",this,c)),p=Ph("line-offset",this,c);return u/2+Math.abs(p)+Ih(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:c,featureState:u,geometry:f,transform:m,pixelsToTileUnits:g}){const y=Eh(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-m.bearingInRadians,g),x=g/2*Fd(this.paint.get("line-width").evaluate(c,u),this.paint.get("line-gap-width").evaluate(c,u)),b=this.paint.get("line-offset").evaluate(c,u);return b&&(f=function(e,c){const u=[];for(let f=0;f=3)for(let c=0;c0?c+2*e:e}const Bd=Ac([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Od=Ac([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ac([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Vd=Ac([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Ac([{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 jd=Ac([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Nd=Ac([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Gd(e,c,u){return e.sections.forEach((e=>{e.text=function(e,c,u){const p=c.layout.get("text-transform").evaluate(u,{});return"uppercase"===p?e=e.toLocaleUpperCase():"lowercase"===p&&(e=e.toLocaleLowerCase()),wc.applyArabicShaping&&(e=wc.applyArabicShaping(e)),e}(e.text,c,u)})),e}Ac([{name:"triangle",components:3,type:"Uint16"}]),Ac([{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"}]),Ac([{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"}]),Ac([{type:"Float32",name:"offsetX"}]),Ac([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Ac([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var Ud=24;const qd={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Zd={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},$d={40:!0};function Wd(e,c,u,p,f,m){if("fontStack"in c){const p=u[c.fontStack],m=p&&p[e];return m?m.metrics.advance*c.scale+f:0}{const e=p[c.imageName];return e?e.displaySize[0]*c.scale*Ud/m+f:0}}function Hd(e,c,u,p){const f=Math.pow(e-c,2);return p?eMath.max(e,this.sections[c].scale)),0)}getMaxImageSize(e){let c=0,u=0;for(let p=0;pu)))}addImageSection(e){const c=e.image?e.image.name:"";if(0===c.length)return void Me("Can't add FormattedSection with an empty image.");const u=this.getNextImageSectionCharCode();u?(this.text+=String.fromCharCode(u),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:c}),this.sectionIndex.push(this.sections.length-1)):Me("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,c,u,p,f){const m=[],g=this.determineAverageLineWidth(e,c,u,p,f),y=this.hasZeroWidthSpaces();let x=0,b=0;const T=this.text[Symbol.iterator]();let S=T.next();const P=this.text[Symbol.iterator]();P.next();let I=P.next();const C=this.text[Symbol.iterator]();C.next(),C.next();let R=C.next();for(;!S.done;){const c=this.getSection(b),L=S.value.codePointAt(0);if(uc(L)||(x+=Wd(L,c,u,p,e,f)),!I.done){const e=cc(L),u=I.value.codePointAt(0);(Zd[L]||e||"imageName"in c||!R.done&&$d[u])&&m.push(Yd(b+1,x,g,m,Xd(L,u,e&&y),!1))}b++,S=T.next(),I=P.next(),R=C.next()}return Kd(Yd(this.length(),x,g,m,0,!0))}determineAverageLineWidth(e,c,u,p,f){let m=0,g=0;for(const c of this.text){const y=this.getSection(g);m+=Wd(c.codePointAt(0),y,u,p,e,f),g++}return m/Math.max(1,Math.ceil(m/c))}}const Qd=4294967296,Jd=1/Qd,ip="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,c,u=this.length){for(;this.pos>3,f=this.pos;this.type=7&u,e(p,c,this),this.pos===f&&this.skip(u)}return c}readMessage(e,c){return this.readFields(e,c,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)*Qd;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Qd;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 c=this.buf;let u,p;return p=c[this.pos++],u=127&p,p<128?u:(p=c[this.pos++],u|=(127&p)<<7,p<128?u:(p=c[this.pos++],u|=(127&p)<<14,p<128?u:(p=c[this.pos++],u|=(127&p)<<21,p<128?u:(p=c[this.pos],u|=(15&p)<<28,function(e,c,u){const p=u.buf;let f,m;if(m=p[u.pos++],f=(112&m)>>4,m<128)return rp(e,f,c);if(m=p[u.pos++],f|=(127&m)<<3,m<128)return rp(e,f,c);if(m=p[u.pos++],f|=(127&m)<<10,m<128)return rp(e,f,c);if(m=p[u.pos++],f|=(127&m)<<17,m<128)return rp(e,f,c);if(m=p[u.pos++],f|=(127&m)<<24,m<128)return rp(e,f,c);if(m=p[u.pos++],f|=(1&m)<<31,m<128)return rp(e,f,c);throw new Error("Expected varint not more than 10 bytes")}(u,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,c=this.pos;return this.pos=e,e-c>=12&&ip?ip.decode(this.buf.subarray(c,e)):function(e,c,u){let p="",f=c;for(;f239?4:c>223?3:c>191?2:1;if(f+b>u)break;1===b?c<128&&(x=c):2===b?(m=e[f+1],128==(192&m)&&(x=(31&c)<<6|63&m,x<=127&&(x=null))):3===b?(m=e[f+1],g=e[f+2],128==(192&m)&&128==(192&g)&&(x=(15&c)<<12|(63&m)<<6|63&g,(x<=2047||x>=55296&&x<=57343)&&(x=null))):4===b&&(m=e[f+1],g=e[f+2],y=e[f+3],128==(192&m)&&128==(192&g)&&128==(192&y)&&(x=(15&c)<<18|(63&m)<<12|(63&g)<<6|63&y,(x<=65535||x>=1114112)&&(x=null))),null===x?(x=65533,b=1):x>65535&&(x-=65536,p+=String.fromCharCode(x>>>10&1023|55296),x=56320|1023&x),p+=String.fromCharCode(x),f+=b}return p}(this.buf,c,e)}readBytes(){const e=this.readVarint()+this.pos,c=this.buf.subarray(this.pos,e);return this.pos=e,c}readPackedVarint(e=[],c){const u=this.readPackedEnd();for(;this.pos127;);else if(2===c)this.pos=this.readVarint()+this.pos;else if(5===c)this.pos+=4;else{if(1!==c)throw new Error(`Unimplemented type: ${c}`);this.pos+=8}}writeTag(e,c){this.writeVarint(e<<3|c)}realloc(e){let c=this.length||16;for(;c268435455||e<0?function(e,c){let u,p;if(e>=0?(u=e%4294967296|0,p=e/4294967296|0):(u=~(-e%4294967296),p=~(-e/4294967296),4294967295^u?u=u+1|0:(u=0,p=p+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");c.realloc(10),function(e,c,u){u.buf[u.pos++]=127&e|128,e>>>=7,u.buf[u.pos++]=127&e|128,e>>>=7,u.buf[u.pos++]=127&e|128,e>>>=7,u.buf[u.pos++]=127&e|128,u.buf[u.pos]=127&(e>>>=7)}(u,0,c),function(e,c){const u=(7&e)<<4;c.buf[c.pos++]|=u|((e>>>=3)?128:0),e&&(c.buf[c.pos++]=127&e|((e>>>=7)?128:0),e&&(c.buf[c.pos++]=127&e|((e>>>=7)?128:0),e&&(c.buf[c.pos++]=127&e|((e>>>=7)?128:0),e&&(c.buf[c.pos++]=127&e|((e>>>=7)?128:0),e&&(c.buf[c.pos++]=127&e)))))}(p,c)}(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 c=this.pos;this.pos=function(e,c,u){for(let p,f,m=0;m55295&&p<57344){if(!f){p>56319||m+1===c.length?(e[u++]=239,e[u++]=191,e[u++]=189):f=p;continue}if(p<56320){e[u++]=239,e[u++]=191,e[u++]=189,f=p;continue}p=f-55296<<10|p-56320|65536,f=null}else f&&(e[u++]=239,e[u++]=191,e[u++]=189,f=null);p<128?e[u++]=p:(p<2048?e[u++]=p>>6|192:(p<65536?e[u++]=p>>12|224:(e[u++]=p>>18|240,e[u++]=p>>12&63|128),e[u++]=p>>6&63|128),e[u++]=63&p|128)}return u}(this.buf,e,this.pos);const u=this.pos-c;u>=128&&np(c,u,this),this.pos=c-1,this.writeVarint(u),this.pos+=u}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 c=e.length;this.writeVarint(c),this.realloc(c);for(let u=0;u=128&&np(u,p,this),this.pos=u-1,this.writeVarint(p),this.pos+=p}writeMessage(e,c,u){this.writeTag(e,2),this.writeRawMessage(c,u)}writePackedVarint(e,c){c.length&&this.writeMessage(e,sp,c)}writePackedSVarint(e,c){c.length&&this.writeMessage(e,op,c)}writePackedBoolean(e,c){c.length&&this.writeMessage(e,cp,c)}writePackedFloat(e,c){c.length&&this.writeMessage(e,ap,c)}writePackedDouble(e,c){c.length&&this.writeMessage(e,lp,c)}writePackedFixed32(e,c){c.length&&this.writeMessage(e,hp,c)}writePackedSFixed32(e,c){c.length&&this.writeMessage(e,up,c)}writePackedFixed64(e,c){c.length&&this.writeMessage(e,dp,c)}writePackedSFixed64(e,c){c.length&&this.writeMessage(e,pp,c)}writeBytesField(e,c){this.writeTag(e,2),this.writeBytes(c)}writeFixed32Field(e,c){this.writeTag(e,5),this.writeFixed32(c)}writeSFixed32Field(e,c){this.writeTag(e,5),this.writeSFixed32(c)}writeFixed64Field(e,c){this.writeTag(e,1),this.writeFixed64(c)}writeSFixed64Field(e,c){this.writeTag(e,1),this.writeSFixed64(c)}writeVarintField(e,c){this.writeTag(e,0),this.writeVarint(c)}writeSVarintField(e,c){this.writeTag(e,0),this.writeSVarint(c)}writeStringField(e,c){this.writeTag(e,2),this.writeString(c)}writeFloatField(e,c){this.writeTag(e,5),this.writeFloat(c)}writeDoubleField(e,c){this.writeTag(e,1),this.writeDouble(c)}writeBooleanField(e,c){this.writeVarintField(e,+c)}}function rp(e,c,u){return u?4294967296*c+(e>>>0):4294967296*(c>>>0)+(e>>>0)}function np(e,c,u){const p=c<=16383?1:c<=2097151?2:c<=268435455?3:Math.floor(Math.log(c)/(7*Math.LN2));u.realloc(p);for(let c=u.pos-1;c>=e;c--)u.buf[c+p]=u.buf[c]}function sp(e,c){for(let u=0;uc.h-e.h));const p=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(c/.95)),u),h:1/0}];let f=0,m=0;for(const c of e)for(let e=p.length-1;e>=0;e--){const u=p[e];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,m=Math.max(m,c.y+c.h),f=Math.max(f,c.x+c.w),c.w===u.w&&c.h===u.h){const c=p.pop();c&&eL.toCodeUnitIndex(e)));const e=O(L.toString(),B);for(const c of e){const e=[...c].map((()=>0));F.push(new Sc(c,L.sections,e))}}else if(V){F=[],B=B.map((e=>L.toCodeUnitIndex(e)));let e=0;const c=[];for(const u of L.text)c.push(...Array(u.length).fill(L.sectionIndex[e])),e++;const u=V(L.text,c,B);for(const e of u){const c=[];let u="";for(const p of e[0])c.push(e[1][u.length]),u+=p;F.push(new Sc(e[0],L.sections,c))}}else F=function(e,c){const u=[];let p=0;for(const f of c)u.push(e.substring(p,f)),p=f;return pb){const e=Math.ceil(m/b);f*=e/g,g=e}return{x1:p,y1:f,x2:p+m,y2:f+g}}function Dp(e,c,u,p,f,m){const g=e.image;let y;if(g.content){const e=g.content,c=g.pixelRatio||1;y=[e[0]/c,e[1]/c,g.displaySize[0]-e[2]/c,g.displaySize[1]-e[3]/c]}const x=c.left*m,b=c.right*m;let T,S,P,I;"width"===u||"both"===u?(I=f[0]+x-p[3],S=f[0]+b+p[1]):(I=f[0]+(x+b-g.displaySize[0])/2,S=I+g.displaySize[0]);const C=c.top*m,R=c.bottom*m;return"height"===u||"both"===u?(T=f[1]+C-p[0],P=f[1]+R+p[2]):(T=f[1]+(C+R-g.displaySize[1])/2,P=T+g.displaySize[1]),{image:g,top:T,right:S,bottom:P,left:I,collisionPadding:y}}ec("ImagePosition",jc),ec("ImageAtlas",qc),c.az=void 0,(yp=c.az||(c.az={}))[yp.none=0]="none",yp[yp.horizontal=1]="horizontal",yp[yp.vertical=2]="vertical",yp[yp.horizontalOnly=3]="horizontalOnly";const zp=128,Rp=32640;function Fp(e,c){const{expression:u}=c;if("constant"===u.kind)return{kind:"constant",layoutSize:u.evaluate(new Ps(e+1))};if("source"===u.kind)return{kind:"source"};{const{zoomStops:c,interpolationType:p}=u;let f=0;for(;fe.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const u=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fp(this.zoom,u["text-size"]),this.iconSizeData=Fp(this.zoom,u["icon-size"]);const p=this.layers[0].layout,f=p.get("symbol-sort-key"),m=p.get("symbol-z-order");this.canOverlap="never"!==Bp(p,"text-overlap","text-allow-overlap")||"never"!==Bp(p,"icon-overlap","icon-allow-overlap")||p.get("text-ignore-placement")||p.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==m&&!f.isConstant(),this.sortFeaturesByY=("viewport-y"===m||"auto"===m&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===p.get("symbol-placement")&&(this.writingModes=p.get("text-writing-mode").map((e=>c.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,c,u,p,f){for(const m of e)if(c[m.codePointAt(0)]=!0,(u||p)&&f){const e=qd[m];e&&(c[e.codePointAt(0)]=!0)}}populate(e,u,p){const f=this.layers[0],m=f.layout,g=m.get("text-font"),y=m.get("text-field"),x=m.get("icon-image"),b=("constant"!==y.value.kind||y.value.value instanceof De&&!y.value.value.isEmpty()||y.value.value.toString().length>0)&&("constant"!==g.value.kind||g.value.value.length>0),T="constant"!==x.value.kind||!!x.value.value||Object.keys(x.parameters).length>0,S=m.get("symbol-sort-key");if(this.features=[],!b&&!T)return;const P=u.iconDependencies,I=u.glyphDependencies,C=u.availableImages,R=new Ps(this.zoom);for(const{feature:u,id:y,index:x,sourceLayerIndex:L}of e){const e=f._featureFilter.needGeometry,F=rh(u,e);if(!f._featureFilter.filter(R,F,p))continue;let B,O;if(e||(F.geometry=ih(u)),b){const e=f.getValueAndResolveTokens("text-field",F,p,C),c=De.factory(e),u=this.hasRTLText=this.hasRTLText||Gp(c);(!u||"unavailable"===wc.getRTLTextPluginStatus()||u&&wc.isParsed())&&(B=Gd(c,f,F))}if(T){const e=f.getValueAndResolveTokens("icon-image",F,p,C);O=e instanceof Oe?e:Oe.fromString(e)}if(!B&&!O)continue;const V=this.sortFeaturesByKey?S.evaluate(F,{},p):void 0;if(this.features.push({id:y,text:B,icon:O,index:x,sourceLayerIndex:L,geometry:F.geometry,properties:u.properties,type:Eu.types[u.type],sortKey:V}),O&&(P[O.name]=!0),B){const e=g.evaluate(F,{},p).join(","),u="viewport"!==m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(c.az.vertical)>=0;for(const c of B.sections)if(c.image)P[c.image.name]=!0;else{const p=dc(B.toString()),f=c.fontStack||e,m=I[f]=I[f]||{};this.calculateGlyphDependencies(c.text,m,u,this.allowVerticalPlacement,p)}}}"line"===m.get("symbol-placement")&&(this.features=function(e){const c={},u={},p=[];let f=0;function m(c){p.push(e[c]),f++}function g(e,c,f){const m=u[e];return delete u[e],u[c]=m,p[m].geometry[0].pop(),p[m].geometry[0]=p[m].geometry[0].concat(f[0]),m}function y(e,u,f){const m=c[u];return delete c[u],c[e]=m,p[m].geometry[0].shift(),p[m].geometry[0]=f[0].concat(p[m].geometry[0]),m}function x(e,c,u){const p=u?c[0][c[0].length-1]:c[0][0];return`${e}:${p.x}:${p.y}`}for(let b=0;be.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,c)=>e.sortKey-c.sortKey))}update(e,c,u){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,c,this.layers,{imagePositions:u}),this.icon.programConfigurations.updatePaintArrays(e,c,this.layers,{imagePositions:u}))}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,c){const u=this.lineVertexArray.length;if(void 0!==e.segment){let u=e.dist(c[e.segment+1]),p=e.dist(c[e.segment]);const f={};for(let p=e.segment+1;p=0;u--)f[u]={x:c[u].x,y:c[u].y,tileUnitDistanceFromAnchor:p},u>0&&(p+=c[u-1].dist(c[u]));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,c){const u=e.placedSymbolArray.get(c),p=u.vertexStartIndex+4*u.numGlyphs;for(let c=u.vertexStartIndex;cp[e]-p[c]||f[c]-f[e])),m}addToSortKeyRanges(e,c){const u=this.sortKeyRanges[this.sortKeyRanges.length-1];u&&u.sortKey===c?u.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:c,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 c=this.symbolInstances.get(e);this.featureSortOrder.push(c.featureIndex),[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex].forEach(((e,c,u)=>{e>=0&&u.indexOf(e)===c&&this.addIndicesForPlacedSymbol(this.text,e)})),c.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,c.verticalPlacedTextSymbolIndex),c.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,c.placedIconSymbolIndex),c.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,c.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Up,qp;ec("SymbolBucket",fh,{omit:["layers","collisionBoxArray","features","compareText"]}),fh.MAX_GLYPHS=65535,fh.addDynamicAttributes=Np;var Zp={get paint(){return qp=qp||new Hs({"icon-opacity":new Gs(Mt.paint_symbol["icon-opacity"]),"icon-color":new Gs(Mt.paint_symbol["icon-color"]),"icon-halo-color":new Gs(Mt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Gs(Mt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Gs(Mt.paint_symbol["icon-halo-blur"]),"icon-translate":new qs(Mt.paint_symbol["icon-translate"]),"icon-translate-anchor":new qs(Mt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Gs(Mt.paint_symbol["text-opacity"]),"text-color":new Gs(Mt.paint_symbol["text-color"],{runtimeType:fi,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Gs(Mt.paint_symbol["text-halo-color"]),"text-halo-width":new Gs(Mt.paint_symbol["text-halo-width"]),"text-halo-blur":new Gs(Mt.paint_symbol["text-halo-blur"]),"text-translate":new qs(Mt.paint_symbol["text-translate"]),"text-translate-anchor":new qs(Mt.paint_symbol["text-translate-anchor"])})},get layout(){return Up=Up||new Hs({"symbol-placement":new qs(Mt.layout_symbol["symbol-placement"]),"symbol-spacing":new qs(Mt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new qs(Mt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Gs(Mt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new qs(Mt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new qs(Mt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new qs(Mt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new qs(Mt.layout_symbol["icon-ignore-placement"]),"icon-optional":new qs(Mt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new qs(Mt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Gs(Mt.layout_symbol["icon-size"]),"icon-text-fit":new qs(Mt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new qs(Mt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Gs(Mt.layout_symbol["icon-image"]),"icon-rotate":new Gs(Mt.layout_symbol["icon-rotate"]),"icon-padding":new Gs(Mt.layout_symbol["icon-padding"]),"icon-keep-upright":new qs(Mt.layout_symbol["icon-keep-upright"]),"icon-offset":new Gs(Mt.layout_symbol["icon-offset"]),"icon-anchor":new Gs(Mt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new qs(Mt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new qs(Mt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new qs(Mt.layout_symbol["text-rotation-alignment"]),"text-field":new Gs(Mt.layout_symbol["text-field"]),"text-font":new Gs(Mt.layout_symbol["text-font"]),"text-size":new Gs(Mt.layout_symbol["text-size"]),"text-max-width":new Gs(Mt.layout_symbol["text-max-width"]),"text-line-height":new qs(Mt.layout_symbol["text-line-height"]),"text-letter-spacing":new Gs(Mt.layout_symbol["text-letter-spacing"]),"text-justify":new Gs(Mt.layout_symbol["text-justify"]),"text-radial-offset":new Gs(Mt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new qs(Mt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Gs(Mt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Gs(Mt.layout_symbol["text-anchor"]),"text-max-angle":new qs(Mt.layout_symbol["text-max-angle"]),"text-writing-mode":new qs(Mt.layout_symbol["text-writing-mode"]),"text-rotate":new Gs(Mt.layout_symbol["text-rotate"]),"text-padding":new qs(Mt.layout_symbol["text-padding"]),"text-keep-upright":new qs(Mt.layout_symbol["text-keep-upright"]),"text-transform":new Gs(Mt.layout_symbol["text-transform"]),"text-offset":new Gs(Mt.layout_symbol["text-offset"]),"text-allow-overlap":new qs(Mt.layout_symbol["text-allow-overlap"]),"text-overlap":new qs(Mt.layout_symbol["text-overlap"]),"text-ignore-placement":new qs(Mt.layout_symbol["text-ignore-placement"]),"text-optional":new qs(Mt.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:li,this.defaultValue=e}evaluate(e){if(e.formattedSection){const c=this.defaultValue.property.overrides;if(c&&c.hasOverride(e.formattedSection))return c.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}}ec("FormatSectionOverride",gh,{omit:["defaultValue"]});class xh extends Ks{constructor(e,c){super(e,Zp,c)}recalculate(e,c){if(super.recalculate(e,c),"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 c=[];for(const u of e)c.indexOf(u)<0&&c.push(u);this.layout._values["text-writing-mode"]=c}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,c,u,p){const f=this.layout.get(e).evaluate(c,{},u,p),m=this._unevaluatedLayout._values[e];return m.isDataDriven()||Vs(m.value)||!f?f:function(e,c){return c.replace(/{([^{}]+)}/g,((c,u)=>e&&u in e?String(e[u]):""))}(c.properties,f)}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 Zp.paint.overridableProperties){if(!xh.hasPaintOverride(this.layout,e))continue;const c=this.paint.get(e),u=new gh(c),p=new ei(u,c.property.specification);let f=null;f="constant"===c.value.kind||"source"===c.value.kind?new ii("source",p):new si("composite",p,c.value.zoomStops),this.paint._values[e]=new Us(c.property,f,c.parameters)}}_handleOverridablePaintPropertyUpdate(e,c,u){return!(!this.layout||c.isDataDriven()||u.isDataDriven())&&xh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,c){const u=e.get("text-field"),p=Zp.paint.properties[c];let f=!1;const m=e=>{for(const c of e)if(p.overrides&&p.overrides.hasOverride(c))return void(f=!0)};if("constant"===u.value.kind&&u.value.value instanceof De)m(u.value.value.sections);else if("source"===u.value.kind||"composite"===u.value.kind){const e=c=>{f||(c instanceof qe&&Ar(c.value)===xi?m(c.value.sections):c instanceof Ir?m(c.sections):c.eachChild(e))},c=u.value;c._styleExpression&&e(c._styleExpression.expression)}return f}}let Xp;var Yp={get paint(){return Xp=Xp||new Hs({"background-color":new qs(Mt.paint_background["background-color"]),"background-pattern":new Ys(Mt.paint_background["background-pattern"]),"background-opacity":new qs(Mt.paint_background["background-opacity"])})}};class wh extends Ks{constructor(e,c){super(e,Yp,c)}}class _h extends Ks{constructor(e,c){super(e,{},c),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 Qp={once:!0},ef=6371008.8;class Mh{constructor(e,c){if(isNaN(e)||isNaN(c))throw new Error(`Invalid LngLat object: (${e}, ${c})`);if(this.lng=+e,this.lat=+c,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Mh(ge(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const c=Math.PI/180,u=this.lat*c,p=e.lat*c,f=Math.sin(u)*Math.sin(p)+Math.cos(u)*Math.cos(p)*Math.cos((e.lng-this.lng)*c);return ef*Math.acos(Math.min(f,1))}static convert(e){if(e instanceof Mh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Mh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Mh(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 nf=2*Math.PI*ef;function sf(e){return nf*Math.cos(e*Math.PI/180)}function af(e){return(180+e)/360}function cf(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function hf(e,c){return e/sf(c)}function pf(e){return 360*e-180}function _f(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function gf(e,c){return e*sf(_f(c))}class Vh{constructor(e,c,u=0){this.x=+e,this.y=+c,this.z=+u}static fromLngLat(e,c=0){const u=Mh.convert(e);return new Vh(af(u.lng),cf(u.lat),hf(c,u.lat))}toLngLat(){return new Mh(pf(this.x),_f(this.y))}toAltitude(){return gf(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/nf*(e=_f(this.y),1/Math.cos(e*Math.PI/180));var e}}function xf(e,c,u){var p=2*Math.PI*6378137/256/Math.pow(2,u);return[e*p-2*Math.PI*6378137/2,c*p-2*Math.PI*6378137/2]}class Lh{constructor(e,c,u){if(!function(e,c,u){return!(e<0||e>25||u<0||u>=Math.pow(2,e)||c<0||c>=Math.pow(2,e))}(e,c,u))throw new Error(`x=${c}, y=${u}, 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=c,this.y=u,this.key=vf(0,e,e,c,u)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,c,u){const p=(m=this.y,g=this.z,y=xf(256*(f=this.x),256*(m=Math.pow(2,g)-m-1),g),x=xf(256*(f+1),256*(m+1),g),y[0]+","+y[1]+","+x[0]+","+x[1]);var f,m,g,y,x;const b=function(e,c,u){let p,f="";for(let m=e;m>0;m--)p=1<1?"@2x":"").replace(/{quadkey}/g,b).replace(/{bbox-epsg-3857}/g,p)}isChildOf(e){const c=this.z-e.z;return c>0&&e.x===this.x>>c&&e.y===this.y>>c}getTilePoint(e){const c=Math.pow(2,this.z);return new p((e.x*c-this.x)*se,(e.y*c-this.y)*se)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Oh{constructor(e,c){this.wrap=e,this.canonical=c,this.key=vf(e,c.z,c.z,c.x,c.y)}}class Rh{constructor(e,c,u,p,f){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${u}`);this.overscaledZ=e,this.wrap=c,this.canonical=new Lh(u,+p,+f),this.key=vf(c,e,u,p,f)}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 c=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>>c,this.canonical.y>>c)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,c){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const u=this.canonical.z-e;return e>this.canonical.z?vf(this.wrap*+c,e,this.canonical.z,this.canonical.x,this.canonical.y):vf(this.wrap*+c,e,e,this.canonical.x>>u,this.canonical.y>>u)}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 c=this.canonical.z-e.canonical.z;return!(c<0)&&e.canonical.x===this.canonical.x>>c&&e.canonical.y===this.canonical.y>>c}children(e){if(this.overscaledZ>=e)return[new Rh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const c=this.canonical.z+1,u=2*this.canonical.x,p=2*this.canonical.y;return[new Rh(c,this.wrap,c,u,p),new Rh(c,this.wrap,c,u+1,p),new Rh(c,this.wrap,c,u,p+1),new Rh(c,this.wrap,c,u+1,p+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y=0&&e=0&&c=x)return null;let T=this.canonical.x+p,S=this.wrap;return T<0?(S-=Math.ceil(-T/x),T=(T%x+x)%x):T>=x&&(S+=Math.floor(T/x),T%=x),{tileID:new Rh(this.overscaledZ,S,y,T,b),x:m,y:g}}}function vf(e,c,u,p,f){(e*=2)<0&&(e=-1*e-1);const m=1<e.key===u));c>-1&&e.addOrUpdateProperties.splice(c,1)}return(e.removeAllProperties||c.removeAllProperties)&&(u.removeAllProperties=!0),(e.removeProperties||c.removeProperties)&&(u.removeProperties=[...e.removeProperties||[],...c.removeProperties||[]]),(e.addOrUpdateProperties||c.addOrUpdateProperties)&&(u.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...c.addOrUpdateProperties||[]]),(e.newGeometry||c.newGeometry)&&(u.newGeometry=c.newGeometry||e.newGeometry),u}function Tf(e){var c,u;if(!e)return{};const p={};return p.removeAll=e.removeAll,p.remove=new Set(e.remove||[]),p.add=new Map(null===(c=e.add)||void 0===c?void 0:c.map((e=>[e.id,e]))),p.update=new Map(null===(u=e.update)||void 0===u?void 0:u.map((e=>[e.id,e]))),p}ec("CanonicalTileID",Lh),ec("OverscaledTileID",Rh,{omit:["terrainRttPosMatrix32f"]});class qh{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 c=new qh;return c.extend(e(new p(this.minX,this.minY))),c.extend(e(new p(this.maxX,this.minY))),c.extend(e(new p(this.minX,this.maxY))),c.extend(e(new p(this.maxX,this.maxY))),c}static fromPoints(e){const c=new qh;for(const u of e)c.extend(u);return c}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 c=0;c=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,c,u,p,f){this.type="Feature",this._vectorTileFeature=e,this._x=u,this._y=p,this._z=c,this.properties=e.properties,this.id=f}projectPoint(e,c,u,p){return[360*(e.x+c)/p-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+u)/p)*Math.PI))-90]}projectLine(e,c,u,p){return e.map((e=>this.projectPoint(e,c,u,p)))}get geometry(){if(this._geometry)return this._geometry;const e=this._vectorTileFeature,c=e.extent*Math.pow(2,this._z),u=e.extent*this._x,p=e.extent*this._y,f=e.loadGeometry();switch(e.type){case 1:{const e=[];for(const c of f)e.push(c[0]);const m=this.projectLine(e,u,p,c);this._geometry=1===e.length?{type:"Point",coordinates:m[0]}:{type:"MultiPoint",coordinates:m};break}case 2:{const e=f.map((e=>this.projectLine(e,u,p,c)));this._geometry=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=dd(f),m=[];for(const f of e)m.push(f.map((e=>this.projectLine(e,u,p,c))));this._geometry=1===m.length?{type:"Polygon",coordinates:m[0]}:{type:"MultiPolygon",coordinates:m};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 c in this)"_geometry"!==c&&"_vectorTileFeature"!==c&&"_x"!==c&&"_y"!==c&&"_z"!==c&&(e[c]=this[c]);return e}}class Yh{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,c,u){this._name=e,this.dataBuffer=c,"number"==typeof u?this._size=u:(this.nullabilityBuffer=u,this._size=u.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,c,u,p){super(e,c,p),this.delta=u}}class Jh extends Wh{constructor(e,c,u,p){super(e,Int32Array.of(c),u,p)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class Qh extends Yh{constructor(e,c,u){super(e,Int32Array.of(c),u)}getValueFromBuffer(e){return this.dataBuffer[0]}}class tp{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,c,u,p,f=4096){this._name=e,this._geometryVector=c,this._idVector=u,this._propertyVectors=p,this._extent=f}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 c=0;for(;c=64)throw new Error("Varint too long")}return c.set(f),u}function Nf(e,c){let u,p;return p=e[c.get()],c.increment(),u=127&p,p<128?u:(p=e[c.get()],c.increment(),u|=(127&p)<<7,p<128?u:(p=e[c.get()],c.increment(),u|=(127&p)<<14,p<128?u:(p=e[c.get()],c.increment(),u|=(127&p)<<21,p<128?u:(p=e[c.get()],u|=(15&p)<<28,function(e,c,u){let p,f;if(f=c[u.get()],u.increment(),p=(112&f)>>4,f<128)return 4294967296*p+(e>>>0);if(f=c[u.get()],u.increment(),p|=(127&f)<<3,f<128)return 4294967296*p+(e>>>0);if(f=c[u.get()],u.increment(),p|=(127&f)<<10,f<128)return 4294967296*p+(e>>>0);if(f=c[u.get()],u.increment(),p|=(127&f)<<17,f<128)return 4294967296*p+(e>>>0);if(f=c[u.get()],u.increment(),p|=(127&f)<<24,f<128)return 4294967296*p+(e>>>0);if(f=c[u.get()],u.increment(),p|=(1&f)<<31,f<128)return 4294967296*p+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(u,e,c)))))}function Gf(e){return e>>>1^-(1&e)}function Uf(e){return e>>1n^-(1n&e)}function qf(e){return e%2==1?(e+1)/-2:e/2}function Zf(e,c,u){if(void 0===u){u=0;for(let p=0;p=4)for(let p=e[0];u>4];let f=null;switch(p){case Mf.DATA:f=new Sp(Object.values(If)[15&u]);break;case Mf.OFFSET:f=new Sp(null,Object.values(Cf)[15&u]);break;case Mf.LENGTH:f=new Sp(null,null,Object.values(Af)[15&u])}c.increment();const m=e[c.get()],g=Object.values(Sf)[m>>5],y=Object.values(Sf)[m>>2&7],x=Object.values(Pf)[3&m];c.increment();const b=Of(e,c,2),T=b[0];return{physicalStreamType:p,logicalStreamType:f,logicalLevelTechnique1:g,logicalLevelTechnique2:y,physicalLevelTechnique:x,numValues:T,byteLength:b[1],decompressedCount:T}}(e,c);return u.logicalLevelTechnique1===Sf.MORTON?function(e,c,u){const p=Of(c,u,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:p[0],coordinateShift:p[1]}}(u,e,c):Sf.RLE!==u.logicalLevelTechnique1&&Sf.RLE!==u.logicalLevelTechnique2||Pf.NONE===u.physicalLevelTechnique?u:function(e,c,u){const p=Of(c,u,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:p[1],runs:p[0],numRleValues:p[1]}}(u,e,c)}!function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(If||(If={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Cf||(Cf={})),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"}(Af||(Af={})),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"}(kf||(kf={}));class kp{values;_size;constructor(e,c){this.values=e,this._size=c}get(e){const c=Math.floor(e/8);return 1==(this.values[c]>>e%8&1)}set(e,c){const u=Math.floor(e/8);this.values[u]=this.values[u]|(c?1:0)<>e%8&1}size(){return this._size}getBuffer(){return this.values}}function Qf(e,c,u){if(!c)return e;const p=c.size(),f=new(0,e.constructor)(p);let m=0;for(let g=0;g=4)for(;u=4)for(;u=4)for(;u>1,c)-u}}function cm(e,c){let u=0;for(let p=0;p>p;return u}!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"}(Rf||(Rf={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(Lf||(Lf={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(Bf||(Bf={}));class $p{createPoint(e){return[[e]]}createMultiPoint(e){return e.map((e=>[e]))}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,c){return[e].concat(c)}createMultiPolygon(e){return e.flat()}}function hm(e){const c=new Array(e.numGeometries);let u=1,f=1,m=1,g=0;const y=new $p;let x=0,b=0;const T=e.mortonSettings,S=e.topologyVector,P=S.geometryOffsets,I=S.partOffsets,C=S.ringOffsets,R=e.vertexOffsets,L=e.containsPolygonGeometry(),F=e.vertexBuffer;for(let S=0;S0&&c.push(c[0]),S.push(c)}e[c]=S,m&&b++}break;case Rf.MULTIPOLYGON:{const T=m[b]-m[b-1];b++;const S=[];for(let e=0;e0&&c.push(c[0]),S.push(c)}}e[c]=S}}return e}[Symbol.iterator](){return null}}function gm(e,c,u,p,f,m){return new tf(e,c,u,p,f,m)}class tf extends Jp{_numGeometries;_geometryType;constructor(e,c,u,p,f,m){super(u,p,f,m),this._numGeometries=e,this._geometryType=c}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function ym(e,c,u,p,f){return new rf(e,c,u,p,f)}class rf extends Jp{_geometryTypes;constructor(e,c,u,p,f){super(c,u,p,f),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function xm(e,c,u,p,f){const m=Yf(e,u);let g=null,y=null,x=null,b=null;if(am(m,p,e,u)===kf.CONST){const f=im(e,u,m,!1);let T=null,S=null,P=null,I=null;for(let p=0;pu?c[m++]:1);return p}function bm(e,c,u,p){const f=new Uint32Array(c[c.length-1]+1);let m=0;f[0]=m;let g=1,y=0;for(let x=0;x=g);){const u=e[p.increment()];if(u<=127){const g=u+3,y=e[p.increment()],x=Math.min(m+g,c);f.fill(y,m,x),m=x}else{const g=256-u;for(let u=0;u=12?Tm.decode(e.subarray(c,u)):function(e,c,u){let p="",f=c;for(;f239?4:c>223?3:c>191?2:1;if(f+b>u)break;1===b?c<128&&(x=c):2===b?(m=e[f+1],128==(192&m)&&(x=(31&c)<<6|63&m,x<=127&&(x=null))):3===b?(m=e[f+1],g=e[f+2],128==(192&m)&&128==(192&g)&&(x=(15&c)<<12|(63&m)<<6|63&g,(x<=2047||x>=55296&&x<=57343)&&(x=null))):4===b&&(m=e[f+1],g=e[f+2],y=e[f+3],128==(192&m)&&128==(192&g)&&128==(192&y)&&(x=(15&c)<<18|(63&m)<<12|(63&g)<<6|63&y,(x<=65535||x>=1114112)&&(x=null))),null===x?(x=65533,b=1):x>65535&&(x-=65536,p+=String.fromCharCode(x>>>10&1023|55296),x=56320|1023&x),p+=String.fromCharCode(x),f+=b}return p}(e,c,u)}class ff extends Yh{offsetBuffer;constructor(e,c,u,p){super(e,u,p),this.offsetBuffer=c}}class df extends ff{textEncoder;constructor(e,c,u,p){super(e,c,u,p??c.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return Sm(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class yf extends ff{indexBuffer;textEncoder;constructor(e,c,u,p,f){super(e,u,p,f??c.length),this.indexBuffer=c,this.indexBuffer=c,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const c=this.indexBuffer[e];return Sm(this.dataBuffer,this.offsetBuffer[c],this.offsetBuffer[c+1])}}class mf extends ff{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,c,u,p,f,m,g){super(e,u,p,g),this.indexBuffer=c,this.symbolOffsetBuffer=f,this.symbolTableBuffer=m,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,c,u){const p=[],f=new Array(c.length).fill(0);for(let e=1;e1?6:4,u.type="physicalType",c.scalarType=u,c.type="scalarType",c}case 4:{const e={nullable:!1,columnScope:0},c={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=c,e}case 30:{const e={nullable:!1,columnScope:0},c={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=c,e}default:return function(e){let c=null;switch(e){case 10:case 11:c=0;break;case 12:case 13:c=1;break;case 14:case 15:c=2;break;case 16:case 17:c=3;break;case 18:case 19:c=4;break;case 20:case 21:c=5;break;case 22:case 23:c=6;break;case 24:case 25:c=7;break;case 26:case 27:c=8;break;case 28:case 29:c=9;break;default:return null}const u={};u.nullable=!!(1&e),u.columnScope=0;const p={type:"physicalType"};return p.physicalType=c,u.type="scalarType",u.scalarType=p,u}(e)}}function Em(e){return e>=10}function Cm(e){return 30===e}function Am(e){if("id"===e.name)return!1;if("scalarType"===e.type){const c=e.scalarType;if("physicalType"===c.type)switch(c.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"===c.type)return!1}else if("complexType"===e.type){const c=e.complexType;if("physicalType"===c.type)switch(c.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}const Dm=new TextDecoder;function zm(e,c){const u=Of(e,c,1)[0];if(0===u)return"";const p=c.get(),f=e.subarray(p,p+u);return c.add(u),Dm.decode(f)}function km(e,c){const u=Of(e,c,1)[0]>>>0;if(u<10||u>30)throw new Error(`Unsupported field type code ${u}. Supported: 10-29(scalars), 30(STRUCT)`);const p=Im(u);if(Em(u)&&(p.name=zm(e,c)),Cm(u)){const u=Of(e,c,1)[0]>>>0;p.complexType.children=new Array(u);for(let f=0;f>>0,p=Im(u);if(!p)throw new Error(`Unsupported column type code ${u}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Em(u)?p.name=zm(e,c):u>=0&&u<=3?p.name="id":4===u&&(p.name="geometry"),Cm(u)){const u=Of(e,c,1)[0]>>>0,f=p.complexType;f.children=new Array(u);for(let p=0;p>>0,m=Of(e,c,1)[0]>>>0;p.columns=new Array(m);for(let u=0;u=4)for(;u>>0,m=p.get()+c;if(m>e.length)throw new Error(`Block overruns tile: ${m} > ${e.length}`);if(1!=Of(e,p,1)[0]>>>0){p.set(m);continue}const g=Lm(e,p),y=g[1],x=g[0].featureTables[0];let b=null,T=null;const S=[];let P=0;for(const c of x.columns){const f=c.name;if("id"===f){let m=null;if(c.nullable){const c=Yf(e,p),u=p.get(),f=wm(e,c.numValues,c.byteLength,p);p.set(u+c.byteLength),m=new kp(f,c.numValues)}const g=Yf(e,p);P=g.decompressedCount,b=Fm(e,c,p,f,g,m??P,u)}else if("geometry"===f){const c=Of(e,p,1)[0];if(0===P){const c=p.get();P=Yf(e,p).decompressedCount,p.set(c)}T=xm(e,c,p,P)}else{const u=Am(c)?Of(e,p,1)[0]:1;if(0===u)continue;const f=Pm(e,p,c,u,P);if(f)if(Array.isArray(f))for(const e of f)S.push(e);else S.push(f)}}const I=new tp(x.name,T,b,S,y);f.push(I),p.set(m)}return f}(new Uint8Array(e));this.layers=c.reduce(((e,c)=>Object.assign(Object.assign({},e),{[c.name]:new Ff(c)})),{})}}class zf{constructor(e,c){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=c,"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=[],c=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const u of c){const c=[];for(const e of u)c.push(new p(e[0],e[1]));e.push(c)}return e}}const Bm="_geojsonTileLayer";function Om(e,c){c.writeVarintField(15,e.version||1),c.writeStringField(1,e.name||""),c.writeVarintField(5,e.extent||4096);const u={keys:[],values:[],keycache:{},valuecache:{}};for(let p=0;p>31}function Um(e,c){const u=e.loadGeometry(),p=e.type;let f=0,m=0;for(const g of u){let u=1;1===p&&(u=g.length),c.writeVarint(Nm(1,u));const y=3===p?g.length-1:g.length;for(let e=0;e=0&&p[3]>=0&&y.insert(g,p[0],p[1],p[2],p[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Vu(new Tc(this.rawTileData)).layers:new Df(this.rawTileData).layers,this.sourceLayerCoder=new Gh(this.vtLayers?Object.keys(this.vtLayers).sort():[Bm])),this.vtLayers}query(e,c,u,f){this.loadVTLayers();const m=e.params,g=se/e.tileSize/e.scale,y=Lo(m.filter,m.globalState),x=e.queryGeometry,b=e.queryPadding*g,T=qh.fromPoints(x),S=this.grid.query(T.minX-b,T.minY-b,T.maxX+b,T.maxY+b),P=qh.fromPoints(e.cameraQueryGeometry).expandBy(b),I=this.grid3D.query(P.minX,P.minY,P.maxX,P.maxY,((c,u,f,m)=>function(e,c,u,f,m){for(const p of e)if(c<=p.x&&u<=p.y&&f>=p.x&&m>=p.y)return!0;const g=[new p(c,u),new p(c,m),new p(f,m),new p(f,u)];if(e.length>2)for(const c of g)if(bh(e,c))return!0;for(let c=0;c(P||(P=ih(c)),u.queryIntersectsFeature({queryGeometry:x,feature:c,featureState:p,geometry:P,zoom:this.z,transform:e.transform,pixelsToTileUnits:g,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return C}loadMatchingFeature(e,c,u,p,f,m,g,y,x,b,T){const S=this.bucketLayerIDs[c];if(m&&!S.some((e=>m.has(e))))return;const P=this.sourceLayerCoder.decode(u),I=this.vtLayers[P].feature(p);if(f.needGeometry){const e=rh(I,!0);if(!f.filter(new Ps(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!f.filter(new Ps(this.tileID.overscaledZ),I))return;const C=this.getId(I,P);for(let c=0;c{const g=c instanceof js?c.get(m):null;return g&&g.evaluate?g.evaluate(u,p,f):g}))}function $m(e,c){return c-e}function Wm(e,c,u,f,m){const g=[];for(let y=0;y=f&&T.x>=f||(y.x>=f?y=new p(f,y.y+(f-y.x)/(T.x-y.x)*(T.y-y.y))._round():T.x>=f&&(T=new p(f,y.y+(f-y.x)/(T.x-y.x)*(T.y-y.y))._round()),y.y>=m&&T.y>=m||(y.y>=m?y=new p(y.x+(m-y.y)/(T.y-y.y)*(T.x-y.x),m)._round():T.y>=m&&(T=new p(y.x+(m-y.y)/(T.y-y.y)*(T.x-y.x),m)._round()),b&&y.equals(b[b.length-1])||(b=[y],g.push(b)),b.push(T)))))}}return g}function Hm(e,c,u,p,f){switch(c){case 1:return function(e,c,u,p){const f=[];for(const m of e)for(const e of m){const m=0===p?e.x:e.y;m>=c&&m<=u&&f.push([e])}return f}(e,u,p,f);case 2:return Ym(e,u,p,f,!1);case 3:return Ym(e,u,p,f,!0)}return[]}function Xm(e,c,u,f,m){const g=0===f?Km:Qm;let y=[];const x=[];for(let p=0;pc&&y.push(g(b,T,c)):S>u?P=c&&(y.push(g(b,T,c)),I=!0),P>u&&S<=u&&(y.push(g(b,T,u)),I=!0),!m&&I&&(x.push(y),y=[])}const b=e.length-1,T=0===f?e[b].x:e[b].y;return T>=c&&T<=u&&y.push(e[b]),m&&y.length>0&&!y[0].equals(y[y.length-1])&&y.push(new p(y[0].x,y[0].y)),y.length>0&&x.push(y),x}function Ym(e,c,u,p,f){const m=[];for(const g of e){const e=Xm(g,c,u,p,f);e.length>0&&m.push(...e)}return m}function Km(e,c,u){return new p(u,e.y+(u-e.x)/(c.x-e.x)*(c.y-e.y))}function Qm(e,c,u){return new p(e.x+(u-e.y)/(c.y-e.y)*(c.x-e.x),u)}ec("FeatureIndex",$f,{omit:["rawTileData","sourceLayerCoder"]});class Kf extends p{constructor(e,c,u,p){super(e,c),this.angle=u,void 0!==p&&(this.segment=p)}clone(){return new Kf(this.x,this.y,this.angle,this.segment)}}function Jm(e,c,u,p,f){if(void 0===c.segment||0===u)return!0;let m=c,g=c.segment+1,y=0;for(;y>-u/2;){if(g--,g<0)return!1;y-=e[g].dist(m),m=e[g]}y+=e[g].dist(e[g+1]),g++;const x=[];let b=0;for(;yp;)b-=x.shift().angleDelta;if(b>f)return!1;g++,y+=c.dist(u)}return!0}function e_(e){let c=0;for(let u=0;ub){const T=(b-x)/m,S=Ur.number(p.x,f.x,T),P=Ur.number(p.y,f.y,T),I=new Kf(S,P,f.angleTo(p),u);return I._round(),!g||Jm(e,I,y,g,c)?I:void 0}x+=m}}function n_(e,c,u,p,f,m,g,y,x){const b=t_(p,m,g),T=i_(p,f),S=T*g,P=0===e[0].x||e[0].x===x||0===e[0].y||e[0].y===x;return c-S=0&&F=0&&B=0&&P+b<=T){const u=new Kf(F,B,R,c);u._round(),p&&!Jm(e,u,m,p,f)||I.push(u)}}S+=C}return y||I.length||g||(I=s_(e,S/2,u,p,f,m,g,!0,x)),I}function o_(e,c,u,f){const m=[],g=e.image,y=g.pixelRatio,x=g.paddedRect.w-2,b=g.paddedRect.h-2;let T={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const S=g.stretchX||[[0,x]],P=g.stretchY||[[0,b]],I=(e,c)=>e+c[1]-c[0],C=S.reduce(I,0),R=P.reduce(I,0),L=x-C,F=b-R;let B=0,O=C,V=0,j=R,G=0,U=L,q=0,Z=F;if(g.content&&f){const c=g.content,u=c[2]-c[0],p=c[3]-c[1];(g.textFitWidth||g.textFitHeight)&&(T=Ap(e)),B=a_(S,0,c[0]),V=a_(P,0,c[1]),O=a_(S,c[0],c[2]),j=a_(P,c[1],c[3]),G=c[0]-B,q=c[1]-V,U=u-O,Z=p-j}const W=T.x1,Q=T.y1,J=T.x2-W,re=T.y2-Q,se=(e,f,m,x)=>{const b=c_(e.stretch-B,O,J,W),T=h_(e.fixed-G,U,e.stretch,C),S=c_(f.stretch-V,j,re,Q),P=h_(f.fixed-q,Z,f.stretch,R),I=c_(m.stretch-B,O,J,W),L=h_(m.fixed-G,U,m.stretch,C),F=c_(x.stretch-V,j,re,Q),se=h_(x.fixed-q,Z,x.stretch,R),le=new p(b,S),ce=new p(I,S),he=new p(I,F),ue=new p(b,F),pe=new p(T/y,P/y),fe=new p(L/y,se/y),me=c*Math.PI/180;if(me){const e=Math.sin(me),c=Math.cos(me),u=[c,-e,e,c];le._matMult(u),ce._matMult(u),ue._matMult(u),he._matMult(u)}const ge=e.stretch+e.fixed,ye=f.stretch+f.fixed;return{tl:le,tr:ce,bl:ue,br:he,tex:{x:g.paddedRect.x+1+ge,y:g.paddedRect.y+1+ye,w:m.stretch+m.fixed-ge,h:x.stretch+x.fixed-ye},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:pe,pixelOffsetBR:fe,minFontScaleX:U/y/J,minFontScaleY:Z/y/re,isSDF:u}};if(f&&(g.stretchX||g.stretchY)){const e=l_(S,L,C),c=l_(P,F,R);for(let u=0;u0&&(p=Math.max(10,p),this.circleDiameter=p)}else{const b=(null===(S=g.image)||void 0===S?void 0:S.content)&&(g.image.textFitWidth||g.image.textFitHeight)?Ap(g):{x1:g.left,y1:g.top,x2:g.right,y2:g.bottom};b.y1=b.y1*y-x[0],b.y2=b.y2*y+x[2],b.x1=b.x1*y-x[3],b.x2=b.x2*y+x[1];const P=g.collisionPadding;if(P&&(b.x1-=P[0]*y,b.y1-=P[1]*y,b.x2+=P[2]*y,b.y2+=P[3]*y),T){const e=new p(b.x1,b.y1),c=new p(b.x2,b.y1),u=new p(b.x1,b.y2),f=new p(b.x2,b.y2),m=T*Math.PI/180;e._rotate(m),c._rotate(m),u._rotate(m),f._rotate(m),b.x1=Math.min(e.x,c.x,u.x,f.x),b.x2=Math.max(e.x,c.x,u.x,f.x),b.y1=Math.min(e.y,c.y,u.y,f.y),b.y2=Math.max(e.y,c.y,u.y,f.y)}e.emplaceBack(c.x,c.y,b.x1,b.y1,b.x2,b.y2,u,f,m)}this.boxEndIndex=e.length}}class cd{constructor(e=[],c=(e,c)=>ec?1:0){if(this.data=e,this.length=this.data.length,this.compare=c,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],c=this.data.pop();return--this.length>0&&(this.data[0]=c,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:c,compare:u}=this,p=c[e];for(;e>0;){const f=e-1>>1,m=c[f];if(u(p,m)>=0)break;c[e]=m,e=f}c[e]=p}_down(e){const{data:c,compare:u}=this,p=this.length>>1,f=c[e];for(;e=0)break;c[e]=c[p],e=p}c[e]=f}}function u_(e,c=1,u=!1){const f=qh.fromPoints(e[0]),m=Math.min(f.width(),f.height());let g=m/2;const y=new cd([],d_),{minX:x,minY:b,maxX:T,maxY:S}=f;if(0===m)return new p(x,b);for(let c=x;cP.d||!P.d)&&(P=p,u&&console.log("found best %d after %d probes",Math.round(1e4*p.d)/1e4,I)),p.max-P.d<=c||(g=p.h/2,y.push(new p_(p.p.x-g,p.p.y-g,g,e)),y.push(new p_(p.p.x+g,p.p.y-g,g,e)),y.push(new p_(p.p.x-g,p.p.y+g,g,e)),y.push(new p_(p.p.x+g,p.p.y+g,g,e)),I+=4)}return u&&(console.log(`num probes: ${I}`),console.log(`best distance: ${P.d}`)),P.p}function d_(e,c){return c.max-e.max}function p_(c,u,f,m){(this||e).p=new p(c,u),(this||e).h=f,(this||e).d=function(e,c){let u=!1,p=1/0;for(let f=0;fe.y!=y.y>e.y&&e.x<(y.x-f.x)*(e.y-f.y)/(y.y-f.y)+f.x&&(u=!u),p=Math.min(p,yh(e,f,y))}}return(u?1:-1)*Math.sqrt(p)}((this||e).p,m),(this||e).max=(this||e).d+(this||e).h*Math.SQRT2}var f_;c.aP=void 0,(f_=c.aP||(c.aP={}))[f_.center=1]="center",f_[f_.left=2]="left",f_[f_.right=3]="right",f_[f_.top=4]="top",f_[f_.bottom=5]="bottom",f_[f_["top-left"]=6]="top-left",f_[f_["top-right"]=7]="top-right",f_[f_["bottom-left"]=8]="bottom-left",f_[f_["bottom-right"]=9]="bottom-right";const m_=Number.POSITIVE_INFINITY;function __(e,c){return c[1]!==m_?function(e,c,u){let p=0,f=0;switch(c=Math.abs(c),u=Math.abs(u),e){case"top-right":case"top-left":case"top":f=u-7;break;case"bottom-right":case"bottom-left":case"bottom":f=7-u}switch(e){case"top-right":case"bottom-right":case"right":p=-c;break;case"top-left":case"bottom-left":case"left":p=c}return[p,f]}(e,c[0],c[1]):function(e,c){let u=0,p=0;c<0&&(c=0);const f=c/Math.SQRT2;switch(e){case"top-right":case"top-left":p=f-7;break;case"bottom-right":case"bottom-left":p=7-f;break;case"bottom":p=7-c;break;case"top":p=c-7}switch(e){case"top-right":case"bottom-right":u=-f;break;case"top-left":case"bottom-left":u=f;break;case"left":u=c;break;case"right":u=-c}return[u,p]}(e,c[0])}function g_(e,c,u){var p;const f=e.layout,m=null===(p=f.get("text-variable-anchor-offset"))||void 0===p?void 0:p.evaluate(c,{},u);if(m){const e=m.values,c=[];for(let u=0;ue*Ud));p.startsWith("top")?f[1]-=7:p.startsWith("bottom")&&(f[1]+=7),c[u+1]=f}return new Le(c)}const g=f.get("text-variable-anchor");if(g){let p;p=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[f.get("text-radial-offset").evaluate(c,{},u)*Ud,m_]:f.get("text-offset").evaluate(c,{},u).map((e=>e*Ud));const m=[];for(const e of g)m.push(e,__(e,p));return new Le(m)}return null}function y_(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 x_(e,u,p,f,m,g,y,x,b,T,S,P){let I=g.textMaxSize.evaluate(u,{});void 0===I&&(I=y);const C=e.layers[0].layout,R=C.get("icon-offset").evaluate(u,{},S),L=b_(p.horizontal),F=y/24,B=e.tilePixelRatio*F,O=e.tilePixelRatio*I/24,V=e.tilePixelRatio*x,j=e.tilePixelRatio*C.get("symbol-spacing"),G=C.get("text-padding")*e.tilePixelRatio,U=function(e,c,u,p=1){const f=e.get("icon-padding").evaluate(c,{},u),m=f&&f.values;return[m[0]*p,m[1]*p,m[2]*p,m[3]*p]}(C,u,S,e.tilePixelRatio),q=C.get("text-max-angle")/180*Math.PI,Z="viewport"!==C.get("text-rotation-alignment")&&"point"!==C.get("symbol-placement"),W="map"===C.get("icon-rotation-alignment")&&"point"!==C.get("symbol-placement"),Q=C.get("symbol-placement"),J=j/2,re=C.get("icon-text-fit");let le;f&&"none"!==re&&(e.allowVerticalPlacement&&p.vertical&&(le=Dp(f,p.vertical,re,C.get("icon-text-fit-padding"),R,F)),L&&(f=Dp(f,L,re,C.get("icon-text-fit-padding"),R,F)));const ce=S?P.line.getGranularityForZoomLevel(S.z):1,he=(x,P)=>{P.x<0||P.x>=se||P.y<0||P.y>=se||function(e,u,p,f,m,g,y,x,b,T,S,P,I,C,R,L,F,B,O,V,j,G,U,q,Z){const W=e.addToLineVertexArray(u,p);let Q,J,re,se,le=0,ce=0,he=0,ue=0,pe=-1,fe=-1;const me={};let ge=$c("");if(e.allowVerticalPlacement&&f.vertical){const e=x.layout.get("text-rotate").evaluate(j,{},q)+90;re=new ud(b,u,T,S,P,f.vertical,I,C,R,e),y&&(se=new ud(b,u,T,S,P,y,F,B,R,e))}if(m){const p=x.layout.get("icon-rotate").evaluate(j,{}),f="none"!==x.layout.get("icon-text-fit"),g=o_(m,p,U,f),I=y?o_(y,p,U,f):void 0;J=new ud(b,u,T,S,P,m,F,B,!1,p),le=4*g.length;const C=e.iconSizeData;let R=null;"source"===C.kind?(R=[zp*x.layout.get("icon-size").evaluate(j,{})],R[0]>Rp&&Me(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===C.kind&&(R=[zp*G.compositeIconSizes[0].evaluate(j,{},q),zp*G.compositeIconSizes[1].evaluate(j,{},q)],(R[0]>Rp||R[1]>Rp)&&Me(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,g,R,V,O,j,c.az.none,u,W.lineStartIndex,W.lineLength,-1,q),pe=e.icon.placedSymbolArray.length-1,I&&(ce=4*I.length,e.addSymbols(e.icon,I,R,V,O,j,c.az.vertical,u,W.lineStartIndex,W.lineLength,-1,q),fe=e.icon.placedSymbolArray.length-1)}const ye=Object.keys(f.horizontal);for(const p of ye){const m=f.horizontal[p];if(!Q){ge=$c(m.text);const e=x.layout.get("text-rotate").evaluate(j,{},q);Q=new ud(b,u,T,S,P,m,I,C,R,e)}const y=1===m.positionedLines.length;if(he+=v_(e,u,m,g,x,R,j,L,W,f.vertical?c.az.horizontal:c.az.horizontalOnly,y?ye:[p],me,pe,G,q),y)break}f.vertical&&(ue+=v_(e,u,f.vertical,g,x,R,j,L,W,c.az.vertical,["vertical"],me,fe,G,q));const xe=Q?Q.boxStartIndex:e.collisionBoxArray.length,ve=Q?Q.boxEndIndex:e.collisionBoxArray.length,be=re?re.boxStartIndex:e.collisionBoxArray.length,we=re?re.boxEndIndex:e.collisionBoxArray.length,Se=J?J.boxStartIndex:e.collisionBoxArray.length,Ee=J?J.boxEndIndex:e.collisionBoxArray.length,Ce=se?se.boxStartIndex:e.collisionBoxArray.length,Ae=se?se.boxEndIndex:e.collisionBoxArray.length;let je=-1;const Ne=(e,c)=>e&&e.circleDiameter?Math.max(e.circleDiameter,c):c;je=Ne(Q,je),je=Ne(re,je),je=Ne(J,je),je=Ne(se,je);const Ge=je>-1?1:0;Ge&&(je*=Z/Ud),e.glyphOffsetArray.length>=fh.MAX_GLYPHS&&Me("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==j.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,j.sortKey);const Ue=g_(x,j,q),[$e,He]=function(e,u){const p=e.length,f=null==u?void 0:u.values;if((null==f?void 0:f.length)>0)for(let u=0;u=0?me.right:-1,me.center>=0?me.center:-1,me.left>=0?me.left:-1,me.vertical||-1,pe,fe,ge,xe,ve,be,we,Se,Ee,Ce,Ae,T,he,ue,le,ce,Ge,0,I,je,$e,He)}(e,P,x,p,f,m,le,e.layers[0],e.collisionBoxArray,u.index,u.sourceLayerIndex,e.index,B,[G,G,G,G],Z,b,V,U,W,R,u,g,T,S,y)};if("line"===Q)for(const c of Wm(u.geometry,0,0,se,se)){const u=Ju(c,ce),m=n_(u,j,q,p.vertical||L,f,24,O,e.overscaling,se);for(const c of m)L&&w_(e,L.text,J,c)||he(u,c)}else if("line-center"===Q){for(const e of u.geometry)if(e.length>1){const c=Ju(e,ce),u=r_(c,q,p.vertical||L,f,24,O);u&&he(c,u)}}else if("Polygon"===u.type)for(const e of Mn(u.geometry,0)){const c=u_(e,16);he(Ju(e[0],ce,!0),new Kf(c.x,c.y,0))}else if("LineString"===u.type)for(const e of u.geometry){const c=Ju(e,ce);he(c,new Kf(c[0].x,c[0].y,0))}else if("Point"===u.type)for(const e of u.geometry)for(const c of e)he([c],new Kf(c.x,c.y,0))}function v_(e,c,u,f,m,g,y,x,b,T,S,P,I,C,R){const L=function(e,c,u,f,m,g,y,x){const b=f.layout.get("text-rotate").evaluate(g,{})*Math.PI/180,T=[];for(const e of c.positionedLines)for(const f of e.positionedGlyphs){if(!f.rect)continue;const g=f.rect||{};let S=4,P=!0,I=1,C=0;const R=(m||x)&&f.vertical,L=f.metrics.advance*f.scale/2;if(x&&c.verticalizable&&(C=e.lineOffset/2-(f.imageName?-(Ud-f.metrics.width*f.scale)/2:(f.scale-1)*Ud)),f.imageName){const e=y[f.imageName];P=e.sdf,I=e.pixelRatio,S=1/I}const F=m?[f.x+L,f.y]:[0,0];let B=m?[0,0]:[f.x+L+u[0],f.y+u[1]-C],O=[0,0];R&&(O=B,B=[0,0]);const V=f.metrics.isDoubleResolution?2:1,j=(f.metrics.left-S)*f.scale-L+B[0],G=(-f.metrics.top-S)*f.scale+B[1],U=j+g.w/V*f.scale/I,q=G+g.h/V*f.scale/I,Z=new p(j,G),W=new p(U,G),Q=new p(j,q),J=new p(U,q);if(R){const e=new p(-L,L- -17),c=-Math.PI/2,u=12-L,m=new p(22-u,-(f.imageName?u:0)),g=new p(...O);Z._rotateAround(c,e)._add(m)._add(g),W._rotateAround(c,e)._add(m)._add(g),Q._rotateAround(c,e)._add(m)._add(g),J._rotateAround(c,e)._add(m)._add(g)}if(b){const e=Math.sin(b),c=Math.cos(b),u=[c,-e,e,c];Z._matMult(u),W._matMult(u),Q._matMult(u),J._matMult(u)}const re=new p(0,0),se=new p(0,0);T.push({tl:Z,tr:W,bl:Q,br:J,tex:g,writingMode:c.writingMode,glyphOffset:F,sectionIndex:f.sectionIndex,isSDF:P,pixelOffsetTL:re,pixelOffsetBR:se,minFontScaleX:0,minFontScaleY:0})}return T}(0,u,x,m,g,y,f,e.allowVerticalPlacement),F=e.textSizeData;let B=null;"source"===F.kind?(B=[zp*m.layout.get("text-size").evaluate(y,{})],B[0]>Rp&&Me(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===F.kind&&(B=[zp*C.compositeTextSizes[0].evaluate(y,{},R),zp*C.compositeTextSizes[1].evaluate(y,{},R)],(B[0]>Rp||B[1]>Rp)&&Me(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,L,B,x,g,y,T,c,b.lineStartIndex,b.lineLength,I,R);for(const c of S)P[c]=e.text.placedSymbolArray.length-1;return 4*L.length}function b_(e){for(const c in e)return e[c];return null}function w_(e,c,u,p){const f=e.compareText;if(c in f){const e=f[c];for(let c=e.length-1;c>=0;c--)if(p.dist(e[c])>4;if(1!==p)throw new Error(`Got v${p} data when expected v1.`);const f=T_[15&u];if(!f)throw new Error("Unrecognized array type.");const[m]=new Uint16Array(e,2,1),[g]=new Uint32Array(e,4,1);return new Ad(g,m,f,e)}constructor(e,c=64,u=Float64Array,p){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+c,2),65535),this.ArrayType=u,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const f=T_.indexOf(this.ArrayType),m=2*e*this.ArrayType.BYTES_PER_ELEMENT,g=e*this.IndexArrayType.BYTES_PER_ELEMENT,y=(8-g%8)%8;if(f<0)throw new Error(`Unexpected typed array class: ${u}.`);p&&p instanceof ArrayBuffer?(this.data=p,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+g+y,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+m+g+y),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+g+y,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+f]),new Uint16Array(this.data,2,1)[0]=c,new Uint32Array(this.data,4,1)[0]=e)}add(e,c){const u=this._pos>>1;return this.ids[u]=u,this.coords[this._pos++]=e,this.coords[this._pos++]=c,u}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return S_(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,c,u,p){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:f,coords:m,nodeSize:g}=this,y=[0,f.length-1,0],x=[];for(;y.length;){const b=y.pop()||0,T=y.pop()||0,S=y.pop()||0;if(T-S<=g){for(let g=S;g<=T;g++){const y=m[2*g],b=m[2*g+1];y>=e&&y<=u&&b>=c&&b<=p&&x.push(f[g])}continue}const P=S+T>>1,I=m[2*P],C=m[2*P+1];I>=e&&I<=u&&C>=c&&C<=p&&x.push(f[P]),(0===b?e<=I:c<=C)&&(y.push(S),y.push(P-1),y.push(1-b)),(0===b?u>=I:p>=C)&&(y.push(P+1),y.push(T),y.push(1-b))}return x}within(e,c,u){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:p,coords:f,nodeSize:m}=this,g=[0,p.length-1,0],y=[],x=u*u;for(;g.length;){const b=g.pop()||0,T=g.pop()||0,S=g.pop()||0;if(T-S<=m){for(let u=S;u<=T;u++)E_(f[2*u],f[2*u+1],e,c)<=x&&y.push(p[u]);continue}const P=S+T>>1,I=f[2*P],C=f[2*P+1];E_(I,C,e,c)<=x&&y.push(p[P]),(0===b?e-u<=I:c-u<=C)&&(g.push(S),g.push(P-1),g.push(1-b)),(0===b?e+u>=I:c+u>=C)&&(g.push(P+1),g.push(T),g.push(1-b))}return y}}function S_(e,c,u,p,f,m){if(f-p<=u)return;const g=p+f>>1;P_(e,c,g,p,f,m),S_(e,c,u,p,g-1,1-m),S_(e,c,u,g+1,f,1-m)}function P_(e,c,u,p,f,m){for(;f>p;){if(f-p>600){const g=f-p+1,y=u-p+1,x=Math.log(g),b=.5*Math.exp(2*x/3),T=.5*Math.sqrt(x*b*(g-b)/g)*(y-g/2<0?-1:1);P_(e,c,u,Math.max(p,Math.floor(u-y*b/g+T)),Math.min(f,Math.floor(u+(g-y)*b/g+T)),m)}const g=c[2*u+m];let y=p,x=f;for(M_(e,c,p,u),c[2*f+m]>g&&M_(e,c,p,f);yg;)x--}c[2*p+m]===g?M_(e,c,p,x):(x++,M_(e,c,x,f)),x<=u&&(p=x+1),u<=x&&(f=x-1)}}function M_(e,c,u,p){I_(e,u,p),I_(c,2*u,2*p),I_(c,2*u+1,2*p+1)}function I_(e,c,u){const p=e[c];e[c]=e[u],e[u]=p}function E_(e,c,u,p){const f=e-u,m=c-p;return f*f+m*m}var C_;c.cI=void 0,(C_=c.cI||(c.cI={})).create="create",C_.load="load",C_.fullLoad="fullLoad";let A_=null,D_=[];const z_=1e3/60,k_="loadTime",R_="fullLoadTime",L_={mark(e){performance.mark(e)},recordStartOfFrameAt(e){null!=A_&&D_.push(e-A_),A_=e},resetRuntimeMetrics(){A_=null,D_=[]},clearInitializationMetrics(){performance.clearMeasures(k_),performance.clearMeasures(R_);for(const e in c.cI)performance.clearMarks(c.cI[e])},remove(){this.resetRuntimeMetrics(),this.clearInitializationMetrics()},getPerformanceMetrics(){performance.measure(k_,c.cI.create,c.cI.load),performance.measure(R_,c.cI.create,c.cI.fullLoad);const e=performance.getEntriesByName(k_)[0].duration,u=performance.getEntriesByName(R_)[0].duration,p=D_.length;return{loadTimeMs:e,fullLoadTimeMs:u,averageFramesPerSecond:1/(D_.reduce(((e,c)=>e+c),0)/p/1e3),virtualDroppedFramesCount:D_.filter((e=>e>z_)).reduce(((e,c)=>e+(c-z_)/z_),0),totalFramesCount:p}}};c.$=S,c.A=C,c.B=Ql,c.C=Wl,c.D=qs,c.E=xt,c.F=function([e,c,u]){return c+=90,c*=Math.PI/180,u*=Math.PI/180,{x:e*Math.cos(c)*Math.sin(u),y:e*Math.sin(c)*Math.sin(u),z:e*Math.cos(u)}},c.G=Ur,c.H=Ps,c.I=jc,c.J=Xl,c.K=function(e){if(null==Ae){const c=e.navigator?e.navigator.userAgent:null;Ae=!!e.safari||!(!c||!(/\b(iPad|iPhone|iPod)\b/.test(c)||c.match("Safari")&&!c.match("Chrome")))}return Ae},c.L=class{constructor(e,c){this.target=e,this.mapId=c,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Sh((()=>this.process())),this.subscription=He(this.target,"message",(e=>this.receive(e)),!1),this.globalScope=Ce(self)?e:window}registerMessageHandler(e,c){this.messageHandlers[e]=c}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,c){return new Promise(((u,p)=>{const f=Math.round(1e18*Math.random()).toString(36).substring(0,10),m=c?He(c.signal,"abort",(()=>{null==m||m.unsubscribe(),delete this.resolveRejects[f];const c={id:f,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(c)}),Qp):null;this.resolveRejects[f]={resolve:e=>{null==m||m.unsubscribe(),u(e)},reject:e=>{null==m||m.unsubscribe(),p(e)}};const g=[],y=Object.assign(Object.assign({},e),{id:f,sourceMapId:this.mapId,origin:location.origin,data:oc(e.data,g)});this.target.postMessage(y,{transfer:g})}))}receive(e){const c=e.data,u=c.id;if(!("file://"!==c.origin&&"file://"!==location.origin&&"resource://android"!==c.origin&&"resource://android"!==location.origin&&c.origin!==location.origin||c.targetMapId&&this.mapId!==c.targetMapId)){if(""===c.type){delete this.tasks[u];const e=this.abortControllers[u];return delete this.abortControllers[u],void(e&&e.abort())}if(Ce(self)||c.mustQueue)return this.tasks[u]=c,this.taskQueue.push(u),void this.invoker.trigger();this.processTask(u,c)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),c=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),c&&this.processTask(e,c)}processTask(e,c){return u(this,void 0,void 0,(function*(){if(""===c.type){const u=this.resolveRejects[e];if(delete this.resolveRejects[e],!u)return;return void(c.error?u.reject(lc(c.error)):u.resolve(lc(c.data)))}if(!this.messageHandlers[c.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${c.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const u=lc(c.data),p=new AbortController;this.abortControllers[e]=p;try{const f=yield this.messageHandlers[c.type](c.sourceMapId,u,p);this.completeTask(e,null,f)}catch(u){this.completeTask(e,u)}}))}completeTask(e,c,u){const p=[];delete this.abortControllers[e];const f={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:c?oc(c):null,data:oc(u,p)};this.target.postMessage(f,{transfer:p})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},c.M=_t,c.N=function(){var e=new C(16);return C!=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},c.O=function(e,c,u){var p,f,m,g,y,x,b,T,S,P,I,C,R=u[0],L=u[1],F=u[2];return c===e?(e[12]=c[0]*R+c[4]*L+c[8]*F+c[12],e[13]=c[1]*R+c[5]*L+c[9]*F+c[13],e[14]=c[2]*R+c[6]*L+c[10]*F+c[14],e[15]=c[3]*R+c[7]*L+c[11]*F+c[15]):(f=c[1],m=c[2],g=c[3],y=c[4],x=c[5],b=c[6],T=c[7],S=c[8],P=c[9],I=c[10],C=c[11],e[0]=p=c[0],e[1]=f,e[2]=m,e[3]=g,e[4]=y,e[5]=x,e[6]=b,e[7]=T,e[8]=S,e[9]=P,e[10]=I,e[11]=C,e[12]=p*R+y*L+S*F+c[12],e[13]=f*R+x*L+P*F+c[13],e[14]=m*R+b*L+I*F+c[14],e[15]=g*R+T*L+C*F+c[15]),e},c.P=p,c.Q=function(e,c,u){var p=u[0],f=u[1],m=u[2];return e[0]=c[0]*p,e[1]=c[1]*p,e[2]=c[2]*p,e[3]=c[3]*p,e[4]=c[4]*f,e[5]=c[5]*f,e[6]=c[6]*f,e[7]=c[7]*f,e[8]=c[8]*m,e[9]=c[9]*m,e[10]=c[10]*m,e[11]=c[11]*m,e[12]=c[12],e[13]=c[13],e[14]=c[14],e[15]=c[15],e},c.R=Sl,c.S=function(e,c,u){var p=c[0],f=c[1],m=c[2],g=c[3],y=c[4],x=c[5],b=c[6],T=c[7],S=c[8],P=c[9],I=c[10],C=c[11],R=c[12],L=c[13],F=c[14],B=c[15],O=u[0],V=u[1],j=u[2],G=u[3];return e[0]=O*p+V*y+j*S+G*R,e[1]=O*f+V*x+j*P+G*L,e[2]=O*m+V*b+j*I+G*F,e[3]=O*g+V*T+j*C+G*B,e[4]=(O=u[4])*p+(V=u[5])*y+(j=u[6])*S+(G=u[7])*R,e[5]=O*f+V*x+j*P+G*L,e[6]=O*m+V*b+j*I+G*F,e[7]=O*g+V*T+j*C+G*B,e[8]=(O=u[8])*p+(V=u[9])*y+(j=u[10])*S+(G=u[11])*R,e[9]=O*f+V*x+j*P+G*L,e[10]=O*m+V*b+j*I+G*F,e[11]=O*g+V*T+j*C+G*B,e[12]=(O=u[12])*p+(V=u[13])*y+(j=u[14])*S+(G=u[15])*R,e[13]=O*f+V*x+j*P+G*L,e[14]=O*m+V*b+j*I+G*F,e[15]=O*g+V*T+j*C+G*B,e},c.T=zl,c.U=function(e,c){const u={};for(let p=0;p0||(null===(f=u.addOrUpdateProperties)||void 0===f?void 0:f.length)>0;if(!g&&!y)continue;m.push(c.geometry);const x=Object.assign({},c);if(e.set(u.id,x),g&&(m.push(u.newGeometry),x.geometry=u.newGeometry),y){if(x.properties=u.removeAllProperties?{}:Object.assign({},x.properties||{}),u.removeProperties)for(const e of u.removeProperties)delete x.properties[e];if(u.addOrUpdateProperties)for(const{key:e,value:c}of u.addOrUpdateProperties)x.properties[e]=c}}return m},c.a9=Vh,c.aA=function(e,{uSize:c,uSizeT:u},{lowerSize:p,upperSize:f}){return"source"===e.kind?p/zp:"composite"===e.kind?Ur.number(p/zp,f/zp,u):c},c.aB=function(e,c){var u=c[0],p=c[1],f=c[2],m=c[3],g=c[4],y=c[5],x=c[6],b=c[7],T=c[8],S=c[9],P=c[10],I=c[11],C=c[12],R=c[13],L=c[14],F=c[15],B=u*y-p*g,O=u*x-f*g,V=u*b-m*g,j=p*x-f*y,G=p*b-m*y,U=f*b-m*x,q=T*R-S*C,Z=T*L-P*C,W=T*F-I*C,Q=S*L-P*R,J=S*F-I*R,re=P*F-I*L,se=B*re-O*J+V*Q+j*W-G*Z+U*q;return se?(e[0]=(y*re-x*J+b*Q)*(se=1/se),e[1]=(f*J-p*re-m*Q)*se,e[2]=(R*U-L*G+F*j)*se,e[3]=(P*G-S*U-I*j)*se,e[4]=(x*W-g*re-b*Z)*se,e[5]=(u*re-f*W+m*Z)*se,e[6]=(L*V-C*U-F*O)*se,e[7]=(T*U-P*V+I*O)*se,e[8]=(g*J-y*W+b*q)*se,e[9]=(p*W-u*J-m*q)*se,e[10]=(C*G-R*V+F*B)*se,e[11]=(S*V-T*G-I*B)*se,e[12]=(y*Z-g*Q-x*q)*se,e[13]=(u*Q-p*Z+f*q)*se,e[14]=(R*O-C*j-L*B)*se,e[15]=(T*j-S*O+P*B)*se,e):null},c.aC=J,c.aD=function(e){var c=e[0],u=e[1];return Math.sqrt(c*c+u*u)},c.aE=function(e){return e[0]=0,e[1]=0,e},c.aF=function(e,c,u){return e[0]=c[0]*u,e[1]=c[1]*u,e},c.aG=Np,c.aH=Z,c.aI=function(e,c,u,f){const m=c.y-e.y,g=c.x-e.x,y=f.y-u.y,x=f.x-u.x,b=y*g-x*m;if(0===b)return null;const T=(x*(e.y-u.y)-y*(e.x-u.x))/b;return new p(e.x+T*g,e.y+T*m)},c.aJ=Wm,c.aK=oh,c.aL=function(e){let c=1/0,u=1/0,p=-1/0,f=-1/0;for(const m of e)c=Math.min(c,m.x),u=Math.min(u,m.y),p=Math.max(p,m.x),f=Math.max(f,m.y);return[c,u,p,f]},c.aM=Ud,c.aN=le,c.aO=function(e,c,u,p,f=!1){if(!u[0]&&!u[1])return[0,0];const m=f?"map"===p?-e.bearingInRadians:0:"viewport"===p?e.bearingInRadians:0;if(m){const e=Math.sin(m),c=Math.cos(m);u=[u[0]*c-u[1]*e,u[0]*e+u[1]*c]}return[f?u[0]:le(c,u[0],e.zoom),f?u[1]:le(c,u[1],e.zoom)]},c.aQ=Bp,c.aR=y_,c.aS=vp,c.aT=Ad,c.aU=Ac,c.aV=pu,c.aW=$a,c.aX=io,c.aY=to,c.aZ=et,c.a_=gf,c.aa=qh,c.ab=25,c.ac=Lh,c.ad=e=>{const c=window.document.createElement("video");return c.muted=!0,new Promise((u=>{c.onloadstart=()=>{u(c)};for(const u of e){const e=window.document.createElement("source");bt(u)||(c.crossOrigin="Anonymous"),e.src=u,c.appendChild(e)}}))},c.ae=Dt,c.af=function(){return xe++},c.ag=Fa,c.ah=fh,c.ai=Bm,c.aj=Lo,c.ak=rh,c.al=Xh,c.am=function(e){const c={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,u,p,f)=>{const m=p||f;return c[u]=!m||m.toLowerCase(),""})),c["max-age"]){const e=parseInt(c["max-age"],10);isNaN(e)?delete c["max-age"]:c["max-age"]=e}return c},c.an=me,c.ao=85.051129,c.ap=Ye,c.aq=function(e){return Math.pow(2,e)},c.ar=L,c.as=hf,c.at=function(e){return Math.log(e)/Math.LN2},c.au=function(e){var c=e[0],u=e[1];return c*c+u*u},c.av=function(e){if(!e.length)return new Set;const c=Math.max(...e.map((e=>e.canonical.z)));let u=1/0,p=-1/0,f=1/0,m=-1/0;const g=[];for(const y of e){const{x:e,y:x,z:b}=y.canonical,T=Math.pow(2,c-b),S=e*T,P=x*T;g.push({id:y,x:S,y:P}),Sp&&(p=S),Pm&&(m=P)}const y=new Set;for(const e of g)e.x!==u&&e.x!==p&&e.y!==f&&e.y!==m||y.add(e.id);return y},c.aw=function(e,c){const u=Math.abs(2*e.wrap)-+(e.wrap<0),p=Math.abs(2*c.wrap)-+(c.wrap<0);return e.overscaledZ-c.overscaledZ||p-u||c.canonical.y-e.canonical.y||c.canonical.x-e.canonical.x},c.ax=class{constructor(e,c){this.max=e,this.onRemove=c,this.reset()}reset(){for(const e in this.data)for(const c of this.data[e])c.timeout&&clearTimeout(c.timeout),this.onRemove(c.value);return this.data={},this.order=[],this}add(e,c,u){const p=e.wrapped().key;void 0===this.data[p]&&(this.data[p]=[]);const f={value:c,timeout:void 0};if(void 0!==u&&(f.timeout=setTimeout((()=>{this.remove(e,f)}),u)),this.data[p].push(f),this.order.push(p),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 c=this.data[e].shift();return c.timeout&&clearTimeout(c.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),c.value}getByKey(e){const c=this.data[e];return c?c[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,c){if(!this.has(e))return this;const u=e.wrapped().key,p=void 0===c?0:this.data[u].indexOf(c),f=this.data[u][p];return this.data[u].splice(p,1),f.timeout&&clearTimeout(f.timeout),0===this.data[u].length&&delete this.data[u],this.onRemove(f.value),this.order.splice(this.order.indexOf(u),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 c=[];for(const u in this.data)for(const p of this.data[u])e(p.value)||c.push(p);for(const e of c)this.remove(e.value.tileID,e)}},c.ay=function(e,c){let u=0,p=0;if("constant"===e.kind)p=e.layoutSize;else if("source"!==e.kind){const{interpolationType:f,minZoom:m,maxZoom:g}=e,y=f?me(fr.interpolationFactor(f,c,m,g),0,1):0;"camera"===e.kind?p=Ur.number(e.minSize,e.maxSize,y):u=y}return{uSizeT:u,uSize:p}},c.b=je,c.b$=Ao,c.b0=V,c.b1=function(e){var c=new C(3);return c[0]=e[0],c[1]=e[1],c[2]=e[2],c},c.b2=function(e,c,u){return e[0]=c[0]-u[0],e[1]=c[1]-u[1],e[2]=c[2]-u[2],e},c.b3=function(e,c){var u=c[0],p=c[1],f=c[2],m=u*u+p*p+f*f;return m>0&&(m=1/Math.sqrt(m)),e[0]=c[0]*m,e[1]=c[1]*m,e[2]=c[2]*m,e},c.b4=G,c.b5=function(e,c){return e[0]*c[0]+e[1]*c[1]+e[2]*c[2]},c.b6=function(e,c,u){return e[0]=c[0]*u[0],e[1]=c[1]*u[1],e[2]=c[2]*u[2],e[3]=c[3]*u[3],e},c.b7=B,c.b8=function(e,c,u){const p=c[0]*u[0]+c[1]*u[1]+c[2]*u[2];return 0===p?null:(-(e[0]*u[0]+e[1]*u[1]+e[2]*u[2])-u[3])/p},c.b9=q,c.bA=function(){return new Float64Array(3)},c.bB=Q,c.bC=function(e,c,u){var p=u[0],f=u[1],m=u[2],g=u[3],y=c[0],x=c[1],b=c[2],T=f*b-m*x,S=m*y-p*b,P=p*x-f*y;return e[0]=y+g*(T+=T)+f*(P+=P)-m*(S+=S),e[1]=x+g*S+m*T-p*P,e[2]=b+g*P+p*S-f*T,e},c.bD=function(e,c,u){const p=(f=[e[0],e[1],e[2],c[0],c[1],c[2],u[0],u[1],u[2]])[0]*((T=f[8])*(g=f[4])-(y=f[5])*(b=f[7]))+f[1]*(-T*(m=f[3])+y*(x=f[6]))+f[2]*(b*m-g*x);var f,m,g,y,x,b,T;if(0===p)return null;const S=G([],[c[0],c[1],c[2]],[u[0],u[1],u[2]]),P=G([],[u[0],u[1],u[2]],[e[0],e[1],e[2]]),I=G([],[e[0],e[1],e[2]],[c[0],c[1],c[2]]),C=j([],S,-e[3]);return V(C,C,j([],P,-c[3])),V(C,C,j([],I,-u[3])),j(C,C,1/p),C},c.bE=ef,c.bF=function(){return new Float64Array(4)},c.bG=function(e,c,u,p){var f=[],m=[];return f[0]=c[0]-u[0],f[1]=c[1]-u[1],f[2]=c[2]-u[2],m[0]=f[0]*Math.cos(p)-f[1]*Math.sin(p),m[1]=f[0]*Math.sin(p)+f[1]*Math.cos(p),m[2]=f[2],e[0]=m[0]+u[0],e[1]=m[1]+u[1],e[2]=m[2]+u[2],e},c.bH=function(e,c,u,p){var f=[],m=[];return f[0]=c[0]-u[0],f[1]=c[1]-u[1],f[2]=c[2]-u[2],m[0]=f[0],m[1]=f[1]*Math.cos(p)-f[2]*Math.sin(p),m[2]=f[1]*Math.sin(p)+f[2]*Math.cos(p),e[0]=m[0]+u[0],e[1]=m[1]+u[1],e[2]=m[2]+u[2],e},c.bI=function(e,c,u,p){var f=[],m=[];return f[0]=c[0]-u[0],f[1]=c[1]-u[1],f[2]=c[2]-u[2],m[0]=f[2]*Math.sin(p)+f[0]*Math.cos(p),m[1]=f[1],m[2]=f[2]*Math.cos(p)-f[0]*Math.sin(p),e[0]=m[0]+u[0],e[1]=m[1]+u[1],e[2]=m[2]+u[2],e},c.bJ=function(e,c,u){var p=Math.sin(u),f=Math.cos(u),m=c[0],g=c[1],y=c[2],x=c[3],b=c[8],T=c[9],S=c[10],P=c[11];return c!==e&&(e[4]=c[4],e[5]=c[5],e[6]=c[6],e[7]=c[7],e[12]=c[12],e[13]=c[13],e[14]=c[14],e[15]=c[15]),e[0]=m*f-b*p,e[1]=g*f-T*p,e[2]=y*f-S*p,e[3]=x*f-P*p,e[8]=m*p+b*f,e[9]=g*p+T*f,e[10]=y*p+S*f,e[11]=x*p+P*f,e},c.bK=function(e,c){const u=ce(e,360),p=ce(c,360),f=p-u,m=p>u?f-360:f+360;return Math.abs(f)0?g:-g},c.bN=function(e,c){const u=ce(e,2*Math.PI),p=ce(c,2*Math.PI);return Math.min(Math.abs(u-p),Math.abs(u-p+2*Math.PI),Math.abs(u-p-2*Math.PI))},c.bO=function(){const e={},c=Mt.$version;for(const u in Mt.$root){const p=Mt.$root[u];if(p.required){let f=null;f="version"===u?c:"array"===p.type?[]:{},null!=f&&(e[u]=f)}}return e},c.bP=yt,c.bQ=xs,c.bR=function e(c,u){if(Array.isArray(c)){if(!Array.isArray(u)||c.length!==u.length)return!1;for(let p=0;p"raster"===e.type,c.bV=we,c.bW=function(e,c){if(!e)return[{command:"setStyle",args:[c]}];let u=[];try{if(!Ft(e.version,c.version))return[{command:"setStyle",args:[c]}];Ft(e.center,c.center)||u.push({command:"setCenter",args:[c.center]}),Ft(e.state,c.state)||u.push({command:"setGlobalState",args:[c.state]}),Ft(e.centerAltitude,c.centerAltitude)||u.push({command:"setCenterAltitude",args:[c.centerAltitude]}),Ft(e.zoom,c.zoom)||u.push({command:"setZoom",args:[c.zoom]}),Ft(e.bearing,c.bearing)||u.push({command:"setBearing",args:[c.bearing]}),Ft(e.pitch,c.pitch)||u.push({command:"setPitch",args:[c.pitch]}),Ft(e.roll,c.roll)||u.push({command:"setRoll",args:[c.roll]}),Ft(e.sprite,c.sprite)||u.push({command:"setSprite",args:[c.sprite]}),Ft(e.glyphs,c.glyphs)||u.push({command:"setGlyphs",args:[c.glyphs]}),Ft(e.transition,c.transition)||u.push({command:"setTransition",args:[c.transition]}),Ft(e.light,c.light)||u.push({command:"setLight",args:[c.light]}),Ft(e.terrain,c.terrain)||u.push({command:"setTerrain",args:[c.terrain]}),Ft(e.sky,c.sky)||u.push({command:"setSky",args:[c.sky]}),Ft(e.projection,c.projection)||u.push({command:"setProjection",args:[c.projection]});const p={},f=[];!function(e,c,u,p){let f;for(f in c=c||{},e=e||{})Object.prototype.hasOwnProperty.call(e,f)&&(Object.prototype.hasOwnProperty.call(c,f)||Zt(f,u,p));for(f in c)Object.prototype.hasOwnProperty.call(c,f)&&(Object.prototype.hasOwnProperty.call(e,f)?Ft(e[f],c[f])||("geojson"===e[f].type&&"geojson"===c[f].type&&Xt(e,c,f)?Ot(u,{command:"setGeoJSONSourceData",args:[f,c[f].data]}):Ht(f,c,u,p)):Gt(f,c,u))}(e.sources,c.sources,f,p);const m=[];e.layers&&e.layers.forEach((e=>{"source"in e&&p[e.source]?u.push({command:"removeLayer",args:[e.id]}):m.push(e)})),u=u.concat(f),function(e,c,u){c=c||[];const p=(e=e||[]).map(Jt),f=c.map(Jt),m=e.reduce(ri,{}),g=c.reduce(ri,{}),y=p.slice(),x=Object.create(null);let b,T,S,P,I;for(let e=0,c=0;eI?(f=Math.acos(m),g=Math.sin(f),y=Math.sin((1-p)*f)/g,x=Math.sin(p*f)/g):(y=1-p,x=p),e[0]=y*b+x*C,e[1]=y*T+x*R,e[2]=y*S+x*L,e[3]=y*P+x*F,e},c.bn=function(e){const c=new Float64Array(9);var u,p,f,m,g,y,x,b,T,S,P,I,C,R,L,F,B,O;S=(f=(p=e)[0])*(x=f+f),P=(m=p[1])*x,C=(g=p[2])*x,R=g*(b=m+m),F=(y=p[3])*x,B=y*b,O=y*(T=g+g),(u=c)[0]=1-(I=m*b)-(L=g*T),u[3]=P-O,u[6]=C+B,u[1]=P+O,u[4]=1-S-L,u[7]=R-F,u[2]=C-B,u[5]=R+F,u[8]=1-S-I;const V=et(-Math.asin(me(c[2],-1,1)));let j,G;return Math.hypot(c[5],c[8])<.001?(j=0,G=-et(Math.atan2(c[3],c[4]))):(j=et(0===c[5]&&0===c[8]?0:Math.atan2(c[5],c[8])),G=et(0===c[1]&&0===c[0]?0:Math.atan2(c[1],c[0]))),{roll:j,pitch:V+90,bearing:G}},c.bo=function(e,c){return e.roll==c.roll&&e.pitch==c.pitch&&e.bearing==c.bearing},c.bp=Te,c.bq=_o,c.br=Yu,c.bs=Ku,c.bt=hu,c.bu=he,c.bv=ue,c.bw=Re,c.bx=function(e,c,u,p,f){return he(p,f,me((e-c)/(u-c),0,1))},c.by=function(e,c,u,p){return e[0]=c[0]+u[0]*p,e[1]=c[1]+u[1]*p,e[2]=c[2]+u[2]*p,e},c.bz=ce,c.c=at,c.c$=class{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start)}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return 0===e.length&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}},c.c0=class extends wo{constructor(e,c){super(e,c),this.current=Yc}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 c=1;c<16;c++)if(e[c]!==this.current[c]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},c.c1=So,c.c2=class extends wo{constructor(e,c){super(e,c),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]))}},c.c3=class extends wo{constructor(e,c){super(e,c),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]))}},c.c4=R,c.c5=function(e,c){var u=Math.sin(c),p=Math.cos(c);return e[0]=p,e[1]=u,e[2]=0,e[3]=-u,e[4]=p,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},c.c6=function(e,c,u){var p=c[0],f=c[1],m=c[2];return e[0]=p*u[0]+f*u[3]+m*u[6],e[1]=p*u[1]+f*u[4]+m*u[7],e[2]=p*u[2]+f*u[5]+m*u[8],e},c.c7=function(e,c,u,p,f,m,g){var y=1/(c-u),x=1/(p-f),b=1/(m-g);return e[0]=-2*y,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*x,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*b,e[11]=0,e[12]=(c+u)*y,e[13]=(f+p)*x,e[14]=(g+m)*b,e[15]=1,e},c.c8=class extends wo{constructor(e,c){super(e,c),this.current=new Array}set(e){if(e!=this.current){this.current=e;const c=new Float32Array(4*e.length);for(let u=0;u25||p<0||p>=1||u<0||u>=1)},c.cF=function(e,c){return e[0]=c[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=c[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},c.cG=class extends aa{},c.cH=L_,c.cJ=ct,c.cK=function(e,c){at.REGISTERED_PROTOCOLS[e]=c},c.cL=function(e){delete at.REGISTERED_PROTOCOLS[e]},c.cM=function(e,c){const u={};for(let p=0;pe*Ud))}let O=x?"center":f.get("text-justify").evaluate(m,{},e.canonical);const V="point"===f.get("symbol-placement")?f.get("text-max-width").evaluate(m,{},e.canonical)*Ud:1/0,j=()=>{e.bucket.allowVerticalPlacement&&dc(u)&&(R.vertical=xp(L,e.glyphMap,e.glyphPositions,e.imagePositions,S,V,y,C,"left",T,B,c.az.vertical,!0,I,P))};if(!x&&F){const u=new Set;if("auto"===O)for(let e=0;e=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,c)}clear(){this.map.clear()}},c.cY=Vu,c.cZ=Tc,c.c_=Df,c.ca=class extends xa{},c.cb=Nd,c.cc=class extends ba{},c.cd=su,c.ce=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},c.cf=nu,c.cg=function(e,c,u){var p=c[0],f=c[1],m=c[2],g=u[3]*p+u[7]*f+u[11]*m+u[15];return e[0]=(u[0]*p+u[4]*f+u[8]*m+u[12])/(g=g||1),e[1]=(u[1]*p+u[5]*f+u[9]*m+u[13])/g,e[2]=(u[2]*p+u[6]*f+u[10]*m+u[14])/g,e},c.ch=class extends oa{},c.ci=class extends Ta{},c.cj=function(e,c){return e[0]===c[0]&&e[1]===c[1]&&e[2]===c[2]&&e[3]===c[3]&&e[4]===c[4]&&e[5]===c[5]&&e[6]===c[6]&&e[7]===c[7]&&e[8]===c[8]&&e[9]===c[9]&&e[10]===c[10]&&e[11]===c[11]&&e[12]===c[12]&&e[13]===c[13]&&e[14]===c[14]&&e[15]===c[15]},c.ck=function(e,c){var u=e[0],p=e[1],f=e[2],m=e[3],g=e[4],y=e[5],x=e[6],b=e[7],T=e[8],S=e[9],P=e[10],C=e[11],R=e[12],L=e[13],F=e[14],B=e[15],O=c[0],V=c[1],j=c[2],G=c[3],U=c[4],q=c[5],Z=c[6],W=c[7],Q=c[8],J=c[9],re=c[10],se=c[11],le=c[12],ce=c[13],he=c[14],ue=c[15];return Math.abs(u-O)<=I*Math.max(1,Math.abs(u),Math.abs(O))&&Math.abs(p-V)<=I*Math.max(1,Math.abs(p),Math.abs(V))&&Math.abs(f-j)<=I*Math.max(1,Math.abs(f),Math.abs(j))&&Math.abs(m-G)<=I*Math.max(1,Math.abs(m),Math.abs(G))&&Math.abs(g-U)<=I*Math.max(1,Math.abs(g),Math.abs(U))&&Math.abs(y-q)<=I*Math.max(1,Math.abs(y),Math.abs(q))&&Math.abs(x-Z)<=I*Math.max(1,Math.abs(x),Math.abs(Z))&&Math.abs(b-W)<=I*Math.max(1,Math.abs(b),Math.abs(W))&&Math.abs(T-Q)<=I*Math.max(1,Math.abs(T),Math.abs(Q))&&Math.abs(S-J)<=I*Math.max(1,Math.abs(S),Math.abs(J))&&Math.abs(P-re)<=I*Math.max(1,Math.abs(P),Math.abs(re))&&Math.abs(C-se)<=I*Math.max(1,Math.abs(C),Math.abs(se))&&Math.abs(R-le)<=I*Math.max(1,Math.abs(R),Math.abs(le))&&Math.abs(L-ce)<=I*Math.max(1,Math.abs(L),Math.abs(ce))&&Math.abs(F-he)<=I*Math.max(1,Math.abs(F),Math.abs(he))&&Math.abs(B-ue)<=I*Math.max(1,Math.abs(B),Math.abs(ue))},c.cl=function(e,c){return e[0]=c[0],e[1]=c[1],e[2]=c[2],e[3]=c[3],e[4]=c[4],e[5]=c[5],e[6]=c[6],e[7]=c[7],e[8]=c[8],e[9]=c[9],e[10]=c[10],e[11]=c[11],e[12]=c[12],e[13]=c[13],e[14]=c[14],e[15]=c[15],e},c.cm=e=>"symbol"===e.type,c.cn=e=>"circle"===e.type,c.co=e=>"heatmap"===e.type,c.cp=e=>"line"===e.type,c.cq=e=>"fill"===e.type,c.cr=e=>"fill-extrusion"===e.type,c.cs=e=>"hillshade"===e.type,c.ct=e=>"color-relief"===e.type,c.cu=e=>"background"===e.type,c.cv=e=>"custom"===e.type,c.cw=pe,c.cx=function(e,c,u){if(c<=0)return e;const p=1/c;return void 0===u||Math.abs(u)<1e-10?Math.round(e*p)/p:(u>0?Math.ceil(e*p-1e-9):Math.floor(e*p+1e-10))/p},c.cy=function(e,c,u){const p=re(c.x-u.x,c.y-u.y),f=re(e.x-u.x,e.y-u.y);var m,g;return et(Math.atan2(p[0]*f[1]-p[1]*f[0],(m=p)[0]*(g=f)[0]+m[1]*g[1]))},c.cz=fe,c.d=bt,c.d0=function(c,p,f,m,g){return u(this||e,void 0,void 0,(function*(){if(P())try{return yield Ge(c,p,f,m,g)}catch(e){}return function(e,c,u,p,f){const m=e.width,g=e.height;Ue&&$e||(Ue=new OffscreenCanvas(m,g),$e=Ue.getContext("2d",{willReadFrequently:!0})),Ue.width=m,Ue.height=g,$e.drawImage(e,0,0,m,g);const y=$e.getImageData(c,u,p,f);return $e.clearRect(0,0,m,g),y.data}(c,p,f,m,g)}))},c.d1=Pl,c.d2=f,c.d3=class{constructor(e,c){this.layers={[Bm]:this},this.name=Bm,this.version=c?c.version:1,this.extent=c?c.extent:4096,this.length=e.length,this.features=e}feature(e){return new zf(this.features[e],this.extent)}},c.d4=Ws,c.d5=wc,c.e=ye,c.f=e=>u(void 0,void 0,void 0,(function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const c=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(c)}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.`)}})),c.g=ft,c.h=e=>new Promise(((c,u)=>{const p=new Image;p.onload=()=>{c(p),URL.revokeObjectURL(p.src),p.onload=null,window.requestAnimationFrame((()=>{p.src=Ne}))},p.onerror=()=>u(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 f=new Blob([new Uint8Array(e)],{type:"image/png"});p.src=e.byteLength?URL.createObjectURL(f):Ne})),c.i=Ce,c.j=(e,c)=>vt(ye(e,{type:"json"}),c),c.k=gt,c.l=mt,c.m=vt,c.n=(e,c)=>vt(ye(e,{type:"arrayBuffer"}),c),c.o=function(e){return new Tc(e).readFields(fp,[])},c.p=gp,c.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))},c.r=_l,c.s=He,c.t=Hs,c.u=Mt,c.v=$l,c.w=Me,c.x=Os,c.y=Hl,c.z=Mc}));p("worker",["./shared"],(function(e){class t{constructor(e,c){this.keyCache={},e&&this.replace(e,c)}replace(e,c){this._layerConfigs={},this._layers={},this.update(e,[],c)}update(c,u,p){for(const u of c){this._layerConfigs[u.id]=u;const c=this._layers[u.id]=e.bT(u,p);c._featureFilter=e.aj(c.filter,p),this.keyCache[u.id]&&delete this.keyCache[u.id]}for(const e of u)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const f=e.cM(Object.values(this._layerConfigs),this.keyCache);for(const c of f){const u=c.map((e=>this._layers[e.id])),p=u[0];if(p.isHidden())continue;const f=p.source||"";let m=this.familiesBySource[f];m||(m=this.familiesBySource[f]={});const g=p.sourceLayer||e.ai;let y=m[g];y||(y=m[g]=[]),y.push(u)}}}class o{constructor(c){const u={},p=[];for(const e in c){const f=c[e],m=u[e]={};for(const e in f){const c=f[+e];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const u={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2};p.push(u),m[e]={rect:u,metrics:c.metrics}}}const{w:f,h:m}=e.p(p),g=new e.r({width:f||1,height:m||1});for(const p in c){const f=c[p];for(const c in f){const m=f[+c];if(!m||0===m.bitmap.width||0===m.bitmap.height)continue;const y=u[p][c].rect;e.r.copy(m.bitmap,g,{x:0,y:0},{x:y.x+1,y:y.y+1},m.bitmap)}}this.image=g,this.positions=u}}e.cN("GlyphAtlas",o);class s{constructor(c){this.tileID=new e.a2(c.tileID.overscaledZ,c.tileID.wrap,c.tileID.canonical.z,c.tileID.canonical.x,c.tileID.canonical.y),this.uid=c.uid,this.zoom=c.zoom,this.pixelRatio=c.pixelRatio,this.tileSize=c.tileSize,this.source=c.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=c.showCollisionBoxes,this.collectResourceTiming=!!c.collectResourceTiming,this.returnDependencies=!!c.returnDependencies,this.promoteId=c.promoteId,this.inFlightDependencies=[]}parse(u,p,f,m,g){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=u,this.collisionBoxArray=new e.ag;const y=new e.cO(Object.keys(u.layers).sort()),x=new e.cP(this.tileID,this.promoteId);x.bucketLayerIDs=[];const b={},T={featureIndex:x,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:f,subdivisionGranularity:g},S=p.familiesBySource[this.source];for(const p in S){const m=u.layers[p];if(!m)continue;1===m.version&&e.w(`Vector tile source "${this.source}" layer "${p}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const g=y.encode(p),P=[];for(let e=0;ee.id))))}}const P=e.bY(T.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let I=Promise.resolve({});if(Object.keys(P).length){const e=new AbortController;this.inFlightDependencies.push(e),I=m.sendAsync({type:"GG",data:{stacks:P,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const C=Object.keys(T.iconDependencies);let R=Promise.resolve({});if(C.length){const e=new AbortController;this.inFlightDependencies.push(e),R=m.sendAsync({type:"GI",data:{icons:C,source:this.source,tileID:this.tileID,type:"icons"}},e)}const L=Object.keys(T.patternDependencies);let F=Promise.resolve({});if(L.length){const e=new AbortController;this.inFlightDependencies.push(e),F=m.sendAsync({type:"GI",data:{icons:L,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const B=T.dashDependencies;let O=Promise.resolve({});if(Object.keys(B).length){const e=new AbortController;this.inFlightDependencies.push(e),O=m.sendAsync({type:"GDA",data:{dashes:B}},e)}const[V,j,G,U]=yield Promise.all([I,R,F,O]),q=new o(V),Z=new e.cQ(j,G);for(const u in b){const p=b[u];p instanceof e.ah?(c(p.layers,this.zoom,f),e.cR({bucket:p,glyphMap:V,glyphPositions:q.positions,imageMap:j,imagePositions:Z.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:T.subdivisionGranularity})):p.hasDependencies&&(p instanceof e.cS||p instanceof e.cT||p instanceof e.cU)&&(c(p.layers,this.zoom,f),p.addFeatures(T,this.tileID.canonical,Z.patternPositions,U))}return this.status="done",{buckets:Object.values(b).filter((e=>!e.isEmpty())),featureIndex:x,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:q.image,imageAtlas:Z,dashPositions:U,glyphMap:this.returnDependencies?V:null,iconMap:this.returnDependencies?j:null,glyphPositions:this.returnDependencies?q.positions:null}}))}}function c(c,u,p){const f=new e.H(u);for(const e of c)e.recalculate(f,p)}class r{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(e,c){this.loading[e]=c}finishLoading(e){delete this.loading[e]}abort(e){const c=this.loading[e];(null==c?void 0:c.abort)&&(c.abort.abort(),delete this.loading[e])}setParsing(e,c){this.parsing[e]=c}consumeParsing(e){const c=this.parsing[e];if(c)return delete this.parsing[e],c}clearParsing(e){delete this.parsing[e]}markLoaded(e,c){this.loaded[e]=c}getLoaded(e){const c=this.loaded[e];if(c)return c}removeLoaded(e){delete this.loaded[e]}clearLoaded(){this.loaded={}}}class n{constructor(e,c,u,p,f){this.type=e,this.properties=u||{},this.extent=f,this.pointsArray=c,this.id=p}loadGeometry(){return this.pointsArray.map((c=>c.map((c=>new e.P(c.x,c.y)))))}}class a{constructor(e,c,u){this.version=2,this._myFeatures=e,this.name=c,this.length=e.length,this.extent=u}feature(e){return this._myFeatures[e]}}class l{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function u(c){let u=e.cV(c);return 0===u.byteOffset&&u.byteLength===u.buffer.byteLength||(u=new Uint8Array(u)),{vectorTile:c,rawData:u.buffer}}function p(c,u,p){const{extent:f}=c,m=Math.pow(2,p.z-u.z),g=(p.x-u.x*m)*f,y=(p.y-u.y*m)*f,x=[];for(let u=0;u0&&T.addLayer(m)}const P=u(T);return this.overzoomedTileResultCache.set(x,P),P}reloadTile(c){return e._(this,void 0,void 0,(function*(){const e=c.uid,u=this.tileState.getLoaded(e);if(!u)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(u.showCollisionBoxes=c.showCollisionBoxes,"parsing"===u.status){const p=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(u,c,p)}if("done"===u.status&&u.vectorTile)return yield this._parseWorkerTile(u,c)}))}abortTile(c){return e._(this,void 0,void 0,(function*(){this.tileState.abort(c.uid)}))}removeTile(c){return e._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(c.uid)}))}}class d{constructor(){this.loaded={}}loadTile(c){return e._(this,void 0,void 0,(function*(){const{uid:u,encoding:p,rawImageData:f,redFactor:m,greenFactor:g,blueFactor:y,baseShift:x}=c,b=f.width+2,T=f.height+2,S=e.b(f)?new e.R({width:b,height:T},yield e.d0(f,-1,-1,b,T)):f,P=new e.d1(u,S,p,m,g,y,x);return this.loaded=this.loaded||{},this.loaded[u]=P,P}))}removeTile(e){const c=this.loaded,u=e.uid;c&&c[u]&&delete c[u]}}var f,m,g=function(){if(m)return f;function e(e,u){if(0!==e.length){c(e[0],u);for(var p=1;p=Math.abs(y)?u-x+y:y-x+u,u=x}u+p>=0!=!!c&&e.reverse()}return m=1,f=function c(u,p){var f,m=u&&u.type;if("FeatureCollection"===m)for(f=0;fe},b=Math.fround||(T=new Float32Array(1),e=>(T[0]=+e,T[0]));var T;class _{constructor(e){this.options=Object.assign(Object.create(x),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:c,minZoom:u,maxZoom:p}=this.options;c&&console.time("total time");const f=`prepare ${e.length} points`;c&&console.time(f),this.points=e;const m=[];for(let c=0;c=u;e--){const u=+Date.now();g=this.trees[e]=this._createTree(this._cluster(g,e)),c&&console.log("z%d: %d clusters in %dms",e,g.numItems,+Date.now()-u)}return c&&console.timeEnd("total time"),this}getClusters(e,c){let u=((e[0]+180)%360+360)%360-180;const p=Math.max(-90,Math.min(90,e[1]));let f=180===e[2]?180:((e[2]+180)%360+360)%360-180;const m=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)u=-180,f=180;else if(u>f){const e=this.getClusters([u,p,180,m],c),g=this.getClusters([-180,p,f,m],c);return e.concat(g)}const g=this.trees[this._limitZoom(c)],y=g.range(I(u),C(m),I(f),C(p)),x=g.data,b=[];for(const e of y){const c=this.stride*e;b.push(x[c+5]>1?S(x,c,this.clusterProps):this.points[x[c+3]])}return b}getChildren(e){const c=this._getOriginId(e),u=this._getOriginZoom(e),p="No cluster with the specified id.",f=this.trees[u];if(!f)throw new Error(p);const m=f.data;if(c*this.stride>=m.length)throw new Error(p);const g=this.options.radius/(this.options.extent*Math.pow(2,u-1)),y=f.within(m[c*this.stride],m[c*this.stride+1],g),x=[];for(const c of y){const u=c*this.stride;m[u+4]===e&&x.push(m[u+5]>1?S(m,u,this.clusterProps):this.points[m[u+3]])}if(0===x.length)throw new Error(p);return x}getLeaves(e,c,u){const p=[];return this._appendLeaves(p,e,c=c||10,u=u||0,0),p}getTile(e,c,u){const p=this.trees[this._limitZoom(e)],f=Math.pow(2,e),{extent:m,radius:g}=this.options,y=g/m,x=(u-y)/f,b=(u+1+y)/f,T={features:[]};return this._addTileFeatures(p.range((c-y)/f,x,(c+1+y)/f,b),p.data,c,u,f,T),0===c&&this._addTileFeatures(p.range(1-y/f,x,1,b),p.data,f,u,f,T),c===f-1&&this._addTileFeatures(p.range(0,x,y/f,b),p.data,-1,u,f,T),T.features.length?T:null}getClusterExpansionZoom(e){let c=this._getOriginZoom(e)-1;for(;c<=this.options.maxZoom;){const u=this.getChildren(e);if(c++,1!==u.length)break;e=u[0].properties.cluster_id}return c}_appendLeaves(e,c,u,p,f){const m=this.getChildren(c);for(const c of m){const m=c.properties;if(m&&m.cluster?f+m.point_count<=p?f+=m.point_count:f=this._appendLeaves(e,m.cluster_id,u,p,f):f1;let x,b,T;if(y)x=P(c,e,this.clusterProps),b=c[e],T=c[e+1];else{const u=this.points[c[e+3]];x=u.properties;const[p,f]=u.geometry.coordinates;b=I(p),T=C(f)}const S={type:1,geometry:[[Math.round(this.options.extent*(b*f-u)),Math.round(this.options.extent*(T*f-p))]],tags:x};let R;R=y||this.options.generateId?c[e+3]:this.points[c[e+3]].id,void 0!==R&&(S.id=R),m.features.push(S)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,c){const{radius:u,extent:p,reduce:f,minPoints:m}=this.options,g=u/(p*Math.pow(2,c)),y=e.data,x=[],b=this.stride;for(let u=0;uc&&(I+=y[u+5])}if(I>P&&I>=m){let e,m=p*P,g=T*P,C=-1;const R=(u/b<<5)+(c+1)+this.points.length;for(const p of S){const x=p*b;if(y[x+2]<=c)continue;y[x+2]=c;const T=y[x+5];m+=y[x]*T,g+=y[x+1]*T,y[x+4]=R,f&&(e||(e=this._map(y,u,!0),C=this.clusterProps.length,this.clusterProps.push(e)),f(e,this._map(y,x)))}y[u+4]=R,x.push(m/I,g/I,1/0,R,-1,I),f&&x.push(C)}else{for(let e=0;e1)for(const e of S){const u=e*b;if(!(y[u+2]<=c)){y[u+2]=c;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,c,u){if(e[c+5]>1){const p=this.clusterProps[e[c+6]];return u?Object.assign({},p):p}const p=this.points[e[c+3]].properties,f=this.options.map(p);return u&&f===p?Object.assign({},f):f}}function S(e,c,u){return{type:"Feature",id:e[c+3],properties:P(e,c,u),geometry:{type:"Point",coordinates:[(p=e[c],360*(p-.5)),R(e[c+1])]}};var p}function P(e,c,u){const p=e[c+5],f=p>=1e4?`${Math.round(p/1e3)}k`:p>=1e3?Math.round(p/100)/10+"k":p,m=e[c+6],g=-1===m?{}:Object.assign({},u[m]);return Object.assign(g,{cluster:!0,cluster_id:e[c+3],point_count:p,point_count_abbreviated:f})}function I(e){return e/360+.5}function C(e){const c=Math.sin(e*Math.PI/180),u=.5-.25*Math.log((1+c)/(1-c))/Math.PI;return u<0?0:u>1?1:u}function R(e){const c=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(c))/Math.PI-90}function L(e,c,u,p){let f=p;const m=c+(u-c>>1);let g,y=u-c;const x=e[c],b=e[c+1],T=e[u],S=e[u+1];for(let p=c+3;pf)g=p,f=c;else if(c===f){const e=Math.abs(p-m);ep&&(g-c>3&&L(e,c,g,p),e[g+2]=f,u-g>3&&L(e,g,u,p))}function F(e,c,u,p,f,m){let g=f-u,y=m-p;if(0!==g||0!==y){const x=((e-u)*g+(c-p)*y)/(g*g+y*y);x>1?(u=f,p=m):x>0&&(u+=g*x,p+=y*x)}return g=e-u,y=c-p,g*g+y*y}function B(e,c,u,p){const f={type:c,geom:u},m={id:null==e?null:e,type:f.type,geometry:f.geom,tags:p,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(f.type){case"Point":case"MultiPoint":case"LineString":O(m,f.geom);break;case"Polygon":O(m,f.geom[0]);break;case"MultiLineString":for(const e of f.geom)O(m,e);break;case"MultiPolygon":for(const e of f.geom)O(m,e[0])}return m}function O(e,c){for(let u=0;u0&&(g+=p?(f*x-y*m)/2:Math.sqrt(Math.pow(y-f,2)+Math.pow(x-m,2))),f=y,m=x}const y=c.length-3;c[2]=1,u>0&&L(c,0,y,u),c[y+2]=1,c.size=Math.abs(g),c.start=0,c.end=c.size}function q(e,c,u,p){for(let f=0;f1?1:u}function Q(e,c,u,p,f,m,g,y){if(p/=c,m>=(u/=c)&&g=p)return null;const x=[];for(const c of e){const e=0===f?c.minX:c.minY,m=0===f?c.maxX:c.maxY;if(e>=u&&m=p))switch(c.type){case"Point":case"MultiPoint":{const e=[];if(J(c.geometry,e,u,p,f),!e.length)continue;x.push(B(c.id,3===e.length?"Point":"MultiPoint",e,c.tags));continue}case"LineString":{const e=[];if(re(c.geometry,e,u,p,f,!1,y.lineMetrics),!e.length)continue;if(y.lineMetrics){for(const u of e)x.push(B(c.id,c.type,u,c.tags));continue}if(e.length>1){x.push(B(c.id,"MultiLineString",e,c.tags));continue}x.push(B(c.id,c.type,e[0],c.tags));continue}case"MultiLineString":{const e=[];if(le(c.geometry,e,u,p,f,!1),!e.length)continue;if(1===e.length){x.push(B(c.id,"LineString",e[0],c.tags));continue}x.push(B(c.id,c.type,e,c.tags));continue}case"Polygon":{const e=[];if(le(c.geometry,e,u,p,f,!0),!e.length)continue;x.push(B(c.id,c.type,e,c.tags));continue}case"MultiPolygon":{const e=[];for(const m of c.geometry){const c=[];le(m,c,u,p,f,!0),c.length&&e.push(c)}if(!e.length)continue;x.push(B(c.id,c.type,e,c.tags));continue}}}return x.length?x:null}function J(e,c,u,p,f){for(let m=0;m=u&&g<=p&&ce(c,e[m],e[m+1],e[m+2])}}function re(e,c,u,p,f,m,g){let y=se(e);const x=0===f?he:ue;let b,T,S=e.start;for(let P=0;Pu&&(T=x(y,I,C,L,F,u),g&&(y.start=S+b*T)):B>p?O=u&&(T=x(y,I,C,L,F,u),V=!0),O>p&&B<=p&&(T=x(y,I,C,L,F,p),V=!0),!m&&V&&(g&&(y.end=S+b*T),c.push(y),y=se(e)),g&&(S+=b)}let P=e.length-3;const I=e[P],C=e[P+1],R=0===f?I:C;R>=u&&R<=p&&ce(y,I,C,e[P+2]),P=y.length-3,m&&P>=3&&(y[P]!==y[0]||y[P+1]!==y[1])&&ce(y,y[0],y[1],y[2]),y.length&&c.push(y)}function se(e){const c=[];return c.size=e.size,c.start=e.start,c.end=e.end,c}function le(e,c,u,p,f,m){for(const g of e)re(g,c,u,p,f,m,!1)}function ce(e,c,u,p){e.push(c,u,p)}function he(e,c,u,p,f,m){const g=(m-c)/(p-c);return ce(e,m,u+(f-u)*g,1),g}function ue(e,c,u,p,f,m){const g=(m-u)/(f-u);return ce(e,c+(p-c)*g,m,1),g}function pe(e,c){const u=c.buffer/c.extent;let p=e;const f=Q(e,1,-1-u,u,0,-1,2,c),m=Q(e,1,1-u,2+u,0,-1,2,c);return f||m?(p=Q(e,1,-u,1+u,0,-1,2,c)||[],f&&(p=fe(f,1).concat(p)),m&&(p=p.concat(fe(m,-1))),p):p}function fe(e,c){const u=[];for(const p of e)switch(p.type){case"Point":case"MultiPoint":case"LineString":{const e=me(p.geometry,c);u.push(B(p.id,p.type,e,p.tags));continue}case"MultiLineString":case"Polygon":{const e=[];for(const u of p.geometry)e.push(me(u,c));u.push(B(p.id,p.type,e,p.tags));continue}case"MultiPolygon":{const e=[];for(const u of p.geometry){const p=[];for(const e of u)p.push(me(e,c));e.push(p)}u.push(B(p.id,p.type,e,p.tags));continue}}return u}function me(e,c){const u=[];u.size=e.size,void 0!==e.start&&(u.start=e.start,u.end=e.end);for(let p=0;p0&&c.size<(f?g:p))return void(u.numPoints+=c.length/3);const y=[];for(let e=0;eg)&&(u.numSimplified++,y.push(c[e],c[e+1])),u.numPoints++;f&&function(e,c){let u=0;for(let c=0,p=e.length,f=p-2;c0===c)for(let c=0,u=e.length;c0||c.addOrUpdateProperties?.length>0;if(p){let p=V({type:"FeatureCollection",features:[{type:"Feature",id:e.id,geometry:c.newGeometry,properties:f?Se(e.tags,c):e.tags}]},u);return p=pe(p,u),p[0]}if(f){const u={...e};return u.tags=Se(u.tags,c),u}return null}function Se(e,c){if(c.removeAllProperties)return{};const u={...e||{}};if(c.removeProperties)for(const e of c.removeProperties)delete u[e];if(c.addOrUpdateProperties)for(const{key:e,value:p}of c.addOrUpdateProperties)u[e]=p;return u}const Me={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,debug:0};class oe{options;tiles;tileCoords;stats={};total=0;source;constructor(e,c){const u=(c=this.options=Object.assign({},Me,c)).debug;if(u&&console.time("preprocess data"),c.maxZoom<0||c.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(c.promoteId&&c.generateId)throw new Error("promoteId and generateId cannot be used together.");let p=V(e,c);this.tiles={},this.tileCoords=[],u&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",c.indexMaxZoom,c.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),p=pe(p,c),p.length&&this.splitTile(p,0,0,0),c.updateable&&(this.source=p),u&&(p.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(e,c,u,p,f,m,g){const y=[e,c,u,p],x=this.options,b=x.debug;for(;y.length;){p=y.pop(),u=y.pop(),c=y.pop(),e=y.pop();const T=1<1&&console.time("creation"),P=this.tiles[S]=xe(e,c,u,p,x),this.tileCoords.push({z:c,x:u,y:p,id:S}),b)){b>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",c,u,p,P.numFeatures,P.numPoints,P.numSimplified),console.timeEnd("creation"));const e=`z${c}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(P.source=e,null==f){if(c===x.indexMaxZoom||P.numPoints<=x.indexMaxPoints)continue}else{if(c===x.maxZoom||c===f)continue;if(null!=f){const e=f-c;if(u!==m>>e||p!==g>>e)continue}}if(P.source=null,!e.length)continue;b>1&&console.time("clipping");const I=.5*x.buffer/x.extent,C=.5-I,R=.5+I,L=1+I;let F=null,B=null,O=null,V=null;const j=Q(e,T,u-I,u+R,0,P.minX,P.maxX,x),G=Q(e,T,u+C,u+L,0,P.minX,P.maxX,x);j&&(F=Q(j,T,p-I,p+R,1,P.minY,P.maxY,x),B=Q(j,T,p+C,p+L,1,P.minY,P.maxY,x)),G&&(O=Q(G,T,p-I,p+R,1,P.minY,P.maxY,x),V=Q(G,T,p+C,p+L,1,P.minY,P.maxY,x)),b>1&&console.timeEnd("clipping"),y.push(F||[],c+1,2*u,2*p),y.push(B||[],c+1,2*u,2*p+1),y.push(O||[],c+1,2*u+1,2*p),y.push(V||[],c+1,2*u+1,2*p+1)}}getTile(e,c,u){e=+e,c=+c,u=+u;const p=this.options,{extent:f,debug:m}=p;if(e<0||e>24)return null;const g=1<1&&console.log("drilling down to z%d-%d-%d",e,c,u);let x,b=e,T=c,S=u;for(;!x&&b>0;)b--,T>>=1,S>>=1,x=this.tiles[Ee(b,T,S)];return x?.source?(m>1&&(console.log("found parent tile z%d-%d-%d",b,T,S),console.time("drilling down")),this.splitTile(x.source,b,T,S,e,c,u),m>1&&console.timeEnd("drilling down"),this.tiles[y]?ge(this.tiles[y],f):null):null}invalidateTiles(e){const c=this.options,{debug:u}=c;let p=1/0,f=-1/0,m=1/0,g=-1/0;for(const c of e)p=Math.min(p,c.minX),f=Math.max(f,c.maxX),m=Math.min(m,c.minY),g=Math.max(g,c.maxY);const y=c.buffer/c.extent,x=new Set;for(const c in this.tiles){const b=this.tiles[c],T=1<=P||g=C)continue;let R=!1;for(const c of e)if(c.maxX>=S&&c.minX=I&&c.minY1&&console.log("invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",b.z,b.x,b.y,b.numFeatures,b.numPoints,b.numSimplified);const e=`z${b.z}`;this.stats[e]=(this.stats[e]||0)-1,this.total--}delete this.tiles[c],x.add(c)}}x.size&&(this.tileCoords=this.tileCoords.filter((e=>!x.has(e.id))))}updateData(e){const c=this.options,u=c.debug;if(!c.updateable)throw new Error("to update tile geojson `updateable` option must be set to true");const{affected:p,source:f}=function(e,c,u){const p=function(e){return e?{removeAll:e.removeAll,remove:new Set(e.remove||[]),add:new Map(e.add?.map((e=>[e.id,e]))),update:new Map(e.update?.map((e=>[e.id,e])))}:{remove:new Set,add:new Map,update:new Map}}(c);let f=[];if(p.removeAll&&(f=e,e=[]),p.remove.size||p.add.size){const c=[];for(const u of e){const{id:e}=u;(p.remove.has(e)||p.add.has(e))&&c.push(u)}if(c.length){f.push(...c);const u=new Set(c.map((e=>e.id)));e=e.filter((e=>!u.has(e.id)))}if(p.add.size){let c=V({type:"FeatureCollection",features:Array.from(p.add.values())},u);c=pe(c,u),f.push(...c),e.push(...c)}}if(p.update.size)for(const[c,m]of p.update){const p=e.findIndex((e=>e.id===c));if(-1===p)continue;const g=e[p],y=we(g,m,u);y&&(f.push(g,y),e[p]=y)}return{affected:f,source:e}}(this.source,e,c);if(!p.length)return;this.source=f,u>1&&(console.log("invalidating tiles"),console.time("invalidating")),this.invalidateTiles(p),u>1&&console.timeEnd("invalidating");const[m,g,y]=[0,0,0],x=xe(this.source,m,g,y,this.options);x.source=this.source;const b=Ee(m,g,y);if(this.tiles[b]=x,this.tileCoords.push({z:m,x:g,y:y,id:b}),u){const e=`z${m}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}}}function Ee(e,c,u){return 32*((1<`${e.key}: ${e.message}`)).join(", "));const f=c.features.filter((e=>p.value.evaluate({zoom:0},e)));return this._toFeatureCollection(f)}_toFeatureCollection(e){return{type:"FeatureCollection",features:e}}removeSource(c){return e._(this,void 0,void 0,(function*(){var e;null===(e=this._pendingRequest)||void 0===e||e.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 Ce(c,u){return u.cluster?new _(function({superclusterOptions:c,clusterProperties:u}){if(!u||!c)return c;const p={},f={},m={accumulated:null,zoom:0},g={properties:null},y=Object.keys(u);for(const c of y){const[m,g]=u[c],y=e.d4(g),x=e.d4("string"==typeof m?[m,["accumulated"],["get",c]]:m);p[c]=y.value,f[c]=x.value}return c.map=e=>{g.properties=e;const c={};for(const e of y)c[e]=p[e].evaluate(m,g);return c},c.reduce=(e,c)=>{g.properties=c;for(const c of y)m.accumulated=e[c],e[c]=f[c].evaluate(m,g)},c}(u)).load(c.features):function(e,c){return new oe(e,c)}(c,u.geojsonVtOptions)}class ne{constructor(c){this.self=c,this.actor=new e.L(c),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,c)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=c},this.self.addProtocol=e.cK,this.self.removeProtocol=e.cL,this.self.registerRTLTextPlugin=c=>{e.d5.setMethods(c)},this.actor.registerMessageHandler("LDT",((e,c)=>this._getDEMWorkerSource(e,c.source).loadTile(c))),this.actor.registerMessageHandler("RDT",((c,u)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(c,u.source).removeTile(u)})))),this.actor.registerMessageHandler("GCEZ",((c,u)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(c,u.type,u.source).getClusterExpansionZoom(u)})))),this.actor.registerMessageHandler("GCC",((c,u)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(c,u.type,u.source).getClusterChildren(u)})))),this.actor.registerMessageHandler("GCL",((c,u)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(c,u.type,u.source).getClusterLeaves(u)})))),this.actor.registerMessageHandler("LD",((e,c)=>this._getWorkerSource(e,c.type,c.source).loadData(c))),this.actor.registerMessageHandler("GD",((e,c)=>this._getWorkerSource(e,c.type,c.source).getData())),this.actor.registerMessageHandler("LT",((e,c)=>this._getWorkerSource(e,c.type,c.source).loadTile(c))),this.actor.registerMessageHandler("RT",((e,c)=>this._getWorkerSource(e,c.type,c.source).reloadTile(c))),this.actor.registerMessageHandler("AT",((e,c)=>this._getWorkerSource(e,c.type,c.source).abortTile(c))),this.actor.registerMessageHandler("RMT",((e,c)=>this._getWorkerSource(e,c.type,c.source).removeTile(c))),this.actor.registerMessageHandler("RS",((c,u)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[c]||!this.workerSources[c][u.type]||!this.workerSources[c][u.type][u.source])return;const e=this.workerSources[c][u.type][u.source];delete this.workerSources[c][u.type][u.source],void 0!==e.removeSource&&e.removeSource(u)})))),this.actor.registerMessageHandler("RM",(c=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[c],delete this.availableImages[c],delete this.workerSources[c],delete this.demWorkerSources[c],this.globalStates.delete(c)})))),this.actor.registerMessageHandler("SR",((c,u)=>e._(this,void 0,void 0,(function*(){this.referrer=u})))),this.actor.registerMessageHandler("SRPS",((e,c)=>this._syncRTLPluginState(e,c))),this.actor.registerMessageHandler("IS",((c,u)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(u)})))),this.actor.registerMessageHandler("SI",((e,c)=>this._setImages(e,c))),this.actor.registerMessageHandler("UL",((c,u)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(c).update(u.layers,u.removedIds,this._getGlobalState(c))})))),this.actor.registerMessageHandler("UGS",((c,u)=>e._(this,void 0,void 0,(function*(){const e=this._getGlobalState(c);for(const c in u)e[c]=u[c]})))),this.actor.registerMessageHandler("SL",((c,u)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(c).replace(u,this._getGlobalState(c))}))))}_getGlobalState(e){let c=this.globalStates.get(e);return c||(c={},this.globalStates.set(e,c)),c}_setImages(c,u){return e._(this,void 0,void 0,(function*(){this.availableImages[c]=u;for(const e in this.workerSources[c]){const p=this.workerSources[c][e];for(const e in p)p[e].availableImages=u}}))}_syncRTLPluginState(c,u){return e._(this,void 0,void 0,(function*(){return yield e.d5.syncState(u,this.self.importScripts)}))}_getAvailableImages(e){let c=this.availableImages[e];return c||(c=[]),c}_getLayerIndex(e){let c=this.layerIndexes[e];return c||(c=this.layerIndexes[e]=new t),c}_getWorkerSource(e,c,u){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][c]||(this.workerSources[e][c]={}),!this.workerSources[e][c][u]){const p={sendAsync:(c,u)=>(c.targetMapId=e,this.actor.sendAsync(c,u))};switch(c){case"vector":this.workerSources[e][c][u]=new h(p,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][c][u]=new ie(p,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][c][u]=new this.externalWorkerSourceTypes[c](p,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][c][u]}_getDEMWorkerSource(e,c){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][c]||(this.demWorkerSources[e][c]=new d),this.demWorkerSources[e][c]}}return e.i(self)&&(self.worker=new ne(self)),ne}));p("index",["exports","./shared"],(function(c,u){var p="5.18.0";function f(){var e=new u.A(4);return u.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let m,g,y;const x={frame(e,c,p,f){const m=f||window,g=m.requestAnimationFrame((e=>{y(),c(e)})),{unsubscribe:y}=u.s(e.signal,"abort",(()=>{y(),m.cancelAnimationFrame(g),p(new u.a(e.signal.reason))}),!1)},frameAsync(e,c){return new Promise(((u,p)=>{this.frame(e,u,p,c)}))},getImageData(e,c=0){return this.getImageCanvasContext(e).getImageData(-c,-c,e.width+2*c,e.height+2*c)},getImageCanvasContext(e){const c=window.document.createElement("canvas"),u=c.getContext("2d",{willReadFrequently:!0});if(!u)throw new Error("failed to create canvas 2d context");return c.width=e.width,c.height=e.height,u.drawImage(e,0,0,e.width,e.height),u},resolveURL:e=>(m||(m=document.createElement("a")),m.href=e,m.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==y?y:!!matchMedia&&(null==g&&(g=matchMedia("(prefers-reduced-motion: reduce)")),g.matches)},set prefersReducedMotion(e){y=e}},b=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 T(){return b.getCurrentTime()}class h{static testProp(e){if(!h.docStyle)return e[0];for(let c=0;c{window.removeEventListener("click",h.suppressClickInternal,!0)}),0)}static getScale(e){const c=e.getBoundingClientRect();return{x:c.width/e.offsetWidth||1,y:c.height/e.offsetHeight||1,boundingClientRect:c}}static getPoint(e,c,p){const f=c.boundingClientRect;return new u.P((p.clientX-f.left)/c.x-e.clientLeft,(p.clientY-f.top)/c.y-e.clientTop)}static mousePos(e,c){const u=h.getScale(e);return h.getPoint(e,u,c)}static touchPos(e,c){const u=[],p=h.getScale(e);for(let f=0;f{P&&L(P),P=null,R=!0},I.onerror=()=>{C=!0,P=null},I.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(c){let p,f,m,g;c.resetRequestQueue=()=>{p=[],f=0,m=0,g={}},c.addThrottleControl=e=>{const c=m++;return g[c]=e,c},c.removeThrottleControl=e=>{delete g[e],x()},c.getImage=(e,c,f=!0)=>new Promise(((m,g)=>{S.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),u.e(e,{type:"image"}),p.push({abortController:c,requestParameters:e,supportImageRefresh:f,state:"queued",onError:e=>{g(e)},onSuccess:e=>{m(e)}}),x()}));const y=c=>u._(this||e,void 0,void 0,(function*(){c.state="running";const{requestParameters:e,supportImageRefresh:p,onError:m,onSuccess:g,abortController:y}=c,T=!1===p&&!u.i(self)&&!u.g(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((e,c)=>e&&"accept"===c),!0));f++;const S=T?b(e,y):u.m(e,y);try{const e=yield S;delete c.abortController,c.state="completed",e.data instanceof HTMLImageElement||u.b(e.data)?g(e):e.data&&g({data:yield(P=e.data,"function"==typeof createImageBitmap?u.f(P):u.h(P)),cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete c.abortController,m(e)}finally{f--,x()}var P})),x=()=>{const e=(()=>{for(const e of Object.keys(g))if(g[e]())return!0;return!1})()?u.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:u.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let c=f;c0;c++){const e=p.shift();e.abortController.signal.aborted?c--:y(e)}},b=(e,c)=>new Promise(((p,f)=>{const m=new Image,g=e.url,y=e.credentials;y&&"include"===y?m.crossOrigin="use-credentials":(y&&"same-origin"===y||!u.d(g))&&(m.crossOrigin="anonymous"),c.signal.addEventListener("abort",(()=>{m.src="",f(new u.a(c.signal.reason))})),m.fetchPriority="high",m.onload=()=>{m.onerror=m.onload=null,p({data:m})},m.onerror=()=>{m.onerror=m.onload=null,c.signal.aborted||f(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."))},m.src=g}))}(F||(F={})),F.resetRequestQueue();class v{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,c){return this._transformRequestFn&&this._transformRequestFn(e,c)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function B(e){const c=[];if("string"==typeof e)c.push({id:"default",url:e});else if(e&&e.length>0){const u=[];for(const{id:p,url:f}of e){const e=`${p}${f}`;-1===u.indexOf(e)&&(u.push(e),c.push({id:p,url:f}))}}return c}function O(e,c,u){try{const p=new URL(e);return p.pathname+=`${c}${u}`,p.toString()}catch(c){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function V(e){const{userImage:c}=e;return!!(c&&c.render&&c.render())&&(e.data.replace(new Uint8Array(c.data.buffer)),!0)}class w extends u.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new u.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 u.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:c}of this.requestors)c(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const c=this.images[e];if(c&&!c.data&&c.spriteData){const e=c.spriteData;c.data=new u.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),c.spriteData=null}return c}addImage(e,c){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,c)&&(this.images[e]=c)}_validate(e,c){let p=!0;const f=c.data||c.spriteData;return this._validateStretch(c.stretchX,f&&f.width)||(this.fire(new u.k(new Error(`Image "${e}" has invalid "stretchX" value`))),p=!1),this._validateStretch(c.stretchY,f&&f.height)||(this.fire(new u.k(new Error(`Image "${e}" has invalid "stretchY" value`))),p=!1),this._validateContent(c.content,c)||(this.fire(new u.k(new Error(`Image "${e}" has invalid "content" value`))),p=!1),p}_validateStretch(e,c){if(!e)return!0;let u=0;for(const p of e){if(p[0]{let p=!0;if(!this.isLoaded())for(const c of e)this.images[c]||(p=!1);this.isLoaded()||p?c(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:c})}))}_getImagesForIds(e){const c={};for(const p of e){let e=this.getImage(p);e||(this.fire(new u.l("styleimagemissing",{id:p})),e=this.getImage(p)),e?c[p]={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)}:u.w(`Image "${p}" 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 c}getPixelSize(){const{width:e,height:c}=this.atlasImage;return{width:e,height:c}}getPattern(e){const c=this.patterns[e],p=this.getImage(e);if(!p)return null;if(c&&c.position.version===p.version)return c.position;if(c)c.position.version=p.version;else{const c={w:p.data.width+2,h:p.data.height+2,x:0,y:0},f=new u.I(c,p);this.patterns[e]={bin:c,position:f}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const c=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new u.T(e,this.atlasImage,c.RGBA),this.atlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const c in this.patterns)e.push(this.patterns[c].bin);const{w:c,h:p}=u.p(e),f=this.atlasImage;f.resize({width:c||1,height:p||1});for(const e in this.patterns){const{bin:c}=this.patterns[e],p=c.x+1,m=c.y+1,g=this.getImage(e).data,y=g.width,x=g.height;u.R.copy(g,f,{x:0,y:0},{x:p,y:m},{width:y,height:x}),u.R.copy(g,f,{x:0,y:x-1},{x:p,y:m-1},{width:y,height:1}),u.R.copy(g,f,{x:0,y:0},{x:p,y:m+x},{width:y,height:1}),u.R.copy(g,f,{x:y-1,y:0},{x:p-1,y:m},{width:1,height:x}),u.R.copy(g,f,{x:0,y:0},{x:p+y,y:m},{width:1,height:x})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const c of e){if(this.callbackDispatchedThisFrame[c])continue;this.callbackDispatchedThisFrame[c]=!0;const e=this.getImage(c);e||u.w(`Image with ID: "${c}" was not found`),V(e)&&this.updateImage(c,e)}}cloneImages(){const e={};for(const c in this.images){const u=this.images[c];e[c]=Object.assign(Object.assign({},u),{data:u.data?u.data.clone():null})}return e}}const j=1e20;function G(e,c,u,p,f,m,g,y,x){for(let b=c;b-1);x++,m[x]=y,g[x]=b,g[x+1]=j}for(let y=0,x=0;y/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`)).join(",");return new M.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:u,fontWeight:this._fontWeight(c[0]),fontStyle:this._fontStyle(c[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const c={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 u;for(const[p,f]of Object.entries(c))new RegExp(`\\b${p}\\b`,"i").test(e)&&(u=`${f}`);return u}destroy(){for(const e in this.entries){const c=this.entries[e];c.tinySDF&&(c.tinySDF=null),c.ideographTinySDF&&(c.ideographTinySDF=null),c.glyphs={},c.requests={},c.ranges={}}this.entries={}}}M.loadGlyphRange=function(c,p,f,m){return u._(this||e,void 0,void 0,(function*(){const e=256*p,g=e+255,y=m.transformRequest(f.replace("{fontstack}",c).replace("{range}",`${e}-${g}`),"Glyphs"),x=yield u.n(y,new AbortController);if(!x||!x.data)throw new Error(`Could not load glyph range. range: ${p}, ${e}-${g}`);const b={};for(const e of u.o(x.data))b[e.id]=e;return b}))},M.TinySDF=class{constructor({fontSize:e=24,buffer:c=3,radius:u=8,cutoff:p=.25,fontFamily:f="sans-serif",fontWeight:m="normal",fontStyle:g="normal",lang:y=null}={}){this.buffer=c,this.cutoff=p,this.radius=u,this.lang=y;const x=this.size=e+4*c,b=this._createCanvas(x),T=this.ctx=b.getContext("2d",{willReadFrequently:!0});T.font=`${g} ${m} ${e}px ${f}`,T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(x*x),this.gridInner=new Float64Array(x*x),this.f=new Float64Array(x),this.z=new Float64Array(x+1),this.v=new Uint16Array(x)}_createCanvas(e){const c=document.createElement("canvas");return c.width=c.height=e,c}draw(e){const{width:c,actualBoundingBoxAscent:u,actualBoundingBoxDescent:p,actualBoundingBoxLeft:f,actualBoundingBoxRight:m}=this.ctx.measureText(e),g=Math.ceil(u),y=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(m-f))),x=Math.min(this.size-this.buffer,g+Math.ceil(p)),b=y+2*this.buffer,T=x+2*this.buffer,S=Math.max(b*T,0),P=new Uint8ClampedArray(S),I={data:P,width:b,height:T,glyphWidth:y,glyphHeight:x,glyphTop:g,glyphLeft:0,glyphAdvance:c};if(0===y||0===x)return I;const{ctx:C,buffer:R,gridInner:L,gridOuter:F}=this;this.lang&&(C.lang=this.lang),C.clearRect(R,R,y,x),C.fillText(e,R,R+g);const B=C.getImageData(R,R,y,x);F.fill(j,0,S),L.fill(0,0,S);for(let e=0;e0?e*e:0,L[p]=e<0?e*e:0}}G(F,0,0,b,T,b,this.f,this.v,this.z),G(L,R,R,y,x,b,this.f,this.v,this.z);for(let e=0;e1&&(g=e[++m]);const x=Math.abs(y-g.left),b=Math.abs(y-g.right),T=Math.min(x,b);let S;const P=c/u*(p+1);if(g.isDash){const e=p-Math.abs(P);S=Math.sqrt(T*T+e*e)}else S=p-Math.sqrt(T*T+P*P);this.data[f+y]=Math.max(0,Math.min(255,S+128))}}}addRegularDash(e){for(let c=e.length-1;c>=0;--c){const u=e[c],p=e[c+1];u.zeroLength?e.splice(c,1):p&&p.isDash===u.isDash&&(p.left=u.left,e.splice(c,1))}const c=e[0],u=e[e.length-1];c.isDash===u.isDash&&(c.left=u.left-this.width,u.right=c.right+this.width);const p=this.width*this.nextRow;let f=0,m=e[f];for(let c=0;c1&&(m=e[++f]);const u=Math.abs(c-m.left),g=Math.abs(c-m.right),y=Math.min(u,g);this.data[p+c]=Math.max(0,Math.min(255,(m.isDash?y:-y)+128))}}addDash(e,c){const p=c?7:0,f=2*p+1;if(this.nextRow+f>this.height)return u.w("LineAtlas out of space"),null;let m=0;for(let c=0;c{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Q]}numActive(){return Object.keys(this.active).length}}const J=Math.floor(x.hardwareConcurrency/2);let re,se;function le(){return re||(re=new k),re}k.workerCount=u.K(globalThis)?Math.max(Math.min(J,3),1):1;class N{constructor(e,c){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=c;const p=this.workerPool.acquire(c);for(let e=0;e{e.remove()})),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,c){for(const u of this.actors)u.registerMessageHandler(e,c)}unregisterMessageHandler(e){for(const c of this.actors)c.unregisterMessageHandler(e)}}function ce(){return se||(se=new N(le(),u.M),se.registerMessageHandler("GR",((e,c,p)=>u.m(c,p)))),se}function he(e,c){const p=u.N();return u.O(p,p,[1,1,0]),u.Q(p,p,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?u.S(p,p,e.calculatePosMatrix(c.toUnwrapped())):p}function ue(e,c,u,p,f,m,g){var y;const x=function(e,c,u){if(e)for(const p of e){const e=c[p];if(e&&e.source===u&&"fill-extrusion"===e.type)return!0}else for(const e in c){const p=c[e];if(p.source===u&&"fill-extrusion"===p.type)return!0}return!1}(null!==(y=null==f?void 0:f.layers)&&void 0!==y?y:null,c,e.id),b=m.maxPitchScaleFactor(),T=e.tilesIn(p,b,x);T.sort(pe);const S=[];for(const p of T)S.push({wrappedTileID:p.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(c,u,e.getState(),p.queryGeometry,p.cameraQueryGeometry,p.scale,f,m,b,he(m,p.tileID),g?(e,c)=>g(p.tileID,e,c):void 0)});return function(e,c){for(const u in e)for(const p of e[u])fe(p,c);return e}(function(e){const c={},u={};for(const p of e){const e=p.queryResults,f=p.wrappedTileID,m=u[f]=u[f]||{};for(const u in e){const p=e[u],f=m[u]=m[u]||{},g=c[u]=c[u]||[];for(const e of p)f[e.featureIndex]||(f[e.featureIndex]=!0,g.push(e))}}return c}(S),e)}function pe(e,c){const u=e.tileID,p=c.tileID;return u.overscaledZ-p.overscaledZ||u.canonical.y-p.canonical.y||u.wrap-p.wrap||u.canonical.x-p.canonical.x}function fe(e,c){const u=e.feature,p=c.getFeatureState(u.layer["source-layer"],u.id);u.source=u.layer.source,u.layer["source-layer"]&&(u.sourceLayer=u.layer["source-layer"]),u.state=p}function me(c,p,f,m){return u._(this||e,void 0,void 0,(function*(){let e=c;if(c.url?e=(yield u.j(p.transformRequest(c.url,"Source"),f)).data:yield x.frameAsync(f,m),!e)return null;const g=u.U(u.e(e,c),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in e&&e.vector_layers&&(g.vectorLayerIds=e.vector_layers.map((e=>e.id))),g}))}class ${constructor(e,c){e&&(c?this.setSouthWest(e).setNorthEast(c):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 u.V?new u.V(e.lng,e.lat):u.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof u.V?new u.V(e.lng,e.lat):u.V.convert(e),this}extend(e){const c=this._sw,p=this._ne;let f,m;if(e instanceof u.V)f=e,m=e;else{if(!(e instanceof $))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend($.convert(e)):this.extend(u.V.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(u.V.convert(e)):this;if(f=e._sw,m=e._ne,!f||!m)return this}return c||p?(c.lng=Math.min(f.lng,c.lng),c.lat=Math.min(f.lat,c.lat),p.lng=Math.max(m.lng,p.lng),p.lat=Math.max(m.lat,p.lat)):(this._sw=new u.V(f.lng,f.lat),this._ne=new u.V(m.lng,m.lat)),this}getCenter(){return new u.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 u.V(this.getWest(),this.getNorth())}getSouthEast(){return new u.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:c,lat:p}=u.V.convert(e);let f=this._sw.lng<=c&&c<=this._ne.lng;return this._sw.lng>this._ne.lng&&(f=this._sw.lng>=c&&c>=this._ne.lng),this._sw.lat<=p&&p<=this._ne.lat&&f}intersects(e){if(!((e=$.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;const c=Math.abs(this.getEast()-this.getWest()),p=Math.abs(e.getEast()-e.getWest());if(c>=360||p>=360)return!0;const f=u.W(this.getWest(),-180,180),m=u.W(this.getEast(),-180,180),g=u.W(e.getWest(),-180,180),y=u.W(e.getEast(),-180,180),x=f>m,b=g>y;return!(!x||!b)||(x?y>=f||g<=m:b?m>=g||f<=y:g<=m&&y>=f)}static convert(e){return e instanceof $?e:e?new $(e):e}static fromLngLat(e,c=0){const p=360*c/40075017,f=p/Math.cos(Math.PI/180*e.lat);return new $(new u.V(e.lng-f,e.lat-p),new u.V(e.lng+f,e.lat+p))}adjustAntiMeridian(){const e=new u.V(this._sw.lng,this._sw.lat),c=new u.V(this._ne.lng,this._ne.lat);return new $(e,e.lng>c.lng?new u.V(c.lng+360,c.lat):c)}}class H{constructor(e,c,u){this.bounds=$.convert(this.validateBounds(e)),this.minzoom=c||0,this.maxzoom=u||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 c=Math.pow(2,e.z),p=Math.floor(u.Y(this.bounds.getWest())*c),f=Math.floor(u.X(this.bounds.getNorth())*c),m=Math.ceil(u.Y(this.bounds.getEast())*c),g=Math.ceil(u.X(this.bounds.getSouth())*c);return e.x>=p&&e.x=f&&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 u.e({},this._options)}loadTile(e){return u._(this,void 0,void 0,(function*(){const c=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),u={request:this.map._requestManager.transformRequest(c,"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)};u.request.collectResourceTiming=this._collectResourceTiming;let p="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((c,u)=>{e.reloadPromise={resolve:c,reject:u}}))}else e.actor=this.dispatcher.getActor(),p="LT";e.abortController=new AbortController;try{const c=yield e.actor.sendAsync({type:p,data:u},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,c)}catch(c){if(delete e.abortController,e.aborted)return;if(c&&404!==c.status)throw c;this._afterTileLoadWorkerResponse(e,null)}}))}_getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const c=e.tileID.scaledTo(this.maxzoom).canonical,u=c.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:c,overzoomRequest:this.map._requestManager.transformRequest(u,"Tile")}}_afterTileLoadWorkerResponse(e,c){if(c&&c.resourceTiming&&(e.resourceTiming=c.resourceTiming),c&&this.map._refreshExpiredTiles&&e.setExpiryData(c),e.loadVectorData(c,this.map.painter),e.reloadPromise){const c=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(c.resolve).catch(c.reject)}}abortTile(e){return u._(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 u._(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 u.E{constructor(e,c,p,f){super(),this.id=e,this.dispatcher=p,this.setEventedParent(f),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=u.e({type:"raster"},c),u.e(this,u.U(c,["url","scheme","tileSize"]))}load(){return u._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new u.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const c=yield me(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,c&&(u.e(this,c),c.bounds&&(this.tileBounds=new H(c.bounds,this.minzoom,this.maxzoom)),this.fire(new u.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new u.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,u.Z(e)||this.fire(new u.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 u.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return u._(this,void 0,void 0,(function*(){const c=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const p=yield F.getImage(this.map._requestManager.transformRequest(c,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(p&&p.data){this.map._refreshExpiredTiles&&(p.cacheControl||p.expires)&&e.setExpiryData({cacheControl:p.cacheControl,expires:p.expires});const c=this.map.painter.context,f=c.gl,m=p.data;e.texture=this.map.painter.getTileTexture(m.width),e.texture?e.texture.update(m,{useMipmap:!0}):(e.texture=new u.T(c,m,f.RGBA,{useMipmap:!0}),e.texture.bind(f.LINEAR,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(c){if(delete e.abortController,e.aborted)e.state="unloaded";else if(c)throw e.state="errored",c}}))}abortTile(e){return u._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return u._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class Y extends K{constructor(e,c,p,f){super(e,c,p,f),this.type="raster-dem",this.maxzoom=22,this._options=u.e({type:"raster-dem"},c),this.encoding=c.encoding||"mapbox",this.redFactor=c.redFactor,this.greenFactor=c.greenFactor,this.blueFactor=c.blueFactor,this.baseShift=c.baseShift}loadTile(e){return u._(this,void 0,void 0,(function*(){const c=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),p=this.map._requestManager.transformRequest(c,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const c=yield F.getImage(p,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(c&&c.data){const p=c.data;this.map._refreshExpiredTiles&&(c.cacheControl||c.expires)&&e.setExpiryData({cacheControl:c.cacheControl,expires:c.expires});const f=u.b(p)&&u.$()?p:yield this.readImageNow(p),m={type:this.type,uid:e.uid,source:this.id,rawImageData:f,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 c=yield e.actor.sendAsync({type:"LDT",data:m});e.dem=c,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(c){if(delete e.abortController,e.aborted)e.state="unloaded";else if(c)throw e.state="errored",c}}))}readImageNow(e){return u._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&u.a0()){const c=e.width+2,p=e.height+2;try{return new u.R({width:c,height:p},yield u.a1(e,-1,-1,c,p))}catch(e){}}return x.getImageData(e,1)}))}_getNeighboringTiles(e){const c=e.canonical,p=Math.pow(2,c.z),f=(c.x-1+p)%p,m=0===c.x?e.wrap-1:e.wrap,g=(c.x+1+p)%p,y=c.x+1===p?e.wrap+1:e.wrap,x={};return x[new u.a2(e.overscaledZ,m,c.z,f,c.y).key]={backfilled:!1},x[new u.a2(e.overscaledZ,y,c.z,g,c.y).key]={backfilled:!1},c.y>0&&(x[new u.a2(e.overscaledZ,m,c.z,f,c.y-1).key]={backfilled:!1},x[new u.a2(e.overscaledZ,e.wrap,c.z,c.x,c.y-1).key]={backfilled:!1},x[new u.a2(e.overscaledZ,y,c.z,g,c.y-1).key]={backfilled:!1}),c.y+1e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}function ye(e){const c=new $;let u;switch(e.type){case"FeatureCollection":u=e.features.map((e=>ge(e.geometry))).flat(1/0);break;case"Feature":u=ge(e.geometry);break;default:u=ge(e)}if(0==u.length)return c;for(let e=0;eye(e)))}}shouldReloadTile(e,{affectedBounds:c}){if("loading"===e.state)return!0;if("unloaded"===e.state)return!1;const{buffer:p,extent:f}=this.workerOptions.geojsonVtOptions,m=function({x:e,y:c,z:p},f=0){const m=u.a3((e-f)/Math.pow(2,p)),g=u.a4((c+1+f)/Math.pow(2,p)),y=u.a3((e+1+f)/Math.pow(2,p)),x=u.a4((c-f)/Math.pow(2,p));return new $([m,g],[y,x])}(e.tileID.canonical,p/f);for(const e of c)if(m.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return u._(this,void 0,void 0,(function*(){const c=e.actor?"RT":"LT";e.actor=this.actor;const u={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 p=yield this.actor.sendAsync({type:c,data:u},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(p,this.map.painter,"RT"===c)}))}abortTile(e){return u._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return u._(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 u.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 u.E{constructor(e,c,u,p){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=u,this.coordinates=c.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(p),this.options=c}load(e){return u._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new u.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const c=yield F.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,c&&c.data&&(this.image=c.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,u.Z(e)||this.fire(new u.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 u.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 c=e.map(u.a9.fromLngLat);var p;return this.tileID=function(e){const c=u.aa.fromPoints(e),p=c.width(),f=c.height(),m=Math.max(p,f),g=Math.max(0,Math.floor(-Math.log(m)/Math.LN2)),y=Math.pow(2,g);return new u.ac(g,Math.floor((c.minX+c.maxX)/2*y),Math.floor((c.minY+c.maxY)/2*y))}(c),this.terrainTileRanges=this._getOverlappingTileRanges(c),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=c.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((p=this.tileCoords)[1].x-p[0].x)*(p[2].y-p[0].y)-(p[1].y-p[0].y)*(p[2].x-p[0].x)<0,this.fire(new u.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,c=e.gl;this.texture||(this.texture=new u.T(e,this.image,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE));let p=!1;for(const e in this.tiles){const c=this.tiles[e];"loaded"!==c.state&&(c.state="loaded",c.texture=this.texture,p=!0)}p&&this.fire(new u.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return u._(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:c,minY:p,maxX:f,maxY:m}=u.aa.fromPoints(e),g={};for(let e=0;e<=u.ab;e++){const u=Math.pow(2,e),y=Math.floor(c*u),x=Math.floor(p*u),b=Math.floor(f*u),T=Math.floor(m*u),S=(y%u+u)%u,P=b%u,I=Math.floor(y/u),C=Math.floor(b/u);g[e]={minWrap:I,maxWrap:C,minTileXWrapped:S,maxTileXWrapped:P,minTileY:x,maxTileY:T}}return g}}class ie extends te{constructor(e,c,u,p){super(e,c,u,p),this.roundZoom=!0,this.type="video",this.options=c}load(){return u._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const c of e.urls)this.urls.push(this.map._requestManager.transformRequest(c,"Source").url);try{const e=yield u.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 u.k(e))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const c=this.video.seekable;ec.end(0)?this.fire(new u.k(new u.ae(`sources.${this.id}`,null,`Playback for this video can be set only between the ${c.start(0)} and ${c.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,c=e.gl;this.texture?this.video.paused||(this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE),c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,this.video)):(this.texture=new u.T(e,this.video,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE));let p=!1;for(const e in this.tiles){const c=this.tiles[e];"loaded"!==c.state&&(c.state="loaded",c.texture=this.texture,p=!0)}p&&this.fire(new u.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,c,p,f){super(e,c,p,f),c.coordinates?Array.isArray(c.coordinates)&&4===c.coordinates.length&&!c.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new u.k(new u.ae(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new u.k(new u.ae(`sources.${e}`,null,'missing required property "coordinates"'))),c.animate&&"boolean"!=typeof c.animate&&this.fire(new u.k(new u.ae(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),c.canvas?"string"==typeof c.canvas||c.canvas instanceof HTMLCanvasElement||this.fire(new u.k(new u.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 u.k(new u.ae(`sources.${e}`,null,'missing required property "canvas"'))),this.options=c,this.animate=void 0===c.animate||c.animate}load(){return u._(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 u.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 c=this.map.painter.context,p=c.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new u.T(c,this.canvas,p.RGBA,{premultiply:!0}),this.texture.bind(p.LINEAR,p.CLAMP_TO_EDGE));let f=!1;for(const e in this.tiles){const c=this.tiles[e];"loaded"!==c.state&&(c.state="loaded",c.texture=this.texture,f=!0)}f&&this.fire(new u.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 xe={},ve=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 xe[e]},be="RTLPluginLoaded";class ne extends u.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=ce()}_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 u._(this,arguments,void 0,(function*(e,c=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=x.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!c)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return u._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new u.l(be))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let we=null;function Se(){return we||(we=new ne),we}var Me,Ee;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(Me||(Me={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(Ee||(Ee={}));class de{constructor(e,c){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=u.af(),this.uses=0,this.tileSize=c,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:c,fadingParentID:u,fadeEndTime:p}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=c,this.fadingParentID=u,this.fadeEndTime=p}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=T(),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,c,p){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,c){const u={};if(!c)return u;for(const p of e){const e=p.layerIds.map((e=>c.getLayer(e))).filter(Boolean);if(0!==e.length){p.layers=e,p.stateDependentLayerIds&&(p.stateDependentLayers=p.stateDependentLayerIds.map((c=>e.filter((e=>e.id===c))[0])));for(const c of e)u[c.id]=p}}return u}(e.buckets,null==c?void 0:c.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const c=this.buckets[e];if(c instanceof u.ah){if(this.hasSymbolBuckets=!0,!p)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const c=this.buckets[e];if(c instanceof u.ah&&c.hasRTLText){this.hasRTLText=!0,Se().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const u=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,c.style.getLayer(e).queryRadius(u))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new u.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 c in this.buckets){const u=this.buckets[c];u.uploadPending()&&u.upload(e)}const c=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new u.T(e,this.imageAtlas.image,c.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new u.T(e,this.glyphAtlasImage,c.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,c,u,p,f,m,g,y,x,b,T){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:p,cameraQueryGeometry:f,scale:m,tileSize:this.tileSize,pixelPosMatrix:b,transform:y,params:g,queryPadding:this.queryPadding*x,getElevation:T},e,c,u):{}}querySourceFeatures(e,c){const p=this.latestFeatureIndex;if(!p||!p.rawTileData)return;const f=p.loadVTLayers(),m=c&&c.sourceLayer?c.sourceLayer:"",g=f[u.ai]||f[m];if(!g)return;const y=u.aj(null==c?void 0:c.filter,null==c?void 0:c.globalState),{z:x,x:b,y:T}=this.tileID.canonical,S={z:x,x:b,y:T};for(let c=0;ce)u=!1;else if(c)if(this.expirationTime({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),V=[],j=[];if(e.renderWorldCopies&&y.allowWorldCopies())for(let e=1;e<=3;e++)V.push(O(-e)),V.push(O(e));for(V.push(O(0));V.length>0;){const I=V.pop(),L=I.x,O=I.y;let G=I.fullyVisible;const U={x:L,y:O,z:I.zoom},q=y.getTileBoundingVolume(U,I.wrap,e.elevation,c);if(!G){const e=He(p,q,f);if(0===e)continue;G=2===e}const Z=y.distanceToTile2d(m.x,m.y,U,q);let W=b;x&&(W=(c.calculateTileZoom||tt)(e.zoom+u.at(e.tileSize/c.tileSize),Z,F,B,e.fov)),W=(c.roundZoom?Math.round:Math.floor)(W),W=Math.max(0,W);const Q=Math.min(W,S);if(I.wrap=y.getWrap(g,U,I.wrap),I.zoom>=Q){if(I.zoom>1),wrap:I.wrap,fullyVisible:G})}return j.sort(((e,c)=>e.distanceSq-c.distanceSq)).map((e=>e.tileID))}const ot=u.aa.fromPoints([new u.P(0,0),new u.P(u.a5,u.a5)]);function at(e){return"raster"===e||"image"===e||"video"===e}function ft(e,c,u,p,f,m,g){if(!c.hasData())return!1;const{tileID:y,fadingRole:x,fadingDirection:b,fadingParentID:T}=c;if(x===Me.Base&&b===Ee.Incoming&&T)return u[T.key]=T,!0;const S=Math.max(y.overscaledZ-f,m);for(let f=y.overscaledZ-1;f>=S;f--){const m=y.scaledTo(f),x=e.getLoadedTile(m);if(x)return c.setCrossFadeLogic({fadingRole:Me.Base,fadingDirection:Ee.Incoming,fadingParentID:x.tileID,fadeEndTime:p+g}),x.setCrossFadeLogic({fadingRole:Me.Parent,fadingDirection:Ee.Departing,fadeEndTime:p+g}),u[m.key]=m,!0}return!1}function _t(e,c,u,p,f,m){if(!c.hasData())return!1;const g=c.tileID.children(f);let y=yt(e,c,g,u,p,f,m);if(y)return!0;for(const x of g)yt(e,c,x.children(f),u,p,f,m)&&(y=!0);return y}function yt(e,c,u,p,f,m,g){if(u[0].overscaledZ>=m)return!1;let y=!1;for(const m of u){const u=e.getLoadedTile(m);if(!u)continue;const{fadingRole:x,fadingDirection:b,fadingParentID:T}=u;x===Me.Base&&b===Ee.Departing&&T||(u.setCrossFadeLogic({fadingRole:Me.Base,fadingDirection:Ee.Departing,fadingParentID:c.tileID,fadeEndTime:f+g}),c.setCrossFadeLogic({fadingRole:Me.Parent,fadingDirection:Ee.Incoming,fadeEndTime:f+g})),p[m.key]=m,y=!0}return y}function vt(e,c,u,p){const f=e.tileID;return!!e.selfFading||!e.hasData()&&!!c.has(f)&&(e.setSelfFadeLogic(u+p),!0)}function bt(e,c){var u;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let p=c.tileID.canonical.x-e.tileID.canonical.x;const f=c.tileID.canonical.y-e.tileID.canonical.y,m=Math.pow(2,e.tileID.canonical.z),g=c.tileID.key;0===p&&0===f||Math.abs(f)>1||(Math.abs(p)>1&&(1===Math.abs(p+m)?p+=m:1===Math.abs(p-m)&&(p-=m)),c.dem&&e.dem&&(e.dem.backfillBorder(c.dem,p,f),(null===(u=e.neighboringTiles)||void 0===u?void 0:u[g])&&(e.neighboringTiles[g].backfilled=!0)))}class Le{constructor(){this._tiles={}}handleWrapJump(e){const c={};for(const u in this._tiles){const p=this._tiles[u];p.tileID=p.tileID.unwrapTo(p.tileID.wrap+e),c[p.tileID.key]=p}this._tiles=c}setFeatureState(e,c){for(const u in this._tiles)this._tiles[u].setFeatureState(e,c)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map((e=>e.tileID)).sort(u.aw).map((e=>e.key)):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,c){this._tiles[e]=c}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){const c=this.getTileById(e.key);return(null==c?void 0:c.hasData())?c:null}isIdRenderable(e,c=!1){var u;return null===(u=this.getTileById(e))||void 0===u?void 0:u.isRenderable(c)}getRenderableIds(e=0,c){const p=[];for(const e of this.getAllIds())this.isIdRenderable(e,c)&&p.push(this.getTileById(e));return c?p.sort(((c,p)=>{const f=c.tileID,m=p.tileID,g=new u.P(f.canonical.x,f.canonical.y)._rotate(-e),y=new u.P(m.canonical.x,m.canonical.y)._rotate(-e);return f.overscaledZ-m.overscaledZ||y.y-g.y||y.x-g.x})).map((e=>e.tileID.key)):p.map((e=>e.tileID)).sort(u.aw).map((e=>e.key))}}class ke extends u.E{constructor(e,c,p){super(),this.id=e,this.dispatcher=p,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((e,c,u,p)=>{const f=new(ve(c.type))(e,c,u,p);if(f.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${f.id}`);return f})(e,c,p,this),this._inViewTiles=new Le,this._outOfViewCache=new u.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,c,p){return u._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,c,p)}catch(c){e.state="errored",404!==c.status?this._source.fire(new u.k(c,{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 u.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 c of this._inViewTiles.getAllTiles())c.upload(e),c.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){var c;return this._inViewTiles.getRenderableIds(null===(c=this.transform)||void 0===c?void 0:c.bearingInRadians,e)}hasRenderableParent(e){const c=e.overscaledZ-1;if(c>=this._source.minzoom){const u=this.getLoadedTile(e.scaledTo(c));if(u)return this._inViewTiles.isIdRenderable(u.tileID.key)}return!1}reload(e,c=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const u of this._inViewTiles.getAllIds()){const p=this._inViewTiles.getTileById(u);c&&!this._source.shouldReloadTile(p,c)||(e?this._reloadTile(u,"expired"):"errored"!==p.state&&this._reloadTile(u,"reloading"))}}}_reloadTile(e,c){return u._(this,void 0,void 0,(function*(){const u=this._inViewTiles.getTileById(e);u&&("loading"!==u.state&&(u.state=c),yield this._loadTile(u,e,c))}))}_tileLoaded(e,c,p){e.timeAdded=T(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===p&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(c,e),"raster-dem"===this.getSource().type&&e.dem&&function(e,c){var u,p;const f=c.getRenderableIds();for(const m of f){if(!e.neighboringTiles||!e.neighboringTiles[m])continue;const f=c.getTileById(m);e.neighboringTiles[m].backfilled||bt(e,f),(null===(p=null===(u=f.neighboringTiles)||void 0===u?void 0:u[e.tileID.key])||void 0===p?void 0:p.backfilled)||bt(f,e)}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new u.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,c){const u=this._getLoadedDescendents(c),p=new Set;for(const f of c){const c=u[f.key];if(!(null==c?void 0:c.length)){p.add(f);continue}const m=f.overscaledZ+ke.maxOverzooming,g=c.filter((e=>e.tileID.overscaledZ<=m));if(!g.length){p.add(f);continue}const y=Math.min(...g.map((e=>e.tileID.overscaledZ))),x=g.filter((e=>e.tileID.overscaledZ===y)).map((e=>e.tileID));for(const c of x)e[c.key]=c;this._areDescendentsComplete(x,y,f.overscaledZ)||p.add(f)}return p}_getLoadedDescendents(e){var c;const u={};for(const p of this._inViewTiles.getAllTiles().filter((e=>e.hasData())))for(const f of e)p.tileID.isChildOf(f)&&(u[c=f.key]||(u[c]=[])).push(p);return u}_areDescendentsComplete(e,c,u){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===c:Math.pow(4,c-u)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){const c=Math.ceil(e.width/this._source.tileSize)+1,p=Math.ceil(e.height/this._source.tileSize)+1,f=Math.floor(c*p*(null===this._maxTileCacheZoomLevels?u.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),m="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,f):f;this._outOfViewCache.setMaxSize(m)}handleWrapJump(e){const c=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);this._prevLng=e,c&&(this._inViewTiles.handleWrapJump(c),this._resetTileReloadTimers())}update(e,c){if(!this._sourceLoaded||this._paused)return;let p;this.transform=e,this.terrain=c,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?p=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new u.a2(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(p=rt(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:c,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(p=p.filter((e=>this._source.hasTile(e))))):p=[],this.usedForTerrain&&(p=this._addTerrainIdealTiles(p));const f=0===p.length&&!this._updated&&this._didEmitContent;this._updated=!0,f&&this.fire(new u.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const m=it(e,this._source),g=this._updateRetainedTiles(p,m),y=at(this._source.type);y&&this._rasterFadeDuration>0&&!c&&function(e,c,p,f,m,g,y){const x=T(),b=u.av(c);for(const u of c){const c=e.getTileById(u.key);c.fadingDirection!==Ee.Departing&&0!==c.fadeOpacity||c.resetFadeLogic(),ft(e,c,p,x,f,m,y)||_t(e,c,p,x,g,y)||vt(c,b,x,y)||c.resetFadeLogic()}}(this._inViewTiles,p,g,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),y?this._cleanUpRasterTiles(g):this._cleanUpVectorTiles(g)}_cleanUpRasterTiles(e){for(const c of this._inViewTiles.getAllIds())e[c]||this._removeTile(c)}_cleanUpVectorTiles(e){for(const c of this._inViewTiles.getAllIds()){const u=this._inViewTiles.getTileById(c);e[c]?u.clearSymbolFadeHold():u.hasSymbolBuckets?u.holdingForSymbolFade()?u.symbolFadeFinished()&&this._removeTile(c):u.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(c)}}_addTerrainIdealTiles(e){const c=[];for(const u of e)if(u.canonical.z>this._source.minzoom){const e=u.scaledTo(u.canonical.z-1);c.push(e);const p=u.scaledTo(Math.max(this._source.minzoom,Math.min(u.canonical.z,5)));c.push(p)}return e.concat(c)}releaseSymbolFadeTiles(){for(const e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,c){var u;const p=new Set;for(const c of e)this._addTile(c).hasData()||p.add(c);const f=e.reduce(((e,c)=>(e[c.key]=c,e)),{}),m=this._retainLoadedChildren(f,p),g={},y=Math.max(c-ke.maxUnderzooming,this._source.minzoom);for(const e of m){let c=this._inViewTiles.getTileById(e.key),p=null==c?void 0:c.wasRequested();for(let m=e.overscaledZ-1;m>=y;--m){const y=e.scaledTo(m);if(g[y.key])break;if(g[y.key]=!0,c=this.getTile(y),!c&&p&&(c=this._addTile(y)),c){const e=c.hasData();if((e||!(null===(u=this.map)||void 0===u?void 0:u.cancelPendingTileRequestsWhileZooming)||p)&&(f[y.key]=y),p=c.wasRequested(),e)break}}}return f}_addTile(e){let c=this._inViewTiles.getTileById(e.key);if(c)return c;c=this._outOfViewCache.getAndRemove(e),c&&(c.resetFadeLogic(),this._setTileReloadTimer(e.key,c),c.tileID=e,this._state.initializeTileState(c,this.map?this.map.painter:null));const p=c;return c||(c=new de(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(c,e.key,c.state)),c.uses++,this._inViewTiles.setTile(e.key,c),p||this._source.fire(new u.l("dataloading",{tile:c,coord:c.tileID,dataType:"source"})),c}_setTileReloadTimer(e,c){this._clearTileReloadTimer(e);const u=c.getExpiryTimeout();u&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),u))}_clearTileReloadTimer(e){const c=this._timers[e];c&&(clearTimeout(c),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 c=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,c)}}refreshTiles(e){for(const c of this._inViewTiles.getAllIds()){const u=this._inViewTiles.getTileById(c);(this._inViewTiles.isIdRenderable(c)||"errored"==u.state)&&e.some((e=>e.equals(u.tileID.canonical)))&&this._reloadTile(c,"expired")}}_removeTile(e){const c=this._inViewTiles.getTileById(e);c&&(c.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),c.uses>0||(c.hasData()&&"reloading"!==c.state?this._outOfViewCache.add(c.tileID,c,c.getExpiryTimeout()):(c.aborted=!0,this._abortTile(c),this._unloadTile(c))))}_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,c,p){const f=[],m=this.transform;if(!m)return f;const g=m.getCoveringTilesDetailsProvider().allowWorldCopies(),y=p?m.getCameraQueryGeometry(e):e,x=e=>m.screenPointToMercatorCoordinate(e,this.terrain),b=this.transformBbox(e,x,!g),T=this.transformBbox(y,x,!g),S=this.getIds(),P=u.aa.fromPoints(T);for(let e=0;ee.getTilePoint(new u.a9(c.x,c.y))));if(c.expandBy(I),c.intersects(ot)){const c=b.map((c=>e.getTilePoint(c))),u=T.map((c=>e.getTilePoint(c)));f.push({tile:p,tileID:g?e:e.unwrapTo(0),queryGeometry:c,cameraQueryGeometry:u,scale:x})}}}return f}transformBbox(e,c,p){let f=e.map(c);if(p){const p=u.aa.fromPoints(e);p.shrinkBy(.001*Math.min(p.width(),p.height()));const m=p.map(c);u.aa.fromPoints(f).covers(m)||(f=f.map((e=>e.x>.5?new u.a9(e.x-1,e.y,e.z):e)))}return f}getVisibleCoordinates(e){const c=this.getRenderableIds(e).map((e=>this._inViewTiles.getTileById(e).tileID));return this.transform&&this.transform.populateCache(c),c}hasTransition(){return!!this._source.hasTransition()||!(!at(this._source.type)||!function(e,c){if(c<=0)return!1;const u=T();for(const c of e.getAllTiles())if(c.fadeEndTime>=u)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,c,p){this._state.updateState(e=e||u.ai,c,p)}removeFeatureState(e,c,p){this._state.removeFeatureState(e=e||u.ai,c,p)}getFeatureState(e,c){return this._state.getState(e=e||u.ai,c)}setDependencies(e,c,u){const p=this._inViewTiles.getTileById(e);p&&p.setDependencies(c,u)}reloadTilesForDependencies(e,c){for(const u of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(u).hasDependency(e,c)&&this._reloadTile(u,"reloading");this._outOfViewCache.filter((u=>!u.hasDependency(e,c)))}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,c){this.reset(e,c)}reset(e,c){this.points=e||[],this._distances=[0];for(let e=1;e0?(f-g)/y:0;return this.points[m].mult(1-x).add(this.points[c].mult(x))}}function wt(e,c){let u=!0;return"always"===e||"never"!==e&&"never"!==c||(u=!1),u}class Oe{constructor(e,c,u){const p=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(e/u),this.yCellCount=Math.ceil(c/u);for(let e=0;ethis.width||p<0||c>this.height)return[];const y=[];if(e<=0&&c<=0&&this.width<=u&&this.height<=p){if(f)return[{key:null,x1:e,y1:c,x2:u,y2:p}];for(let e=0;e0}hitTestCircle(e,c,u,p,f){const m=e-u,g=e+u,y=c-u,x=c+u;if(g<0||m>this.width||x<0||y>this.height)return!1;const b=[];return this._forEachCell(m,y,g,x,this._queryCellCircle,b,{hitTest:!0,overlapMode:p,circle:{x:e,y:c,radius:u},seenUids:{box:{},circle:{}}},f),b.length>0}_queryCell(e,c,u,p,f,m,g,y){const{seenUids:x,hitTest:b,overlapMode:T}=g,S=this.boxCells[f];if(null!==S){const f=this.bboxes;for(const g of S)if(!x.box[g]){x.box[g]=!0;const S=4*g,P=this.boxKeys[g];if(e<=f[S+2]&&c<=f[S+3]&&u>=f[S+0]&&p>=f[S+1]&&(!y||y(P))&&(!b||!wt(T,P.overlapMode))&&(m.push({key:P,x1:f[S],y1:f[S+1],x2:f[S+2],y2:f[S+3]}),b))return!0}}const P=this.circleCells[f];if(null!==P){const f=this.circles;for(const g of P)if(!x.circle[g]){x.circle[g]=!0;const S=3*g,P=this.circleKeys[g];if(this._circleAndRectCollide(f[S],f[S+1],f[S+2],e,c,u,p)&&(!y||y(P))&&(!b||!wt(T,P.overlapMode))){const e=f[S],c=f[S+1],u=f[S+2];if(m.push({key:P,x1:e-u,y1:c-u,x2:e+u,y2:c+u}),b)return!0}}}return!1}_queryCellCircle(e,c,u,p,f,m,g,y){const{circle:x,seenUids:b,overlapMode:T}=g,S=this.boxCells[f];if(null!==S){const e=this.bboxes;for(const c of S)if(!b.box[c]){b.box[c]=!0;const u=4*c,p=this.boxKeys[c];if(this._circleAndRectCollide(x.x,x.y,x.radius,e[u+0],e[u+1],e[u+2],e[u+3])&&(!y||y(p))&&!wt(T,p.overlapMode))return m.push(!0),!0}}const P=this.circleCells[f];if(null!==P){const e=this.circles;for(const c of P)if(!b.circle[c]){b.circle[c]=!0;const u=3*c,p=this.circleKeys[c];if(this._circlesCollide(e[u],e[u+1],e[u+2],x.x,x.y,x.radius)&&(!y||y(p))&&!wt(T,p.overlapMode))return m.push(!0),!0}}}_forEachCell(e,c,u,p,f,m,g,y){const x=this._convertToXCellCoord(e),b=this._convertToYCellCoord(c),T=this._convertToXCellCoord(u),S=this._convertToYCellCoord(p);for(let P=x;P<=T;P++)for(let x=b;x<=S;x++)if(f.call(this,e,c,u,p,this.xCellCount*x+P,m,g,y))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,c,u,p,f,m){const g=p-e,y=f-c,x=u+m;return x*x>g*g+y*y}_circleAndRectCollide(e,c,u,p,f,m,g){const y=(m-p)/2,x=Math.abs(e-(p+y));if(x>y+u)return!1;const b=(g-f)/2,T=Math.abs(c-(f+b));if(T>b+u)return!1;if(x<=y||T<=b)return!0;const S=x-y,P=T-b;return S*S+P*P<=u*u}}function Tt(e,c,p){const m=u.N();if(!e){const{vecSouth:e,vecEast:u}=At(c),p=f();p[0]=u[0],p[1]=u[1],p[2]=e[0],p[3]=e[1],g=p,(P=(x=(y=p)[0])*(S=y[3])-(T=y[2])*(b=y[1]))&&(g[0]=S*(P=1/P),g[1]=-b*P,g[2]=-T*P,g[3]=x*P),m[0]=p[0],m[1]=p[1],m[4]=p[2],m[5]=p[3]}var g,y,x,b,T,S,P;return u.Q(m,m,[1/p,1/p,1]),m}function Mt(e,c,p,f){if(e){const e=u.N();if(!c){const{vecSouth:c,vecEast:u}=At(p);e[0]=u[0],e[1]=u[1],e[4]=c[0],e[5]=c[1]}return u.Q(e,e,[f,f,1]),e}return p.pixelsToClipSpaceMatrix}function At(e){const c=Math.cos(e.rollInRadians),p=Math.sin(e.rollInRadians),f=Math.cos(e.pitchInRadians),m=Math.cos(e.bearingInRadians),g=Math.sin(e.bearingInRadians),y=u.aC();y[0]=-m*f*p-g*c,y[1]=-g*f*p+m*c;const x=u.aD(y);x<1e-9?u.aE(y):u.aF(y,y,1/x);const b=u.aC();b[0]=m*f*c-g*p,b[1]=g*f*c+m*p;const T=u.aD(b);return T<1e-9?u.aE(b):u.aF(b,b,1/T),{vecEast:b,vecSouth:y}}function Lt(e,c,p,f){let m;f?(m=[e,c,f(e,c),1],u.aH(m,m,p)):(m=[e,c,0,1],_i(m,m,p));const g=m[3];return{point:new u.P(m[0]/g,m[1]/g),signedDistanceFromCamera:g,isOccluded:!1}}function Ft(e,c){return.5+e/c*.5}function Ot(e,c){return e.x>=-c[0]&&e.x<=c[0]&&e.y>=-c[1]&&e.y<=c[1]}function Gt(e,c,p,f,m,g,y,x,b,T,S,P,I){const C=p?e.textSizeData:e.iconSizeData,R=u.ay(C,c.transform.zoom),L=[256/c.width*2+1,256/c.height*2+1],F=p?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;F.clear();const B=e.lineVertexArray,O=p?e.text.placedSymbolArray:e.icon.placedSymbolArray,V=c.transform.width/c.transform.height;let j=!1;for(let p=0;pMath.abs(p.x-c.x)*f?{useVertical:!0}:(e===u.az.vertical?c.yp.x)?{needsFlipping:!0}:null}function Xt(e){const{projectionContext:c,pitchedLabelPlaneMatrixInverse:p,symbol:f,fontSize:m,flip:g,keepUpright:y,glyphOffsetArray:x,dynamicLayoutVertexArray:b,aspectRatio:T,rotateToLine:S}=e,P=m/24,I=f.lineOffsetX*P,C=f.lineOffsetY*P;let R;if(f.numGlyphs>1){const e=f.glyphStartIndex+f.numGlyphs,u=f.lineStartIndex,m=f.lineStartIndex+f.lineLength,b=Zt(P,x,I,C,g,f,S,c);if(!b)return{notEnoughRoom:!0};const L=ni(b.first.point.x,b.first.point.y,c,p),F=ni(b.last.point.x,b.last.point.y,c,p);if(y&&!g){const e=Ht(f.writingMode,L,F,T);if(e)return e}R=[b.first];for(let p=f.glyphStartIndex+1;p0?y.point:Kt(c.tileAnchorPoint,g,e,1,c),b=ni(e.x,e.y,c,p),S=ni(x.x,x.y,c,p),P=Ht(f.writingMode,b,S,T);if(P)return P}const e=pi(P*x.getoffsetX(f.glyphStartIndex),I,C,g,f.segment,f.lineStartIndex,f.lineStartIndex+f.lineLength,c,S);if(!e||c.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};R=[e]}for(const e of R)u.aG(b,e.point,e.angle);return{}}function Kt(e,c,u,p,f){const m=e.add(e.sub(c)._unit()),g=ri(m.x,m.y,f).point,y=u.sub(g);return u.add(y._mult(p/y.mag()))}function Jt(e,c,p){const f=c.projectionCache;if(f.projections[e])return f.projections[e];const m=new u.P(c.lineVertexArray.getx(e),c.lineVertexArray.gety(e)),g=ri(m.x,m.y,c);if(g.signedDistanceFromCamera>0)return f.projections[e]=g.point,f.anyProjectionOccluded=f.anyProjectionOccluded||g.isOccluded,g.point;const y=e-p.direction;return Kt(0===p.distanceFromAnchor?c.tileAnchorPoint:new u.P(c.lineVertexArray.getx(y),c.lineVertexArray.gety(y)),m,p.previousVertex,p.absOffsetX-p.distanceFromAnchor+1,c)}function ri(e,c,u){const p=e+u.translation[0],f=c+u.translation[1];let m;return u.pitchWithMap?(m=Lt(p,f,u.pitchedLabelPlaneMatrix,u.getElevation),m.isOccluded=!1):(m=u.transform.projectTileCoordinates(p,f,u.unwrappedTileID,u.getElevation),m.point.x=(.5*m.point.x+.5)*u.width,m.point.y=(.5*-m.point.y+.5)*u.height),m}function ni(e,c,p,f){if(p.pitchWithMap){const m=[e,c,0,1];return u.aH(m,m,f),p.transform.projectTileCoordinates(m[0]/m[3],m[1]/m[3],p.unwrappedTileID,p.getElevation).point}return{x:e/p.width*2-1,y:1-c/p.height*2}}function li(e,c,u){return u.transform.projectTileCoordinates(e,c,u.unwrappedTileID,u.getElevation)}function ci(e,c,u){return e._unit()._perp()._mult(c*u)}function ui(e,c,p,f,m,g,y,x,b){if(x.projectionCache.offsets[e])return x.projectionCache.offsets[e];const T=p.add(c);if(e+b.direction=m)return x.projectionCache.offsets[e]=T,T;const S=Jt(e+b.direction,x,b),P=ci(S.sub(p),y,b.direction),I=p.add(P),C=S.add(P);return x.projectionCache.offsets[e]=u.aI(g,T,I,C)||T,x.projectionCache.offsets[e]}function pi(e,c,u,p,f,m,g,y,x){const b=p?e-c:e+c;let T=b>0?1:-1,S=0;p&&(T*=-1,S=Math.PI),T<0&&(S+=Math.PI);let P,I=T>0?m+f:m+f+1;y.projectionCache.cachedAnchorPoint?P=y.projectionCache.cachedAnchorPoint:(P=ri(y.tileAnchorPoint.x,y.tileAnchorPoint.y,y).point,y.projectionCache.cachedAnchorPoint=P);let C,R,L=P,F=P,B=0,O=0;const V=Math.abs(b),j=[];let G;for(;B+O<=V;){if(I+=T,I=g)return null;B+=O,F=L,R=C;const e={absOffsetX:V,direction:T,distanceFromAnchor:B,previousVertex:F};if(L=Jt(I,y,e),0===u)j.push(F),G=L.sub(F);else{let c;const p=L.sub(F);c=0===p.mag()?ci(Jt(I+T,y,e).sub(L),u,T):ci(p,u,T),R||(R=F.add(c)),C=ui(I,c,L,m,g,R,u,y,e),j.push(R),G=C.sub(R)}O=G.mag()}const U=G._mult((V-B)/O)._add(R||F),q=S+Math.atan2(L.y-F.y,L.x-F.x);return j.push(U),{point:U,angle:x?q:0,path:j}}const fi=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function mi(e,c){for(let u=0;u=1;e--)I.push(g.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let L=[];if(I.length>0){const e=I[0].clone(),c=I[0].clone();for(let u=1;u=p.x&&c.x<=f.x&&e.y>=p.y&&c.y<=f.y?[I]:c.xf.x||c.yf.y?[]:u.aJ([I],p.x,p.y,f.x,f.y)}for(const u of L){m.reset(u,.25*c);let p=0;p=m.length<=.5*c?1:Math.ceil(m.paddedLength/C)+1;for(let u=0;u{const u=Lt(e.x,e.y,p,c.getElevation),f=c.transform.projectTileCoordinates(u.point.x,u.point.y,c.unwrappedTileID,c.getElevation);return f.point.x=(.5*f.point.x+.5)*c.width,f.point.y=(.5*-f.point.y+.5)*c.height,f}))}(e,c);return function(e){let c=0,u=0,p=0,f=0;for(let m=0;mu&&(u=f,c=p));return e.slice(c,c+u)}(p)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const c=[],p=new u.aa;for(const f of e){const e=new u.P(f.x+gi,f.y+gi);p.extend(e),c.push(e)}const{minX:f,minY:m,maxX:g,maxY:y}=p,x=this.grid.query(f,m,g,y).concat(this.ignoredGrid.query(f,m,g,y)),b={},T={};for(const e of x){const p=e.key;if(void 0===b[p.bucketInstanceId]&&(b[p.bucketInstanceId]={}),b[p.bucketInstanceId][p.featureIndex])continue;const f=[new u.P(e.x1,e.y1),new u.P(e.x2,e.y1),new u.P(e.x2,e.y2),new u.P(e.x1,e.y2)];u.aK(c,f)&&(b[p.bucketInstanceId][p.featureIndex]=!0,void 0===T[p.bucketInstanceId]&&(T[p.bucketInstanceId]=[]),T[p.bucketInstanceId].push(p.featureIndex))}return T}insertCollisionBox(e,c,u,p,f,m){(u?this.ignoredGrid:this.grid).insert({bucketInstanceId:p,featureIndex:f,collisionGroupID:m,overlapMode:c},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,c,u,p,f,m){const g=u?this.ignoredGrid:this.grid,y={bucketInstanceId:p,featureIndex:f,collisionGroupID:m,overlapMode:c};for(let c=0;c=this.screenRightBoundary||pthis.screenBottomBoundary}isInsideGrid(e,c,u,p){return u>=0&&e=0&&cthis.projectAndGetPerspectiveRatio(e.x,e.y,f,b,S)));re=e.some((e=>!e.isOccluded)),J=e.map((e=>new u.P(e.x,e.y)))}else re=!0;return{box:u.aL(J),allPointsOccluded:!re}}}class lt{constructor(e,c,u,p){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?c:-c))):p&&u?1:0,this.placed=u}isHidden(){return 0===this.opacity&&!this.placed}}class ct{constructor(e,c,u,p,f){this.text=new lt(e?e.text:null,c,u,f),this.icon=new lt(e?e.icon:null,c,p,f)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class ht{constructor(e,c,u){this.text=e,this.icon=c,this.skipFade=u}}class ut{constructor(e,c,u,p,f){this.bucketInstanceId=e,this.featureIndex=c,this.sourceLayerIndex=u,this.bucketIndex=p,this.tileID=f}}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 c=++this.maxGroupID;this.collisionGroups[e]={ID:c,predicate:e=>e.collisionGroupID===c}}return this.collisionGroups[e]}}function yi(e,c,p,f,m){const{horizontalAlign:g,verticalAlign:y}=u.aS(e);return new u.P(-(g-.5)*c+f[0]*m,-(y-.5)*p+f[1]*m)}class pt{constructor(e,c,u,p,f){this.transform=e.clone(),this.terrain=c,this.collisionIndex=new nt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=u,this.retainedQueryData={},this.collisionGroups=new dt(p),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=f,f&&(f.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const c=this.terrain;return c?(u,p)=>c.getElevation(e,u,p):null}getBucketParts(e,c,p,f){const m=p.getBucket(c),g=p.latestFeatureIndex;if(!m||!g||c.id!==m.layerIds[0])return;const y=p.collisionBoxArray,x=m.layers[0].layout,b=m.layers[0].paint,T=Math.pow(2,this.transform.zoom-p.tileID.overscaledZ),S=p.tileSize/u.a5,P=p.tileID.toUnwrapped(),I="map"===x.get("text-rotation-alignment"),C=u.aN(p,1,this.transform.zoom),R=u.aO(this.collisionIndex.transform,p,b.get("text-translate"),b.get("text-translate-anchor")),L=u.aO(this.collisionIndex.transform,p,b.get("icon-translate"),b.get("icon-translate-anchor")),F=Tt(I,this.transform,C);this.retainedQueryData[m.bucketInstanceId]=new ut(m.bucketInstanceId,g,m.sourceLayerIndex,m.index,p.tileID);const B={bucket:m,layout:x,translationText:R,translationIcon:L,unwrappedTileID:P,pitchedLabelPlaneMatrix:F,scale:T,textPixelRatio:S,holdingForFade:p.holdingForSymbolFade(),collisionBoxArray:y,partiallyEvaluatedTextSize:u.ay(m.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(m.sourceID)};if(f)for(const c of m.sortKeyRanges){const{sortKey:u,symbolInstanceStart:p,symbolInstanceEnd:f}=c;e.push({sortKey:u,symbolInstanceStart:p,symbolInstanceEnd:f,parameters:B})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:m.symbolInstances.length,parameters:B})}attemptAnchorPlacement(e,c,p,f,m,g,y,x,b,T,S,P,I,C,R,L,F,B,O,V){const j=u.aP[e.textAnchor],G=[e.textOffset0,e.textOffset1],U=yi(j,p,f,G,m),q=this.collisionIndex.placeCollisionBox(c,P,x,b,T,y,g,L,S.predicate,O,U,V);if((!B||this.collisionIndex.placeCollisionBox(B,P,x,b,T,y,g,F,S.predicate,O,U,V).placeable)&&q.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[I.crossTileID]&&this.prevPlacement.placements[I.crossTileID]&&this.prevPlacement.placements[I.crossTileID].text&&(e=this.prevPlacement.variableOffsets[I.crossTileID].anchor),0===I.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[I.crossTileID]={textOffset:G,width:p,height:f,anchor:j,textBoxScale:m,prevAnchor:e},this.markUsedJustification(C,j,I,R),C.allowVerticalPlacement&&(this.markUsedOrientation(C,R,I),this.placedOrientations[I.crossTileID]=R),{shift:U,placedGlyphBoxes:q}}}placeLayerBucketPart(e,c,p){const{bucket:f,layout:m,translationText:g,translationIcon:y,unwrappedTileID:x,pitchedLabelPlaneMatrix:b,textPixelRatio:T,holdingForFade:S,collisionBoxArray:P,partiallyEvaluatedTextSize:I,collisionGroup:C}=e.parameters,R=m.get("text-optional"),L=m.get("icon-optional"),F=u.aQ(m,"text-overlap","text-allow-overlap"),B="always"===F,O=u.aQ(m,"icon-overlap","icon-allow-overlap"),V="always"===O,j="map"===m.get("text-rotation-alignment"),G="map"===m.get("text-pitch-alignment"),U="none"!==m.get("icon-text-fit"),q="viewport-y"===m.get("symbol-z-order"),Z=B&&(V||!f.hasIconData()||L),W=V&&(B||!f.hasTextData()||R);!f.collisionArrays&&P&&f.deserializeCollisionBoxes(P);const Q=this.retainedQueryData[f.bucketInstanceId].tileID,J=this._getTerrainElevationFunc(Q),re=this.transform.getFastPathSimpleProjectionMatrix(Q),se=(e,P,V)=>{var q,se;if(c[e.crossTileID])return;if(S)return void(this.placements[e.crossTileID]=new ht(!1,!1,!1));let le=!1,ce=!1,he=!0,ue=null,pe={box:null,placeable:!1,offscreen:null,occluded:!1},fe={placeable:!1},me=null,ge=null,ye=null,xe=0,ve=0,be=0;P.textFeatureIndex?xe=P.textFeatureIndex:e.useRuntimeCollisionCircles&&(xe=e.featureIndex),P.verticalTextFeatureIndex&&(ve=P.verticalTextFeatureIndex);const we=P.textBox;if(we){const c=c=>{let p=u.az.horizontal;if(f.allowVerticalPlacement&&!c&&this.prevPlacement){const c=this.prevPlacement.placedOrientations[e.crossTileID];c&&(this.placedOrientations[e.crossTileID]=c,p=c,this.markUsedOrientation(f,p,e))}return p},m=(c,p)=>{if(f.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&P.verticalTextBox){for(const e of f.writingModes)if(e===u.az.vertical?(pe=p(),fe=pe):pe=c(),pe&&pe.placeable)break}else pe=c()},b=e.textAnchorOffsetStartIndex,S=e.textAnchorOffsetEndIndex;if(S===b){const p=(c,u)=>{const p=this.collisionIndex.placeCollisionBox(c,F,T,Q,x,G,j,g,C.predicate,J,void 0,re);return p&&p.placeable&&(this.markUsedOrientation(f,u,e),this.placedOrientations[e.crossTileID]=u),p};m((()=>p(we,u.az.horizontal)),(()=>{const c=P.verticalTextBox;return f.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&c?p(c,u.az.vertical):{box:null,offscreen:null}})),c(pe&&pe.placeable)}else{let I=u.aP[null===(se=null===(q=this.prevPlacement)||void 0===q?void 0:q.variableOffsets[e.crossTileID])||void 0===se?void 0:se.anchor];const R=(c,u,m)=>{const P=c.x2-c.x1,R=c.y2-c.y1,L=e.textBoxScale,B=U&&"never"===O?u:null;let V=null,q="never"===F?1:2,Z="never";I&&q++;for(let u=0;uR(we,P.iconBox,u.az.horizontal)),(()=>{const c=P.verticalTextBox;return f.allowVerticalPlacement&&(!pe||!pe.placeable)&&e.numVerticalGlyphVertices>0&&c?R(c,P.verticalIconBox,u.az.vertical):{box:null,occluded:!0,offscreen:null}})),pe&&(le=pe.placeable,he=pe.offscreen);const L=c(pe&&pe.placeable);if(!le&&this.prevPlacement){const c=this.prevPlacement.variableOffsets[e.crossTileID];c&&(this.variableOffsets[e.crossTileID]=c,this.markUsedJustification(f,c.anchor,e,L))}}}if(me=pe,le=me&&me.placeable,he=me&&me.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const c=f.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),y=u.aA(f.textSizeData,I,c),T=m.get("text-padding");ge=this.collisionIndex.placeCollisionCircles(F,c,f.lineVertexArray,f.glyphOffsetArray,y,x,b,p,G,C.predicate,e.collisionCircleDiameter,T,g,J),ge.circles.length&&ge.collisionDetected&&!p&&u.w("Collisions detected, but collision boxes are not shown"),le=B||ge.circles.length>0&&!ge.collisionDetected,he=he&&ge.offscreen}if(P.iconFeatureIndex&&(be=P.iconFeatureIndex),P.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,O,T,Q,x,G,j,y,C.predicate,J,U&&ue?ue:void 0,re);fe&&fe.placeable&&P.verticalIconBox?(ye=e(P.verticalIconBox),ce=ye.placeable):(ye=e(P.iconBox),ce=ye.placeable),he=he&&ye.offscreen}const Se=R||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Me=L||0===e.numIconVertices;Se||Me?Me?Se||(ce=ce&&le):le=ce&&le:ce=le=ce&≤const Ee=ce&&ye.placeable;if(le&&me.placeable&&this.collisionIndex.insertCollisionBox(me.box,F,m.get("text-ignore-placement"),f.bucketInstanceId,fe&&fe.placeable&&ve?ve:xe,C.ID),Ee&&this.collisionIndex.insertCollisionBox(ye.box,O,m.get("icon-ignore-placement"),f.bucketInstanceId,be,C.ID),ge&&le&&this.collisionIndex.insertCollisionCircles(ge.circles,F,m.get("text-ignore-placement"),f.bucketInstanceId,xe,C.ID),p&&this.storeCollisionData(f.bucketInstanceId,V,P,me,ye,ge),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===f.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new ht((le||Z)&&!(null==me?void 0:me.occluded),(ce||W)&&!(null==ye?void 0:ye.occluded),he||f.justReloaded),c[e.crossTileID]=!0};if(q){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const c=f.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=c.length-1;e>=0;--e){const u=c[e];se(f.symbolInstances.get(u),f.collisionArrays[u],u)}}else for(let c=e.symbolInstanceStart;c=0&&(e.text.placedSymbolArray.get(c).crossTileID=m>=0&&c!==m?0:p.crossTileID)}markUsedOrientation(e,c,p){const f=c===u.az.horizontal||c===u.az.horizontalOnly?c:0,m=c===u.az.vertical?c:0,g=[p.leftJustifiedTextSymbolIndex,p.centerJustifiedTextSymbolIndex,p.rightJustifiedTextSymbolIndex];for(const c of g)e.text.placedSymbolArray.get(c).placedOrientation=f;p.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(p.verticalPlacedTextSymbolIndex).placedOrientation=m)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const c=this.prevPlacement;let u=!1;this.prevZoomAdjustment=c?c.zoomAdjustment(this.transform.zoom):0;const p=c?c.symbolFadeChange(e):1,f=c?c.opacities:{},m=c?c.variableOffsets:{},g=c?c.placedOrientations:{};for(const e in this.placements){const c=this.placements[e],m=f[e];m?(this.opacities[e]=new ct(m,p,c.text,c.icon),u=u||c.text!==m.text.placed||c.icon!==m.icon.placed):(this.opacities[e]=new ct(null,p,c.text,c.icon,c.skipFade),u=u||c.text||c.icon)}for(const e in f){const c=f[e];if(!this.opacities[e]){const f=new ct(c,p,!1,!1);f.isHidden()||(this.opacities[e]=f,u=u||c.text.placed||c.icon.placed)}}for(const e in m)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=m[e]);for(const e in g)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=g[e]);if(c&&void 0===c.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");u?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=c?c.lastPlacementChangeTime:e)}updateLayerOpacities(e,c){const u={};for(const p of c){const c=p.getBucket(e);c&&p.latestFeatureIndex&&e.id===c.layerIds[0]&&this.updateBucketOpacities(c,p.tileID,u,p.collisionBoxArray)}}updateBucketOpacities(e,c,p,f){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 m=e.layers[0],g=m.layout,y=new ct(null,0,!1,!1,!0),x=g.get("text-allow-overlap"),b=g.get("icon-allow-overlap"),T=m._unevaluatedLayout.hasValue("text-variable-anchor")||m._unevaluatedLayout.hasValue("text-variable-anchor-offset"),S="map"===g.get("text-rotation-alignment"),P="map"===g.get("text-pitch-alignment"),I="none"!==g.get("icon-text-fit"),C=new ct(null,0,x&&(b||!e.hasIconData()||g.get("icon-optional")),b&&(x||!e.hasTextData()||g.get("text-optional")),!0);!e.collisionArrays&&f&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(f);const R=(e,c,u)=>{for(let p=0;p0,B=this.placedOrientations[f.crossTileID],O=B===u.az.vertical,V=B===u.az.horizontal||B===u.az.horizontalOnly;if(m>0||g>0){const c=Li(b.text);R(e.text,m,O?Fi:c),R(e.text,g,V?Fi:c);const u=b.text.isHidden();[f.rightJustifiedTextSymbolIndex,f.centerJustifiedTextSymbolIndex,f.leftJustifiedTextSymbolIndex].forEach((c=>{c>=0&&(e.text.placedSymbolArray.get(c).hidden=u||O?1:0)})),f.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(f.verticalPlacedTextSymbolIndex).hidden=u||V?1:0);const p=this.variableOffsets[f.crossTileID];p&&this.markUsedJustification(e,p.anchor,f,B);const y=this.placedOrientations[f.crossTileID];y&&(this.markUsedJustification(e,"left",f,y),this.markUsedOrientation(e,y,f))}if(F){const c=Li(b.icon),u=!(I&&f.verticalPlacedIconSymbolIndex&&O);f.placedIconSymbolIndex>=0&&(R(e.icon,f.numIconVertices,u?c:Fi),e.icon.placedSymbolArray.get(f.placedIconSymbolIndex).hidden=b.icon.isHidden()),f.verticalPlacedIconSymbolIndex>=0&&(R(e.icon,f.numVerticalIconVertices,u?Fi:c),e.icon.placedSymbolArray.get(f.verticalPlacedIconSymbolIndex).hidden=b.icon.isHidden())}const j=L&&L.has(c)?L.get(c):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const p=e.collisionArrays[c];if(p){let c=new u.P(0,0);if(p.textBox||p.verticalTextBox){let u=!0;if(T){const e=this.variableOffsets[x];e?(c=yi(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),S&&c._rotate(P?-this.transform.bearingInRadians:this.transform.bearingInRadians)):u=!1}if(p.textBox||p.verticalTextBox){let f;p.textBox&&(f=O),p.verticalTextBox&&(f=V),xi(e.textCollisionBox.collisionVertexArray,b.text.placed,!u||f,j.text,c.x,c.y)}}if(p.iconBox||p.verticalIconBox){const u=Boolean(!V&&p.verticalIconBox);let f;p.iconBox&&(f=u),p.verticalIconBox&&(f=!u),xi(e.iconCollisionBox.collisionVertexArray,b.icon.placed,f,j.icon,I?c.x:0,I?c.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 xi(e,c,u,p,f,m){p&&0!==p.length||(p=[0,0,0,0]);const g=p[0]-gi,y=p[1]-gi,x=p[2]-gi,b=p[3]-gi;e.emplaceBack(c?1:0,u?1:0,f||0,m||0,g,y),e.emplaceBack(c?1:0,u?1:0,f||0,m||0,x,y),e.emplaceBack(c?1:0,u?1:0,f||0,m||0,x,b),e.emplaceBack(c?1:0,u?1:0,f||0,m||0,g,b)}const vi=Math.pow(2,25),bi=Math.pow(2,24),wi=Math.pow(2,17),Ii=Math.pow(2,16),Ei=Math.pow(2,9),Ci=Math.pow(2,8),Ai=Math.pow(2,1);function Li(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const c=e.placed?1:0,u=Math.floor(127*e.opacity);return u*vi+c*bi+u*wi+c*Ii+u*Ei+c*Ci+u*Ai+c}const Fi=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,c,u,p,f){const m=this._bucketParts;for(;this._currentTileIndexe.sortKey-c.sortKey)));this._currentPartIndex!this._forceFullPlacement&&T()-p>2;for(;this._currentPlacementIndex>=0;){const p=c[e[this._currentPlacementIndex]],m=this.placement.collisionIndex.transform.zoom;if("symbol"===p.type&&(!p.minzoom||p.minzoom<=m)&&(!p.maxzoom||p.maxzoom>m)){if(this._inProgressLayer||(this._inProgressLayer=new Ct(p)),this._inProgressLayer.continuePlacement(u[p.source],this.placement,this._showCollisionBoxes,p,f))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Oi=512/u.a5/2;class Et{constructor(e,c,p){this.tileID=e,this.bucketInstanceId=p,this._symbolsByKey={};const f=new Map;for(let e=0;e({x:Math.floor(e.anchorX*Oi),y:Math.floor(e.anchorY*Oi)}))),crossTileIDs:c.map((e=>e.crossTileID))};if(p.positions.length>128){const e=new u.aT(p.positions.length,16,Uint16Array);for(const{x:c,y:u}of p.positions)e.add(c,u);e.finish(),delete p.positions,p.index=e}this._symbolsByKey[e]=p}}getScaledCoordinates(e,c){const{x:p,y:f,z:m}=this.tileID.canonical,{x:g,y:y,z:x}=c.canonical,b=Oi/Math.pow(2,x-m),T=(y*u.a5+e.anchorY)*b,S=f*u.a5*Oi;return{x:Math.floor((g*u.a5+e.anchorX)*b-p*u.a5*Oi),y:Math.floor(T-S)}}findMatches(e,c,u){const p=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 c=Math.round((e-this.lng)/360);if(0!==c)for(const e in this.indexes){const u=this.indexes[e],p={};for(const e in u){const f=u[e];f.tileID=f.tileID.unwrapTo(f.tileID.wrap+c),p[f.tileID.key]=f}this.indexes[e]=p}this.lng=e}addBucket(e,c,u){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===c.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;ee.overscaledZ)for(const u in f){const m=f[u];m.tileID.isChildOf(e)&&m.findMatches(c.symbolInstances,e,p)}else{const m=f[e.scaledTo(Number(u)).key];m&&m.findMatches(c.symbolInstances,e,p)}}for(let e=0;e{c[e]=!0}));for(const e in this.layerIndexes)c[e]||delete this.layerIndexes[e]}}var Vi="void main() {fragColor=vec4(1.0);}";const ji={prelude:Ni("#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:Ni("","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:Ni("","#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:Ni("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:Ni("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:Ni("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:Ni(Vi,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Ni("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:Ni("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:Ni("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:Ni("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:Ni("#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:Ni("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:Ni(Vi,"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:Ni("#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:Ni("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:Ni("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:Ni("#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:Ni("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:Ni("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:Ni("#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:Ni("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:Ni("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:Ni("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:Ni("#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:Ni("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:Ni("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:Ni("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:Ni("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:Ni("#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:Ni("#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:Ni("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:Ni("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:Ni("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:Ni("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:Ni("#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:Ni("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 Ni(e,c){const u=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,p=c.match(/in ([\w]+) ([\w]+)/g),f=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),m=c.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),g=m?m.concat(f):f,y={};return{fragmentSource:e=e.replace(u,((e,c,u,p,f)=>(y[f]=!0,"define"===c?`\n#ifndef HAS_UNIFORM_u_${f}\nin ${u} ${p} ${f};\n#else\nuniform ${u} ${p} u_${f};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${f}\n ${u} ${p} ${f} = u_${f};\n#endif\n`))),vertexSource:c=c.replace(u,((e,c,u,p,f)=>{const m="float"===p?"vec2":"vec4",g=f.match(/color/)?"color":m;return y[f]?"define"===c?`\n#ifndef HAS_UNIFORM_u_${f}\nuniform lowp float u_${f}_t;\nin ${u} ${m} a_${f};\nout ${u} ${p} ${f};\n#else\nuniform ${u} ${p} u_${f};\n#endif\n`:"vec4"===g?`\n#ifndef HAS_UNIFORM_u_${f}\n ${f} = a_${f};\n#else\n ${u} ${p} ${f} = u_${f};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${f}\n ${f} = unpack_mix_${g}(a_${f}, u_${f}_t);\n#else\n ${u} ${p} ${f} = u_${f};\n#endif\n`:"define"===c?`\n#ifndef HAS_UNIFORM_u_${f}\nuniform lowp float u_${f}_t;\nin ${u} ${m} a_${f};\n#else\nuniform ${u} ${p} u_${f};\n#endif\n`:"vec4"===g?`\n#ifndef HAS_UNIFORM_u_${f}\n ${u} ${p} ${f} = a_${f};\n#else\n ${u} ${p} ${f} = u_${f};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${f}\n ${u} ${p} ${f} = unpack_mix_${g}(a_${f}, u_${f}_t);\n#else\n ${u} ${p} ${f} = u_${f};\n#endif\n`})),staticAttributes:p,staticUniforms:g}}class kt{constructor(e,c,u){this.vertexBuffer=e,this.indexBuffer=c,this.segments=u}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Gi=u.aU([{name:"a_pos",type:"Int16",components:2}]);const Ui="#define PROJECTION_MERCATOR",qi="mercator";class jt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return qi}get shaderDefine(){return Ui}get shaderPreludeCode(){return ji.projectionMercator}get vertexShaderPreludeCode(){return ji.projectionMercator.vertexSource}get subdivisionGranularity(){return u.aV.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,c,p,f,m){if(this._cachedMesh)return this._cachedMesh;const g=new u.aW;g.emplaceBack(0,0),g.emplaceBack(u.a5,0),g.emplaceBack(0,u.a5),g.emplaceBack(u.a5,u.a5);const y=e.createVertexBuffer(g,Gi.members),x=u.aX.simpleSegment(0,0,4,2),b=new u.aY;b.emplaceBack(1,0,2),b.emplaceBack(1,2,3);const T=e.createIndexBuffer(b);return this._cachedMesh=new kt(y,T,x),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Nt{constructor(e=0,c=0,u=0,p=0){if(isNaN(e)||e<0||isNaN(c)||c<0||isNaN(u)||u<0||isNaN(p)||p<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=c,this.left=u,this.right=p}interpolate(e,c,p){return null!=c.top&&null!=e.top&&(this.top=u.G.number(e.top,c.top,p)),null!=c.bottom&&null!=e.bottom&&(this.bottom=u.G.number(e.bottom,c.bottom,p)),null!=c.left&&null!=e.left&&(this.left=u.G.number(e.left,c.left,p)),null!=c.right&&null!=e.right&&(this.right=u.G.number(e.right,c.right,p)),this}getCenter(e,c){const p=u.an((this.left+e-this.right)/2,0,e),f=u.an((this.top+c-this.bottom)/2,0,c);return new u.P(p,f)}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 $i(e,c){if(!e.renderWorldCopies||e.lngRange)return;const u=c.lng-e.center.lng;c.lng+=u>180?-360:u<-180?360:0}function Wi(e){return Math.max(0,Math.floor(e))}class Ut{constructor(e,c){var p;this.applyConstrain=(e,c)=>null!==this._constrainOverride?this._constrainOverride(e,c):this._callbacks.defaultConstrain(e,c),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==c?void 0:c.renderWorldCopies)||!!(null==c?void 0:c.renderWorldCopies),this._minZoom=(null==c?void 0:c.minZoom)||0,this._maxZoom=(null==c?void 0:c.maxZoom)||22,this._minPitch=null==(null==c?void 0:c.minPitch)?0:null==c?void 0:c.minPitch,this._maxPitch=null==(null==c?void 0:c.maxPitch)?60:null==c?void 0:c.maxPitch,this._constrainOverride=null!==(p=null==c?void 0:c.constrainOverride)&&void 0!==p?p:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new u.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Wi(this._zoom),this._scale=u.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,c,p){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=Wi(this._zoom),this._scale=u.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=!p&&e.autoCalculateNearFarZ,c&&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 u.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const c=u.W(e,-180,180)*Math.PI/180;var p,m,g,y,x,b,T,S,P;this._bearingInRadians!==c&&(this._unmodified=!1,this._bearingInRadians=c,this._calcMatrices(),this._rotationMatrix=f(),p=this._rotationMatrix,g=-this._bearingInRadians,y=(m=this._rotationMatrix)[0],x=m[1],b=m[2],T=m[3],S=Math.sin(g),P=Math.cos(g),p[0]=y*P+b*S,p[1]=x*P+T*S,p[2]=y*-S+b*P,p[3]=x*-S+T*P)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const c=u.an(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==c&&(this._unmodified=!1,this._pitchInRadians=c,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const c=e/180*Math.PI;this._rollInRadians!==c&&(this._unmodified=!1,this._rollInRadians=c,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return u.aZ(this._fovInRadians)}setFov(e){e=u.an(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=u.ap(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const c=this.applyConstrain(this._center,e).zoom;this._zoom!==c&&(this._unmodified=!1,this._zoom=c,this._tileZoom=Math.max(0,Math.floor(c)),this._scale=u.aq(c),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,c){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=c,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,c,u){this._unmodified=!1,this._edgeInsets.interpolate(e,c,u),this.constrainInternal(),this._calcMatrices()}resize(e,c,u=!0){this._width=e,this._height=c,u&&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=[-u.ao,u.ao])}getCameraQueryGeometry(e,c){if(1===c.length)return[c[0],e];{const{minX:p,minY:f,maxX:m,maxY:g}=u.aa.fromPoints(c).extend(e);return[new u.P(p,f),new u.P(m,f),new u.P(m,g),new u.P(p,g),new u.P(p,f)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:c,zoom:u}=this.applyConstrain(this.center,this.zoom);this.setCenter(c),this.setZoom(u),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=u.ar(new Float64Array(16));u.Q(e,e,[this._width/2,-this._height/2,1]),u.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=u.ar(new Float64Array(16)),u.Q(e,e,[1,-1,1]),u.O(e,e,[-1,-1,0]),u.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,c,p,f){const m=void 0!==p?p:this.bearing,g=f=void 0!==f?f:this.pitch,{distanceToCenter:y,clampedElevation:x}=this._distanceToCenterFromAltElevationPitch(c,this.elevation,g),{x:b,y:T}=$e(g,m),S=u.a9.fromLngLat(e,c);let P,I,C=u.a_(1,S.y),R=0;do{if(R+=1,R>10)break;I=y/C,P=new u.a9(S.x+b*I,S.y+T*I),C=1/P.meterInMercatorCoordinateUnits()}while(Math.abs(y-I*C)>1e-12);return{center:P.toLngLat(),elevation:x,zoom:u.at(this.height/2/Math.tan(this.fovInRadians/2)/I/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const c=1/this.worldSize,p=u.as(1,this.center.lat)*this.worldSize,f=u.a9.fromLngLat(this.center,this.elevation),m=f.x/c,g=f.y/c,y=f.z/c,x=this.pitch,b=this.bearing,{x:T,y:S,z:P}=$e(x,b),I=this.cameraToCenterDistance,C=m+I*-T,R=g+I*-S,L=y+I*P,{distanceToCenter:F,clampedElevation:B}=this._distanceToCenterFromAltElevationPitch(L/p,e,x),O=F*p,V=new u.a9((C+T*O)*c,(R+S*O)*c,0).toLngLat(),j=u.as(1,V.lat),G=u.at(this.height/2/Math.tan(this.fovInRadians/2)/F/j/this.tileSize);this._elevation=B,this._center=V,this.setZoom(G)}_distanceToCenterFromAltElevationPitch(e,c,p){const f=-Math.cos(u.ap(p)),m=e-c;let g,y=c;return f*m>=0||Math.abs(f)<.1?(g=1e4,y=e+g*f):g=-m/f,{distanceToCenter:g,clampedElevation:y}}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new u.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=u.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 c=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?(c+=e[p]*this.min[p],u+=e[p]*this.max[p]):(u+=e[p]*this.min[p],c+=e[p]*this.max[p]);return c>=0?2:u<0?0:1}}class qt{distanceToTile2d(e,c,u,p){const f=p.distanceX([e,c]),m=p.distanceY([e,c]);return Math.hypot(f,m)}getWrap(e,c,u){return u}getTileBoundingVolume(e,c,p,f){var m,g;let y=0,x=0;if(null==f?void 0:f.terrain){const b=new u.a2(e.z,c,e.z,e.x,e.y),T=f.terrain.getMinMaxElevation(b);y=null!==(m=T.minElevation)&&void 0!==m?m:Math.min(0,p),x=null!==(g=T.maxElevation)&&void 0!==g?g:Math.max(0,p)}const b=1<f}allowWorldCopies(){return!0}prepareNextFrame(){}}class Wt{constructor(e,c,u){this.points=e,this.planes=c,this.aabb=u}static fromInvProjectionMatrix(e,c=1,p=0,f,m){const g=m?[[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]],y=Math.pow(2,p),x=[[-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((p=>function(e,c,p,f){const m=u.aH([],e,c),g=1/m[3]/p*f;return u.b6(m,m,[g,g,1/m[3],g])}(p,e,c,y)));f&&function(e,c,p,f){const m=f?4:0,g=f?0:4;let y=0;const x=[],b=[];for(let c=0;c<4;c++){const p=u.b2([],e[c+g],e[c+m]),f=u.b7(p);u.a$(p,p,1/f),x.push(f),b.push(p)}for(let c=0;c<4;c++){const f=u.b8(e[c+m],b[c],p);y=null!==f&&f>=0?Math.max(y,f):Math.max(y,x[c])}const T=function(e,c){const p=u.b2([],e[c[0]],e[c[1]]),f=u.b2([],e[c[2]],e[c[1]]),m=[0,0,0,0];return u.b3(m,u.b4([],p,f)),m[3]=-u.b5(m,e[c[0]]),m}(e,c),S=function(e,c){const p=u.b9(e),f=u.ba([],e,1/p),m=u.b2([],c,u.a$([],f,u.b5(c,f))),g=u.b9(m);if(g>0){const e=Math.sqrt(1-f[3]*f[3]),p=u.a$([],f,-f[3]),y=u.b0([],p,u.a$([],m,e/g));return u.bb(c,y)}return null}(p,T);if(null!==S){const e=S/u.b5(b[0],T);y=Math.min(y,e)}for(let c=0;c<4;c++){const u=Math.min(y,x[c]);e[c+g]=[e[c+m][0]+b[c][0]*u,e[c+m][1]+b[c][1]*u,e[c+m][2]+b[c][2]*u,1]}}(x,g[0],f,m);const b=g.map((e=>{const c=u.b2([],x[e[0]],x[e[1]]),p=u.b2([],x[e[2]],x[e[1]]),f=u.b3([],u.b4([],c,p)),m=-u.b5(f,x[e[1]]);return f.concat(m)})),T=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],S=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of x)for(let c=0;c<3;c++)T[c]=Math.min(T[c],e[c]),S[c]=Math.max(S[c],e[c]);return new Wt(x,b,new Vt(T,S))}}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,c,u){return this._helper.interpolatePadding(e,c,u)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,c,u=!0){this._helper.resize(e,c,u)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,c){this._helper.overrideNearFarZ(e,c)}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,c){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,c)=>{c=u.an(+c,this.minZoom,this.maxZoom);const p={center:new u.V(e.lng,e.lat),zoom:c};let f=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===f){const e=180-1e-10;f=[-e,e]}const m=this.tileSize*u.aq(p.zoom);let g=0,y=m,x=0,b=m,T=0,S=0;const{x:P,y:I}=this.size;if(this._helper._latRange){const e=this._helper._latRange;g=u.X(e[1])*m,y=u.X(e[0])*m,y-gy&&(F=y-e)}if(f){const e=(x+b)/2;let c=C;this._helper._renderWorldCopies&&(c=u.W(C,e-m/2,e+m/2));const p=P/2;c-pb&&(L=b-p)}if(void 0!==L||void 0!==F){const e=new u.P(null!=L?L:C,null!=F?F:R);p.center=je(m,e).wrap()}return p},this.applyConstrain=(e,c)=>this._helper.applyConstrain(e,c),this._helper=new Ut({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,c)=>this.defaultConstrain(e,c)},e),this._coveringTilesDetailsProvider=new qt}clone(){const e=new $t;return e.apply(this,!1),e}apply(e,c,u){this._helper.apply(e,c,u)}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 c=[new u.bc(0,e)];if(this._helper._renderWorldCopies){const p=this.screenPointToMercatorCoordinate(new u.P(0,0)),f=this.screenPointToMercatorCoordinate(new u.P(this._helper._width,0)),m=this.screenPointToMercatorCoordinate(new u.P(this._helper._width,this._helper._height)),g=this.screenPointToMercatorCoordinate(new u.P(0,this._helper._height)),y=Math.floor(Math.min(p.x,f.x,m.x,g.x)),x=Math.floor(Math.max(p.x,f.x,m.x,g.x)),b=1;for(let p=y-b;p<=x+b;p++)0!==p&&c.push(new u.bc(p,e))}return c}getCameraFrustum(){return Wt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const c=this.screenPointToLocation(this.centerPoint,e),u=e?e.getElevationForLngLatZoom(c,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(u)}setLocationAtPoint(e,c){const p=u.as(this.elevation,this.center.lat),f=this.screenPointToMercatorCoordinateAtZ(c,p),m=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,p),g=u.a9.fromLngLat(e),y=new u.a9(g.x-(f.x-m.x),g.y-(f.y-m.y));this.setCenter(null==y?void 0:y.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,c){return c?this.coordinatePoint(u.a9.fromLngLat(e),c.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(u.a9.fromLngLat(e))}screenPointToLocation(e,c){var u;return null===(u=this.screenPointToMercatorCoordinate(e,c))||void 0===u?void 0:u.toLngLat()}screenPointToMercatorCoordinate(e,c){if(c){const u=c.pointCoordinate(e);if(null!=u)return u}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,c){const p=c||0,f=[e.x,e.y,0,1],m=[e.x,e.y,1,1];u.aH(f,f,this._pixelMatrixInverse),u.aH(m,m,this._pixelMatrixInverse);const g=f[3],y=m[3],x=f[1]/g,b=m[1]/y,T=f[2]/g,S=m[2]/y,P=T===S?0:(p-T)/(S-T);return new u.a9(u.G.number(f[0]/g,m[0]/y,P)/this.worldSize,u.G.number(x,b,P)/this.worldSize,p)}coordinatePoint(e,c=0,p=this._pixelMatrix){const f=[e.x*this.worldSize,e.y*this.worldSize,c,1];return u.aH(f,f,p),new u.P(f[0]/f[3],f[1]/f[3])}getBounds(){const e=Math.max(0,this._helper._height/2-Ne(this));return(new $).extend(this.screenPointToLocation(new u.P(0,e))).extend(this.screenPointToLocation(new u.P(this._helper._width,e))).extend(this.screenPointToLocation(new u.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new u.P(0,this._helper._height)))}isPointOnMapSurface(e,c){return c?null!=c.pointCoordinate(e):e.y>this.height/2-Ne(this)}calculatePosMatrix(e,c=!1,p){var f;const m=null!==(f=e.key)&&void 0!==f?f:u.bd(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),g=c?this._alignedPosMatrixCache:this._posMatrixCache;if(g.has(m)){const e=g.get(m);return p?e.f32:e.f64}const y=Ge(e,this.worldSize);u.S(y,c?this._alignedProjMatrix:this._viewProjMatrix,y);const x={f64:y,f32:new Float32Array(y)};return g.set(m,x),p?x.f32:x.f64}calculateFogMatrix(e){const c=e.key,p=this._fogMatrixCacheF32;if(p.has(c))return p.get(c);const f=Ge(e,this.worldSize);return u.S(f,this._fogMatrix,f),p.set(c,new Float32Array(f)),p.get(c)}calculateCenterFromCameraLngLatAlt(e,c,u,p){return this._helper.calculateCenterFromCameraLngLatAlt(e,c,u,p)}_calculateNearFarZIfNeeded(e,c,p){if(!this._helper.autoCalculateNearFarZ)return;const f=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),m=e-f*this._helper._pixelPerMeter/Math.cos(c),g=f<0?m:e,y=Math.PI/2+this.pitchInRadians,x=u.ap(this.fov)*(Math.abs(Math.cos(u.ap(this.roll)))*this.height+Math.abs(Math.sin(u.ap(this.roll)))*this.width)/this.height*(.5+p.y/this.height),b=Math.sin(x)*g/Math.sin(u.an(Math.PI-y-x,.01,Math.PI-.01)),T=Ne(this),S=Math.atan(T/this._helper.cameraToCenterDistance),P=u.ap(.75),I=S>P?2*S*(.5+p.y/(2*T)):P,C=Math.sin(I)*g/Math.sin(u.an(Math.PI-y-I,.01,Math.PI-.01)),R=Math.min(b,C);this._helper._farZ=1.01*(Math.cos(Math.PI/2-c)*R+g),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,c=Ae(this.worldSize,this.center),p=c.x,f=c.y;this._helper._pixelPerMeter=u.as(1,this.center.lat)*this.worldSize;const m=u.ap(Math.min(this.pitch,Ce)),g=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(m));let y;this._calculateNearFarZIfNeeded(g,m,e),y=new Float64Array(16),u.be(y,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),u.aB(this._invProjMatrix,y),y[8]=2*-e.x/this._helper._width,y[9]=2*e.y/this._helper._height,this._projectionMatrix=u.bf(y),u.Q(y,y,[1,-1,1]),u.O(y,y,[0,0,-this._helper.cameraToCenterDistance]),u.bg(y,y,-this.rollInRadians),u.bh(y,y,this.pitchInRadians),u.bg(y,y,-this.bearingInRadians),u.O(y,y,[-p,-f,0]),this._mercatorMatrix=u.Q([],y,[this.worldSize,this.worldSize,this.worldSize]),u.Q(y,y,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=u.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,y),u.O(y,y,[0,0,-this.elevation]),this._viewProjMatrix=y,this._invViewProjMatrix=u.aB([],y);const x=[0,0,-1,1];u.aH(x,x,this._invViewProjMatrix),this._cameraPosition=[x[0]/x[3],x[1]/x[3],x[2]/x[3]],this._fogMatrix=new Float64Array(16),u.be(this._fogMatrix,this.fovInRadians,this.width/this.height,g,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,u.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),u.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),u.bg(this._fogMatrix,this._fogMatrix,-this.rollInRadians),u.bh(this._fogMatrix,this._fogMatrix,this.pitchInRadians),u.bg(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),u.O(this._fogMatrix,this._fogMatrix,[-p,-f,0]),u.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),u.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=u.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,y);const b=this._helper._width%2/2,T=this._helper._height%2/2,S=Math.cos(this.bearingInRadians),P=Math.sin(-this.bearingInRadians),I=p-Math.round(p)+S*b+P*T,C=f-Math.round(f)+S*T+P*b,R=new Float64Array(y);if(u.O(R,R,[I>.5?I-1:I,C>.5?C-1:C,0]),this._alignedProjMatrix=R,y=u.aB(new Float64Array(16),this._pixelMatrix),!y)throw new Error("failed to invert matrix");this._pixelMatrixInverse=y,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new u.P(0,0)),c=[e.x*this.worldSize,e.y*this.worldSize,0,1];return u.aH(c,c,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=u.as(1,this.center.lat)*this.worldSize;return Ue(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,c){const p=u.a9.fromLngLat(e),f=[p.x*this.worldSize,p.y*this.worldSize,c,1];return u.aH(f,f,this._viewProjMatrix),f[2]/f[3]}getProjectionData(e){const{overscaledTileID:c,aligned:p,applyTerrainMatrix:f}=e,m=this._helper.getMercatorTileCoordinates(c),g=c?this.calculatePosMatrix(c,p,!0):null;let y;return y=c&&c.terrainRttPosMatrix32f&&f?c.terrainRttPosMatrix32f:g||u.bi(),{mainMatrix:y,tileMercatorCoords:m,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:y}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,c,u){return 1}transformLightDirection(e){return u.b1(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,c,p,f){const m=this.calculatePosMatrix(p);let g;f?(g=[e,c,f(e,c),1],u.aH(g,g,m)):(g=[e,c,0,1],_i(g,g,m));const y=g[3];return{point:new u.P(g[0]/y,g[1]/y),signedDistanceFromCamera:y,isOccluded:!1}}populateCache(e){for(const c of e)this.calculatePosMatrix(c)}getMatrixForModel(e,c){const p=u.a9.fromLngLat(e,c),f=p.meterInMercatorCoordinateUnits(),m=u.bj();return u.O(m,m,[p.x,p.y,p.z]),u.bg(m,m,Math.PI),u.bh(m,m,Math.PI/2),u.Q(m,m,[-f,f,f]),m}getProjectionDataForCustomLayer(e=!0){const c=new u.a2(0,0,0,0,0),p=this.getProjectionData({overscaledTileID:c,applyGlobeMatrix:e}),f=Ge(c,this.worldSize);u.S(f,this._viewProjMatrix,f),p.tileMercatorCoords=[0,0,1,1];const m=[u.a5,u.a5,this.worldSize/this._helper.pixelsPerMeter],g=u.bk();return u.Q(g,f,m),p.fallbackMatrix=g,p.mainMatrix=g,p}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Hi(){u.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Xi(e){if(e.useSlerp)if(e.k<1){const c=u.bl(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),p=u.bl(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),f=new Float64Array(4);u.bm(f,c,p,e.k);const m=u.bn(f);e.tr.setRoll(m.roll),e.tr.setPitch(m.pitch),e.tr.setBearing(m.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(u.G.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(u.G.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(u.G.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Yi(e,c,p,f,m){const g=m.padding,y=Ae(m.worldSize,p.getNorthWest()),x=Ae(m.worldSize,p.getNorthEast()),b=Ae(m.worldSize,p.getSouthEast()),T=Ae(m.worldSize,p.getSouthWest()),S=u.ap(-f),P=y.rotate(S),I=x.rotate(S),C=b.rotate(S),R=T.rotate(S),L=new u.P(Math.max(P.x,I.x,R.x,C.x),Math.max(P.y,I.y,R.y,C.y)),F=new u.P(Math.min(P.x,I.x,R.x,C.x),Math.min(P.y,I.y,R.y,C.y)),B=L.sub(F),O=(m.width-(g.left+g.right+c.left+c.right))/B.x,V=(m.height-(g.top+g.bottom+c.top+c.bottom))/B.y;if(V<0||O<0)return void Hi();const j=Math.min(u.at(m.scale*Math.min(O,V)),e.maxZoom),G=u.P.convert(e.offset),U=new u.P((c.left-c.right)/2,(c.top-c.bottom)/2).rotate(u.ap(f)),q=G.add(U).mult(m.scale/u.aq(j));return{center:je(m.worldSize,y.add(b).div(2).sub(q)),zoom:j,bearing:f}}class Yt{get useGlobeControls(){return!1}handlePanInertia(e,c){const u=e.mag(),p=Math.abs(Ne(c));return{easingOffset:e.mult(Math.min(.75*p/u,1)),easingCenter:c.center}}handleMapControlsRollPitchBearingZoom(e,c){e.bearingDelta&&c.setBearing(c.bearing+e.bearingDelta),e.pitchDelta&&c.setPitch(c.pitch+e.pitchDelta),e.rollDelta&&c.setRoll(c.roll+e.rollDelta),e.zoomDelta&&c.setZoom(c.zoom+e.zoomDelta)}handleMapControlsPan(e,c,u){e.around.distSqr(c.centerPoint)<.01||c.setLocationAtPoint(u,e.around)}cameraForBoxAndBearing(e,c,u,p,f){return Yi(e,c,u,p,f)}handleJumpToCenterZoom(e,c){e.zoom!==(void 0!==c.zoom?+c.zoom:e.zoom)&&e.setZoom(+c.zoom),void 0!==c.center&&e.setCenter(u.V.convert(c.center))}handleEaseTo(e,c){const p=e.zoom,f=e.padding,m={roll:e.roll,pitch:e.pitch,bearing:e.bearing},g={roll:void 0===c.roll?e.roll:c.roll,pitch:void 0===c.pitch?e.pitch:c.pitch,bearing:void 0===c.bearing?e.bearing:c.bearing},y=void 0!==c.zoom,x=!e.isPaddingEqual(c.padding);let b=!1;const T=y?+c.zoom:e.zoom;let S=e.centerPoint.add(c.offsetAsPoint);const P=e.screenPointToLocation(S),{center:I,zoom:C}=e.applyConstrain(u.V.convert(c.center||P),null!=T?T:p);$i(e,I);const R=Ae(e.worldSize,P),L=Ae(e.worldSize,I).sub(R),F=u.aq(C-p);return b=C!==p,{easeFunc:y=>{if(b&&e.setZoom(u.G.number(p,C,y)),u.bo(m,g)||Xi({startEulerAngles:m,endEulerAngles:g,tr:e,k:y,useSlerp:m.roll!=g.roll}),x&&(e.interpolatePadding(f,c.padding,y),S=e.centerPoint.add(c.offsetAsPoint)),c.around)e.setLocationAtPoint(c.around,c.aroundPoint);else{const c=u.aq(e.zoom-p),f=C>p?Math.min(2,F):Math.max(.5,F),m=Math.pow(f,1-y),g=je(e.worldSize,R.add(L.mult(y*m)).mult(c));e.setLocationAtPoint(e.renderWorldCopies?g.wrap():g,S)}},isZooming:b,elevationCenter:I}}handleFlyTo(e,c){const p=void 0!==c.zoom,f=e.zoom,m=e.applyConstrain(u.V.convert(c.center||c.locationAtOffset),p?+c.zoom:f),g=m.center,y=m.zoom;$i(e,g);const x=Ae(e.worldSize,c.locationAtOffset),b=Ae(e.worldSize,g).sub(x),T=b.mag(),S=u.aq(y-f);let P;if(void 0!==c.minZoom){const p=Math.min(+c.minZoom,f,y),m=e.applyConstrain(g,p).zoom;P=u.aq(m-f)}return{easeFunc:(c,p,m,T)=>{e.setZoom(1===c?y:f+u.at(p));const S=1===c?g:je(e.worldSize,x.add(b.mult(m)).mult(p));e.setLocationAtPoint(e.renderWorldCopies?S.wrap():S,T)},scaleOfZoom:S,targetCenter:g,scaleOfMinZoom:P,pixelPathLength:T}}}class Qt{constructor(e,c,u){this.blendFunction=e,this.blendColor=c,this.mask=u}}Qt.Replace=[1,0],Qt.disabled=new Qt(Qt.Replace,u.bp.transparent,[!1,!1,!1,!1]),Qt.unblended=new Qt(Qt.Replace,u.bp.transparent,[!0,!0,!0,!0]),Qt.alphaBlended=new Qt([1,771],u.bp.transparent,[!0,!0,!0,!0]);const Ki=2305;class ei{constructor(e,c,u){this.enable=e,this.mode=c,this.frontFace=u}}ei.disabled=new ei(!1,1029,Ki),ei.backCCW=new ei(!0,1029,Ki),ei.frontCCW=new ei(!0,1028,Ki);class ti{constructor(e,c,u){this.func=e,this.mask=c,this.range=u}}ti.ReadOnly=!1,ti.ReadWrite=!0,ti.disabled=new ti(519,ti.ReadOnly,[0,1]);const Qi=7680;class ai{constructor(e,c,u,p,f,m){this.test=e,this.ref=c,this.mask=u,this.fail=p,this.depthFail=f,this.pass=m}}ai.disabled=new ai({func:519,mask:0},0,0,Qi,Qi,Qi);const Ji=new WeakMap;function lr(e){var c;if(Ji.has(e))return Ji.get(e);{const u=null===(c=e.getParameter(e.VERSION))||void 0===c?void 0:c.startsWith("WebGL 2.0");return Ji.set(e,u),u}}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 c=e.context,p=c.gl;this._texFormat=p.RGBA,this._texType=p.UNSIGNED_BYTE;const f=new u.aW;f.emplaceBack(-1,-1),f.emplaceBack(2,-1),f.emplaceBack(-1,2);const m=new u.aY;m.emplaceBack(0,1,2),this._fullscreenTriangle=new kt(c.createVertexBuffer(f,Gi.members),c.createIndexBuffer(m),u.aX.simpleSegment(0,0,f.length,m.length)),this._resultBuffer=new Uint8Array(4),c.activeTexture.set(p.TEXTURE1);const g=p.createTexture();p.bindTexture(p.TEXTURE_2D,g),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.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texImage2D(p.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=c.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(g),lr(p)&&(this._pbo=p.createBuffer(),p.bindBuffer(p.PIXEL_PACK_BUFFER,this._pbo),p.bufferData(p.PIXEL_PACK_BUFFER,4,p.STREAM_READ),p.bindBuffer(p.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,c){const u=this._updateCount;return this._readbackQueue?u>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():u>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,c),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,c=e.gl;e.activeTexture.set(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,c){const p=this._cachedRenderContext.context,f=p.gl;if(this._bindFramebuffer(),p.viewport.set([0,0,this._texWidth,this._texHeight]),p.clear({color:u.bp.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(p,f.TRIANGLES,ti.disabled,ai.disabled,Qt.unblended,ei.disabled,((e,c)=>({u_input:e,u_output_expected:c}))(e,c),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&lr(f)){f.bindBuffer(f.PIXEL_PACK_BUFFER,this._pbo),f.readBuffer(f.COLOR_ATTACHMENT0),f.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),f.bindBuffer(f.PIXEL_PACK_BUFFER,null);const e=f.fenceSync(f.SYNC_GPU_COMMANDS_COMPLETE,0);f.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&&lr(e)){const c=e.clientWaitSync(this._readbackQueue.sync,0,0);if(c===e.WAIT_FAILED)return u.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(c===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 c=0;return c+=e[0]/256,c+=e[1]/65536,c+=e[2]/16777216,e[3]<127&&(c=-c),c/128}}const cr=u.a5/128;function hr(e,c){const p=void 0!==e.granularity?Math.max(e.granularity,1):1,f=p+(e.generateBorders?2:0),m=p+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),g=f+1,y=m+1,x=e.generateBorders?-1:0,b=e.generateBorders||e.extendToNorthPole?-1:0,T=p+(e.generateBorders?1:0),S=p+(e.generateBorders||e.extendToSouthPole?1:0),P=g*y,I=f*m*6,C=g*y>65536;if(C&&"16bit"===c)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const R=C||"32bit"===c,L=new Int16Array(2*P);let F=0;for(let c=b;c<=S;c++)for(let f=x;f<=T;f++){let m=f/p*u.a5;-1===f&&(m=-cr),f===p+1&&(m=u.a5+cr);let g=c/p*u.a5;-1===c&&(g=e.extendToNorthPole?u.br:-cr),c===p+1&&(g=e.extendToSouthPole?u.bs:u.a5+cr),L[F++]=m,L[F++]=g}const B=R?new Uint32Array(I):new Uint16Array(I);let O=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,c,u,p,f){return this.currentProjection.getMeshFromTileID(e,c,u,p,f)}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 pr(e){const c=yr(e.worldSize,e.center.lat);return 2*Math.PI*c}function _r(e,c,p,f,m){const g=1/(1<1e-6){const f=e[0]/p,m=Math.acos(e[2]/p),g=(f>0?m:-m)/Math.PI*180;return new u.V(u.W(g,-180,180),c)}return new u.V(0,c)}function vr(e){return Math.cos(e*Math.PI/180)}function br(e,c){const p=vr(e),f=vr(c);return u.at(f/p)}function wr(e,c){const p=e.rotate(c.bearingInRadians),f=c.zoom+br(c.center.lat,0),m=u.bu(1/vr(c.center.lat),1/vr(Math.min(Math.abs(c.center.lat),60)),u.bx(f,7,3,0,1)),g=360/pr({worldSize:c.worldSize,center:{lat:c.center.lat}});return new u.V(c.center.lng-p.x*g*m,u.an(c.center.lat+p.y*g,-u.ao,u.ao))}function Sr(e){const c=.5*e,u=Math.sin(c),p=Math.cos(c);return Math.log(u+p)-Math.log(p-u)}function Pr(e,c,p,f){const m=e.lat+p*f;if(Math.abs(p)>1){const g=(Math.sign(e.lat+p)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,y=Math.abs(e.lat+p)*Math.PI/180,x=Sr(g+f*(y-g)),b=Sr(g),T=Sr(y);return new u.V(e.lng+c*((x-b)/(T-b)),m)}return new u.V(e.lng+c*f,m)}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,c,u,p){const f=`${e.z}_${e.x}_${e.y}_${(null==p?void 0:p.terrain)?"t":""}`,m=this._cache.get(f);if(m)return m;const g=this._cachePrevious.get(f);if(g)return this._cache.set(f,g),g;const y=this._boundingVolumeFactory(e,c,u,p);return this._cache.set(f,y),this._hadAnyChanges=!0,y}}class Pi{constructor(e,c,u,p){this.min=u,this.max=p,this.points=e,this.planes=c}static fromAabb(e,c){const u=[];for(let p=0;p<8;p++)u.push([1&~p?e[0]:c[0],1==(p>>1&1)?c[1]:e[1],1==(p>>2&1)?c[2]:e[2]]);return new Pi(u,[[-1,0,0,c[0]],[1,0,0,-e[0]],[0,-1,0,c[1]],[0,1,0,-e[1]],[0,0,-1,c[2]],[0,0,1,-e[2]]],e,c)}static fromCenterSizeAngles(e,c,p){const f=u.bB([],p[0],p[1],p[2]),m=u.bC([],[c[0],0,0],f),g=u.bC([],[0,c[1],0],f),y=u.bC([],[0,0,c[2]],f),x=[...e],b=[...e];for(let c=0;c<8;c++)for(let u=0;u<3;u++){const p=e[u]+m[u]*(1&~c?-1:1)+g[u]*(1==(c>>1&1)?1:-1)+y[u]*(1==(c>>2&1)?1:-1);x[u]=Math.min(x[u],p),b[u]=Math.max(b[u],p)}const T=[];for(let c=0;c<8;c++){const p=[...e];u.b0(p,p,u.a$([],m,1&~c?-1:1)),u.b0(p,p,u.a$([],g,1==(c>>1&1)?1:-1)),u.b0(p,p,u.a$([],y,1==(c>>2&1)?1:-1)),T.push(p)}return new Pi(T,[[...m,-u.b5(m,T[0])],[...g,-u.b5(g,T[0])],[...y,-u.b5(y,T[0])],[-m[0],-m[1],-m[2],-u.b5(m,T[7])],[-g[0],-g[1],-g[2],-u.b5(g,T[7])],[-y[0],-y[1],-y[2],-u.b5(y,T[7])]],x,b)}intersectsFrustum(e){let c=!0;const u=this.points.length,p=this.planes.length,f=e.planes.length,m=e.points.length;for(let p=0;p=0&&m++}if(0===m)return 0;m=0&&p++}if(0===p)return 0}return 1}intersectsPlane(e){const c=this.points.length;let u=0;for(let p=0;p=0&&u++}return u===c?2:0===u?0:1}}function Cr(e,c,u){const p=e-c;return p<0?-p:Math.max(0,p-u)}function Ar(e,c,u,p,f){const m=e-u;let g;return g=m<0?Math.min(-m,1+m-f):m>1?Math.min(Math.max(m-f,0),1-m):0,Math.max(g,Cr(c,p,f))}class Mi{constructor(){this._boundingVolumeCache=new Ti(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,c,u,p){const f=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,c,u,p){return this._boundingVolumeCache.getTileBoundingVolume(e,c,u,p)}_computeTileBoundingVolume(e,c,p,f){var m,g;let y=0,x=0;if(null==f?void 0:f.terrain){const b=new u.a2(e.z,c,e.z,e.x,e.y),T=f.terrain.getMinMaxElevation(b);y=null!==(m=T.minElevation)&&void 0!==m?m:Math.min(0,p),x=null!==(g=T.maxElevation)&&void 0!==g?g:Math.max(0,p)}if(y/=u.bE,x/=u.bE,y+=1,x+=1,e.z<=0)return Pi.fromAabb([-x,-x,-x],[x,x,x]);if(1===e.z)return Pi.fromAabb([0===e.x?-x:0,0===e.y?0:-x,-x],[0===e.x?0:x,0===e.y?x:0,x]);{const c=[_r(0,0,e.x,e.y,e.z),_r(u.a5,0,e.x,e.y,e.z),_r(u.a5,u.a5,e.x,e.y,e.z),_r(0,u.a5,e.x,e.y,e.z)],p=[];for(const e of c)p.push(u.a$([],e,x));if(x!==y)for(const e of c)p.push(u.a$([],e,y));0===e.y&&p.push([0,1,0]),e.y===(1<=(1<{const p=u.an(e.lat,-u.ao,u.ao),f=u.an(+c,this.minZoom+br(0,p),this.maxZoom);return{center:new u.V(e.lng,p),zoom:f}},this.applyConstrain=(e,c)=>this._helper.applyConstrain(e,c),this._helper=new Ut({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,c)=>this.defaultConstrain(e,c)},e),this._coveringTilesDetailsProvider=new Mi}clone(){const e=new Si;return e.apply(this,!1),e}apply(e,c,u){this._globeLatitudeErrorCorrectionRadians=u||0,this._helper.apply(e,c)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=u.bA();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:c,applyGlobeMatrix:u}=e,p=this._helper.getMercatorTileCoordinates(c);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:p,clippingPlane:this._cachedClippingPlane,projectionTransition:u?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const c=this.pitchInRadians,p=this.cameraToCenterDistance/e,f=Math.sin(c)*p,m=Math.cos(c)*p+1,g=1/Math.sqrt(f*f+m*m)*1;let y=-f,x=m;const b=Math.sqrt(y*y+x*x);y/=b,x/=b;const T=[0,y,x];u.bG(T,T,[0,0,0],-this.bearingInRadians),u.bH(T,T,[0,0,0],-1*this.center.lat*Math.PI/180),u.bI(T,T,[0,0,0],this.center.lng*Math.PI/180);const S=1/u.b7(T);return u.a$(T,T,S),[...T,-g*S]}isLocationOccluded(e){return!this.isSurfacePointVisible(gr(e))}transformLightDirection(e){const c=this._helper._center.lng*Math.PI/180,p=this._helper._center.lat*Math.PI/180,f=Math.cos(p),m=[Math.sin(c)*f,Math.sin(p),Math.cos(c)*f],g=[m[2],0,-m[0]],y=[0,0,0];u.b4(y,g,m),u.b3(g,g),u.b3(y,y);const x=[0,0,0];return u.b3(x,[g[0]*e[0]+y[0]*e[1]+m[0]*e[2],g[1]*e[0]+y[1]*e[1]+m[1]*e[2],g[2]*e[0]+y[2]*e[1]+m[2]*e[2]]),x}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,c,p){const f=function(e,c,p){const f=1/(1<m&&(m=c),py&&(y=p)}const T=[b.lng+g,b.lat+x,b.lng+m,b.lat+y];return this.isSurfacePointOnScreen([0,1,0])&&(T[3]=90,T[0]=-180,T[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(T[1]=-90,T[0]=-180,T[2]=180),new $(T)}calculateCenterFromCameraLngLatAlt(e,c,u,p){return this._helper.calculateCenterFromCameraLngLatAlt(e,c,u,p)}setLocationAtPoint(e,c){const p=gr(this.unprojectScreenPoint(c)),f=gr(e),m=u.bA();u.bL(m);const g=u.bA();u.bI(g,p,m,-this.center.lng*Math.PI/180),u.bH(g,g,m,this.center.lat*Math.PI/180);const y=f[0]*f[0]+f[2]*f[2],x=g[0]*g[0];if(y=-F&&C<=F,O=L>=-F&&L<=F;let V,j;if(B&&O){const e=this.center.lng*Math.PI/180,c=this.center.lat*Math.PI/180;u.bN(S,e)+u.bN(C,c)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const c=u.bF();return u.aH(c,[...e,1],this._globeViewProjMatrixNoCorrection),c[0]/=c[3],c[1]/=c[3],c[2]/=c[3],c[0]>-1&&c[0]<1&&c[1]>-1&&c[1]<1&&c[2]>-1&&c[2]<1}rayPlanetIntersection(e,c){const p=u.b5(e,c),f=u.bA(),m=u.bA();u.a$(m,c,p),u.b2(f,e,m);const g=1-u.b5(f,f);if(g<0)return null;const y=u.b5(e,e)-1,x=-p+(p<0?1:-1)*Math.sqrt(g),b=y/x,T=x;return{tMin:Math.min(b,T),tMax:Math.max(b,T)}}unprojectScreenPoint(e){const c=this._cameraPosition,p=this.getRayDirectionFromPixel(e),f=this.rayPlanetIntersection(c,p);if(f){const e=u.bA();u.b0(e,c,[p[0]*f.tMin,p[1]*f.tMin,p[2]*f.tMin]);const m=u.bA();return u.b3(m,e),xr(m)}const m=this._cachedClippingPlane,g=m[0]*p[0]+m[1]*p[1]+m[2]*p[2],y=-u.bb(m,c)/g,x=u.bA();if(y>0)u.b0(x,c,[p[0]*y,p[1]*y,p[2]*y]);else{const e=u.bA();u.b0(e,c,[2*p[0],2*p[1],2*p[2]]);const f=u.bb(this._cachedClippingPlane,e);u.b2(x,e,[this._cachedClippingPlane[0]*f,this._cachedClippingPlane[1]*f,this._cachedClippingPlane[2]*f])}const b=function(e){const c=u.bA();return c[0]=e[0]*-e[3],c[1]=e[1]*-e[3],c[2]=e[2]*-e[3],{center:c,radius:Math.sqrt(1-e[3]*e[3])}}(m);return xr(function(e,c,p){const f=u.bA();u.b2(f,p,e);const m=u.bA();return u.by(m,e,f,c/u.b9(f)),m}(b.center,b.radius,x))}getMatrixForModel(e,c){const p=u.V.convert(e),f=1/u.bE,m=u.bj();return u.bJ(m,m,p.lng/180*Math.PI),u.bh(m,m,-p.lat/180*Math.PI),u.O(m,m,[0,0,1+c/u.bE]),u.bh(m,m,.5*Math.PI),u.Q(m,m,[f,f,f]),m}getProjectionDataForCustomLayer(e=!0){const c=this.getProjectionData({overscaledTileID:new u.a2(0,0,0,0,0),applyGlobeMatrix:e});return c.tileMercatorCoords=[0,0,1,1],c}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,c,u){return this._helper.interpolatePadding(e,c,u)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,c,u=!0){this._helper.resize(e,c,u)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,c){this._helper.overrideNearFarZ(e,c)}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,c){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=c,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,c)=>this.currentTransform.defaultConstrain(e,c),this.applyConstrain=(e,c)=>this._helper.applyConstrain(e,c),this._helper=new Ut({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,c)=>this.defaultConstrain(e,c)},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,c){this._helper.apply(e,c),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 c=this._mercatorTransform.getProjectionData(e),u=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?u.mainMatrix:c.mainMatrix,clippingPlane:u.clippingPlane,tileMercatorCoords:u.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:c.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return u.bu(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return u.bu(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,c,p){const f=this._mercatorTransform.getPitchedTextCorrection(e,c,p),m=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,c,p);return u.bu(f,m,this._globeness)}projectTileCoordinates(e,c,u,p){return this.currentTransform.projectTileCoordinates(e,c,u,p)}_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,c){return this.currentTransform.lngLatToCameraDepth(e,c)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,c,u,p){return this._helper.calculateCenterFromCameraLngLatAlt(e,c,u,p)}setLocationAtPoint(e,c){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,c),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,c),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,c){return this.currentTransform.locationToScreenPoint(e,c)}screenPointToMercatorCoordinate(e,c){return this.currentTransform.screenPointToMercatorCoordinate(e,c)}screenPointToLocation(e,c){return this.currentTransform.screenPointToLocation(e,c)}isPointOnMapSurface(e,c){return this.currentTransform.isPointOnMapSurface(e,c)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,c){return this.currentTransform.getMatrixForModel(e,c)}getProjectionDataForCustomLayer(e=!0){const c=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return c;const u=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return u.fallbackMatrix=c.mainMatrix,u}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Ri{get useGlobeControls(){return!0}handlePanInertia(e,c){const p=wr(e,c);return Math.abs(p.lng-c.center.lng)>180&&(p.lng=c.center.lng+179.5*Math.sign(p.lng-c.center.lng)),{easingCenter:p,easingOffset:new u.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,c){const p=e.around,f=c.screenPointToLocation(p);e.bearingDelta&&c.setBearing(c.bearing+e.bearingDelta),e.pitchDelta&&c.setPitch(c.pitch+e.pitchDelta),e.rollDelta&&c.setRoll(c.roll+e.rollDelta);const m=c.zoom;e.zoomDelta&&c.setZoom(c.zoom+e.zoomDelta);const g=c.zoom-m;if(0===g)return;const y=u.bK(c.center.lng,f.lng),x=y/(Math.abs(y/180)+1),b=u.bK(c.center.lat,f.lat),T=c.getRayDirectionFromPixel(p),S=c.cameraPosition,P=-1*u.b5(S,T),I=u.bA();u.b0(I,S,[T[0]*P,T[1]*P,T[2]*P]);const C=u.b7(I)-1,R=Math.exp(.5*-Math.max(C-.3,0)),L=yr(c.worldSize,c.center.lat)/Math.min(c.width,c.height),F=u.bx(L,.9,.5,1,.25),B=(1-u.aq(-g))*Math.min(R,F),O=c.center.lat,V=c.zoom,j=new u.V(c.center.lng+x*B,u.an(c.center.lat+b*B,-u.ao,u.ao));c.setLocationAtPoint(f,p);const G=c.center,U=u.bx(Math.abs(y),45,85,0,1),q=u.bx(L,.75,.35,0,1),Z=Math.pow(Math.max(U,q),.25),W=u.bK(G.lng,j.lng),Q=u.bK(G.lat,j.lat);c.setCenter(new u.V(G.lng+W*Z,G.lat+Q*Z).wrap()),c.setZoom(V+br(O,c.center.lat))}handleMapControlsPan(e,c,u){if(!e.panDelta)return;const p=c.center.lat,f=c.zoom;c.setCenter(wr(e.panDelta,c).wrap()),c.setZoom(f+br(p,c.center.lat))}cameraForBoxAndBearing(e,c,p,f,m){const g=Yi(e,c,p,f,m),y=c.left/m.width*2-1,x=(m.width-c.right)/m.width*2-1,b=c.top/m.height*-2+1,T=(m.height-c.bottom)/m.height*-2+1,S=u.bK(p.getWest(),p.getEast())<0,P=S?p.getEast():p.getWest(),I=S?p.getWest():p.getEast(),C=Math.max(p.getNorth(),p.getSouth()),R=Math.min(p.getNorth(),p.getSouth()),L=P+.5*u.bK(P,I),F=C+.5*u.bK(C,R),B=m.clone();B.setCenter(g.center),B.setBearing(g.bearing),B.setPitch(0),B.setRoll(0),B.setZoom(g.zoom);const O=B.modelViewProjectionMatrix,V=[gr(p.getNorthWest()),gr(p.getNorthEast()),gr(p.getSouthWest()),gr(p.getSouthEast()),gr(new u.V(I,F)),gr(new u.V(P,F)),gr(new u.V(L,C)),gr(new u.V(L,R))],j=gr(g.center);let G=Number.POSITIVE_INFINITY;for(const e of V)y<0&&(G=Ri.getLesserNonNegativeNonNull(G,Ri.solveVectorScale(e,j,O,"x",y))),x>0&&(G=Ri.getLesserNonNegativeNonNull(G,Ri.solveVectorScale(e,j,O,"x",x))),b>0&&(G=Ri.getLesserNonNegativeNonNull(G,Ri.solveVectorScale(e,j,O,"y",b))),T<0&&(G=Ri.getLesserNonNegativeNonNull(G,Ri.solveVectorScale(e,j,O,"y",T)));if(Number.isFinite(G)&&0!==G)return g.zoom=B.zoom+u.at(G),g;Hi()}handleJumpToCenterZoom(e,c){const p=e.center.lat,f=e.applyConstrain(c.center?u.V.convert(c.center):e.center,e.zoom).center;e.setCenter(f.wrap());const m=void 0!==c.zoom?+c.zoom:e.zoom+br(p,f.lat);e.zoom!==m&&e.setZoom(m)}handleEaseTo(e,c){const p=e.zoom,f=e.center,m=e.padding,g={roll:e.roll,pitch:e.pitch,bearing:e.bearing},y={roll:void 0===c.roll?e.roll:c.roll,pitch:void 0===c.pitch?e.pitch:c.pitch,bearing:void 0===c.bearing?e.bearing:c.bearing},x=void 0!==c.zoom,b=!e.isPaddingEqual(c.padding);let T=!1;const S=c.center?u.V.convert(c.center):f,P=e.applyConstrain(S,p).center;$i(e,P);const I=e.clone();I.setCenter(P),I.setZoom(x?+c.zoom:p+br(f.lat,S.lat)),I.setBearing(c.bearing);const C=new u.P(u.an(e.centerPoint.x+c.offsetAsPoint.x,0,e.width),u.an(e.centerPoint.y+c.offsetAsPoint.y,0,e.height));I.setLocationAtPoint(P,C);const R=(c.offset&&c.offsetAsPoint.mag())>0?I.center:P,L=x?+c.zoom:p+br(f.lat,R.lat),F=p+br(f.lat,0),B=L+br(R.lat,0),O=u.bK(f.lng,R.lng),V=u.bK(f.lat,R.lat),j=u.aq(B-F);return T=L!==p,{easeFunc:p=>{if(u.bo(g,y)||Xi({startEulerAngles:g,endEulerAngles:y,tr:e,k:p,useSlerp:g.roll!=y.roll}),b&&e.interpolatePadding(m,c.padding,p),c.around)u.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(c.around,c.aroundPoint);else{const c=B>F?Math.min(2,j):Math.max(.5,j),u=Math.pow(c,1-p),m=Pr(f,O,V,p*u);e.setCenter(m.wrap())}if(T){const c=u.G.number(F,B,p)+br(0,e.center.lat);e.setZoom(c)}},isZooming:T,elevationCenter:R}}handleFlyTo(e,c){const p=void 0!==c.zoom,f=e.center,m=e.zoom,g=e.padding,y=!e.isPaddingEqual(c.padding),x=e.applyConstrain(u.V.convert(c.center||c.locationAtOffset),m).center,b=p?+c.zoom:e.zoom+br(e.center.lat,x.lat),T=e.clone();T.setCenter(x),T.setZoom(b),T.setBearing(c.bearing);const S=new u.P(u.an(e.centerPoint.x+c.offsetAsPoint.x,0,e.width),u.an(e.centerPoint.y+c.offsetAsPoint.y,0,e.height));T.setLocationAtPoint(x,S);const P=T.center;$i(e,P);const I=function(e,c,p){const f=gr(c),m=gr(p),g=u.b5(f,m),y=Math.acos(g),x=pr(e);return y/(2*Math.PI)*x}(e,f,P),C=m+br(f.lat,0),R=b+br(P.lat,0),L=u.aq(R-C);let F;if("number"==typeof c.minZoom){const p=+c.minZoom+br(P.lat,0),f=Math.min(p,C,R)+br(0,P.lat),m=e.applyConstrain(P,f).zoom+br(P.lat,0);F=u.aq(m-C)}const B=u.bK(f.lng,P.lng),O=u.bK(f.lat,P.lat);return{easeFunc:(p,m,x,T)=>{const S=Pr(f,B,O,x);y&&e.interpolatePadding(g,c.padding,p);const I=1===p?P:S;e.setCenter(I.wrap());const R=C+u.at(m);e.setZoom(1===p?b:R+br(0,I.lat))},scaleOfZoom:L,targetCenter:P,scaleOfMinZoom:F,pixelPathLength:I}}static solveVectorScale(e,c,u,p,f){const m="x"===p?[u[0],u[4],u[8],u[12]]:[u[1],u[5],u[9],u[13]],g=[u[3],u[7],u[11],u[15]],y=e[0]*m[0]+e[1]*m[1]+e[2]*m[2],x=e[0]*g[0]+e[1]*g[1]+e[2]*g[2],b=c[0]*m[0]+c[1]*m[1]+c[2]*m[2],T=c[0]*g[0]+c[1]*g[1]+c[2]*g[2];return b+f*x===y+f*T||g[3]*(y-b)+m[3]*(T-x)+y*T==b*x?null:(b+m[3]-f*T-f*g[3])/(b-y-f*T+f*x)}static getLesserNonNegativeNonNull(e,c){return null!==c&&c>=0&&cu.B(e,c&&c.filter((e=>"source.canvas"!==e.identifier))),kr=u.bO();class ki extends u.E{constructor(e,c={}){var p,f;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const c=this.tileManagers[e].getSource().type;"vector"!==c&&"geojson"!==c||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new N(le(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,c)=>this.getGlyphs(e,c))),this.dispatcher.registerMessageHandler("GI",((e,c)=>this.getImages(e,c))),this.dispatcher.registerMessageHandler("GDA",((e,c)=>this.getDashes(e,c))),this.imageManager=new w,this.imageManager.setEventedParent(this);const m=(null===(p=e._container)||void 0===p?void 0:p.lang)||"undefined"!=typeof document&&(null===(f=document.documentElement)||void 0===f?void 0:f.lang)||void 0;this.glyphManager=new M(e._requestManager,c.localIdeographFontFamily,m),this.lineAtlas=new A(256,512),this.crossTileSymbolIndex=new Rt,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",u.bP()),Se().on(be,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const c=this.tileManagers[e.sourceId];if(!c)return;const u=c.getSource();if(u&&u.vectorLayerIds)for(const e in this._layers){const c=this._layers[e];c.source===u.id&&this._validateLayer(c)}}))}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new u.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,c){var p,f,m;this._checkLoaded();const g=null===c?null!==(m=null===(f=null===(p=this.stylesheet.state)||void 0===p?void 0:p[e])||void 0===f?void 0:f.default)&&void 0!==m?m:null:c;if(u.bR(g,this._globalState[e]))return this;this._globalState[e]=g,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const c=[];for(const p in e)!u.bR(this._globalState[p],e[p].default)&&(c.push(p),this._globalState[p]=e[p].default);this._applyGlobalStateChanges(c)}_applyGlobalStateChanges(e){if(0===e.length)return;const c=new Set,u={};for(const p of e){u[p]=this._globalState[p];for(const e in this._layers){const u=this._layers[e],f=u.getLayoutAffectingGlobalStateRefs(),m=u.getPaintAffectingGlobalStateRefs(),g=u.getVisibilityAffectingGlobalStateRefs();if(f.has(p)&&c.add(u.source),m.has(p))for(const{name:e,value:c}of m.get(p))this._updatePaintProperty(u,e,c);(null==g?void 0:g.has(p))&&(u.recalculateVisibility(),this._updateLayer(u))}}this.dispatcher.broadcast("UGS",u);for(const e in this.tileManagers)c.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,c={},p){this.fire(new u.l("dataloading",{dataType:"style"})),c.validate="boolean"!=typeof c.validate||c.validate;const f=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const m=this._loadStyleRequest;u.j(f,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,c,p)})).catch((e=>{this._loadStyleRequest=null,e&&!m.signal.aborted&&this.fire(new u.k(e))}))}loadJSON(e,c={},p){this.fire(new u.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,x.frameAsync(this._frameRequest,this.map._ownerWindow).then((()=>{this._frameRequest=null,c.validate=!1!==c.validate,this._load(e,c,p)})).catch((()=>{}))}loadEmpty(){this.fire(new u.l("dataloading",{dataType:"style"})),this._load(kr,{validate:!1})}_load(e,c,p){var f,m;let g=c.transformStyle?c.transformStyle(p,e):e;if(!c.validate||!zr(this,u.C(g))){g=Object.assign({},g),this._loaded=!0,this.stylesheet=g;for(const e in g.sources)this.addSource(e,g.sources[e],{validate:!1});g.sprite?this._loadSprite(g.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(g.glyphs),this._createLayers(),this.light=new z(this.stylesheet.light),this._setProjectionInternal((null===(f=this.stylesheet.projection)||void 0===f?void 0:f.type)||"mercator"),this.sky=new D(this.stylesheet.sky),this.map.setTerrain(null!==(m=this.stylesheet.terrain)&&void 0!==m?m:null),this.fire(new u.l("data",{dataType:"style"})),this.fire(new u.l("style.load"))}}_createLayers(){var e,c,p;const f=u.bS(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",f),this._order=f.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const e of f){const f=u.bT(e,this._globalState);if(f.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=f,u.bU(f)&&this.tileManagers[f.source]){const u=null!==(p=null===(c=e.paint)||void 0===c?void 0:c["raster-fade-duration"])&&void 0!==p?p:f.paint.get("raster-fade-duration");this.tileManagers[f.source].setRasterFadeDuration(u)}}}_loadSprite(e,c=!1,p=void 0){this.imageManager.setLoaded(!1);const f=new AbortController;let m;this._spriteRequest=f,function(e,c,p,f){return u._(this,void 0,void 0,(function*(){const m=B(e),g=p>1?"@2x":"",y={},b={};for(const{id:e,url:p}of m){const m=c.transformRequest(O(p,g,".json"),"SpriteJSON");y[e]=u.j(m,f);const x=c.transformRequest(O(p,g,".png"),"SpriteImage");b[e]=F.getImage(x,f)}return yield Promise.all([...Object.values(y),...Object.values(b)]),function(e,c){return u._(this,void 0,void 0,(function*(){const u={};for(const p in e){u[p]={};const f=x.getImageCanvasContext((yield c[p]).data),m=(yield e[p]).data;for(const e in m){const{width:c,height:g,x:y,y:x,sdf:b,pixelRatio:T,stretchX:S,stretchY:P,content:I,textFitWidth:C,textFitHeight:R}=m[e];u[p][e]={data:null,pixelRatio:T,sdf:b,stretchX:S,stretchY:P,content:I,textFitWidth:C,textFitHeight:R,spriteData:{width:c,height:g,x:y,y:x,context:f}}}}return u}))}(y,b)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const u in e){this._spritesImagesIds[u]=[];const p=this._spritesImagesIds[u]?this._spritesImagesIds[u].filter((c=>!(c in e))):[];for(const e of p)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const p in e[u]){const f="default"===u?p:`${u}:${p}`;this._spritesImagesIds[u].push(f),f in this.imageManager.images?this.imageManager.updateImage(f,e[u][p],!1):this.imageManager.addImage(f,e[u][p]),c&&(this._changedImages[f]=!0)}}})).catch((e=>{this._spriteRequest=null,m=e,f.signal.aborted||this.fire(new u.k(m))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),c&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new u.l("data",{dataType:"style"})),p&&p(m)}))}_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 u.l("data",{dataType:"style"}))}_validateLayer(e){const c=this.tileManagers[e.source];if(!c)return;const p=e.sourceLayer;if(!p)return;const f=c.getSource();("geojson"===f.type||f.vectorLayerIds&&-1===f.vectorLayerIds.indexOf(p))&&this.fire(new u.k(new Error(`Source layer "${p}" does not exist on source "${f.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,c=!1){const p=this._serializedAllLayers();if(!e||0===e.length)return Object.values(c?u.bV(p):p);const f=[];for(const m of e)if(p[m]){const e=c?u.bV(p[m]):p[m];f.push(e)}return f}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const c=Object.keys(this._layers);for(const u of c){const c=this._layers[u];"custom"!==c.type&&(e[u]=c.serialize())}return e}hasTransitions(){var e,c,u;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(c=this.sky)||void 0===c?void 0:c.hasTransition())return!0;if(null===(u=this.projection)||void 0===u?void 0:u.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 c=this._changed;if(c){const c=Object.keys(this._updatedLayers),u=Object.keys(this._removedLayers);(c.length||u.length)&&this._updateWorkerLayers(c,u);for(const e in this._updatedSources){const c=this._updatedSources[e];if("reload"===c)this._reloadSource(e);else{if("clear"!==c)throw new Error(`Invalid action ${c}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const c in this._updatedPaintProps)this._layers[c].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const p={};for(const e in this.tileManagers){const c=this.tileManagers[e];p[e]=c.used,c.used=!1}for(const c of this._order){const u=this._layers[c];u.recalculate(e,this._availableImages),!u.isHidden(e.zoom)&&u.source&&(this.tileManagers[u.source].used=!0)}for(const e in p){const c=this.tileManagers[e];!!p[e]!=!!c.used&&c.fire(new u.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,c&&this.fire(new u.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const c in this.tileManagers)this.tileManagers[c].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,c){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:c})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,c={}){var p;this._checkLoaded();const f=this.serialize();if(e=c.transformStyle?c.transformStyle(f,e):e,(null===(p=c.validate)||void 0===p||p)&&zr(this,u.C(e)))return!1;(e=u.bV(e)).layers=u.bS(e.layers);const m=u.bW(f,e),g=this._getOperationsToPerform(m);if(g.unimplemented.length>0)throw new Error(`Unimplemented: ${g.unimplemented.join(", ")}.`);if(0===g.operations.length)return!1;for(const e of g.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new u.l("style.load",{style:this})),!0}_getOperationsToPerform(e){const c=[],u=[];for(const p of e)switch(p.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":c.push((()=>this.addLayer.apply(this,p.args)));break;case"removeLayer":c.push((()=>this.removeLayer.apply(this,p.args)));break;case"setPaintProperty":c.push((()=>this.setPaintProperty.apply(this,p.args)));break;case"setLayoutProperty":c.push((()=>this.setLayoutProperty.apply(this,p.args)));break;case"setFilter":c.push((()=>this.setFilter.apply(this,p.args)));break;case"addSource":c.push((()=>this.addSource.apply(this,p.args)));break;case"removeSource":c.push((()=>this.removeSource.apply(this,p.args)));break;case"setLayerZoomRange":c.push((()=>this.setLayerZoomRange.apply(this,p.args)));break;case"setLight":c.push((()=>this.setLight.apply(this,p.args)));break;case"setGeoJSONSourceData":c.push((()=>this.setGeoJSONSourceData.apply(this,p.args)));break;case"setGlyphs":c.push((()=>this.setGlyphs.apply(this,p.args)));break;case"setSprite":c.push((()=>this.setSprite.apply(this,p.args)));break;case"setTerrain":c.push((()=>this.map.setTerrain.apply(this,p.args)));break;case"setSky":c.push((()=>this.setSky.apply(this,p.args)));break;case"setProjection":this.setProjection.apply(this,p.args);break;case"setGlobalState":c.push((()=>this.setGlobalState.apply(this,p.args)));break;case"setTransition":c.push((()=>{}));break;default:u.push(p.command)}return{operations:c,unimplemented:u}}addImage(e,c){if(this.getImage(e))return this.fire(new u.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,c),this._afterImageUpdated(e)}updateImage(e,c){this.imageManager.updateImage(e,c)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new u.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 u.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,c,p={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!c.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(c).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(c.type)>=0&&this._validate(u.C.source,`sources.${e}`,c,null,p))return;this.map&&this.map._collectResourceTiming&&(c.collectResourceTiming=!0);const f=this.tileManagers[e]=new ke(e,c,this.dispatcher);f.style=this,f.setEventedParent(this,(()=>({isSourceLoaded:f.loaded(),source:f.serialize(),sourceId:e}))),f.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 c in this._layers)if(this._layers[c].source===e)return this.fire(new u.k(new Error(`Source "${e}" cannot be removed while layer "${c}" is using it.`)));const c=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],c.fire(new u.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),c.setEventedParent(null),c.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,c){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const u=this.tileManagers[e].getSource();if("geojson"!==u.type)throw new Error(`geojsonSource.type is ${u.type}, which is !== 'geojson`);u.setData(c),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,c,p={}){this._checkLoaded();const f=e.id;if(this.getLayer(f))return void this.fire(new u.k(new Error(`Layer "${f}" already exists on this map.`)));let m;if("custom"===e.type){if(zr(this,u.bX(e)))return;m=u.bT(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(f,e.source),e=u.bV(e),e=u.e(e,{source:f})),this._validate(u.C.layer,`layers.${f}`,e,{arrayIndex:-1},p))return;m=u.bT(e,this._globalState),this._validateLayer(m),m.setEventedParent(this,{layer:{id:f}})}const g=c?this._order.indexOf(c):this._order.length;if(c&&-1===g)this.fire(new u.k(new Error(`Cannot add layer "${f}" before non-existing layer "${c}".`)));else{if(this._order.splice(g,0,f),this._layerOrderChanged=!0,this._layers[f]=m,this._removedLayers[f]&&m.source&&"custom"!==m.type){const e=this._removedLayers[f];delete this._removedLayers[f],e.type!==m.type?this._updatedSources[m.source]="clear":(this._updatedSources[m.source]="reload",this.tileManagers[m.source].pause())}this._updateLayer(m),m.onAdd&&m.onAdd(this.map)}}moveLayer(e,c){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new u.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===c)return;const p=this._order.indexOf(e);this._order.splice(p,1);const f=c?this._order.indexOf(c):this._order.length;c&&-1===f?this.fire(new u.k(new Error(`Cannot move layer "${e}" before non-existing layer "${c}".`))):(this._order.splice(f,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const c=this._layers[e];if(!c)return void this.fire(new u.k(new Error(`Cannot remove non-existing layer "${e}".`)));c.setEventedParent(null);const p=this._order.indexOf(e);this._order.splice(p,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=c,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],c.onRemove&&c.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,c,p){this._checkLoaded();const f=this.getLayer(e);f?f.minzoom===c&&f.maxzoom===p||(null!=c&&(f.minzoom=c),null!=p&&(f.maxzoom=p),this._updateLayer(f)):this.fire(new u.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,c,p={}){this._checkLoaded();const f=this.getLayer(e);if(f){if(!u.bR(f.filter,c))return null==c?(f.setFilter(void 0),void this._updateLayer(f)):void(this._validate(u.C.filter,`layers.${f.id}.filter`,c,null,p)||(f.setFilter(u.bV(c)),this._updateLayer(f)))}else this.fire(new u.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return u.bV(this.getLayer(e).filter)}setLayoutProperty(e,c,p,f={}){this._checkLoaded();const m=this.getLayer(e);m?u.bR(m.getLayoutProperty(c),p)||(m.setLayoutProperty(c,p,f),this._updateLayer(m)):this.fire(new u.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,c){const p=this.getLayer(e);if(p)return p.getLayoutProperty(c);this.fire(new u.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,c,p,f={}){this._checkLoaded();const m=this.getLayer(e);m?u.bR(m.getPaintProperty(c),p)||this._updatePaintProperty(m,c,p,f):this.fire(new u.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,c,p,f={}){e.setPaintProperty(c,p,f)&&this._updateLayer(e),u.bU(e)&&"raster-fade-duration"===c&&this.tileManagers[e.source].setRasterFadeDuration(p),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,c){return this.getLayer(e).getPaintProperty(c)}setFeatureState(e,c){this._checkLoaded();const p=e.source,f=e.sourceLayer,m=this.tileManagers[p];if(void 0===m)return void this.fire(new u.k(new Error(`The source '${p}' does not exist in the map's style.`)));const g=m.getSource().type;"geojson"===g&&f?this.fire(new u.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==g||f?(void 0===e.id&&this.fire(new u.k(new Error("The feature id parameter must be provided."))),m.setFeatureState(f,e.id,c)):this.fire(new u.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,c){this._checkLoaded();const p=e.source,f=this.tileManagers[p];if(void 0===f)return void this.fire(new u.k(new Error(`The source '${p}' does not exist in the map's style.`)));const m=f.getSource().type,g="vector"===m?e.sourceLayer:void 0;"vector"!==m||g?c&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new u.k(new Error("A feature id is required to remove its specific state property."))):f.removeFeatureState(g,e.id,c):this.fire(new u.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const c=e.source,p=e.sourceLayer,f=this.tileManagers[c];if(void 0!==f)return"vector"!==f.getSource().type||p?(void 0===e.id&&this.fire(new u.k(new Error("The feature id parameter must be provided."))),f.getFeatureState(p,e.id)):void this.fire(new u.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new u.k(new Error(`The source '${c}' does not exist in the map's style.`)))}getTransition(){return u.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=u.bY(this.tileManagers,(e=>e.serialize())),c=this._serializeByIds(this._order,!0),p=this.map.getTerrain()||void 0,f=this.stylesheet;return u.bZ({version:f.version,name:f.name,metadata:f.metadata,light:f.light,sky:f.sky,center:f.center,zoom:f.zoom,bearing:f.bearing,pitch:f.pitch,sprite:f.sprite,glyphs:f.glyphs,transition:f.transition,projection:f.projection,sources:e,layers:c,terrain:p},(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 c=e=>"fill-extrusion"===this._layers[e].type,u={},p=[];for(let f=this._order.length-1;f>=0;f--){const m=this._order[f];if(c(m)){u[m]=f;for(const c of e){const e=c[m];if(e)for(const c of e)p.push(c)}}}p.sort(((e,c)=>c.intersectionZ-e.intersectionZ));const f=[];for(let m=this._order.length-1;m>=0;m--){const g=this._order[m];if(c(g))for(let e=p.length-1;e>=0;e--){const c=p[e].feature;if(u[c.layer.id]this.map.terrain.getElevation(e,c,u):void 0));return this.placement&&m.push(function(e,c,u,p,f,m,g){const y={},x=m.queryRenderedSymbols(p),b=[];for(const e of Object.keys(x).map(Number))b.push(g[e]);b.sort(pe);for(const u of b){const p=u.featureIndex.lookupSymbolFeatures(x[u.bucketInstanceId],c,u.bucketIndex,u.sourceLayerIndex,{filterSpec:f.filter,globalState:f.globalState},f.layers,f.availableImages,e);for(const e in p){const c=y[e]=y[e]||[],f=p[e];f.sort(((e,c)=>{const p=u.featureSortOrder;if(p){const u=p.indexOf(e.featureIndex);return p.indexOf(c.featureIndex)-u}return c.featureIndex-e.featureIndex}));for(const e of f)c.push(e)}}return function(e,c,u){for(const p in e)for(const f of e[p])fe(f,u[c[p].source]);return e}(y,e,u)}(this._layers,g,this.tileManagers,e,x,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(m)}querySourceFeatures(e,c){(null==c?void 0:c.filter)&&this._validate(u.C.filter,"querySourceFeatures.filter",c.filter,null,c);const p=this.tileManagers[e];return p?function(e,c){const u=e.getRenderableIds().map((c=>e.getTileByID(c))),p=[],f={};for(let e=0;ee.getTileByID(c))).sort(((e,c)=>c.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(c.tileID)?-1:1)))}const p=this.crossTileSymbolIndex.addLayer(u,y[u.source],e.center.lng);m=m||p}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((f=f||this._layerOrderChanged||0===u)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(T(),e.zoom))&&(this.pauseablePlacement=new It(e,this.map.terrain,this._order,f,c,u,p,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,y),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(T()),g=!0),m&&this.pauseablePlacement.placement.setStale()),g||m)for(const e of this._order){const c=this._layers[e];"symbol"===c.type&&this.placement.updateLayerOpacities(c,y[c.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(T())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,c){return u._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(c.icons);this._updateTilesForChangedImages();const u=this.tileManagers[c.source];return u&&u.setDependencies(c.tileID.key,c.type,c.icons),e}))}getGlyphs(e,c){return u._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(c.stacks),u=this.tileManagers[c.source];return u&&u.setDependencies(c.tileID.key,c.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,c={}){this._checkLoaded(),e&&this._validate(u.C.glyphs,"glyphs",e,null,c)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,c){return u._(this,void 0,void 0,(function*(){const e={};for(const[u,p]of Object.entries(c.dashes))e[u]=this.lineAtlas.getDash(p.dasharray,p.round);return e}))}addSprite(e,c,p={},f){this._checkLoaded();const m=[{id:e,url:c}],g=[...B(this.stylesheet.sprite),...m];this._validate(u.C.sprite,"sprite",g,null,p)||(this.stylesheet.sprite=g,this._loadSprite(m,!0,f))}removeSprite(e){this._checkLoaded();const c=B(this.stylesheet.sprite);if(c.find((c=>c.id===e))){if(this._spritesImagesIds[e])for(const c of this._spritesImagesIds[e])this.imageManager.removeImage(c),this._changedImages[c]=!0;c.splice(c.findIndex((c=>c.id===e)),1),this.stylesheet.sprite=c.length>0?c:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new u.l("data",{dataType:"style"}))}else this.fire(new u.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return B(this.stylesheet.sprite)}setSprite(e,c={},p){this._checkLoaded(),e&&this._validate(u.C.sprite,"sprite",e,null,c)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,p):(this._unloadSprite(),p&&p(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 c=this.tileManagers[e];c.setEventedParent(null),c.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 c=this._layers[e];c.setEventedParent(null),c.onRemove&&c.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 Rr=u.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,c,u,p,f,m,g,y,x){this.context=e;let b=this.boundPaintVertexBuffers.length!==p.length;for(let e=0;!b&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:c,u_fog_color:p?p.properties.get("fog-color"):u.bp.white,u_fog_ground_blend:p?p.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:m?0:p?p.calculateFogBlendOpacity(f):0,u_horizon_color:p?p.properties.get("horizon-color"):u.bp.white,u_horizon_fog_blend:p?p.properties.get("horizon-fog-blend"):1,u_is_globe_mode:m?1:0}),Br={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 Or(e){const c=[];for(let u=0;u({u_depth:new u.b_(e,c.u_depth),u_terrain:new u.b_(e,c.u_terrain),u_terrain_dim:new u.bq(e,c.u_terrain_dim),u_terrain_matrix:new u.c0(e,c.u_terrain_matrix),u_terrain_unpack:new u.c1(e,c.u_terrain_unpack),u_terrain_exaggeration:new u.bq(e,c.u_terrain_exaggeration)}))(e,Z),this.projectionUniforms=((e,c)=>({u_projection_matrix:new u.c0(e,c.u_projection_matrix),u_projection_tile_mercator_coords:new u.c1(e,c.u_projection_tile_mercator_coords),u_projection_clipping_plane:new u.c1(e,c.u_projection_clipping_plane),u_projection_transition:new u.bq(e,c.u_projection_transition),u_projection_fallback_matrix:new u.c0(e,c.u_projection_fallback_matrix)}))(e,Z),this.binderUniforms=p?p.getUniforms(e,Z):[]}draw(e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,L,F,B){const O=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(u),e.setStencilMode(p),e.setColorMode(f),e.setCullFace(m),y){e.activeTexture.set(O.TEXTURE2),O.bindTexture(O.TEXTURE_2D,y.depthTexture),e.activeTexture.set(O.TEXTURE3),O.bindTexture(O.TEXTURE_2D,y.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(y[e])}if(x)for(const e in x)this.projectionUniforms[Br[e]].set(x[e]);if(g)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(g[e]);R&&R.setUniforms(e,this.binderUniforms,I,{zoom:C});let V=0;switch(c){case O.LINES:V=2;break;case O.TRIANGLES:V=3;break;case O.LINE_STRIP:V=1}for(const u of P.get()){const p=u.vaos||(u.vaos={});(p[b]||(p[b]=new Bi)).bind(e,this,T,R?R.getPaintVertexBuffers():[],S,u.vertexOffset,L,F,B),O.drawElements(c,u.primitiveLength*V,O.UNSIGNED_SHORT,u.primitiveOffset*V*2)}}}function Vr(e,c,p){const f=1/u.aN(p,1,c.transform.tileZoom),m=Math.pow(2,p.tileID.overscaledZ),g=p.tileSize*Math.pow(2,c.transform.tileZoom)/m,y=g*(p.tileID.canonical.x+p.tileID.wrap*m),x=g*p.tileID.canonical.y;return{u_image:0,u_texsize:p.imageAtlasTexture.size,u_scale:[f,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[y>>16,x>>16],u_pixel_coord_lower:[65535&y,65535&x]}}const jr=(e,c,p,f)=>{const m=e.style.light,g=m.properties.get("position"),y=[g.x,g.y,g.z],x=u.c4();"viewport"===m.properties.get("anchor")&&u.c5(x,e.transform.bearingInRadians),u.c6(y,y,x);const b=e.transform.transformLightDirection(y),T=m.properties.get("color");return{u_lightpos:y,u_lightpos_globe:b,u_lightintensity:m.properties.get("intensity"),u_lightcolor:[T.r,T.g,T.b],u_vertical_gradient:+c,u_opacity:p,u_fill_translate:f}},Nr=(e,c,p,f,m,g,y)=>u.e(jr(e,c,p,f),Vr(g,e,y),{u_height_factor:-Math.pow(2,m.overscaledZ)/y.tileSize/8}),Gr=(e,c,p,f)=>u.e(Vr(c,e,p),{u_fill_translate:f}),Ur=(e,c)=>({u_world:e,u_fill_translate:c}),Zr=(e,c,p,f,m)=>u.e(Gr(e,c,p,m),{u_world:f}),Wr=(e,c,p,f,m)=>{const g=e.transform;let y,x,b=0;if("map"===p.paint.get("circle-pitch-alignment")){const e=u.aN(c,1,g.zoom);y=!0,x=[e,e],b=e/(u.a5*Math.pow(2,c.tileID.overscaledZ))*2*Math.PI*m}else y=!1,x=g.pixelsToGLUnits;return{u_camera_to_center_distance:g.cameraToCenterDistance,u_scale_with_map:+("map"===p.paint.get("circle-pitch-scale")),u_pitch_with_map:+y,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:x,u_globe_extrude_scale:b,u_translate:f}},Xr=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Yr=e=>({u_viewport_size:[e.width,e.height]}),Kr=(e,c=1)=>({u_color:e,u_overlay:0,u_overlay_scale:c}),Qr=(e,c,p,f)=>{const m=u.aN(e,1,c)/(u.a5*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*f;return{u_extrude_scale:u.aN(e,1,c),u_intensity:p,u_globe_extrude_scale:m}},Jr=(e,c,p,f)=>{const m=u.N();u.c7(m,0,e.width,e.height,0,0,1);const g=e.context.gl;return{u_matrix:m,u_world:[g.drawingBufferWidth,g.drawingBufferHeight],u_image:p,u_color_ramp:f,u_opacity:c.paint.get("heatmap-opacity")}},en=(e,c,u)=>{const p=u.paint.get("hillshade-accent-color");let f;switch(u.paint.get("hillshade-method")){case"basic":f=4;break;case"combined":f=1;break;case"igor":f=2;break;case"multidirectional":f=3;break;default:f=0}const m=u.getIlluminationProperties();for(let c=0;c{const p=c.stride,f=u.N();return u.c7(f,0,u.a5,-u.a5,0,0,1),u.O(f,f,[0,-u.a5,0]),{u_matrix:f,u_image:1,u_dimension:[p,p],u_zoom:e.overscaledZ,u_unpack:c.getUnpackVector()}};function rn(e,c){const p=Math.pow(2,c.canonical.z),f=c.canonical.y;return[new u.a9(0,f/p).toLngLat().lat,new u.a9(0,(f+1)/p).toLngLat().lat]}const nn=(e,c,u=0)=>({u_image:0,u_unpack:c.getUnpackVector(),u_dimension:[c.stride,c.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:u,u_opacity:e.paint.get("color-relief-opacity")}),sn=(e,c,p,f)=>{const m=e.transform;return{u_translation:dn(e,c,p),u_ratio:f/u.aN(c,1,m.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/m.pixelsToGLUnits[0],1/m.pixelsToGLUnits[1]]}},an=(e,c,p,f,m)=>u.e(sn(e,c,p,f),{u_image:0,u_image_height:m}),ln=(e,c,p,f,m)=>{const g=e.transform,y=un(c,g);return{u_translation:dn(e,c,p),u_texsize:c.imageAtlasTexture.size,u_ratio:f/u.aN(c,1,g.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[y,m.fromScale,m.toScale],u_fade:m.t,u_units_to_pixels:[1/g.pixelsToGLUnits[0],1/g.pixelsToGLUnits[1]]}},cn=(e,c,p,f,m)=>{const g=un(c,e.transform);return u.e(sn(e,c,p,f),{u_tileratio:g,u_crossfade_from:m.fromScale,u_crossfade_to:m.toScale,u_image:0,u_mix:m.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},hn=(e,c,p,f,m,g)=>{const y=un(c,e.transform);return u.e(sn(e,c,p,f),{u_image:0,u_image_height:g,u_tileratio:y,u_crossfade_from:m.fromScale,u_crossfade_to:m.toScale,u_image_dash:1,u_mix:m.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function un(e,c){return 1/u.aN(e,1,c.tileZoom)}function dn(e,c,p){return u.aO(e.transform,c,p.paint.get("line-translate"),p.paint.get("line-translate-anchor"))}const pn=(e,c,u,p,f)=>{return{u_tl_parent:e,u_scale_parent:c,u_buffer_scale:1,u_fade_t:u.mix,u_opacity:u.opacity*p.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:p.paint.get("raster-brightness-min"),u_brightness_high:p.paint.get("raster-brightness-max"),u_saturation_factor:(g=p.paint.get("raster-saturation"),g>0?1-1/(1.001-g):-g),u_contrast_factor:(m=p.paint.get("raster-contrast"),m>0?1/(1-m):1+m),u_spin_weights:fn(p.paint.get("raster-hue-rotate")),u_coords_top:[f[0].x,f[0].y,f[1].x,f[1].y],u_coords_bottom:[f[3].x,f[3].y,f[2].x,f[2].y]};var m,g};function fn(e){e*=Math.PI/180;const c=Math.sin(e),u=Math.cos(e);return[(2*u+1)/3,(-Math.sqrt(3)*c-u+1)/3,(Math.sqrt(3)*c-u+1)/3]}const mn=(e,c,u,p,f,m,g,y,x,b,T,S,P)=>{const I=g.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:c?c.uSizeT:0,u_size:c?c.uSize:0,u_camera_to_center_distance:I.cameraToCenterDistance,u_pitch:I.pitch/360*2*Math.PI,u_rotate_symbol:+u,u_aspect_ratio:I.width/I.height,u_fade_change:g.options.fadeDuration?g.symbolFadeChange:1,u_label_plane_matrix:y,u_coord_matrix:x,u_is_text:+T,u_pitch_with_map:+p,u_is_along_line:f,u_is_variable_anchor:m,u_texsize:S,u_texture:0,u_translation:b,u_pitched_scale:P}},_n=(e,c,p,f,m,g,y,x,b,T,S,P,I,C)=>{const R=y.transform;return u.e(mn(e,c,p,f,m,g,y,x,b,T,S,P,C),{u_gamma_scale:f?Math.cos(R.pitch*Math.PI/180)*R.cameraToCenterDistance:1,u_device_pixel_ratio:y.pixelRatio,u_is_halo:1})},gn=(e,c,p,f,m,g,y,x,b,T,S,P,I)=>u.e(_n(e,c,p,f,m,g,y,x,b,T,!0,S,0,I),{u_texsize_icon:P,u_texture_icon:1}),yn=(e,c)=>({u_opacity:e,u_color:c}),xn=(e,c,p,f,m)=>u.e(function(e,c,p,f){const m=p.imageManager.getPattern(e.from.toString()),g=p.imageManager.getPattern(e.to.toString()),{width:y,height:x}=p.imageManager.getPixelSize(),b=Math.pow(2,f.tileID.overscaledZ),T=f.tileSize*Math.pow(2,p.transform.tileZoom)/b,S=T*(f.tileID.canonical.x+f.tileID.wrap*b),P=T*f.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:m.tl,u_pattern_br_a:m.br,u_pattern_tl_b:g.tl,u_pattern_br_b:g.br,u_texsize:[y,x],u_mix:c.t,u_pattern_size_a:m.displaySize,u_pattern_size_b:g.displaySize,u_scale_a:c.fromScale,u_scale_b:c.toScale,u_tile_units_to_pixels:1/u.aN(f,1,p.transform.tileZoom),u_pixel_coord_upper:[S>>16,P>>16],u_pixel_coord_lower:[65535&S,65535&P]}}(p,m,c,f),{u_opacity:e}),vn=(e,c)=>{},bn={fillExtrusion:(e,c)=>({u_lightpos:new u.c2(e,c.u_lightpos),u_lightpos_globe:new u.c2(e,c.u_lightpos_globe),u_lightintensity:new u.bq(e,c.u_lightintensity),u_lightcolor:new u.c2(e,c.u_lightcolor),u_vertical_gradient:new u.bq(e,c.u_vertical_gradient),u_opacity:new u.bq(e,c.u_opacity),u_fill_translate:new u.c3(e,c.u_fill_translate)}),fillExtrusionPattern:(e,c)=>({u_lightpos:new u.c2(e,c.u_lightpos),u_lightpos_globe:new u.c2(e,c.u_lightpos_globe),u_lightintensity:new u.bq(e,c.u_lightintensity),u_lightcolor:new u.c2(e,c.u_lightcolor),u_vertical_gradient:new u.bq(e,c.u_vertical_gradient),u_height_factor:new u.bq(e,c.u_height_factor),u_opacity:new u.bq(e,c.u_opacity),u_fill_translate:new u.c3(e,c.u_fill_translate),u_image:new u.b_(e,c.u_image),u_texsize:new u.c3(e,c.u_texsize),u_pixel_coord_upper:new u.c3(e,c.u_pixel_coord_upper),u_pixel_coord_lower:new u.c3(e,c.u_pixel_coord_lower),u_scale:new u.c2(e,c.u_scale),u_fade:new u.bq(e,c.u_fade)}),fill:(e,c)=>({u_fill_translate:new u.c3(e,c.u_fill_translate)}),fillPattern:(e,c)=>({u_image:new u.b_(e,c.u_image),u_texsize:new u.c3(e,c.u_texsize),u_pixel_coord_upper:new u.c3(e,c.u_pixel_coord_upper),u_pixel_coord_lower:new u.c3(e,c.u_pixel_coord_lower),u_scale:new u.c2(e,c.u_scale),u_fade:new u.bq(e,c.u_fade),u_fill_translate:new u.c3(e,c.u_fill_translate)}),fillOutline:(e,c)=>({u_world:new u.c3(e,c.u_world),u_fill_translate:new u.c3(e,c.u_fill_translate)}),fillOutlinePattern:(e,c)=>({u_world:new u.c3(e,c.u_world),u_image:new u.b_(e,c.u_image),u_texsize:new u.c3(e,c.u_texsize),u_pixel_coord_upper:new u.c3(e,c.u_pixel_coord_upper),u_pixel_coord_lower:new u.c3(e,c.u_pixel_coord_lower),u_scale:new u.c2(e,c.u_scale),u_fade:new u.bq(e,c.u_fade),u_fill_translate:new u.c3(e,c.u_fill_translate)}),circle:(e,c)=>({u_camera_to_center_distance:new u.bq(e,c.u_camera_to_center_distance),u_scale_with_map:new u.b_(e,c.u_scale_with_map),u_pitch_with_map:new u.b_(e,c.u_pitch_with_map),u_extrude_scale:new u.c3(e,c.u_extrude_scale),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_globe_extrude_scale:new u.bq(e,c.u_globe_extrude_scale),u_translate:new u.c3(e,c.u_translate)}),collisionBox:(e,c)=>({u_pixel_extrude_scale:new u.c3(e,c.u_pixel_extrude_scale)}),collisionCircle:(e,c)=>({u_viewport_size:new u.c3(e,c.u_viewport_size)}),debug:(e,c)=>({u_color:new u.b$(e,c.u_color),u_overlay:new u.b_(e,c.u_overlay),u_overlay_scale:new u.bq(e,c.u_overlay_scale)}),depth:vn,clippingMask:vn,heatmap:(e,c)=>({u_extrude_scale:new u.bq(e,c.u_extrude_scale),u_intensity:new u.bq(e,c.u_intensity),u_globe_extrude_scale:new u.bq(e,c.u_globe_extrude_scale)}),heatmapTexture:(e,c)=>({u_matrix:new u.c0(e,c.u_matrix),u_world:new u.c3(e,c.u_world),u_image:new u.b_(e,c.u_image),u_color_ramp:new u.b_(e,c.u_color_ramp),u_opacity:new u.bq(e,c.u_opacity)}),hillshade:(e,c)=>({u_image:new u.b_(e,c.u_image),u_latrange:new u.c3(e,c.u_latrange),u_exaggeration:new u.bq(e,c.u_exaggeration),u_altitudes:new u.c9(e,c.u_altitudes),u_azimuths:new u.c9(e,c.u_azimuths),u_accent:new u.b$(e,c.u_accent),u_method:new u.b_(e,c.u_method),u_shadows:new u.c8(e,c.u_shadows),u_highlights:new u.c8(e,c.u_highlights)}),hillshadePrepare:(e,c)=>({u_matrix:new u.c0(e,c.u_matrix),u_image:new u.b_(e,c.u_image),u_dimension:new u.c3(e,c.u_dimension),u_zoom:new u.bq(e,c.u_zoom),u_unpack:new u.c1(e,c.u_unpack)}),colorRelief:(e,c)=>({u_image:new u.b_(e,c.u_image),u_unpack:new u.c1(e,c.u_unpack),u_dimension:new u.c3(e,c.u_dimension),u_elevation_stops:new u.b_(e,c.u_elevation_stops),u_color_stops:new u.b_(e,c.u_color_stops),u_color_ramp_size:new u.b_(e,c.u_color_ramp_size),u_opacity:new u.bq(e,c.u_opacity)}),line:(e,c)=>({u_translation:new u.c3(e,c.u_translation),u_ratio:new u.bq(e,c.u_ratio),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_units_to_pixels:new u.c3(e,c.u_units_to_pixels)}),lineGradient:(e,c)=>({u_translation:new u.c3(e,c.u_translation),u_ratio:new u.bq(e,c.u_ratio),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_units_to_pixels:new u.c3(e,c.u_units_to_pixels),u_image:new u.b_(e,c.u_image),u_image_height:new u.bq(e,c.u_image_height)}),linePattern:(e,c)=>({u_translation:new u.c3(e,c.u_translation),u_texsize:new u.c3(e,c.u_texsize),u_ratio:new u.bq(e,c.u_ratio),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_image:new u.b_(e,c.u_image),u_units_to_pixels:new u.c3(e,c.u_units_to_pixels),u_scale:new u.c2(e,c.u_scale),u_fade:new u.bq(e,c.u_fade)}),lineSDF:(e,c)=>({u_translation:new u.c3(e,c.u_translation),u_ratio:new u.bq(e,c.u_ratio),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_units_to_pixels:new u.c3(e,c.u_units_to_pixels),u_image:new u.b_(e,c.u_image),u_mix:new u.bq(e,c.u_mix),u_tileratio:new u.bq(e,c.u_tileratio),u_crossfade_from:new u.bq(e,c.u_crossfade_from),u_crossfade_to:new u.bq(e,c.u_crossfade_to),u_lineatlas_width:new u.bq(e,c.u_lineatlas_width),u_lineatlas_height:new u.bq(e,c.u_lineatlas_height)}),lineGradientSDF:(e,c)=>({u_translation:new u.c3(e,c.u_translation),u_ratio:new u.bq(e,c.u_ratio),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_units_to_pixels:new u.c3(e,c.u_units_to_pixels),u_image:new u.b_(e,c.u_image),u_image_height:new u.bq(e,c.u_image_height),u_tileratio:new u.bq(e,c.u_tileratio),u_crossfade_from:new u.bq(e,c.u_crossfade_from),u_crossfade_to:new u.bq(e,c.u_crossfade_to),u_image_dash:new u.b_(e,c.u_image_dash),u_mix:new u.bq(e,c.u_mix),u_lineatlas_width:new u.bq(e,c.u_lineatlas_width),u_lineatlas_height:new u.bq(e,c.u_lineatlas_height)}),raster:(e,c)=>({u_tl_parent:new u.c3(e,c.u_tl_parent),u_scale_parent:new u.bq(e,c.u_scale_parent),u_buffer_scale:new u.bq(e,c.u_buffer_scale),u_fade_t:new u.bq(e,c.u_fade_t),u_opacity:new u.bq(e,c.u_opacity),u_image0:new u.b_(e,c.u_image0),u_image1:new u.b_(e,c.u_image1),u_brightness_low:new u.bq(e,c.u_brightness_low),u_brightness_high:new u.bq(e,c.u_brightness_high),u_saturation_factor:new u.bq(e,c.u_saturation_factor),u_contrast_factor:new u.bq(e,c.u_contrast_factor),u_spin_weights:new u.c2(e,c.u_spin_weights),u_coords_top:new u.c1(e,c.u_coords_top),u_coords_bottom:new u.c1(e,c.u_coords_bottom)}),symbolIcon:(e,c)=>({u_is_size_zoom_constant:new u.b_(e,c.u_is_size_zoom_constant),u_is_size_feature_constant:new u.b_(e,c.u_is_size_feature_constant),u_size_t:new u.bq(e,c.u_size_t),u_size:new u.bq(e,c.u_size),u_camera_to_center_distance:new u.bq(e,c.u_camera_to_center_distance),u_pitch:new u.bq(e,c.u_pitch),u_rotate_symbol:new u.b_(e,c.u_rotate_symbol),u_aspect_ratio:new u.bq(e,c.u_aspect_ratio),u_fade_change:new u.bq(e,c.u_fade_change),u_label_plane_matrix:new u.c0(e,c.u_label_plane_matrix),u_coord_matrix:new u.c0(e,c.u_coord_matrix),u_is_text:new u.b_(e,c.u_is_text),u_pitch_with_map:new u.b_(e,c.u_pitch_with_map),u_is_along_line:new u.b_(e,c.u_is_along_line),u_is_variable_anchor:new u.b_(e,c.u_is_variable_anchor),u_texsize:new u.c3(e,c.u_texsize),u_texture:new u.b_(e,c.u_texture),u_translation:new u.c3(e,c.u_translation),u_pitched_scale:new u.bq(e,c.u_pitched_scale)}),symbolSDF:(e,c)=>({u_is_size_zoom_constant:new u.b_(e,c.u_is_size_zoom_constant),u_is_size_feature_constant:new u.b_(e,c.u_is_size_feature_constant),u_size_t:new u.bq(e,c.u_size_t),u_size:new u.bq(e,c.u_size),u_camera_to_center_distance:new u.bq(e,c.u_camera_to_center_distance),u_pitch:new u.bq(e,c.u_pitch),u_rotate_symbol:new u.b_(e,c.u_rotate_symbol),u_aspect_ratio:new u.bq(e,c.u_aspect_ratio),u_fade_change:new u.bq(e,c.u_fade_change),u_label_plane_matrix:new u.c0(e,c.u_label_plane_matrix),u_coord_matrix:new u.c0(e,c.u_coord_matrix),u_is_text:new u.b_(e,c.u_is_text),u_pitch_with_map:new u.b_(e,c.u_pitch_with_map),u_is_along_line:new u.b_(e,c.u_is_along_line),u_is_variable_anchor:new u.b_(e,c.u_is_variable_anchor),u_texsize:new u.c3(e,c.u_texsize),u_texture:new u.b_(e,c.u_texture),u_gamma_scale:new u.bq(e,c.u_gamma_scale),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_is_halo:new u.b_(e,c.u_is_halo),u_translation:new u.c3(e,c.u_translation),u_pitched_scale:new u.bq(e,c.u_pitched_scale)}),symbolTextAndIcon:(e,c)=>({u_is_size_zoom_constant:new u.b_(e,c.u_is_size_zoom_constant),u_is_size_feature_constant:new u.b_(e,c.u_is_size_feature_constant),u_size_t:new u.bq(e,c.u_size_t),u_size:new u.bq(e,c.u_size),u_camera_to_center_distance:new u.bq(e,c.u_camera_to_center_distance),u_pitch:new u.bq(e,c.u_pitch),u_rotate_symbol:new u.b_(e,c.u_rotate_symbol),u_aspect_ratio:new u.bq(e,c.u_aspect_ratio),u_fade_change:new u.bq(e,c.u_fade_change),u_label_plane_matrix:new u.c0(e,c.u_label_plane_matrix),u_coord_matrix:new u.c0(e,c.u_coord_matrix),u_is_text:new u.b_(e,c.u_is_text),u_pitch_with_map:new u.b_(e,c.u_pitch_with_map),u_is_along_line:new u.b_(e,c.u_is_along_line),u_is_variable_anchor:new u.b_(e,c.u_is_variable_anchor),u_texsize:new u.c3(e,c.u_texsize),u_texsize_icon:new u.c3(e,c.u_texsize_icon),u_texture:new u.b_(e,c.u_texture),u_texture_icon:new u.b_(e,c.u_texture_icon),u_gamma_scale:new u.bq(e,c.u_gamma_scale),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_is_halo:new u.b_(e,c.u_is_halo),u_translation:new u.c3(e,c.u_translation),u_pitched_scale:new u.bq(e,c.u_pitched_scale)}),background:(e,c)=>({u_opacity:new u.bq(e,c.u_opacity),u_color:new u.b$(e,c.u_color)}),backgroundPattern:(e,c)=>({u_opacity:new u.bq(e,c.u_opacity),u_image:new u.b_(e,c.u_image),u_pattern_tl_a:new u.c3(e,c.u_pattern_tl_a),u_pattern_br_a:new u.c3(e,c.u_pattern_br_a),u_pattern_tl_b:new u.c3(e,c.u_pattern_tl_b),u_pattern_br_b:new u.c3(e,c.u_pattern_br_b),u_texsize:new u.c3(e,c.u_texsize),u_mix:new u.bq(e,c.u_mix),u_pattern_size_a:new u.c3(e,c.u_pattern_size_a),u_pattern_size_b:new u.c3(e,c.u_pattern_size_b),u_scale_a:new u.bq(e,c.u_scale_a),u_scale_b:new u.bq(e,c.u_scale_b),u_pixel_coord_upper:new u.c3(e,c.u_pixel_coord_upper),u_pixel_coord_lower:new u.c3(e,c.u_pixel_coord_lower),u_tile_units_to_pixels:new u.bq(e,c.u_tile_units_to_pixels)}),terrain:(e,c)=>({u_texture:new u.b_(e,c.u_texture),u_ele_delta:new u.bq(e,c.u_ele_delta),u_fog_matrix:new u.c0(e,c.u_fog_matrix),u_fog_color:new u.b$(e,c.u_fog_color),u_fog_ground_blend:new u.bq(e,c.u_fog_ground_blend),u_fog_ground_blend_opacity:new u.bq(e,c.u_fog_ground_blend_opacity),u_horizon_color:new u.b$(e,c.u_horizon_color),u_horizon_fog_blend:new u.bq(e,c.u_horizon_fog_blend),u_is_globe_mode:new u.bq(e,c.u_is_globe_mode)}),terrainDepth:(e,c)=>({u_ele_delta:new u.bq(e,c.u_ele_delta)}),terrainCoords:(e,c)=>({u_texture:new u.b_(e,c.u_texture),u_terrain_coords_id:new u.bq(e,c.u_terrain_coords_id),u_ele_delta:new u.bq(e,c.u_ele_delta)}),projectionErrorMeasurement:(e,c)=>({u_input:new u.bq(e,c.u_input),u_output_expected:new u.bq(e,c.u_output_expected)}),atmosphere:(e,c)=>({u_sun_pos:new u.c2(e,c.u_sun_pos),u_atmosphere_blend:new u.bq(e,c.u_atmosphere_blend),u_globe_position:new u.c2(e,c.u_globe_position),u_globe_radius:new u.bq(e,c.u_globe_radius),u_inv_proj_matrix:new u.c0(e,c.u_inv_proj_matrix)}),sky:(e,c)=>({u_sky_color:new u.b$(e,c.u_sky_color),u_horizon_color:new u.b$(e,c.u_horizon_color),u_horizon:new u.c3(e,c.u_horizon),u_horizon_normal:new u.c3(e,c.u_horizon_normal),u_sky_horizon_blend:new u.bq(e,c.u_sky_horizon_blend),u_sky_blend:new u.bq(e,c.u_sky_blend)})};class ba{constructor(e,c,u){this.context=e;const p=e.gl;this.buffer=p.createBuffer(),this.dynamicDraw=Boolean(u),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),p.bufferData(p.ELEMENT_ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?p.DYNAMIC_DRAW:p.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const c=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),c.bufferSubData(c.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const wn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class wa{constructor(e,c,u,p){this.length=c.length,this.attributes=u,this.itemSize=c.bytesPerElement,this.dynamicDraw=p,this.context=e;const f=e.gl;this.buffer=f.createBuffer(),e.bindVertexBuffer.set(this.buffer),f.bufferData(f.ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||delete c.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 c=this.context.gl;this.bind(),c.bufferSubData(c.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,c){for(let u=0;u0&&(T.push({circleArray:L,circleOffset:P,coord:I}),S+=L.length/4,P=S),R&&b.draw(g,x.LINES,ti.disabled,ai.disabled,e.colorModeForRenderPass(),ei.disabled,Xr(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(I),y.getProjectionData({overscaledTileID:I,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),p.id,R.layoutVertexBuffer,R.indexBuffer,R.segments,null,e.transform.zoom,null,null,R.collisionVertexBuffer)}if(!m||!T.length)return;const I=e.useProgram("collisionCircle"),C=new u.ca;C.resize(4*S),C._trim();let R=0;for(const e of T)for(let c=0;c=0&&(L[F.associatedIconIndex]={shiftedAnchor:J,angle:re})}else mi(F.numGlyphs,C)}if(b){R.clear();const c=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(x,c,u):null,u="map"===p.layout.get("text-rotation-alignment");Gt(b,e,m,ge,ye,B,T,u,x.toUnwrapped(),L.width,L.height,ve,c)}const Me=m&&q||Se,Ee=O||Me?Mn:B?ge:e.transform.clipSpaceToPixelsMatrix,Ce=C&&0!==p.paint.get(m?"text-halo-width":"icon-halo-width").constantOr(1);let Ae;Ae=C?b.iconsInText?gn(U.kind,re,V,B,O,Me,e,Ee,xe,ve,le,pe,W):_n(U.kind,re,V,B,O,Me,e,Ee,xe,ve,m,le,0,W):mn(U.kind,re,V,B,O,Me,e,Ee,xe,ve,m,le,W);const je={program:J,buffers:S,uniformValues:Ae,projectionData:be,atlasTexture:ce,atlasTextureIcon:fe,atlasInterpolation:he,atlasInterpolationIcon:ue,isSDF:C,hasHalo:Ce};if(j&&b.canOverlap){G=!0;const e=S.segments.get();for(const c of e)Z.push({segments:new u.aX([c]),sortKey:c.sortKey,state:je,terrainData:se})}else Z.push({segments:S.segments,sortKey:0,state:je,terrainData:se})}G&&Z.sort(((e,c)=>e.sortKey-c.sortKey));for(const c of Z){const u=c.state;if(C.activeTexture.set(R.TEXTURE0),u.atlasTexture.bind(u.atlasInterpolation,R.CLAMP_TO_EDGE),u.atlasTextureIcon&&(C.activeTexture.set(R.TEXTURE1),u.atlasTextureIcon&&u.atlasTextureIcon.bind(u.atlasInterpolationIcon,R.CLAMP_TO_EDGE)),u.isSDF){const f=u.uniformValues;u.hasHalo&&(f.u_is_halo=1,Rn(u.buffers,c.segments,p,e,u.program,U,S,P,f,u.projectionData,c.terrainData)),f.u_is_halo=0}Rn(u.buffers,c.segments,p,e,u.program,U,S,P,u.uniformValues,u.projectionData,c.terrainData)}}function Rn(e,c,u,p,f,m,g,y,x,b,T){const S=p.context;f.draw(S,S.gl.TRIANGLES,m,g,y,ei.backCCW,x,T,b,u.id,e.layoutVertexBuffer,e.indexBuffer,c,u.paint,p.transform.zoom,e.programConfigurations.get(u.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function Ln(e,c,p,f,m){const g=e.context,y=g.gl,x=ai.disabled,b=new Qt([y.ONE,y.ONE],u.bp.transparent,[!0,!0,!0,!0]),T=c.getBucket(p);if(!T)return;const S=f.key;let P=p.heatmapFbos.get(S);P||(P=On(g,c.tileSize,c.tileSize),p.heatmapFbos.set(S,P)),g.bindFramebuffer.set(P.framebuffer),g.viewport.set([0,0,c.tileSize,c.tileSize]),g.clear({color:u.bp.transparent});const I=T.programConfigurations.get(p.id),C=e.useProgram("heatmap",I,!m),R=e.transform.getProjectionData({overscaledTileID:c.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),L=e.style.map.terrain.getTerrainData(f);C.draw(g,y.TRIANGLES,ti.disabled,x,b,ei.disabled,Qr(c,e.transform.zoom,p.paint.get("heatmap-intensity"),1),L,R,p.id,T.layoutVertexBuffer,T.indexBuffer,T.segments,p.paint,e.transform.zoom,I)}function Bn(e,c,u,p,f){const m=e.context,g=m.gl,y=e.transform;m.setColorMode(e.colorModeForRenderPass());const x=Vn(m,c),b=u.key,T=c.heatmapFbos.get(b);if(!T)return;m.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,T.colorAttachment.get()),m.activeTexture.set(g.TEXTURE1),x.bind(g.LINEAR,g.CLAMP_TO_EDGE);const S=y.getProjectionData({overscaledTileID:u,applyTerrainMatrix:f,applyGlobeMatrix:!p});e.useProgram("heatmapTexture").draw(m,g.TRIANGLES,ti.disabled,ai.disabled,e.colorModeForRenderPass(),ei.disabled,Jr(e,c,0,1),null,S,c.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,c.paint,y.zoom),T.destroy(),c.heatmapFbos.delete(b)}function On(e,c,u){var p,f;const m=e.gl,g=m.createTexture();m.bindTexture(m.TEXTURE_2D,g),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.LINEAR),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.LINEAR);const y=null!==(p=e.HALF_FLOAT)&&void 0!==p?p:m.UNSIGNED_BYTE,x=null!==(f=e.RGBA16F)&&void 0!==f?f:m.RGBA;m.texImage2D(m.TEXTURE_2D,0,x,c,u,0,m.RGBA,y,null);const b=e.createFramebuffer(c,u,!1,!1);return b.colorAttachment.set(g),b}function Vn(e,c){return c.colorRampTexture||(c.colorRampTexture=new u.T(e,c.colorRamp,e.gl.RGBA)),c.colorRampTexture}function jn(e,c,p,f,m,g,y,x){let b=256;if(m.stepInterpolant){const f=c.getSource().maxzoom,m=y.canonical.z===f?Math.ceil(1<20&&P.texParameterf(P.TEXTURE_2D,S.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,S.extTextureFilterAnisotropicMax);const re=e.style.map.terrain&&e.style.map.terrain.getTerrainData(G),se=C.getProjectionData({overscaledTileID:G,aligned:F,applyGlobeMatrix:!b,applyTerrainMatrix:!0}),le=pn(Q,W,J.fadeMix,u,y),ce=R.getMeshFromTileID(S,G.canonical,m,g,"raster");I.draw(S,P.TRIANGLES,p,f?f[G.overscaledZ]:ai.disabled,L,x?ei.frontCCW:ei.backCCW,le,re,se,u.id,ce.vertexBuffer,ce.indexBuffer,ce.segments)}}function Qn(e,c,p,f){const m={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===p||f)return m;if(e.fadingParentID){const f=c.getLoadedTile(e.fadingParentID);if(!f)return m;const g=Math.pow(2,f.tileID.overscaledZ-e.tileID.overscaledZ),y=[e.tileID.canonical.x*g%1,e.tileID.canonical.y*g%1],x=function(e,c,p){const f=T(),m=(f-c.timeAdded)/p,g=e.fadingDirection===Ee.Incoming,y=u.an((f-e.timeAdded)/p,0,1),x=u.an(1-m,0,1),b=g?y:x;return{tileOpacity:b,parentTileOpacity:g?x:y,fadeMix:{opacity:1,mix:1-b}}}(e,f,p);return{parentTile:f,parentScaleBy:g,parentTopLeft:y,fadeValues:x}}if(e.selfFading){const c=function(e,c){const p=(T()-e.timeAdded)/c,f=u.an(p,0,1);return{tileOpacity:f,fadeMix:{opacity:f,mix:0}}}(e,p);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:c}}return m}const Jn=new u.bp(1,0,0,1),es=new u.bp(0,1,0,1),ns=new u.bp(0,0,1,1),ss=new u.bp(1,0,1,1),ls=new u.bp(0,1,1,1);function us(e,c,u,p){ps(e,0,c+u/2,e.transform.width,u,p)}function ds(e,c,u,p){ps(e,c-u/2,0,u,e.transform.height,p)}function ps(e,c,u,p,f,m){const g=e.context,y=g.gl;y.enable(y.SCISSOR_TEST),y.scissor(c*e.pixelRatio,u*e.pixelRatio,p*e.pixelRatio,f*e.pixelRatio),g.clear({color:m}),y.disable(y.SCISSOR_TEST)}function fs(e,c,p){const f=e.context,m=f.gl,g=e.useProgram("debug"),y=ti.disabled,x=ai.disabled,b=e.colorModeForRenderPass(),T="$debug",S=e.style.map.terrain&&e.style.map.terrain.getTerrainData(p);f.activeTexture.set(m.TEXTURE0);const P=c.getTileByID(p.key).latestRawTileData,I=Math.floor((P&&P.byteLength||0)/1024),C=c.getTile(p).tileSize,R=512/Math.min(C,512)*(p.overscaledZ/e.transform.zoom)*.5;let L=p.canonical.toString();p.overscaledZ!==p.canonical.z&&(L+=` => ${p.overscaledZ}`),function(e,c){e.initDebugOverlayCanvas();const u=e.debugOverlayCanvas,p=e.context.gl,f=e.debugOverlayCanvas.getContext("2d");f.clearRect(0,0,u.width,u.height),f.shadowColor="white",f.shadowBlur=2,f.lineWidth=1.5,f.strokeStyle="white",f.textBaseline="top",f.font="bold 36px Open Sans, sans-serif",f.fillText(c,5,5),f.strokeText(c,5,5),e.debugOverlayTexture.update(u),e.debugOverlayTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE)}(e,`${L} ${I}kB`);const F=e.transform.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0});g.draw(f,m.TRIANGLES,y,x,Qt.alphaBlended,ei.disabled,Kr(u.bp.transparent,R),null,F,T,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),g.draw(f,m.LINE_STRIP,y,x,b,ei.disabled,Kr(u.bp.red),S,F,T,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function _s(e,c,u,p){const{isRenderingGlobe:f}=p,m=e.context,g=m.gl,y=e.transform,x=e.colorModeForRenderPass(),b=e.getDepthModeFor3D(),T=e.useProgram("terrain");m.bindFramebuffer.set(null),m.viewport.set([0,0,e.width,e.height]);for(const p of u){const u=c.getTerrainMesh(p.tileID),S=e.renderToTexture.getTexture(p),P=c.getTerrainData(p.tileID);m.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,S.texture);const I=c.getMeshFrameDelta(y.zoom),C=y.calculateFogMatrix(p.tileID.toUnwrapped()),R=Lr(I,C,e.style.sky,y.pitch,f),L=y.getProjectionData({overscaledTileID:p.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});T.draw(m,g.TRIANGLES,b,ai.disabled,x,ei.backCCW,R,P,L,"terrain",u.vertexBuffer,u.indexBuffer,u.segments)}}function gs(e,c){if(!c.mesh){const p=new u.aW;p.emplaceBack(-1,-1),p.emplaceBack(1,-1),p.emplaceBack(1,1),p.emplaceBack(-1,1);const f=new u.aY;f.emplaceBack(0,1,2),f.emplaceBack(0,2,3),c.mesh=new kt(e.createVertexBuffer(p,Gi.members),e.createIndexBuffer(f),u.aX.simpleSegment(0,0,p.length,f.length))}return c.mesh}class qr{constructor(e,c){this.context=new nr(e),this.transform=c,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:u.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,c,u){if(this.width=Math.floor(e*u),this.height=Math.floor(c*u),this.pixelRatio=u,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,c=new u.aW;c.emplaceBack(0,0),c.emplaceBack(u.a5,0),c.emplaceBack(0,u.a5),c.emplaceBack(u.a5,u.a5),this.tileExtentBuffer=e.createVertexBuffer(c,Gi.members),this.tileExtentSegments=u.aX.simpleSegment(0,0,4,2);const p=new u.aW;p.emplaceBack(0,0),p.emplaceBack(u.a5,0),p.emplaceBack(0,u.a5),p.emplaceBack(u.a5,u.a5),this.debugBuffer=e.createVertexBuffer(p,Gi.members),this.debugSegments=u.aX.simpleSegment(0,0,4,5);const f=new u.ch;f.emplaceBack(0,0,0,0),f.emplaceBack(u.a5,0,u.a5,0),f.emplaceBack(0,u.a5,0,u.a5),f.emplaceBack(u.a5,u.a5,u.a5,u.a5),this.rasterBoundsBuffer=e.createVertexBuffer(f,Rr.members),this.rasterBoundsSegments=u.aX.simpleSegment(0,0,4,2);const m=new u.aW;m.emplaceBack(0,0),m.emplaceBack(u.a5,0),m.emplaceBack(0,u.a5),m.emplaceBack(u.a5,u.a5),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(m,Gi.members),this.rasterBoundsSegmentsPosOnly=u.aX.simpleSegment(0,0,4,5);const g=new u.aW;g.emplaceBack(0,0),g.emplaceBack(1,0),g.emplaceBack(0,1),g.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(g,Gi.members),this.viewportSegments=u.aX.simpleSegment(0,0,4,2);const y=new u.ci;y.emplaceBack(0),y.emplaceBack(1),y.emplaceBack(3),y.emplaceBack(2),y.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(y);const x=new u.aY;x.emplaceBack(1,0,2),x.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(x);const b=this.context.gl;this.stencilClearMode=new ai({func:b.ALWAYS,mask:0},0,255,b.ZERO,b.ZERO,b.ZERO),this.tileExtentMesh=new kt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,c=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const p=u.N();u.c7(p,0,this.width,this.height,0,0,1),u.Q(p,p,[c.drawingBufferWidth,c.drawingBufferHeight,0]);const f={mainMatrix:p,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:p};this.useProgram("clippingMask",null,!0).draw(e,c.TRIANGLES,ti.disabled,this.stencilClearMode,Qt.disabled,ei.disabled,null,null,f,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,c,u){if(this.currentStencilSource===e.source||!e.isTileClipped()||!c||!c.length)return;this.currentStencilSource=e.source,this.nextStencilID+c.length>256&&this.clearStencil();const p=this.context;p.setColorMode(Qt.disabled),p.setDepthMode(ti.disabled);const f={};for(const e of c)f[e.key]=this.nextStencilID++;this._renderTileMasks(f,c,u,!0),this._renderTileMasks(f,c,u,!1),this._tileClippingMaskIDs=f}_renderTileMasks(e,c,u,p){const f=this.context,m=f.gl,g=this.style.projection,y=this.transform,x=this.useProgram("clippingMask");for(const b of c){const c=e[b.key],T=this.style.map.terrain&&this.style.map.terrain.getTerrainData(b),S=g.getMeshFromTileID(this.context,b.canonical,p,!0,"stencil"),P=y.getProjectionData({overscaledTileID:b,applyGlobeMatrix:!u,applyTerrainMatrix:!0});x.draw(f,m.TRIANGLES,ti.disabled,new ai({func:m.ALWAYS,mask:0},c,255,m.KEEP,m.KEEP,m.REPLACE),Qt.disabled,u?ei.disabled:ei.backCCW,null,T,P,"$clipping",S.vertexBuffer,S.indexBuffer,S.segments)}}_renderTilesDepthBuffer(){const e=this.context,c=e.gl,u=this.style.projection,p=this.transform,f=this.useProgram("depth"),m=this.getDepthModeFor3D(),g=rt(p,{tileSize:p.tileSize});for(const y of g){const g=this.style.map.terrain&&this.style.map.terrain.getTerrainData(y),x=u.getMeshFromTileID(this.context,y.canonical,!0,!0,"raster"),b=p.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!0,applyTerrainMatrix:!0});f.draw(e,c.TRIANGLES,m,ai.disabled,Qt.disabled,ei.backCCW,null,g,b,"$clipping",x.vertexBuffer,x.indexBuffer,x.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,c=this.context.gl;return new ai({func:c.NOTEQUAL,mask:255},e,255,c.KEEP,c.KEEP,c.REPLACE)}stencilModeForClipping(e){const c=this.context.gl;return new ai({func:c.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,c.KEEP,c.KEEP,c.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const c=this.context.gl,u=e.sort(((e,c)=>c.overscaledZ-e.overscaledZ)),p=u[u.length-1].overscaledZ,f=u[0].overscaledZ-p+1;if(f>1){this.currentStencilSource=void 0,this.nextStencilID+f>256&&this.clearStencil();const e={};for(let u=0;uc.overscaledZ-e.overscaledZ)),p=u[u.length-1].overscaledZ,f=u[0].overscaledZ-p+1;if(this.clearStencil(),f>1){const e={},m={};for(let u=0;u0};for(const e in g){const c=g[e];c.used&&c.prepare(this.context),y[e]=c.getVisibleCoordinates(!1),x[e]=y[e].slice().reverse(),b[e]=c.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:c.showOverdrawInspector?u.bp.black:u.bp.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,c){const u=e.context,p=u.gl,f=((e,c,u)=>{const p=Math.cos(c.rollInRadians),f=Math.sin(c.rollInRadians),m=Ne(c),g=c.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:[(c.width/2-m*f)*u,(c.height/2+m*p)*u],u_horizon_normal:[-f,p],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*c.height/2*u,u_sky_blend:g}})(c,e.style.map.transform,e.pixelRatio),m=new ti(p.LEQUAL,ti.ReadWrite,[0,1]),g=ai.disabled,y=e.colorModeForRenderPass(),x=e.useProgram("sky"),b=gs(u,c);x.draw(u,p.TRIANGLES,m,g,y,ei.disabled,f,null,void 0,"sky",b.vertexBuffer,b.indexBuffer,b.segments)}(this,this.style.sky),this._showOverdrawInspector=c.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=m.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[m[this.currentLayer]],c=g[e.source],u=y[e.source];this._renderTileClippingMasks(e,u,!1),this.renderLayer(this,c,e,u,S)}this.renderPass="translucent";let P=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:c,u_globe_position:u,u_globe_radius:p,u_inv_proj_matrix:f}))(b,S,[C[0],C[1],C[2]],P,I),L=gs(f,c);g.draw(f,m.TRIANGLES,y,ai.disabled,Qt.alphaBlended,ei.disabled,R,null,null,"atmosphere",L.vertexBuffer,L.indexBuffer,L.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,c){let u=null;const p=Object.values(e._layers).flatMap((u=>u.source&&!u.isHidden(c)?[e.tileManagers[u.source]]:[])),f=p.filter((e=>"vector"===e.getSource().type)),m=p.filter((e=>"vector"!==e.getSource().type)),g=e=>{(!u||u.getSource().maxzoomg(e))),u||m.forEach((e=>g(e))),u}(this.style,this.transform.zoom);e&&function(e,c,u){for(let p=0;pS.getElevation(m,e,c):null;An(g,P,I,b,T,L,c,C,F,u.aO(T,e,y,x),m.toUnwrapped(),p)}}}(f,e,p,c,p.layout.get("text-rotation-alignment"),p.layout.get("text-pitch-alignment"),p.paint.get("text-translate"),p.paint.get("text-translate-anchor"),m),0!==p.paint.get("icon-opacity").constantOr(1)&&kn(e,c,p,f,!1,p.paint.get("icon-translate"),p.paint.get("icon-translate-anchor"),p.layout.get("icon-rotation-alignment"),p.layout.get("icon-pitch-alignment"),p.layout.get("icon-keep-upright"),x,b,y),0!==p.paint.get("text-opacity").constantOr(1)&&kn(e,c,p,f,!0,p.paint.get("text-translate"),p.paint.get("text-translate-anchor"),p.layout.get("text-rotation-alignment"),p.layout.get("text-pitch-alignment"),p.layout.get("text-keep-upright"),x,b,y),c.map.showCollisionBoxes&&(Pn(e,c,p,f,!0),Pn(e,c,p,f,!1))}(e,c,p,f,this.style.placement.variableOffsets,m):u.cn(p)?function(e,c,p,f,m){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:g}=m,y=p.paint.get("circle-opacity"),x=p.paint.get("circle-stroke-width"),b=p.paint.get("circle-stroke-opacity"),T=!p.layout.get("circle-sort-key").isConstant();if(0===y.constantOr(1)&&(0===x.constantOr(1)||0===b.constantOr(1)))return;const S=e.context,P=S.gl,I=e.transform,C=e.getDepthModeForSublayer(0,ti.ReadOnly),R=ai.disabled,L=e.colorModeForRenderPass(),F=[],B=I.getCircleRadiusCorrection();for(let m=0;me.sortKey-c.sortKey));for(const c of F){const{programConfiguration:u,program:f,layoutVertexBuffer:m,indexBuffer:g,uniformValues:y,terrainData:x,projectionData:b}=c.state;f.draw(S,P.TRIANGLES,C,R,L,ei.backCCW,y,x,b,p.id,m,g,c.segments,p.paint,e.transform.zoom,u)}}(e,c,p,f,m):u.co(p)?function(e,c,p,f,m){if(0===p.paint.get("heatmap-opacity"))return;const g=e.context,{isRenderingToTexture:y,isRenderingGlobe:x}=m;if(e.style.map.terrain){for(const u of f){const f=c.getTile(u);c.hasRenderableParent(u)||("offscreen"===e.renderPass?Ln(e,f,p,u,x):"translucent"===e.renderPass&&Bn(e,p,u,y,x))}g.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,c,p,f){const m=e.context,g=m.gl,y=e.transform,x=ai.disabled,b=new Qt([g.ONE,g.ONE],u.bp.transparent,[!0,!0,!0,!0]);(function(e,c,p){const f=e.gl;e.activeTexture.set(f.TEXTURE1),e.viewport.set([0,0,c.width/4,c.height/4]);let m=p.heatmapFbos.get(u.cd);m?(f.bindTexture(f.TEXTURE_2D,m.colorAttachment.get()),e.bindFramebuffer.set(m.framebuffer)):(m=On(e,c.width/4,c.height/4),p.heatmapFbos.set(u.cd,m))})(m,e,p),m.clear({color:u.bp.transparent});for(let u=0;u0?c.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const c=this.imageManager.getPattern(e.from.toString()),u=this.imageManager.getPattern(e.to.toString());return!c||!u}useProgram(e,c,u=!1,p=[]){this.cache=this.cache||{};const f=!!this.style.map.terrain,m=this.style.projection,g=u?ji.projectionMercator:m.shaderPreludeCode,y=u?Ui:m.shaderDefine,x=e+(c?c.cacheKey:"")+`/${u?qi:m.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(f?"/terrain":"")+(p?`/${p.join("/")}`:"");return this.cache[x]||(this.cache[x]=new Zi(this.context,ji[e],c,bn[e],this._showOverdrawInspector,f,g,y,p)),this.cache[x]}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 u.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,c;if(this._tileTextures){for(const e in this._tileTextures){const c=this._tileTextures[e];if(c)for(const e of c)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===(c=this.tileExtentMesh.indexBuffer)||void 0===c||c.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const c=this.cache[e];c&&c.program&&this.context.gl.deleteProgram(c.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:c}=this.context.gl;return this.width!==e||this.height!==c}}function ys(c,u){let p,f=!1,m=null,g=null;const y=()=>{m=null,f&&(c.apply(g,p),m=setTimeout(y,u),f=!1)};return(...c)=>(f=!0,g=this||e,p=c,m||y(),m)}class $r{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let c;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(c=e)})),(c&&c[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const c=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:c,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 c=e.join("/");let u=c;u.split("&").length>0&&(u=u.split("&")[0]),this._hashName&&(u=`${this._hashName}=${c}`);let p=window.location.hash.replace(u,"");p.startsWith("#&")?p=p.slice(0,1)+p.slice(2):"#"===p&&(p="");let f=window.location.href.replace(/(#.+)?$/,p);f=f.replace("&&","&"),window.history.replaceState(window.history.state,null,f)},this._updateHash=ys(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 c=this._map.getCenter(),u=Math.round(100*this._map.getZoom())/100,p=Math.ceil((u*Math.LN2+Math.log(512/360/.5))/Math.LN10),f=Math.pow(10,p),m=Math.round(c.lng*f)/f,g=Math.round(c.lat*f)/f,y=this._map.getBearing(),x=this._map.getPitch();let b="";if(b+=e?`/${m}/${g}/${u}`:`${u}/${g}/${m}`,(y||x)&&(b+="/"+Math.round(10*y)/10),x&&(b+=`/${Math.round(x)}`),this._hashName){const e=this._hashName;let c=!1;const u=window.location.hash.slice(1).split("&").map((u=>{const p=u.split("=")[0];return p===e?(c=!0,`${p}=${b}`):u})).filter((e=>e));return c||u.push(`${e}=${b}`),`#${u.join("&")}`}return`#${b}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new u.V(+e[2],+e[1])}catch(e){return!1}const c=+e[0],p=+(e[3]||0),f=+(e[4]||0);return c>=this._map.getMinZoom()&&c<=this._map.getMaxZoom()&&p>=-180&&p<=180&&f>=this._map.getMinPitch()&&f<=this._map.getMaxPitch()}}const vs={linearity:.3,easing:u.cw(0,0,.3,1)},bs=u.e({deceleration:2500,maxSpeed:1400},vs),ws=u.e({deceleration:20,maxSpeed:1400},vs),Ts=u.e({deceleration:1e3,maxSpeed:360},vs),Ss=u.e({deceleration:1e3,maxSpeed:90},vs),Ms=u.e({deceleration:1e3,maxSpeed:360},vs);class eo{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:T(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,c=T();for(;e.length>0&&c-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const c={zoom:0,bearing:0,pitch:0,roll:0,pan:new u.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)c.zoom+=e.zoomDelta||0,c.bearing+=e.bearingDelta||0,c.pitch+=e.pitchDelta||0,c.roll+=e.rollDelta||0,e.panDelta&&c.pan._add(e.panDelta),e.around&&(c.around=e.around),e.pinchAround&&(c.pinchAround=e.pinchAround);const p=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,f={};if(c.pan.mag()){const m=Es(c.pan.mag(),p,u.e({},bs,e||{})),g=c.pan.mult(m.amount/c.pan.mag()),y=this._map.cameraHelper.handlePanInertia(g,this._map.transform);f.center=y.easingCenter,f.offset=y.easingOffset,Is(f,m)}if(c.zoom){const e=Es(c.zoom,p,ws),m=u.cx(this._map.transform.zoom+e.amount,this._map.getZoomSnap(),e.amount);f.zoom=m,Is(f,e)}if(c.bearing){const e=Es(c.bearing,p,Ts);f.bearing=this._map.transform.bearing+u.an(e.amount,-179,179),Is(f,e)}if(c.pitch){const e=Es(c.pitch,p,Ss);f.pitch=this._map.transform.pitch+e.amount,Is(f,e)}if(c.roll){const e=Es(c.roll,p,Ms);f.roll=this._map.transform.roll+u.an(e.amount,-179,179),Is(f,e)}if(f.zoom||f.bearing){const e=void 0===c.pinchAround?c.around:c.pinchAround;f.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),u.e(f,{noMoveStart:!0})}}function Is(e,c){(!e.duration||e.durationc.unproject(e))),y=m.reduce(((e,c,u,p)=>e.add(c.div(p.length))),new u.P(0,0));super(e,{points:m,point:y,lngLats:g,lngLat:c.unproject(y),originalEvent:p}),this._defaultPrevented=!1}}class oo extends u.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,c,u){super(e,{originalEvent:u}),this._defaultPrevented=!1}}class so{constructor(e,c){this._map=e,this._clickTolerance=c.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new oo(e.type,this._map,e))}mousedown(e,c){return this._mousedownPos=c,this._firePreventable(new ao(e.type,this._map,e))}mouseup(e){this._map.fire(new ao(e.type,this._map,e))}click(e,c){this._mousedownPos&&this._mousedownPos.dist(c)>=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(u.P.convert(e),this._map.terrain)}}class co{constructor(e,c){this._map=e,this._tr=new lo(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=c.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,c){this.isEnabled()&&e.shiftKey&&0===e.button&&(h.disableDrag(),this._startPos=this._lastPos=c,this._active=!0)}mousemoveWindow(e,c){if(!this._active)return;const u=c;if(this._lastPos.equals(u)||!this._box&&u.dist(this._startPos)e.fitScreenCoordinates(p,f,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,c){return this._map.fire(new u.l(e,{originalEvent:c}))}}function As(e,c){if(e.length!==c.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${c.length}`);const u={};for(let p=0;pthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),p.length===this.numTouches&&(this.centroid=function(e){const c=new u.P(0,0);for(const u of e)c._add(u);return c.div(e.length)}(c),this.touches=As(p,c)))}touchmove(e,c,u){if(this.aborted||!this.centroid)return;const p=As(u,c);for(const e in this.touches){const c=p[e];(!c||c.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,c,u){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===u.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,c,u){this.singleTap.touchstart(e,c,u)}touchmove(e,c,u){this.singleTap.touchmove(e,c,u)}touchend(e,c,u){const p=this.singleTap.touchend(e,c,u);if(p){const c=e.timeStamp-this.lastTime<500,u=!this.lastTap||this.lastTap.dist(p)<30;if(c&&u||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=p,this.count===this.numTaps)return this.reset(),p}}}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,c,u){this._zoomIn.touchstart(e,c,u),this._zoomOut.touchstart(e,c,u)}touchmove(e,c,u){this._zoomIn.touchmove(e,c,u),this._zoomOut.touchmove(e,c,u)}touchend(e,c,p){const f=this._zoomIn.touchend(e,c,p),m=this._zoomOut.touchend(e,c,p),g=this._tr;return f?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:c=>c.easeTo({duration:300,zoom:u.cx(g.zoom+1,c.getZoomSnap()),around:g.unproject(f)},{originalEvent:e})}):m?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:c=>c.easeTo({duration:300,zoom:u.cx(g.zoom-1,c.getZoomSnap()),around:g.unproject(m)},{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 c=this._moveFunction(...e);if(c.bearingDelta||c.pitchDelta||c.rollDelta||c.around||c.panDelta)return this._active=!0,c}dragStart(e,c){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(c)?c[0]:c,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,c){if(!this.isEnabled())return;const u=this._lastPoint;if(!u)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const p=Array.isArray(c)?c[0]:c;return!this._moved&&p.dist(u)!0}),c=new bo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=c}_executeRelevantHandler(e,c,u){return e instanceof MouseEvent?c(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?u(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 Fs=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class To{constructor(e,c){this._clickTolerance=e.clickTolerance||1,this._map=c,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new u.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,c,u){return this._calculateTransform(e,c,u)}touchmove(e,c,u){if(this._active){if(!this._shouldBePrevented(u.length))return e.preventDefault(),this._calculateTransform(e,c,u);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,c,u){this._calculateTransform(e,c,u),this._active&&this._shouldBePrevented(u.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,c,p){p.length>0&&(this._active=!0);const f=As(p,c),m=new u.P(0,0),g=new u.P(0,0);let y=0;for(const e in f){const c=f[e],u=this._touches[e];u&&(m._add(c),g._add(c.sub(u)),y++,f[e]=c)}if(this._touches=f,this._shouldBePrevented(y)||!g.mag())return;const x=g.div(y);return this._sum._add(x),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,c,u){super.touchstart(e,c,u),this._currentTouchCount=u.length}_start(e){this._lastPoints=e,Js(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,c,u){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const p=e[0].sub(this._lastPoints[0]),f=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(p,f,u.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(p.y+f.y)/2*-.5}):void 0}gestureBeginsVertically(e,c,u){if(void 0!==this._valid)return this._valid;const p=e.mag()>=2,f=c.mag()>=2;if(!p&&!f)return;if(!p||!f)return void 0===this._firstMove&&(this._firstMove=u),u-this._firstMove<100&&void 0;const m=e.y>0==c.y>0;return Js(e)&&Js(c)&&m}}const ho={panStep:100,bearingStep:15,pitchStep:10};class Ao{constructor(e){this._tr=new lo(e);const c=ho;this._panStep=c.panStep,this._bearingStep=c.bearingStep,this._pitchStep=c.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let c=0,p=0,f=0,m=0,g=0;switch(e.keyCode){case 61:case 107:case 171:case 187:c=1;break;case 189:case 109:case 173:c=-1;break;case 37:e.shiftKey?p=-1:(e.preventDefault(),m=-1);break;case 39:e.shiftKey?p=1:(e.preventDefault(),m=1);break;case 38:e.shiftKey?f=1:(e.preventDefault(),g=-1);break;case 40:e.shiftKey?f=-1:(e.preventDefault(),g=1);break;default:return}return this._rotationDisabled&&(p=0,f=0),{cameraAnimation:y=>{const x=this._tr;y.easeTo({duration:300,easeId:"keyboardHandler",easing:fo,zoom:c?u.cx(x.zoom+c*(e.shiftKey?2:1),y.getZoomSnap()):x.zoom,bearing:x.bearing+p*this._bearingStep,pitch:x.pitch+f*this._pitchStep,offset:[-m*this._panStep,-g*this._panStep],center:x.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 fo(e){return e*(2-e)}const vo=4.000244140625,Co=1/450;class Bo{constructor(e,c){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=c,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Co}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 c=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const u=T(),p=u-(this._lastWheelEventTime||0);this._lastWheelEventTime=u,0!==c&&c%vo==0?this._type="wheel":0!==c&&Math.abs(c)<4?this._type="trackpad":p>400?(this._type=null,this._lastValue=c,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(p*c)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,c+=this._lastValue)),e.shiftKey&&c&&(c/=4),this._type&&(this._lastWheelEvent=e,this._delta-=c,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 c=h.mousePos(this._map.getCanvas(),e),p=this._tr;this._aroundPoint=this._aroundCenter?p.transform.locationToScreenPoint(u.V.convert(p.center)):c,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 c=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=c),"number"==typeof this._targetZoom&&(this._targetZoom+=c)}if(0!==this._delta){const c="wheel"===this._type&&Math.abs(this._delta)>vo?this._wheelZoomRate:this._defaultZoomRate;let p=2/(1+Math.exp(-Math.abs(this._delta*c)));this._delta<0&&0!==p&&(p=1/p);const f="number"!=typeof this._targetZoom?e.scale:u.aq(this._targetZoom),m=e.applyConstrain(e.getCameraLngLat(),u.at(f*p)).zoom,g=this._map.getZoomSnap();if("wheel"===this._type&&g>0){const c=u.cx(e.zoom,g);this._targetZoom=u.cx(m,g,m-c)}else this._targetZoom=m;"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const c="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,p=this._startZoom,f=this._easing;let m,g=!1;if("wheel"===this._type&&p&&f){const e=T()-this._lastWheelEventTime,y=Math.min((e+5)/200,1),x=f(y);m=u.G.number(p,c,x),y<1?this._frameId||(this._frameId=!0):g=!0}else m=c,g=!0;return this._active=!0,g&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=m,{noInertia:!0,needsRenderFrame:!g,zoomDelta:m-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let c=u.cz;if(this._prevEase){const e=this._prevEase,p=(T()-e.start)/e.duration,f=e.easing(p+.01)-e.easing(p),m=.27/Math.sqrt(f*f+1e-4)*.01,g=Math.sqrt(.0729-m*m);c=u.cw(m,g,.25,1)}return this._prevEase={start:T(),duration:e,easing:c},c}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,c){this._clickZoom=e,this._tapZoom=c}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,c){return e.preventDefault(),{cameraAnimation:p=>{p.easeTo({duration:300,zoom:u.cx(this._tr.zoom+(e.shiftKey?-1:1),p.getZoomSnap()),around:this._tr.unproject(c)},{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,c,u){if(!this._swipePoint)if(this._tapTime){const p=c[0],f=e.timeStamp-this._tapTime<500,m=this._tapPoint.dist(p)<30;f&&m?u.length>0&&(this._swipePoint=p,this._swipeTouch=u[0].identifier):this.reset()}else this._tap.touchstart(e,c,u)}touchmove(e,c,u){if(this._tapTime){if(this._swipePoint){if(u[0].identifier!==this._swipeTouch)return;const p=c[0],f=p.y-this._swipePoint.y;return this._swipePoint=p,e.preventDefault(),this._active=!0,{zoomDelta:f/128}}}else this._tap.touchmove(e,c,u)}touchend(e,c,u){if(this._tapTime)this._swipePoint&&0===u.length&&this.reset();else{const p=this._tap.touchend(e,c,u);p&&(this._tapTime=e.timeStamp,this._tapPoint=p)}}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,c,u){this._el=e,this._mousePan=c,this._touchPan=u}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,c,u,p){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=c,this._mousePitch=u,this._mouseRoll=p}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,c,u,p){this._el=e,this._touchZoom=c,this._touchRotate=u,this._tapDragZoom=p,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,c){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=c,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 c=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(c=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const u=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),p=document.createElement("div");p.className="maplibregl-desktop-message",p.textContent=c,this._container.appendChild(p);const f=document.createElement("div");f.className="maplibregl-mobile-message",f.textContent=u,this._container.appendChild(f),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,c){this._enabled&&(this._map.fire(new u.l("cooperativegestureprevented",{gestureType:e,originalEvent:c})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const ko=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Wo extends u.l{}function Lo(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Ho{get _ownerDocument(){var e;return(null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||document}get _ownerWindow(){var e,c;return(null===(c=null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||void 0===c?void 0:c.defaultView)||window}constructor(e,c){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,c)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const p="renderFrame"===e.type?void 0:e,f={needsRenderFrame:!1},m={},g={};for(const{handlerName:y,handler:x,allowed:b}of this._handlers){if(!x.isEnabled())continue;let T;if(this._blockedByActive(g,b,y))x.reset();else if(x[c||e.type]){if(u.cA(e,c||e.type)){const u=h.mousePos(this._map.getCanvas(),e);T=x[c||e.type](e,u)}else if(u.cB(e,c||e.type)){const u=this._getMapTouches(e.touches),p=h.touchPos(this._map.getCanvas(),u);T=x[c||e.type](e,p,u)}else u.cC(c||e.type)||(T=x[c||e.type](e));this.mergeHandlerResult(f,m,T,y,p),T&&T.needsRenderFrame&&this._triggerRenderFrame()}(T||x.isActive())&&(g[y]=x)}const y={};for(const e in this._previousActiveHandlers)g[e]||(y[e]=p);this._previousActiveHandlers=g,(Object.keys(y).length||Lo(f))&&(this._changes.push([f,m,y]),this._triggerRenderFrame()),(Object.keys(g).length||Lo(f))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:x}=f;x&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],x(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new eo(e),this._bearingSnap=c.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(c);const p=this._el;this._listeners=[[p,"touchstart",{passive:!0}],[p,"touchmove",{passive:!1}],[p,"touchend",void 0],[p,"touchcancel",void 0],[p,"mousedown",void 0],[p,"mousemove",void 0],[p,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[p,"mouseover",void 0],[p,"mouseout",void 0],[p,"dblclick",void 0],[p,"click",void 0],[p,"keydown",{capture:!1}],[p,"keyup",void 0],[p,"wheel",{passive:!1}],[p,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(const[e,c,u]of this._listeners)h.addEventListener(e,c,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,u)}destroy(){for(const[e,c,u]of this._listeners)h.removeEventListener(e,c,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,u)}_addDefaultHandlers(e){const c=this._map,p=c.getCanvasContainer();this._add("mapEvent",new so(c,e));const f=c.boxZoom=new co(c,e);this._add("boxZoom",f),e.interactive&&e.boxZoom&&f.enable();const m=c.cooperativeGestures=new Vo(c,e.cooperativeGestures);this._add("cooperativeGestures",m),e.cooperativeGestures&&m.enable();const g=new po(c),y=new jo(c);c.doubleClickZoom=new Oo(y,g),this._add("tapZoom",g),this._add("clickZoom",y),e.interactive&&e.doubleClickZoom&&c.doubleClickZoom.enable();const x=new No;this._add("tapDragZoom",x);const b=c.touchPitch=new Ro(c);this._add("touchPitch",b),e.interactive&&e.touchPitch&&c.touchPitch.enable(e.touchPitch);const T=()=>c.project(c.getCenter()),S=function({enable:e,clickTolerance:c,aroundCenter:p=!0,minPixelCenterThreshold:f=100,rotateDegreesPerPixelMoved:m=.8},g){const y=new xo({checkCorrectEvent:e=>0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)&&!e.ctrlKey});return new mo({clickTolerance:c,move:(e,c)=>{const y=g();if(p&&Math.abs(y.y-e.y)>f)return{bearingDelta:u.cy(new u.P(e.x,c.y),c,y)};let x=(c.x-e.x)*m;return p&&c.y0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)});return new mo({clickTolerance:c,move:(e,c)=>({pitchDelta:(c.y-e.y)*u}),moveStateManager:p,enable:e,assignEvents:Fs})}(e),I=function({enable:e,clickTolerance:c,rollDegreesPerPixelMoved:u=.3},p){const f=new xo({checkCorrectEvent:e=>2===h.mouseButton(e)&&e.ctrlKey});return new mo({clickTolerance:c,move:(e,c)=>{const f=p();let m=(c.x-e.x)*u;return c.y0===h.mouseButton(e)&&!e.ctrlKey});return new mo({clickTolerance:c,move:(e,c)=>({around:c,panDelta:c.sub(e)}),activateOnStart:!0,moveStateManager:u,enable:e,assignEvents:Fs})}(e),R=new To(e,c);c.dragPan=new Zo(p,C,R),this._add("mousePan",C),this._add("touchPan",R,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&c.dragPan.enable(e.dragPan);const L=new So,F=new Mo;c.touchZoomRotate=new Uo(p,F,L,x),this._add("touchRotate",L,["touchPan","touchZoom"]),this._add("touchZoom",F,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&c.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new no(c));const B=c.scrollZoom=new Bo(c,(()=>this._triggerRenderFrame()));this._add("scrollZoom",B,["mousePan"]),e.interactive&&e.scrollZoom&&c.scrollZoom.enable(e.scrollZoom);const O=c.keyboard=new Ao(c);this._add("keyboard",O),e.interactive&&e.keyboard&&c.keyboard.enable()}_add(e,c,u){this._handlers.push({handlerName:e,handler:c,allowed:u}),this._handlersById[e]=c}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(ko(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,c,u){for(const p in e)if(p!==u&&(!c||c.indexOf(p)<0))return!0;return!1}_getMapTouches(e){const c=[];for(const u of e)this._el.contains(u.target)&&c.push(u);return c}mergeHandlerResult(e,c,p,f,m){if(!p)return;u.e(e,p);const g={handlerName:f,originalEvent:p.originalEvent||m};void 0!==p.zoomDelta&&(c.zoom=g),void 0!==p.panDelta&&(c.drag=g),void 0!==p.rollDelta&&(c.roll=g),void 0!==p.pitchDelta&&(c.pitch=g),void 0!==p.bearingDelta&&(c.rotate=g)}_applyChanges(){const e={},c={},p={};for(const[f,m,g]of this._changes)f.panDelta&&(e.panDelta=(e.panDelta||new u.P(0,0))._add(f.panDelta)),f.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+f.zoomDelta),f.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+f.bearingDelta),f.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+f.pitchDelta),f.rollDelta&&(e.rollDelta=(e.rollDelta||0)+f.rollDelta),void 0!==f.around&&(e.around=f.around),void 0!==f.pinchAround&&(e.pinchAround=f.pinchAround),f.noInertia&&(e.noInertia=f.noInertia),u.e(c,m),u.e(p,g);this._updateMapTransform(e,c,p),this._changes=[]}_updateMapTransform(e,c,u){const p=this._map,f=p._getTransformForUpdate(),m=p.terrain;if(!(Lo(e)||m&&this._terrainMovement))return this._fireEvents(c,u,!0);p._stop(!0);let{panDelta:g,zoomDelta:y,bearingDelta:x,pitchDelta:b,rollDelta:T,around:S,pinchAround:P}=e;void 0!==P&&(S=P),S=S||p.transform.centerPoint,m&&!f.isPointOnMapSurface(S)&&(S=f.centerPoint);const I={panDelta:g,zoomDelta:y,rollDelta:T,pitchDelta:b,bearingDelta:x,around:S};this._map.cameraHelper.useGlobeControls&&!f.isPointOnMapSurface(S)&&(S=f.centerPoint);const C=S.distSqr(f.centerPoint)<.01?f.center:f.screenPointToLocation(g?S.sub(g):S);this._handleMapControls({terrain:m,tr:f,deltasForHelper:I,preZoomAroundLoc:C,combinedEventsInProgress:c,panDelta:g}),p._applyUpdatedTransform(f),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(c,u,!0)}_handleMapControls({terrain:e,tr:c,deltasForHelper:u,preZoomAroundLoc:p,combinedEventsInProgress:f,panDelta:m}){const g=this._map.cameraHelper;if(g.handleMapControlsRollPitchBearingZoom(u,c),e)return g.useGlobeControls?(this._terrainMovement||!f.drag&&!f.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void g.handleMapControlsPan(u,c,p)):this._terrainMovement||!f.drag&&!f.zoom?void(f.drag&&this._terrainMovement&&m?c.setCenter(c.screenPointToLocation(c.centerPoint.sub(m))):g.handleMapControlsPan(u,c,p)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void g.handleMapControlsPan(u,c,p));g.handleMapControlsPan(u,c,p)}_fireEvents(e,c,p){const f=ko(this._eventsInProgress),m=ko(e),g={};for(const c in e){const{originalEvent:u}=e[c];this._eventsInProgress[c]||(g[`${c}start`]=u),this._eventsInProgress[c]=e[c]}!f&&m&&this._fireEvent("movestart",m.originalEvent);for(const e in g)this._fireEvent(e,g[e]);m&&this._fireEvent("move",m.originalEvent);for(const c in e){const{originalEvent:u}=e[c];this._fireEvent(c,u)}const y={};let b;for(const e in this._eventsInProgress){const{handlerName:u,originalEvent:p}=this._eventsInProgress[e];this._handlersById[u].isActive()||(delete this._eventsInProgress[e],b=c[u]||p,y[`${e}end`]=b)}for(const e in y)this._fireEvent(e,y[e]);const T=ko(this._eventsInProgress),S=(f||m)&&!T;if(S&&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(p&&S){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),c=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 u.E{constructor(e,c,u){super(),this._renderFrameCallback=()=>{const e=Math.min((T()-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=u.bearingSnap,this._zoomSnap=u.zoomSnap,this.cameraHelper=c,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(e,c){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=c}getCenter(){return new u.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,c){return this.jumpTo({center:e},c)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,c){return this.jumpTo({elevation:e},c),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,c,p){return e=u.P.convert(e).mult(-1),this.panTo(this.transform.center,u.e({offset:e},c),p)}panTo(e,c,p){return this.easeTo(u.e({center:e},c),p)}getZoom(){return this.transform.zoom}setZoom(e,c){return this.jumpTo({zoom:e},c),this}zoomTo(e,c,p){return this.easeTo(u.e({zoom:e},c),p)}zoomIn(e,c){return this.zoomTo(u.cx(this.getZoom()+1,this._zoomSnap),e,c),this}zoomOut(e,c){return this.zoomTo(u.cx(this.getZoom()-1,this._zoomSnap),e,c),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,c){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new u.l("movestart",c)).fire(new u.l("move",c)).fire(new u.l("moveend",c))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,c){return this.jumpTo({bearing:e},c),this}getPadding(){return this.transform.padding}setPadding(e,c){return this.jumpTo({padding:e},c),this}rotateTo(e,c,p){return this.easeTo(u.e({bearing:e},c),p)}resetNorth(e,c){return this.rotateTo(0,u.e({duration:1e3},e),c),this}resetNorthPitch(e,c){return this.easeTo(u.e({bearing:0,pitch:0,roll:0,duration:1e3},e),c),this}snapToNorth(e,c){return Math.abs(this.getBearing()){L.easeFunc(u),this.terrain&&!e.freezeElevation&&this._updateElevation(u),this._applyUpdatedTransform(p),this._fireMoveEvents(c)}),(u=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(c,u)}),e),this}_prepareEase(e,c,p={}){this._moving=!0,c||p.moving||this.fire(new u.l("movestart",e)),this._zooming&&!p.zooming&&this.fire(new u.l("zoomstart",e)),this._rotating&&!p.rotating&&this.fire(new u.l("rotatestart",e)),this._pitching&&!p.pitching&&this.fire(new u.l("pitchstart",e)),this._rolling&&!p.rolling&&this.fire(new u.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 c=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&c!==this._elevationTarget){const u=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(u-(c-(u*e+this._elevationStart))/(1-e)),this._elevationTarget=c}this.transform.setElevation(u.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 c=e.getCameraLngLat(),u=e.getCameraAltitude(),p=this.terrain?this.terrain.getElevationForLngLatZoom(c,e.zoom):0;if(uthis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&c.push((e=>this.transformCameraUpdate(e))),!c.length)return;const u=e.clone();for(const e of c){const c=u.clone(),{center:p,zoom:f,roll:m,pitch:g,bearing:y,elevation:x}=e(c);p&&c.setCenter(p),void 0!==x&&c.setElevation(x),void 0!==f&&c.setZoom(f),void 0!==m&&c.setRoll(m),void 0!==g&&c.setPitch(g),void 0!==y&&c.setBearing(y),u.apply(c,!1)}this.transform.apply(u,!1)}_fireMoveEvents(e){this.fire(new u.l("move",e)),this._zooming&&this.fire(new u.l("zoom",e)),this._rotating&&this.fire(new u.l("rotate",e)),this._pitching&&this.fire(new u.l("pitch",e)),this._rolling&&this.fire(new u.l("roll",e))}_afterEase(e,c){if(this._easeId&&c&&this._easeId===c)return;delete this._easeId;const p=this._zooming,f=this._rotating,m=this._pitching,g=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,p&&this.fire(new u.l("zoomend",e)),f&&this.fire(new u.l("rotateend",e)),m&&this.fire(new u.l("pitchend",e)),g&&this.fire(new u.l("rollend",e)),this.fire(new u.l("moveend",e))}flyTo(e,c){if(!e.essential&&x.prefersReducedMotion){const p=u.U(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(p,c)}this.stop(),e=u.e({offset:[0,0],speed:1.2,curve:1.42,easing:u.cz},e);const p=this._getTransformForUpdate(),f=p.bearing,m=p.pitch,g=p.roll,y=p.padding,b="bearing"in e?this._normalizeBearing(e.bearing,f):f,T="pitch"in e?+e.pitch:m,S="roll"in e?this._normalizeBearing(e.roll,g):g,P="padding"in e?e.padding:p.padding,I=u.P.convert(e.offset);let C=p.centerPoint.add(I);const R=p.screenPointToLocation(C),L=this.cameraHelper.handleFlyTo(p,{bearing:b,pitch:T,roll:S,padding:P,locationAtOffset:R,offsetAsPoint:I,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let F=e.curve;const B=Math.max(p.width,p.height),O=B/L.scaleOfZoom,V=L.pixelPathLength;"number"==typeof L.scaleOfMinZoom&&(F=Math.sqrt(B/L.scaleOfMinZoom/V*2));const j=F*F;function G(e){const c=(O*O-B*B+(e?-1:1)*j*j*V*V)/(2*(e?O:B)*j*V);return Math.log(Math.sqrt(c*c+1)-c)}function U(e){return(Math.exp(e)-Math.exp(-e))/2}function q(e){return(Math.exp(e)+Math.exp(-e))/2}const Z=G(!1);let W=function(e){return q(Z)/q(Z+F*e)},Q=function(e){return B*((q(Z)*(U(c=Z+F*e)/q(c))-U(Z))/j)/V;var c},J=(G(!0)-Z)/F;if(Math.abs(V)<2e-6||!isFinite(J)){if(Math.abs(B-O)<1e-6)return this.easeTo(e,c);const u=O0,W=e=>Math.exp(u*F*e)}return e.duration="duration"in e?+e.duration:1e3*J/("screenSpeed"in e?+e.screenSpeed/F:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=f!==b,this._pitching=T!==m,this._rolling=S!==g,this._padding=!p.isPaddingEqual(P),this._prepareEase(c,!1),this.terrain&&this._prepareElevation(L.targetCenter),this._ease((x=>{const R=x*J,F=1/W(R),B=Q(R);this._rotating&&p.setBearing(u.G.number(f,b,x)),this._pitching&&p.setPitch(u.G.number(m,T,x)),this._rolling&&p.setRoll(u.G.number(g,S,x)),this._padding&&(p.interpolatePadding(y,P,x),C=p.centerPoint.add(I)),L.easeFunc(x,F,B,C),this.terrain&&!e.freezeElevation&&this._updateElevation(x),this._applyUpdatedTransform(p),this._fireMoveEvents(c)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(c)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,c){var u;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,c)}return e||null===(u=this.handlers)||void 0===u||u.stop(!1),this}_ease(e,c,u){!1===u.animate||0===u.duration?(e(1),c()):(this._easeStart=T(),this._easeOptions=u,this._onEaseFrame=e,this._onEaseEnd=c,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,c){e=u.W(e,-180,180);const p=Math.abs(e-c);return Math.abs(e-360-c)MapLibre'};class Yo{constructor(e=$o){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,c){const u=this._map._getUIString(`AttributionControl.${c}`);e.title=u,e.setAttribute("aria-label",u)}_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 c=this._map.style.tileManagers;for(const u in c){const p=c[u];if(p.used||p.usedForTerrain){const c=p.getSource();c.attribution&&e.indexOf(c.attribution)<0&&e.push(c.attribution)}}e=e.filter((e=>String(e).trim())),e.sort(((e,c)=>e.length-c.length)),e=e.filter(((c,u)=>{for(let p=u+1;p=0)return!1;return!0}));const u=e.join(" | ");u!==this._attribHTML&&(this._attribHTML=u,e.length?(this._innerContainer.innerHTML=h.sanitize(u),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 c=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&c.classList.add("maplibregl-compact"):c.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 c=h.create("a","maplibregl-ctrl-logo");return c.target="_blank",c.rel="noopener nofollow",c.href="https://maplibre.org/",c.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),c.setAttribute("rel","noopener nofollow"),this._container.appendChild(c),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 c=++this._id;return this._queue.push({callback:e,id:c,cancelled:!1}),c}remove(e){const c=this._currentlyRunning,u=c?this._queue.concat(c):this._queue;for(const c of u)if(c.id===e)return void(c.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const c=this._currentlyRunning=this._queue;this._queue=[];for(const u of c)if(!u.cancelled&&(u.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Ko=u.aU([{name:"a_pos3d",type:"Int16",components:3}]);class ts extends u.E{constructor(e){super(),this._lastTilesetChange=T(),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,c){this.tileManager.update(e,c),this._renderableTilesKeys=[];const p={};for(const f of rt(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:c,calculateTileZoom:this.tileManager._source.calculateTileZoom}))p[f.key]=!0,this._renderableTilesKeys.push(f.key),this._tiles[f.key]||(f.terrainRttPosMatrix32f=new Float64Array(16),u.c7(f.terrainRttPosMatrix32f,0,u.a5,u.a5,0,0,1),this._tiles[f.key]=new de(f,this.tileSize),this._lastTilesetChange=T());for(const e in this._tiles)p[e]||delete this._tiles[e]}freeRtt(e){for(const c in this._tiles){const u=this._tiles[c];(!e||u.tileID.equals(e)||u.tileID.isChildOf(e)||e.isChildOf(u.tileID))&&(u.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,c){return c?this._getTerrainCoordsForTileRanges(e,c):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const c={};for(const p of this._renderableTilesKeys){const f=this._tiles[p].tileID,m=e.clone(),g=u.bk();if(f.canonical.equals(e.canonical))u.c7(g,0,u.a5,u.a5,0,0,1);else if(f.canonical.isChildOf(e.canonical)){const c=f.canonical.z-e.canonical.z,p=f.canonical.x-(f.canonical.x>>c<>c<>c;u.c7(g,0,y,y,0,0,1),u.O(g,g,[-p*y,-m*y,0])}else{if(!e.canonical.isChildOf(f.canonical))continue;{const c=e.canonical.z-f.canonical.z,p=e.canonical.x-(e.canonical.x>>c<>c<>c;u.c7(g,0,u.a5,u.a5,0,0,1),u.O(g,g,[p*y,m*y,0]),u.Q(g,g,[1/2**c,1/2**c,0])}}m.terrainRttPosMatrix32f=new Float32Array(g),c[p]=m}return c}_getTerrainCoordsForTileRanges(e,c){const p={};for(const f of this._renderableTilesKeys){const m=this._tiles[f].tileID;if(!this._isWithinTileRanges(m,c))continue;const g=e.clone(),y=u.bk();if(m.canonical.z===e.canonical.z){const c=e.canonical.x-m.canonical.x+e.wrap*(1<e.canonical.z){const c=m.canonical.z-e.canonical.z,p=m.canonical.x-(m.canonical.x>>c<>c<>c),x=e.canonical.y-(m.canonical.y>>c),b=u.a5>>c;u.c7(y,0,b,b,0,0,1),u.O(y,y,[-p*b+g*u.a5,-f*b+x*u.a5,0])}else{const c=e.canonical.z-m.canonical.z,p=e.canonical.x-(e.canonical.x>>c<>c<>c)-m.canonical.x,x=(e.canonical.y>>c)-m.canonical.y,b=u.a5<u.maxzoom&&(p=u.maxzoom),p=u.minzoom&&!(null==f?void 0:f.dem);)f=this.findTileInCaches(e.scaledTo(p--).key);return f}findTileInCaches(e){let c=this.tileManager.getTileByID(e);return c||(c=this.tileManager._outOfViewCache.getByKey(e),c)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,c){const u=c[e.canonical.z];return!!u&&(e.wrap>u.minWrap||e.wrap=u.minTileXWrapped&&e.canonical.x<=u.maxTileXWrapped&&e.canonical.y>=u.minTileY&&e.canonical.y<=u.maxTileY)}}class is{constructor(e,c,u){this._meshCache={},this.painter=e,this.tileManager=new ts(c),this.options=u,this.exaggeration="number"==typeof u.exaggeration?u.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,c,p,f=u.a5){var m;const g=e.normalizeCoordinates(c,p,f);if(!g)return 0;const y=this.getTerrainData(g.tileID),x=null===(m=y.tile)||void 0===m?void 0:m.dem;if(!x)return 0;const b=u.cD([],[g.x/f*u.a5,g.y/f*u.a5],y.u_terrain_matrix),T=[b[0]*x.dim,b[1]*x.dim],S=Math.floor(T[0]),P=Math.floor(T[1]),I=T[0]-S,C=T[1]-P;return x.get(S,P)*(1-I)*(1-C)+x.get(S+1,P)*I*(1-C)+x.get(S,P+1)*(1-I)*C+x.get(S+1,P+1)*I*C}getElevationForLngLatZoom(e,c){if(!u.cE(c,e.wrap()))return 0;const{tileID:p,mercatorX:f,mercatorY:m}=this._getOverscaledTileIDFromLngLatZoom(e,c);return this.getElevation(p,f%u.a5,m%u.a5,u.a5)}getElevationForLngLat(e,c){const u=rt(c,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let p=0;for(const e of u)e.canonical.z>p&&(p=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,p)}getElevation(e,c,p,f=u.a5){return this.getDEMElevation(e,c,p,f)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const e=this.painter.context,c=new u.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new u.T(e,c,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new u.T(e,new u.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=u.ar([])}const c=this.tileManager.getSourceTile(e,!0);if(c&&c.dem&&(!c.demTexture||c.needsTerrainPrepare)){const e=this.painter.context;c.demTexture=this.painter.getTileTexture(c.dem.stride),c.demTexture?c.demTexture.update(c.dem.getPixels(),{premultiply:!1}):c.demTexture=new u.T(e,c.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),c.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),c.needsTerrainPrepare=!1}const p=c&&c.toString()+c.tileID.key+e.key;if(p&&!this._demMatrixCache[p]){const p=this.tileManager.getSource().maxzoom;let f=e.canonical.z-c.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=p?f=e.canonical.z-p:u.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=e.canonical.x-(e.canonical.x>>f<>f<>8<<4|e>>8,c[u+3]=0;const p=new u.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(c.buffer)),f=new u.T(e,p,e.gl.RGBA,{premultiply:!1});return f.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=f,f}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const c=new Uint8Array(4),p=this.painter.context,f=p.gl,m=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),g=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),y=Math.round(this.painter.height/devicePixelRatio);p.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),f.readPixels(m,y-g-1,1,1,f.RGBA,f.UNSIGNED_BYTE,c),p.bindFramebuffer.set(null);const x=c[0]+(c[2]>>4<<8),b=c[1]+((15&c[2])<<8),T=this.coordsIndex[255-c[3]],S=T&&this.tileManager.getTileByID(T);if(!S)return null;const P=this._coordsTextureSize,I=(1<0,f=p&&0===e.canonical.y,m=p&&e.canonical.y===(1<e.id!==c)),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 ta={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class os{constructor(e,c){this.painter=e,this.terrain=c,this.pool=new as(e.context,30,c.tileManager.tileSize*c.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,c){var u,p;this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter((u=>!e._layers[u].isHidden(c))),this._coordsAscending={};for(const c in e.tileManagers){this._coordsAscending[c]={};const u=e.tileManagers[c].getVisibleCoordinates(),p=e.tileManagers[c].getSource(),f=p instanceof te?p.terrainTileRanges:null;for(const e of u){const u=this.terrain.tileManager.getTerrainCoords(e,f);for(const e in u)this._coordsAscending[c][e]||(this._coordsAscending[c][e]=[]),this._coordsAscending[c][e].push(u[e])}}this._rttFingerprints={};for(const c of e._order){const f=e._layers[c],m=f.source;if(ta[f.type]&&!this._rttFingerprints[m]){this._rttFingerprints[m]={};const c=null!==(p=null===(u=e.tileManagers[m])||void 0===u?void 0:u.getState().revision)&&void 0!==p?p:0;for(const e in this._coordsAscending[m])this._rttFingerprints[m][e]=`${this._coordsAscending[m][e].map((e=>e.key)).sort().join()}#${c}`}}for(const e of this._renderableTiles)for(const c in this._rttFingerprints){const u=this._rttFingerprints[c][e.tileID.key];u&&u!==e.rttFingerprint[c]&&(e.rtt=[])}}renderLayer(e,c){if(e.isHidden(this.painter.transform.zoom))return!1;const p=Object.assign(Object.assign({},c),{isRenderingToTexture:!0}),f=e.type,m=this.painter,g=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(ta[f]&&(this._prevType&&ta[this._prevType]||this._stacks.push([]),this._prevType=f,this._stacks[this._stacks.length-1].push(e.id),!g))return!0;if(ta[this._prevType]||ta[f]&&g){this._prevType=f;const e=this._stacks.length-1,c=this._stacks[e]||[];for(const f of this._renderableTiles){if(this.pool.isFull()&&(_s(this.painter,this.terrain,this._rttTiles,p),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(f),f.rtt[e]){const c=this.pool.getObjectForId(f.rtt[e].id);if(c.stamp===f.rtt[e].stamp){this.pool.useObject(c);continue}}const g=this.pool.getOrCreateFreeObject();this.pool.useObject(g),this.pool.stampObject(g),f.rtt[e]={id:g.id,stamp:g.stamp},m.context.bindFramebuffer.set(g.fbo.framebuffer),m.context.clear({color:u.bp.transparent,stencil:0}),m.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=c;const f=new yo;this._rotatePitchHandler=new mo({clickTolerance:3,move:(e,f)=>{const m=c.getBoundingClientRect(),g=new u.P((m.bottom-m.top)/2,(m.right-m.left)/2);return{bearingDelta:u.cy(new u.P(e.x,f.y),f,g),pitchDelta:p?-.5*(f.y-e.y):void 0}},moveStateManager:f,enable:!0,assignEvents:()=>{}}),this.map=e,h.addEventListener(c,"mousedown",this.mousedown),h.addEventListener(c,"touchstart",this.touchstart,{passive:!1}),h.addEventListener(c,"touchcancel",this.reset)}startMove(e,c){this._rotatePitchHandler.dragStart(e,c),h.disableDrag()}move(e,c){const u=this.map,{bearingDelta:p,pitchDelta:f}=this._rotatePitchHandler.dragMove(e,c)||{};p&&u.setBearing(u.getBearing()+p),f&&u.setPitch(u.getPitch()+f)}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 il;function rl(e,c,p,f=!1){if(f||!p.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const m=new u.V(e.lng,e.lat);if(e=new u.V(e.lng,e.lat),c){const f=new u.V(e.lng-360,e.lat),m=new u.V(e.lng+360,e.lat),g=p.locationToScreenPoint(e).distSqr(c);p.locationToScreenPoint(f).distSqr(c)180;){const c=p.locationToScreenPoint(e);if(c.x>=0&&c.y>=0&&c.x<=p.width&&c.y<=p.height)break;e.lng>p.center.lng?e.lng-=360:e.lng+=360}return e.lng!==m.lng&&p.isPointOnMapSurface(p.locationToScreenPoint(e))?e:m}const nl={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 sl(e,c,u){const p=e.classList;for(const e in nl)p.remove(`maplibregl-${u}-anchor-${e}`);p.add(`maplibregl-${u}-anchor-${c}`)}class ms extends u.E{constructor(e){if(super(),this._onClick=e=>{this.fire(new u.l("click",{originalEvent:e}))},this._onKeyPress=e=>{const c=e.code,u=e.charCode||e.keyCode;"Space"!==c&&"Enter"!==c&&32!==u&&13!==u||this.togglePopup()},this._onMapClick=e=>{const c=e.originalEvent.target,u=this._element;this._popup&&(c===u||u.contains(c))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const c=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!c)&&this._map.once("render",this._update),this._lngLat=rl(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 u="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?u=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(u=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let p="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?p="rotateX(0deg)":"map"===this._pitchAlignment&&(p=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),h.setTransform(this._element,`${nl[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${p} ${u}`),x.frameAsync(new AbortController,this._map._ownerWindow).then((()=>{this._updateOpacity(e&&"moveend"===e.type)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){const c=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=c}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 u.l("dragstart"))),this.fire(new u.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 u.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=u.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create("div");const c=h.createNS("http://www.w3.org/2000/svg","svg"),p=41,f=27;c.setAttributeNS(null,"display","block"),c.setAttributeNS(null,"height",`${p}px`),c.setAttributeNS(null,"width",`${f}px`),c.setAttributeNS(null,"viewBox",`0 0 ${f} ${p}`);const m=h.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"stroke","none"),m.setAttributeNS(null,"stroke-width","1"),m.setAttributeNS(null,"fill","none"),m.setAttributeNS(null,"fill-rule","evenodd");const g=h.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill-rule","nonzero");const y=h.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"transform","translate(3.0, 29.0)"),y.setAttributeNS(null,"fill","#000000");const x=[{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 x){const c=h.createNS("http://www.w3.org/2000/svg","ellipse");c.setAttributeNS(null,"opacity","0.04"),c.setAttributeNS(null,"cx","10.5"),c.setAttributeNS(null,"cy","5.80029008"),c.setAttributeNS(null,"rx",e.rx),c.setAttributeNS(null,"ry",e.ry),y.appendChild(c)}const b=h.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=h.createNS("http://www.w3.org/2000/svg","path");T.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"),b.appendChild(T);const S=h.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const P=h.createNS("http://www.w3.org/2000/svg","path");P.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"),S.appendChild(P);const I=h.createNS("http://www.w3.org/2000/svg","g");I.setAttributeNS(null,"transform","translate(6.0, 7.0)"),I.setAttributeNS(null,"fill","#FFFFFF");const C=h.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"transform","translate(8.0, 8.0)");const R=h.createNS("http://www.w3.org/2000/svg","circle");R.setAttributeNS(null,"fill","#000000"),R.setAttributeNS(null,"opacity","0.25"),R.setAttributeNS(null,"cx","5.5"),R.setAttributeNS(null,"cy","5.5"),R.setAttributeNS(null,"r","5.4999962");const L=h.createNS("http://www.w3.org/2000/svg","circle");L.setAttributeNS(null,"fill","#FFFFFF"),L.setAttributeNS(null,"cx","5.5"),L.setAttributeNS(null,"cy","5.5"),L.setAttributeNS(null,"r","5.4999962"),C.appendChild(R),C.appendChild(L),g.appendChild(y),g.appendChild(b),g.appendChild(S),g.appendChild(I),g.appendChild(C),c.appendChild(g),c.setAttributeNS(null,"height",p*this._scale+"px"),c.setAttributeNS(null,"width",f*this._scale+"px"),this._element.appendChild(c),this._offset=u.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()})),sl(this._element,this._anchor,"marker"),this._element.addEventListener("click",this._onClick),e&&e.className)for(const c of e.className.split(" "))this._element.classList.add(c);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=u.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 c=38.1,u=13.5,p=Math.abs(u)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-c],"bottom-left":[p,-1*(c-u+p)],"bottom-right":[-p,-1*(c-u+p)],left:[u,-1*(c-u)],right:[-u,-1*(c-u)]}: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 c,p;const f=null===(c=this._map)||void 0===c?void 0:c.terrain,m=this._map.transform.isLocationOccluded(this._lngLat);if(!f||m){const e=m?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 g=this._map,y=g.terrain.depthAtPoint(this._pos),x=g.terrain.getElevationForLngLat(this._lngLat,g.transform);if(g.transform.lngLatToCameraDepth(this._lngLat,x)-y<.006)return void(this._element.style.opacity=this._opacity);const b=-this._offset.y/g.transform.pixelsPerMeter,T=Math.sin(g.getPitch()*Math.PI/180)*b,S=g.terrain.depthAtPoint(new u.P(this._pos.x,this._pos.y-this._offset.y)),P=g.transform.lngLatToCameraDepth(this._lngLat,x+T)-S>.006;(null===(p=this._popup)||void 0===p?void 0:p.isOpen())&&P&&this._popup.remove(),this._element.style.opacity=P?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=u.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,c){return(void 0===this._opacity||void 0===e&&void 0===c)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==c&&(this._opacityWhenCovered=c),this._map&&this._updateOpacity(!0),this}}const ol={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let al=0,ll=!1;const cl={maxWidth:100,unit:"metric"};function hl(e,c,u){const p=u&&u.maxWidth||100,f=e._container.clientHeight/2,m=e._container.clientWidth/2,g=e.unproject([m-p/2,f]),y=e.unproject([m+p/2,f]),x=Math.round(e.project(y).x-e.project(g).x),b=Math.min(p,x,e._container.clientWidth),T=g.distanceTo(y);if(u&&"imperial"===u.unit){const u=3.2808*T;u>5280?ul(c,b,u/5280,e._getUIString("ScaleControl.Miles")):ul(c,b,u,e._getUIString("ScaleControl.Feet"))}else u&&"nautical"===u.unit?ul(c,b,T/1852,e._getUIString("ScaleControl.NauticalMiles")):T>=1e3?ul(c,b,T/1e3,e._getUIString("ScaleControl.Kilometers")):ul(c,b,T,e._getUIString("ScaleControl.Meters"))}function ul(e,c,u,p){const f=function(e){const c=Math.pow(10,`${Math.floor(e)}`.length-1);let u=e/c;return u=u>=10?10:u>=5?5:u>=3?3:u>=2?2:u>=1?1:function(e){const c=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*c)/c}(u),c*u}(u);e.style.width=c*(f/u)+"px",e.innerHTML=`${f} ${p}`}const dl={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},pl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function fl(e){if(e){if("number"==typeof e){const c=Math.round(Math.abs(e)/Math.SQRT2);return{center:new u.P(0,0),top:new u.P(0,e),"top-left":new u.P(c,c),"top-right":new u.P(-c,c),bottom:new u.P(0,-e),"bottom-left":new u.P(c,-c),"bottom-right":new u.P(-c,-c),left:new u.P(e,0),right:new u.P(-e,0)}}if(e instanceof u.P||Array.isArray(e)){const c=u.P.convert(e);return{center:c,top:c,"top-left":c,"top-right":c,bottom:c,"bottom-left":c,"bottom-right":c,left:c,right:c}}return{center:u.P.convert(e.center||[0,0]),top:u.P.convert(e.top||[0,0]),"top-left":u.P.convert(e["top-left"]||[0,0]),"top-right":u.P.convert(e["top-right"]||[0,0]),bottom:u.P.convert(e.bottom||[0,0]),"bottom-left":u.P.convert(e["bottom-left"]||[0,0]),"bottom-right":u.P.convert(e["bottom-right"]||[0,0]),left:u.P.convert(e.left||[0,0]),right:u.P.convert(e.right||[0,0])}}return fl(new u.P(0,0))}const gl=p;c.AJAXError=u.cJ,c.EXTENT=u.a5,c.Event=u.l,c.Evented=u.E,c.LngLat=u.V,c.MercatorCoordinate=u.a9,c.Point=u.P,c.addProtocol=u.cK,c.config=u.c,c.removeProtocol=u.cL,c.AttributionControl=Yo,c.BoxZoomHandler=co,c.CanvasSource=ae,c.CooperativeGesturesHandler=Vo,c.DoubleClickZoomHandler=Oo,c.DragPanHandler=Zo,c.DragRotateHandler=Go,c.EdgeInsets=Nt,c.FullscreenControl=class extends u.E{constructor(e={}){var c;super(),this._onFullscreenChange=()=>{var e;let c=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;null===(e=null==c?void 0:c.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)c=c.shadowRoot.fullscreenElement;c===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=null!==(c=e.pseudo)&&void 0!==c&&c,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:u.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 u.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new u.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},c.GeoJSONSource=ee,c.GeolocateControl=class extends u.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new u.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 u.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const c=new u.V(e.coords.longitude,e.coords.latitude),p=e.coords.accuracy,f=this._map.getBearing(),m=u.e({bearing:f},this.options.fitBoundsOptions),g=$.fromLngLat(c,p);this._map.fitBounds(g,m,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const c=new u.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(c).addTo(this._map),this._userLocationDotMarker.setLngLat(c).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&&ll)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new u.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){u.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 c=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||c||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 u.l("trackuserlocationend")),this.fire(new u.l("userlocationlostfocus")))}))}},this.options=u.e({},ol,e)}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return u._(this,arguments,void 0,(function*(e=!1){if(void 0!==il&&!e)return il;if(void 0===window.navigator.permissions)return il=!!window.navigator.geolocation,il;try{const e=yield window.navigator.permissions.query({name:"geolocation"});il="denied"!==e.state}catch(e){il=!!window.navigator.geolocation}return il}))}().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,al=0,ll=!1}_isOutOfMapMaxBounds(e){const c=this._map.getMaxBounds(),u=e.coords;return c&&(u.longitudec.getEast()||u.latitudec.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 c=this._map.project(e),u=this._map.unproject([c.x+100,c.y]),p=e.distanceTo(u)/100,f=2*this._accuracy/p;this._circleElement.style.width=`${f.toFixed(2)}px`,this._circleElement.style.height=`${f.toFixed(2)}px`}trigger(){if(!this._setup)return u.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 u.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":al--,ll=!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 u.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 u.l("trackuserlocationstart")),this.fire(new u.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"),al++,al>1?(e={maximumAge:6e5,timeout:0},ll=!0):(e=this.options.positionOptions,ll=!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)}},c.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const c=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==c&&c?{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._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){h.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},c.Hash=$r,c.ImageSource=te,c.KeyboardHandler=Ao,c.LngLatBounds=$,c.LogoControl=Qo,c.Map=class extends Xo{get _ownerWindow(){var e,c;return(null===(c=null===(e=this._container)||void 0===e?void 0:e.ownerDocument)||void 0===c?void 0:c.defaultView)||window}constructor(e){var c,p;u.cH.mark(u.cI.create);const f=Object.assign(Object.assign(Object.assign({},el),e),{canvasContextAttributes:Object.assign(Object.assign({},el.canvasContextAttributes),e.canvasContextAttributes)});if(null!=f.minZoom&&null!=f.maxZoom&&f.minZoom>f.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=f.minPitch&&null!=f.maxPitch&&f.minPitch>f.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=f.minPitch&&f.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=f.maxPitch&&f.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const m=new $t,g=new Yt;void 0!==f.minZoom&&m.setMinZoom(f.minZoom),void 0!==f.maxZoom&&m.setMaxZoom(f.maxZoom),void 0!==f.minPitch&&m.setMinPitch(f.minPitch),void 0!==f.maxPitch&&m.setMaxPitch(f.maxPitch),void 0!==f.renderWorldCopies&&m.setRenderWorldCopies(f.renderWorldCopies),null!==f.transformConstrain&&m.setConstrainOverride(f.transformConstrain),super(m,g,{bearingSnap:f.bearingSnap,zoomSnap:f.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Jo,this._controls=[],this._mapId=u.af(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{if(e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){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[c]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${c}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new u.l("webglcontextlost",{originalEvent:e}))}else this.fire(new u.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 u.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=f.interactive,this._maxTileCacheSize=f.maxTileCacheSize,this._maxTileCacheZoomLevels=f.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},f.canvasContextAttributes),this._trackResize=!0===f.trackResize,this._bearingSnap=f.bearingSnap,this._zoomSnap=f.zoomSnap,this._centerClampedToGround=f.centerClampedToGround,this._refreshExpiredTiles=!0===f.refreshExpiredTiles,this._fadeDuration=f.fadeDuration,this._crossSourceCollisions=!0===f.crossSourceCollisions,this._collectResourceTiming=!0===f.collectResourceTiming,this._locale=Object.assign(Object.assign({},ia),f.locale),this._clickTolerance=f.clickTolerance,this._overridePixelRatio=f.pixelRatio,this._maxCanvasSize=f.maxCanvasSize,this._zoomLevelsToOverscale=f.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=f.transformCameraUpdate,this.transformConstrain=f.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===f.cancelPendingTileRequestsWhileZooming,void 0!==f.reduceMotion&&(x.prefersReducedMotion=f.reduceMotion),this._imageQueueHandle=F.addThrottleControl((()=>this.isMoving())),this._requestManager=new v(f.transformRequest),this._container=this._resolveContainer(f.container),f.maxBounds&&this.setMaxBounds(f.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&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new Ho(this,f),this._hash=f.hash&&new $r("string"==typeof f.hash&&f.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:f.center,elevation:f.elevation,zoom:f.zoom,bearing:f.bearing,pitch:f.pitch,roll:f.roll}),f.bounds&&(this.resize(),this.fitBounds(f.bounds,u.e({},f.fitBoundsOptions,{duration:0}))));const y="string"==typeof f.style||!("globe"===(null===(p=null===(c=f.style)||void 0===c?void 0:c.projection)||void 0===p?void 0:p.type));this.resize(null,y),this._localIdeographFontFamily=f.localIdeographFontFamily,this._validateStyle=f.validateStyle,f.style&&this.setStyle(f.style,{localIdeographFontFamily:f.localIdeographFontFamily}),f.attributionControl&&this.addControl(new Yo("boolean"==typeof f.attributionControl?void 0:f.attributionControl)),f.maplibreLogo&&this.addControl(new Qo,f.logoPosition),this.on("style.load",(()=>{if(y||this._resizeTransform(),this.transform.unmodified){const e=u.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new u.l(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new u.l(`${e.dataType}dataloading`,e))})),this.on("dataabort",(e=>{this.fire(new u.l("sourcedataabort",e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,c){return this.style.setGlobalStateProperty(e,c),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,c){if(void 0===c&&(c=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new u.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const p=e.onAdd(this);this._controls.push(e);const f=this._controlPositions[c];return-1!==c.indexOf("bottom")?f.insertBefore(p,f.firstChild):f.appendChild(p),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new u.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const c=this._controls.indexOf(e);return c>-1&&this._controls.splice(c,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return rt(this.transform,e)}calculateCameraOptionsFromTo(e,c,u,p){return null==p&&this.terrain&&(p=this.terrain.getElevationForLngLat(u,this.transform)),super.calculateCameraOptionsFromTo(e,c,u,p)}resize(e,c=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(c);const p=!this._moving;return p&&(this.stop(),this.fire(new u.l("movestart",e)).fire(new u.l("move",e))),this.fire(new u.l("resize",e)),p&&this.fire(new u.l("moveend",e)),this}_resizeInternal(e=!0){const[c,u]=this._containerDimensions(),p=this._getClampedPixelRatio(c,u);if(this._resizeCanvas(c,u,p),this.painter.resize(c,u,p),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const p=this._getClampedPixelRatio(c,u);this._resizeCanvas(c,u,p),this.painter.resize(c,u,p)}this._resizeTransform(e)}_resizeTransform(e=!0){var c;const[u,p]=this._containerDimensions();this.transform.resize(u,p,e),null===(c=this._requestedCameraState)||void 0===c||c.resize(u,p,e)}_getClampedPixelRatio(e,c){const{0:u,1:p}=this._maxCanvasSize,f=this.getPixelRatio(),m=e*f,g=c*f;return Math.min(m>u?u/m:1,g>p?p/g:1)*f}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 c=this.transform.zoom,p=this._getTransformForUpdate();return p.setMinZoom(e),this._applyUpdatedTransform(p),this._update(),c!==this.transform.zoom&&this.fire(new u.l("zoomstart")).fire(new u.l("zoom")).fire(new u.l("zoomend")).fire(new u.l("movestart")).fire(new u.l("move")).fire(new u.l("moveend")),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 c=this.transform.zoom,p=this._getTransformForUpdate();return p.setMaxZoom(e),this._applyUpdatedTransform(p),this._update(),c!==this.transform.zoom&&this.fire(new u.l("zoomstart")).fire(new u.l("zoom")).fire(new u.l("zoomend")).fire(new u.l("movestart")).fire(new u.l("move")).fire(new u.l("moveend")),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){const c=this.transform.pitch,p=this._getTransformForUpdate();return p.setMinPitch(e),this._applyUpdatedTransform(p),this._update(),c!==this.transform.pitch&&this.fire(new u.l("pitchstart")).fire(new u.l("pitch")).fire(new u.l("pitchend")).fire(new u.l("movestart")).fire(new u.l("move")).fire(new u.l("moveend")),this}throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?60:e)>180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch){const c=this.transform.pitch,p=this._getTransformForUpdate();return p.setMaxPitch(e),this._applyUpdatedTransform(p),this._update(),c!==this.transform.pitch&&this.fire(new u.l("pitchstart")).fire(new u.l("pitch")).fire(new u.l("pitchend")).fire(new u.l("movestart")).fire(new u.l("move")).fire(new u.l("moveend")),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(u.V.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(u.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,c,u){if("mouseenter"===e||"mouseover"===e){let p=!1;const f=f=>{const m=c.filter((e=>this.getLayer(e))),g=0!==m.length?this.queryRenderedFeatures(f.point,{layers:m}):[];g.length?p||(p=!0,u.call(this,new ao(e,this,f.originalEvent,{features:g}))):p=!1};return{layers:c,listener:u,delegates:{mousemove:f,mouseout:()=>{p=!1}}}}if("mouseleave"===e||"mouseout"===e){let p=!1;const f=f=>{const m=c.filter((e=>this.getLayer(e)));(0!==m.length?this.queryRenderedFeatures(f.point,{layers:m}):[]).length?p=!0:p&&(p=!1,u.call(this,new ao(e,this,f.originalEvent)))},m=c=>{p&&(p=!1,u.call(this,new ao(e,this,c.originalEvent)))};return{layers:c,listener:u,delegates:{mousemove:f,mouseout:m}}}{const p=e=>{const p=c.filter((e=>this.getLayer(e))),f=0!==p.length?this.queryRenderedFeatures(e.point,{layers:p}):[];f.length&&(e.features=f,u.call(this,e),delete e.features)};return{layers:c,listener:u,delegates:{[e]:p}}}}_saveDelegatedListener(e,c){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(c)}_removeDelegatedListener(e,c,u){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const p=this._delegatedListeners[e];for(let e=0;ec.includes(e)))){for(const e in f.delegates)this.off(e,f.delegates[e]);return void p.splice(e,1)}}}on(e,c,u){if(void 0===u)return super.on(e,c);const p="string"==typeof c?[c]:c,f=this._createDelegatedListener(e,p,u);this._saveDelegatedListener(e,f);for(const e in f.delegates)this.on(e,f.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,p,u)}}}once(e,c,u){if(void 0===u)return super.once(e,c);const p="string"==typeof c?[c]:c,f=this._createDelegatedListener(e,p,u);for(const c in f.delegates){const m=f.delegates[c];f.delegates[c]=(...c)=>{this._removeDelegatedListener(e,p,u),m(...c)}}this._saveDelegatedListener(e,f);for(const e in f.delegates)this.once(e,f.delegates[e]);return this}off(e,c,u){return void 0===u?super.off(e,c):(this._removeDelegatedListener(e,"string"==typeof c?[c]:c,u),this)}queryRenderedFeatures(e,c){if(!this.style)return[];let p;const f=e instanceof u.P||Array.isArray(e),m=f?e:[[0,0],[this.transform.width,this.transform.height]];if(c=c||(f?{}:e)||{},m instanceof u.P||"number"==typeof m[0])p=[u.P.convert(m)];else{const e=u.P.convert(m[0]),c=u.P.convert(m[1]);p=[e,new u.P(c.x,e.y),c,new u.P(e.x,c.y),e]}return this.style.queryRenderedFeatures(p,c,this.transform)}querySourceFeatures(e,c){return this.style.querySourceFeatures(e,c)}setStyle(e,c){return!1!==(c=u.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},c)).diff&&c.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,c),this):(this._localIdeographFontFamily=c.localIdeographFontFamily,this._updateStyle(e,c))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const c=this._locale[e];if(null==c)throw new Error(`Missing UI string '${e}'`);return c}_updateStyle(e,c){var u,p;if(c.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,c)));const f=this.style&&c.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new ki(this,c||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,c,f):this.style.loadJSON(e,c,f),this):(null===(p=null===(u=this.style)||void 0===u?void 0:u.projection)||void 0===p||p.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,c){if("string"==typeof e){const p=this._requestManager.transformRequest(e,"Style");u.j(p,new AbortController).then((e=>{this._updateDiff(e.data,c)})).catch((e=>{e&&this.fire(new u.k(e))}))}else"object"==typeof e&&this._updateDiff(e,c)}_updateDiff(e,c){try{this.style.setState(e,c)&&this._update(!0)}catch(p){u.w(`Unable to perform style diff: ${p.message||p.error||p}. Rebuilding the style from scratch.`),this._updateStyle(e,c)}}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():u.w("There is no style added to the map.")}addSource(e,c){return this._lazyInitEmptyStyle(),this.style.addSource(e,c),this._update(!0)}isSourceLoaded(e){const c=this.style&&this.style.tileManagers[e];if(void 0!==c)return c.loaded();this.fire(new u.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 c=this.style.tileManagers[e.source];if(!c)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&c.reload();for(const c in this.style._layers){const p=this.style._layers[c];"hillshade"===p.type&&p.source===e.source&&u.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"===p.type&&p.source===e.source&&u.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,c,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=c=>{var u;"style"===c.dataType?this.terrain.tileManager.freeRtt():"source"===c.dataType&&c.tile&&(c.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===(u=c.source)||void 0===u?void 0:u.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(c.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 u.l("terrain",{terrain:e})),this}getTerrain(){var e,c;return null!==(c=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==c?c:null}areTilesLoaded(){const e=this.style&&this.style.tileManagers;for(const c of Object.values(e))if(!c.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,c,u){if(u){const p=this.getSource(u);if(!p)throw new Error(`There is no source with ID "${u}", cannot set LOD parameters`);p.calculateTileZoom=et(Math.max(1,e),Math.max(1,c))}else for(const u in this.style.tileManagers)this.style.tileManagers[u].getSource().calculateTileZoom=et(Math.max(1,e),Math.max(1,c));return this._update(!0),this}refreshTiles(e,c){const p=this.style.tileManagers[e];if(!p)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===c?p.reload(!0):p.refreshTiles(c.map((e=>new u.ac(e.z,e.x,e.y))))}addImage(e,c,p={}){const{pixelRatio:f=1,sdf:m=!1,stretchX:g,stretchY:y,content:b,textFitWidth:T,textFitHeight:S}=p;if(this._lazyInitEmptyStyle(),!(c instanceof HTMLImageElement||u.b(c))){if(void 0===c.width||void 0===c.height)return this.fire(new u.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:p,height:x,data:P}=c,I=c;return this.style.addImage(e,{data:new u.R({width:p,height:x},new Uint8Array(P)),pixelRatio:f,stretchX:g,stretchY:y,content:b,textFitWidth:T,textFitHeight:S,sdf:m,version:0,userImage:I}),I.onAdd&&I.onAdd(this,e),this}}{const{width:p,height:P,data:I}=x.getImageData(c);this.style.addImage(e,{data:new u.R({width:p,height:P},I),pixelRatio:f,stretchX:g,stretchY:y,content:b,textFitWidth:T,textFitHeight:S,sdf:m,version:0})}}updateImage(e,c){const p=this.style.getImage(e);if(!p)return this.fire(new u.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const f=c instanceof HTMLImageElement||u.b(c)?x.getImageData(c):c,{width:m,height:g,data:y}=f;if(void 0===m||void 0===g)return this.fire(new u.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(m!==p.data.width||g!==p.data.height)return this.fire(new u.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const b=!(c instanceof HTMLImageElement||u.b(c));return p.data.replace(y,b),this.style.updateImage(e,p),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new u.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return F.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,c){return this._lazyInitEmptyStyle(),this.style.addLayer(e,c),this._update(!0)}moveLayer(e,c){return this.style.moveLayer(e,c),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,c,u){return this.style.setLayerZoomRange(e,c,u),this._update(!0)}setFilter(e,c,u={}){return this.style.setFilter(e,c,u),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,c,u,p={}){return this.style.setPaintProperty(e,c,u,p),this._update(!0)}getPaintProperty(e,c){return this.style.getPaintProperty(e,c)}setLayoutProperty(e,c,u,p={}){return this.style.setLayoutProperty(e,c,u,p),this._update(!0)}getLayoutProperty(e,c){return this.style.getLayoutProperty(e,c)}setGlyphs(e,c={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,c),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,c,u={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,c,u,(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,c={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,c,(e=>{e||this._update(!0)})),this}setLight(e,c={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,c),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,c={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,c),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,c){return this.style.setFeatureState(e,c),this._update()}removeFeatureState(e,c){return this.style.removeFeatureState(e,c),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,c=0;return this._container&&(e=this._container.clientWidth||400,c=this._container.clientHeight||300),[e,c]}_setupResizeObserver(){var e;let c=!1;const u=ys((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50),p=null!==(e=this._ownerWindow.ResizeObserver)&&void 0!==e?e:ResizeObserver;this._resizeObserver=new p((e=>{c?u(e):c=!0})),this._resizeObserver.observe(this._container)}_resolveContainer(e){if("string"==typeof e){const c=document.getElementById(e);if(!c)throw new Error(`Container '${e}' not found.`);return c}if(e instanceof HTMLElement)return e;if(e&&"object"==typeof e&&1===e.nodeType)return e;throw new Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const c=this._canvasContainer=h.create("div","maplibregl-canvas-container",e);this._interactive&&c.classList.add("maplibregl-interactive"),this._canvas=h.create("canvas","maplibregl-canvas",c),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 u=this._containerDimensions(),p=this._getClampedPixelRatio(u[0],u[1]);this._resizeCanvas(u[0],u[1],p);const f=this._controlContainer=h.create("div","maplibregl-control-container",e),m=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{m[e]=h.create("div",`maplibregl-ctrl-${e} `,f)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,c,u){this._canvas.width=Math.floor(u*e),this._canvas.height=Math.floor(u*c),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${c}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let c=null;this._canvas.addEventListener("webglcontextcreationerror",(u=>{c={requestedAttributes:e},u&&(c.statusMessage=u.statusMessage,c.type=u.type)}),{once:!0});let u=null;if(u=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!u){const e="Failed to initialize WebGL";throw c?(c.message=e,new Error(JSON.stringify(c))):new Error(e)}this.painter=new qr(u,this.transform),S.testSupport(u)}migrateProjection(e,c){super.migrateProjection(e,c),this.painter.transform=e,this.fire(new u.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 c,p,f,m,g;const y=this._idleTriggered?this._fadeDuration:0,x=(null===(c=this.style.projection)||void 0===c?void 0:c.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let b=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,c=T();this.style.zoomHistory.update(e,c);const p=new u.H(e,{now:c,fadeDuration:y,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),f=p.crossFadingFactor();1===f&&f===this._crossFadingFactor||(b=!0,this._crossFadingFactor=f),this.style.update(p)}const S=(null===(p=this.style.projection)||void 0===p?void 0:p.transitionState)>0!==x;null===(f=this.style.projection)||void 0===f||f.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(m=this.style.projection)||void 0===m?void 0:m.transitionState,null===(g=this.style.projection)||void 0===g?void 0:g.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||S)&&(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,y,this._crossSourceCollisions,S),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:y,showPadding:this.showPadding}),this.fire(new u.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,u.cH.mark(u.cI.load),this.fire(new u.l("load"))),this.style&&(this.style.hasTransitions()||b)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const P=this._sourcesDirty||this._styleDirty||this._placementDirty;return P||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new u.l("idle")),!this._loaded||this._fullyLoaded||P||(this._fullyLoaded=!0,u.cH.mark(u.cI.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&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),F.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const c=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==c?void 0:c.loseContext)&&c.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"),u.cH.remove(),this._removed=!0,this.fire(new u.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,x.frame(this._frameRequest,(e=>{u.cH.recordStartOfFrameAt(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!u.Z(e)&&!function(e){return e.message===Tn}(e))throw e}}),(()=>{}),this._ownerWindow))}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 na}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},c.MapMouseEvent=ao,c.MapTouchEvent=ro,c.MapWheelEvent=oo,c.Marker=ms,c.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),c=e===this._map.getMaxZoom(),u=e===this._map.getMinZoom();this._zoomInButton.disabled=c,this._zoomOutButton.disabled=u,this._zoomInButton.setAttribute("aria-disabled",c.toString()),this._zoomOutButton.setAttribute("aria-disabled",u.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,c)=>{const u=this._map._getUIString(`NavigationControl.${c}`);e.title=u,e.setAttribute("aria-label",u)},this.options=u.e({},tl,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,c){const u=h.create("button",e,this._container);return u.type="button",u.addEventListener("click",c),u}},c.Popup=class extends u.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 u.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=rl(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const c=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 u=this.options.anchor;const p=fl(this.options.offset);if(!u){const e=this._container.offsetWidth,f=this._container.offsetHeight,m=function(e){var c,u,p,f;return e?{top:null!==(c=e.top)&&void 0!==c?c:0,right:null!==(u=e.right)&&void 0!==u?u:0,bottom:null!==(p=e.bottom)&&void 0!==p?p:0,left:null!==(f=e.left)&&void 0!==f?f:0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);let g;g=c.y+p.bottom.ythis._map.transform.height-f-m.bottom?["bottom"]:[],c.xthis._map.transform.width-e/2-m.right&&g.push("right"),u=0===g.length?"bottom":g.join("-")}let f=c.add(p[u]);this.options.subpixelPositioning||(f=f.round()),h.setTransform(this._container,`${nl[u]} translate(${f.x}px,${f.y}px)`),sl(this._container,u,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=u.e(Object.create(dl),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 u.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=u.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 c=document.createDocumentFragment(),u=document.createElement("body");let p;for(u.innerHTML=e;p=u.firstChild,p;)c.appendChild(p);return this.setDOMContent(c)}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(pl);e&&e.focus()}},c.RasterDEMTileSource=Y,c.RasterTileSource=K,c.ScaleControl=class{constructor(e){this._onMove=()=>{hl(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,hl(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},cl),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}},c.ScrollZoomHandler=Bo,c.Style=ki,c.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}},c.TwoFingersTouchPitchHandler=Ro,c.TwoFingersTouchRotateHandler=So,c.TwoFingersTouchZoomHandler=Mo,c.TwoFingersTouchZoomRotateHandler=Uo,c.VectorTileSource=X,c.VideoSource=ie,c.addSourceType=(e,c)=>u._(void 0,void 0,void 0,(function*(){if(ve(e))throw new Error(`A source type called "${e}" already exists.`);((e,c)=>{xe[e]=c})(e,c)})),c.clearPrewarmedResources=function(){const e=re;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Q),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()"))},c.createTileMesh=hr,c.getMaxParallelImageRequests=function(){return u.c.MAX_PARALLEL_IMAGE_REQUESTS},c.getRTLTextPluginStatus=function(){return Se().getRTLTextPluginStatus()},c.getVersion=function(){return gl},c.getWorkerCount=function(){return k.workerCount},c.getWorkerUrl=function(){return u.c.WORKER_URL},c.importScriptInWorkers=function(e){return ce().broadcast("IS",e)},c.isTimeFrozen=function(){return b.isFrozen()},c.now=T,c.prewarm=function(){le().acquire(Q)},c.restoreNow=function(){b.restoreNow()},c.setMaxParallelImageRequests=function(e){u.c.MAX_PARALLEL_IMAGE_REQUESTS=e},c.setNow=function(e){b.setNow(e)},c.setRTLTextPlugin=function(e,c){return Se().setRTLTextPlugin(e,c)},c.setWorkerCount=function(e){k.workerCount=e},c.setWorkerUrl=function(e){u.c.WORKER_URL=e}}));var f=c;return f}));var u=c;export{u as default};