From e12a31891ae7cc78f9589216509b17d716e9c674 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 15:30:52 +0000 Subject: [PATCH] Update maplibre-gl to version 5.6.2 --- 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 778d37041..7d3989354 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -29,7 +29,7 @@ under: "mapbox-gl-draw-paint-mode", preload: false # https://github.com/maplibre/maplibre-gl-js -pin "maplibre-gl", preload: false # @5.6.1 +pin "maplibre-gl", preload: false # @5.6.2 # 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 3373aec11..cccfb79db 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 r={}; +var e=typeof globalThis!=="undefined"?globalThis:typeof self!=="undefined"?self:global;var s={}; /** * MapLibre GL JS - * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.6.1/LICENSE.txt - */(function(e,a){r=a()})(0,(function(){var r={};var a={};function l(e,l,c){a[e]=c;if(e==="index"){var h="var sharedModule = {}; ("+a.shared+")(sharedModule); ("+a.worker+")(sharedModule);";var u={};a.shared(u);a.index(r,u);typeof window!=="undefined"&&r.setWorkerUrl(window.URL.createObjectURL(new Blob([h],{type:"text/javascript"})));return r}}l("shared",["exports"],(function(r){function a(e,r,a,l){return new(a||(a=Promise))((function(c,h){function u(e){try{g(l.next(e))}catch(e){h(e)}}function p(e){try{g(l.throw(e))}catch(e){h(e)}}function g(e){var r;e.done?c(e.value):(r=e.value,r instanceof a?r:new a((function(e){e(r)}))).then(u,p)}g((l=l.apply(e,r||[])).next())}))}function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c,h;function u(){if(h)return c;function r(r,a){(this||e).x=r,(this||e).y=a}return h=1,c=r,r.prototype={clone:function(){return new r((this||e).x,(this||e).y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,r){return this.clone()._rotateAround(e,r)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt((this||e).x*(this||e).x+(this||e).y*(this||e).y)},equals:function(r){return(this||e).x===r.x&&(this||e).y===r.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(r){var a=r.x-(this||e).x,l=r.y-(this||e).y;return a*a+l*l},angle:function(){return Math.atan2((this||e).y,(this||e).x)},angleTo:function(r){return Math.atan2((this||e).y-r.y,(this||e).x-r.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(r,a){return Math.atan2((this||e).x*a-(this||e).y*r,(this||e).x*r+(this||e).y*a)},_matMult:function(r){var a=r[2]*(this||e).x+r[3]*(this||e).y;return(this||e).x=r[0]*(this||e).x+r[1]*(this||e).y,(this||e).y=a,this||e},_add:function(r){return(this||e).x+=r.x,(this||e).y+=r.y,this||e},_sub:function(r){return(this||e).x-=r.x,(this||e).y-=r.y,this||e},_mult:function(r){return(this||e).x*=r,(this||e).y*=r,this||e},_div:function(r){return(this||e).x/=r,(this||e).y/=r,this||e},_multByPoint:function(r){return(this||e).x*=r.x,(this||e).y*=r.y,this||e},_divByPoint:function(r){return(this||e).x/=r.x,(this||e).y/=r.y,this||e},_unit:function(){return this._div(this.mag()),this||e},_perp:function(){var r=(this||e).y;return(this||e).y=(this||e).x,(this||e).x=-r,this||e},_rotate:function(r){var a=Math.cos(r),l=Math.sin(r),c=l*(this||e).x+a*(this||e).y;return(this||e).x=a*(this||e).x-l*(this||e).y,(this||e).y=c,this||e},_rotateAround:function(r,a){var l=Math.cos(r),c=Math.sin(r),h=a.y+c*((this||e).x-a.x)+l*((this||e).y-a.y);return(this||e).x=a.x+l*((this||e).x-a.x)-c*((this||e).y-a.y),(this||e).y=h,this||e},_round:function(){return(this||e).x=Math.round((this||e).x),(this||e).y=Math.round((this||e).y),this||e}},r.convert=function(e){return e instanceof r?e:Array.isArray(e)?new r(e[0],e[1]):e},c}"function"==typeof SuppressedError&&SuppressedError;var p,g,y=l(u()),x=function(){if(g)return p;function r(r,a,l,c){(this||e).cx=3*r,(this||e).bx=3*(l-r)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*a,(this||e).by=3*(c-a)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=r,(this||e).p1y=a,(this||e).p2x=l,(this||e).p2y=c}return g=1,p=r,r.prototype={sampleCurveX:function(r){return(((this||e).ax*r+(this||e).bx)*r+(this||e).cx)*r},sampleCurveY:function(r){return(((this||e).ay*r+(this||e).by)*r+(this||e).cy)*r},sampleCurveDerivativeX:function(r){return(3*(this||e).ax*r+2*(this||e).bx)*r+(this||e).cx},solveCurveX:function(e,r){if(void 0===r&&(r=1e-6),e<0)return 0;if(e>1)return 1;for(var a=e,l=0;l<8;l++){var c=this.sampleCurveX(a)-e;if(Math.abs(c)c?u=a:p=a,a=.5*(p-u)+u;return a},solve:function(e,r){return this.sampleCurveY(this.solveCurveX(e,r))}},p}(),v=l(x);let w,M;function C(){return null==w&&(w="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),w}function A(){if(null==M&&(M=!1,C())){const e=5,r=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(r){for(let a=0;a=1)return 1;const r=e*e,a=r*e;return 4*(e<.5?a:3*(e-r)+a-.75)}function ut(e,r,a,l){const c=new v(e,r,a,l);return e=>c.solve(e)}const yt=ut(.25,.1,.25,1);function Pt(e,r,a){return Math.min(a,Math.max(r,e))}function St(e,r,a){const l=a-r,c=((e-r)%l+l)%l+r;return c===r?a:c}function Ct(e,...r){for(const a of r)for(const r in a)e[r]=a[r];return e}let Et=1;function kt(r,a,l){const c={};for(const l in r)c[l]=a.call(this||e,r[l],l,r);return c}function Bt(r,a,l){const c={};for(const l in r)a.call(this||e,r[l],l,r)&&(c[l]=r[l]);return c}function Nt(e){return Array.isArray(e)?e.map(Nt):"object"==typeof e&&e?kt(e,Nt):e}const $t={};function Gt(e){$t[e]||("undefined"!=typeof console&&console.warn(e),$t[e]=!0)}function qt(e,r,a){return(a.y-e.y)*(r.x-e.x)>(r.y-e.y)*(a.x-e.x)}function Ht(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Xt=null;function Kt(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const Qt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function ee(r,l,c,h,u){return a(this||e,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(r,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const p=a.startsWith("BGR"),g=new Uint8ClampedArray(h*u*4);if(yield e.copyTo(g,function(e,r,a,l,c){const h=4*Math.max(-r,0),u=(Math.max(0,a)-a)*l*4+h,p=4*l,g=Math.max(0,r),y=Math.max(0,a);return{rect:{x:g,y:y,width:Math.min(e.width,r+l)-g,height:Math.min(e.height,a+c)-y},layout:[{offset:u,stride:p}]}}(r,l,c,h,u)),p)for(let e=0;e{e.removeEventListener(r,a,l)}}}function ce(e){return e*Math.PI/180}function he(e){return e/Math.PI*180}const ue={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},de={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},pe="AbortError";function fe(){return new Error(pe)}const me={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function _e(e){return me.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const ge="global-dispatcher";class pt extends Error{constructor(e,r,a,l){super(`AJAXError: ${r} (${e}): ${a}`),this.status=e,this.statusText=r,this.url=a,this.body=l}}const ye=()=>Ht(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,ve=function(r,l){if(/:\/\//.test(r.url)&&!/^https?:|^file:/.test(r.url)){const e=_e(r.url);if(e)return e(r,l);if(Ht(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,targetMapId:ge},l)}if(!(/^file:/.test(c=r.url)||/^file:/.test(ye())&&!/^\w+:/.test(c))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(r,l){return a(this||e,void 0,void 0,(function*(){const e=new Request(r.url,{method:r.method||"GET",body:r.body,credentials:r.credentials,headers:r.headers,cache:r.cache,referrer:ye(),signal:l.signal});let a,c;"json"!==r.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{a=yield fetch(e)}catch(e){throw new pt(0,e.message,r.url,new Blob)}if(!a.ok){const e=yield a.blob();throw new pt(a.status,a.statusText,r.url,e)}c="arrayBuffer"===r.type||"image"===r.type?a.arrayBuffer():"json"===r.type?a.json():a.text();const h=yield c;if(l.signal.aborted)throw fe();return{data:h,cacheControl:a.headers.get("Cache-Control"),expires:a.headers.get("Expires")}}))}(r,l);if(Ht(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,mustQueue:!0,targetMapId:ge},l)}var c;return function(e,r){return new Promise(((a,l)=>{var c;const h=new XMLHttpRequest;h.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(h.responseType="arraybuffer");for(const r in e.headers)h.setRequestHeader(r,e.headers[r]);"json"===e.type&&(h.responseType="text",(null===(c=e.headers)||void 0===c?void 0:c.Accept)||h.setRequestHeader("Accept","application/json")),h.withCredentials="include"===e.credentials,h.onerror=()=>{l(new Error(h.statusText))},h.onload=()=>{if(!r.signal.aborted)if((h.status>=200&&h.status<300||0===h.status)&&null!==h.response){let r=h.response;if("json"===e.type)try{r=JSON.parse(h.response)}catch(e){return void l(e)}a({data:r,cacheControl:h.getResponseHeader("Cache-Control"),expires:h.getResponseHeader("Expires")})}else{const r=new Blob([h.response],{type:h.getResponseHeader("Content-Type")});l(new pt(h.status,h.statusText,e.url,r))}},r.signal.addEventListener("abort",(()=>{h.abort(),l(fe())})),h.send(e.body)}))}(r,l)};function be(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const r=new URL(e),a=window.location;return r.protocol===a.protocol&&r.host===a.host}function we(e,r,a){a[e]&&-1!==a[e].indexOf(r)||(a[e]=a[e]||[],a[e].push(r))}function Se(e,r,a){if(a&&a[e]){const l=a[e].indexOf(r);-1!==l&&a[e].splice(l,1)}}class xt{constructor(e,r={}){Ct(this,r),this.type=e}}class vt extends xt{constructor(e,r={}){super("error",Ct({error:e},r))}}class bt{on(e,r){return this._listeners=this._listeners||{},we(e,r,this._listeners),{unsubscribe:()=>{this.off(e,r)}}}off(e,r){return Se(e,r,this._listeners),Se(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},we(e,r,this._oneTimeListeners),this):new Promise((r=>this.once(e,r)))}fire(e,r){"string"==typeof e&&(e=new xt(e,r||{}));const a=e.type;if(this.listens(a)){e.target=this;const r=this._listeners&&this._listeners[a]?this._listeners[a].slice():[];for(const a of r)a.call(this,e);const l=this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[];for(const r of l)Se(a,r,this._oneTimeListeners),r.call(this,e);const c=this._eventedParent;c&&(Ct(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),c.fire(e))}else e instanceof vt&&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,r){return this._eventedParent=e,this._eventedParentData=r,this}}var Me={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},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"},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},"*":{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:"*"},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","property-type":"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","property-type":"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","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"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","property-type":"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","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},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:"*",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"]},"property-type":"cross-faded"},"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"}}};const Ie=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Ae(e,r){const a={};for(const r in e)"ref"!==r&&(a[r]=e[r]);return Ie.forEach((e=>{e in r&&(a[e]=r[e])})),a}function ze(e,r){if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(let a=0;a`:"value"===e.itemType.kind?"array":`array<${r}>`}return e.kind}const zi=[ei,ii,ri,si,li,ci,yi,di,Ei(mi),xi,Mi,Ti,Ii,Ci];function ki(e,r){if("error"===r.kind)return null;if("array"===e.kind){if("array"===r.kind&&(0===r.N&&"value"===r.itemType.kind||!ki(e.itemType,r.itemType))&&("number"!=typeof e.N||e.N===r.N))return null}else{if(e.kind===r.kind)return null;if("value"===e.kind)for(const e of zi)if(!ki(e,r))return null}return`Expected ${Ai(e)} but found ${Ai(r)} instead.`}function Ri(e,r){return r.some((r=>r.kind===e.kind))}function Di(e,r){return r.some((r=>"null"===r?null===e:"array"===r?Array.isArray(e):"object"===r?e&&!Array.isArray(e)&&"object"==typeof e:r===typeof e))}function Li(e,r){return"array"===e.kind&&"array"===r.kind?e.itemType.kind===r.itemType.kind&&"number"==typeof e.N:e.kind===r.kind}const Fi=.96422,Bi=.82521,Oi=4/29,ji=6/29,Vi=3*ji*ji,Ni=ji*ji*ji,Ui=Math.PI/180,Zi=180/Math.PI;function $i(e){return(e%=360)<0&&(e+=360),e}function Gi([e,r,a,l]){let c,h;const u=Wi((.2225045*(e=qi(e))+.7168786*(r=qi(r))+.0606169*(a=qi(a)))/1);e===r&&r===a?c=h=u:(c=Wi((.4360747*e+.3850649*r+.1430804*a)/Fi),h=Wi((.0139322*e+.0971045*r+.7141733*a)/Bi));const p=116*u-16;return[p<0?0:p,500*(c-u),200*(u-h),l]}function qi(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Wi(e){return e>Ni?Math.pow(e,1/3):e/Vi+Oi}function Hi([e,r,a,l]){let c=(e+16)/116,h=isNaN(r)?c:c+r/500,u=isNaN(a)?c:c-a/200;return c=1*Yi(c),h=Fi*Yi(h),u=Bi*Yi(u),[Xi(3.1338561*h-1.6168667*c-.4906146*u),Xi(-.9787684*h+1.9161415*c+.033454*u),Xi(.0719453*h-.2289914*c+1.4052427*u),l]}function Xi(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function Yi(e){return e>ji?e*e*e:Vi*(e-Oi)}const Ki=Object.hasOwn||function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};function Ji(e,r){return Ki(e,r)?e[r]:void 0}function Qi(e){return parseInt(e.padEnd(2,e),16)/255}function lr(e,r){return cr(r?e/100:e,0,1)}function cr(e,r,a){return Math.min(Math.max(r,e),a)}function hr(e){return!e.some(Number.isNaN)}const dr={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 pr(e,r,a){return e+a*(r-e)}function fr(e,r,a){return e.map(((e,l)=>pr(e,r[l],a)))}class Pe{constructor(e,r,a,l=1,c=!0){this.r=e,this.g=r,this.b=a,this.a=l,c||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[e,r,a,l]))}static parse(e){if(e instanceof Pe)return e;if("string"!=typeof e)return;const r=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const r=Ji(dr,e);if(r){const[e,a,l]=r;return[e/255,a/255,l/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const r=e.length<6?1:2;let a=1;return[Qi(e.slice(a,a+=r)),Qi(e.slice(a,a+=r)),Qi(e.slice(a,a+=r)),Qi(e.slice(a,a+r)||"ff")]}if(e.startsWith("rgb")){const r=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[e,a,l,c,h,u,p,g,y,x,v,w]=r,M=[c||" ",p||" ",x].join("");if(" "===M||" /"===M||",,"===M||",,,"===M){const e=[l,u,y].join(""),r="%%%"===e?100:""===e?255:0;if(r){const e=[cr(+a/r,0,1),cr(+h/r,0,1),cr(+g/r,0,1),v?lr(+v,w):1];if(hr(e))return e}}return}}const a=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(a){const[e,r,l,c,h,u,p,g,y]=a,x=[l||" ",h||" ",p].join("");if(" "===x||" /"===x||",,"===x||",,,"===x){const e=[+r,cr(+c,0,100),cr(+u,0,100),g?lr(+g,y):1];if(hr(e))return function([e,r,a,l]){function c(l){const c=(l+e/30)%12,h=r*Math.min(a,1-a);return a-h*Math.max(-1,Math.min(c-3,9-c,1))}return e=$i(e),r/=100,a/=100,[c(0),c(8),c(4),l]}(e)}}}(e);return r?new Pe(...r,!1):void 0}get rgb(){const{r:e,g:r,b:a,a:l}=this,c=l||1/0;return this.overwriteGetter("rgb",[e/c,r/c,a/c,l])}get hcl(){return this.overwriteGetter("hcl",function(e){const[r,a,l,c]=Gi(e),h=Math.sqrt(a*a+l*l);return[Math.round(1e4*h)?$i(Math.atan2(l,a)*Zi):NaN,h,r,c]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Gi(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){const[e,r,a,l]=this.rgb;return`rgba(${[e,r,a].map((e=>Math.round(255*e))).join(",")},${l})`}static interpolate(e,r,a,l="rgb"){switch(l){case"rgb":{const[l,c,h,u]=fr(e.rgb,r.rgb,a);return new Pe(l,c,h,u,!1)}case"hcl":{const[l,c,h,u]=e.hcl,[p,g,y,x]=r.hcl;let v,w;if(isNaN(l)||isNaN(p))isNaN(l)?isNaN(p)?v=NaN:(v=p,1!==h&&0!==h||(w=g)):(v=l,1!==y&&0!==y||(w=c));else{let e=p-l;p>l&&e>180?e-=360:p180&&(e+=360),v=l+a*e}const[M,C,A,k]=function([e,r,a,l]){return e=isNaN(e)?0:e*Ui,Hi([a,Math.cos(e)*r,Math.sin(e)*r,l])}([v,null!=w?w:pr(c,g,a),pr(h,y,a),pr(u,x,a)]);return new Pe(M,C,A,k,!1)}case"lab":{const[l,c,h,u]=Hi(fr(e.lab,r.lab,a));return new Pe(l,c,h,u,!1)}}}}Pe.black=new Pe(0,0,0,1),Pe.white=new Pe(1,1,1,1),Pe.transparent=new Pe(0,0,0,0),Pe.red=new Pe(1,0,0,1);class Ce{constructor(e,r,a){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=a,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const mr=["bottom","center","top"];class Ee{constructor(e,r,a,l,c,h){this.text=e,this.image=r,this.scale=a,this.fontStack=l,this.textColor=c,this.verticalAlign=h}}class Te{constructor(e){this.sections=e}static fromString(e){return new Te([new Ee(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 Te?e:Te.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}}class Ve{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ve)return e;if("number"==typeof e)return new Ve([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const r of e)if("number"!=typeof r)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 Ve(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,a){return new Ve(fr(e.values,r.values,a))}}class Fe{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Fe)return e;if("number"==typeof e)return new Fe([e]);if(Array.isArray(e)){for(const r of e)if("number"!=typeof r)return;return new Fe(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,a){return new Fe(fr(e.values,r.values,a))}}class Le{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Le)return e;if("string"==typeof e){const r=Pe.parse(e);if(!r)return;return new Le([r])}if(!Array.isArray(e))return;const r=[];for(const a of e){if("string"!=typeof a)return;const e=Pe.parse(a);if(!e)return;r.push(e)}return new Le(r)}toString(){return JSON.stringify(this.values)}static interpolate(e,r,a,l="rgb"){const c=[];if(e.values.length!=r.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${r.values.length}), cannot interpolate.`);for(let h=0;h=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255&&"number"==typeof a&&a>=0&&a<=255?void 0===l||"number"==typeof l&&l>=0&&l<=1?null:`Invalid rgba value [${[e,r,a,l].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof l?[e,r,a,l]:[e,r,a]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function vr(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof je||e instanceof Pe||e instanceof Ce||e instanceof Te||e instanceof Ve||e instanceof Fe||e instanceof Le||e instanceof Oe||e instanceof Re)return!0;if(Array.isArray(e)){for(const r of e)if(!vr(r))return!1;return!0}if("object"==typeof e){for(const r in e)if(!vr(e[r]))return!1;return!0}return!1}function br(e){if(null===e)return ei;if("string"==typeof e)return ri;if("boolean"==typeof e)return si;if("number"==typeof e)return ii;if(e instanceof Pe)return li;if(e instanceof je)return ci;if(e instanceof Ce)return _i;if(e instanceof Te)return yi;if(e instanceof Ve)return xi;if(e instanceof Fe)return Mi;if(e instanceof Le)return Ti;if(e instanceof Oe)return Ci;if(e instanceof Re)return Ii;if(Array.isArray(e)){const r=e.length;let a;for(const r of e){const e=br(r);if(a){if(a===e)continue;a=mi;break}a=e}return Ei(a||mi,r)}return di}function wr(e){const r=typeof e;return null===e?"":"string"===r||"number"===r||"boolean"===r?String(e):e instanceof Pe||e instanceof je||e instanceof Te||e instanceof Ve||e instanceof Fe||e instanceof Le||e instanceof Oe||e instanceof Re?e.toString():JSON.stringify(e)}class Xe{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(2!==e.length)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!vr(e[1]))return r.error("invalid value");const a=e[1];let l=br(a);const c=r.expectedType;return"array"!==l.kind||0!==l.N||!c||"array"!==c.kind||"number"==typeof c.N&&0!==c.N||(l=c),new Xe(l,a)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Tr={string:ri,number:ii,boolean:si,object:di};class Ye{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let a,l=1;const c=e[0];if("array"===c){let c,h;if(e.length>2){const a=e[1];if("string"!=typeof a||!(a in Tr)||"object"===a)return r.error('The item type argument of "array" must be one of string, number, boolean',1);c=Tr[a],l++}else c=mi;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);h=e[2],l++}a=Ei(c,h)}else{if(!Tr[c])throw new Error(`Types doesn't contain name = ${c}`);a=Tr[c]}const h=[];for(;le.outputDefined()))}}const Sr={"to-boolean":si,"to-color":li,"to-number":ii,"to-string":ri};class Ke{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const a=e[0];if(!Sr[a])throw new Error(`Can't parse ${a} as it is not part of the known types`);if(("to-boolean"===a||"to-string"===a)&&2!==e.length)return r.error("Expected one argument.");const l=Sr[a],c=[];for(let a=1;a4?`Invalid rgba value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:gr(r[0],r[1],r[2],r[3]),!a))return new Pe(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new $e(a||`Could not parse color from value '${"string"==typeof r?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const a of this.args){r=a.evaluate(e);const l=Ve.parse(r);if(l)return l}throw new $e(`Could not parse padding from value '${"string"==typeof r?r:JSON.stringify(r)}'`)}case"numberArray":{let r;for(const a of this.args){r=a.evaluate(e);const l=Fe.parse(r);if(l)return l}throw new $e(`Could not parse numberArray from value '${"string"==typeof r?r:JSON.stringify(r)}'`)}case"colorArray":{let r;for(const a of this.args){r=a.evaluate(e);const l=Le.parse(r);if(l)return l}throw new $e(`Could not parse colorArray from value '${"string"==typeof r?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const a of this.args){r=a.evaluate(e);const l=Oe.parse(r);if(l)return l}throw new $e(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof r?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const a of this.args){if(r=a.evaluate(e),null===r)return 0;const l=Number(r);if(!isNaN(l))return l}throw new $e(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return Te.fromString(wr(this.args[0].evaluate(e)));case"resolvedImage":return Re.fromString(wr(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return wr(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Ir=["Unknown","Point","LineString","Polygon"];class We{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?Ir[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 r=this._parseColorCache.get(e);return r||(r=Pe.parse(e),this._parseColorCache.set(e,r)),r}}class Qe{constructor(e,r,a=[],l,c=new Lt,h=[]){this.registry=e,this.path=a,this.key=a.map((e=>`[${e}]`)).join(""),this.scope=c,this.errors=h,this.expectedType=l,this._isConstant=r}parse(e,r,a,l,c={}){return r?this.concat(r,a,l)._parse(e,c):this._parse(e,c)}_parse(e,r){function a(e,r,a){return"assert"===a?new Ye(r,[e]):"coerce"===a?new Ke(r,[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 l=e[0];if("string"!=typeof l)return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const c=this.registry[l];if(c){let l=c.parse(e,this);if(!l)return null;if(this.expectedType){const e=this.expectedType,c=l.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==c.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(c.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(c.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(c.kind)||"colorArray"===e.kind&&["value","string","array"].includes(c.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(c.kind))l=a(l,e,r.typeAnnotation||"coerce");else if(this.checkSubtype(e,c))return null}else l=a(l,e,r.typeAnnotation||"assert")}if(!(l instanceof Xe)&&"resolvedImage"!==l.type.kind&&this._isConstant(l)){const r=new We;try{l=new Xe(l.type,l.evaluate(r))}catch(e){return this.error(e.message),null}}return l}return this.error(`Unknown expression "${l}". 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,r,a){const l="number"==typeof e?this.path.concat(e):this.path,c=a?this.scope.concat(a):this.scope;return new Qe(this.registry,this._isConstant,l,r||null,c,this.errors)}error(e,...r){const a=`${this.key}${r.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Ft(a,e))}checkSubtype(e,r){const a=ki(e,r);return a&&this.error(a),a}}class tr{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const a=[];for(let l=1;l=a.length)throw new $e(`Array index out of bounds: ${r} > ${a.length-1}.`);if(r!==Math.floor(r))throw new $e(`Array index must be an integer, but found ${r} instead.`);return a[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class nr{constructor(e,r){this.type=si,this.needle=e,this.haystack=r}static parse(e,r){if(3!==e.length)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,mi),l=r.parse(e[2],2,mi);return a&&l?Ri(a.type,[si,ri,ii,ei,mi])?new nr(a,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(a.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!a)return!1;if(!Di(r,["boolean","string","number","null"]))throw new $e(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(br(r))} instead.`);if(!Di(a,["string","array"]))throw new $e(`Expected second argument to be of type array or string, but found ${Ai(br(a))} instead.`);return a.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ir{constructor(e,r,a){this.type=ii,this.needle=e,this.haystack=r,this.fromIndex=a}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,mi),l=r.parse(e[2],2,mi);if(!a||!l)return null;if(!Ri(a.type,[si,ri,ii,ei,mi]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(a.type)} instead`);if(4===e.length){const c=r.parse(e[3],3,ii);return c?new ir(a,l,c):null}return new ir(a,l)}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!Di(r,["boolean","string","number","null"]))throw new $e(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(br(r))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(e)),Di(a,["string"])){const e=a.indexOf(r,l);return-1===e?-1:[...a.slice(0,e)].length}if(Di(a,["array"]))return a.indexOf(r,l);throw new $e(`Expected second argument to be of type array or string, but found ${Ai(br(a))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class sr{constructor(e,r,a,l,c,h){this.inputType=e,this.type=r,this.input=a,this.cases=l,this.outputs=c,this.otherwise=h}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let a,l;r.expectedType&&"value"!==r.expectedType.kind&&(l=r.expectedType);const c={},h=[];for(let u=2;uNumber.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(a){if(y.checkSubtype(a,br(e)))return null}else a=br(e);if(void 0!==c[String(e)])return y.error("Branch labels must be unique.");c[String(e)]=h.length}const x=r.parse(g,u,l);if(!x)return null;l=l||x.type,h.push(x)}const u=r.parse(e[1],1,mi);if(!u)return null;const p=r.parse(e[e.length-1],e.length-1,l);return p?"value"!==u.type.kind&&r.concat(1).checkSubtype(a,u.type)?null:new sr(a,l,u,c,h,p):null}evaluate(e){const r=this.input.evaluate(e);return(br(r)===this.inputType&&this.outputs[this.cases[r]]||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 ar{constructor(e,r,a){this.type=e,this.branches=r,this.otherwise=a}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let a;r.expectedType&&"value"!==r.expectedType.kind&&(a=r.expectedType);const l=[];for(let c=1;cr.outputDefined()))&&this.otherwise.outputDefined()}}class or{constructor(e,r,a,l){this.type=e,this.input=r,this.beginIndex=a,this.endIndex=l}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,mi),l=r.parse(e[2],2,ii);if(!a||!l)return null;if(!Ri(a.type,[Ei(mi),ri,mi]))return r.error(`Expected first argument to be of type array or string, but found ${Ai(a.type)} instead`);if(4===e.length){const c=r.parse(e[3],3,ii);return c?new or(a.type,a,l,c):null}return new or(a.type,a,l)}evaluate(e){const r=this.input.evaluate(e),a=this.beginIndex.evaluate(e);let l;if(this.endIndex&&(l=this.endIndex.evaluate(e)),Di(r,["string"]))return[...r].slice(a,l).join("");if(Di(r,["array"]))return r.slice(a,l);throw new $e(`Expected first argument to be of type array or string, but found ${Ai(br(r))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Ar(e,r){const a=e.length-1;let l,c,h=0,u=a,p=0;for(;h<=u;)if(p=Math.floor((h+u)/2),l=e[p],c=e[p+1],l<=r){if(p===a||rr))throw new $e("Input is not a number.");u=p-1}return 0}class ur{constructor(e,r,a){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[e,r]of a)this.labels.push(e),this.outputs.push(r)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const a=r.parse(e[1],1,ii);if(!a)return null;const l=[];let c=null;r.expectedType&&"value"!==r.expectedType.kind&&(c=r.expectedType);for(let a=1;a=h)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',p);const y=r.parse(u,g,c);if(!y)return null;c=c||y.type,l.push([h,y])}return new ur(c,a,l)}evaluate(e){const r=this.labels,a=this.outputs;if(1===r.length)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return a[0].evaluate(e);const c=r.length;return l>=r[c-1]?a[c-1].evaluate(e):a[Ar(r,l)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function kr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Rr,Dr,Lr=function(){if(Dr)return Rr;function r(r,a,l,c){(this||e).cx=3*r,(this||e).bx=3*(l-r)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*a,(this||e).by=3*(c-a)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=r,(this||e).p1y=a,(this||e).p2x=l,(this||e).p2y=c}return Dr=1,Rr=r,r.prototype={sampleCurveX:function(r){return(((this||e).ax*r+(this||e).bx)*r+(this||e).cx)*r},sampleCurveY:function(r){return(((this||e).ay*r+(this||e).by)*r+(this||e).cy)*r},sampleCurveDerivativeX:function(r){return(3*(this||e).ax*r+2*(this||e).bx)*r+(this||e).cx},solveCurveX:function(e,r){if(void 0===r&&(r=1e-6),e<0)return 0;if(e>1)return 1;for(var a=e,l=0;l<8;l++){var c=this.sampleCurveX(a)-e;if(Math.abs(c)c?u=a:p=a,a=.5*(p-u)+u;return a},solve:function(e,r){return this.sampleCurveY(this.solveCurveX(e,r))}},Rr}(),Or=kr(Lr);class yr{constructor(e,r,a,l,c){this.type=e,this.operator=r,this.interpolation=a,this.input=l,this.labels=[],this.outputs=[];for(const[e,r]of c)this.labels.push(e),this.outputs.push(r)}static interpolationFactor(e,r,a,l){let c=0;if("exponential"===e.name)c=qr(r,e.base,a,l);else if("linear"===e.name)c=qr(r,1,a,l);else if("cubic-bezier"===e.name){const h=e.controlPoints;c=new Or(h[0],h[1],h[2],h[3]).solve(qr(r,1,a,l))}return c}static parse(e,r){let[a,l,c,...h]=e;if(!Array.isArray(l)||0===l.length)return r.error("Expected an interpolation type expression.",1);if("linear"===l[0])l={name:"linear"};else if("exponential"===l[0]){const e=l[1];if("number"!=typeof e)return r.error("Exponential interpolation requires a numeric base.",1,1);l={name:"exponential",base:e}}else{if("cubic-bezier"!==l[0])return r.error(`Unknown interpolation type ${String(l[0])}`,1,0);{const e=l.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(c=r.parse(c,2,ii),!c)return null;const u=[];let p=null;"interpolate-hcl"!==a&&"interpolate-lab"!==a||r.expectedType==Ti?r.expectedType&&"value"!==r.expectedType.kind&&(p=r.expectedType):p=li;for(let e=0;e=a)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',c);const y=r.parse(l,g,p);if(!y)return null;p=p||y.type,u.push([a,y])}return Li(p,ii)||Li(p,ci)||Li(p,li)||Li(p,xi)||Li(p,Mi)||Li(p,Ti)||Li(p,Ci)||Li(p,Ei(ii))?new yr(p,a,l,c,u):r.error(`Type ${Ai(p)} is not interpolatable.`)}evaluate(e){const r=this.labels,a=this.outputs;if(1===r.length)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return a[0].evaluate(e);const c=r.length;if(l>=r[c-1])return a[c-1].evaluate(e);const h=Ar(r,l),u=yr.interpolationFactor(this.interpolation,l,r[h],r[h+1]),p=a[h].evaluate(e),g=a[h+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return pr(p,g,u);case"color":return Pe.interpolate(p,g,u);case"padding":return Ve.interpolate(p,g,u);case"colorArray":return Le.interpolate(p,g,u);case"numberArray":return Fe.interpolate(p,g,u);case"variableAnchorOffsetCollection":return Oe.interpolate(p,g,u);case"array":return fr(p,g,u);case"projectionDefinition":return je.interpolate(p,g,u)}case"interpolate-hcl":switch(this.type.kind){case"color":return Pe.interpolate(p,g,u,"hcl");case"colorArray":return Le.interpolate(p,g,u,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Pe.interpolate(p,g,u,"lab");case"colorArray":return Le.interpolate(p,g,u,"lab")}}}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function qr(e,r,a,l){const c=l-a,h=e-a;return 0===c?0:1===r?h/c:(Math.pow(r,h)-1)/(Math.pow(r,c)-1)}const Yr={color:Pe.interpolate,number:pr,padding:Ve.interpolate,numberArray:Fe.interpolate,colorArray:Le.interpolate,variableAnchorOffsetCollection:Oe.interpolate,array:fr};class xr{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let a=null;const l=r.expectedType;l&&"value"!==l.kind&&(a=l);const c=[];for(const l of e.slice(1)){const e=r.parse(l,1+c.length,a,void 0,{typeAnnotation:"omit"});if(!e)return null;a=a||e.type,c.push(e)}if(!a)throw new Error("No output type");const h=l&&c.some((e=>ki(l,e.type)));return new xr(h?mi:a,c)}evaluate(e){let r,a=null,l=0;for(const c of this.args)if(l++,a=c.evaluate(e),a&&a instanceof Re&&!a.available&&(r||(r=a.name),a=null,l===this.args.length&&(a=r)),null!==a)break;return a}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function Qr(e,r){return"=="===e||"!="===e?"boolean"===r.kind||"string"===r.kind||"number"===r.kind||"null"===r.kind||"value"===r.kind:"string"===r.kind||"number"===r.kind||"value"===r.kind}function tn(e,r,a,l){return 0===l.compare(r,a)}function en(e,r,a){const l="=="!==e&&"!="!==e;return class i{constructor(e,r,a){this.type=si,this.lhs=e,this.rhs=r,this.collator=a,this.hasUntypedArgument="value"===e.type.kind||"value"===r.type.kind}static parse(e,r){if(3!==e.length&&4!==e.length)return r.error("Expected two or three arguments.");const a=e[0];let c=r.parse(e[1],1,mi);if(!c)return null;if(!Qr(a,c.type))return r.concat(1).error(`"${a}" comparisons are not supported for type '${Ai(c.type)}'.`);let h=r.parse(e[2],2,mi);if(!h)return null;if(!Qr(a,h.type))return r.concat(2).error(`"${a}" comparisons are not supported for type '${Ai(h.type)}'.`);if(c.type.kind!==h.type.kind&&"value"!==c.type.kind&&"value"!==h.type.kind)return r.error(`Cannot compare types '${Ai(c.type)}' and '${Ai(h.type)}'.`);l&&("value"===c.type.kind&&"value"!==h.type.kind?c=new Ye(h.type,[c]):"value"!==c.type.kind&&"value"===h.type.kind&&(h=new Ye(c.type,[h])));let u=null;if(4===e.length){if("string"!==c.type.kind&&"string"!==h.type.kind&&"value"!==c.type.kind&&"value"!==h.type.kind)return r.error("Cannot use collator to compare non-string types.");if(u=r.parse(e[3],3,_i),!u)return null}return new i(c,h,u)}evaluate(c){const h=this.lhs.evaluate(c),u=this.rhs.evaluate(c);if(l&&this.hasUntypedArgument){const r=br(h),a=br(u);if(r.kind!==a.kind||"string"!==r.kind&&"number"!==r.kind)throw new $e(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${r.kind}, ${a.kind}) instead.`)}if(this.collator&&!l&&this.hasUntypedArgument){const e=br(h),a=br(u);if("string"!==e.kind||"string"!==a.kind)return r(c,h,u)}return this.collator?a(c,h,u,this.collator.evaluate(c)):r(c,h,u)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const rn=en("==",(function(e,r,a){return r===a}),tn),nn=en("!=",(function(e,r,a){return r!==a}),(function(e,r,a,l){return!tn(0,r,a,l)})),sn=en("<",(function(e,r,a){return r",(function(e,r,a){return r>a}),(function(e,r,a,l){return l.compare(r,a)>0})),an=en("<=",(function(e,r,a){return r<=a}),(function(e,r,a,l){return l.compare(r,a)<=0})),ln=en(">=",(function(e,r,a){return r>=a}),(function(e,r,a,l){return l.compare(r,a)>=0}));class zr{constructor(e,r,a){this.type=_i,this.locale=a,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(2!==e.length)return r.error("Expected one argument.");const a=e[1];if("object"!=typeof a||Array.isArray(a))return r.error("Collator options argument must be an object.");const l=r.parse(void 0!==a["case-sensitive"]&&a["case-sensitive"],1,si);if(!l)return null;const c=r.parse(void 0!==a["diacritic-sensitive"]&&a["diacritic-sensitive"],1,si);if(!c)return null;let h=null;return a.locale&&(h=r.parse(a.locale,1,ri),!h)?null:new zr(l,c,h)}evaluate(e){return new Ce(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 Pr{constructor(e,r,a,l,c){this.type=ri,this.number=e,this.locale=r,this.currency=a,this.minFractionDigits=l,this.maxFractionDigits=c}static parse(e,r){if(3!==e.length)return r.error("Expected two arguments.");const a=r.parse(e[1],1,ii);if(!a)return null;const l=e[2];if("object"!=typeof l||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let c=null;if(l.locale&&(c=r.parse(l.locale,1,ri),!c))return null;let h=null;if(l.currency&&(h=r.parse(l.currency,1,ri),!h))return null;let u=null;if(l["min-fraction-digits"]&&(u=r.parse(l["min-fraction-digits"],1,ii),!u))return null;let p=null;return l["max-fraction-digits"]&&(p=r.parse(l["max-fraction-digits"],1,ii),!p)?null:new Pr(a,c,h,u,p)}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 Cr{constructor(e){this.type=yi,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const a=e[1];if(!Array.isArray(a)&&"object"==typeof a)return r.error("First argument must be an image or text section.");const l=[];let c=!1;for(let a=1;a<=e.length-1;++a){const h=e[a];if(c&&"object"==typeof h&&!Array.isArray(h)){c=!1;let e=null;if(h["font-scale"]&&(e=r.parse(h["font-scale"],1,ii),!e))return null;let a=null;if(h["text-font"]&&(a=r.parse(h["text-font"],1,Ei(ri)),!a))return null;let u=null;if(h["text-color"]&&(u=r.parse(h["text-color"],1,li),!u))return null;let p=null;if(h["vertical-align"]){if("string"==typeof h["vertical-align"]&&!mr.includes(h["vertical-align"]))return r.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${h["vertical-align"]}' instead.`);if(p=r.parse(h["vertical-align"],1,ri),!p)return null}const g=l[l.length-1];g.scale=e,g.font=a,g.textColor=u,g.verticalAlign=p}else{const h=r.parse(e[a],1,mi);if(!h)return null;const u=h.type.kind;if("string"!==u&&"value"!==u&&"null"!==u&&"resolvedImage"!==u)return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");c=!0,l.push({content:h,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Cr(l)}evaluate(e){return new Te(this.sections.map((r=>{const a=r.content.evaluate(e);return br(a)===Ii?new Ee("",a,null,null,null,r.verticalAlign?r.verticalAlign.evaluate(e):null):new Ee(wr(a),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null,r.verticalAlign?r.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor),r.verticalAlign&&e(r.verticalAlign)}outputDefined(){return!1}}class Br{constructor(e){this.type=Ii,this.input=e}static parse(e,r){if(2!==e.length)return r.error("Expected two arguments.");const a=r.parse(e[1],1,ri);return a?new Br(a):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),a=Re.fromString(r);return a&&e.availableImages&&(a.available=e.availableImages.indexOf(r)>-1),a}eachChild(e){e(this.input)}outputDefined(){return!1}}class Er{constructor(e){this.type=ii,this.input=e}static parse(e,r){if(2!==e.length)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const a=r.parse(e[1],1);return a?"array"!==a.type.kind&&"string"!==a.type.kind&&"value"!==a.type.kind?r.error(`Expected argument of type string or array, but found ${Ai(a.type)} instead.`):new Er(a):null}evaluate(e){const r=this.input.evaluate(e);if("string"==typeof r)return[...r].length;if(Array.isArray(r))return r.length;throw new $e(`Expected value to be of type string or array, but found ${Ai(br(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const cn=8192;function hn(e,r){const a=(180+e[0])/360,l=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,c=Math.pow(2,r.z);return[Math.round(a*c*cn),Math.round(l*c*cn)]}function dn(e,r){const a=Math.pow(2,r.z);return[(c=(e[0]/cn+r.x)/a,360*c-180),(l=(e[1]/cn+r.y)/a,360/Math.PI*Math.atan(Math.exp((180-360*l)*Math.PI/180))-90)];var l,c}function pn(e,r){e[0]=Math.min(e[0],r[0]),e[1]=Math.min(e[1],r[1]),e[2]=Math.max(e[2],r[0]),e[3]=Math.max(e[3],r[1])}function fn(e,r){return!(e[0]<=r[0]||e[2]>=r[2]||e[1]<=r[1]||e[3]>=r[3])}function mn(e,r,a){const l=e[0]-r[0],c=e[1]-r[1],h=e[0]-a[0],u=e[1]-a[1];return l*u-h*c==0&&l*h<=0&&c*u<=0}function _n(e,r,a,l){return 0!=(c=[l[0]-a[0],l[1]-a[1]])[0]*(h=[r[0]-e[0],r[1]-e[1]])[1]-c[1]*h[0]&&!(!wn(e,r,a,l)||!wn(a,l,e,r));var c,h}function gn(e,r,a){for(const l of a)for(let a=0;a(c=e)[1]!=(u=p[r+1])[1]>c[1]&&c[0]<(u[0]-h[0])*(c[1]-h[1])/(u[1]-h[1])+h[0]&&(l=!l)}var c,h,u;return l}function xn(e,r){for(const a of r)if(yn(e,a))return!0;return!1}function vn(e,r){for(const a of e)if(!yn(a,r))return!1;for(let a=0;a0&&p<0||u<0&&p>0}function Tn(e,r,a){const l=[];for(let c=0;ca[2]){const r=.5*l;let c=e[0]-a[0]>r?-l:a[0]-e[0]>r?l:0;0===c&&(c=e[0]-a[2]>r?-l:a[2]-e[0]>r?l:0),e[0]+=c}pn(r,e)}function Mn(e,r,a,l){const c=Math.pow(2,l.z)*cn,h=[l.x*cn,l.y*cn],u=[];for(const l of e)for(const e of l){const l=[e.x+h[0],e.y+h[1]];Sn(l,r,a,c),u.push(l)}return u}function In(e,r,a,l){const c=Math.pow(2,l.z)*cn,h=[l.x*cn,l.y*cn],u=[];for(const a of e){const e=[];for(const l of a){const a=[l.x+h[0],l.y+h[1]];pn(r,a),e.push(a)}u.push(e)}if(r[2]-r[0]<=c/2){(p=r)[0]=p[1]=1/0,p[2]=p[3]=-1/0;for(const e of u)for(const l of e)Sn(l,r,a,c)}var p;return u}class Jr{constructor(e,r){this.type=si,this.geojson=e,this.geometries=r}static parse(e,r){if(2!==e.length)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(vr(e[1])){const r=e[1];if("FeatureCollection"===r.type){const e=[];for(const a of r.features){const{type:r,coordinates:l}=a.geometry;"Polygon"===r&&e.push(l),"MultiPolygon"===r&&e.push(...l)}if(e.length)return new Jr(r,{type:"MultiPolygon",coordinates:e})}else if("Feature"===r.type){const e=r.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Jr(r,r.geometry)}else if("Polygon"===r.type||"MultiPolygon"===r.type)return new Jr(r,r)}return r.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,r){const a=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],c=e.canonicalID();if("Polygon"===r.type){const h=Tn(r.coordinates,l,c),u=Mn(e.geometry(),a,l,c);if(!fn(a,l))return!1;for(const e of u)if(!yn(e,h))return!1}if("MultiPolygon"===r.type){const h=Pn(r.coordinates,l,c),u=Mn(e.geometry(),a,l,c);if(!fn(a,l))return!1;for(const e of u)if(!xn(e,h))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,r){const a=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],c=e.canonicalID();if("Polygon"===r.type){const h=Tn(r.coordinates,l,c),u=In(e.geometry(),a,l,c);if(!fn(a,l))return!1;for(const e of u)if(!vn(e,h))return!1}if("MultiPolygon"===r.type){const h=Pn(r.coordinates,l,c),u=In(e.geometry(),a,l,c);if(!fn(a,l))return!1;for(const e of u)if(!bn(e,h))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Cn=class{constructor(e=[],r=(e,r)=>er?1:0){if(this.data=e,this.length=this.data.length,this.compare=r,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],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:a}=this,l=r[e];for(;e>0;){const c=e-1>>1,h=r[c];if(a(l,h)>=0)break;r[e]=h,e=c}r[e]=l}_down(e){const{data:r,compare:a}=this,l=this.length>>1,c=r[e];for(;e=0)break;r[e]=r[l],e=l}r[e]=c}};function An(e,r,a=0,l=e.length-1,c=kn){for(;l>a;){if(l-a>600){const h=l-a+1,u=r-a+1,p=Math.log(h),g=.5*Math.exp(2*p/3),y=.5*Math.sqrt(p*g*(h-g)/h)*(u-h/2<0?-1:1);An(e,r,Math.max(a,Math.floor(r-u*g/h+y)),Math.min(l,Math.floor(r+(h-u)*g/h+y)),c)}const h=e[r];let u=a,p=l;for(zn(e,a,r),c(e[l],h)>0&&zn(e,a,l);u0;)p--}0===c(e[a],h)?zn(e,a,p):(p++,zn(e,p,l)),p<=r&&(a=p+1),r<=p&&(l=p-1)}}function zn(e,r,a){const l=e[r];e[r]=e[a],e[a]=l}function kn(e,r){return er?1:0}function Rn(e,r){if(e.length<=1)return[e];const a=[];let l,c;for(const r of e){const e=Ln(r);0!==e&&(r.area=Math.abs(e),void 0===c&&(c=e<0),c===e<0?(l&&a.push(l),l=[r]):l.push(r))}if(l&&a.push(l),r>1)for(let e=0;e1?(g=e[p+1][0],y=e[p+1][1]):w>0&&(g+=x/this.kx*w,y+=v/this.ky*w)),x=this.wrap(r[0]-g)*this.kx,v=(r[1]-y)*this.ky;const M=x*x+v*v;M180;)e-=360;return e}}function Nn(e,r){return r[0]-e[0]}function Un(e){return e[1]-e[0]+1}function Zn(e,r){return e[1]>=e[0]&&e[1]e[1])return[null,null];const a=Un(e);if(r){if(2===a)return[e,null];const r=Math.floor(a/2);return[[e[0],e[0]+r],[e[0]+r,e[1]]]}if(1===a)return[e,null];const l=Math.floor(a/2)-1;return[[e[0],e[0]+l],[e[0]+l+1,e[1]]]}function Gn(e,r){if(!Zn(r,e.length))return[1/0,1/0,-1/0,-1/0];const a=[1/0,1/0,-1/0,-1/0];for(let l=r[0];l<=r[1];++l)pn(a,e[l]);return a}function qn(e){const r=[1/0,1/0,-1/0,-1/0];for(const a of e)for(const e of a)pn(r,e);return r}function Wn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Hn(e,r,a){if(!Wn(e)||!Wn(r))return NaN;let l=0,c=0;return e[2]r[2]&&(l=e[0]-r[2]),e[1]>r[3]&&(c=e[1]-r[3]),e[3]=l)return l;if(fn(c,h)){if(es(e,r))return 0}else if(es(r,e))return 0;let u=1/0;for(const l of e)for(let e=0,c=l.length,h=c-1;e0;){const c=u.pop();if(c[0]>=h)continue;const g=c[1],y=r?50:100;if(Un(g)<=y){if(!Zn(g,e.length))return NaN;if(r){const r=ts(e,g,a,l);if(isNaN(r)||0===r)return r;h=Math.min(h,r)}else for(let r=g[0];r<=g[1];++r){const c=Qn(e[r],a,l);if(h=Math.min(h,c),0===h)return 0}}else{const a=$n(g,r);rs(u,h,l,e,p,a[0]),rs(u,h,l,e,p,a[1])}}return h}function as(e,r,a,l,c,h=1/0){let u=Math.min(h,c.distance(e[0],a[0]));if(0===u)return u;const p=new Cn([[0,[0,e.length-1],[0,a.length-1]]],Nn);for(;p.length>0;){const h=p.pop();if(h[0]>=u)continue;const g=h[1],y=h[2],x=r?50:100,v=l?50:100;if(Un(g)<=x&&Un(y)<=v){if(!Zn(g,e.length)&&Zn(y,a.length))return NaN;let h;if(r&&l)h=Kn(e,g,a,y,c),u=Math.min(u,h);else if(r&&!l){const r=e.slice(g[0],g[1]+1);for(let e=y[0];e<=y[1];++e)if(h=Xn(a[e],r,c),u=Math.min(u,h),0===u)return u}else if(!r&&l){const r=a.slice(y[0],y[1]+1);for(let a=g[0];a<=g[1];++a)if(h=Xn(e[a],r,c),u=Math.min(u,h),0===u)return u}else h=Jn(e,g,a,y,c),u=Math.min(u,h)}else{const h=$n(g,r),x=$n(y,l);ns(p,u,c,e,a,h[0],x[0]),ns(p,u,c,e,a,h[0],x[1]),ns(p,u,c,e,a,h[1],x[0]),ns(p,u,c,e,a,h[1],x[1])}}return u}function ls(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 Bn{constructor(e,r){this.type=ii,this.geojson=e,this.geometries=r}static parse(e,r){if(2!==e.length)return r.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(vr(e[1])){const r=e[1];if("FeatureCollection"===r.type)return new Bn(r,r.features.map((e=>ls(e.geometry))).flat());if("Feature"===r.type)return new Bn(r,ls(r.geometry));if("type"in r&&"coordinates"in r)return new Bn(r,ls(r))}return r.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,r){const a=e.geometry(),l=a.flat().map((r=>dn([r.x,r.y],e.canonical)));if(0===a.length)return NaN;const c=new un(l[0][1]);let h=1/0;for(const e of r){switch(e.type){case"Point":h=Math.min(h,as(l,!1,[e.coordinates],!1,c,h));break;case"LineString":h=Math.min(h,as(l,!1,e.coordinates,!0,c,h));break;case"Polygon":h=Math.min(h,ss(l,!1,e.coordinates,c,h))}if(0===h)return h}return h}(e,this.geometries);if("LineString"===e.geometryType())return function(e,r){const a=e.geometry(),l=a.flat().map((r=>dn([r.x,r.y],e.canonical)));if(0===a.length)return NaN;const c=new un(l[0][1]);let h=1/0;for(const e of r){switch(e.type){case"Point":h=Math.min(h,as(l,!0,[e.coordinates],!1,c,h));break;case"LineString":h=Math.min(h,as(l,!0,e.coordinates,!0,c,h));break;case"Polygon":h=Math.min(h,ss(l,!0,e.coordinates,c,h))}if(0===h)return h}return h}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,r){const a=e.geometry();if(0===a.length||0===a[0].length)return NaN;const l=Rn(a,0).map((r=>r.map((r=>r.map((r=>dn([r.x,r.y],e.canonical))))))),c=new un(l[0][0][0][1]);let h=1/0;for(const e of r)for(const r of l){switch(e.type){case"Point":h=Math.min(h,ss([e.coordinates],!1,r,c,h));break;case"LineString":h=Math.min(h,ss(e.coordinates,!0,r,c,h));break;case"Polygon":h=Math.min(h,is(r,e.coordinates,c,h))}if(0===h)return h}return h}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class En{constructor(e){this.type=mi,this.key=e}static parse(e,r){if(2!==e.length)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const a=e[1];return null==a?r.error("Global state property must be defined."):"string"!=typeof a?r.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new En(a)}evaluate(e){var r;const a=null===(r=e.globals)||void 0===r?void 0:r.globalState;return a&&0!==Object.keys(a).length?Ji(a,this.key):null}eachChild(){}outputDefined(){return!1}}const cs={"==":rn,"!=":nn,">":on,"<":sn,">=":ln,"<=":an,array:Ye,at:rr,boolean:Ye,case:ar,coalesce:xr,collator:zr,format:Cr,image:Br,in:nr,"index-of":ir,interpolate:yr,"interpolate-hcl":yr,"interpolate-lab":yr,length:Er,let:tr,literal:Xe,match:sr,number:Ye,"number-format":Pr,object:Ye,slice:or,step:ur,string:Ye,"to-boolean":Ke,"to-color":Ke,"to-number":Ke,"to-string":Ke,var:er,within:Jr,distance:Bn,"global-state":En};class Vn{constructor(e,r,a,l){this.name=e,this.type=r,this._evaluate=a,this.args=l}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){const a=e[0],l=Vn.definitions[a];if(!l)return r.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0);const c=Array.isArray(l)?l[0]:l.type,h=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,u=h.filter((([r])=>!Array.isArray(r)||r.length===e.length-1));let p=null;for(const[l,h]of u){p=new Qe(r.registry,fs,r.path,null,r.scope);const u=[];let g=!1;for(let r=1;r{return r=e,Array.isArray(r)?`(${r.map(Ai).join(", ")})`:`(${Ai(r.type)}...)`;var r})).join(" | "),l=[];for(let a=1;a{a=r?a&&fs(e):a&&e instanceof Xe})),!!a&&ms(e)&&gs(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function ms(e){if(e instanceof Vn){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 Jr)return!1;if(e instanceof Bn)return!1;let r=!0;return e.eachChild((e=>{r&&!ms(e)&&(r=!1)})),r}function _s(e){if(e instanceof Vn&&"feature-state"===e.name)return!1;let r=!0;return e.eachChild((e=>{r&&!_s(e)&&(r=!1)})),r}function gs(e,r){if(e instanceof Vn&&r.indexOf(e.name)>=0)return!1;let a=!0;return e.eachChild((e=>{a&&!gs(e,r)&&(a=!1)})),a}function xs(e){return{result:"success",value:e}}function vs(e){return{result:"error",value:e}}function bs(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function ws(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Ps(e){return!!e.expression&&e.expression.interpolated}function Ss(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Ms(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&br(e)===di}function Is(e){return e}function As(e,r){const a=e.stops&&"object"==typeof e.stops[0][0],l=a||!(a||void 0!==e.property),c=e.type||(Ps(r)?"exponential":"interval"),h=function(e){switch(e.type){case"color":return Pe.parse;case"padding":return Ve.parse;case"numberArray":return Fe.parse;case"colorArray":return Le.parse;default:return null}}(r);if(h&&((e=ti({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],h(e[1])]))),e.default=h(e.default?e.default:r.default)),e.colorSpace&&"rgb"!==(u=e.colorSpace)&&"hcl"!==u&&"lab"!==u)throw new Error(`Unknown color space: "${e.colorSpace}"`);var u;const p=function(e){switch(e){case"exponential":return Gs;case"interval":return Zs;case"categorical":return ks;case"identity":return Ks;default:throw new Error(`Unknown function type "${e}"`)}}(c);let g,y;if("categorical"===c){g=Object.create(null);for(const r of e.stops)g[r[0]]=r[1];y=typeof e.stops[0][0]}if(a){const a={},l=[];for(let r=0;re[0])),evaluate:({zoom:a},l)=>Gs({stops:c,base:e.base},r,a).evaluate(a,l)}}if(l){const a="exponential"===c?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:a,interpolationFactor:yr.interpolationFactor.bind(void 0,a),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:a})=>p(e,r,a,g,y)}}return{kind:"source",evaluate(a,l){const c=l&&l.properties?l.properties[e.property]:void 0;return void 0===c?zs(e.default,r.default):p(e,r,c,g,y)}}}function zs(e,r,a){return void 0!==e?e:void 0!==r?r:void 0!==a?a:void 0}function ks(e,r,a,l,c){return zs(typeof a===c?l[a]:void 0,e.default,r.default)}function Zs(e,r,a){if("number"!==Ss(a))return zs(e.default,r.default);const l=e.stops.length;if(1===l)return e.stops[0][1];if(a<=e.stops[0][0])return e.stops[0][1];if(a>=e.stops[l-1][0])return e.stops[l-1][1];const c=Ar(e.stops.map((e=>e[0])),a);return e.stops[c][1]}function Gs(e,r,a){const l=void 0!==e.base?e.base:1;if("number"!==Ss(a))return zs(e.default,r.default);const c=e.stops.length;if(1===c)return e.stops[0][1];if(a<=e.stops[0][0])return e.stops[0][1];if(a>=e.stops[c-1][0])return e.stops[c-1][1];const h=Ar(e.stops.map((e=>e[0])),a),u=function(e,r,a,l){const c=l-a,h=e-a;return 0===c?0:1===r?h/c:(Math.pow(r,h)-1)/(Math.pow(r,c)-1)}(a,l,e.stops[h][0],e.stops[h+1][0]),p=e.stops[h][1],g=e.stops[h+1][1],y=Yr[r.type]||Is;return"function"==typeof p.evaluate?{evaluate(...r){const a=p.evaluate.apply(void 0,r),l=g.evaluate.apply(void 0,r);if(void 0!==a&&void 0!==l)return y(a,l,u,e.colorSpace)}}:y(p,g,u,e.colorSpace)}function Ks(e,r,a){switch(r.type){case"color":a=Pe.parse(a);break;case"formatted":a=Te.fromString(a.toString());break;case"resolvedImage":a=Re.fromString(a.toString());break;case"padding":a=Ve.parse(a);break;case"colorArray":a=Le.parse(a);break;case"numberArray":a=Fe.parse(a);break;default:Ss(a)===r.type||"enum"===r.type&&r.values[a]||(a=void 0)}return zs(a,e.default,r.default)}Vn.register(cs,{error:[{kind:"error"},[ri],(e,[r])=>{throw new $e(r.evaluate(e))}],typeof:[ri,[mi],(e,[r])=>Ai(br(r.evaluate(e)))],"to-rgba":[Ei(ii,4),[li],(e,[r])=>{const[a,l,c,h]=r.evaluate(e).rgb;return[255*a,255*l,255*c,h]}],rgb:[li,[ii,ii,ii],hs],rgba:[li,[ii,ii,ii,ii],hs],has:{type:si,overloads:[[[ri],(e,[r])=>us(r.evaluate(e),e.properties())],[[ri,di],(e,[r,a])=>us(r.evaluate(e),a.evaluate(e))]]},get:{type:mi,overloads:[[[ri],(e,[r])=>ds(r.evaluate(e),e.properties())],[[ri,di],(e,[r,a])=>ds(r.evaluate(e),a.evaluate(e))]]},"feature-state":[mi,[ri],(e,[r])=>ds(r.evaluate(e),e.featureState||{})],properties:[di,[],e=>e.properties()],"geometry-type":[ri,[],e=>e.geometryType()],id:[mi,[],e=>e.id()],zoom:[ii,[],e=>e.globals.zoom],"heatmap-density":[ii,[],e=>e.globals.heatmapDensity||0],elevation:[ii,[],e=>e.globals.elevation||0],"line-progress":[ii,[],e=>e.globals.lineProgress||0],accumulated:[mi,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ii,ps(ii),(e,r)=>{let a=0;for(const l of r)a+=l.evaluate(e);return a}],"*":[ii,ps(ii),(e,r)=>{let a=1;for(const l of r)a*=l.evaluate(e);return a}],"-":{type:ii,overloads:[[[ii,ii],(e,[r,a])=>r.evaluate(e)-a.evaluate(e)],[[ii],(e,[r])=>-r.evaluate(e)]]},"/":[ii,[ii,ii],(e,[r,a])=>r.evaluate(e)/a.evaluate(e)],"%":[ii,[ii,ii],(e,[r,a])=>r.evaluate(e)%a.evaluate(e)],ln2:[ii,[],()=>Math.LN2],pi:[ii,[],()=>Math.PI],e:[ii,[],()=>Math.E],"^":[ii,[ii,ii],(e,[r,a])=>Math.pow(r.evaluate(e),a.evaluate(e))],sqrt:[ii,[ii],(e,[r])=>Math.sqrt(r.evaluate(e))],log10:[ii,[ii],(e,[r])=>Math.log(r.evaluate(e))/Math.LN10],ln:[ii,[ii],(e,[r])=>Math.log(r.evaluate(e))],log2:[ii,[ii],(e,[r])=>Math.log(r.evaluate(e))/Math.LN2],sin:[ii,[ii],(e,[r])=>Math.sin(r.evaluate(e))],cos:[ii,[ii],(e,[r])=>Math.cos(r.evaluate(e))],tan:[ii,[ii],(e,[r])=>Math.tan(r.evaluate(e))],asin:[ii,[ii],(e,[r])=>Math.asin(r.evaluate(e))],acos:[ii,[ii],(e,[r])=>Math.acos(r.evaluate(e))],atan:[ii,[ii],(e,[r])=>Math.atan(r.evaluate(e))],min:[ii,ps(ii),(e,r)=>Math.min(...r.map((r=>r.evaluate(e))))],max:[ii,ps(ii),(e,r)=>Math.max(...r.map((r=>r.evaluate(e))))],abs:[ii,[ii],(e,[r])=>Math.abs(r.evaluate(e))],round:[ii,[ii],(e,[r])=>{const a=r.evaluate(e);return a<0?-Math.round(-a):Math.round(a)}],floor:[ii,[ii],(e,[r])=>Math.floor(r.evaluate(e))],ceil:[ii,[ii],(e,[r])=>Math.ceil(r.evaluate(e))],"filter-==":[si,[ri,mi],(e,[r,a])=>e.properties()[r.value]===a.value],"filter-id-==":[si,[mi],(e,[r])=>e.id()===r.value],"filter-type-==":[si,[ri],(e,[r])=>e.geometryType()===r.value],"filter-<":[si,[ri,mi],(e,[r,a])=>{const l=e.properties()[r.value],c=a.value;return typeof l==typeof c&&l{const a=e.id(),l=r.value;return typeof a==typeof l&&a":[si,[ri,mi],(e,[r,a])=>{const l=e.properties()[r.value],c=a.value;return typeof l==typeof c&&l>c}],"filter-id->":[si,[mi],(e,[r])=>{const a=e.id(),l=r.value;return typeof a==typeof l&&a>l}],"filter-<=":[si,[ri,mi],(e,[r,a])=>{const l=e.properties()[r.value],c=a.value;return typeof l==typeof c&&l<=c}],"filter-id-<=":[si,[mi],(e,[r])=>{const a=e.id(),l=r.value;return typeof a==typeof l&&a<=l}],"filter->=":[si,[ri,mi],(e,[r,a])=>{const l=e.properties()[r.value],c=a.value;return typeof l==typeof c&&l>=c}],"filter-id->=":[si,[mi],(e,[r])=>{const a=e.id(),l=r.value;return typeof a==typeof l&&a>=l}],"filter-has":[si,[mi],(e,[r])=>r.value in e.properties()],"filter-has-id":[si,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[si,[Ei(ri)],(e,[r])=>r.value.indexOf(e.geometryType())>=0],"filter-id-in":[si,[Ei(mi)],(e,[r])=>r.value.indexOf(e.id())>=0],"filter-in-small":[si,[ri,Ei(mi)],(e,[r,a])=>a.value.indexOf(e.properties()[r.value])>=0],"filter-in-large":[si,[ri,Ei(mi)],(e,[r,a])=>function(e,r,a,l){for(;a<=l;){const c=a+l>>1;if(r[c]===e)return!0;r[c]>e?l=c-1:a=c+1}return!1}(e.properties()[r.value],a.value,0,a.value.length-1)],all:{type:si,overloads:[[[si,si],(e,[r,a])=>r.evaluate(e)&&a.evaluate(e)],[ps(si),(e,r)=>{for(const a of r)if(!a.evaluate(e))return!1;return!0}]]},any:{type:si,overloads:[[[si,si],(e,[r,a])=>r.evaluate(e)||a.evaluate(e)],[ps(si),(e,r)=>{for(const a of r)if(a.evaluate(e))return!0;return!1}]]},"!":[si,[si],(e,[r])=>!r.evaluate(e)],"is-supported-script":[si,[ri],(e,[r])=>{const a=e.globals&&e.globals.isSupportedScript;return!a||a(r.evaluate(e))}],upcase:[ri,[ri],(e,[r])=>r.evaluate(e).toUpperCase()],downcase:[ri,[ri],(e,[r])=>r.evaluate(e).toLowerCase()],concat:[ri,ps(mi),(e,r)=>r.map((r=>wr(r.evaluate(e)))).join("")],"resolved-locale":[ri,[_i],(e,[r])=>r.evaluate(e).resolvedLocale()]});class ni{constructor(e,r){this.expression=e,this._warningHistory={},this._evaluator=new We,this._defaultValue=r?function(e){if("color"===e.type&&Ms(e.default))return new Pe(0,0,0,0);switch(e.type){case"color":return Pe.parse(e.default)||null;case"padding":return Ve.parse(e.default)||null;case"numberArray":return Fe.parse(e.default)||null;case"colorArray":return Le.parse(e.default)||null;case"variableAnchorOffsetCollection":return Oe.parse(e.default)||null;case"projectionDefinition":return je.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(r):null,this._enumValues=r&&"enum"===r.type?r.values:null}evaluateWithoutErrorHandling(e,r,a,l,c,h){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=a,this._evaluator.canonical=l,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=h,this.expression.evaluate(this._evaluator)}evaluate(e,r,a,l,c,h){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=a||null,this._evaluator.canonical=l,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=h||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 $e(`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 Js(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in cs}function to(e,r){const a=new Qe(cs,fs,[],r?function(e){const r={color:li,string:ri,number:ii,enum:ri,boolean:si,formatted:yi,padding:xi,numberArray:Mi,colorArray:Ti,projectionDefinition:ci,resolvedImage:Ii,variableAnchorOffsetCollection:Ci};return"array"===e.type?Ei(r[e.value]||mi,e.length):r[e.type]}(r):void 0),l=a.parse(e,void 0,void 0,void 0,r&&"string"===r.type?{typeAnnotation:"coerce"}:void 0);return l?xs(new ni(l,r)):vs(a.errors)}class ai{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent="constant"!==e&&!_s(r.expression),this.globalStateRefs=ro(r.expression)}evaluateWithoutErrorHandling(e,r,a,l,c,h){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,l,c,h)}evaluate(e,r,a,l,c,h){return this._styleExpression.evaluate(e,r,a,l,c,h)}}class oi{constructor(e,r,a,l){this.kind=e,this.zoomStops=a,this._styleExpression=r,this.isStateDependent="camera"!==e&&!_s(r.expression),this.globalStateRefs=ro(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(e,r,a,l,c,h){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,l,c,h)}evaluate(e,r,a,l,c,h){return this._styleExpression.evaluate(e,r,a,l,c,h)}interpolationFactor(e,r,a){return this.interpolationType?yr.interpolationFactor(this.interpolationType,e,r,a):0}}function eo(e,r){const a=to(e,r);if("error"===a.result)return a;const l=a.value.expression,c=ms(l);if(!c&&!bs(r))return vs([new Ft("","data expressions not supported")]);const h=gs(l,["zoom"]);if(!h&&!ws(r))return vs([new Ft("","zoom expressions not supported")]);const u=io(l);return u||h?u instanceof Ft?vs([u]):u instanceof yr&&!Ps(r)?vs([new Ft("",'"interpolate" expressions cannot be used with this property')]):xs(u?new oi(c?"camera":"composite",a.value,u.labels,u instanceof yr?u.interpolation:void 0):new ai(c?"constant":"source",a.value)):vs([new Ft("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class ui{constructor(e,r){this._parameters=e,this._specification=r,ti(this,As(this._parameters,this._specification))}static deserialize(e){return new ui(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function io(e){let r=null;if(e instanceof tr)r=io(e.result);else if(e instanceof xr){for(const a of e.args)if(r=io(a),r)break}else(e instanceof ur||e instanceof yr)&&e.input instanceof Vn&&"zoom"===e.input.name&&(r=e);return r instanceof Ft||e.eachChild((e=>{const a=io(e);a instanceof Ft?r=a:!r&&a?r=new Ft("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):r&&a&&r!==a&&(r=new Ft("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),r}function ro(e,r=new Set){return e instanceof En&&r.add(e.key),e.eachChild((e=>{ro(e,r)})),r}function no(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 r of e.slice(1))if(!no(r)&&"boolean"!=typeof r)return!1;return!0;default:return!0}}const oo={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function qo(e){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};no(e)||(e=Jo(e));const r=to(e,oo);if("error"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,a,l)=>r.value.evaluate(e,a,{},l),needGeometry:Yo(e),getGlobalStateRefs:()=>ro(r.value.expression)}}function Xo(e,r){return er?1:0}function Yo(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let r=1;r"===r||"<="===r||">="===r?Qo(e[1],e[2],r):"any"===r?(a=e.slice(1),["any"].concat(a.map(Jo))):"all"===r?["all"].concat(e.slice(1).map(Jo)):"none"===r?["all"].concat(e.slice(1).map(Jo).map(Ya)):"in"===r?Za(e[1],e.slice(2)):"!in"===r?Ya(Za(e[1],e.slice(2))):"has"===r?Wa(e[1]):"!has"!==r||Ya(Wa(e[1]));var a}function Qo(e,r,a){switch(e){case"$type":return[`filter-type-${a}`,r];case"$id":return[`filter-id-${a}`,r];default:return[`filter-${a}`,e,r]}}function Za(e,r){if(0===r.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",r]];case"$id":return["filter-id-in",["literal",r]];default:return r.length>200&&!r.some((e=>typeof e!=typeof r[0]))?["filter-in-large",e,["literal",r.sort(Xo)]]:["filter-in-small",e,["literal",r]]}}function Wa(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Ya(e){return["!",e]}function Ja(e){const r=typeof e;if("number"===r||"boolean"===r||"string"===r||null==e)return JSON.stringify(e);if(Array.isArray(e)){let r="[";for(const a of e)r+=`${Ja(a)},`;return`${r}]`}const a=Object.keys(e).sort();let l="{";for(let r=0;rl.maximum?[new Tt(r,a,`${a} is greater than the maximum value ${l.maximum}`)]:[]}function cl(e){const r=e.valueSpec,a=el(e.value.type);let l,c,h,u={};const p="categorical"!==a&&void 0===e.value.property,g=!p,y="array"===Ss(e.value.stops)&&"array"===Ss(e.value.stops[0])&&"object"===Ss(e.value.stops[0][0]),x=nl({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===a)return[new Tt(e.key,e.value,'identity function may not have a "stops" property')];let r=[];const l=e.value;return r=r.concat(ol({key:e.key,value:l,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:v})),"array"===Ss(l)&&0===l.length&&r.push(new Tt(e.key,l,"array must have at least one stop")),r},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:r,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===a&&p&&x.push(new Tt(e.key,e.value,'missing required property "property"')),"identity"===a||e.value.stops||x.push(new Tt(e.key,e.value,'missing required property "stops"')),"exponential"===a&&e.valueSpec.expression&&!Ps(e.valueSpec)&&x.push(new Tt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(g&&!bs(e.valueSpec)?x.push(new Tt(e.key,e.value,"property functions not supported")):p&&!ws(e.valueSpec)&&x.push(new Tt(e.key,e.value,"zoom functions not supported"))),"categorical"!==a&&!y||void 0!==e.value.property||x.push(new Tt(e.key,e.value,'"property" property is required')),x;function v(e){let a=[];const l=e.value,p=e.key;if("array"!==Ss(l))return[new Tt(p,l,`array expected, ${Ss(l)} found`)];if(2!==l.length)return[new Tt(p,l,`array length 2 expected, length ${l.length} found`)];if(y){if("object"!==Ss(l[0]))return[new Tt(p,l,`object expected, ${Ss(l[0])} found`)];if(void 0===l[0].zoom)return[new Tt(p,l,"object stop key must have zoom")];if(void 0===l[0].value)return[new Tt(p,l,"object stop key must have value")];if(h&&h>el(l[0].zoom))return[new Tt(p,l[0].zoom,"stop zoom values must appear in ascending order")];el(l[0].zoom)!==h&&(h=el(l[0].zoom),c=void 0,u={}),a=a.concat(nl({key:`${p}[0]`,value:l[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:al,value:w}}))}else a=a.concat(w({key:`${p}[0]`,value:l[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},l));return Js(rl(l[1]))?a.concat([new Tt(`${p}[1]`,l[1],"expressions are not allowed in function stops.")]):a.concat(e.validateSpec({key:`${p}[1]`,value:l[1],valueSpec:r,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function w(e,h){const p=Ss(e.value),g=el(e.value),y=null!==e.value?e.value:h;if(l){if(p!==l)return[new Tt(e.key,y,`${p} stop domain type must match previous stop domain type ${l}`)]}else l=p;if("number"!==p&&"string"!==p&&"boolean"!==p)return[new Tt(e.key,y,"stop domain value must be a number, string, or boolean")];if("number"!==p&&"categorical"!==a){let l=`number expected, ${p} found`;return bs(r)&&void 0===a&&(l+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Tt(e.key,y,l)]}return"categorical"!==a||"number"!==p||isFinite(g)&&Math.floor(g)===g?"categorical"!==a&&"number"===p&&void 0!==c&&gnew Tt(`${e.key}${r.key}`,e.value,r.message)));const a=r.value.expression||r.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!a.outputDefined())return[new Tt(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!_s(a))return[new Tt(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!_s(a))return[new Tt(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!gs(a,["zoom","feature-state"]))return[new Tt(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!ms(a))return[new Tt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function pl(e){const r=e.key,a=e.value,l=Ss(a);return"string"!==l?[new Tt(r,a,`color expected, ${l} found`)]:Pe.parse(String(a))?[]:[new Tt(r,a,`color expected, "${a}" found`)]}function fl(e){const r=e.key,a=e.value,l=e.valueSpec,c=[];return Array.isArray(l.values)?-1===l.values.indexOf(el(a))&&c.push(new Tt(r,a,`expected one of [${l.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(l.values).indexOf(el(a))&&c.push(new Tt(r,a,`expected one of [${Object.keys(l.values).join(", ")}], ${JSON.stringify(a)} found`)),c}function ml(e){return no(rl(e.value))?ul(ti({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):_l(e)}function _l(e){const r=e.value,a=e.key;if("array"!==Ss(r))return[new Tt(a,r,`array expected, ${Ss(r)} found`)];const l=e.styleSpec;let c,h=[];if(r.length<1)return[new Tt(a,r,"filter array must have at least 1 element")];switch(h=h.concat(fl({key:`${a}[0]`,value:r[0],valueSpec:l.filter_operator,style:e.style,styleSpec:e.styleSpec})),el(r[0])){case"<":case"<=":case">":case">=":r.length>=2&&"$type"===el(r[1])&&h.push(new Tt(a,r,`"$type" cannot be use with operator "${r[0]}"`));case"==":case"!=":3!==r.length&&h.push(new Tt(a,r,`filter array for operator "${r[0]}" must have 3 elements`));case"in":case"!in":r.length>=2&&(c=Ss(r[1]),"string"!==c&&h.push(new Tt(`${a}[1]`,r[1],`string expected, ${c} found`)));for(let u=2;u{e in a&&r.push(new Tt(l,a[e],`"${e}" is prohibited for ref layers`))})),c.layers.forEach((r=>{el(r.id)===p&&(e=r)})),e?e.ref?r.push(new Tt(l,a.ref,"ref cannot reference another ref layer")):u=el(e.type):r.push(new Tt(l,a.ref,`ref layer "${p}" not found`))}else if("background"!==u)if(a.source){const e=c.sources&&c.sources[a.source],h=e&&el(e.type);e?"vector"===h&&"raster"===u?r.push(new Tt(l,a.source,`layer "${a.id}" requires a raster source`)):"raster-dem"!==h&&"hillshade"===u||"raster-dem"!==h&&"color-relief"===u?r.push(new Tt(l,a.source,`layer "${a.id}" requires a raster-dem source`)):"raster"===h&&"raster"!==u?r.push(new Tt(l,a.source,`layer "${a.id}" requires a vector source`)):"vector"!==h||a["source-layer"]?"raster-dem"===h&&"hillshade"!==u&&"color-relief"!==u?r.push(new Tt(l,a.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==u||!a.paint||!a.paint["line-gradient"]||"geojson"===h&&e.lineMetrics||r.push(new Tt(l,a,`layer "${a.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new Tt(l,a,`layer "${a.id}" must specify a "source-layer"`)):r.push(new Tt(l,a.source,`source "${a.source}" not found`))}else r.push(new Tt(l,a,'missing required property "source"'));return r=r.concat(nl({key:l,value:a,valueSpec:h.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${l}.type`,value:a.type,valueSpec:h.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:a,objectKey:"type"}),filter:ml,layout:e=>nl({layer:a,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>bl(ti({layerType:u},e))}}),paint:e=>nl({layer:a,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>vl(ti({layerType:u},e))}})}})),r}function Tl(e){const r=e.value,a=e.key,l=Ss(r);return"string"!==l?[new Tt(a,r,`string expected, ${l} found`)]:[]}const Pl={promoteId:function({key:e,value:r}){if("string"===Ss(r))return Tl({key:e,value:r});{const a=[];for(const l in r)a.push(...Tl({key:`${e}.${l}`,value:r[l]}));return a}}};function Sl(e){const r=e.value,a=e.key,l=e.styleSpec,c=e.style,h=e.validateSpec;if(!r.type)return[new Tt(a,r,'"type" is required')];const u=el(r.type);let p;switch(u){case"vector":case"raster":return p=nl({key:a,value:r,valueSpec:l[`source_${u.replace("-","_")}`],style:e.style,styleSpec:l,objectElementValidators:Pl,validateSpec:h}),p;case"raster-dem":return p=function(e){var r;const a=null!==(r=e.sourceName)&&void 0!==r?r:"",l=e.value,c=e.styleSpec,h=c.source_raster_dem,u=e.style;let p=[];const g=Ss(l);if(void 0===l)return p;if("object"!==g)return p.push(new Tt("source_raster_dem",l,`object expected, ${g} found`)),p;const y="custom"===el(l.encoding),x=["redFactor","greenFactor","blueFactor","baseShift"],v=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const r in l)!y&&x.includes(r)?p.push(new Tt(r,l[r],`In "${a}": "${r}" is only valid when "encoding" is set to "custom". ${v} encoding found`)):h[r]?p=p.concat(e.validateSpec({key:r,value:l[r],valueSpec:h[r],validateSpec:e.validateSpec,style:u,styleSpec:c})):p.push(new Tt(r,l[r],`unknown property "${r}"`));return p}({sourceName:a,value:r,style:e.style,styleSpec:l,validateSpec:h}),p;case"geojson":if(p=nl({key:a,value:r,valueSpec:l.source_geojson,style:c,styleSpec:l,validateSpec:h,objectElementValidators:Pl}),r.cluster)for(const e in r.clusterProperties){const[l,c]=r.clusterProperties[e],h="string"==typeof l?[l,["accumulated"],["get",e]]:l;p.push(...ul({key:`${a}.${e}.map`,value:c,expressionContext:"cluster-map"})),p.push(...ul({key:`${a}.${e}.reduce`,value:h,expressionContext:"cluster-reduce"}))}return p;case"video":return nl({key:a,value:r,valueSpec:l.source_video,style:c,validateSpec:h,styleSpec:l});case"image":return nl({key:a,value:r,valueSpec:l.source_image,style:c,validateSpec:h,styleSpec:l});case"canvas":return[new Tt(a,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return fl({key:`${a}.type`,value:r.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Ml(e){const r=e.value,a=e.styleSpec,l=a.light,c=e.style;let h=[];const u=Ss(r);if(void 0===r)return h;if("object"!==u)return h=h.concat([new Tt("light",r,`object expected, ${u} found`)]),h;for(const u in r){const p=u.match(/^(.*)-transition$/);h=h.concat(p&&l[p[1]]&&l[p[1]].transition?e.validateSpec({key:u,value:r[u],valueSpec:a.transition,validateSpec:e.validateSpec,style:c,styleSpec:a}):l[u]?e.validateSpec({key:u,value:r[u],valueSpec:l[u],validateSpec:e.validateSpec,style:c,styleSpec:a}):[new Tt(u,r[u],`unknown property "${u}"`)])}return h}function Il(e){const r=e.value,a=e.styleSpec,l=a.sky,c=e.style,h=Ss(r);if(void 0===r)return[];if("object"!==h)return[new Tt("sky",r,`object expected, ${h} found`)];let u=[];for(const h in r)u=u.concat(l[h]?e.validateSpec({key:h,value:r[h],valueSpec:l[h],style:c,styleSpec:a}):[new Tt(h,r[h],`unknown property "${h}"`)]);return u}function Cl(e){const r=e.value,a=e.styleSpec,l=a.terrain,c=e.style;let h=[];const u=Ss(r);if(void 0===r)return h;if("object"!==u)return h=h.concat([new Tt("terrain",r,`object expected, ${u} found`)]),h;for(const u in r)h=h.concat(l[u]?e.validateSpec({key:u,value:r[u],valueSpec:l[u],validateSpec:e.validateSpec,style:c,styleSpec:a}):[new Tt(u,r[u],`unknown property "${u}"`)]);return h}function El(e){let r=[];const a=e.value,l=e.key;if(Array.isArray(a)){const c=[],h=[];for(const u in a)a[u].id&&c.includes(a[u].id)&&r.push(new Tt(l,a,`all the sprites' ids must be unique, but ${a[u].id} is duplicated`)),c.push(a[u].id),a[u].url&&h.includes(a[u].url)&&r.push(new Tt(l,a,`all the sprites' URLs must be unique, but ${a[u].url} is duplicated`)),h.push(a[u].url),r=r.concat(nl({key:`${l}[${u}]`,value:a[u],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return r}return Tl({key:l,value:a})}function Al(e){return r=e.value,Boolean(r)&&r.constructor===Object?[]:[new Tt(e.key,e.value,`object expected, ${Ss(e.value)} found`)];var r}const zl={"*":()=>[],array:ol,boolean:function(e){const r=e.value,a=e.key,l=Ss(r);return"boolean"!==l?[new Tt(a,r,`boolean expected, ${l} found`)]:[]},number:al,color:pl,constants:tl,enum:fl,filter:ml,function:cl,layer:wl,object:nl,source:Sl,light:Ml,sky:Il,terrain:Cl,projection:function(e){const r=e.value,a=e.styleSpec,l=a.projection,c=e.style,h=Ss(r);if(void 0===r)return[];if("object"!==h)return[new Tt("projection",r,`object expected, ${h} found`)];let u=[];for(const h in r)u=u.concat(l[h]?e.validateSpec({key:h,value:r[h],valueSpec:l[h],style:c,styleSpec:a}):[new Tt(h,r[h],`unknown property "${h}"`)]);return u},projectionDefinition:function(e){const r=e.key;let a=e.value;a=a instanceof String?a.valueOf():a;const l=Ss(a);return"array"!==l||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(a)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(a)?["array","string"].includes(l)?[]:[new Tt(r,a,`projection expected, invalid type "${l}" found`)]:[new Tt(r,a,`projection expected, invalid array ${JSON.stringify(a)} 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 r=e.key,a=e.value;if("array"===Ss(a)){if(a.length<1||a.length>4)return[new Tt(r,a,`padding requires 1 to 4 values; ${a.length} values found`)];const l={type:"number"};let c=[];for(let h=0;h[]}})),e.constants&&(a=a.concat(tl({key:"constants",value:e.constants}))),Fl(a)}function Ll(e){return function(r){return e({...r,validateSpec:kl})}}function Fl(e){return[].concat(e).sort(((e,r)=>e.line-r.line))}function Bl(r){return function(...a){return Fl(r.apply(this||e,a))}}Dl.source=Bl(Ll(Sl)),Dl.sprite=Bl(Ll(El)),Dl.glyphs=Bl(Ll(Rl)),Dl.light=Bl(Ll(Ml)),Dl.sky=Bl(Ll(Il)),Dl.terrain=Bl(Ll(Cl)),Dl.state=Bl(Ll(Al)),Dl.layer=Bl(Ll(wl)),Dl.filter=Bl(Ll(ml)),Dl.paintProperty=Bl(Ll(vl)),Dl.layoutProperty=Bl(Ll(bl));const Ol=Dl,jl=Ol.light,Vl=Ol.sky,Nl=Ol.paintProperty,Ul=Ol.layoutProperty;function $l(e,r){let a=!1;if(r&&r.length)for(const l of r)e.fire(new vt(new Error(l.message))),a=!0;return a}class os{constructor(e,r,a){const l=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const c=new Int32Array(this.arrayBuffer);e=c[0],this.d=(r=c[1])+2*(a=c[2]);for(let e=0;e=y[g+0]&&l>=y[g+1])?(u[v]=!0,h.push(c[v])):u[v]=!1}}}}_forEachCell(e,r,a,l,c,h,u,p){const g=this._convertToCellCoord(e),y=this._convertToCellCoord(r),x=this._convertToCellCoord(a),v=this._convertToCellCoord(l);for(let w=g;w<=x;w++)for(let g=y;g<=v;g++){const y=this.d*g+w;if((!p||p(this._convertFromCellCoord(w),this._convertFromCellCoord(g),this._convertFromCellCoord(w+1),this._convertFromCellCoord(g+1)))&&c.call(this,e,r,a,l,y,h,u,p))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,r=3+this.cells.length+1+1;let a=0;for(let e=0;e=0)continue;const h=e[l];c[l]=Gl[a].shallow.indexOf(l)>=0?h:Kl(h,r)}e instanceof Error&&(c.message=e.message)}if(c.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(c.$name=a),c}function Ql(e){if(Xl(e))return e;if(Array.isArray(e))return e.map(Ql);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const r=Hl(e)||"Object";if(!Gl[r])throw new Error(`can't deserialize unregistered class ${r}`);const{klass:a}=Gl[r];if(!a)throw new Error(`can't deserialize unregistered class ${r}`);if(a.deserialize)return a.deserialize(e);const l=Object.create(a.prototype);for(const a of Object.keys(e)){if("$name"===a)continue;const c=e[a];l[a]=Gl[r].shallow.indexOf(a)>=0?c:Ql(c)}return l}class ys{constructor(){this.first=!0}update(e,r){const a=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=r):this.lastFloorZoome>=128&&e<=255,"Hangul Jamo":e=>e>=4352&&e<=4607,Khmer:e=>e>=6016&&e<=6143,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Kanbun:e=>e>=12688&&e<=12703,"CJK Strokes":e=>e>=12736&&e<=12783,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Hangul Syllables":e=>e>=44032&&e<=55215,"Private Use Area":e=>e>=57344&&e<=63743,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519};function ec(e){for(const r of e)if(ac(r.charCodeAt(0)))return!0;return!1}function ic(e){for(const r of e)if(!sc(r.charCodeAt(0)))return!1;return!0}function rc(e){const r=e.map((e=>{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}})).filter((e=>e));return new RegExp(r.join("|"),"u")}const nc=rc(["Arab","Dupl","Mong","Ougr","Syrc"]);function sc(e){return!nc.test(String.fromCodePoint(e))}const oc=rc(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function ac(e){return!(746!==e&&747!==e&&(e<4352||!(tc["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||tc["CJK Compatibility"](e)||tc["CJK Strokes"](e)||!(!tc["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||tc["Enclosed CJK Letters and Months"](e)||tc["Ideographic Description Characters"](e)||tc.Kanbun(e)||tc.Katakana(e)&&12540!==e||!(!tc["Halfwidth and Fullwidth Forms"](e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!tc["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||tc["Vertical Forms"](e)||tc["Yijing Hexagram Symbols"](e)||/\p{sc=Cans}/u.test(String.fromCodePoint(e))||/\p{sc=Hang}/u.test(String.fromCodePoint(e))||oc.test(String.fromCodePoint(e)))))}function lc(e){return!(ac(e)||function(e){return!!(tc["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||tc["General Punctuation"](e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||tc["Letterlike Symbols"](e)||tc["Number Forms"](e)||tc["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||tc["Control Pictures"](e)&&9251!==e||tc["Optical Character Recognition"](e)||tc["Enclosed Alphanumerics"](e)||tc["Geometric Shapes"](e)||tc["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||tc["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||tc["CJK Symbols and Punctuation"](e)||tc.Katakana(e)||tc["Private Use Area"](e)||tc["CJK Compatibility Forms"](e)||tc["Small Form Variants"](e)||tc["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}const cc=rc(["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 hc(e){return cc.test(String.fromCodePoint(e))}function uc(e,r){return!(!r&&hc(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||tc.Khmer(e))}function dc(e){for(const r of e)if(hc(r.charCodeAt(0)))return!0;return!1}const pc=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(pc.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,r){return a(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const a=e.pluginURL,l=new Promise((e=>{this.loadScriptResolve=e}));r(a);const c=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([l,c]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:a};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${a}`)}))}};class Cs{constructor(e,r){this.zoom=e,r?(this.now=r.now||0,this.fadeDuration=r.fadeDuration||0,this.zoomHistory=r.zoomHistory||new ys,this.transition=r.transition||{},this.globalState=r.globalState||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ys,this.transition={},this.globalState={})}isSupportedScript(e){return function(e,r){for(const a of e)if(!uc(a.charCodeAt(0),r))return!1;return!0}(e,"loaded"===pc.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,r=e-Math.floor(e),a=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*a}:{fromScale:.5,toScale:1,t:1-(1-a)*r}}}class Bs{constructor(e,r){this.property=e,this.value=r,this.expression=function(e,r){if(Ms(e))return new ui(e,r);if(Js(e)){const a=eo(e,r);if("error"===a.result)throw new Error(a.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return a.value}{let a=e;return"color"===r.type&&"string"==typeof e?a=Pe.parse(e):"padding"!==r.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==r.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==r.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===r.type&&Array.isArray(e)?a=Oe.parse(e):"projectionDefinition"===r.type&&"string"==typeof e&&(a=je.parse(e)):a=Le.parse(e):a=Fe.parse(e):a=Ve.parse(e),{globalStateRefs:new Set,kind:"constant",evaluate:()=>a}}}(void 0===r?e.specification.default:r,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,r,a){return this.property.possiblyEvaluate(this,e,r,a)}}class Es{constructor(e){this.property=e,this.value=new Bs(e,void 0)}transitioned(e,r){return new Vs(this.property,this.value,r,Ct({},e.transition,this.transition),e.now)}untransitioned(){return new Vs(this.property,this.value,null,{},0)}}class Ts{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return Nt(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Es(this._values[e].property)),this._values[e].value=new Bs(this._values[e].property,null===r?void 0:Nt(r))}getTransition(e){return Nt(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Es(this._values[e].property)),this._values[e].transition=Nt(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const a=this.getValue(r);void 0!==a&&(e[r]=a);const l=this.getTransition(r);void 0!==l&&(e[`${r}-transition`]=l)}return e}transitioned(e,r){const a=new Fs(this._properties);for(const l of Object.keys(this._values))a._values[l]=this._values[l].transitioned(e,r._values[l]);return a}untransitioned(){const e=new Fs(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class Vs{constructor(e,r,a,l,c){this.property=e,this.value=r,this.begin=c+l.delay||0,this.end=this.begin+l.duration||0,e.specification.transition&&(l.delay||l.duration)&&(this.prior=a)}possiblyEvaluate(e,r,a){const l=e.now||0,c=this.value.possiblyEvaluate(e,r,a),h=this.prior;if(h){if(l>this.end)return this.prior=null,c;if(this.value.isDataDriven())return this.prior=null,c;if(ll.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class Ns{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,l){if(void 0!==e.value){if("constant"===e.expression.kind){const c=e.expression.evaluate(r,null,{},a,l);return this._calculate(c,c,c,r)}return this._calculate(e.expression.evaluate(new Cs(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Cs(Math.floor(r.zoom),r)),e.expression.evaluate(new Cs(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,a,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class Us{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,l){return!!e.expression.evaluate(r,null,{},a,l)}interpolate(){return!1}}class qs{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in e){const a=e[r];a.specification.overridable&&this.overridableProperties.push(r);const l=this.defaultPropertyValues[r]=new Bs(a,void 0),c=this.defaultTransitionablePropertyValues[r]=new Es(a);this.defaultTransitioningPropertyValues[r]=c.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}ql("DataDrivenProperty",Rs),ql("DataConstantProperty",Os),ql("CrossFadedDataDrivenProperty",js),ql("CrossFadedProperty",Ns),ql("ColorRampProperty",Us);const fc="-transition";class Xs extends bt{constructor(e,r){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},"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=qo(e.filter)),r.layout&&(this._unevaluatedLayout=new Ls(r.layout)),r.paint)){this._transitionablePaint=new Ts(r.paint);for(const r in e.paint)this.setPaintProperty(r,e.paint[r],{validate:!1});for(const r in e.layout)this.setLayoutProperty(r,e.layout[r],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ds(r.paint)}}setFilter(e){this.filter=e,this._featureFilter=qo(e)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;if(this._unevaluatedLayout)for(const r in this._unevaluatedLayout._values){const a=this._unevaluatedLayout._values[r];for(const r of a.getGlobalStateRefs())e.add(r)}for(const r of this._featureFilter.getGlobalStateRefs())e.add(r);return e}setLayoutProperty(e,r,a={}){null!=r&&this._validate(Ul,`layers.${this.id}.layout.${e}`,e,r,a)||("visibility"!==e?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return e.endsWith(fc)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,a={}){if(null!=r&&this._validate(Nl,`layers.${this.id}.paint.${e}`,e,r,a))return!1;if(e.endsWith(fc))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{const a=this._transitionablePaint._values[e],l="cross-faded-data-driven"===a.property.specification["property-type"],c=a.value.isDataDriven(),h=a.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const u=this._transitionablePaint._values[e].value;return u.isDataDriven()||c||l||this._handleOverridablePaintPropertyUpdate(e,h,u)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,a){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}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),Bt(e,((e,r)=>!(void 0===e||"layout"===r&&!Object.keys(e).length||"paint"===r&&!Object.keys(e).length)))}_validate(e,r,a,l,c={}){return(!c||!1!==c.validate)&&$l(this,e.call(Ol,{key:r,layerType:this.type,objectKey:a,value:l,styleSpec:Me,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof $s&&bs(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}}const _c={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ys{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Hs{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_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 r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function yc(e,r=1){let a=0,l=0;return{members:e.map((e=>{const c=_c[e.type].BYTES_PER_ELEMENT,h=a=bc(a,Math.max(r,c)),u=e.components||1;return l=Math.max(l,c),a+=c*u,{name:e.name,type:e.type,components:u,offset:h}})),size:bc(a,Math.max(l,r)),alignment:r}}function bc(e,r){return Math.ceil(e/r)*r}class Ws extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const l=2*e;return this.int16[l+0]=r,this.int16[l+1]=a,e}}Ws.prototype.bytesPerElement=4,ql("StructArrayLayout2i4",Ws);class Qs extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const c=3*e;return this.int16[c+0]=r,this.int16[c+1]=a,this.int16[c+2]=l,e}}Qs.prototype.bytesPerElement=6,ql("StructArrayLayout3i6",Qs);class ta extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,a,l)}emplace(e,r,a,l,c){const h=4*e;return this.int16[h+0]=r,this.int16[h+1]=a,this.int16[h+2]=l,this.int16[h+3]=c,e}}ta.prototype.bytesPerElement=8,ql("StructArrayLayout4i8",ta);class ea extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,c,h){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,a,l,c,h)}emplace(e,r,a,l,c,h,u){const p=6*e;return this.int16[p+0]=r,this.int16[p+1]=a,this.int16[p+2]=l,this.int16[p+3]=c,this.int16[p+4]=h,this.int16[p+5]=u,e}}ea.prototype.bytesPerElement=12,ql("StructArrayLayout2i4i12",ea);class ra extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,c,h){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,a,l,c,h)}emplace(e,r,a,l,c,h,u){const p=4*e,g=8*e;return this.int16[p+0]=r,this.int16[p+1]=a,this.uint8[g+4]=l,this.uint8[g+5]=c,this.uint8[g+6]=h,this.uint8[g+7]=u,e}}ra.prototype.bytesPerElement=8,ql("StructArrayLayout2i4ub8",ra);class na extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const l=2*e;return this.float32[l+0]=r,this.float32[l+1]=a,e}}na.prototype.bytesPerElement=8,ql("StructArrayLayout2f8",na);class ia extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,c,h,u,p,g,y){const x=this.length;return this.resize(x+1),this.emplace(x,e,r,a,l,c,h,u,p,g,y)}emplace(e,r,a,l,c,h,u,p,g,y,x){const v=10*e;return this.uint16[v+0]=r,this.uint16[v+1]=a,this.uint16[v+2]=l,this.uint16[v+3]=c,this.uint16[v+4]=h,this.uint16[v+5]=u,this.uint16[v+6]=p,this.uint16[v+7]=g,this.uint16[v+8]=y,this.uint16[v+9]=x,e}}ia.prototype.bytesPerElement=20,ql("StructArrayLayout10ui20",ia);class sa extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,c,h,u,p,g,y,x,v){const w=this.length;return this.resize(w+1),this.emplace(w,e,r,a,l,c,h,u,p,g,y,x,v)}emplace(e,r,a,l,c,h,u,p,g,y,x,v,w){const M=12*e;return this.int16[M+0]=r,this.int16[M+1]=a,this.int16[M+2]=l,this.int16[M+3]=c,this.uint16[M+4]=h,this.uint16[M+5]=u,this.uint16[M+6]=p,this.uint16[M+7]=g,this.int16[M+8]=y,this.int16[M+9]=x,this.int16[M+10]=v,this.int16[M+11]=w,e}}sa.prototype.bytesPerElement=24,ql("StructArrayLayout4i4ui4i24",sa);class aa extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const c=3*e;return this.float32[c+0]=r,this.float32[c+1]=a,this.float32[c+2]=l,e}}aa.prototype.bytesPerElement=12,ql("StructArrayLayout3f12",aa);class oa extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}oa.prototype.bytesPerElement=4,ql("StructArrayLayout1ul4",oa);class la extends Hs{_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,r,a,l,c,h,u,p,g){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,a,l,c,h,u,p,g)}emplace(e,r,a,l,c,h,u,p,g,y){const x=10*e,v=5*e;return this.int16[x+0]=r,this.int16[x+1]=a,this.int16[x+2]=l,this.int16[x+3]=c,this.int16[x+4]=h,this.int16[x+5]=u,this.uint32[v+3]=p,this.uint16[x+8]=g,this.uint16[x+9]=y,e}}la.prototype.bytesPerElement=20,ql("StructArrayLayout6i1ul2ui20",la);class ua extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,c,h){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,a,l,c,h)}emplace(e,r,a,l,c,h,u){const p=6*e;return this.int16[p+0]=r,this.int16[p+1]=a,this.int16[p+2]=l,this.int16[p+3]=c,this.int16[p+4]=h,this.int16[p+5]=u,e}}ua.prototype.bytesPerElement=12,ql("StructArrayLayout2i2i2i12",ua);class ca extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,a,l,c)}emplace(e,r,a,l,c,h){const u=4*e,p=8*e;return this.float32[u+0]=r,this.float32[u+1]=a,this.float32[u+2]=l,this.int16[p+6]=c,this.int16[p+7]=h,e}}ca.prototype.bytesPerElement=16,ql("StructArrayLayout2f1f2i16",ca);class ha extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,c,h){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,a,l,c,h)}emplace(e,r,a,l,c,h,u){const p=16*e,g=4*e,y=8*e;return this.uint8[p+0]=r,this.uint8[p+1]=a,this.float32[g+1]=l,this.float32[g+2]=c,this.int16[y+6]=h,this.int16[y+7]=u,e}}ha.prototype.bytesPerElement=16,ql("StructArrayLayout2ub2f2i16",ha);class pa extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const c=3*e;return this.uint16[c+0]=r,this.uint16[c+1]=a,this.uint16[c+2]=l,e}}pa.prototype.bytesPerElement=6,ql("StructArrayLayout3ui6",pa);class fa extends Hs{_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,r,a,l,c,h,u,p,g,y,x,v,w,M,C,A,k){const R=this.length;return this.resize(R+1),this.emplace(R,e,r,a,l,c,h,u,p,g,y,x,v,w,M,C,A,k)}emplace(e,r,a,l,c,h,u,p,g,y,x,v,w,M,C,A,k,R){const D=24*e,L=12*e,B=48*e;return this.int16[D+0]=r,this.int16[D+1]=a,this.uint16[D+2]=l,this.uint16[D+3]=c,this.uint32[L+2]=h,this.uint32[L+3]=u,this.uint32[L+4]=p,this.uint16[D+10]=g,this.uint16[D+11]=y,this.uint16[D+12]=x,this.float32[L+7]=v,this.float32[L+8]=w,this.uint8[B+36]=M,this.uint8[B+37]=C,this.uint8[B+38]=A,this.uint32[L+10]=k,this.int16[D+22]=R,e}}fa.prototype.bytesPerElement=48,ql("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",fa);class da extends Hs{_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,r,a,l,c,h,u,p,g,y,x,v,w,M,C,A,k,R,D,L,B,O,j,N,U,Z,J,Q){const et=this.length;return this.resize(et+1),this.emplace(et,e,r,a,l,c,h,u,p,g,y,x,v,w,M,C,A,k,R,D,L,B,O,j,N,U,Z,J,Q)}emplace(e,r,a,l,c,h,u,p,g,y,x,v,w,M,C,A,k,R,D,L,B,O,j,N,U,Z,J,Q,et){const it=32*e,rt=16*e;return this.int16[it+0]=r,this.int16[it+1]=a,this.int16[it+2]=l,this.int16[it+3]=c,this.int16[it+4]=h,this.int16[it+5]=u,this.int16[it+6]=p,this.int16[it+7]=g,this.uint16[it+8]=y,this.uint16[it+9]=x,this.uint16[it+10]=v,this.uint16[it+11]=w,this.uint16[it+12]=M,this.uint16[it+13]=C,this.uint16[it+14]=A,this.uint16[it+15]=k,this.uint16[it+16]=R,this.uint16[it+17]=D,this.uint16[it+18]=L,this.uint16[it+19]=B,this.uint16[it+20]=O,this.uint16[it+21]=j,this.uint16[it+22]=N,this.uint32[rt+12]=U,this.float32[rt+13]=Z,this.float32[rt+14]=J,this.uint16[it+30]=Q,this.uint16[it+31]=et,e}}da.prototype.bytesPerElement=64,ql("StructArrayLayout8i15ui1ul2f2ui64",da);class ya extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}ya.prototype.bytesPerElement=4,ql("StructArrayLayout1f4",ya);class ma extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const c=3*e;return this.uint16[6*e+0]=r,this.float32[c+1]=a,this.float32[c+2]=l,e}}ma.prototype.bytesPerElement=12,ql("StructArrayLayout1ui2f12",ma);class ga extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const c=4*e;return this.uint32[2*e+0]=r,this.uint16[c+2]=a,this.uint16[c+3]=l,e}}ga.prototype.bytesPerElement=8,ql("StructArrayLayout1ul2ui8",ga);class xa extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const l=2*e;return this.uint16[l+0]=r,this.uint16[l+1]=a,e}}xa.prototype.bytesPerElement=4,ql("StructArrayLayout2ui4",xa);class va extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}va.prototype.bytesPerElement=2,ql("StructArrayLayout1ui2",va);class ba extends Hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,a,l)}emplace(e,r,a,l,c){const h=4*e;return this.float32[h+0]=r,this.float32[h+1]=a,this.float32[h+2]=l,this.float32[h+3]=c,e}}ba.prototype.bytesPerElement=16,ql("StructArrayLayout4f16",ba);class wa extends Ys{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 y(this.anchorPointX,this.anchorPointY)}}wa.prototype.size=20;class _a extends la{get(e){return new wa(this,e)}}ql("CollisionBoxArray",_a);class Sa extends Ys{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]}}Sa.prototype.size=48;class Aa extends fa{get(e){return new Sa(this,e)}}ql("PlacedSymbolArray",Aa);class ka extends Ys{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]}}ka.prototype.size=64;class Ma extends da{get(e){return new ka(this,e)}}ql("SymbolInstanceArray",Ma);class Ia extends ya{getoffsetX(e){return this.float32[1*e+0]}}ql("GlyphOffsetArray",Ia);class za extends Qs{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}ql("SymbolLineVertexArray",za);class Pa extends Ys{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]}}Pa.prototype.size=12;class Ca extends ma{get(e){return new Pa(this,e)}}ql("TextAnchorOffsetArray",Ca);class Ba extends Ys{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]}}Ba.prototype.size=8;class Ea extends ga{get(e){return new Ba(this,e)}}ql("FeatureIndexArray",Ea);class Ta extends Ws{}class Va extends Ws{}class Fa extends Ws{}class La extends ea{}class $a extends ra{}class Da extends na{}class Oa extends ia{}class Ra extends sa{}class ja extends aa{}class Na extends oa{}class Ua extends ua{}class qa extends ha{}class Ga extends pa{}class Xa extends xa{}const wc=yc([{name:"a_pos",components:2,type:"Int16"}],4),{members:Tc}=wc;class Ha{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,r,a,l){const c=this.segments[this.segments.length-1];return e>Ha.MAX_VERTEX_ARRAY_LENGTH&&Gt(`Max vertices per segment is ${Ha.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Ha.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!c||c.vertexLength+e>Ha.MAX_VERTEX_ARRAY_LENGTH||c.sortKey!==l?this.createNewSegment(r,a,l):c}createNewSegment(e,r,a){const l={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==a&&(l.sortKey=a),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(l),l}getOrCreateLatestSegment(e,r,a){return this.prepareSegment(0,e,r,a)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,a,l){return new Ha([{vertexOffset:e,primitiveOffset:r,vertexLength:a,primitiveLength:l,vaos:{},sortKey:0}])}}function Pc(e,r){return 256*(e=Pt(Math.floor(e),0,255))+Pt(Math.floor(r),0,255)}Ha.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ql("SegmentVector",Ha);const Sc=yc([{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"}]);var Mc,Ic,Cc,Ec={exports:{}},Ac={exports:{}},zc={exports:{}},kc=function(){if(Cc)return Ec.exports;Cc=1;var e=(Mc||(Mc=1,Ac.exports=function(e,r){var a,l,c,h,u,p,g,y;for(l=e.length-(a=3&e.length),c=r,u=3432918353,p=461845907,y=0;y>>16)*u&65535)<<16)&4294967295)<<15|g>>>17))*p+(((g>>>16)*p&65535)<<16)&4294967295)<<13|c>>>19))+((5*(c>>>16)&65535)<<16)&4294967295))+((58964+(h>>>16)&65535)<<16);switch(g=0,a){case 3:g^=(255&e.charCodeAt(y+2))<<16;case 2:g^=(255&e.charCodeAt(y+1))<<8;case 1:c^=g=(65535&(g=(g=(65535&(g^=255&e.charCodeAt(y)))*u+(((g>>>16)*u&65535)<<16)&4294967295)<<15|g>>>17))*p+(((g>>>16)*p&65535)<<16)&4294967295}return c^=e.length,c=2246822507*(65535&(c^=c>>>16))+((2246822507*(c>>>16)&65535)<<16)&4294967295,c=3266489909*(65535&(c^=c>>>13))+((3266489909*(c>>>16)&65535)<<16)&4294967295,(c^=c>>>16)>>>0}),Ac.exports),r=(Ic||(Ic=1,zc.exports=function(e,r){for(var a,l=e.length,c=r^l,h=0;l>=4;)a=1540483477*(65535&(a=255&e.charCodeAt(h)|(255&e.charCodeAt(++h))<<8|(255&e.charCodeAt(++h))<<16|(255&e.charCodeAt(++h))<<24))+((1540483477*(a>>>16)&65535)<<16),c=1540483477*(65535&c)+((1540483477*(c>>>16)&65535)<<16)^(a=1540483477*(65535&(a^=a>>>24))+((1540483477*(a>>>16)&65535)<<16)),l-=4,++h;switch(l){case 3:c^=(255&e.charCodeAt(h+2))<<16;case 2:c^=(255&e.charCodeAt(h+1))<<8;case 1:c=1540483477*(65535&(c^=255&e.charCodeAt(h)))+((1540483477*(c>>>16)&65535)<<16)}return c=1540483477*(65535&(c^=c>>>13))+((1540483477*(c>>>16)&65535)<<16),(c^=c>>>15)>>>0}),zc.exports);return Ec.exports=e,Ec.exports.murmur3=e,Ec.exports.murmur2=r,Ec.exports}(),Rc=l(kc);class ao{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,a,l){this.ids.push(Dc(e)),this.positions.push(r,a,l)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=Dc(e);let a=0,l=this.ids.length-1;for(;a>1;this.ids[e]>=r?l=e:a=e+1}const c=[];for(;this.ids[a]===r;)c.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return c}static serialize(e,r){const a=new Float64Array(e.ids),l=new Uint32Array(e.positions);return Lc(a,l,0,a.length-1),r&&r.push(a.buffer,l.buffer),{ids:a,positions:l}}static deserialize(e){const r=new ao;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function Dc(e){const r=+e;return!isNaN(r)&&r<=Number.MAX_SAFE_INTEGER?r:Rc(String(e))}function Lc(e,r,a,l){for(;a>1];let h=a-1,u=l+1;for(;;){do{h++}while(e[h]c);if(h>=u)break;Fc(e,h,u),Fc(r,3*h,3*u),Fc(r,3*h+1,3*u+1),Fc(r,3*h+2,3*u+2)}u-a`u_${e}`)),this.type=a}setUniform(e,r,a){e.set(a.constantOr(this.value))}getBinding(e,r,a){return"color"===this.type?new fo(e,r):new ho(e,r)}}class xo{constructor(e,r){this.uniformNames=r.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=e.tlbr}setUniform(e,r,a,l){const c="u_pattern_to"===l?this.patternTo:"u_pattern_from"===l?this.patternFrom:"u_pixel_ratio_to"===l?this.pixelRatioTo:"u_pixel_ratio_from"===l?this.pixelRatioFrom:null;c&&e.set(c)}getBinding(e,r,a){return"u_pattern"===a.substr(0,9)?new po(e,r):new ho(e,r)}}class vo{constructor(e,r,a,l){this.expression=e,this.type=a,this.maxValue=0,this.paintVertexAttributes=r.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===a?2:1,offset:0}))),this.paintVertexArray=new l}populatePaintArray(e,r,a,l,c){const h=this.paintVertexArray.length,u=this.expression.evaluate(new Cs(0),r,{},l,[],c);this.paintVertexArray.resize(e),this._setPaintValue(h,e,u)}updatePaintArray(e,r,a,l){const c=this.expression.evaluate({zoom:0},a,l);this._setPaintValue(e,r,c)}_setPaintValue(e,r,a){if("color"===this.type){const l=Oc(a);for(let a=e;a`u_${e}_t`)),this.type=a,this.useIntegerZoom=l,this.zoom=c,this.maxValue=0,this.paintVertexAttributes=r.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===a?4:2,offset:0}))),this.paintVertexArray=new h}populatePaintArray(e,r,a,l,c){const h=this.expression.evaluate(new Cs(this.zoom),r,{},l,[],c),u=this.expression.evaluate(new Cs(this.zoom+1),r,{},l,[],c),p=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(p,e,h,u)}updatePaintArray(e,r,a,l){const c=this.expression.evaluate({zoom:this.zoom},a,l),h=this.expression.evaluate({zoom:this.zoom+1},a,l);this._setPaintValue(e,r,c,h)}_setPaintValue(e,r,a,l){if("color"===this.type){const c=Oc(a),h=Oc(l);for(let a=e;a`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const a=this.binders[r];if(a instanceof vo||a instanceof bo)for(let r=0;r!0){this.programConfigurations={};for(const l of e)this.programConfigurations[l.id]=new _o(l,r,a);this.needsUpload=!1,this._featureMap=new ao,this._bufferOffset=0}populatePaintArrays(e,r,a,l,c,h){for(const a in this.programConfigurations)this.programConfigurations[a].populatePaintArrays(e,r,l,c,h);void 0!==r.id&&this._featureMap.add(r.id,a,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,a,l){for(const c of a)this.needsUpload=this.programConfigurations[c.id].updatePaintArrays(e,this._featureMap,r,c,l)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function jc(e,r){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-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(`${r}-`,"").replace(/-/g,"_")]}function Vc(e,r,a){const l={color:{source:na,composite:ba},number:{source:ya,composite:na}},c=function(e){return{"line-pattern":{source:Oa,composite:Oa},"fill-pattern":{source:Oa,composite:Oa},"fill-extrusion-pattern":{source:Oa,composite:Oa}}[e]}(e);return c&&c[a]||l[r][a]}ql("ConstantBinder",go),ql("CrossFadedConstantBinder",xo),ql("SourceExpressionBinder",vo),ql("CrossFadedCompositeBinder",wo),ql("CompositeExpressionBinder",bo),ql("ProgramConfiguration",_o,{omit:["_buffers"]}),ql("ProgramConfigurationSet",So);const Nc=Math.pow(2,14)-1,Uc=-Nc-1;function Zc(e){const r=ot/e.extent,a=e.loadGeometry();for(let e=0;ea.x+1||ha.y+1)&&Gt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return a}function $c(e,r){return{type:e.type,id:e.id,properties:e.properties,geometry:r?Zc(e):[]}}const Gc=-32768;function qc(e,r,a,l,c){e.emplaceBack(Gc+8*r+l,Gc+8*a+c)}class Eo{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Va,this.indexArray=new Ga,this.segments=new Ha,this.programConfigurations=new So(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,r,a){const l=this.layers[0],c=[];let h=null,u=!1,p="heatmap"===l.type;if("circle"===l.type){const e=l;h=e.layout.get("circle-sort-key"),u=!h.isConstant(),p=p||"map"===e.paint.get("circle-pitch-alignment")}const g=p?r.subdivisionGranularity.circle:1;for(const{feature:r,id:l,index:p,sourceLayerIndex:g}of e){const e=this.layers[0]._featureFilter.needGeometry,y=$c(r,e);if(!this.layers[0]._featureFilter.filter(new Cs(this.zoom,{globalState:this.globalState}),y,a))continue;const x=u?h.evaluate(y,{},a):void 0,v={id:l,properties:r.properties,type:r.type,sourceLayerIndex:g,index:p,geometry:e?y.geometry:Zc(r),patterns:{},sortKey:x};c.push(v)}u&&c.sort(((e,r)=>e.sortKey-r.sortKey));for(const l of c){const{geometry:c,index:h,sourceLayerIndex:u}=l,p=e[h].feature;this.addFeature(l,c,h,a,g),r.featureIndex.insert(p,c,h,u,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Tc),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,r,a,l,c=1){let h;switch(c){case 1:h=[0,7];break;case 3:h=[0,2,5,7];break;case 5:h=[0,1,3,4,6,7];break;case 7:h=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${c}; valid values are 1, 3, 5, 7.`)}const u=h.length;for(const a of r)for(const r of a){const a=r.x,l=r.y;if(a<0||a>=ot||l<0||l>=ot)continue;const c=this.segments.prepareSegment(u*u,this.layoutVertexArray,this.indexArray,e.sortKey),p=c.vertexLength;for(let e=0;e1){if(th(e,r))return!0;for(let l=0;l1?a:a.sub(r)._mult(c)._add(r))}function ah(e,r){let a,l,c,h=!1;for(let u=0;ur.y!=c.y>r.y&&r.x<(c.x-l.x)*(r.y-l.y)/(c.y-l.y)+l.x&&(h=!h)}return h}function hh(e,r){let a=!1;for(let l=0,c=e.length-1;lr.y!=u.y>r.y&&r.x<(u.x-h.x)*(r.y-h.y)/(u.y-h.y)+h.x&&(a=!a)}return a}function dh(e,r,a){const l=a[0],c=a[2];if(e.xc.x&&r.x>c.x||e.yc.y&&r.y>c.y)return!1;const h=qt(e,r,a[0]);return h!==qt(e,r,a[1])||h!==qt(e,r,a[2])||h!==qt(e,r,a[3])}function ph(e,r,a){const l=r.paint.get(e).value;return"constant"===l.kind?l.value:a.programConfigurations.get(r.id).getMaxValue(e)}function mh(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function _h(e,r,a,l,c){if(!r[0]&&!r[1])return e;const h=y.convert(r)._mult(c);"viewport"===a&&h._rotate(-l);const u=[];for(let r=0;rvh(e,r,a,l)))}(g,c,u,p),w=x?y*h:y;for(const e of l)for(const r of e){const e=x?r:vh(r,c,u,p);let a=w;const l=c.projectTileCoordinates(r.x,r.y,u,p).signedDistanceFromCamera;if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?a*=l/c.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(a*=c.cameraToCenterDistance/l),Xc(v,e,a))return!0}return!1}}function vh(e,r,a,l){const c=r.projectTileCoordinates(e.x,e.y,a,l).point;return new y((.5*c.x+.5)*r.width,(.5*-c.y+.5)*r.height)}class Wo extends Eo{}let bh;ql("HeatmapBucket",Wo,{omit:["layers"]});var Th={get paint(){return bh=bh||new qs({"heatmap-radius":new Rs(Me.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Rs(Me.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Os(Me.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Us(Me.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Os(Me.paint_heatmap["heatmap-opacity"])})}};function Mh(e,{width:r,height:a},l,c){if(c){if(c instanceof Uint8ClampedArray)c=new Uint8Array(c.buffer);else if(c.length!==r*a*l)throw new RangeError(`mismatched image size. expected: ${c.length} but got: ${r*a*l}`)}else c=new Uint8Array(r*a*l);return e.width=r,e.height=a,e.data=c,e}function Eh(e,{width:r,height:a},l){if(r===e.width&&a===e.height)return;const c=Mh({},{width:r,height:a},l);Rh(e,c,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,r),height:Math.min(e.height,a)},l),e.width=r,e.height=a,e.data=c.data}function Rh(e,r,a,l,c,h){if(0===c.width||0===c.height)return r;if(c.width>e.width||c.height>e.height||a.x>e.width-c.width||a.y>e.height-c.height)throw new RangeError("out of range source coordinates for image copy");if(c.width>r.width||c.height>r.height||l.x>r.width-c.width||l.y>r.height-c.height)throw new RangeError("out of range destination coordinates for image copy");const u=e.data,p=r.data;if(u===p)throw new Error("srcData equals dstData, so image is already copied");for(let g=0;g{r[e.evaluationKey]=u;const p=e.expression.evaluate(r);c.setPixel(l/4/a,h/4,p)};if(e.clips)for(let r=0,c=0;rthis.max&&(this.max=a),a=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(e+1)}unpack(e,r,a){return e*this.redFactor+r*this.greenFactor+a*this.blueFactor-this.baseShift}pack(e){return Nh(e,this.getUnpackVector())}getPixels(){return new sl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,a){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let l=r*this.dim,c=r*this.dim+this.dim,h=a*this.dim,u=a*this.dim+this.dim;switch(r){case-1:l=c-1;break;case 1:c=l+1}switch(a){case-1:h=u-1;break;case 1:u=h+1}const p=-r*this.dim,g=-a*this.dim;for(let r=h;r0)for(let c=r;c=r;c-=l)h=yu(c/l|0,e[c],e[c+1],h);return h&&du(h,h.next)&&(xu(h),h=h.next),h}function Hh(e,r){if(!e)return e;r||(r=e);let a,l=e;do{if(a=!1,l.steiner||!du(l,l.next)&&0!==uu(l.prev,l,l.next))l=l.next;else{if(xu(l),l=r=l.prev,l===l.next)break;a=!0}}while(a||l!==r);return r}function Xh(e,r,a,l,c,h,u){if(!e)return;!u&&h&&function(e,r,a,l){let c=e;do{0===c.z&&(c.z=su(c.x,c.y,r,a,l)),c.prevZ=c.prev,c.nextZ=c.next,c=c.next}while(c!==e);c.prevZ.nextZ=null,c.prevZ=null,function(e){let r,a=1;do{let l,c=e;e=null;let h=null;for(r=0;c;){r++;let u=c,p=0;for(let e=0;e0||g>0&&u;)0!==p&&(0===g||!u||c.z<=u.z)?(l=c,c=c.nextZ,p--):(l=u,u=u.nextZ,g--),h?h.nextZ=l:e=l,l.prevZ=h,h=l;c=u}h.nextZ=null,a*=2}while(r>1)}(c)}(e,l,c,h);let p=e;for(;e.prev!==e.next;){const g=e.prev,y=e.next;if(h?Jh(e,l,c,h):Kh(e))r.push(g.i,e.i,y.i),xu(e),e=y.next,p=y.next;else if((e=y)===p){u?1===u?Xh(e=Qh(Hh(e),r),r,a,l,c,h,2):2===u&&tu(e,r,a,l,c,h):Xh(Hh(e),r,a,l,c,h,1);break}}}function Kh(e){const r=e.prev,a=e,l=e.next;if(uu(r,a,l)>=0)return!1;const c=r.x,h=a.x,u=l.x,p=r.y,g=a.y,y=l.y,x=Math.min(c,h,u),v=Math.min(p,g,y),w=Math.max(c,h,u),M=Math.max(p,g,y);let C=l.next;for(;C!==r;){if(C.x>=x&&C.x<=w&&C.y>=v&&C.y<=M&&cu(c,p,h,g,u,y,C.x,C.y)&&uu(C.prev,C,C.next)>=0)return!1;C=C.next}return!0}function Jh(e,r,a,l){const c=e.prev,h=e,u=e.next;if(uu(c,h,u)>=0)return!1;const p=c.x,g=h.x,y=u.x,x=c.y,v=h.y,w=u.y,M=Math.min(p,g,y),C=Math.min(x,v,w),A=Math.max(p,g,y),k=Math.max(x,v,w),R=su(M,C,r,a,l),D=su(A,k,r,a,l);let L=e.prevZ,B=e.nextZ;for(;L&&L.z>=R&&B&&B.z<=D;){if(L.x>=M&&L.x<=A&&L.y>=C&&L.y<=k&&L!==c&&L!==u&&cu(p,x,g,v,y,w,L.x,L.y)&&uu(L.prev,L,L.next)>=0)return!1;if(L=L.prevZ,B.x>=M&&B.x<=A&&B.y>=C&&B.y<=k&&B!==c&&B!==u&&cu(p,x,g,v,y,w,B.x,B.y)&&uu(B.prev,B,B.next)>=0)return!1;B=B.nextZ}for(;L&&L.z>=R;){if(L.x>=M&&L.x<=A&&L.y>=C&&L.y<=k&&L!==c&&L!==u&&cu(p,x,g,v,y,w,L.x,L.y)&&uu(L.prev,L,L.next)>=0)return!1;L=L.prevZ}for(;B&&B.z<=D;){if(B.x>=M&&B.x<=A&&B.y>=C&&B.y<=k&&B!==c&&B!==u&&cu(p,x,g,v,y,w,B.x,B.y)&&uu(B.prev,B,B.next)>=0)return!1;B=B.nextZ}return!0}function Qh(e,r){let a=e;do{const l=a.prev,c=a.next.next;!du(l,c)&&pu(l,a,a.next,c)&&_u(l,c)&&_u(c,l)&&(r.push(l.i,a.i,c.i),xu(a),xu(a.next),a=e=c),a=a.next}while(a!==e);return Hh(a)}function tu(e,r,a,l,c,h){let u=e;do{let e=u.next.next;for(;e!==u.prev;){if(u.i!==e.i&&hu(u,e)){let p=gu(u,e);return u=Hh(u,u.next),p=Hh(p,p.next),Xh(u,r,a,l,c,h,0),void Xh(p,r,a,l,c,h,0)}e=e.next}u=u.next}while(u!==e)}function eu(e,r){let a=e.x-r.x;return 0===a&&(a=e.y-r.y,0===a)&&(a=(e.next.y-e.y)/(e.next.x-e.x)-(r.next.y-r.y)/(r.next.x-r.x)),a}function iu(e,r){const a=function(e,r){let a=r;const l=e.x,c=e.y;let h,u=-1/0;if(du(e,a))return a;do{if(du(e,a.next))return a.next;if(c<=a.y&&c>=a.next.y&&a.next.y!==a.y){const e=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(e<=l&&e>u&&(u=e,h=a.x=a.x&&a.x>=g&&l!==a.x&&lu(ch.x||a.x===h.x&&ru(h,a)))&&(h=a,x=r)}a=a.next}while(a!==p);return h}(e,r);if(!a)return r;const l=gu(a,e);return Hh(l,l.next),Hh(a,a.next)}function ru(e,r){return uu(e.prev,e,r.prev)<0&&uu(r.next,e,e.next)<0}function su(e,r,a,l,c){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-a)*c|0)|e<<8))|e<<4))|e<<2))|e<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-l)*c|0)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function au(e){let r=e,a=e;do{(r.x=(e-u)*(h-p)&&(e-u)*(l-p)>=(a-u)*(r-p)&&(a-u)*(h-p)>=(c-u)*(l-p)}function cu(e,r,a,l,c,h,u,p){return!(e===u&&r===p)&&lu(e,r,a,l,c,h,u,p)}function hu(e,r){return e.next.i!==r.i&&e.prev.i!==r.i&&!function(e,r){let a=e;do{if(a.i!==e.i&&a.next.i!==e.i&&a.i!==r.i&&a.next.i!==r.i&&pu(a,a.next,e,r))return!0;a=a.next}while(a!==e);return!1}(e,r)&&(_u(e,r)&&_u(r,e)&&function(e,r){let a=e,l=!1;const c=(e.x+r.x)/2,h=(e.y+r.y)/2;do{a.y>h!=a.next.y>h&&a.next.y!==a.y&&c<(a.next.x-a.x)*(h-a.y)/(a.next.y-a.y)+a.x&&(l=!l),a=a.next}while(a!==e);return l}(e,r)&&(uu(e.prev,e,r.prev)||uu(e,r.prev,r))||du(e,r)&&uu(e.prev,e,e.next)>0&&uu(r.prev,r,r.next)>0)}function uu(e,r,a){return(r.y-e.y)*(a.x-r.x)-(r.x-e.x)*(a.y-r.y)}function du(e,r){return e.x===r.x&&e.y===r.y}function pu(e,r,a,l){const c=mu(uu(e,r,a)),h=mu(uu(e,r,l)),u=mu(uu(a,l,e)),p=mu(uu(a,l,r));return c!==h&&u!==p||!(0!==c||!fu(e,a,r))||!(0!==h||!fu(e,l,r))||!(0!==u||!fu(a,e,l))||!(0!==p||!fu(a,r,l))}function fu(e,r,a){return r.x<=Math.max(e.x,a.x)&&r.x>=Math.min(e.x,a.x)&&r.y<=Math.max(e.y,a.y)&&r.y>=Math.min(e.y,a.y)}function mu(e){return e>0?1:e<0?-1:0}function _u(e,r){return uu(e.prev,e,e.next)<0?uu(e,r,e.next)>=0&&uu(e,e.prev,r)>=0:uu(e,r,e.prev)<0||uu(e,e.next,r)<0}function gu(e,r){const a=vu(e.i,e.x,e.y),l=vu(r.i,r.x,r.y),c=e.next,h=r.prev;return e.next=r,r.prev=e,a.next=c,c.prev=a,l.next=a,a.prev=l,h.next=l,l.prev=h,l}function yu(e,r,a,l){const c=vu(e,r,a);return l?(c.next=l.next,c.prev=l,l.next.prev=c,l.next=c):(c.prev=c,c.next=c),c}function xu(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 vu(e,r,a){return{i:e,x:r,y:a,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Zl{constructor(e,r){if(r>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=r}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||r>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const a=0|Math.round(e),l=0|Math.round(r),c=this._getKey(a,l);if(this._vertexDictionary.has(c))return this._vertexDictionary.get(c);const h=this._vertexBuffer.length/2;return this._vertexDictionary.set(c,h),this._vertexBuffer.push(a,l),h}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,r){const a=[];for(let l=0;l0?(a.push(c),a.push(u),a.push(h)):(a.push(c),a.push(h),a.push(u))}return a}(this._vertexBuffer,e);const r=[],a=e.length;for(let l=0;l=1||L<=0)||A&&(pc)){y>=l&&y<=c&&h.push(a[(e+1)%3]);continue}!A&&D>0&&h.push(this._vertexToIndex(u+w*D,p+M*D));const B=u+w*Math.max(D,0),O=u+w*Math.min(L,1);C||this._generateIntraEdgeVertices(h,u,p,g,y,B,O),!A&&L<1&&h.push(this._vertexToIndex(u+w*L,p+M*L)),(A||y>=l&&y<=c)&&h.push(a[(e+1)%3]),!A&&(y<=l||y>=c)&&this._generateInterEdgeVertices(h,u,p,g,y,x,v,O,l,c)}return h}_generateIntraEdgeVertices(e,r,a,l,c,h,u){const p=l-r,g=c-a,y=0===g,x=y?Math.min(r,l):Math.min(h,u),v=y?Math.max(r,l):Math.max(h,u),w=Math.floor(x/this._granularityCellSize)+1,M=Math.ceil(v/this._granularityCellSize)-1;if(y?r=w;l--){const c=l*this._granularityCellSize;e.push(this._vertexToIndex(c,a+g*(c-r)/p))}}_generateInterEdgeVertices(e,r,a,l,c,h,u,p,g,y){const x=c-a,v=h-l,w=u-c,M=(g-c)/w,C=(y-c)/w,A=Math.min(M,C),k=Math.max(M,C),R=l+v*A;let D=Math.floor(Math.min(R,p)/this._granularityCellSize)+1,L=Math.ceil(Math.max(R,p)/this._granularityCellSize)-1,B=p=1||k<=0){const e=a-u,l=h+(r-h)*Math.min((g-u)/e,(y-u)/e);D=Math.floor(Math.min(l,p)/this._granularityCellSize)+1,L=Math.ceil(Math.max(l,p)/this._granularityCellSize)-1,B=p0?y:g;if(B)for(let r=D;r<=L;r++)e.push(this._vertexToIndex(r*this._granularityCellSize,j));else for(let r=L;r>=D;r--)e.push(this._vertexToIndex(r*this._granularityCellSize,j))}_generateOutline(e){const r=[];for(const a of e){const e=Pu(a,this._granularity,!0),l=this._pointArrayToIndices(e),c=[];for(let e=1;ec!=(h===bu)?(e.push(r),e.push(a),e.push(this._vertexToIndex(l,h)),e.push(a),e.push(this._vertexToIndex(c,h)),e.push(this._vertexToIndex(l,h))):(e.push(a),e.push(r),e.push(this._vertexToIndex(l,h)),e.push(this._vertexToIndex(c,h)),e.push(a),e.push(this._vertexToIndex(l,h)))}_fillPoles(e,r,a){const l=this._vertexBuffer,c=ot,h=e.length;for(let u=2;u80*a){p=1/0,g=1/0;let r=-1/0,l=-1/0;for(let h=a;hr&&(r=a),c>l&&(l=c)}y=Math.max(r-p,l-g),y=0!==y?32767/y:0}return Xh(h,u,a,p,g,y,0),u}(a,l),r=this._convertIndices(a,e);c=this._subdivideTrianglesScanline(r)}catch(e){console.error(e)}let h=[];return r&&(h=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(c),{verticesFlattened:this._vertexBuffer,indicesTriangles:c,indicesLineList:h}}_convertIndices(e,r){const a=[];for(let l=0;l0?(Math.floor(D/u)+1)*u:(Math.ceil(D/u)-1)*u,r=A>0?(Math.floor(L/u)+1)*u:(Math.ceil(L/u)-1)*u,a=Math.abs(D-e),l=Math.abs(L-r),c=Math.abs(D-x),h=Math.abs(L-v),g=w?a/k:Number.POSITIVE_INFINITY,B=M?l/R:Number.POSITIVE_INFINITY;if((c<=a||!w)&&(h<=l||!M))break;if(g=0?u-1:h-1,c=(p+1)%h,g=e[2*r[l]],y=e[2*r[c]],x=e[2*r[u]],v=e[2*r[u]+1],w=e[2*r[p]+1];let M=!1;if(gy)M=!1;else{const a=w-v,h=-(e[2*r[p]]-x),u=v((y-x)*a+(e[2*r[c]+1]-v)*h)*u&&(M=!0)}if(M){const e=r[l],c=r[u],g=r[p];e!==c&&e!==g&&c!==g&&a.push(g,c,e),u--,u<0&&(u=h-1)}else{const e=r[c],l=r[u],g=r[p];e!==l&&e!==g&&l!==g&&a.push(g,l,e),p++,p>=h&&(p=0)}if(l===c)break}}function Iu(e,r,a,l,c,h,u,p,g){const y=c.length/2,x=u&&p&&g;if(yHa.MAX_VERTEX_ARRAY_LENGTH&&(y=e.createNewSegment(r,a),g=p.count,A=!0,k=!0,R=!0,x=0);const D=Cu(u,l,h,p,w,A,y),L=Cu(u,l,h,p,M,k,y),B=Cu(u,l,h,p,C,R,y);a.emplaceBack(x+D-g,x+L-g,x+B-g),y.primitiveLength++}}(r,a,l,c,h,e),x&&function(e,r,a,l,c,h){const u=[];for(let e=0;eHa.MAX_VERTEX_ARRAY_LENGTH&&(y=e.createNewSegment(r,a),g=p.count,C=!0,A=!0,x=0);const k=Cu(u,l,h,p,c,C,y),R=Cu(u,l,h,p,v,A,y);a.emplaceBack(x+k-g,x+R-g),y.primitiveLength++}}}(u,a,p,c,g,e),r.forceNewSegmentOnNextPrepare(),null==u||u.forceNewSegmentOnNextPrepare()}function Cu(e,r,a,l,c,h,u){if(h){const h=l.count;return a(r[2*c],r[2*c+1]),e[c]=l.count,l.count++,u.vertexLength++,h}return e[c]}class nu{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Fa,this.indexArray=new Ga,this.indexArray2=new Xa,this.programConfigurations=new So(e.layers,e.zoom),this.segments=new Ha,this.segments2=new Ha,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,r,a){this.hasPattern=Gh("fill",this.layers,r);const l=this.layers[0].layout.get("fill-sort-key"),c=!l.isConstant(),h=[];for(const{feature:u,id:p,index:g,sourceLayerIndex:y}of e){const e=this.layers[0]._featureFilter.needGeometry,x=$c(u,e);if(!this.layers[0]._featureFilter.filter(new Cs(this.zoom,{globalState:this.globalState}),x,a))continue;const v=c?l.evaluate(x,{},a,r.availableImages):void 0,w={id:p,properties:u.properties,type:u.type,sourceLayerIndex:y,index:g,geometry:e?x.geometry:Zc(u),patterns:{},sortKey:v};h.push(w)}c&&h.sort(((e,r)=>e.sortKey-r.sortKey));for(const l of h){const{geometry:c,index:h,sourceLayerIndex:u}=l;if(this.hasPattern){const e=qh("fill",this.layers,l,this.zoom,r);this.patternFeatures.push(e)}else this.addFeature(l,c,h,a,{},r.subdivisionGranularity);r.featureIndex.insert(e[h].feature,c,h,u,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,a,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,$h),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,r,a,l,c,h){for(const e of Rn(r,500)){const r=Tu(e,l,h.fill.getGranularityForZoomLevel(l.z)),a=this.layoutVertexArray;Iu(((e,r)=>{a.emplaceBack(e,r)}),this.segments,this.layoutVertexArray,this.indexArray,r.verticesFlattened,r.indicesTriangles,this.segments2,this.indexArray2,r.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,c,l)}}let Au,zu;ql("FillBucket",nu,{omit:["layers","patternFeatures"]});var ku={get paint(){return zu=zu||new qs({"fill-antialias":new Os(Me.paint_fill["fill-antialias"]),"fill-opacity":new Rs(Me.paint_fill["fill-opacity"]),"fill-color":new Rs(Me.paint_fill["fill-color"]),"fill-outline-color":new Rs(Me.paint_fill["fill-outline-color"]),"fill-translate":new Os(Me.paint_fill["fill-translate"]),"fill-translate-anchor":new Os(Me.paint_fill["fill-translate-anchor"]),"fill-pattern":new js(Me.paint_fill["fill-pattern"])})},get layout(){return Au=Au||new qs({"fill-sort-key":new Rs(Me.layout_fill["fill-sort-key"])})}};class ou extends Xs{constructor(e){super(e,ku)}recalculate(e,r){super.recalculate(e,r);const a=this.paint._values["fill-outline-color"];"constant"===a.value.kind&&void 0===a.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new nu(e)}queryRadius(){return mh(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:r,transform:a,pixelsToTileUnits:l}){return Yc(_h(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-a.bearingInRadians,l),r)}isTileClipped(){return!0}}const Ru=yc([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Du=yc([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Lu}=Ru;var Fu,Bu,Ou,ju,Vu,Uu,Zu,$u={};function Gu(){if(Bu)return Fu;Bu=1;var r=u();function a(r,a,c,h,u){(this||e).properties={},(this||e).extent=c,(this||e).type=0,(this||e)._pbf=r,(this||e)._geometry=-1,(this||e)._keys=h,(this||e)._values=u,r.readFields(l,this||e,a)}function l(e,r,a){1==e?r.id=a.readVarint():2==e?function(e,r){for(var a=e.readVarint()+e.pos;e.pos>3}if(u--,1===h||2===h)p+=a.readSVarint(),g+=a.readSVarint(),1===h&&(l&&y.push(l),l=[]),l.push(new r(p,g));else{if(7!==h)throw new Error("unknown command "+h);l&&l.push(l[0].clone())}}return l&&y.push(l),y},a.prototype.bbox=function(){var r=(this||e)._pbf;r.pos=(this||e)._geometry;for(var a=r.readVarint()+r.pos,l=1,c=0,h=0,u=0,p=1/0,g=-1/0,y=1/0,x=-1/0;r.pos>3}if(c--,1===l||2===l)(h+=r.readSVarint())g&&(g=h),(u+=r.readSVarint())x&&(x=u);else if(7!==l)throw new Error("unknown command "+l)}return[p,y,g,x]},a.prototype.toGeoJSON=function(r,l,h){var u,p,g=(this||e).extent*Math.pow(2,h),y=(this||e).extent*r,x=(this||e).extent*l,v=this.loadGeometry(),w=a.types[(this||e).type];function M(e){for(var r=0;r>3;r=1===l?e.readString():2===l?e.readFloat():3===l?e.readDouble():4===l?e.readVarint64():5===l?e.readVarint():6===l?e.readSVarint():7===l?e.readBoolean():null}return r}(a))}return Ou=a,a.prototype.feature=function(a){if(a<0||a>=(this||e)._features.length)throw new Error("feature index out of bounds");(this||e)._pbf.pos=(this||e)._features[a];var l=(this||e)._pbf.readVarint()+(this||e)._pbf.pos;return new r((this||e)._pbf,l,(this||e).extent,(this||e)._keys,(this||e)._values)},Ou}function Wu(){return Zu||(Zu=1,$u.VectorTile=function(){if(Uu)return Vu;Uu=1;var r=qu();function a(e,a,l){if(3===e){var c=new r(l,l.readVarint()+l.pos);c.length&&(a[c.name]=c)}}return Vu=function(r,l){(this||e).layers=r.readFields(a,{},l)},Vu}(),$u.VectorTileFeature=Gu(),$u.VectorTileLayer=qu()),$u}var Hu=l(Wu());const Ku=Hu.VectorTileFeature.types,Ju=Math.pow(2,13);function Qu(e,r,a,l,c,h,u,p){e.emplaceBack(r,a,2*Math.floor(l*Ju)+u,c*Ju*2,h*Ju*2,Math.round(p))}class Mu{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new La,this.centroidVertexArray=new Ta,this.indexArray=new Ga,this.programConfigurations=new So(e.layers,e.zoom),this.segments=new Ha,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,r,a){this.features=[],this.hasPattern=Gh("fill-extrusion",this.layers,r);for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,p=$c(l,e);if(!this.layers[0]._featureFilter.filter(new Cs(this.zoom,{globalState:this.globalState}),p,a))continue;const g={id:c,sourceLayerIndex:u,index:h,geometry:e?p.geometry:Zc(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(qh("fill-extrusion",this.layers,g,this.zoom,r)):this.addFeature(g,g.geometry,h,a,{},r.subdivisionGranularity),r.featureIndex.insert(l,g.geometry,h,u,this.index,!0)}}addFeatures(e,r,a){for(const l of this.features){const{geometry:c}=l;this.addFeature(l,c,l.index,r,a,e.subdivisionGranularity)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}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,Lu),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Du.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,r,a,l,c,h){for(const a of Rn(r,500)){const r={x:0,y:0,sampleCount:0},c=this.layoutVertexArray.length;this.processPolygon(r,l,e,a,h);const u=this.layoutVertexArray.length-c,p=Math.floor(r.x/r.sampleCount),g=Math.floor(r.y/r.sampleCount);for(let e=0;e{Qu(y,e,r,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,g.verticesFlattened,g.indicesTriangles)}_generateSideFaces(e,r){let a=0;for(let l=1;lHa.MAX_VERTEX_ARRAY_LENGTH&&(r.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const u=c.sub(h)._perp()._unit(),p=h.dist(c);a+p>32768&&(a=0),Qu(this.layoutVertexArray,c.x,c.y,u.x,u.y,0,0,a),Qu(this.layoutVertexArray,c.x,c.y,u.x,u.y,0,1,a),a+=p,Qu(this.layoutVertexArray,h.x,h.y,u.x,u.y,0,0,a),Qu(this.layoutVertexArray,h.x,h.y,u.x,u.y,0,1,a);const g=r.segment.vertexLength;this.indexArray.emplaceBack(g,g+2,g+1),this.indexArray.emplaceBack(g+1,g+2,g+3),r.segment.vertexLength+=4,r.segment.primitiveLength+=2}}}function td(e,r){for(let a=0;aot)||e.y===r.y&&(e.y<0||e.y>ot)}function id(e){return e.every((e=>e.x<0))||e.every((e=>e.x>ot))||e.every((e=>e.y<0))||e.every((e=>e.y>ot))}let rd;ql("FillExtrusionBucket",Mu,{omit:["layers","features"]});var nd={get paint(){return rd=rd||new qs({"fill-extrusion-opacity":new Os(Me["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Rs(Me["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Os(Me["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Os(Me["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new js(Me["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Rs(Me["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Rs(Me["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Os(Me["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Eu extends Xs{constructor(e){super(e,nd)}createBucket(e){return new Mu(e)}queryRadius(){return mh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:a,geometry:l,transform:c,pixelsToTileUnits:h,pixelPosMatrix:u}){const p=_h(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-c.bearingInRadians,h),g=this.paint.get("fill-extrusion-height").evaluate(r,a),x=this.paint.get("fill-extrusion-base").evaluate(r,a),v=function(e,r){const a=[];for(const l of e){const e=[l.x,l.y,0,1];et(e,e,r),a.push(new y(e[0]/e[3],e[1]/e[3]))}return a}(p,u),w=function(e,r,a,l){const c=[],h=[],u=l[8]*r,p=l[9]*r,g=l[10]*r,x=l[11]*r,v=l[8]*a,w=l[9]*a,M=l[10]*a,C=l[11]*a;for(const r of e){const e=[],a=[];for(const c of r){const r=c.x,h=c.y,A=l[0]*r+l[4]*h+l[12],k=l[1]*r+l[5]*h+l[13],R=l[2]*r+l[6]*h+l[14],D=l[3]*r+l[7]*h+l[15],L=R+g,B=D+x,O=A+v,j=k+w,N=R+M,U=D+C,Z=new y((A+u)/B,(k+p)/B);Z.z=L/B,e.push(Z);const J=new y(O/U,j/U);J.z=N/U,a.push(J)}c.push(e),h.push(a)}return[c,h]}(l,x,g,u);return function(e,r,a){let l=1/0;Yc(a,r)&&(l=od(a,r[0]));for(let c=0;ce.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new $a,this.layoutVertexArray2=new Da,this.indexArray=new Ga,this.programConfigurations=new So(e.layers,e.zoom),this.segments=new Ha,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,r,a){this.hasPattern=Gh("line",this.layers,r);const l=this.layers[0].layout.get("line-sort-key"),c=!l.isConstant(),h=[];for(const{feature:r,id:u,index:p,sourceLayerIndex:g}of e){const e=this.layers[0]._featureFilter.needGeometry,y=$c(r,e);if(!this.layers[0]._featureFilter.filter(new Cs(this.zoom,{globalState:this.globalState}),y,a))continue;const x=c?l.evaluate(y,{},a):void 0,v={id:u,properties:r.properties,type:r.type,sourceLayerIndex:g,index:p,geometry:e?y.geometry:Zc(r),patterns:{},sortKey:x};h.push(v)}c&&h.sort(((e,r)=>e.sortKey-r.sortKey));for(const l of h){const{geometry:c,index:h,sourceLayerIndex:u}=l;if(this.hasPattern){const e=qh("line",this.layers,l,this.zoom,r);this.patternFeatures.push(e)}else this.addFeature(l,c,h,a,{},r.subdivisionGranularity);r.featureIndex.insert(e[h].feature,c,h,u,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,a,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,hd)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ld),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,r,a,l,c,h){const u=this.layers[0].layout,p=u.get("line-join").evaluate(e,{}),g=u.get("line-cap"),y=u.get("line-miter-limit"),x=u.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const a of r)this.addLine(a,e,p,g,y,x,l,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,c,l)}addLine(e,r,a,l,c,h,u,p){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Pu(e,u?p.line.getGranularityForZoomLevel(u.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let r=0;r=2&&e[y-1].equals(e[y-2]);)y--;let x=0;for(;x0;if(O&&r>x){const e=M.dist(C);if(e>2*v){const r=M.sub(M.sub(C)._mult(v/e)._round());this.updateDistance(C,r),this.addCurrentVertex(r,k,0,0,w),C=r}}const N=C&&A;let U=N?a:g?"butt":l;if(N&&"round"===U&&(Lc&&(U="bevel"),"bevel"===U&&(L>2&&(U="flipbevel"),L100)u=R.mult(-1);else{const e=L*k.add(R).mag()/k.sub(R).mag();u._perp()._mult(e*(j?-1:1))}this.addCurrentVertex(M,u,0,0,w),this.addCurrentVertex(M,u.mult(-1),0,0,w)}else if("bevel"===U||"fakeround"===U){const e=-Math.sqrt(L*L-1),r=j?e:0,a=j?0:e;if(C&&this.addCurrentVertex(M,k,r,a,w),"fakeround"===U){const e=Math.round(180*B/Math.PI/20);for(let r=1;r2*v){const r=M.add(A.sub(M)._mult(v/e)._round());this.updateDistance(M,r),this.addCurrentVertex(r,R,0,0,w),M=r}}}}addCurrentVertex(e,r,a,l,c,h=!1){const u=r.y*l-r.x,p=-r.y-r.x*l;this.addHalfVertex(e,r.x+r.y*a,r.y-r.x*a,h,!1,a,c),this.addHalfVertex(e,u,p,h,!0,-l,c),this.distance>pd/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,r,a,l,c,h))}addHalfVertex({x:e,y:r},a,l,c,h,u,p){const g=.5*(this.lineClips?this.scaledDistance*(pd-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(c?1:0),(r<<1)+(h?1:0),Math.round(63*a)+128,Math.round(63*l)+128,1+(0===u?0:u<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=p.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,y,this.e2),p.primitiveLength++),h?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,r){this.distance+=e.dist(r),this.updateScaledDistance()}}let fd,md;ql("LineBucket",Nu,{omit:["layers","patternFeatures"]});var _d={get paint(){return md=md||new qs({"line-opacity":new Rs(Me.paint_line["line-opacity"]),"line-color":new Rs(Me.paint_line["line-color"]),"line-translate":new Os(Me.paint_line["line-translate"]),"line-translate-anchor":new Os(Me.paint_line["line-translate-anchor"]),"line-width":new Rs(Me.paint_line["line-width"]),"line-gap-width":new Rs(Me.paint_line["line-gap-width"]),"line-offset":new Rs(Me.paint_line["line-offset"]),"line-blur":new Rs(Me.paint_line["line-blur"]),"line-dasharray":new Ns(Me.paint_line["line-dasharray"]),"line-pattern":new js(Me.paint_line["line-pattern"]),"line-gradient":new Us(Me.paint_line["line-gradient"])})},get layout(){return fd=fd||new qs({"line-cap":new Os(Me.layout_line["line-cap"]),"line-join":new Rs(Me.layout_line["line-join"]),"line-miter-limit":new Os(Me.layout_line["line-miter-limit"]),"line-round-limit":new Os(Me.layout_line["line-round-limit"]),"line-sort-key":new Rs(Me.layout_line["line-sort-key"])})}};class Xu extends Rs{possiblyEvaluate(e,r){return r=new Cs(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(e,r)}evaluate(e,r,a,l){return r=Ct({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(e,r,a,l)}}let gd;class Yu extends Xs{constructor(e){super(e,_d),this.gradientVersion=0,gd||(gd=new Xu(_d.paint.properties["line-width"].specification),gd.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 ur,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,r){super.recalculate(e,r),this.paint._values["line-floorwidth"]=gd.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Nu(e)}queryRadius(e){const r=e,a=yd(ph("line-width",this,r),ph("line-gap-width",this,r)),l=ph("line-offset",this,r);return a/2+Math.abs(l)+mh(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:a,geometry:l,transform:c,pixelsToTileUnits:h}){const u=_h(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-c.bearingInRadians,h),p=h/2*yd(this.paint.get("line-width").evaluate(r,a),this.paint.get("line-gap-width").evaluate(r,a)),g=this.paint.get("line-offset").evaluate(r,a);return g&&(l=function(e,r){const a=[];for(let l=0;l=3)for(let r=0;r0?r+2*e:e}const xd=yc([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),vd=yc([{name:"a_projected_pos",components:3,type:"Float32"}],4);yc([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const bd=yc([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);yc([{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 wd=yc([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Td=yc([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Pd(e,r,a){return e.sections.forEach((e=>{e.text=function(e,r,a){const l=r.layout.get("text-transform").evaluate(a,{});return"uppercase"===l?e=e.toLocaleUpperCase():"lowercase"===l&&(e=e.toLocaleLowerCase()),pc.applyArabicShaping&&(e=pc.applyArabicShaping(e)),e}(e.text,r,a)})),e}yc([{name:"triangle",components:3,type:"Uint16"}]),yc([{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"}]),yc([{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"}]),yc([{type:"Float32",name:"offsetX"}]),yc([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),yc([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Sd={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Md,Id,Cd,Ed=24,Ad={};function zd(){return Md||(Md=1,Ad.read=function(e,r,a,l,c){var h,u,p=8*c-l-1,g=(1<>1,x=-7,v=a?c-1:0,w=a?-1:1,M=e[r+v];for(v+=w,h=M&(1<<-x)-1,M>>=-x,x+=p;x>0;h=256*h+e[r+v],v+=w,x-=8);for(u=h&(1<<-x)-1,h>>=-x,x+=l;x>0;u=256*u+e[r+v],v+=w,x-=8);if(0===h)h=1-y;else{if(h===g)return u?NaN:1/0*(M?-1:1);u+=Math.pow(2,l),h-=y}return(M?-1:1)*u*Math.pow(2,h-l)},Ad.write=function(e,r,a,l,c,h){var u,p,g,y=8*h-c-1,x=(1<>1,w=23===c?Math.pow(2,-24)-Math.pow(2,-77):0,M=l?0:h-1,C=l?1:-1,A=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(p=isNaN(r)?1:0,u=x):(u=Math.floor(Math.log(r)/Math.LN2),r*(g=Math.pow(2,-u))<1&&(u--,g*=2),(r+=u+v>=1?w/g:w*Math.pow(2,1-v))*g>=2&&(u++,g/=2),u+v>=x?(p=0,u=x):u+v>=1?(p=(r*g-1)*Math.pow(2,c),u+=v):(p=r*Math.pow(2,v-1)*Math.pow(2,c),u=0));c>=8;e[a+M]=255&p,M+=C,p/=256,c-=8);for(u=u<0;e[a+M]=255&u,M+=C,u/=256,y-=8);e[a+M-C]|=128*A}),Ad}function kd(){if(Cd)return Id;Cd=1,Id=a;var r=zd();function a(r){(this||e).buf=ArrayBuffer.isView&&ArrayBuffer.isView(r)?r:new Uint8Array(r||0),(this||e).pos=0,(this||e).type=0,(this||e).length=(this||e).buf.length}a.Varint=0,a.Fixed64=1,a.Bytes=2,a.Fixed32=5;var l=4294967296,c=1/l,h="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function u(e){return e.type===a.Bytes?e.readVarint()+e.pos:e.pos+1}function p(e,r,a){return a?4294967296*r+(e>>>0):4294967296*(r>>>0)+(e>>>0)}function g(e,r,a){var l=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));a.realloc(l);for(var c=a.pos-1;c>=e;c--)a.buf[c+l]=a.buf[c]}function y(e,r){for(var a=0;a>>8,e[a+2]=r>>>16,e[a+3]=r>>>24}function B(e,r){return(e[r]|e[r+1]<<8|e[r+2]<<16)+(e[r+3]<<24)}return a.prototype={destroy:function(){(this||e).buf=null},readFields:function(r,a,l){for(l=l||(this||e).length;(this||e).pos>3,u=(this||e).pos;(this||e).type=7&c,r(h,a,this||e),(this||e).pos===u&&this.skip(c)}return a},readMessage:function(r,a){return this.readFields(r,a,this.readVarint()+(this||e).pos)},readFixed32:function(){var r=D((this||e).buf,(this||e).pos);return(this||e).pos+=4,r},readSFixed32:function(){var r=B((this||e).buf,(this||e).pos);return(this||e).pos+=4,r},readFixed64:function(){var r=D((this||e).buf,(this||e).pos)+D((this||e).buf,(this||e).pos+4)*l;return(this||e).pos+=8,r},readSFixed64:function(){var r=D((this||e).buf,(this||e).pos)+B((this||e).buf,(this||e).pos+4)*l;return(this||e).pos+=8,r},readFloat:function(){var a=r.read((this||e).buf,(this||e).pos,!0,23,4);return(this||e).pos+=4,a},readDouble:function(){var a=r.read((this||e).buf,(this||e).pos,!0,52,8);return(this||e).pos+=8,a},readVarint:function(r){var a,l,c=(this||e).buf;return a=127&(l=c[(this||e).pos++]),l<128?a:(a|=(127&(l=c[(this||e).pos++]))<<7,l<128?a:(a|=(127&(l=c[(this||e).pos++]))<<14,l<128?a:(a|=(127&(l=c[(this||e).pos++]))<<21,l<128?a:function(e,r,a){var l,c,h=a.buf;if(l=(112&(c=h[a.pos++]))>>4,c<128)return p(e,l,r);if(l|=(127&(c=h[a.pos++]))<<3,c<128)return p(e,l,r);if(l|=(127&(c=h[a.pos++]))<<10,c<128)return p(e,l,r);if(l|=(127&(c=h[a.pos++]))<<17,c<128)return p(e,l,r);if(l|=(127&(c=h[a.pos++]))<<24,c<128)return p(e,l,r);if(l|=(1&(c=h[a.pos++]))<<31,c<128)return p(e,l,r);throw new Error("Expected varint not more than 10 bytes")}(a|=(15&(l=c[(this||e).pos]))<<28,r,this||e))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var r=this.readVarint()+(this||e).pos,a=(this||e).pos;return(this||e).pos=r,r-a>=12&&h?function(e,r,a){return h.decode(e.subarray(r,a))}((this||e).buf,a,r):function(e,r,a){for(var l="",c=r;c239?4:g>223?3:g>191?2:1;if(c+x>a)break;1===x?g<128&&(y=g):2===x?128==(192&(h=e[c+1]))&&(y=(31&g)<<6|63&h)<=127&&(y=null):3===x?(u=e[c+2],128==(192&(h=e[c+1]))&&128==(192&u)&&((y=(15&g)<<12|(63&h)<<6|63&u)<=2047||y>=55296&&y<=57343)&&(y=null)):4===x&&(u=e[c+2],p=e[c+3],128==(192&(h=e[c+1]))&&128==(192&u)&&128==(192&p)&&((y=(15&g)<<18|(63&h)<<12|(63&u)<<6|63&p)<=65535||y>=1114112)&&(y=null)),null===y?(y=65533,x=1):y>65535&&(y-=65536,l+=String.fromCharCode(y>>>10&1023|55296),y=56320|1023&y),l+=String.fromCharCode(y),c+=x}return l}((this||e).buf,a,r)},readBytes:function(){var r=this.readVarint()+(this||e).pos,a=(this||e).buf.subarray((this||e).pos,r);return(this||e).pos=r,a},readPackedVarint:function(r,l){if((this||e).type!==a.Bytes)return r.push(this.readVarint(l));var c=u(this||e);for(r=r||[];(this||e).pos127;);else if(l===a.Bytes)(this||e).pos=this.readVarint()+(this||e).pos;else if(l===a.Fixed32)(this||e).pos+=4;else{if(l!==a.Fixed64)throw new Error("Unimplemented type: "+l);(this||e).pos+=8}},writeTag:function(e,r){this.writeVarint(e<<3|r)},realloc:function(r){for(var a=(this||e).length||16;a<(this||e).pos+r;)a*=2;if(a!==(this||e).length){var l=new Uint8Array(a);l.set((this||e).buf),(this||e).buf=l,(this||e).length=a}},finish:function(){return(this||e).length=(this||e).pos,(this||e).pos=0,(this||e).buf.subarray(0,(this||e).length)},writeFixed32:function(r){this.realloc(4),L((this||e).buf,r,(this||e).pos),(this||e).pos+=4},writeSFixed32:function(r){this.realloc(4),L((this||e).buf,r,(this||e).pos),(this||e).pos+=4},writeFixed64:function(r){this.realloc(8),L((this||e).buf,-1&r,(this||e).pos),L((this||e).buf,Math.floor(r*c),(this||e).pos+4),(this||e).pos+=8},writeSFixed64:function(r){this.realloc(8),L((this||e).buf,-1&r,(this||e).pos),L((this||e).buf,Math.floor(r*c),(this||e).pos+4),(this||e).pos+=8},writeVarint:function(r){(r=+r||0)>268435455||r<0?function(e,r){var a,l;if(e>=0?(a=e%4294967296|0,l=e/4294967296|0):(l=~(-e/4294967296),4294967295^(a=~(-e%4294967296))?a=a+1|0:(a=0,l=l+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(e,r,a){a.buf[a.pos++]=127&e|128,e>>>=7,a.buf[a.pos++]=127&e|128,e>>>=7,a.buf[a.pos++]=127&e|128,e>>>=7,a.buf[a.pos++]=127&e|128,a.buf[a.pos]=127&(e>>>=7)}(a,0,r),function(e,r){var a=(7&e)<<4;r.buf[r.pos++]|=a|((e>>>=3)?128:0),e&&(r.buf[r.pos++]=127&e|((e>>>=7)?128:0),e&&(r.buf[r.pos++]=127&e|((e>>>=7)?128:0),e&&(r.buf[r.pos++]=127&e|((e>>>=7)?128:0),e&&(r.buf[r.pos++]=127&e|((e>>>=7)?128:0),e&&(r.buf[r.pos++]=127&e)))))}(l,r)}(r,this||e):(this.realloc(4),(this||e).buf[(this||e).pos++]=127&r|(r>127?128:0),r<=127||((this||e).buf[(this||e).pos++]=127&(r>>>=7)|(r>127?128:0),r<=127||((this||e).buf[(this||e).pos++]=127&(r>>>=7)|(r>127?128:0),r<=127||((this||e).buf[(this||e).pos++]=r>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(r){r=String(r),this.realloc(4*r.length),(this||e).pos++;var a=(this||e).pos;(this||e).pos=function(e,r,a){for(var l,c,h=0;h55295&&l<57344){if(!c){l>56319||h+1===r.length?(e[a++]=239,e[a++]=191,e[a++]=189):c=l;continue}if(l<56320){e[a++]=239,e[a++]=191,e[a++]=189,c=l;continue}l=c-55296<<10|l-56320|65536,c=null}else c&&(e[a++]=239,e[a++]=191,e[a++]=189,c=null);l<128?e[a++]=l:(l<2048?e[a++]=l>>6|192:(l<65536?e[a++]=l>>12|224:(e[a++]=l>>18|240,e[a++]=l>>12&63|128),e[a++]=l>>6&63|128),e[a++]=63&l|128)}return a}((this||e).buf,r,(this||e).pos);var l=(this||e).pos-a;l>=128&&g(a,l,this||e),(this||e).pos=a-1,this.writeVarint(l),(this||e).pos+=l},writeFloat:function(a){this.realloc(4),r.write((this||e).buf,a,(this||e).pos,!0,23,4),(this||e).pos+=4},writeDouble:function(a){this.realloc(8),r.write((this||e).buf,a,(this||e).pos,!0,52,8),(this||e).pos+=8},writeBytes:function(r){var a=r.length;this.writeVarint(a),this.realloc(a);for(var l=0;l=128&&g(l,c,this||e),(this||e).pos=l-1,this.writeVarint(c),(this||e).pos+=c},writeMessage:function(e,r,l){this.writeTag(e,a.Bytes),this.writeRawMessage(r,l)},writePackedVarint:function(e,r){r.length&&this.writeMessage(e,y,r)},writePackedSVarint:function(e,r){r.length&&this.writeMessage(e,x,r)},writePackedBoolean:function(e,r){r.length&&this.writeMessage(e,M,r)},writePackedFloat:function(e,r){r.length&&this.writeMessage(e,v,r)},writePackedDouble:function(e,r){r.length&&this.writeMessage(e,w,r)},writePackedFixed32:function(e,r){r.length&&this.writeMessage(e,C,r)},writePackedSFixed32:function(e,r){r.length&&this.writeMessage(e,A,r)},writePackedFixed64:function(e,r){r.length&&this.writeMessage(e,k,r)},writePackedSFixed64:function(e,r){r.length&&this.writeMessage(e,R,r)},writeBytesField:function(e,r){this.writeTag(e,a.Bytes),this.writeBytes(r)},writeFixed32Field:function(e,r){this.writeTag(e,a.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(e,r){this.writeTag(e,a.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(e,r){this.writeTag(e,a.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(e,r){this.writeTag(e,a.Fixed64),this.writeSFixed64(r)},writeVarintField:function(e,r){this.writeTag(e,a.Varint),this.writeVarint(r)},writeSVarintField:function(e,r){this.writeTag(e,a.Varint),this.writeSVarint(r)},writeStringField:function(e,r){this.writeTag(e,a.Bytes),this.writeString(r)},writeFloatField:function(e,r){this.writeTag(e,a.Fixed32),this.writeFloat(r)},writeDoubleField:function(e,r){this.writeTag(e,a.Fixed64),this.writeDouble(r)},writeBooleanField:function(e,r){this.writeVarintField(e,Boolean(r))}},Id}var Rd,Dd=l(kd());function Ld(e,r,a){1===e&&a.readMessage(Fd,r)}function Fd(e,r,a){if(3===e){const{id:e,bitmap:l,width:c,height:h,left:u,top:p,advance:g}=a.readMessage(Bd,{});r.push({id:e,bitmap:new il({width:c+6,height:h+6},l),metrics:{width:c,height:h,left:u,top:p,advance:g}})}}function Bd(e,r,a){1===e?r.id=a.readVarint():2===e?r.bitmap=a.readBytes():3===e?r.width=a.readVarint():4===e?r.height=a.readVarint():5===e?r.left=a.readSVarint():6===e?r.top=a.readSVarint():7===e&&(r.advance=a.readVarint())}function Od(e){let r=0,a=0;for(const l of e)r+=l.w*l.h,a=Math.max(a,l.w);e.sort(((e,r)=>r.h-e.h));const l=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),a),h:1/0}];let c=0,h=0;for(const r of e)for(let e=l.length-1;e>=0;e--){const a=l[e];if(!(r.w>a.w||r.h>a.h)){if(r.x=a.x,r.y=a.y,h=Math.max(h,r.y+r.h),c=Math.max(c,r.x+r.w),r.w===a.w&&r.h===a.h){const r=l.pop();e=0&&a>=e&&Vd[this.text.charCodeAt(a)];a--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const a=new vc;return a.text=this.text.substring(e,r),a.sectionIndex=this.sectionIndex.slice(e,r),a.sections=this.sections,a}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,r)=>Math.max(e,this.sections[r].scale)),0)}getMaxImageSize(e){let r=0,a=0;for(let l=0;l=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function jd(e,a,l,c,h,u,p,g,y,x,v,w,M,C,A){const k=vc.fromFeature(e,h);let R;w===r.an.vertical&&k.verticalizePunctuation();const{processBidirectionalText:D,processStyledBidirectionalText:L}=pc;if(D&&1===k.sections.length){R=[];const e=D(k.toString(),Hd(k,x,u,a,c,C));for(const r of e){const e=new vc;e.text=r,e.sections=k.sections;for(let a=0;a=0;let y=0;for(let a=0;ay){const e=Math.ceil(h/y);c*=e/u,u=e}return{x1:l,y1:c,x2:l+h,y2:c+u}}function np(e,r,a,l,c,h){const u=e.image;let p;if(u.content){const e=u.content,r=u.pixelRatio||1;p=[e[0]/r,e[1]/r,u.displaySize[0]-e[2]/r,u.displaySize[1]-e[3]/r]}const g=r.left*h,y=r.right*h;let x,v,w,M;"width"===a||"both"===a?(M=c[0]+g-l[3],v=c[0]+y+l[1]):(M=c[0]+(g+y-u.displaySize[0])/2,v=M+u.displaySize[0]);const C=r.top*h,A=r.bottom*h;return"height"===a||"both"===a?(x=c[1]+C-l[0],w=c[1]+A+l[2]):(x=c[1]+(C+A-u.displaySize[1])/2,w=x+u.displaySize[1]),{image:u,top:x,right:v,bottom:w,left:M,collisionPadding:p}}const sp=128,op=32640;function ap(e,r){const{expression:a}=r;if("constant"===a.kind)return{kind:"constant",layoutSize:a.evaluate(new Cs(e+1))};if("source"===a.kind)return{kind:"source"};{const{zoomStops:r,interpolationType:l}=a;let c=0;for(;ce.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const a=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ap(this.zoom,a["text-size"]),this.iconSizeData=ap(this.zoom,a["icon-size"]);const l=this.layers[0].layout,c=l.get("symbol-sort-key"),h=l.get("symbol-z-order");this.canOverlap="never"!==cp(l,"text-overlap","text-allow-overlap")||"never"!==cp(l,"icon-overlap","icon-allow-overlap")||l.get("text-ignore-placement")||l.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==h&&!c.isConstant(),this.sortFeaturesByY=("viewport-y"===h||"auto"===h&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===l.get("symbol-placement")&&(this.writingModes=l.get("text-writing-mode").map((e=>r.an[e]))),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Hc(new So(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new Hc(new So(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new Ia,this.lineVertexArray=new za,this.symbolInstances=new Ma,this.textAnchorOffsets=new Ca}calculateGlyphDependencies(e,r,a,l,c){for(let h=0;h0)&&("constant"!==u.value.kind||u.value.value.length>0),x="constant"!==g.value.kind||!!g.value.value||Object.keys(g.parameters).length>0,v=h.get("symbol-sort-key");if(this.features=[],!y&&!x)return;const w=a.iconDependencies,M=a.glyphDependencies,C=a.availableImages,A=new Cs(this.zoom,{globalState:this.globalState});for(const{feature:a,id:p,index:g,sourceLayerIndex:k}of e){const e=c._featureFilter.needGeometry,R=$c(a,e);if(!c._featureFilter.filter(A,R,l))continue;let D,L;if(e||(R.geometry=Zc(a)),y){const e=c.getValueAndResolveTokens("text-field",R,l,C),r=Te.factory(e),a=this.hasRTLText=this.hasRTLText||fp(r);(!a||"unavailable"===pc.getRTLTextPluginStatus()||a&&pc.isParsed())&&(D=Pd(r,c,R))}if(x){const e=c.getValueAndResolveTokens("icon-image",R,l,C);L=e instanceof Re?e:Re.fromString(e)}if(!D&&!L)continue;const B=this.sortFeaturesByKey?v.evaluate(R,{},l):void 0;if(this.features.push({id:p,text:D,icon:L,index:g,sourceLayerIndex:k,geometry:R.geometry,properties:a.properties,type:hp[a.type],sortKey:B}),L&&(w[L.name]=!0),D){const e=u.evaluate(R,{},l).join(","),a="viewport"!==h.get("text-rotation-alignment")&&"point"!==h.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(r.an.vertical)>=0;for(const r of D.sections)if(r.image)w[r.image.name]=!0;else{const l=ec(D.toString()),c=r.fontStack||e,h=M[c]=M[c]||{};this.calculateGlyphDependencies(r.text,h,a,this.allowVerticalPlacement,l)}}}"line"===h.get("symbol-placement")&&(this.features=function(e){const r={},a={},l=[];let c=0;function h(r){l.push(e[r]),c++}function u(e,r,c){const h=a[e];return delete a[e],a[r]=h,l[h].geometry[0].pop(),l[h].geometry[0]=l[h].geometry[0].concat(c[0]),h}function p(e,a,c){const h=r[a];return delete r[a],r[e]=h,l[h].geometry[0].shift(),l[h].geometry[0]=c[0].concat(l[h].geometry[0]),h}function g(e,r,a){const l=a?r[0][r[0].length-1]:r[0][0];return`${e}:${l.x}:${l.y}`}for(let y=0;ye.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,r)=>e.sortKey-r.sortKey))}update(e,r,a){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,a),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,a))}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,r){const a=this.lineVertexArray.length;if(void 0!==e.segment){let a=e.dist(r[e.segment+1]),l=e.dist(r[e.segment]);const c={};for(let l=e.segment+1;l=0;a--)c[a]={x:r[a].x,y:r[a].y,tileUnitDistanceFromAnchor:l},a>0&&(l+=r[a-1].dist(r[a]));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,r){const a=e.placedSymbolArray.get(r),l=a.vertexStartIndex+4*a.numGlyphs;for(let r=a.vertexStartIndex;rl[e]-l[r]||c[r]-c[e])),h}addToSortKeyRanges(e,r){const a=this.sortKeyRanges[this.sortKeyRanges.length-1];a&&a.sortKey===r?a.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,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 r=this.symbolInstances.get(e);this.featureSortOrder.push(r.featureIndex),[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach(((e,r,a)=>{e>=0&&a.indexOf(e)===r&&this.addIndicesForPlacedSymbol(this.text,e)})),r.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,r.verticalPlacedTextSymbolIndex),r.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,r.placedIconSymbolIndex),r.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,r.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let mp,_p;ql("SymbolBucket",Jc,{omit:["layers","collisionBoxArray","features","compareText"]}),Jc.MAX_GLYPHS=65535,Jc.addDynamicAttributes=pp;var gp={get paint(){return _p=_p||new qs({"icon-opacity":new Rs(Me.paint_symbol["icon-opacity"]),"icon-color":new Rs(Me.paint_symbol["icon-color"]),"icon-halo-color":new Rs(Me.paint_symbol["icon-halo-color"]),"icon-halo-width":new Rs(Me.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Rs(Me.paint_symbol["icon-halo-blur"]),"icon-translate":new Os(Me.paint_symbol["icon-translate"]),"icon-translate-anchor":new Os(Me.paint_symbol["icon-translate-anchor"]),"text-opacity":new Rs(Me.paint_symbol["text-opacity"]),"text-color":new Rs(Me.paint_symbol["text-color"],{runtimeType:li,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Rs(Me.paint_symbol["text-halo-color"]),"text-halo-width":new Rs(Me.paint_symbol["text-halo-width"]),"text-halo-blur":new Rs(Me.paint_symbol["text-halo-blur"]),"text-translate":new Os(Me.paint_symbol["text-translate"]),"text-translate-anchor":new Os(Me.paint_symbol["text-translate-anchor"])})},get layout(){return mp=mp||new qs({"symbol-placement":new Os(Me.layout_symbol["symbol-placement"]),"symbol-spacing":new Os(Me.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Os(Me.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Rs(Me.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Os(Me.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Os(Me.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Os(Me.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Os(Me.layout_symbol["icon-ignore-placement"]),"icon-optional":new Os(Me.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Os(Me.layout_symbol["icon-rotation-alignment"]),"icon-size":new Rs(Me.layout_symbol["icon-size"]),"icon-text-fit":new Os(Me.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Os(Me.layout_symbol["icon-text-fit-padding"]),"icon-image":new Rs(Me.layout_symbol["icon-image"]),"icon-rotate":new Rs(Me.layout_symbol["icon-rotate"]),"icon-padding":new Rs(Me.layout_symbol["icon-padding"]),"icon-keep-upright":new Os(Me.layout_symbol["icon-keep-upright"]),"icon-offset":new Rs(Me.layout_symbol["icon-offset"]),"icon-anchor":new Rs(Me.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Os(Me.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Os(Me.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Os(Me.layout_symbol["text-rotation-alignment"]),"text-field":new Rs(Me.layout_symbol["text-field"]),"text-font":new Rs(Me.layout_symbol["text-font"]),"text-size":new Rs(Me.layout_symbol["text-size"]),"text-max-width":new Rs(Me.layout_symbol["text-max-width"]),"text-line-height":new Os(Me.layout_symbol["text-line-height"]),"text-letter-spacing":new Rs(Me.layout_symbol["text-letter-spacing"]),"text-justify":new Rs(Me.layout_symbol["text-justify"]),"text-radial-offset":new Rs(Me.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Os(Me.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Rs(Me.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Rs(Me.layout_symbol["text-anchor"]),"text-max-angle":new Os(Me.layout_symbol["text-max-angle"]),"text-writing-mode":new Os(Me.layout_symbol["text-writing-mode"]),"text-rotate":new Rs(Me.layout_symbol["text-rotate"]),"text-padding":new Os(Me.layout_symbol["text-padding"]),"text-keep-upright":new Os(Me.layout_symbol["text-keep-upright"]),"text-transform":new Rs(Me.layout_symbol["text-transform"]),"text-offset":new Rs(Me.layout_symbol["text-offset"]),"text-allow-overlap":new Os(Me.layout_symbol["text-allow-overlap"]),"text-overlap":new Os(Me.layout_symbol["text-overlap"]),"text-ignore-placement":new Os(Me.layout_symbol["text-ignore-placement"]),"text-optional":new Os(Me.layout_symbol["text-optional"])})}};class eh{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:ei,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.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}}ql("FormatSectionOverride",eh,{omit:["defaultValue"]});class rh extends Xs{constructor(e){super(e,gp)}recalculate(e,r){if(super.recalculate(e,r),"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 r=[];for(const a of e)r.indexOf(a)<0&&r.push(a);this.layout._values["text-writing-mode"]=r}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,a,l){const c=this.layout.get(e).evaluate(r,{},a,l),h=this._unevaluatedLayout._values[e];return h.isDataDriven()||Js(h.value)||!c?c:function(e,r){return r.replace(/{([^{}]+)}/g,((r,a)=>e&&a in e?String(e[a]):""))}(r.properties,c)}createBucket(e){return new Jc(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of gp.paint.overridableProperties){if(!rh.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),a=new eh(r),l=new ni(a,r.property.specification);let c=null;c="constant"===r.value.kind||"source"===r.value.kind?new ai("source",l):new oi("composite",l,r.value.zoomStops),this.paint._values[e]=new $s(r.property,c,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,a){return!(!this.layout||r.isDataDriven()||a.isDataDriven())&&rh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const a=e.get("text-field"),l=gp.paint.properties[r];let c=!1;const h=e=>{for(const r of e)if(l.overrides&&l.overrides.hasOverride(r))return void(c=!0)};if("constant"===a.value.kind&&a.value.value instanceof Te)h(a.value.value.sections);else if("source"===a.value.kind){const e=r=>{c||(r instanceof Xe&&br(r.value)===yi?h(r.value.sections):r instanceof Cr?h(r.sections):r.eachChild(e))},r=a.value;r._styleExpression&&e(r._styleExpression.expression)}return c}}let yp;var xp={get paint(){return yp=yp||new qs({"background-color":new Os(Me.paint_background["background-color"]),"background-pattern":new Ns(Me.paint_background["background-pattern"]),"background-opacity":new Os(Me.paint_background["background-opacity"])})}};class sh extends Xs{constructor(e){super(e,xp)}}let vp;var bp={get paint(){return vp=vp||new qs({"raster-opacity":new Os(Me.paint_raster["raster-opacity"]),"raster-hue-rotate":new Os(Me.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Os(Me.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Os(Me.paint_raster["raster-brightness-max"]),"raster-saturation":new Os(Me.paint_raster["raster-saturation"]),"raster-contrast":new Os(Me.paint_raster["raster-contrast"]),"raster-resampling":new Os(Me.paint_raster["raster-resampling"]),"raster-fade-duration":new Os(Me.paint_raster["raster-fade-duration"])})}};class lh extends Xs{constructor(e){super(e,bp)}}class uh extends Xs{constructor(e){super(e,{}),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 ch{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 wp={once:!0},Tp=6371008.8;class fh{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new fh(St(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,a=this.lat*r,l=e.lat*r,c=Math.sin(a)*Math.sin(l)+Math.cos(a)*Math.cos(l)*Math.cos((e.lng-this.lng)*r);return Tp*Math.acos(Math.min(c,1))}static convert(e){if(e instanceof fh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new fh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new fh(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 Pp=2*Math.PI*Tp;function Sp(e){return Pp*Math.cos(e*Math.PI/180)}function Mp(e){return(180+e)/360}function Ip(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Cp(e,r){return e/Sp(r)}function Ep(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Ap(e,r){return e*Sp(Ep(r))}class wh{constructor(e,r,a=0){this.x=+e,this.y=+r,this.z=+a}static fromLngLat(e,r=0){const a=fh.convert(e);return new wh(Mp(a.lng),Ip(a.lat),Cp(r,a.lat))}toLngLat(){return new fh(360*this.x-180,Ep(this.y))}toAltitude(){return Ap(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Pp*(e=Ep(this.y),1/Math.cos(e*Math.PI/180));var e}}function zp(e,r,a){var l=2*Math.PI*6378137/256/Math.pow(2,a);return[e*l-2*Math.PI*6378137/2,r*l-2*Math.PI*6378137/2]}class Sh{constructor(e,r,a){if(!function(e,r,a){return!(e<0||e>25||a<0||a>=Math.pow(2,e)||r<0||r>=Math.pow(2,e))}(e,r,a))throw new Error(`x=${r}, y=${a}, 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=r,this.y=a,this.key=kp(0,e,e,r,a)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,a){const l=(h=this.y,u=this.z,p=zp(256*(c=this.x),256*(h=Math.pow(2,u)-h-1),u),g=zp(256*(c+1),256*(h+1),u),p[0]+","+p[1]+","+g[0]+","+g[1]);var c,h,u,p,g;const y=function(e,r,a){let l,c="";for(let h=e;h>0;h--)l=1<1?"@2x":"").replace(/{quadkey}/g,y).replace(/{bbox-epsg-3857}/g,l)}isChildOf(e){const r=this.z-e.z;return r>0&&e.x===this.x>>r&&e.y===this.y>>r}getTilePoint(e){const r=Math.pow(2,this.z);return new y((e.x*r-this.x)*ot,(e.y*r-this.y)*ot)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Ah{constructor(e,r){this.wrap=e,this.canonical=r,this.key=kp(e,r.z,r.z,r.x,r.y)}}class kh{constructor(e,r,a,l,c){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${a}`);this.overscaledZ=e,this.wrap=r,this.canonical=new Sh(a,+l,+c),this.key=kp(r,e,a,l,c)}clone(){return new kh(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 r=this.canonical.z-e;return e>this.canonical.z?new kh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new kh(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const a=this.canonical.z-e;return e>this.canonical.z?kp(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):kp(this.wrap*+r,e,e,this.canonical.x>>a,this.canonical.y>>a)}isChildOf(e){if(e.wrap!==this.wrap)return!1;const r=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new kh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,a=2*this.canonical.x,l=2*this.canonical.y;return[new kh(r,this.wrap,r,a,l),new kh(r,this.wrap,r,a+1,l),new kh(r,this.wrap,r,a,l+1),new kh(r,this.wrap,r,a+1,l+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ythis.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 r=new Ih;return r.extend(e(new y(this.minX,this.minY))),r.extend(e(new y(this.maxX,this.minY))),r.extend(e(new y(this.minX,this.maxY))),r.extend(e(new y(this.maxX,this.maxY))),r}static fromPoints(e){const r=new Ih;for(const a of e)r.extend(a);return r}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 zh{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r=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 Ph{constructor(e,r,a,l,c){this.type="Feature",this._vectorTileFeature=e,e._z=r,e._x=a,e._y=l,this.properties=e.properties,this.id=c}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const r in this)"_geometry"!==r&&"_vectorTileFeature"!==r&&(e[r]=this[r]);return e}}class Ch{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new os(ot,16,0),this.grid3D=new os(ot,16,0),this.featureIndexArray=new Ea,this.promoteId=r}insert(e,r,a,l,c,h){const u=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(a,l,c);const p=h?this.grid3D:this.grid;for(let e=0;e=0&&l[3]>=0&&p.insert(u,l[0],l[1],l[2],l[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Hu.VectorTile(new Dd(this.rawTileData)).layers,this.sourceLayerCoder=new zh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,r,a,l){this.loadVTLayers();const c=e.params,h=ot/e.tileSize/e.scale,u=qo(c.filter),p=e.queryGeometry,g=e.queryPadding*h,x=Ih.fromPoints(p),v=this.grid.query(x.minX-g,x.minY-g,x.maxX+g,x.maxY+g),w=Ih.fromPoints(e.cameraQueryGeometry).expandBy(g),M=this.grid3D.query(w.minX,w.minY,w.maxX,w.maxY,((r,a,l,c)=>function(e,r,a,l,c){for(const h of e)if(r<=h.x&&a<=h.y&&l>=h.x&&c>=h.y)return!0;const h=[new y(r,a),new y(r,c),new y(l,c),new y(l,a)];if(e.length>2)for(const r of h)if(hh(e,r))return!0;for(let r=0;r(w||(w=Zc(r)),a.queryIntersectsFeature({queryGeometry:p,feature:r,featureState:l,geometry:w,zoom:this.z,transform:e.transform,pixelsToTileUnits:h,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return C}loadMatchingFeature(e,r,a,l,c,h,u,p,g,y,x){const v=this.bucketLayerIDs[r];if(h&&!v.some((e=>h.has(e))))return;const w=this.sourceLayerCoder.decode(a),M=this.vtLayers[w].feature(l);if(c.needGeometry){const e=$c(M,!0);if(!c.filter(new Cs(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!c.filter(new Cs(this.tileID.overscaledZ),M))return;const C=this.getId(M,w);for(let r=0;r{const u=r instanceof Ds?r.get(h):null;return u&&u.evaluate?u.evaluate(a,l,c):u}))}function Dp(e,r){return r-e}function Lp(e,r,a,l,c){const h=[];for(let u=0;u=l&&x.x>=l||(u.x>=l?u=new y(l,u.y+(l-u.x)/(x.x-u.x)*(x.y-u.y))._round():x.x>=l&&(x=new y(l,u.y+(l-u.x)/(x.x-u.x)*(x.y-u.y))._round()),u.y>=c&&x.y>=c||(u.y>=c?u=new y(u.x+(c-u.y)/(x.y-u.y)*(x.x-u.x),c)._round():x.y>=c&&(x=new y(u.x+(c-u.y)/(x.y-u.y)*(x.x-u.x),c)._round()),g&&u.equals(g[g.length-1])||(g=[u],h.push(g)),g.push(x)))))}}return h}ql("FeatureIndex",Ch,{omit:["rawTileData","sourceLayerCoder"]});class Vh extends y{constructor(e,r,a,l){super(e,r),this.angle=a,void 0!==l&&(this.segment=l)}clone(){return new Vh(this.x,this.y,this.angle,this.segment)}}function Fp(e,r,a,l,c){if(void 0===r.segment||0===a)return!0;let h=r,u=r.segment+1,p=0;for(;p>-a/2;){if(u--,u<0)return!1;p-=e[u].dist(h),h=e[u]}p+=e[u].dist(e[u+1]),u++;const g=[];let y=0;for(;pl;)y-=g.shift().angleDelta;if(y>c)return!1;u++,p+=r.dist(a)}return!0}function Bp(e){let r=0;for(let a=0;ay){const x=(y-g)/h,v=Yr.number(l.x,c.x,x),w=Yr.number(l.y,c.y,x),M=new Vh(v,w,c.angleTo(l),a);return M._round(),!u||Fp(e,M,p,u,r)?M:void 0}g+=h}}function Np(e,r,a,l,c,h,u,p,g){const y=Op(l,h,u),x=jp(l,c),v=x*u,w=0===e[0].x||e[0].x===g||0===e[0].y||e[0].y===g;return r-v=0&&R=0&&D=0&&w+y<=x){const a=new Vh(R,D,A,r);a._round(),l&&!Fp(e,a,h,l,c)||M.push(a)}}v+=C}return p||M.length||u||(M=Up(e,v/2,a,l,c,h,u,!0,g)),M}function Zp(e,r,a,l){const c=[],h=e.image,u=h.pixelRatio,p=h.paddedRect.w-2,g=h.paddedRect.h-2;let x={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const v=h.stretchX||[[0,p]],w=h.stretchY||[[0,g]],M=(e,r)=>e+r[1]-r[0],C=v.reduce(M,0),A=w.reduce(M,0),k=p-C,R=g-A;let D=0,L=C,B=0,O=A,j=0,N=k,U=0,Z=R;if(h.content&&l){const r=h.content,a=r[2]-r[0],l=r[3]-r[1];(h.textFitWidth||h.textFitHeight)&&(x=rp(e)),D=$p(v,0,r[0]),B=$p(w,0,r[1]),L=$p(v,r[0],r[2]),O=$p(w,r[1],r[3]),j=r[0]-D,U=r[1]-B,N=a-L,Z=l-O}const J=x.x1,Q=x.y1,et=x.x2-J,it=x.y2-Q,rt=(e,l,c,p)=>{const g=qp(e.stretch-D,L,et,J),x=Wp(e.fixed-j,N,e.stretch,C),v=qp(l.stretch-B,O,it,Q),w=Wp(l.fixed-U,Z,l.stretch,A),M=qp(c.stretch-D,L,et,J),k=Wp(c.fixed-j,N,c.stretch,C),R=qp(p.stretch-B,O,it,Q),rt=Wp(p.fixed-U,Z,p.stretch,A),nt=new y(g,v),st=new y(M,v),ot=new y(M,R),at=new y(g,R),lt=new y(x/u,w/u),ct=new y(k/u,rt/u),ht=r*Math.PI/180;if(ht){const e=Math.sin(ht),r=Math.cos(ht),a=[r,-e,e,r];nt._matMult(a),st._matMult(a),at._matMult(a),ot._matMult(a)}const ut=e.stretch+e.fixed,yt=l.stretch+l.fixed;return{tl:nt,tr:st,bl:at,br:ot,tex:{x:h.paddedRect.x+1+ut,y:h.paddedRect.y+1+yt,w:c.stretch+c.fixed-ut,h:p.stretch+p.fixed-yt},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:lt,pixelOffsetBR:ct,minFontScaleX:N/u/et,minFontScaleY:Z/u/it,isSDF:a}};if(l&&(h.stretchX||h.stretchY)){const e=Gp(v,k,C),r=Gp(w,R,A);for(let a=0;a0&&(l=Math.max(10,l),this.circleDiameter=l)}else{const g=(null===(v=h.image)||void 0===v?void 0:v.content)&&(h.image.textFitWidth||h.image.textFitHeight)?rp(h):{x1:h.left,y1:h.top,x2:h.right,y2:h.bottom};g.y1=g.y1*u-p[0],g.y2=g.y2*u+p[2],g.x1=g.x1*u-p[3],g.x2=g.x2*u+p[1];const w=h.collisionPadding;if(w&&(g.x1-=w[0]*u,g.y1-=w[1]*u,g.x2+=w[2]*u,g.y2+=w[3]*u),x){const e=new y(g.x1,g.y1),r=new y(g.x2,g.y1),a=new y(g.x1,g.y2),l=new y(g.x2,g.y2),c=x*Math.PI/180;e._rotate(c),r._rotate(c),a._rotate(c),l._rotate(c),g.x1=Math.min(e.x,r.x,a.x,l.x),g.x2=Math.max(e.x,r.x,a.x,l.x),g.y1=Math.min(e.y,r.y,a.y,l.y),g.y2=Math.max(e.y,r.y,a.y,l.y)}e.emplaceBack(r.x,r.y,g.x1,g.y1,g.x2,g.y2,a,l,c)}this.boxEndIndex=e.length}}class Yh{constructor(e=[],r=(e,r)=>er?1:0){if(this.data=e,this.length=this.data.length,this.compare=r,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],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:a}=this,l=r[e];for(;e>0;){const c=e-1>>1,h=r[c];if(a(l,h)>=0)break;r[e]=h,e=c}r[e]=l}_down(e){const{data:r,compare:a}=this,l=this.length>>1,c=r[e];for(;e=0)break;r[e]=r[l],e=l}r[e]=c}}function Hp(e,r=1,a=!1){const l=Ih.fromPoints(e[0]),c=Math.min(l.width(),l.height());let h=c/2;const u=new Yh([],Xp),{minX:p,minY:g,maxX:x,maxY:v}=l;if(0===c)return new y(p,g);for(let r=p;rw.d||!w.d)&&(w=l,a&&console.log("found best %d after %d probes",Math.round(1e4*l.d)/1e4,M)),l.max-w.d<=r||(h=l.h/2,u.push(new Yp(l.p.x-h,l.p.y-h,h,e)),u.push(new Yp(l.p.x+h,l.p.y-h,h,e)),u.push(new Yp(l.p.x-h,l.p.y+h,h,e)),u.push(new Yp(l.p.x+h,l.p.y+h,h,e)),M+=4)}return a&&(console.log(`num probes: ${M}`),console.log(`best distance: ${w.d}`)),w.p}function Xp(e,r){return r.max-e.max}function Yp(r,a,l,c){(this||e).p=new y(r,a),(this||e).h=l,(this||e).d=function(e,r){let a=!1,l=1/0;for(let c=0;ce.y!=p.y>e.y&&e.x<(p.x-c.x)*(e.y-c.y)/(p.y-c.y)+c.x&&(a=!a),l=Math.min(l,oh(e,c,p))}}return(a?1:-1)*Math.sqrt(l)}((this||e).p,c),(this||e).max=(this||e).d+(this||e).h*Math.SQRT2}var Kp;r.aD=void 0,(Kp=r.aD||(r.aD={}))[Kp.center=1]="center",Kp[Kp.left=2]="left",Kp[Kp.right=3]="right",Kp[Kp.top=4]="top",Kp[Kp.bottom=5]="bottom",Kp[Kp["top-left"]=6]="top-left",Kp[Kp["top-right"]=7]="top-right",Kp[Kp["bottom-left"]=8]="bottom-left",Kp[Kp["bottom-right"]=9]="bottom-right";const Jp=Number.POSITIVE_INFINITY;function Qp(e,r){return r[1]!==Jp?function(e,r,a){let l=0,c=0;switch(r=Math.abs(r),a=Math.abs(a),e){case"top-right":case"top-left":case"top":c=a-7;break;case"bottom-right":case"bottom-left":case"bottom":c=7-a}switch(e){case"top-right":case"bottom-right":case"right":l=-r;break;case"top-left":case"bottom-left":case"left":l=r}return[l,c]}(e,r[0],r[1]):function(e,r){let a=0,l=0;r<0&&(r=0);const c=r/Math.SQRT2;switch(e){case"top-right":case"top-left":l=c-7;break;case"bottom-right":case"bottom-left":l=7-c;break;case"bottom":l=7-r;break;case"top":l=r-7}switch(e){case"top-right":case"bottom-right":a=-c;break;case"top-left":case"bottom-left":a=c;break;case"left":a=r;break;case"right":a=-r}return[a,l]}(e,r[0])}function tf(e,r,a){var l;const c=e.layout,h=null===(l=c.get("text-variable-anchor-offset"))||void 0===l?void 0:l.evaluate(r,{},a);if(h){const e=h.values,r=[];for(let a=0;ae*Ed));l.startsWith("top")?c[1]-=7:l.startsWith("bottom")&&(c[1]+=7),r[a+1]=c}return new Oe(r)}const u=c.get("text-variable-anchor");if(u){let l;l=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[c.get("text-radial-offset").evaluate(r,{},a)*Ed,Jp]:c.get("text-offset").evaluate(r,{},a).map((e=>e*Ed));const h=[];for(const e of u)h.push(e,Qp(e,l));return new Oe(h)}return null}function ef(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 rf(e,a,l,c,h,u,p,g,y,x,v,w){let M=u.textMaxSize.evaluate(a,{});void 0===M&&(M=p);const C=e.layers[0].layout,A=C.get("icon-offset").evaluate(a,{},v),k=sf(l.horizontal),R=p/24,D=e.tilePixelRatio*R,L=e.tilePixelRatio*M/24,B=e.tilePixelRatio*g,O=e.tilePixelRatio*C.get("symbol-spacing"),j=C.get("text-padding")*e.tilePixelRatio,N=function(e,r,a,l=1){const c=e.get("icon-padding").evaluate(r,{},a),h=c&&c.values;return[h[0]*l,h[1]*l,h[2]*l,h[3]*l]}(C,a,v,e.tilePixelRatio),U=C.get("text-max-angle")/180*Math.PI,Z="viewport"!==C.get("text-rotation-alignment")&&"point"!==C.get("symbol-placement"),J="map"===C.get("icon-rotation-alignment")&&"point"!==C.get("symbol-placement"),Q=C.get("symbol-placement"),et=O/2,it=C.get("icon-text-fit");let rt;c&&"none"!==it&&(e.allowVerticalPlacement&&l.vertical&&(rt=np(c,l.vertical,it,C.get("icon-text-fit-padding"),A,R)),k&&(c=np(c,k,it,C.get("icon-text-fit-padding"),A,R)));const nt=v?w.line.getGranularityForZoomLevel(v.z):1,st=(g,w)=>{w.x<0||w.x>=ot||w.y<0||w.y>=ot||function(e,a,l,c,h,u,p,g,y,x,v,w,M,C,A,k,R,D,L,B,O,j,N,U,Z){const J=e.addToLineVertexArray(a,l);let Q,et,it,rt,nt=0,st=0,ot=0,at=0,lt=-1,ct=-1;const ht={};let ut=Rc("");if(e.allowVerticalPlacement&&c.vertical){const e=g.layout.get("text-rotate").evaluate(O,{},U)+90;it=new Zh(y,a,x,v,w,c.vertical,M,C,A,e),p&&(rt=new Zh(y,a,x,v,w,p,R,D,A,e))}if(h){const l=g.layout.get("icon-rotate").evaluate(O,{}),c="none"!==g.layout.get("icon-text-fit"),u=Zp(h,l,N,c),M=p?Zp(p,l,N,c):void 0;et=new Zh(y,a,x,v,w,h,R,D,!1,l),nt=4*u.length;const C=e.iconSizeData;let A=null;"source"===C.kind?(A=[sp*g.layout.get("icon-size").evaluate(O,{})],A[0]>op&&Gt(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===C.kind&&(A=[sp*j.compositeIconSizes[0].evaluate(O,{},U),sp*j.compositeIconSizes[1].evaluate(O,{},U)],(A[0]>op||A[1]>op)&&Gt(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,u,A,B,L,O,r.an.none,a,J.lineStartIndex,J.lineLength,-1,U),lt=e.icon.placedSymbolArray.length-1,M&&(st=4*M.length,e.addSymbols(e.icon,M,A,B,L,O,r.an.vertical,a,J.lineStartIndex,J.lineLength,-1,U),ct=e.icon.placedSymbolArray.length-1)}const yt=Object.keys(c.horizontal);for(const l of yt){const h=c.horizontal[l];if(!Q){ut=Rc(h.text);const e=g.layout.get("text-rotate").evaluate(O,{},U);Q=new Zh(y,a,x,v,w,h,M,C,A,e)}const p=1===h.positionedLines.length;if(ot+=nf(e,a,h,u,g,A,O,k,J,c.vertical?r.an.horizontal:r.an.horizontalOnly,p?yt:[l],ht,lt,j,U),p)break}c.vertical&&(at+=nf(e,a,c.vertical,u,g,A,O,k,J,r.an.vertical,["vertical"],ht,ct,j,U));const Pt=Q?Q.boxStartIndex:e.collisionBoxArray.length,St=Q?Q.boxEndIndex:e.collisionBoxArray.length,Ct=it?it.boxStartIndex:e.collisionBoxArray.length,Et=it?it.boxEndIndex:e.collisionBoxArray.length,kt=et?et.boxStartIndex:e.collisionBoxArray.length,Bt=et?et.boxEndIndex:e.collisionBoxArray.length,Nt=rt?rt.boxStartIndex:e.collisionBoxArray.length,$t=rt?rt.boxEndIndex:e.collisionBoxArray.length;let qt=-1;const Ht=(e,r)=>e&&e.circleDiameter?Math.max(e.circleDiameter,r):r;qt=Ht(Q,qt),qt=Ht(it,qt),qt=Ht(et,qt),qt=Ht(rt,qt);const Xt=qt>-1?1:0;Xt&&(qt*=Z/Ed),e.glyphOffsetArray.length>=Jc.MAX_GLYPHS&&Gt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==O.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,O.sortKey);const Kt=tf(g,O,U),[Qt,ee]=function(e,a){const l=e.length,c=null==a?void 0:a.values;if((null==c?void 0:c.length)>0)for(let a=0;a=0?ht.right:-1,ht.center>=0?ht.center:-1,ht.left>=0?ht.left:-1,ht.vertical||-1,lt,ct,ut,Pt,St,Ct,Et,kt,Bt,Nt,$t,x,ot,at,nt,st,Xt,0,M,qt,Qt,ee)}(e,w,g,l,c,h,rt,e.layers[0],e.collisionBoxArray,a.index,a.sourceLayerIndex,e.index,D,[j,j,j,j],Z,y,B,N,J,A,a,u,x,v,p)};if("line"===Q)for(const r of Lp(a.geometry,0,0,ot,ot)){const a=Pu(r,nt),h=Np(a,O,U,l.vertical||k,c,24,L,e.overscaling,ot);for(const r of h)k&&of(e,k.text,et,r)||st(a,r)}else if("line-center"===Q){for(const e of a.geometry)if(e.length>1){const r=Pu(e,nt),a=Vp(r,U,l.vertical||k,c,24,L);a&&st(r,a)}}else if("Polygon"===a.type)for(const e of Rn(a.geometry,0)){const r=Hp(e,16);st(Pu(e[0],nt,!0),new Vh(r.x,r.y,0))}else if("LineString"===a.type)for(const e of a.geometry){const r=Pu(e,nt);st(r,new Vh(r[0].x,r[0].y,0))}else if("Point"===a.type)for(const e of a.geometry)for(const r of e)st([r],new Vh(r.x,r.y,0))}function nf(e,r,a,l,c,h,u,p,g,x,v,w,M,C,A){const k=function(e,r,a,l,c,h,u,p){const g=l.layout.get("text-rotate").evaluate(h,{})*Math.PI/180,x=[];for(const e of r.positionedLines)for(const l of e.positionedGlyphs){if(!l.rect)continue;const h=l.rect||{};let v=4,w=!0,M=1,C=0;const A=(c||p)&&l.vertical,k=l.metrics.advance*l.scale/2;if(p&&r.verticalizable&&(C=e.lineOffset/2-(l.imageName?-(Ed-l.metrics.width*l.scale)/2:(l.scale-1)*Ed)),l.imageName){const e=u[l.imageName];w=e.sdf,M=e.pixelRatio,v=1/M}const R=c?[l.x+k,l.y]:[0,0];let D=c?[0,0]:[l.x+k+a[0],l.y+a[1]-C],L=[0,0];A&&(L=D,D=[0,0]);const B=l.metrics.isDoubleResolution?2:1,O=(l.metrics.left-v)*l.scale-k+D[0],j=(-l.metrics.top-v)*l.scale+D[1],N=O+h.w/B*l.scale/M,U=j+h.h/B*l.scale/M,Z=new y(O,j),J=new y(N,j),Q=new y(O,U),et=new y(N,U);if(A){const e=new y(-k,k- -17),r=-Math.PI/2,a=12-k,c=new y(22-a,-(l.imageName?a:0)),h=new y(...L);Z._rotateAround(r,e)._add(c)._add(h),J._rotateAround(r,e)._add(c)._add(h),Q._rotateAround(r,e)._add(c)._add(h),et._rotateAround(r,e)._add(c)._add(h)}if(g){const e=Math.sin(g),r=Math.cos(g),a=[r,-e,e,r];Z._matMult(a),J._matMult(a),Q._matMult(a),et._matMult(a)}const it=new y(0,0),rt=new y(0,0);x.push({tl:Z,tr:J,bl:Q,br:et,tex:h,writingMode:r.writingMode,glyphOffset:R,sectionIndex:l.sectionIndex,isSDF:w,pixelOffsetTL:it,pixelOffsetBR:rt,minFontScaleX:0,minFontScaleY:0})}return x}(0,a,p,c,h,u,l,e.allowVerticalPlacement),R=e.textSizeData;let D=null;"source"===R.kind?(D=[sp*c.layout.get("text-size").evaluate(u,{})],D[0]>op&&Gt(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===R.kind&&(D=[sp*C.compositeTextSizes[0].evaluate(u,{},A),sp*C.compositeTextSizes[1].evaluate(u,{},A)],(D[0]>op||D[1]>op)&&Gt(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,k,D,p,h,u,x,r,g.lineStartIndex,g.lineLength,M,A);for(const r of v)w[r]=e.text.placedSymbolArray.length-1;return 4*k.length}function sf(e){for(const r in e)return e[r];return null}function of(e,r,a,l){const c=e.compareText;if(r in c){const e=c[r];for(let r=e.length-1;r>=0;r--)if(l.dist(e[r])>4;if(1!==l)throw new Error(`Got v${l} data when expected v1.`);const c=af[15&a];if(!c)throw new Error("Unrecognized array type.");const[h]=new Uint16Array(e,2,1),[u]=new Uint32Array(e,4,1);return new lp(u,h,c,e)}constructor(e,r=64,a=Float64Array,l){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=a,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const c=af.indexOf(this.ArrayType),h=2*e*this.ArrayType.BYTES_PER_ELEMENT,u=e*this.IndexArrayType.BYTES_PER_ELEMENT,p=(8-u%8)%8;if(c<0)throw new Error(`Unexpected typed array class: ${a}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+u+p,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+h+u+p),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+u+p,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+c]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const a=this._pos>>1;return this.ids[a]=a,this.coords[this._pos++]=e,this.coords[this._pos++]=r,a}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return lf(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,a,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:h,nodeSize:u}=this,p=[0,c.length-1,0],g=[];for(;p.length;){const y=p.pop()||0,x=p.pop()||0,v=p.pop()||0;if(x-v<=u){for(let u=v;u<=x;u++){const p=h[2*u],y=h[2*u+1];p>=e&&p<=a&&y>=r&&y<=l&&g.push(c[u])}continue}const w=v+x>>1,M=h[2*w],C=h[2*w+1];M>=e&&M<=a&&C>=r&&C<=l&&g.push(c[w]),(0===y?e<=M:r<=C)&&(p.push(v),p.push(w-1),p.push(1-y)),(0===y?a>=M:l>=C)&&(p.push(w+1),p.push(x),p.push(1-y))}return g}within(e,r,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:c,nodeSize:h}=this,u=[0,l.length-1,0],p=[],g=a*a;for(;u.length;){const y=u.pop()||0,x=u.pop()||0,v=u.pop()||0;if(x-v<=h){for(let a=v;a<=x;a++)df(c[2*a],c[2*a+1],e,r)<=g&&p.push(l[a]);continue}const w=v+x>>1,M=c[2*w],C=c[2*w+1];df(M,C,e,r)<=g&&p.push(l[w]),(0===y?e-a<=M:r-a<=C)&&(u.push(v),u.push(w-1),u.push(1-y)),(0===y?e+a>=M:r+a>=C)&&(u.push(w+1),u.push(x),u.push(1-y))}return p}}function lf(e,r,a,l,c,h){if(c-l<=a)return;const u=l+c>>1;cf(e,r,u,l,c,h),lf(e,r,a,l,u-1,1-h),lf(e,r,a,u+1,c,1-h)}function cf(e,r,a,l,c,h){for(;c>l;){if(c-l>600){const u=c-l+1,p=a-l+1,g=Math.log(u),y=.5*Math.exp(2*g/3),x=.5*Math.sqrt(g*y*(u-y)/u)*(p-u/2<0?-1:1);cf(e,r,a,Math.max(l,Math.floor(a-p*y/u+x)),Math.min(c,Math.floor(a+(u-p)*y/u+x)),h)}const u=r[2*a+h];let p=l,g=c;for(hf(e,r,l,a),r[2*c+h]>u&&hf(e,r,l,c);pu;)g--}r[2*l+h]===u?hf(e,r,l,g):(g++,hf(e,r,g,c)),g<=a&&(l=g+1),a<=g&&(c=g-1)}}function hf(e,r,a,l){uf(e,a,l),uf(r,2*a,2*l),uf(r,2*a+1,2*l+1)}function uf(e,r,a){const l=e[r];e[r]=e[a],e[a]=l}function df(e,r,a,l){const c=e-a,h=r-l;return c*c+h*h}var pf;r.cw=void 0,(pf=r.cw||(r.cw={})).create="create",pf.load="load",pf.fullLoad="fullLoad";let ff=null,mf=[];const _f=1e3/60,gf="loadTime",yf="fullLoadTime",xf={mark(e){performance.mark(e)},frame(e){const r=e;null!=ff&&mf.push(r-ff),ff=r},clearMetrics(){ff=null,mf=[],performance.clearMeasures(gf),performance.clearMeasures(yf);for(const e in r.cw)performance.clearMarks(r.cw[e])},getPerformanceMetrics(){performance.measure(gf,r.cw.create,r.cw.load),performance.measure(yf,r.cw.create,r.cw.fullLoad);const e=performance.getEntriesByName(gf)[0].duration,a=performance.getEntriesByName(yf)[0].duration,l=mf.length,c=1/(mf.reduce(((e,r)=>e+r),0)/l/1e3),h=mf.filter((e=>e>_f)).reduce(((e,r)=>e+(r-_f)/_f),0);return{loadTime:e,fullLoadTime:a,fps:c,percentDroppedFrames:h/(l+h)*100,totalFrames:l}}};r.$=ot,r.A=R,r.B=function([e,r,a]){return r+=90,r*=Math.PI/180,a*=Math.PI/180,{x:e*Math.cos(r)*Math.sin(a),y:e*Math.sin(r)*Math.sin(a),z:e*Math.cos(a)}},r.C=Yr,r.D=Os,r.E=bt,r.F=Cs,r.G=Vl,r.H=function(e){if(null==Xt){const r=e.navigator?e.navigator.userAgent:null;Xt=!!e.safari||!(!r||!(/\b(iPad|iPhone|iPod)\b/.test(r)||r.match("Safari")&&!r.match("Chrome")))}return Xt},r.I=mc,r.J=class{constructor(e,r){this.target=e,this.mapId=r,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new ch((()=>this.process())),this.subscription=le(this.target,"message",(e=>this.receive(e)),!1),this.globalScope=Ht(self)?e:window}registerMessageHandler(e,r){this.messageHandlers[e]=r}sendAsync(e,r){return new Promise(((a,l)=>{const c=Math.round(1e18*Math.random()).toString(36).substring(0,10),h=r?le(r.signal,"abort",(()=>{null==h||h.unsubscribe(),delete this.resolveRejects[c];const r={id:c,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(r)}),wp):null;this.resolveRejects[c]={resolve:e=>{null==h||h.unsubscribe(),a(e)},reject:e=>{null==h||h.unsubscribe(),l(e)}};const u=[],p=Object.assign(Object.assign({},e),{id:c,sourceMapId:this.mapId,origin:location.origin,data:Kl(e.data,u)});this.target.postMessage(p,{transfer:u})}))}receive(e){const r=e.data,a=r.id;if(!("file://"!==r.origin&&"file://"!==location.origin&&"resource://android"!==r.origin&&"resource://android"!==location.origin&&r.origin!==location.origin||r.targetMapId&&this.mapId!==r.targetMapId)){if(""===r.type){delete this.tasks[a];const e=this.abortControllers[a];return delete this.abortControllers[a],void(e&&e.abort())}if(Ht(self)||r.mustQueue)return this.tasks[a]=r,this.taskQueue.push(a),void this.invoker.trigger();this.processTask(a,r)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),r=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),r&&this.processTask(e,r)}processTask(e,r){return a(this,void 0,void 0,(function*(){if(""===r.type){const a=this.resolveRejects[e];if(delete this.resolveRejects[e],!a)return;return void(r.error?a.reject(Ql(r.error)):a.resolve(Ql(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const a=Ql(r.data),l=new AbortController;this.abortControllers[e]=l;try{const c=yield this.messageHandlers[r.type](r.sourceMapId,a,l);this.completeTask(e,null,c)}catch(a){this.completeTask(e,a)}}))}completeTask(e,r,a){const l=[];delete this.abortControllers[e];const c={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:r?Kl(r):null,data:Kl(a,l)};this.target.postMessage(c,{transfer:l})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},r.K=ge,r.L=function(){var e=new R(16);return R!=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},r.M=function(e,r,a){var l,c,h,u,p,g,y,x,v,w,M,C,A=a[0],k=a[1],R=a[2];return r===e?(e[12]=r[0]*A+r[4]*k+r[8]*R+r[12],e[13]=r[1]*A+r[5]*k+r[9]*R+r[13],e[14]=r[2]*A+r[6]*k+r[10]*R+r[14],e[15]=r[3]*A+r[7]*k+r[11]*R+r[15]):(c=r[1],h=r[2],u=r[3],p=r[4],g=r[5],y=r[6],x=r[7],v=r[8],w=r[9],M=r[10],C=r[11],e[0]=l=r[0],e[1]=c,e[2]=h,e[3]=u,e[4]=p,e[5]=g,e[6]=y,e[7]=x,e[8]=v,e[9]=w,e[10]=M,e[11]=C,e[12]=l*A+p*k+v*R+r[12],e[13]=c*A+g*k+w*R+r[13],e[14]=h*A+y*k+M*R+r[14],e[15]=u*A+x*k+C*R+r[15]),e},r.N=function(e,r,a){var l=a[0],c=a[1],h=a[2];return e[0]=r[0]*l,e[1]=r[1]*l,e[2]=r[2]*l,e[3]=r[3]*l,e[4]=r[4]*c,e[5]=r[5]*c,e[6]=r[6]*c,e[7]=r[7]*c,e[8]=r[8]*h,e[9]=r[9]*h,e[10]=r[10]*h,e[11]=r[11]*h,e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],e},r.O=function(e,r,a){var l=r[0],c=r[1],h=r[2],u=r[3],p=r[4],g=r[5],y=r[6],x=r[7],v=r[8],w=r[9],M=r[10],C=r[11],A=r[12],k=r[13],R=r[14],D=r[15],L=a[0],B=a[1],O=a[2],j=a[3];return e[0]=L*l+B*p+O*v+j*A,e[1]=L*c+B*g+O*w+j*k,e[2]=L*h+B*y+O*M+j*R,e[3]=L*u+B*x+O*C+j*D,e[4]=(L=a[4])*l+(B=a[5])*p+(O=a[6])*v+(j=a[7])*A,e[5]=L*c+B*g+O*w+j*k,e[6]=L*h+B*y+O*M+j*R,e[7]=L*u+B*x+O*C+j*D,e[8]=(L=a[8])*l+(B=a[9])*p+(O=a[10])*v+(j=a[11])*A,e[9]=L*c+B*g+O*w+j*k,e[10]=L*h+B*y+O*M+j*R,e[11]=L*u+B*x+O*C+j*D,e[12]=(L=a[12])*l+(B=a[13])*p+(O=a[14])*v+(j=a[15])*A,e[13]=L*c+B*g+O*w+j*k,e[14]=L*h+B*y+O*M+j*R,e[15]=L*u+B*x+O*C+j*D,e},r.P=y,r.Q=function(e,r){const a={};for(let l=0;l{const r=window.document.createElement("video");return r.muted=!0,new Promise((a=>{r.onloadstart=()=>{a(r)};for(const a of e){const e=window.document.createElement("source");be(a)||(r.crossOrigin="Anonymous"),e.src=a,r.appendChild(e)}}))},r.a5=Tt,r.a6=function(){return Et++},r.a7=_a,r.a8=Jc,r.a9=qo,r.aA=Ed,r.aB=at,r.aC=function(e,r,a,l,c=!1){if(!a[0]&&!a[1])return[0,0];const h=c?"map"===l?-e.bearingInRadians:0:"viewport"===l?e.bearingInRadians:0;if(h){const e=Math.sin(h),r=Math.cos(h);a=[a[0]*r-a[1]*e,a[0]*e+a[1]*r]}return[c?a[0]:at(r,a[0],e.zoom),c?a[1]:at(r,a[1],e.zoom)]},r.aE=cp,r.aF=ef,r.aG=Xd,r.aH=lp,r.aI=yc,r.aJ=Yl,r.aK=Ta,r.aL=Ha,r.aM=Ga,r.aN=St,r.aO=he,r.aP=Ap,r.aQ=U,r.aR=N,r.aS=function(e){var r=new R(3);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r},r.aT=function(e,r,a){return e[0]=r[0]-a[0],e[1]=r[1]-a[1],e[2]=r[2]-a[2],e},r.aU=function(e,r){var a=r[0],l=r[1],c=r[2],h=a*a+l*l+c*c;return h>0&&(h=1/Math.sqrt(h)),e[0]=r[0]*h,e[1]=r[1]*h,e[2]=r[2]*h,e},r.aV=Z,r.aW=function(e,r){return e[0]*r[0]+e[1]*r[1]+e[2]*r[2]},r.aX=function(e,r,a){return e[0]=r[0]*a[0],e[1]=r[1]*a[1],e[2]=r[2]*a[2],e[3]=r[3]*a[3],e},r.aY=O,r.aZ=function(e,r,a){const l=r[0]*a[0]+r[1]*a[1]+r[2]*a[2];return 0===l?null:(-(e[0]*a[0]+e[1]*a[1]+e[2]*a[2])-a[3])/l},r.a_=Q,r.aa=$c,r.ab=Ph,r.ac=function(e){const r={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,a,l,c)=>{const h=l||c;return r[a]=!h||h.toLowerCase(),""})),r["max-age"]){const e=parseInt(r["max-age"],10);isNaN(e)?delete r["max-age"]:r["max-age"]=e}return r},r.ad=ce,r.ae=function(e){return Math.pow(2,e)},r.af=L,r.ag=Pt,r.ah=85.051129,r.ai=Cp,r.aj=function(e){return Math.log(e)/Math.LN2},r.ak=function(e){var r=e[0],a=e[1];return r*r+a*a},r.al=function(e,r){const a=[];for(const l in e)l in r||a.push(l);return a},r.am=function(e,r){let a=0,l=0;if("constant"===e.kind)l=e.layoutSize;else if("source"!==e.kind){const{interpolationType:c,minZoom:h,maxZoom:u}=e,p=c?Pt(yr.interpolationFactor(c,r,h,u),0,1):0;"camera"===e.kind?l=Yr.number(e.minSize,e.maxSize,p):a=p}return{uSizeT:a,uSize:l}},r.ao=function(e,{uSize:r,uSizeT:a},{lowerSize:l,upperSize:c}){return"source"===e.kind?l/sp:"composite"===e.kind?Yr.number(l/sp,c/sp,a):r},r.ap=function(e,r){var a=r[0],l=r[1],c=r[2],h=r[3],u=r[4],p=r[5],g=r[6],y=r[7],x=r[8],v=r[9],w=r[10],M=r[11],C=r[12],A=r[13],k=r[14],R=r[15],D=a*p-l*u,L=a*g-c*u,B=a*y-h*u,O=l*g-c*p,j=l*y-h*p,N=c*y-h*g,U=x*A-v*C,Z=x*k-w*C,J=x*R-M*C,Q=v*k-w*A,et=v*R-M*A,it=w*R-M*k,rt=D*it-L*et+B*Q+O*J-j*Z+N*U;return rt?(e[0]=(p*it-g*et+y*Q)*(rt=1/rt),e[1]=(c*et-l*it-h*Q)*rt,e[2]=(A*N-k*j+R*O)*rt,e[3]=(w*j-v*N-M*O)*rt,e[4]=(g*J-u*it-y*Z)*rt,e[5]=(a*it-c*J+h*Z)*rt,e[6]=(k*B-C*N-R*L)*rt,e[7]=(x*N-w*B+M*L)*rt,e[8]=(u*et-p*J+y*U)*rt,e[9]=(l*J-a*et-h*U)*rt,e[10]=(C*j-A*B+R*D)*rt,e[11]=(v*B-x*j-M*D)*rt,e[12]=(p*Z-u*Q-g*U)*rt,e[13]=(a*Q-l*Z+c*U)*rt,e[14]=(A*L-C*O-k*D)*rt,e[15]=(x*O-v*L+w*D)*rt,e):null},r.aq=nt,r.ar=function(e){return Math.hypot(e[0],e[1])},r.as=function(e){return e[0]=0,e[1]=0,e},r.at=function(e,r,a){return e[0]=r[0]*a,e[1]=r[1]*a,e},r.au=pp,r.av=et,r.aw=function(e,r,a,l){const c=r.y-e.y,h=r.x-e.x,u=l.y-a.y,p=l.x-a.x,g=u*h-p*c;if(0===g)return null;const x=(p*(e.y-a.y)-u*(e.x-a.x))/g;return new y(e.x+x*h,e.y+x*c)},r.ax=Lp,r.ay=Wc,r.az=function(e){let r=1/0,a=1/0,l=-1/0,c=-1/0;for(const h of e)r=Math.min(r,h.x),a=Math.min(a,h.y),l=Math.max(l,h.x),c=Math.max(c,h.y);return[r,a,l,c]},r.b=Kt,r.b$=Td,r.b0=function(e,r){return e[0]*r[0]+e[1]*r[1]+e[2]*r[2]+e[3]},r.b1=Ah,r.b2=kp,r.b3=function(e,r,a,l,c){var h,u=1/Math.tan(r/2);return e[0]=u/a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=c&&c!==1/0?(e[10]=(c+l)*(h=1/(l-c)),e[14]=2*c*l*h):(e[10]=-1,e[14]=-2*l),e},r.b4=function(e){var r=new R(16);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r},r.b5=function(e,r,a){var l=Math.sin(a),c=Math.cos(a),h=r[0],u=r[1],p=r[2],g=r[3],y=r[4],x=r[5],v=r[6],w=r[7];return r!==e&&(e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15]),e[0]=h*c+y*l,e[1]=u*c+x*l,e[2]=p*c+v*l,e[3]=g*c+w*l,e[4]=y*c-h*l,e[5]=x*c-u*l,e[6]=v*c-p*l,e[7]=w*c-g*l,e},r.b6=function(e,r,a){var l=Math.sin(a),c=Math.cos(a),h=r[4],u=r[5],p=r[6],g=r[7],y=r[8],x=r[9],v=r[10],w=r[11];return r!==e&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15]),e[4]=h*c+y*l,e[5]=u*c+x*l,e[6]=p*c+v*l,e[7]=g*c+w*l,e[8]=y*c-h*l,e[9]=x*c-u*l,e[10]=v*c-p*l,e[11]=w*c-g*l,e},r.b7=function(){const e=new Float32Array(16);return L(e),e},r.b8=function(){const e=new Float64Array(16);return L(e),e},r.b9=function(){return new Float64Array(16)},r.bA=function(e){return e[0]=0,e[1]=0,e[2]=0,e},r.bB=function(e,r,a,l){const c=Math.sqrt(e*e+r*r),h=Math.sqrt(a*a+l*l);e/=c,r/=c,a/=h,l/=h;const u=Math.acos(e*a+r*l);return-r*a+e*l>0?u:-u},r.bC=function(e,r){const a=lt(e,2*Math.PI),l=lt(r,2*Math.PI);return Math.min(Math.abs(a-l),Math.abs(a-l+2*Math.PI),Math.abs(a-l-2*Math.PI))},r.bD=function(){const e={},r=Me.$version;for(const a in Me.$root){const l=Me.$root[a];if(l.required){let c=null;c="version"===a?r:"array"===l.type?[]:{},null!=c&&(e[a]=c)}}return e},r.bE=ys,r.bF=ye,r.bG=function e(r,a){if(Array.isArray(r)){if(!Array.isArray(a)||r.length!==a.length)return!1;for(let l=0;l{"source"in e&&l[e.source]?a.push({command:"removeLayer",args:[e.id]}):h.push(e)})),a=a.concat(c),function(e,r,a){r=r||[];const l=(e=e||[]).map(Ge),c=r.map(Ge),h=e.reduce(qe,{}),u=r.reduce(qe,{}),p=l.slice(),g=Object.create(null);let y,x,v,w,M;for(let e=0,r=0;ek?(c=Math.acos(h),u=Math.sin(c),p=Math.sin((1-l)*c)/u,g=Math.sin(l*c)/u):(p=1-l,g=l),e[0]=p*y+g*M,e[1]=p*x+g*C,e[2]=p*v+g*A,e[3]=p*w+g*R,e},r.bc=function(e){const r=new Float64Array(9);var a,l,c,h,u,p,g,y,x,v,w,M,C,A,k,R,D,L;v=(c=(l=e)[0])*(g=c+c),w=(h=l[1])*g,C=(u=l[2])*g,A=u*(y=h+h),R=(p=l[3])*g,D=p*y,L=p*(x=u+u),(a=r)[0]=1-(M=h*y)-(k=u*x),a[3]=w-L,a[6]=C+D,a[1]=w+L,a[4]=1-v-k,a[7]=A-R,a[2]=C-D,a[5]=A+R,a[8]=1-v-M;const B=he(-Math.asin(Pt(r[2],-1,1)));let O,j;return Math.hypot(r[5],r[8])<.001?(O=0,j=-he(Math.atan2(r[3],r[4]))):(O=he(0===r[5]&&0===r[8]?0:Math.atan2(r[5],r[8])),j=he(0===r[1]&&0===r[0]?0:Math.atan2(r[1],r[0]))),{roll:O,pitch:B+90,bearing:j}},r.bd=function(e,r){return e.roll==r.roll&&e.pitch==r.pitch&&e.bearing==r.bearing},r.be=Pe,r.bf=ho,r.bg=bu,r.bh=wu,r.bi=Zl,r.bj=ct,r.bk=ht,r.bl=je,r.bm=function(e,r,a,l,c){return ct(l,c,Pt((e-r)/(a-r),0,1))},r.bn=lt,r.bo=function(){return new Float64Array(3)},r.bp=function(e,r,a,l){return e[0]=r[0]+a[0]*l,e[1]=r[1]+a[1]*l,e[2]=r[2]+a[2]*l,e},r.bq=rt,r.br=function(e,r,a){var l=a[0],c=a[1],h=a[2],u=r[0],p=r[1],g=r[2],y=c*g-h*p,x=h*u-l*g,v=l*p-c*u,w=c*v-h*x,M=h*y-l*v,C=l*x-c*y,A=2*a[3];return x*=A,v*=A,M*=2,C*=2,e[0]=u+(y*=A)+(w*=2),e[1]=p+x+M,e[2]=g+v+C,e},r.bs=function(e,r,a){const l=(c=[e[0],e[1],e[2],r[0],r[1],r[2],a[0],a[1],a[2]])[0]*((x=c[8])*(u=c[4])-(p=c[5])*(y=c[7]))+c[1]*(-x*(h=c[3])+p*(g=c[6]))+c[2]*(y*h-u*g);var c,h,u,p,g,y,x;if(0===l)return null;const v=Z([],[r[0],r[1],r[2]],[a[0],a[1],a[2]]),w=Z([],[a[0],a[1],a[2]],[e[0],e[1],e[2]]),M=Z([],[e[0],e[1],e[2]],[r[0],r[1],r[2]]),C=U([],v,-e[3]);return N(C,C,U([],w,-r[3])),N(C,C,U([],M,-a[3])),U(C,C,1/l),C},r.bt=Tp,r.bu=function(){return new Float64Array(4)},r.bv=function(e,r,a,l){var c=[],h=[];return c[0]=r[0]-a[0],c[1]=r[1]-a[1],c[2]=r[2]-a[2],h[0]=c[0]*Math.cos(l)-c[1]*Math.sin(l),h[1]=c[0]*Math.sin(l)+c[1]*Math.cos(l),h[2]=c[2],e[0]=h[0]+a[0],e[1]=h[1]+a[1],e[2]=h[2]+a[2],e},r.bw=function(e,r,a,l){var c=[],h=[];return c[0]=r[0]-a[0],c[1]=r[1]-a[1],c[2]=r[2]-a[2],h[0]=c[0],h[1]=c[1]*Math.cos(l)-c[2]*Math.sin(l),h[2]=c[1]*Math.sin(l)+c[2]*Math.cos(l),e[0]=h[0]+a[0],e[1]=h[1]+a[1],e[2]=h[2]+a[2],e},r.bx=function(e,r,a,l){var c=[],h=[];return c[0]=r[0]-a[0],c[1]=r[1]-a[1],c[2]=r[2]-a[2],h[0]=c[2]*Math.sin(l)+c[0]*Math.cos(l),h[1]=c[1],h[2]=c[2]*Math.cos(l)-c[0]*Math.sin(l),e[0]=h[0]+a[0],e[1]=h[1]+a[1],e[2]=h[2]+a[2],e},r.by=function(e,r,a){var l=Math.sin(a),c=Math.cos(a),h=r[0],u=r[1],p=r[2],g=r[3],y=r[8],x=r[9],v=r[10],w=r[11];return r!==e&&(e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15]),e[0]=h*c-y*l,e[1]=u*c-x*l,e[2]=p*c-v*l,e[3]=g*c-w*l,e[8]=h*l+y*c,e[9]=u*l+x*c,e[10]=p*l+v*c,e[11]=g*l+w*c,e},r.bz=function(e,r){const a=lt(e,360),l=lt(r,360),c=l-a,h=l>a?c-360:c+360;return Math.abs(c)e*Ed))}let L=p?"center":l.get("text-justify").evaluate(c,{},e.canonical);const B="point"===l.get("symbol-placement")?l.get("text-max-width").evaluate(c,{},e.canonical)*Ed:1/0,O=()=>{e.bucket.allowVerticalPlacement&&ec(h)&&(C.vertical=jd(A,e.glyphMap,e.glyphPositions,e.imagePositions,x,B,u,k,"left",M,R,r.an.vertical,!0,w,v))};if(!p&&D){const a=new Set;if("auto"===L)for(let e=0;e"symbol"===e.type,r.cb=e=>"circle"===e.type,r.cc=e=>"heatmap"===e.type,r.cd=e=>"line"===e.type,r.ce=e=>"fill"===e.type,r.cf=e=>"fill-extrusion"===e.type,r.cg=e=>"hillshade"===e.type,r.ch=e=>"color-relief"===e.type,r.ci=e=>"raster"===e.type,r.cj=e=>"background"===e.type,r.ck=e=>"custom"===e.type,r.cl=ut,r.cm=function(e,r,a){const l=st(r.x-a.x,r.y-a.y),c=st(e.x-a.x,e.y-a.y);var h,u;return he(Math.atan2(l[0]*c[1]-l[1]*c[0],(h=l)[0]*(u=c)[0]+h[1]*u[1]))},r.cn=yt,r.co=function(e,r){return de[r]&&(e instanceof MouseEvent||e instanceof WheelEvent)},r.cp=function(e,r){return ue[r]&&"touches"in e},r.cq=function(e){return ue[e]||de[e]},r.cr=function(e,r,a){var l=r[0],c=r[1];return e[0]=a[0]*l+a[4]*c+a[12],e[1]=a[1]*l+a[5]*c+a[13],e},r.cs=function(e,r){const{x:a,y:l}=wh.fromLngLat(r);return!(e<0||e>25||l<0||l>=1||a<0||a>=1)},r.ct=function(e,r){return e[0]=r[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=r[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},r.cu=class extends Qs{},r.cv=xf,r.cx=function(e){return e.message===pe},r.cy=pt,r.cz=function(e,r){me.REGISTERED_PROTOCOLS[e]=r},r.d=be,r.e=Ct,r.f=e=>a(void 0,void 0,void 0,(function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const r=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(r)}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.`)}})),r.g=_e,r.h=e=>new Promise(((r,a)=>{const l=new Image;l.onload=()=>{r(l),URL.revokeObjectURL(l.src),l.onload=null,window.requestAnimationFrame((()=>{l.src=Qt}))},l.onerror=()=>a(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 c=new Blob([new Uint8Array(e)],{type:"image/png"});l.src=e.byteLength?URL.createObjectURL(c):Qt})),r.i=Ht,r.j=(e,r)=>ve(Ct(e,{type:"json"}),r),r.k=vt,r.l=xt,r.m=ve,r.n=(e,r)=>ve(Ct(e,{type:"arrayBuffer"}),r),r.o=function(e){return new Dd(e).readFields(Ld,[])},r.p=Od,r.q=il,r.r=qs,r.s=le,r.t=Ts,r.u=tc,r.v=Me,r.w=Gt,r.x=jl,r.y=$l,r.z=Ol}));l("worker",["./shared"],(function(r){class t{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(e,a){for(const a of e){this._layerConfigs[a.id]=a;const e=this._layers[a.id]=r.bI(a);e._featureFilter=r.a9(e.filter),this.keyCache[a.id]&&delete this.keyCache[a.id]}for(const e of a)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const l=r.cB(Object.values(this._layerConfigs),this.keyCache);for(const e of l){const r=e.map((e=>this._layers[e.id])),a=r[0];if("none"===a.visibility)continue;const l=a.source||"";let c=this.familiesBySource[l];c||(c=this.familiesBySource[l]={});const h=a.sourceLayer||"_geojsonTileLayer";let u=c[h];u||(u=c[h]=[]),u.push(r)}}}class o{constructor(e){const a={},l=[];for(const r in e){const c=e[r],h=a[r]={};for(const e in c){const r=c[+e];if(!r||0===r.bitmap.width||0===r.bitmap.height)continue;const a={x:0,y:0,w:r.bitmap.width+2,h:r.bitmap.height+2};l.push(a),h[e]={rect:a,metrics:r.metrics}}}const{w:c,h:h}=r.p(l),u=new r.q({width:c||1,height:h||1});for(const l in e){const c=e[l];for(const e in c){const h=c[+e];if(!h||0===h.bitmap.width||0===h.bitmap.height)continue;const p=a[l][e].rect;r.q.copy(h.bitmap,u,{x:0,y:0},{x:p.x+1,y:p.y+1},h.bitmap)}}this.image=u,this.positions=a}}r.cC("GlyphAtlas",o);class i{constructor(e){this.tileID=new r.Z(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[],this.globalState=e.globalState}parse(e,l,c,h,u){return r._(this,void 0,void 0,(function*(){this.status="parsing",this.data=e,this.collisionBoxArray=new r.a7;const p=new r.cD(Object.keys(e.layers).sort()),g=new r.cE(this.tileID,this.promoteId);g.bucketLayerIDs=[];const y={},x={featureIndex:g,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:c,subdivisionGranularity:u},v=l.familiesBySource[this.source];for(const l in v){const h=e.layers[l];if(!h)continue;1===h.version&&r.w(`Vector tile source "${this.source}" layer "${l}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const u=p.encode(l),w=[];for(let e=0;e=l.maxzoom||"none"!==l.visibility&&(a(e,this.zoom,c),(y[l.id]=l.createBucket({index:g.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:u,sourceID:this.source,globalState:this.globalState})).populate(w,x,this.tileID.canonical),g.bucketLayerIDs.push(e.map((e=>e.id))))}}const w=r.bM(x.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let M=Promise.resolve({});if(Object.keys(w).length){const e=new AbortController;this.inFlightDependencies.push(e),M=h.sendAsync({type:"GG",data:{stacks:w,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const C=Object.keys(x.iconDependencies);let A=Promise.resolve({});if(C.length){const e=new AbortController;this.inFlightDependencies.push(e),A=h.sendAsync({type:"GI",data:{icons:C,source:this.source,tileID:this.tileID,type:"icons"}},e)}const k=Object.keys(x.patternDependencies);let R=Promise.resolve({});if(k.length){const e=new AbortController;this.inFlightDependencies.push(e),R=h.sendAsync({type:"GI",data:{icons:k,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const[D,L,B]=yield Promise.all([M,A,R]),O=new o(D),j=new r.cF(L,B);for(const e in y){const l=y[e];l instanceof r.a8?(a(l.layers,this.zoom,c),r.cG({bucket:l,glyphMap:D,glyphPositions:O.positions,imageMap:L,imagePositions:j.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:x.subdivisionGranularity})):l.hasPattern&&(l instanceof r.cH||l instanceof r.cI||l instanceof r.cJ)&&(a(l.layers,this.zoom,c),l.addFeatures(x,this.tileID.canonical,j.patternPositions))}return this.status="done",{buckets:Object.values(y).filter((e=>!e.isEmpty())),featureIndex:g,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:O.image,imageAtlas:j,glyphMap:this.returnDependencies?D:null,iconMap:this.returnDependencies?L:null,glyphPositions:this.returnDependencies?O.positions:null}}))}}function a(e,a,l){const c=new r.F(a);for(const r of e)r.recalculate(c,l)}class s{constructor(e,r,a){this.actor=e,this.layerIndex=r,this.availableImages=a,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(e,a){return r._(this,void 0,void 0,(function*(){const l=yield r.n(e.request,a);try{return{vectorTile:new r.cK.VectorTile(new r.cL(l.data)),rawData:l.data,cacheControl:l.cacheControl,expires:l.expires}}catch(r){const a=new Uint8Array(l.data);let c=`Unable to parse the tile at ${e.request.url}, `;throw c+=31===a[0]&&139===a[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${r.message}`,new Error(c)}}))}loadTile(e){return r._(this,void 0,void 0,(function*(){const a=e.uid,l=!!(e&&e.request&&e.request.collectResourceTiming)&&new r.cM(e.request),c=new i(e);this.loading[a]=c;const h=new AbortController;c.abort=h;try{const u=yield this.loadVectorTile(e,h);if(delete this.loading[a],!u)return null;const p=u.rawData,g={};u.expires&&(g.expires=u.expires),u.cacheControl&&(g.cacheControl=u.cacheControl);const y={};if(l){const e=l.finish();e&&(y.resourceTiming=JSON.parse(JSON.stringify(e)))}c.vectorTile=u.vectorTile;const x=c.parse(u.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity);this.loaded[a]=c,this.fetching[a]={rawTileData:p,cacheControl:g,resourceTiming:y};try{const e=yield x;return r.e({rawTileData:p.slice(0)},e,g,y)}finally{delete this.fetching[a]}}catch(e){throw delete this.loading[a],c.status="done",this.loaded[a]=c,e}}))}reloadTile(e){return r._(this,void 0,void 0,(function*(){const a=e.uid;if(!this.loaded||!this.loaded[a])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const l=this.loaded[a];if(l.showCollisionBoxes=e.showCollisionBoxes,l.globalState=e.globalState,"parsing"===l.status){const c=yield l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity);let h;if(this.fetching[a]){const{rawTileData:e,cacheControl:l,resourceTiming:u}=this.fetching[a];delete this.fetching[a],h=r.e({rawTileData:e.slice(0)},c,l,u)}else h=c;return h}if("done"===l.status&&l.vectorTile)return l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity)}))}abortTile(e){return r._(this,void 0,void 0,(function*(){const r=this.loading,a=e.uid;r&&r[a]&&r[a].abort&&(r[a].abort.abort(),delete r[a])}))}removeTile(e){return r._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[e.uid]&&delete this.loaded[e.uid]}))}}class n{constructor(){this.loaded={}}loadTile(e){return r._(this,void 0,void 0,(function*(){const{uid:a,encoding:l,rawImageData:c,redFactor:h,greenFactor:u,blueFactor:p,baseShift:g}=e,y=c.width+2,x=c.height+2,v=r.b(c)?new r.R({width:y,height:x},yield r.cN(c,-1,-1,y,x)):c,w=new r.cO(a,v,l,h,u,p,g);return this.loaded=this.loaded||{},this.loaded[a]=w,w}))}removeTile(e){const r=this.loaded,a=e.uid;r&&r[a]&&delete r[a]}}var l,c,h=function(){if(c)return l;function e(e,a){if(0!==e.length){r(e[0],a);for(var l=1;l=Math.abs(p)?a-g+p:p-g+a,a=g}a+l>=0!=!!r&&e.reverse()}return c=1,l=function r(a,l){var c,h=a&&a.type;if("FeatureCollection"===h)for(c=0;c>31}function C(e,r){for(var a=e.loadGeometry(),l=e.type,c=0,h=0,u=a.length,p=0;pe},A=Math.fround||(k=new Float32Array(1),e=>(k[0]=+e,k[0]));var k;class _{constructor(e){this.options=Object.assign(Object.create(C),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:r,minZoom:a,maxZoom:l}=this.options;r&&console.time("total time");const c=`prepare ${e.length} points`;r&&console.time(c),this.points=e;const h=[];for(let r=0;r=a;e--){const a=+Date.now();u=this.trees[e]=this._createTree(this._cluster(u,e)),r&&console.log("z%d: %d clusters in %dms",e,u.numItems,+Date.now()-a)}return r&&console.timeEnd("total time"),this}getClusters(e,r){let a=((e[0]+180)%360+360)%360-180;const l=Math.max(-90,Math.min(90,e[1]));let c=180===e[2]?180:((e[2]+180)%360+360)%360-180;const h=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)a=-180,c=180;else if(a>c){const e=this.getClusters([a,l,180,h],r),u=this.getClusters([-180,l,c,h],r);return e.concat(u)}const u=this.trees[this._limitZoom(r)],p=u.range(L(a),B(h),L(c),B(l)),g=u.data,y=[];for(const e of p){const r=this.stride*e;y.push(g[r+5]>1?R(g,r,this.clusterProps):this.points[g[r+3]])}return y}getChildren(e){const r=this._getOriginId(e),a=this._getOriginZoom(e),l="No cluster with the specified id.",c=this.trees[a];if(!c)throw new Error(l);const h=c.data;if(r*this.stride>=h.length)throw new Error(l);const u=this.options.radius/(this.options.extent*Math.pow(2,a-1)),p=c.within(h[r*this.stride],h[r*this.stride+1],u),g=[];for(const r of p){const a=r*this.stride;h[a+4]===e&&g.push(h[a+5]>1?R(h,a,this.clusterProps):this.points[h[a+3]])}if(0===g.length)throw new Error(l);return g}getLeaves(e,r,a){const l=[];return this._appendLeaves(l,e,r=r||10,a=a||0,0),l}getTile(e,r,a){const l=this.trees[this._limitZoom(e)],c=Math.pow(2,e),{extent:h,radius:u}=this.options,p=u/h,g=(a-p)/c,y=(a+1+p)/c,x={features:[]};return this._addTileFeatures(l.range((r-p)/c,g,(r+1+p)/c,y),l.data,r,a,c,x),0===r&&this._addTileFeatures(l.range(1-p/c,g,1,y),l.data,c,a,c,x),r===c-1&&this._addTileFeatures(l.range(0,g,p/c,y),l.data,-1,a,c,x),x.features.length?x:null}getClusterExpansionZoom(e){let r=this._getOriginZoom(e)-1;for(;r<=this.options.maxZoom;){const a=this.getChildren(e);if(r++,1!==a.length)break;e=a[0].properties.cluster_id}return r}_appendLeaves(e,r,a,l,c){const h=this.getChildren(r);for(const r of h){const h=r.properties;if(h&&h.cluster?c+h.point_count<=l?c+=h.point_count:c=this._appendLeaves(e,h.cluster_id,a,l,c):c1;let g,y,x;if(p)g=D(r,e,this.clusterProps),y=r[e],x=r[e+1];else{const a=this.points[r[e+3]];g=a.properties;const[l,c]=a.geometry.coordinates;y=L(l),x=B(c)}const v={type:1,geometry:[[Math.round(this.options.extent*(y*c-a)),Math.round(this.options.extent*(x*c-l))]],tags:g};let w;w=p||this.options.generateId?r[e+3]:this.points[r[e+3]].id,void 0!==w&&(v.id=w),h.features.push(v)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,r){const{radius:a,extent:l,reduce:c,minPoints:h}=this.options,u=a/(l*Math.pow(2,r)),p=e.data,g=[],y=this.stride;for(let a=0;ar&&(M+=p[a+5])}if(M>w&&M>=h){let e,h=l*w,u=x*w,C=-1;const A=(a/y<<5)+(r+1)+this.points.length;for(const l of v){const g=l*y;if(p[g+2]<=r)continue;p[g+2]=r;const x=p[g+5];h+=p[g]*x,u+=p[g+1]*x,p[g+4]=A,c&&(e||(e=this._map(p,a,!0),C=this.clusterProps.length,this.clusterProps.push(e)),c(e,this._map(p,g)))}p[a+4]=A,g.push(h/M,u/M,1/0,A,-1,M),c&&g.push(C)}else{for(let e=0;e1)for(const e of v){const a=e*y;if(!(p[a+2]<=r)){p[a+2]=r;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,r,a){if(e[r+5]>1){const l=this.clusterProps[e[r+6]];return a?Object.assign({},l):l}const l=this.points[e[r+3]].properties,c=this.options.map(l);return a&&c===l?Object.assign({},c):c}}function R(e,r,a){return{type:"Feature",id:e[r+3],properties:D(e,r,a),geometry:{type:"Point",coordinates:[(l=e[r],360*(l-.5)),O(e[r+1])]}};var l}function D(e,r,a){const l=e[r+5],c=l>=1e4?`${Math.round(l/1e3)}k`:l>=1e3?Math.round(l/100)/10+"k":l,h=e[r+6],u=-1===h?{}:Object.assign({},a[h]);return Object.assign(u,{cluster:!0,cluster_id:e[r+3],point_count:l,point_count_abbreviated:c})}function L(e){return e/360+.5}function B(e){const r=Math.sin(e*Math.PI/180),a=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return a<0?0:a>1?1:a}function O(e){const r=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}function j(e,r,a,l){let c=l;const h=r+(a-r>>1);let u,p=a-r;const g=e[r],y=e[r+1],x=e[a],v=e[a+1];for(let l=r+3;lc)u=l,c=r;else if(r===c){const e=Math.abs(l-h);el&&(u-r>3&&j(e,r,u,l),e[u+2]=c,a-u>3&&j(e,u,a,l))}function N(e,r,a,l,c,h){let u=c-a,p=h-l;if(0!==u||0!==p){const g=((e-a)*u+(r-l)*p)/(u*u+p*p);g>1?(a=c,l=h):g>0&&(a+=u*g,l+=p*g)}return u=e-a,p=r-l,u*u+p*p}function U(e,r,a,l){const c={id:null==e?null:e,type:r,geometry:a,tags:l,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===r||"MultiPoint"===r||"LineString"===r)Z(c,a);else if("Polygon"===r)Z(c,a[0]);else if("MultiLineString"===r)for(const e of a)Z(c,e);else if("MultiPolygon"===r)for(const e of a)Z(c,e[0]);return c}function Z(e,r){for(let a=0;a0&&(u+=l?(c*g-p*h)/2:Math.sqrt(Math.pow(p-c,2)+Math.pow(g-h,2))),c=p,h=g}const p=r.length-3;r[2]=1,j(r,0,p,a),r[p+2]=1,r.size=Math.abs(u),r.start=0,r.end=r.size}function it(e,r,a,l){for(let c=0;c1?1:a}function st(e,r,a,l,c,h,u,p){if(l/=r,h>=(a/=r)&&u=l)return null;const g=[];for(const r of e){const e=r.geometry;let h=r.type;const u=0===c?r.minX:r.minY,y=0===c?r.maxX:r.maxY;if(u>=a&&y=l)continue;let x=[];if("Point"===h||"MultiPoint"===h)ot(e,x,a,l,c);else if("LineString"===h)at(e,x,a,l,c,!1,p.lineMetrics);else if("MultiLineString"===h)ct(e,x,a,l,c,!1);else if("Polygon"===h)ct(e,x,a,l,c,!0);else if("MultiPolygon"===h)for(const r of e){const e=[];ct(r,e,a,l,c,!0),e.length&&x.push(e)}if(x.length){if(p.lineMetrics&&"LineString"===h){for(const e of x)g.push(U(r.id,h,e,r.tags));continue}"LineString"!==h&&"MultiLineString"!==h||(1===x.length?(h="LineString",x=x[0]):h="MultiLineString"),"Point"!==h&&"MultiPoint"!==h||(h=3===x.length?"Point":"MultiPoint"),g.push(U(r.id,h,x,r.tags))}}return g.length?g:null}function ot(e,r,a,l,c){for(let h=0;h=a&&u<=l&&ht(r,e[h],e[h+1],e[h+2])}}function at(e,r,a,l,c,h,u){let p=lt(e);const g=0===c?ut:yt;let y,x,v=e.start;for(let w=0;wa&&(x=g(p,M,C,k,R,a),u&&(p.start=v+y*x)):D>l?L=a&&(x=g(p,M,C,k,R,a),B=!0),L>l&&D<=l&&(x=g(p,M,C,k,R,l),B=!0),!h&&B&&(u&&(p.end=v+y*x),r.push(p),p=lt(e)),u&&(v+=y)}let w=e.length-3;const M=e[w],C=e[w+1],A=0===c?M:C;A>=a&&A<=l&&ht(p,M,C,e[w+2]),w=p.length-3,h&&w>=3&&(p[w]!==p[0]||p[w+1]!==p[1])&&ht(p,p[0],p[1],p[2]),p.length&&r.push(p)}function lt(e){const r=[];return r.size=e.size,r.start=e.start,r.end=e.end,r}function ct(e,r,a,l,c,h){for(const u of e)at(u,r,a,l,c,h,!1)}function ht(e,r,a,l){e.push(r,a,l)}function ut(e,r,a,l,c,h){const u=(h-r)/(l-r);return ht(e,h,a+(c-a)*u,1),u}function yt(e,r,a,l,c,h){const u=(h-a)/(c-a);return ht(e,r+(l-r)*u,h,1),u}function Pt(e,r){const a=[];for(let l=0;l0&&r.size<(c?u:l))return void(a.numPoints+=r.length/3);const p=[];for(let e=0;eu)&&(a.numSimplified++,p.push(r[e],r[e+1])),a.numPoints++;c&&function(e,r){let a=0;for(let r=0,l=e.length,c=l-2;r0===r)for(let r=0,a=e.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw new Error("promoteId and generateId cannot be used together.");let l=function(e,r){const a=[];if("FeatureCollection"===e.type)for(let l=0;l1&&console.time("creation"),w=this.tiles[v]=kt(e,r,a,l,g),this.tileCoords.push({z:r,x:a,y:l}),y)){y>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,a,l,w.numFeatures,w.numPoints,w.numSimplified),console.timeEnd("creation"));const e=`z${r}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(w.source=e,null==c){if(r===g.indexMaxZoom||w.numPoints<=g.indexMaxPoints)continue}else{if(r===g.maxZoom||r===c)continue;if(null!=c){const e=c-r;if(a!==h>>e||l!==u>>e)continue}}if(w.source=null,0===e.length)continue;y>1&&console.time("clipping");const M=.5*g.buffer/g.extent,C=.5-M,A=.5+M,k=1+M;let R=null,D=null,L=null,B=null,O=st(e,x,a-M,a+A,0,w.minX,w.maxX,g),j=st(e,x,a+C,a+k,0,w.minX,w.maxX,g);e=null,O&&(R=st(O,x,l-M,l+A,1,w.minY,w.maxY,g),D=st(O,x,l+C,l+k,1,w.minY,w.maxY,g),O=null),j&&(L=st(j,x,l-M,l+A,1,w.minY,w.maxY,g),B=st(j,x,l+C,l+k,1,w.minY,w.maxY,g),j=null),y>1&&console.timeEnd("clipping"),p.push(R||[],r+1,2*a,2*l),p.push(D||[],r+1,2*a,2*l+1),p.push(L||[],r+1,2*a+1,2*l),p.push(B||[],r+1,2*a+1,2*l+1)}}getTile(e,r,a){e=+e,r=+r,a=+a;const l=this.options,{extent:c,debug:h}=l;if(e<0||e>24)return null;const u=1<1&&console.log("drilling down to z%d-%d-%d",e,r,a);let g,y=e,x=r,v=a;for(;!g&&y>0;)y--,x>>=1,v>>=1,g=this.tiles[Gt(y,x,v)];return g&&g.source?(h>1&&(console.log("found parent tile z%d-%d-%d",y,x,v),console.time("drilling down")),this.splitTile(g.source,y,x,v,e,r,a),h>1&&console.timeEnd("drilling down"),this.tiles[p]?Ct(this.tiles[p],c):null):null}}function Gt(e,r,a){return 32*((1<{u.properties=e;const r={};for(const e of p)r[e]=l[e].evaluate(h,u);return r},e.reduce=(e,r)=>{u.properties=r;for(const r of p)h.accumulated=e[r],e[r]=c[r].evaluate(h,u)},e}(e)).load((yield this._pendingData).features):(c=yield this._pendingData,new te(c,e.geojsonVtOptions)),this.loaded={};const a={};if(l){const r=l.finish();r&&(a.resourceTiming={},a.resourceTiming[e.source]=JSON.parse(JSON.stringify(r)))}return a}catch(e){if(delete this._pendingRequest,r.cx(e))return{abandoned:!0};throw e}var c}))}getData(){return r._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){const r=this.loaded;return r&&r[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(e,a){return r._(this,void 0,void 0,(function*(){let l=yield this.loadGeoJSON(e,a);if(delete this._pendingRequest,"object"!=typeof l)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(u(l,!0),e.filter){const a=r.cT(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===a.result)throw new Error(a.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const c=l.features.filter((e=>a.value.evaluate({zoom:0},e)));l={type:"FeatureCollection",features:c}}return l}))}loadGeoJSON(e,a){return r._(this,void 0,void 0,(function*(){const{promoteId:l}=e;if(e.request){const c=yield r.j(e.request,a);return this._dataUpdateable=Ht(c.data,l)?Xt(c.data,l):void 0,c.data}if("string"==typeof e.data)try{const r=JSON.parse(e.data);return this._dataUpdateable=Ht(r,l)?Xt(r,l):void 0,r}catch(r){throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`)}if(!e.dataDiff)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${e.source}`);return function(e,r,a){var l,c,h,u;if(r.removeAll&&e.clear(),r.remove)for(const a of r.remove)e.delete(a);if(r.add)for(const l of r.add){const r=qt(l,a);null!=r&&e.set(r,l)}if(r.update)for(const a of r.update){let r=e.get(a.id);if(null==r)continue;const p=!a.removeAllProperties&&((null===(l=a.removeProperties)||void 0===l?void 0:l.length)>0||(null===(c=a.addOrUpdateProperties)||void 0===c?void 0:c.length)>0);if((a.newGeometry||a.removeAllProperties||p)&&(r=Object.assign({},r),e.set(a.id,r),p&&(r.properties=Object.assign({},r.properties))),a.newGeometry&&(r.geometry=a.newGeometry),a.removeAllProperties)r.properties={};else if((null===(h=a.removeProperties)||void 0===h?void 0:h.length)>0)for(const e of a.removeProperties)Object.prototype.hasOwnProperty.call(r.properties,e)&&delete r.properties[e];if((null===(u=a.addOrUpdateProperties)||void 0===u?void 0:u.length)>0)for(const{key:e,value:l}of a.addOrUpdateProperties)r.properties[e]=l}}(this._dataUpdateable,e.dataDiff,l),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(e){return r._(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)}}class ae{constructor(e){this.self=e,this.actor=new r.J(e),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,r)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=r},this.self.addProtocol=r.cz,this.self.removeProtocol=r.cA,this.self.registerRTLTextPlugin=e=>{r.cU.setMethods(e)},this.actor.registerMessageHandler("LDT",((e,r)=>this._getDEMWorkerSource(e,r.source).loadTile(r))),this.actor.registerMessageHandler("RDT",((e,a)=>r._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(e,a.source).removeTile(a)})))),this.actor.registerMessageHandler("GCEZ",((e,a)=>r._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,a.type,a.source).getClusterExpansionZoom(a)})))),this.actor.registerMessageHandler("GCC",((e,a)=>r._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,a.type,a.source).getClusterChildren(a)})))),this.actor.registerMessageHandler("GCL",((e,a)=>r._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,a.type,a.source).getClusterLeaves(a)})))),this.actor.registerMessageHandler("LD",((e,r)=>this._getWorkerSource(e,r.type,r.source).loadData(r))),this.actor.registerMessageHandler("GD",((e,r)=>this._getWorkerSource(e,r.type,r.source).getData())),this.actor.registerMessageHandler("LT",((e,r)=>this._getWorkerSource(e,r.type,r.source).loadTile(r))),this.actor.registerMessageHandler("RT",((e,r)=>this._getWorkerSource(e,r.type,r.source).reloadTile(r))),this.actor.registerMessageHandler("AT",((e,r)=>this._getWorkerSource(e,r.type,r.source).abortTile(r))),this.actor.registerMessageHandler("RMT",((e,r)=>this._getWorkerSource(e,r.type,r.source).removeTile(r))),this.actor.registerMessageHandler("RS",((e,a)=>r._(this,void 0,void 0,(function*(){if(!this.workerSources[e]||!this.workerSources[e][a.type]||!this.workerSources[e][a.type][a.source])return;const r=this.workerSources[e][a.type][a.source];delete this.workerSources[e][a.type][a.source],void 0!==r.removeSource&&r.removeSource(a)})))),this.actor.registerMessageHandler("RM",(e=>r._(this,void 0,void 0,(function*(){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e]})))),this.actor.registerMessageHandler("SR",((e,a)=>r._(this,void 0,void 0,(function*(){this.referrer=a})))),this.actor.registerMessageHandler("SRPS",((e,r)=>this._syncRTLPluginState(e,r))),this.actor.registerMessageHandler("IS",((e,a)=>r._(this,void 0,void 0,(function*(){this.self.importScripts(a)})))),this.actor.registerMessageHandler("SI",((e,r)=>this._setImages(e,r))),this.actor.registerMessageHandler("UL",((e,a)=>r._(this,void 0,void 0,(function*(){this._getLayerIndex(e).update(a.layers,a.removedIds)})))),this.actor.registerMessageHandler("SL",((e,a)=>r._(this,void 0,void 0,(function*(){this._getLayerIndex(e).replace(a)}))))}_setImages(e,a){return r._(this,void 0,void 0,(function*(){this.availableImages[e]=a;for(const r in this.workerSources[e]){const l=this.workerSources[e][r];for(const e in l)l[e].availableImages=a}}))}_syncRTLPluginState(e,a){return r._(this,void 0,void 0,(function*(){return yield r.cU.syncState(a,this.self.importScripts)}))}_getAvailableImages(e){let r=this.availableImages[e];return r||(r=[]),r}_getLayerIndex(e){let r=this.layerIndexes[e];return r||(r=this.layerIndexes[e]=new t),r}_getWorkerSource(e,r,a){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][r]||(this.workerSources[e][r]={}),!this.workerSources[e][r][a]){const l={sendAsync:(r,a)=>(r.targetMapId=e,this.actor.sendAsync(r,a))};switch(r){case"vector":this.workerSources[e][r][a]=new s(l,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][r][a]=new ne(l,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][r][a]=new this.externalWorkerSourceTypes[r](l,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][r][a]}_getDEMWorkerSource(e,r){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][r]||(this.demWorkerSources[e][r]=new n),this.demWorkerSources[e][r]}}return r.i(self)&&(self.worker=new ae(self)),ae}));l("index",["exports","./shared"],(function(r,a){var l="5.6.1";function c(){var e=new a.A(4);return a.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let h,u;const p={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(e,r,l){const c=requestAnimationFrame((e=>{h(),r(e)})),{unsubscribe:h}=a.s(e.signal,"abort",(()=>{h(),cancelAnimationFrame(c),l(a.c())}),!1)},frameAsync(e){return new Promise(((r,a)=>{this.frame(e,r,a)}))},getImageData(e,r=0){return this.getImageCanvasContext(e).getImageData(-r,-r,e.width+2*r,e.height+2*r)},getImageCanvasContext(e){const r=window.document.createElement("canvas"),a=r.getContext("2d",{willReadFrequently:!0});if(!a)throw new Error("failed to create canvas 2d context");return r.width=e.width,r.height=e.height,a.drawImage(e,0,0,e.width,e.height),a},resolveURL:e=>(h||(h=document.createElement("a")),h.href=e,h.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==u&&(u=matchMedia("(prefers-reduced-motion: reduce)")),u.matches)}};class n{static testProp(e){if(!n.docStyle)return e[0];for(let r=0;r{window.removeEventListener("click",n.suppressClickInternal,!0)}),0)}static getScale(e){const r=e.getBoundingClientRect();return{x:r.width/e.offsetWidth||1,y:r.height/e.offsetHeight||1,boundingClientRect:r}}static getPoint(e,r,l){const c=r.boundingClientRect;return new a.P((l.clientX-c.left)/r.x-e.clientLeft,(l.clientY-c.top)/r.y-e.clientTop)}static mousePos(e,r){const a=n.getScale(e);return n.getPoint(e,a,r)}static touchPos(e,r){const a=[],l=n.getScale(e);for(let c=0;c{y&&M(y),y=null,w=!0},x.onerror=()=>{v=!0,y=null},x.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(r){let l,c,h,u;r.resetRequestQueue=()=>{l=[],c=0,h=0,u={}},r.addThrottleControl=e=>{const r=h++;return u[r]=e,r},r.removeThrottleControl=e=>{delete u[e],y()},r.getImage=(e,r,c=!0)=>new Promise(((h,u)=>{g.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),a.e(e,{type:"image"}),l.push({abortController:r,requestParameters:e,supportImageRefresh:c,state:"queued",onError:e=>{u(e)},onSuccess:e=>{h(e)}}),y()}));const p=r=>a._(this||e,void 0,void 0,(function*(){r.state="running";const{requestParameters:e,supportImageRefresh:l,onError:h,onSuccess:u,abortController:p}=r,g=!1===l&&!a.i(self)&&!a.g(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((e,r)=>e&&"accept"===r),!0));c++;const v=g?x(e,p):a.m(e,p);try{const e=yield v;delete r.abortController,r.state="completed",e.data instanceof HTMLImageElement||a.b(e.data)?u(e):e.data&&u({data:yield(w=e.data,"function"==typeof createImageBitmap?a.f(w):a.h(w)),cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete r.abortController,h(e)}finally{c--,y()}var w})),y=()=>{const e=(()=>{for(const e of Object.keys(u))if(u[e]())return!0;return!1})()?a.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:a.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=c;r0;r++){const e=l.shift();e.abortController.signal.aborted?r--:p(e)}},x=(e,r)=>new Promise(((l,c)=>{const h=new Image,u=e.url,p=e.credentials;p&&"include"===p?h.crossOrigin="use-credentials":(p&&"same-origin"===p||!a.d(u))&&(h.crossOrigin="anonymous"),r.signal.addEventListener("abort",(()=>{h.src="",c(a.c())})),h.fetchPriority="high",h.onload=()=>{h.onerror=h.onload=null,l({data:h})},h.onerror=()=>{h.onerror=h.onload=null,r.signal.aborted||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."))},h.src=u}))}(C||(C={})),C.resetRequestQueue();class m{constructor(e){this._transformRequestFn=e}transformRequest(e,r){return this._transformRequestFn&&this._transformRequestFn(e,r)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function A(e){const r=[];if("string"==typeof e)r.push({id:"default",url:e});else if(e&&e.length>0){const a=[];for(const{id:l,url:c}of e){const e=`${l}${c}`;-1===a.indexOf(e)&&(a.push(e),r.push({id:l,url:c}))}}return r}function k(e,r,a){try{const l=new URL(e);return l.pathname+=`${r}${a}`,l.toString()}catch(r){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function R(e){const{userImage:r}=e;return!!(r&&r.render&&r.render())&&(e.data.replace(new Uint8Array(r.data.buffer)),!0)}class b extends a.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.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:r}of this.requestors)r(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const r=this.images[e];if(r&&!r.data&&r.spriteData){const e=r.spriteData;r.data=new a.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),r.spriteData=null}return r}addImage(e,r){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,r)&&(this.images[e]=r)}_validate(e,r){let l=!0;const c=r.data||r.spriteData;return this._validateStretch(r.stretchX,c&&c.width)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "stretchX" value`))),l=!1),this._validateStretch(r.stretchY,c&&c.height)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "stretchY" value`))),l=!1),this._validateContent(r.content,r)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "content" value`))),l=!1),l}_validateStretch(e,r){if(!e)return!0;let a=0;for(const l of e){if(l[0]{let l=!0;if(!this.isLoaded())for(const r of e)this.images[r]||(l=!1);this.isLoaded()||l?r(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:r})}))}_getImagesForIds(e){const r={};for(const l of e){let e=this.getImage(l);e||(this.fire(new a.l("styleimagemissing",{id:l})),e=this.getImage(l)),e?r[l]={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)}:a.w(`Image "${l}" 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 r}getPixelSize(){const{width:e,height:r}=this.atlasImage;return{width:e,height:r}}getPattern(e){const r=this.patterns[e],l=this.getImage(e);if(!l)return null;if(r&&r.position.version===l.version)return r.position;if(r)r.position.version=l.version;else{const r={w:l.data.width+2,h:l.data.height+2,x:0,y:0},c=new a.I(r,l);this.patterns[e]={bin:r,position:c}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const r=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new a.T(e,this.atlasImage,r.RGBA),this.atlasTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const r in this.patterns)e.push(this.patterns[r].bin);const{w:r,h:l}=a.p(e),c=this.atlasImage;c.resize({width:r||1,height:l||1});for(const e in this.patterns){const{bin:r}=this.patterns[e],l=r.x+1,h=r.y+1,u=this.getImage(e).data,p=u.width,g=u.height;a.R.copy(u,c,{x:0,y:0},{x:l,y:h},{width:p,height:g}),a.R.copy(u,c,{x:0,y:g-1},{x:l,y:h-1},{width:p,height:1}),a.R.copy(u,c,{x:0,y:0},{x:l,y:h+g},{width:p,height:1}),a.R.copy(u,c,{x:p-1,y:0},{x:l-1,y:h},{width:1,height:g}),a.R.copy(u,c,{x:0,y:0},{x:l+p,y:h},{width:1,height:g})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const r of e){if(this.callbackDispatchedThisFrame[r])continue;this.callbackDispatchedThisFrame[r]=!0;const e=this.getImage(r);e||a.w(`Image with ID: "${r}" was not found`),R(e)&&this.updateImage(r,e)}}}const D=1e20;function L(e,r,a,l,c,h,u,p,g){for(let y=r;y-1);g++,h[g]=p,u[g]=y,u[g+1]=D}for(let p=0,g=0;p65535)throw new Error("glyphs > 65535 not supported");if(a.ranges[c])return{stack:e,id:r,glyph:l};if(!this.url)throw new Error("glyphsUrl is not set");if(!a.requests[c]){const r=T.loadGlyphRange(e,c,this.url,this.requestManager);a.requests[c]=r}const h=yield a.requests[c];for(const e in h)this._doesCharSupportLocalGlyph(+e)||(a.glyphs[+e]=h[+e]);return a.ranges[c]=!0,{stack:e,id:r,glyph:h[r]||null}}))}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))||a.u["CJK Unified Ideographs"](e)||a.u["Hangul Syllables"](e)||a.u.Hiragana(e)||a.u.Katakana(e)||a.u["CJK Symbols and Punctuation"](e)||a.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,r,l){const c=this.localIdeographFontFamily;if(!c)return;if(!this._doesCharSupportLocalGlyph(l))return;let h=e.tinySDF;if(!h){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),h=e.tinySDF=new T.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:c,fontWeight:a})}const u=h.draw(String.fromCharCode(l));return{id:l,bitmap:new a.q({width:u.width||60,height:u.height||60},u.data),metrics:{width:u.glyphWidth/2||24,height:u.glyphHeight/2||24,left:u.glyphLeft/2+.5||0,top:u.glyphTop/2-27.5||-8,advance:u.glyphAdvance/2||24,isDoubleResolution:!0}}}}T.loadGlyphRange=function(r,l,c,h){return a._(this||e,void 0,void 0,(function*(){const e=256*l,u=e+255,p=h.transformRequest(c.replace("{fontstack}",r).replace("{range}",`${e}-${u}`),"Glyphs"),g=yield a.n(p,new AbortController);if(!g||!g.data)throw new Error(`Could not load glyph range. range: ${l}, ${e}-${u}`);const y={};for(const e of a.o(g.data))y[e.id]=e;return y}))},T.TinySDF=class{constructor({fontSize:e=24,buffer:r=3,radius:a=8,cutoff:l=.25,fontFamily:c="sans-serif",fontWeight:h="normal",fontStyle:u="normal"}={}){this.buffer=r,this.cutoff=l,this.radius=a;const p=this.size=e+4*r,g=this._createCanvas(p),y=this.ctx=g.getContext("2d",{willReadFrequently:!0});y.font=`${u} ${h} ${e}px ${c}`,y.textBaseline="alphabetic",y.textAlign="left",y.fillStyle="black",this.gridOuter=new Float64Array(p*p),this.gridInner=new Float64Array(p*p),this.f=new Float64Array(p),this.z=new Float64Array(p+1),this.v=new Uint16Array(p)}_createCanvas(e){const r=document.createElement("canvas");return r.width=r.height=e,r}draw(e){const{width:r,actualBoundingBoxAscent:a,actualBoundingBoxDescent:l,actualBoundingBoxLeft:c,actualBoundingBoxRight:h}=this.ctx.measureText(e),u=Math.ceil(a),p=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(h-c))),g=Math.min(this.size-this.buffer,u+Math.ceil(l)),y=p+2*this.buffer,x=g+2*this.buffer,v=Math.max(y*x,0),w=new Uint8ClampedArray(v),M={data:w,width:y,height:x,glyphWidth:p,glyphHeight:g,glyphTop:u,glyphLeft:0,glyphAdvance:r};if(0===p||0===g)return M;const{ctx:C,buffer:A,gridInner:k,gridOuter:R}=this;C.clearRect(A,A,p,g),C.fillText(e,A,A+u);const B=C.getImageData(A,A,p,g);R.fill(D,0,v),k.fill(0,0,v);for(let e=0;e0?e*e:0,k[l]=e<0?e*e:0}}L(R,0,0,y,x,y,this.f,this.v,this.z),L(k,A,A,p,g,y,this.f,this.v,this.z);for(let e=0;e1&&(u=e[++h]);const g=Math.abs(p-u.left),y=Math.abs(p-u.right),x=Math.min(g,y);let v;const w=r/a*(l+1);if(u.isDash){const e=l-Math.abs(w);v=Math.sqrt(x*x+e*e)}else v=l-Math.sqrt(x*x+w*w);this.data[c+p]=Math.max(0,Math.min(255,v+128))}}}addRegularDash(e){for(let r=e.length-1;r>=0;--r){const a=e[r],l=e[r+1];a.zeroLength?e.splice(r,1):l&&l.isDash===a.isDash&&(l.left=a.left,e.splice(r,1))}const r=e[0],a=e[e.length-1];r.isDash===a.isDash&&(r.left=a.left-this.width,a.right=r.right+this.width);const l=this.width*this.nextRow;let c=0,h=e[c];for(let r=0;r1&&(h=e[++c]);const a=Math.abs(r-h.left),u=Math.abs(r-h.right),p=Math.min(a,u);this.data[l+r]=Math.max(0,Math.min(255,(h.isDash?p:-p)+128))}}addDash(e,r){const l=r?7:0,c=2*l+1;if(this.nextRow+c>this.height)return a.w("LineAtlas out of space"),null;let h=0;for(let r=0;r{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[N]}numActive(){return Object.keys(this.active).length}}const U=Math.floor(p.hardwareConcurrency/2);let Z,J;function Q(){return Z||(Z=new z),Z}z.workerCount=a.H(globalThis)?Math.max(Math.min(U,3),1):1;class F{constructor(e,r){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=r;const l=this.workerPool.acquire(r);for(let e=0;e{e.remove()})),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,r){for(const a of this.actors)a.registerMessageHandler(e,r)}}function et(){return J||(J=new F(Q(),a.K),J.registerMessageHandler("GR",((e,r,l)=>a.m(r,l)))),J}function it(e,r){const l=a.L();return a.M(l,l,[1,1,0]),a.N(l,l,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?a.O(l,l,e.calculatePosMatrix(r.toUnwrapped())):l}function rt(e,r,a,l,c,h,u){var p;const g=function(e,r,a){if(e)for(const l of e){const e=r[l];if(e&&e.source===a&&"fill-extrusion"===e.type)return!0}else for(const e in r){const l=r[e];if(l.source===a&&"fill-extrusion"===l.type)return!0}return!1}(null!==(p=null==c?void 0:c.layers)&&void 0!==p?p:null,r,e.id),y=h.maxPitchScaleFactor(),x=e.tilesIn(l,y,g);x.sort(nt);const v=[];for(const l of x)v.push({wrappedTileID:l.tileID.wrapped().key,queryResults:l.tile.queryRenderedFeatures(r,a,e._state,l.queryGeometry,l.cameraQueryGeometry,l.scale,c,h,y,it(e.transform,l.tileID),u?(e,r)=>u(l.tileID,e,r):void 0)});return function(e,r){for(const a in e)for(const l of e[a])st(l,r);return e}(function(e){const r={},a={};for(const l of e){const e=l.queryResults,c=l.wrappedTileID,h=a[c]=a[c]||{};for(const a in e){const l=e[a],c=h[a]=h[a]||{},u=r[a]=r[a]||[];for(const e of l)c[e.featureIndex]||(c[e.featureIndex]=!0,u.push(e))}}return r}(v),e)}function nt(e,r){const a=e.tileID,l=r.tileID;return a.overscaledZ-l.overscaledZ||a.canonical.y-l.canonical.y||a.wrap-l.wrap||a.canonical.x-l.canonical.x}function st(e,r){const a=e.feature,l=r.getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=l}function ot(r,l,c){return a._(this||e,void 0,void 0,(function*(){let e=r;if(r.url?e=(yield a.j(l.transformRequest(r.url,"Source"),c)).data:yield p.frameAsync(c),!e)return null;const h=a.Q(a.e(e,r),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in e&&e.vector_layers&&(h.vectorLayerIds=e.vector_layers.map((e=>e.id))),h}))}class G{constructor(e,r){e&&(r?this.setSouthWest(e).setNorthEast(r):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 a.S?new a.S(e.lng,e.lat):a.S.convert(e),this}setSouthWest(e){return this._sw=e instanceof a.S?new a.S(e.lng,e.lat):a.S.convert(e),this}extend(e){const r=this._sw,l=this._ne;let c,h;if(e instanceof a.S)c=e,h=e;else{if(!(e instanceof G))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(G.convert(e)):this.extend(a.S.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(a.S.convert(e)):this;if(c=e._sw,h=e._ne,!c||!h)return this}return r||l?(r.lng=Math.min(c.lng,r.lng),r.lat=Math.min(c.lat,r.lat),l.lng=Math.max(h.lng,l.lng),l.lat=Math.max(h.lat,l.lat)):(this._sw=new a.S(c.lng,c.lat),this._ne=new a.S(h.lng,h.lat)),this}getCenter(){return new a.S((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 a.S(this.getWest(),this.getNorth())}getSouthEast(){return new a.S(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:r,lat:l}=a.S.convert(e);let c=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=l&&l<=this._ne.lat&&c}static convert(e){return e instanceof G?e:e?new G(e):e}static fromLngLat(e,r=0){const l=360*r/40075017,c=l/Math.cos(Math.PI/180*e.lat);return new G(new a.S(e.lng-c,e.lat-l),new a.S(e.lng+c,e.lat+l))}adjustAntiMeridian(){const e=new a.S(this._sw.lng,this._sw.lat),r=new a.S(this._ne.lng,this._ne.lat);return new G(e,e.lng>r.lng?new a.S(r.lng+360,r.lat):r)}}class V{constructor(e,r,a){this.bounds=G.convert(this.validateBounds(e)),this.minzoom=r||0,this.maxzoom=a||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 r=Math.pow(2,e.z),l=Math.floor(a.V(this.bounds.getWest())*r),c=Math.floor(a.U(this.bounds.getNorth())*r),h=Math.ceil(a.V(this.bounds.getEast())*r),u=Math.ceil(a.U(this.bounds.getSouth())*r);return e.x>=l&&e.x=c&&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 a.e({},this._options)}loadTile(e){return a._(this,void 0,void 0,(function*(){const r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a={request:this.map._requestManager.transformRequest(r,"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,globalState:this.map.getGlobalState()};a.request.collectResourceTiming=this._collectResourceTiming;let l="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((r,a)=>{e.reloadPromise={resolve:r,reject:a}}))}else e.actor=this.dispatcher.getActor(),l="LT";e.abortController=new AbortController;try{const r=yield e.actor.sendAsync({type:l,data:a},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,r)}catch(r){if(delete e.abortController,e.aborted)return;if(r&&404!==r.status)throw r;this._afterTileLoadWorkerResponse(e,null)}}))}_afterTileLoadWorkerResponse(e,r){if(r&&r.resourceTiming&&(e.resourceTiming=r.resourceTiming),r&&this.map._refreshExpiredTiles&&e.setExpiryData(r),e.loadVectorData(r,this.map.painter),e.reloadPromise){const r=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(r.resolve).catch(r.reject)}}abortTile(e){return a._(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 a._(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 q extends a.E{constructor(e,r,l,c){super(),this.id=e,this.dispatcher=l,this.setEventedParent(c),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=a.e({type:"raster"},r),a.e(this,a.Q(r,["url","scheme","tileSize"]))}load(){return a._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new a.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const r=yield ot(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,r&&(a.e(this,r),r.bounds&&(this.tileBounds=new V(r.bounds,this.minzoom,this.maxzoom)),this.fire(new a.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this.fire(new a.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 a.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return a._(this,void 0,void 0,(function*(){const r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const l=yield C.getImage(this.map._requestManager.transformRequest(r,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(l&&l.data){this.map._refreshExpiredTiles&&(l.cacheControl||l.expires)&&e.setExpiryData({cacheControl:l.cacheControl,expires:l.expires});const r=this.map.painter.context,c=r.gl,h=l.data;e.texture=this.map.painter.getTileTexture(h.width),e.texture?e.texture.update(h,{useMipmap:!0}):(e.texture=new a.T(r,h,c.RGBA,{useMipmap:!0}),e.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE,c.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(r){if(delete e.abortController,e.aborted)e.state="unloaded";else if(r)throw e.state="errored",r}}))}abortTile(e){return a._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return a._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class W extends q{constructor(e,r,l,c){super(e,r,l,c),this.type="raster-dem",this.maxzoom=22,this._options=a.e({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox",this.redFactor=r.redFactor,this.greenFactor=r.greenFactor,this.blueFactor=r.blueFactor,this.baseShift=r.baseShift}loadTile(e){return a._(this,void 0,void 0,(function*(){const r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),l=this.map._requestManager.transformRequest(r,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const r=yield C.getImage(l,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(r&&r.data){const l=r.data;this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&e.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});const c=a.b(l)&&a.W()?l:yield this.readImageNow(l),h={type:this.type,uid:e.uid,source:this.id,rawImageData:c,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 r=yield e.actor.sendAsync({type:"LDT",data:h});e.dem=r,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(r){if(delete e.abortController,e.aborted)e.state="unloaded";else if(r)throw e.state="errored",r}}))}readImageNow(e){return a._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&a.X()){const r=e.width+2,l=e.height+2;try{return new a.R({width:r,height:l},yield a.Y(e,-1,-1,r,l))}catch(e){}}return p.getImageData(e,1)}))}_getNeighboringTiles(e){const r=e.canonical,l=Math.pow(2,r.z),c=(r.x-1+l)%l,h=0===r.x?e.wrap-1:e.wrap,u=(r.x+1+l)%l,p=r.x+1===l?e.wrap+1:e.wrap,g={};return g[new a.Z(e.overscaledZ,h,r.z,c,r.y).key]={backfilled:!1},g[new a.Z(e.overscaledZ,p,r.z,u,r.y).key]={backfilled:!1},r.y>0&&(g[new a.Z(e.overscaledZ,h,r.z,c,r.y-1).key]={backfilled:!1},g[new a.Z(e.overscaledZ,e.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},g[new a.Z(e.overscaledZ,p,r.z,u,r.y-1).key]={backfilled:!1}),r.y+1e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return a._(this,void 0,void 0,(function*(){const e=new G,r=yield this.getData();let a;switch(r.type){case"FeatureCollection":a=r.features.map((e=>this.getCoordinatesFromGeometry(e.geometry))).flat(1/0);break;case"Feature":a=this.getCoordinatesFromGeometry(r.geometry);break;default:a=this.getCoordinatesFromGeometry(r)}if(0==a.length)return e;for(let r=0;r0&&a.e(c,{resourceTiming:l}),this.fire(new a.l("data",Object.assign(Object.assign({},c),{sourceDataType:"metadata"}))),this.fire(new a.l("data",Object.assign(Object.assign({},c),{sourceDataType:"content"})))}catch(e){if(this._pendingLoads--,this._removed)return void this.fire(new a.l("dataabort",{dataType:"source"}));this.fire(new a.k(e))}}))}loaded(){return 0===this._pendingLoads}loadTile(e){return a._(this,void 0,void 0,(function*(){const r=e.actor?"RT":"LT";e.actor=this.actor;const a={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,globalState:this.map.getGlobalState()};e.abortController=new AbortController;const l=yield this.actor.sendAsync({type:r,data:a},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(l,this.map.painter,"RT"===r)}))}abortTile(e){return a._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return a._(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 a.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class X extends a.E{constructor(e,r,a,l){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=a,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(l),this.options=r}load(e){return a._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new a.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const r=yield C.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,r&&r.data&&(this.image=r.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,this.fire(new a.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 a.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 r=e.map(a.a0.fromLngLat);var l;return this.tileID=function(e){const r=a.a1.fromPoints(e),l=r.width(),c=r.height(),h=Math.max(l,c),u=Math.max(0,Math.floor(-Math.log(h)/Math.LN2)),p=Math.pow(2,u);return new a.a3(u,Math.floor((r.minX+r.maxX)/2*p),Math.floor((r.minY+r.maxY)/2*p))}(r),this.terrainTileRanges=this._getOverlappingTileRanges(r),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=r.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((l=this.tileCoords)[1].x-l[0].x)*(l[2].y-l[0].y)-(l[1].y-l[0].y)*(l[2].x-l[0].x)<0,this.fire(new a.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,r=e.gl;this.texture||(this.texture=new a.T(e,this.image,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let l=!1;for(const e in this.tiles){const r=this.tiles[e];"loaded"!==r.state&&(r.state="loaded",r.texture=this.texture,l=!0)}l&&this.fire(new a.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return a._(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:r,minY:l,maxX:c,maxY:h}=a.a1.fromPoints(e),u={};for(let e=0;e<=a.a2;e++){const a=Math.pow(2,e),p=Math.floor(r*a),g=Math.floor(l*a),y=Math.floor(c*a),x=Math.floor(h*a);u[e]={minTileX:p,minTileY:g,maxTileX:y,maxTileY:x}}return u}}class K extends X{constructor(e,r,a,l){super(e,r,a,l),this.roundZoom=!0,this.type="video",this.options=r}load(){return a._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const r of e.urls)this.urls.push(this.map._requestManager.transformRequest(r,"Source").url);try{const e=yield a.a4(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 a.k(e))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const r=this.video.seekable;er.end(0)?this.fire(new a.k(new a.a5(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.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,r=e.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new a.T(e,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let l=!1;for(const e in this.tiles){const r=this.tiles[e];"loaded"!==r.state&&(r.state="loaded",r.texture=this.texture,l=!0)}l&&this.fire(new a.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 Y extends X{constructor(e,r,l,c){super(e,r,l,c),r.coordinates?Array.isArray(r.coordinates)&&4===r.coordinates.length&&!r.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new a.k(new a.a5(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.k(new a.a5(`sources.${e}`,null,'missing required property "coordinates"'))),r.animate&&"boolean"!=typeof r.animate&&this.fire(new a.k(new a.a5(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),r.canvas?"string"==typeof r.canvas||r.canvas instanceof HTMLCanvasElement||this.fire(new a.k(new a.a5(`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 a.k(new a.a5(`sources.${e}`,null,'missing required property "canvas"'))),this.options=r,this.animate=void 0===r.animate||r.animate}load(){return a._(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 a.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 r=this.map.painter.context,l=r.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.T(r,this.canvas,l.RGBA,{premultiply:!0});let c=!1;for(const e in this.tiles){const r=this.tiles[e];"loaded"!==r.state&&(r.state="loaded",r.texture=this.texture,c=!0)}c&&this.fire(new a.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"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 at={},lt=e=>{switch(e){case"geojson":return H;case"image":return X;case"raster":return q;case"raster-dem":return W;case"vector":return $;case"video":return K;case"canvas":return Y}return at[e]},ct="RTLPluginLoaded";class te extends a.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=et()}_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 a._(this,arguments,void 0,(function*(e,r=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=p.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!r)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return a._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new a.l(ct))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let ht=null;function ut(){return ht||(ht=new te),ht}class re{constructor(e,r){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=a.a6(),this.uses=0,this.tileSize=r,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"}registerFadeDuration(e){const r=e+this.timeAdded;rr.getLayer(e))).filter(Boolean);if(0!==e.length){l.layers=e,l.stateDependentLayerIds&&(l.stateDependentLayers=l.stateDependentLayerIds.map((r=>e.filter((e=>e.id===r))[0])));for(const r of e)a[r.id]=l}}return a}(e.buckets,null==r?void 0:r.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const r=this.buckets[e];if(r instanceof a.a8){if(this.hasSymbolBuckets=!0,!l)break;r.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const r=this.buckets[e];if(r instanceof a.a8&&r.hasRTLText){this.hasRTLText=!0,ut().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const a=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(e).queryRadius(a))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new a.a7}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.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const r in this.buckets){const a=this.buckets[r];a.uploadPending()&&a.upload(e)}const r=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new a.T(e,this.imageAtlas.image,r.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new a.T(e,this.glyphAtlasImage,r.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,r,a,l,c,h,u,p,g,y,x){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:l,cameraQueryGeometry:c,scale:h,tileSize:this.tileSize,pixelPosMatrix:y,transform:p,params:u,queryPadding:this.queryPadding*g,getElevation:x},e,r,a):{}}querySourceFeatures(e,r){const l=this.latestFeatureIndex;if(!l||!l.rawTileData)return;const c=l.loadVTLayers(),h=r&&r.sourceLayer?r.sourceLayer:"",u=c._geojsonTileLayer||c[h];if(!u)return;const p=a.a9(r&&r.filter),{z:g,x:y,y:x}=this.tileID.canonical,v={z:g,x:y,y:x};for(let r=0;re)a=!1;else if(r)if(this.expirationTime{this.remove(e,c)}),a)),this.data[l].push(c),this.order.push(l),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 r=this.data[e].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),r.value}getByKey(e){const r=this.data[e];return r?r[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,r){if(!this.has(e))return this;const a=e.wrapped().key,l=void 0===r?0:this.data[a].indexOf(r),c=this.data[a][l];return this.data[a].splice(l,1),c.timeout&&clearTimeout(c.timeout),0===this.data[a].length&&delete this.data[a],this.onRemove(c.value),this.order.splice(this.order.indexOf(a),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 r=[];for(const a in this.data)for(const l of this.data[a])e(l.value)||r.push(l);for(const e of r)this.remove(e.value.tileID,e)}}class se{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,r,l){const c=String(r);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][c]=this.stateChanges[e][c]||{},a.e(this.stateChanges[e][c],l),null===this.deletedStates[e]){this.deletedStates[e]={};for(const r in this.state[e])r!==c&&(this.deletedStates[e][r]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][c]){this.deletedStates[e][c]={};for(const r in this.state[e][c])l[r]||(this.deletedStates[e][c][r]=null)}else for(const r in l)this.deletedStates[e]&&this.deletedStates[e][c]&&null===this.deletedStates[e][c][r]&&delete this.deletedStates[e][c][r]}removeFeatureState(e,r,a){if(null===this.deletedStates[e])return;const l=String(r);if(this.deletedStates[e]=this.deletedStates[e]||{},a&&void 0!==r)null!==this.deletedStates[e][l]&&(this.deletedStates[e][l]=this.deletedStates[e][l]||{},this.deletedStates[e][l][a]=null);else if(void 0!==r)if(this.stateChanges[e]&&this.stateChanges[e][l])for(a in this.deletedStates[e][l]={},this.stateChanges[e][l])this.deletedStates[e][l][a]=null;else this.deletedStates[e][l]=null;else this.deletedStates[e]=null}getState(e,r){const l=String(r),c=a.e({},(this.state[e]||{})[l],(this.stateChanges[e]||{})[l]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const a=this.deletedStates[e][r];if(null===a)return{};for(const e in a)delete c[e]}return c}initializeTileState(e,r){e.setFeatureState(this.state,r)}coalesceChanges(e,r){const l={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const r={};for(const l in this.stateChanges[e])this.state[e][l]||(this.state[e][l]={}),a.e(this.state[e][l],this.stateChanges[e][l]),r[l]=this.state[e][l];l[e]=r}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const r={};if(null===this.deletedStates[e])for(const a in this.state[e])r[a]={},this.state[e][a]={};else for(const a in this.deletedStates[e]){if(null===this.deletedStates[e][a])this.state[e][a]={};else for(const r of Object.keys(this.deletedStates[e][a]))delete this.state[e][a][r];r[a]=this.state[e][a]}l[e]=l[e]||{},a.e(l[e],r)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(l).length)for(const a in e)e[a].setFeatureState(l,r)}}const yt=89.25;function Pt(e,r){const l=a.ag(r.lat,-a.ah,a.ah);return new a.P(a.V(r.lng)*e,a.U(l)*e)}function St(e,r){return new a.a0(r.x/e,r.y/e).toLngLat()}function Ct(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(a.ad(90-e.pitch)),Math.tan(a.ad(yt-e.pitch)))}function Et(e,r){const l=e.canonical,c=r/a.ae(l.z),h=l.x+Math.pow(2,l.z)*e.wrap,u=a.af(new Float64Array(16));return a.M(u,u,[h*c,l.y*c,0]),a.N(u,u,[c/a.$,c/a.$,1]),u}function kt(e,r,l,c,h){const u=a.a0.fromLngLat(e,r),p=h*a.ai(1,e.lat),g=p*Math.cos(a.ad(l)),y=Math.sqrt(p*p-g*g),x=y*Math.sin(a.ad(-c)),v=y*Math.cos(a.ad(-c));return new a.a0(u.x+x,u.y+v,u.z+g)}function Bt(e,r,a){const l=r.intersectsFrustum(e);if(!a||0===l)return l;const c=r.intersectsPlane(a);return 0===c?0:2===l&&2===c?2:1}function Nt(e,r,a){let l=0;const c=(a-r)/10;for(let h=0;h<10;h++)l+=c*Math.pow(Math.cos(r+(h+.5)/10*(a-r)),e);return l}function $t(e,r){return function(l,c,h,u,p){const g=2*((e-1)/a.aj(Math.cos(a.ad(yt-p))/Math.cos(a.ad(yt)))-1),y=Math.acos(h/u),x=2*Nt(g-1,0,a.ad(p/2)),v=Math.min(a.ad(yt),y+a.ad(p/2)),w=Nt(g-1,Math.min(v,y-a.ad(p/2)),v),M=Math.atan(c/h),C=Math.hypot(c,h);let A=l;return A+=a.aj(u/C/Math.max(.5,Math.cos(a.ad(p/2)))),A+=g*a.aj(Math.cos(M))/2,A-=a.aj(Math.max(1,w/x/r))/2,A}}const Gt=$t(9.314,3);function qt(e,r){const l=(r.roundZoom?Math.round:Math.floor)(e.zoom+a.aj(e.tileSize/r.tileSize));return Math.max(0,l)}function Ht(e,r){const l=e.getCameraFrustum(),c=e.getClippingPlane(),h=e.screenPointToMercatorCoordinate(e.getCameraPoint()),u=a.a0.fromLngLat(e.center,e.elevation);h.z=u.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const p=e.getCoveringTilesDetailsProvider(),g=p.allowVariableZoom(e,r),y=qt(e,r),x=r.minzoom||0,v=void 0!==r.maxzoom?r.maxzoom:e.maxZoom,w=Math.min(Math.max(0,y),v),M=Math.pow(2,w),C=[M*h.x,M*h.y,0],A=[M*u.x,M*u.y,0],k=Math.hypot(u.x-h.x,u.y-h.y),R=Math.abs(u.z-h.z),D=Math.hypot(k,R),L=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),B=[],O=[];if(e.renderWorldCopies&&p.allowWorldCopies())for(let e=1;e<=3;e++)B.push(L(-e)),B.push(L(e));for(B.push(L(0));B.length>0;){const M=B.pop(),k=M.x,L=M.y;let j=M.fullyVisible;const N={x:k,y:L,z:M.zoom},U=p.getTileBoundingVolume(N,M.wrap,e.elevation,r);if(!j){const e=Bt(l,U,c);if(0===e)continue;j=2===e}const Z=p.distanceToTile2d(h.x,h.y,N,U);let J=y;g&&(J=(r.calculateTileZoom||Gt)(e.zoom+a.aj(e.tileSize/r.tileSize),Z,R,D,e.fov)),J=(r.roundZoom?Math.round:Math.floor)(J),J=Math.max(0,J);const Q=Math.min(J,v);if(M.wrap=p.getWrap(u,N,M.wrap),M.zoom>=Q){if(M.zoom>1),wrap:M.wrap,fullyVisible:j})}return O.sort(((e,r)=>e.distanceSq-r.distanceSq)).map((e=>e.tileID))}const Xt=a.a1.fromPoints([new a.P(0,0),new a.P(a.$,a.$)]);class xe extends a.E{constructor(e,r,a){super(),this.id=e,this.dispatcher=a,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((e,r,a,l)=>{const c=new(lt(r.type))(e,r,a,l);if(c.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${c.id}`);return c})(e,r,a,this),this._tiles={},this._cache=new ae(0,(e=>this._unloadTile(e))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new se,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){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}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 in this._tiles){const r=this._tiles[e];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}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,r,l){return a._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,r,l)}catch(r){e.state="errored",404!==r.status?this._source.fire(new a.k(r,{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 a.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._tiles,this.map?this.map.painter:null);for(const r in this._tiles){const a=this._tiles[r];a.upload(e),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(Kt).map((e=>e.key))}getRenderableIds(e){const r=[];for(const a in this._tiles)this._isIdRenderable(a,e)&&r.push(this._tiles[a]);return e?r.sort(((e,r)=>{const l=e.tileID,c=r.tileID,h=new a.P(l.canonical.x,l.canonical.y)._rotate(-this.transform.bearingInRadians),u=new a.P(c.canonical.x,c.canonical.y)._rotate(-this.transform.bearingInRadians);return l.overscaledZ-c.overscaledZ||u.y-h.y||u.x-h.x})).map((e=>e.tileID.key)):r.map((e=>e.tileID)).sort(Kt).map((e=>e.key))}hasRenderableParent(e){const r=this.findLoadedParent(e,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(e,r){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(r||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const r in this._tiles)e?this._reloadTile(r,"expired"):"errored"!==this._tiles[r].state&&this._reloadTile(r,"reloading")}}_reloadTile(e,r){return a._(this,void 0,void 0,(function*(){const a=this._tiles[e];a&&("loading"!==a.state&&(a.state=r),yield this._loadTile(a,e,r))}))}_tileLoaded(e,r,l){e.timeAdded=p.now(),"expired"===l&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(r,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new a.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const r=this.getRenderableIds();for(let l=0;l1||(Math.abs(a)>1&&(1===Math.abs(a+c)?a+=c:1===Math.abs(a-c)&&(a-=c)),r.dem&&e.dem&&(e.dem.backfillBorder(r.dem,a,l),e.neighboringTiles&&e.neighboringTiles[h]&&(e.neighboringTiles[h].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,r,a,l){for(const c in this._tiles){let h=this._tiles[c];if(l[c]||!h.hasData()||h.tileID.overscaledZ<=r||h.tileID.overscaledZ>a)continue;let u=h.tileID;for(;h&&h.tileID.overscaledZ>r+1;){const e=h.tileID.scaledTo(h.tileID.overscaledZ-1);h=this._tiles[e.key],h&&h.hasData()&&(u=e)}let p=u;for(;p.overscaledZ>r;)if(p=p.scaledTo(p.overscaledZ-1),e[p.key]||e[p.canonical.key]){l[u.key]=u;break}}}findLoadedParent(e,r){if(e.key in this._loadedParentTiles){const a=this._loadedParentTiles[e.key];return a&&a.tileID.overscaledZ>=r?a:null}for(let a=e.overscaledZ-1;a>=r;a--){const r=e.scaledTo(a),l=this._getLoadedTile(r);if(l)return l}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const r=this._tiles[e.key];return r&&r.hasData()?r:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const r=Math.ceil(e.width/this._source.tileSize)+1,l=Math.ceil(e.height/this._source.tileSize)+1,c=Math.floor(r*l*(null===this._maxTileCacheZoomLevels?a.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),h="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,c):c;this._cache.setMaxSize(h)}handleWrapJump(e){const r=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,r){const e={};for(const a in this._tiles){const l=this._tiles[a];l.tileID=l.tileID.unwrapTo(l.tileID.wrap+r),e[l.tileID.key]=l}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e])}}_updateCoveredAndRetainedTiles(e,r,a,l,c,h){const u={},g={},y=Object.keys(e),x=p.now();for(const a of y){const l=e[a],c=this._tiles[a];if(!c||0!==c.fadeEndTime&&c.fadeEndTime<=x)continue;const h=this.findLoadedParent(l,r),p=this.findLoadedSibling(l),y=h||p||null;y&&(this._addTile(y.tileID),u[y.tileID.key]=y.tileID),g[a]=l}this._retainLoadedChildren(g,l,a,e);for(const r in u)e[r]||(this._coveredTiles[r]=!0,e[r]=u[r]);if(h){const r={},a={};for(const e of c)this._tiles[e.key].hasData()?r[e.key]=e:a[e.key]=e;for(const l in a){const c=a[l].children(this._source.maxzoom);this._tiles[c[0].key]&&this._tiles[c[1].key]&&this._tiles[c[2].key]&&this._tiles[c[3].key]&&(r[c[0].key]=e[c[0].key]=c[0],r[c[1].key]=e[c[1].key]=c[1],r[c[2].key]=e[c[2].key]=c[2],r[c[3].key]=e[c[3].key]=c[3],delete a[l])}for(const l in a){const c=a[l],h=this.findLoadedParent(c,this._source.minzoom),u=this.findLoadedSibling(c),p=h||u||null;if(p){r[p.tileID.key]=e[p.tileID.key]=p.tileID;for(const e in r)r[e].isChildOf(p.tileID)&&delete r[e]}}for(const e in this._tiles)r[e]||(this._coveredTiles[e]=!0)}}update(e,r){if(!this._sourceLoaded||this._paused)return;let l;this.transform=e,this.terrain=r,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?l=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new a.Z(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(l=Ht(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:r,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(l=l.filter((e=>this._source.hasTile(e))))):l=[];const c=qt(e,this._source),h=Math.max(c-xe.maxOverzooming,this._source.minzoom),u=Math.max(c+xe.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const e={};for(const r of l)if(r.canonical.z>this._source.minzoom){const a=r.scaledTo(r.canonical.z-1);e[a.key]=a;const l=r.scaledTo(Math.max(this._source.minzoom,Math.min(r.canonical.z,5)));e[l.key]=l}l=l.concat(Object.values(e))}const p=0===l.length&&!this._updated&&this._didEmitContent;this._updated=!0,p&&this.fire(new a.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const g=this._updateRetainedTiles(l,c);Qt(this._source.type)&&this._updateCoveredAndRetainedTiles(g,h,u,c,l,r);for(const e in g)this._tiles[e].clearFadeHold();const y=a.al(this._tiles,g);for(const e of y){const r=this._tiles[e];r.hasSymbolBuckets&&!r.holdingForFade()?r.setHoldDuration(this.map._fadeDuration):r.hasSymbolBuckets&&!r.symbolFadeFinished()||this._removeTile(e)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,r){var a;const l={},c={},h=Math.max(r-xe.maxOverzooming,this._source.minzoom),u=Math.max(r+xe.maxUnderzooming,this._source.minzoom),p={};for(const a of e){const e=this._addTile(a);l[a.key]=a,e.hasData()||rthis._source.maxzoom){const e=u.children(this._source.maxzoom)[0],r=this.getTile(e);if(r&&r.hasData()){l[e.key]=e;continue}}else{const e=u.children(this._source.maxzoom);if(l[e[0].key]&&l[e[1].key]&&l[e[2].key]&&l[e[3].key])continue}let p=e.wasRequested();for(let r=u.overscaledZ-1;r>=h;--r){const h=u.scaledTo(r);if(c[h.key])break;if(c[h.key]=!0,e=this.getTile(h),!e&&p&&(e=this._addTile(h)),e){const r=e.hasData();if((r||!(null===(a=this.map)||void 0===a?void 0:a.cancelPendingTileRequestsWhileZooming)||p)&&(l[h.key]=h),p=e.wasRequested(),r)break}}}return l}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const r=[];let a,l=this._tiles[e].tileID;for(;l.overscaledZ>0;){if(l.key in this._loadedParentTiles){a=this._loadedParentTiles[l.key];break}r.push(l.key);const e=l.scaledTo(l.overscaledZ-1);if(a=this._getLoadedTile(e),a)break;l=e}for(const e of r)this._loadedParentTiles[e]=a}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const r=this._tiles[e].tileID,a=this._getLoadedTile(r);this._loadedSiblingTiles[r.key]=a}}_addTile(e){let r=this._tiles[e.key];if(r)return r;r=this._cache.getAndRemove(e),r&&(this._setTileReloadTimer(e.key,r),r.tileID=e,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,r)));const l=r;return r||(r=new re(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(r,e.key,r.state)),r.uses++,this._tiles[e.key]=r,l||this._source.fire(new a.l("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r}_setTileReloadTimer(e,r){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const a=r.getExpiryTimeout();a&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),a))}refreshTiles(e){for(const r in this._tiles)(this._isIdRenderable(r)||"errored"==this._tiles[r].state)&&e.some((e=>e.equals(this._tiles[r].tileID.canonical)))&&this._reloadTile(r,"expired")}_removeTile(e){const r=this._tiles[e];r&&(r.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}_dataHandler(e){const r=e.sourceDataType;"source"===e.dataType&&"metadata"===r&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===r&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,r,l){const c=[],h=this.transform;if(!h)return c;const u=h.getCoveringTilesDetailsProvider().allowWorldCopies(),p=l?h.getCameraQueryGeometry(e):e,g=e=>h.screenPointToMercatorCoordinate(e,this.terrain),y=this.transformBbox(e,g,!u),x=this.transformBbox(p,g,!u),v=this.getIds(),w=a.a1.fromPoints(x);for(let e=0;ee.getTilePoint(new a.a0(r.x,r.y))));if(r.expandBy(M),r.intersects(Xt)){const r=y.map((r=>e.getTilePoint(r))),a=x.map((r=>e.getTilePoint(r)));c.push({tile:l,tileID:u?e:e.unwrapTo(0),queryGeometry:r,cameraQueryGeometry:a,scale:g})}}}return c}transformBbox(e,r,l){let c=e.map(r);if(l){const l=a.a1.fromPoints(e);l.shrinkBy(.001*Math.min(l.width(),l.height()));const h=l.map(r);a.a1.fromPoints(c).covers(h)||(c=c.map((e=>e.x>.5?new a.a0(e.x-1,e.y,e.z):e)))}return c}getVisibleCoordinates(e){const r=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));return this.transform&&this.transform.populateCache(r),r}hasTransition(){if(this._source.hasTransition())return!0;if(Qt(this._source.type)){const e=p.now();for(const r in this._tiles)if(this._tiles[r].fadeEndTime>=e)return!0}return!1}setFeatureState(e,r,a){this._state.updateState(e=e||"_geojsonTileLayer",r,a)}removeFeatureState(e,r,a){this._state.removeFeatureState(e=e||"_geojsonTileLayer",r,a)}getFeatureState(e,r){return this._state.getState(e=e||"_geojsonTileLayer",r)}setDependencies(e,r,a){const l=this._tiles[e];l&&l.setDependencies(r,a)}reloadTilesForDependencies(e,r){for(const a in this._tiles)this._tiles[a].hasDependency(e,r)&&this._reloadTile(a,"reloading");this._cache.filter((a=>!a.hasDependency(e,r)))}}function Kt(e,r){const a=Math.abs(2*e.wrap)-+(e.wrap<0),l=Math.abs(2*r.wrap)-+(r.wrap<0);return e.overscaledZ-r.overscaledZ||l-a||r.canonical.y-e.canonical.y||r.canonical.x-e.canonical.x}function Qt(e){return"raster"===e||"image"===e||"video"===e}xe.maxOverzooming=10,xe.maxUnderzooming=3;class Te{constructor(e,r){this.reset(e,r)}reset(e,r){this.points=e||[],this._distances=[0];for(let e=1;e0?(c-u)/p:0;return this.points[h].mult(1-g).add(this.points[r].mult(g))}}function ee(e,r){let a=!0;return"always"===e||"never"!==e&&"never"!==r||(a=!1),a}class Ce{constructor(e,r,a){const l=this.boxCells=[],c=this.circleCells=[];this.xCellCount=Math.ceil(e/a),this.yCellCount=Math.ceil(r/a);for(let e=0;ethis.width||l<0||r>this.height)return[];const p=[];if(e<=0&&r<=0&&this.width<=a&&this.height<=l){if(c)return[{key:null,x1:e,y1:r,x2:a,y2:l}];for(let e=0;e0}hitTestCircle(e,r,a,l,c){const h=e-a,u=e+a,p=r-a,g=r+a;if(u<0||h>this.width||g<0||p>this.height)return!1;const y=[];return this._forEachCell(h,p,u,g,this._queryCellCircle,y,{hitTest:!0,overlapMode:l,circle:{x:e,y:r,radius:a},seenUids:{box:{},circle:{}}},c),y.length>0}_queryCell(e,r,a,l,c,h,u,p){const{seenUids:g,hitTest:y,overlapMode:x}=u,v=this.boxCells[c];if(null!==v){const c=this.bboxes;for(const u of v)if(!g.box[u]){g.box[u]=!0;const v=4*u,w=this.boxKeys[u];if(e<=c[v+2]&&r<=c[v+3]&&a>=c[v+0]&&l>=c[v+1]&&(!p||p(w))&&(!y||!ee(x,w.overlapMode))&&(h.push({key:w,x1:c[v],y1:c[v+1],x2:c[v+2],y2:c[v+3]}),y))return!0}}const w=this.circleCells[c];if(null!==w){const c=this.circles;for(const u of w)if(!g.circle[u]){g.circle[u]=!0;const v=3*u,w=this.circleKeys[u];if(this._circleAndRectCollide(c[v],c[v+1],c[v+2],e,r,a,l)&&(!p||p(w))&&(!y||!ee(x,w.overlapMode))){const e=c[v],r=c[v+1],a=c[v+2];if(h.push({key:w,x1:e-a,y1:r-a,x2:e+a,y2:r+a}),y)return!0}}}return!1}_queryCellCircle(e,r,a,l,c,h,u,p){const{circle:g,seenUids:y,overlapMode:x}=u,v=this.boxCells[c];if(null!==v){const e=this.bboxes;for(const r of v)if(!y.box[r]){y.box[r]=!0;const a=4*r,l=this.boxKeys[r];if(this._circleAndRectCollide(g.x,g.y,g.radius,e[a+0],e[a+1],e[a+2],e[a+3])&&(!p||p(l))&&!ee(x,l.overlapMode))return h.push(!0),!0}}const w=this.circleCells[c];if(null!==w){const e=this.circles;for(const r of w)if(!y.circle[r]){y.circle[r]=!0;const a=3*r,l=this.circleKeys[r];if(this._circlesCollide(e[a],e[a+1],e[a+2],g.x,g.y,g.radius)&&(!p||p(l))&&!ee(x,l.overlapMode))return h.push(!0),!0}}}_forEachCell(e,r,a,l,c,h,u,p){const g=this._convertToXCellCoord(e),y=this._convertToYCellCoord(r),x=this._convertToXCellCoord(a),v=this._convertToYCellCoord(l);for(let w=g;w<=x;w++)for(let g=y;g<=v;g++)if(c.call(this,e,r,a,l,this.xCellCount*g+w,h,u,p))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,r,a,l,c,h){const u=l-e,p=c-r,g=a+h;return g*g>u*u+p*p}_circleAndRectCollide(e,r,a,l,c,h,u){const p=(h-l)/2,g=Math.abs(e-(l+p));if(g>p+a)return!1;const y=(u-c)/2,x=Math.abs(r-(c+y));if(x>y+a)return!1;if(g<=p||x<=y)return!0;const v=g-p,w=x-y;return v*v+w*w<=a*a}}function ie(e,r,l){const h=a.L();if(!e){const{vecSouth:e,vecEast:a}=le(r),l=c();l[0]=a[0],l[1]=a[1],l[2]=e[0],l[3]=e[1],u=l,(w=(g=(p=l)[0])*(v=p[3])-(x=p[2])*(y=p[1]))&&(u[0]=v*(w=1/w),u[1]=-y*w,u[2]=-x*w,u[3]=g*w),h[0]=l[0],h[1]=l[1],h[4]=l[2],h[5]=l[3]}var u,p,g,y,x,v,w;return a.N(h,h,[1/l,1/l,1]),h}function oe(e,r,l,c){if(e){const e=a.L();if(!r){const{vecSouth:r,vecEast:a}=le(l);e[0]=a[0],e[1]=a[1],e[4]=r[0],e[5]=r[1]}return a.N(e,e,[c,c,1]),e}return l.pixelsToClipSpaceMatrix}function le(e){const r=Math.cos(e.rollInRadians),l=Math.sin(e.rollInRadians),c=Math.cos(e.pitchInRadians),h=Math.cos(e.bearingInRadians),u=Math.sin(e.bearingInRadians),p=a.aq();p[0]=-h*c*l-u*r,p[1]=-u*c*l+h*r;const g=a.ar(p);g<1e-9?a.as(p):a.at(p,p,1/g);const y=a.aq();y[0]=h*c*r-u*l,y[1]=u*c*r+h*l;const x=a.ar(y);return x<1e-9?a.as(y):a.at(y,y,1/x),{vecEast:y,vecSouth:p}}function ce(e,r,l,c){let h;c?(h=[e,r,c(e,r),1],a.av(h,h,l)):(h=[e,r,0,1],ze(h,h,l));const u=h[3];return{point:new a.P(h[0]/u,h[1]/u),signedDistanceFromCamera:u,isOccluded:!1}}function he(e,r){return.5+e/r*.5}function ue(e,r){return e.x>=-r[0]&&e.x<=r[0]&&e.y>=-r[1]&&e.y<=r[1]}function de(e,r,l,c,h,u,p,g,y,x,v,w,M){const C=l?e.textSizeData:e.iconSizeData,A=a.am(C,r.transform.zoom),k=[256/r.width*2+1,256/r.height*2+1],R=l?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;R.clear();const D=e.lineVertexArray,L=l?e.text.placedSymbolArray:e.icon.placedSymbolArray,B=r.transform.width/r.transform.height;let O=!1;for(let l=0;lMath.abs(l.x-r.x)*c?{useVertical:!0}:(e===a.an.vertical?r.yl.x)?{needsFlipping:!0}:null}function me(e){const{projectionContext:r,pitchedLabelPlaneMatrixInverse:l,symbol:c,fontSize:h,flip:u,keepUpright:p,glyphOffsetArray:g,dynamicLayoutVertexArray:y,aspectRatio:x,rotateToLine:v}=e,w=h/24,M=c.lineOffsetX*w,C=c.lineOffsetY*w;let A;if(c.numGlyphs>1){const e=c.glyphStartIndex+c.numGlyphs,a=c.lineStartIndex,h=c.lineStartIndex+c.lineLength,y=pe(w,g,M,C,u,c,v,r);if(!y)return{notEnoughRoom:!0};const k=ve(y.first.point.x,y.first.point.y,r,l),R=ve(y.last.point.x,y.last.point.y,r,l);if(p&&!u){const e=fe(c.writingMode,k,R,x);if(e)return e}A=[y.first];for(let l=c.glyphStartIndex+1;l0?p.point:_e(r.tileAnchorPoint,u,e,1,r),y=ve(e.x,e.y,r,l),v=ve(g.x,g.y,r,l),w=fe(c.writingMode,y,v,x);if(w)return w}const e=Me(w*g.getoffsetX(c.glyphStartIndex),M,C,u,c.segment,c.lineStartIndex,c.lineStartIndex+c.lineLength,r,v);if(!e||r.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};A=[e]}for(const e of A)a.au(y,e.point,e.angle);return{}}function _e(e,r,a,l,c){const h=e.add(e.sub(r)._unit()),u=ye(h.x,h.y,c).point,p=a.sub(u);return a.add(p._mult(l/p.mag()))}function ge(e,r,l){const c=r.projectionCache;if(c.projections[e])return c.projections[e];const h=new a.P(r.lineVertexArray.getx(e),r.lineVertexArray.gety(e)),u=ye(h.x,h.y,r);if(u.signedDistanceFromCamera>0)return c.projections[e]=u.point,c.anyProjectionOccluded=c.anyProjectionOccluded||u.isOccluded,u.point;const p=e-l.direction;return _e(0===l.distanceFromAnchor?r.tileAnchorPoint:new a.P(r.lineVertexArray.getx(p),r.lineVertexArray.gety(p)),h,l.previousVertex,l.absOffsetX-l.distanceFromAnchor+1,r)}function ye(e,r,a){const l=e+a.translation[0],c=r+a.translation[1];let h;return a.pitchWithMap?(h=ce(l,c,a.pitchedLabelPlaneMatrix,a.getElevation),h.isOccluded=!1):(h=a.transform.projectTileCoordinates(l,c,a.unwrappedTileID,a.getElevation),h.point.x=(.5*h.point.x+.5)*a.width,h.point.y=(.5*-h.point.y+.5)*a.height),h}function ve(e,r,l,c){if(l.pitchWithMap){const h=[e,r,0,1];return a.av(h,h,c),l.transform.projectTileCoordinates(h[0]/h[3],h[1]/h[3],l.unwrappedTileID,l.getElevation).point}return{x:e/l.width*2-1,y:1-r/l.height*2}}function be(e,r,a){return a.transform.projectTileCoordinates(e,r,a.unwrappedTileID,a.getElevation)}function we(e,r,a){return e._unit()._perp()._mult(r*a)}function Se(e,r,l,c,h,u,p,g,y){if(g.projectionCache.offsets[e])return g.projectionCache.offsets[e];const x=l.add(r);if(e+y.direction=h)return g.projectionCache.offsets[e]=x,x;const v=ge(e+y.direction,g,y),w=we(v.sub(l),p,y.direction),M=l.add(w),C=v.add(w);return g.projectionCache.offsets[e]=a.aw(u,x,M,C)||x,g.projectionCache.offsets[e]}function Me(e,r,a,l,c,h,u,p,g){const y=l?e-r:e+r;let x=y>0?1:-1,v=0;l&&(x*=-1,v=Math.PI),x<0&&(v+=Math.PI);let w,M=x>0?h+c:h+c+1;p.projectionCache.cachedAnchorPoint?w=p.projectionCache.cachedAnchorPoint:(w=ye(p.tileAnchorPoint.x,p.tileAnchorPoint.y,p).point,p.projectionCache.cachedAnchorPoint=w);let C,A,k=w,R=w,D=0,L=0;const B=Math.abs(y),O=[];let j;for(;D+L<=B;){if(M+=x,M=u)return null;D+=L,R=k,A=C;const e={absOffsetX:B,direction:x,distanceFromAnchor:D,previousVertex:R};if(k=ge(M,p,e),0===a)O.push(R),j=k.sub(R);else{let r;const l=k.sub(R);r=0===l.mag()?we(ge(M+x,p,e).sub(k),a,x):we(l,a,x),A||(A=R.add(r)),C=Se(M,r,k,h,u,A,a,p,e),O.push(A),j=C.sub(A)}L=j.mag()}const N=j._mult((B-D)/L)._add(A||R),U=v+Math.atan2(k.y-R.y,k.x-R.x);return O.push(N),{point:N,angle:g?U:0,path:O}}const Ie=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Ae(e,r){for(let a=0;a=1;e--)M.push(u.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let k=[];if(M.length>0){const e=M[0].clone(),r=M[0].clone();for(let a=1;a=l.x&&r.x<=c.x&&e.y>=l.y&&r.y<=c.y?[M]:r.xc.x||r.yc.y?[]:a.ax([M],l.x,l.y,c.x,c.y)}for(const a of k){h.reset(a,.25*r);let l=0;l=h.length<=.5*r?1:Math.ceil(h.paddedLength/C)+1;for(let a=0;a{const a=ce(e.x,e.y,l,r.getElevation),c=r.transform.projectTileCoordinates(a.point.x,a.point.y,r.unwrappedTileID,r.getElevation);return c.point.x=(.5*c.point.x+.5)*r.width,c.point.y=(.5*-c.point.y+.5)*r.height,c}))}(e,r);return function(e){let r=0,a=0,l=0,c=0;for(let h=0;ha&&(a=c,r=l));return e.slice(r,r+a)}(l)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const r=[],l=new a.a1;for(const c of e){const e=new a.P(c.x+ke,c.y+ke);l.extend(e),r.push(e)}const{minX:c,minY:h,maxX:u,maxY:p}=l,g=this.grid.query(c,h,u,p).concat(this.ignoredGrid.query(c,h,u,p)),y={},x={};for(const e of g){const l=e.key;if(void 0===y[l.bucketInstanceId]&&(y[l.bucketInstanceId]={}),y[l.bucketInstanceId][l.featureIndex])continue;const c=[new a.P(e.x1,e.y1),new a.P(e.x2,e.y1),new a.P(e.x2,e.y2),new a.P(e.x1,e.y2)];a.ay(r,c)&&(y[l.bucketInstanceId][l.featureIndex]=!0,void 0===x[l.bucketInstanceId]&&(x[l.bucketInstanceId]=[]),x[l.bucketInstanceId].push(l.featureIndex))}return x}insertCollisionBox(e,r,a,l,c,h){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:c,collisionGroupID:h,overlapMode:r},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,r,a,l,c,h){const u=a?this.ignoredGrid:this.grid,p={bucketInstanceId:l,featureIndex:c,collisionGroupID:h,overlapMode:r};for(let r=0;r=this.screenRightBoundary||lthis.screenBottomBoundary}isInsideGrid(e,r,a,l){return a>=0&&e=0&&rthis.projectAndGetPerspectiveRatio(e.x,e.y,c,y,v)));it=e.some((e=>!e.isOccluded)),et=e.map((e=>new a.P(e.x,e.y)))}else it=!0;return{box:a.az(et),allPointsOccluded:!it}}}class Xe{constructor(e,r,a,l){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?r:-r))):l&&a?1:0,this.placed=a}isHidden(){return 0===this.opacity&&!this.placed}}class Ke{constructor(e,r,a,l,c){this.text=new Xe(e?e.text:null,r,a,c),this.icon=new Xe(e?e.icon:null,r,l,c)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ye{constructor(e,r,a){this.text=e,this.icon=r,this.skipFade=a}}class Qe{constructor(e,r,a,l,c){this.bucketInstanceId=e,this.featureIndex=r,this.sourceLayerIndex=a,this.bucketIndex=l,this.tileID=c}}class Je{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 r=++this.maxGroupID;this.collisionGroups[e]={ID:r,predicate:e=>e.collisionGroupID===r}}return this.collisionGroups[e]}}function De(e,r,l,c,h){const{horizontalAlign:u,verticalAlign:p}=a.aG(e);return new a.P(-(u-.5)*r+c[0]*h,-(p-.5)*l+c[1]*h)}class tt{constructor(e,r,a,l,c){this.transform=e.clone(),this.terrain=r,this.collisionIndex=new He(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new Je(l),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=c,c&&(c.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const r=this.terrain;return r?(a,l)=>r.getElevation(e,a,l):null}getBucketParts(e,r,l,c){const h=l.getBucket(r),u=l.latestFeatureIndex;if(!h||!u||r.id!==h.layerIds[0])return;const p=l.collisionBoxArray,g=h.layers[0].layout,y=h.layers[0].paint,x=Math.pow(2,this.transform.zoom-l.tileID.overscaledZ),v=l.tileSize/a.$,w=l.tileID.toUnwrapped(),M="map"===g.get("text-rotation-alignment"),C=a.aB(l,1,this.transform.zoom),A=a.aC(this.collisionIndex.transform,l,y.get("text-translate"),y.get("text-translate-anchor")),k=a.aC(this.collisionIndex.transform,l,y.get("icon-translate"),y.get("icon-translate-anchor")),R=ie(M,this.transform,C);this.retainedQueryData[h.bucketInstanceId]=new Qe(h.bucketInstanceId,u,h.sourceLayerIndex,h.index,l.tileID);const D={bucket:h,layout:g,translationText:A,translationIcon:k,unwrappedTileID:w,pitchedLabelPlaneMatrix:R,scale:x,textPixelRatio:v,holdingForFade:l.holdingForFade(),collisionBoxArray:p,partiallyEvaluatedTextSize:a.am(h.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(h.sourceID)};if(c)for(const r of h.sortKeyRanges){const{sortKey:a,symbolInstanceStart:l,symbolInstanceEnd:c}=r;e.push({sortKey:a,symbolInstanceStart:l,symbolInstanceEnd:c,parameters:D})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:h.symbolInstances.length,parameters:D})}attemptAnchorPlacement(e,r,l,c,h,u,p,g,y,x,v,w,M,C,A,k,R,D,L,B){const O=a.aD[e.textAnchor],j=[e.textOffset0,e.textOffset1],N=De(O,l,c,j,h),U=this.collisionIndex.placeCollisionBox(r,w,g,y,x,p,u,k,v.predicate,L,N,B);if((!D||this.collisionIndex.placeCollisionBox(D,w,g,y,x,p,u,R,v.predicate,L,N,B).placeable)&&U.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[M.crossTileID]&&this.prevPlacement.placements[M.crossTileID]&&this.prevPlacement.placements[M.crossTileID].text&&(e=this.prevPlacement.variableOffsets[M.crossTileID].anchor),0===M.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[M.crossTileID]={textOffset:j,width:l,height:c,anchor:O,textBoxScale:h,prevAnchor:e},this.markUsedJustification(C,O,M,A),C.allowVerticalPlacement&&(this.markUsedOrientation(C,A,M),this.placedOrientations[M.crossTileID]=A),{shift:N,placedGlyphBoxes:U}}}placeLayerBucketPart(e,r,l){const{bucket:c,layout:h,translationText:u,translationIcon:p,unwrappedTileID:g,pitchedLabelPlaneMatrix:y,textPixelRatio:x,holdingForFade:v,collisionBoxArray:w,partiallyEvaluatedTextSize:M,collisionGroup:C}=e.parameters,A=h.get("text-optional"),k=h.get("icon-optional"),R=a.aE(h,"text-overlap","text-allow-overlap"),D="always"===R,L=a.aE(h,"icon-overlap","icon-allow-overlap"),B="always"===L,O="map"===h.get("text-rotation-alignment"),j="map"===h.get("text-pitch-alignment"),N="none"!==h.get("icon-text-fit"),U="viewport-y"===h.get("symbol-z-order"),Z=D&&(B||!c.hasIconData()||k),J=B&&(D||!c.hasTextData()||A);!c.collisionArrays&&w&&c.deserializeCollisionBoxes(w);const Q=this.retainedQueryData[c.bucketInstanceId].tileID,et=this._getTerrainElevationFunc(Q),it=this.transform.getFastPathSimpleProjectionMatrix(Q),rt=(e,w,B)=>{var U,rt;if(r[e.crossTileID])return;if(v)return void(this.placements[e.crossTileID]=new Ye(!1,!1,!1));let nt=!1,st=!1,ot=!0,at=null,lt={box:null,placeable:!1,offscreen:null,occluded:!1},ct={placeable:!1},ht=null,ut=null,yt=null,Pt=0,St=0,Ct=0;w.textFeatureIndex?Pt=w.textFeatureIndex:e.useRuntimeCollisionCircles&&(Pt=e.featureIndex),w.verticalTextFeatureIndex&&(St=w.verticalTextFeatureIndex);const Et=w.textBox;if(Et){const r=r=>{let l=a.an.horizontal;if(c.allowVerticalPlacement&&!r&&this.prevPlacement){const r=this.prevPlacement.placedOrientations[e.crossTileID];r&&(this.placedOrientations[e.crossTileID]=r,l=r,this.markUsedOrientation(c,l,e))}return l},h=(r,l)=>{if(c.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&w.verticalTextBox){for(const e of c.writingModes)if(e===a.an.vertical?(lt=l(),ct=lt):lt=r(),lt&<.placeable)break}else lt=r()},y=e.textAnchorOffsetStartIndex,v=e.textAnchorOffsetEndIndex;if(v===y){const l=(r,a)=>{const l=this.collisionIndex.placeCollisionBox(r,R,x,Q,g,j,O,u,C.predicate,et,void 0,it);return l&&l.placeable&&(this.markUsedOrientation(c,a,e),this.placedOrientations[e.crossTileID]=a),l};h((()=>l(Et,a.an.horizontal)),(()=>{const r=w.verticalTextBox;return c.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&r?l(r,a.an.vertical):{box:null,offscreen:null}})),r(lt&<.placeable)}else{let M=a.aD[null===(rt=null===(U=this.prevPlacement)||void 0===U?void 0:U.variableOffsets[e.crossTileID])||void 0===rt?void 0:rt.anchor];const A=(r,a,h)=>{const w=r.x2-r.x1,A=r.y2-r.y1,k=e.textBoxScale,D=N&&"never"===L?a:null;let B=null,U="never"===R?1:2,Z="never";M&&U++;for(let a=0;aA(Et,w.iconBox,a.an.horizontal)),(()=>{const r=w.verticalTextBox;return c.allowVerticalPlacement&&(!lt||!lt.placeable)&&e.numVerticalGlyphVertices>0&&r?A(r,w.verticalIconBox,a.an.vertical):{box:null,occluded:!0,offscreen:null}})),lt&&(nt=lt.placeable,ot=lt.offscreen);const k=r(lt&<.placeable);if(!nt&&this.prevPlacement){const r=this.prevPlacement.variableOffsets[e.crossTileID];r&&(this.variableOffsets[e.crossTileID]=r,this.markUsedJustification(c,r.anchor,e,k))}}}if(ht=lt,nt=ht&&ht.placeable,ot=ht&&ht.offscreen,e.useRuntimeCollisionCircles){const r=c.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),p=a.ao(c.textSizeData,M,r),x=h.get("text-padding");ut=this.collisionIndex.placeCollisionCircles(R,r,c.lineVertexArray,c.glyphOffsetArray,p,g,y,l,j,C.predicate,e.collisionCircleDiameter,x,u,et),ut.circles.length&&ut.collisionDetected&&!l&&a.w("Collisions detected, but collision boxes are not shown"),nt=D||ut.circles.length>0&&!ut.collisionDetected,ot=ot&&ut.offscreen}if(w.iconFeatureIndex&&(Ct=w.iconFeatureIndex),w.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,L,x,Q,g,j,O,p,C.predicate,et,N&&at?at:void 0,it);ct&&ct.placeable&&w.verticalIconBox?(yt=e(w.verticalIconBox),st=yt.placeable):(yt=e(w.iconBox),st=yt.placeable),ot=ot&&yt.offscreen}const kt=A||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Bt=k||0===e.numIconVertices;kt||Bt?Bt?kt||(st=st&&nt):nt=st&&nt:st=nt=st&&nt;const Nt=st&&yt.placeable;if(nt&&ht.placeable&&this.collisionIndex.insertCollisionBox(ht.box,R,h.get("text-ignore-placement"),c.bucketInstanceId,ct&&ct.placeable&&St?St:Pt,C.ID),Nt&&this.collisionIndex.insertCollisionBox(yt.box,L,h.get("icon-ignore-placement"),c.bucketInstanceId,Ct,C.ID),ut&&nt&&this.collisionIndex.insertCollisionCircles(ut.circles,R,h.get("text-ignore-placement"),c.bucketInstanceId,Pt,C.ID),l&&this.storeCollisionData(c.bucketInstanceId,B,w,ht,yt,ut),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===c.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Ye((nt||Z)&&!(null==ht?void 0:ht.occluded),(st||J)&&!(null==yt?void 0:yt.occluded),ot||c.justReloaded),r[e.crossTileID]=!0};if(U){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const r=c.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=r.length-1;e>=0;--e){const a=r[e];rt(c.symbolInstances.get(a),c.collisionArrays[a],a)}}else for(let r=e.symbolInstanceStart;r=0&&(e.text.placedSymbolArray.get(r).crossTileID=h>=0&&r!==h?0:l.crossTileID)}markUsedOrientation(e,r,l){const c=r===a.an.horizontal||r===a.an.horizontalOnly?r:0,h=r===a.an.vertical?r:0,u=[l.leftJustifiedTextSymbolIndex,l.centerJustifiedTextSymbolIndex,l.rightJustifiedTextSymbolIndex];for(const r of u)e.text.placedSymbolArray.get(r).placedOrientation=c;l.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(l.verticalPlacedTextSymbolIndex).placedOrientation=h)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let a=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const l=r?r.symbolFadeChange(e):1,c=r?r.opacities:{},h=r?r.variableOffsets:{},u=r?r.placedOrientations:{};for(const e in this.placements){const r=this.placements[e],h=c[e];h?(this.opacities[e]=new Ke(h,l,r.text,r.icon),a=a||r.text!==h.text.placed||r.icon!==h.icon.placed):(this.opacities[e]=new Ke(null,l,r.text,r.icon,r.skipFade),a=a||r.text||r.icon)}for(const e in c){const r=c[e];if(!this.opacities[e]){const c=new Ke(r,l,!1,!1);c.isHidden()||(this.opacities[e]=c,a=a||r.text.placed||r.icon.placed)}}for(const e in h)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=h[e]);for(const e in u)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=u[e]);if(r&&void 0===r.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:e)}updateLayerOpacities(e,r){const a={};for(const l of r){const r=l.getBucket(e);r&&l.latestFeatureIndex&&e.id===r.layerIds[0]&&this.updateBucketOpacities(r,l.tileID,a,l.collisionBoxArray)}}updateBucketOpacities(e,r,l,c){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 h=e.layers[0],u=h.layout,p=new Ke(null,0,!1,!1,!0),g=u.get("text-allow-overlap"),y=u.get("icon-allow-overlap"),x=h._unevaluatedLayout.hasValue("text-variable-anchor")||h._unevaluatedLayout.hasValue("text-variable-anchor-offset"),v="map"===u.get("text-rotation-alignment"),w="map"===u.get("text-pitch-alignment"),M="none"!==u.get("icon-text-fit"),C=new Ke(null,0,g&&(y||!e.hasIconData()||u.get("icon-optional")),y&&(g||!e.hasTextData()||u.get("text-optional")),!0);!e.collisionArrays&&c&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(c);const A=(e,r,a)=>{for(let l=0;l0,D=this.placedOrientations[c.crossTileID],L=D===a.an.vertical,B=D===a.an.horizontal||D===a.an.horizontalOnly;if(h>0||u>0){const r=ii(y.text);A(e.text,h,L?ri:r),A(e.text,u,B?ri:r);const a=y.text.isHidden();[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex].forEach((r=>{r>=0&&(e.text.placedSymbolArray.get(r).hidden=a||L?1:0)})),c.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).hidden=a||B?1:0);const l=this.variableOffsets[c.crossTileID];l&&this.markUsedJustification(e,l.anchor,c,D);const p=this.placedOrientations[c.crossTileID];p&&(this.markUsedJustification(e,"left",c,p),this.markUsedOrientation(e,p,c))}if(R){const r=ii(y.icon),a=!(M&&c.verticalPlacedIconSymbolIndex&&L);c.placedIconSymbolIndex>=0&&(A(e.icon,c.numIconVertices,a?r:ri),e.icon.placedSymbolArray.get(c.placedIconSymbolIndex).hidden=y.icon.isHidden()),c.verticalPlacedIconSymbolIndex>=0&&(A(e.icon,c.numVerticalIconVertices,a?ri:r),e.icon.placedSymbolArray.get(c.verticalPlacedIconSymbolIndex).hidden=y.icon.isHidden())}const O=k&&k.has(r)?k.get(r):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const l=e.collisionArrays[r];if(l){let r=new a.P(0,0);if(l.textBox||l.verticalTextBox){let a=!0;if(x){const e=this.variableOffsets[g];e?(r=De(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),v&&r._rotate(w?-this.transform.bearingInRadians:this.transform.bearingInRadians)):a=!1}if(l.textBox||l.verticalTextBox){let c;l.textBox&&(c=L),l.verticalTextBox&&(c=B),Be(e.textCollisionBox.collisionVertexArray,y.text.placed,!a||c,O.text,r.x,r.y)}}if(l.iconBox||l.verticalIconBox){const a=Boolean(!B&&l.verticalIconBox);let c;l.iconBox&&(c=a),l.verticalIconBox&&(c=!a),Be(e.iconCollisionBox.collisionVertexArray,y.icon.placed,c,O.icon,M?r.x:0,M?r.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 Be(e,r,a,l,c,h){l&&0!==l.length||(l=[0,0,0,0]);const u=l[0]-ke,p=l[1]-ke,g=l[2]-ke,y=l[3]-ke;e.emplaceBack(r?1:0,a?1:0,c||0,h||0,u,p),e.emplaceBack(r?1:0,a?1:0,c||0,h||0,g,p),e.emplaceBack(r?1:0,a?1:0,c||0,h||0,g,y),e.emplaceBack(r?1:0,a?1:0,c||0,h||0,u,y)}const Ne=Math.pow(2,25),Ue=Math.pow(2,24),Ze=Math.pow(2,17),Ge=Math.pow(2,16),qe=Math.pow(2,9),ti=Math.pow(2,8),ei=Math.pow(2,1);function ii(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const r=e.placed?1:0,a=Math.floor(127*e.opacity);return a*Ne+r*Ue+a*Ze+r*Ge+a*qe+r*ti+a*ei+r}const ri=0;class dt{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,r,a,l,c){const h=this._bucketParts;for(;this._currentTileIndexe.sortKey-r.sortKey)));this._currentPartIndex!this._forceFullPlacement&&p.now()-l>2;for(;this._currentPlacementIndex>=0;){const l=r[e[this._currentPlacementIndex]],h=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=h)&&(!l.maxzoom||l.maxzoom>h)){if(this._inProgressLayer||(this._inProgressLayer=new dt(l)),this._inProgressLayer.continuePlacement(a[l.source],this.placement,this._showCollisionBoxes,l,c))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const si=512/a.$/2;class mt{constructor(e,r,l){this.tileID=e,this.bucketInstanceId=l,this._symbolsByKey={};const c=new Map;for(let e=0;e({x:Math.floor(e.anchorX*si),y:Math.floor(e.anchorY*si)}))),crossTileIDs:r.map((e=>e.crossTileID))};if(l.positions.length>128){const e=new a.aH(l.positions.length,16,Uint16Array);for(const{x:r,y:a}of l.positions)e.add(r,a);e.finish(),delete l.positions,l.index=e}this._symbolsByKey[e]=l}}getScaledCoordinates(e,r){const{x:l,y:c,z:h}=this.tileID.canonical,{x:u,y:p,z:g}=r.canonical,y=si/Math.pow(2,g-h),x=(p*a.$+e.anchorY)*y,v=c*a.$*si;return{x:Math.floor((u*a.$+e.anchorX)*y-l*a.$*si),y:Math.floor(x-v)}}findMatches(e,r,a){const l=this.tileID.canonical.ze))}}class ft{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class gt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const r=Math.round((e-this.lng)/360);if(0!==r)for(const e in this.indexes){const a=this.indexes[e],l={};for(const e in a){const c=a[e];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+r),l[c.tileID.key]=c}this.indexes[e]=l}this.lng=e}addBucket(e,r,a){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===r.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;ee.overscaledZ)for(const a in c){const h=c[a];h.tileID.isChildOf(e)&&h.findMatches(r.symbolInstances,e,l)}else{const h=c[e.scaledTo(Number(a)).key];h&&h.findMatches(r.symbolInstances,e,l)}}for(let e=0;e{r[e]=!0}));for(const e in this.layerIndexes)r[e]||delete this.layerIndexes[e]}}var li="void main() {fragColor=vec4(1.0);}";const ci={prelude:di("#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:di("","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:di("","#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:di("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:di("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:di("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:di(li,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:di("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:di("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:di("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:di("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:di("#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:di("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:di(li,"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:di("#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:di("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:di("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:di("#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:di("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:di("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:di("#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:di("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:di("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:di("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:di("#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:di("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;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\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\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);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_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_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;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\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\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_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:di("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:di("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:di("#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:di("#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:di("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:di("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:di("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:di("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:di("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:di("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 di(e,r){const a=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,l=r.match(/in ([\w]+) ([\w]+)/g),c=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),h=r.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),u=h?h.concat(c):c,p={};return{fragmentSource:e=e.replace(a,((e,r,a,l,c)=>(p[c]=!0,"define"===r?`\n#ifndef HAS_UNIFORM_u_${c}\nin ${a} ${l} ${c};\n#else\nuniform ${a} ${l} u_${c};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${c}\n ${a} ${l} ${c} = u_${c};\n#endif\n`))),vertexSource:r=r.replace(a,((e,r,a,l,c)=>{const h="float"===l?"vec2":"vec4",u=c.match(/color/)?"color":h;return p[c]?"define"===r?`\n#ifndef HAS_UNIFORM_u_${c}\nuniform lowp float u_${c}_t;\nin ${a} ${h} a_${c};\nout ${a} ${l} ${c};\n#else\nuniform ${a} ${l} u_${c};\n#endif\n`:"vec4"===u?`\n#ifndef HAS_UNIFORM_u_${c}\n ${c} = a_${c};\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${c}\n ${c} = unpack_mix_${u}(a_${c}, u_${c}_t);\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`:"define"===r?`\n#ifndef HAS_UNIFORM_u_${c}\nuniform lowp float u_${c}_t;\nin ${a} ${h} a_${c};\n#else\nuniform ${a} ${l} u_${c};\n#endif\n`:"vec4"===u?`\n#ifndef HAS_UNIFORM_u_${c}\n ${a} ${l} ${c} = a_${c};\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${c}\n ${a} ${l} ${c} = unpack_mix_${u}(a_${c}, u_${c}_t);\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`})),staticAttributes:l,staticUniforms:u}}class wt{constructor(e,r,a){this.vertexBuffer=e,this.indexBuffer=r,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var mi=a.aI([{name:"a_pos",type:"Int16",components:2}]);const _i="#define PROJECTION_MERCATOR",yi="mercator";class It{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return yi}get shaderDefine(){return _i}get shaderPreludeCode(){return ci.projectionMercator}get vertexShaderPreludeCode(){return ci.projectionMercator.vertexSource}get subdivisionGranularity(){return a.aJ.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,r,l,c,h){if(this._cachedMesh)return this._cachedMesh;const u=new a.aK;u.emplaceBack(0,0),u.emplaceBack(a.$,0),u.emplaceBack(0,a.$),u.emplaceBack(a.$,a.$);const p=e.createVertexBuffer(u,mi.members),g=a.aL.simpleSegment(0,0,4,2),y=new a.aM;y.emplaceBack(1,0,2),y.emplaceBack(1,2,3);const x=e.createIndexBuffer(y);return this._cachedMesh=new wt(p,x,g),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Mt{constructor(e=0,r=0,a=0,l=0){if(isNaN(e)||e<0||isNaN(r)||r<0||isNaN(a)||a<0||isNaN(l)||l<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=r,this.left=a,this.right=l}interpolate(e,r,l){return null!=r.top&&null!=e.top&&(this.top=a.C.number(e.top,r.top,l)),null!=r.bottom&&null!=e.bottom&&(this.bottom=a.C.number(e.bottom,r.bottom,l)),null!=r.left&&null!=e.left&&(this.left=a.C.number(e.left,r.left,l)),null!=r.right&&null!=e.right&&(this.right=a.C.number(e.right,r.right,l)),this}getCenter(e,r){const l=a.ag((this.left+e-this.right)/2,0,e),c=a.ag((this.top+r-this.bottom)/2,0,r);return new a.P(l,c)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Mt(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function xi(e,r){if(!e.renderWorldCopies||e.lngRange)return;const a=r.lng-e.center.lng;r.lng+=a>180?-360:a<-180?360:0}function Ti(e){return Math.max(0,Math.floor(e))}class Rt{constructor(e,r,l,c,h,u){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===u||!!u,this._minZoom=r||0,this._maxZoom=l||22,this._minPitch=null==c?0:c,this._maxPitch=null==h?60:h,this.setMaxBounds(),this._width=0,this._height=0,this._center=new a.S(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Ti(this._zoom),this._scale=a.ae(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Mt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,r,l){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=Ti(this._zoom),this._scale=a.ae(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 Mt(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=!l&&e.autoCalculateNearFarZ,r&&this._constrain(),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.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(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 worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const r=a.aN(e,-180,180)*Math.PI/180;var l,h,u,p,g,y,x,v,w;this._bearingInRadians!==r&&(this._unmodified=!1,this._bearingInRadians=r,this._calcMatrices(),this._rotationMatrix=c(),l=this._rotationMatrix,u=-this._bearingInRadians,p=(h=this._rotationMatrix)[0],g=h[1],y=h[2],x=h[3],v=Math.sin(u),w=Math.cos(u),l[0]=p*w+y*v,l[1]=g*w+x*v,l[2]=p*-v+y*w,l[3]=g*-v+x*w)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const r=a.ag(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==r&&(this._unmodified=!1,this._pitchInRadians=r,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const r=e/180*Math.PI;this._rollInRadians!==r&&(this._unmodified=!1,this._rollInRadians=r,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return a.aO(this._fovInRadians)}setFov(e){e=a.ag(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=a.ad(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const r=this.getConstrained(this._center,e).zoom;this._zoom!==r&&(this._unmodified=!1,this._zoom=r,this._tileZoom=Math.max(0,Math.floor(r)),this._scale=a.ae(r),this._constrain(),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._constrain(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),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,r){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=r,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,r,a){this._unmodified=!1,this._edgeInsets.interpolate(e,r,a),this._constrain(),this._calcMatrices()}resize(e,r,a=!0){this._width=e,this._height=r,a&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new G([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._constrain()):(this._lngRange=null,this._latRange=[-a.ah,a.ah])}getConstrained(e,r){return this._callbacks.getConstrained(e,r)}getCameraQueryGeometry(e,r){if(1===r.length)return[r[0],e];{const{minX:l,minY:c,maxX:h,maxY:u}=a.a1.fromPoints(r).extend(e);return[new a.P(l,c),new a.P(h,c),new a.P(h,u),new a.P(l,u),new a.P(l,c)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:r,zoom:a}=this.getConstrained(this.center,this.zoom);this.setCenter(r),this.setZoom(a),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=a.af(new Float64Array(16));a.N(e,e,[this._width/2,-this._height/2,1]),a.M(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=a.af(new Float64Array(16)),a.N(e,e,[1,-1,1]),a.M(e,e,[-1,-1,0]),a.N(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,r,l,c){const h=void 0!==l?l:this.bearing,u=c=void 0!==c?c:this.pitch,p=a.a0.fromLngLat(e,r),g=-Math.cos(a.ad(u)),y=Math.sin(a.ad(u)),x=y*Math.sin(a.ad(h)),v=-y*Math.cos(a.ad(h));let w=this.elevation;const M=r-w;let C;g*M>=0||Math.abs(g)<.1?(C=1e4,w=r+C*g):C=-M/g;let A,k,R=a.aP(1,p.y),D=0;do{if(D+=1,D>10)break;k=C/R,A=new a.a0(p.x+x*k,p.y+v*k),R=1/A.meterInMercatorCoordinateUnits()}while(Math.abs(C-k*R)>1e-12);return{center:A.toLngLat(),elevation:w,zoom:a.aj(this.height/2/Math.tan(this.fovInRadians/2)/k/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const r=a.ai(1,this.center.lat)*this.worldSize,l=this.cameraToCenterDistance/r,c=a.a0.fromLngLat(this.center,this.elevation),h=kt(this.center,this.elevation,this.pitch,this.bearing,l);this._elevation=e;const u=this.calculateCenterFromCameraLngLatAlt(h.toLngLat(),a.aP(h.z,c.y),this.bearing,this.pitch);this._elevation=u.elevation,this._center=u.center,this.setZoom(u.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.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=a.ai(1,this.center.lat)*this.worldSize;return kt(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const r=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?(r+=e[l]*this.min[l],a+=e[l]*this.max[l]):(a+=e[l]*this.min[l],r+=e[l]*this.max[l]);return r>=0?2:a<0?0:1}}class Dt{distanceToTile2d(e,r,a,l){const c=l.distanceX([e,r]),h=l.distanceY([e,r]);return Math.hypot(c,h)}getWrap(e,r,a){return a}getTileBoundingVolume(e,r,l,c){var h,u;let p=l,g=l;if(null==c?void 0:c.terrain){const y=new a.Z(e.z,r,e.z,e.x,e.y),x=c.terrain.getMinMaxElevation(y);p=null!==(h=x.minElevation)&&void 0!==h?h:l,g=null!==(u=x.maxElevation)&&void 0!==u?u:l}const y=1<c}allowWorldCopies(){return!0}prepareNextFrame(){}}class At{constructor(e,r,a){this.points=e,this.planes=r,this.aabb=a}static fromInvProjectionMatrix(e,r=1,l=0,c,h){const u=h?[[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]],p=Math.pow(2,l),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((l=>function(e,r,l,c){const h=a.av([],e,r),u=1/h[3]/l*c;return a.aX(h,h,[u,u,1/h[3],u])}(l,e,r,p)));c&&function(e,r,l,c){const h=c?4:0,u=c?0:4;let p=0;const g=[],y=[];for(let r=0;r<4;r++){const l=a.aT([],e[r+u],e[r+h]),c=a.aY(l);a.aQ(l,l,1/c),g.push(c),y.push(l)}for(let r=0;r<4;r++){const c=a.aZ(e[r+h],y[r],l);p=null!==c&&c>=0?Math.max(p,c):Math.max(p,g[r])}const x=function(e,r){const l=a.aT([],e[r[0]],e[r[1]]),c=a.aT([],e[r[2]],e[r[1]]),h=[0,0,0,0];return a.aU(h,a.aV([],l,c)),h[3]=-a.aW(h,e[r[0]]),h}(e,r),v=function(e,r){const l=a.a_(e),c=a.a$([],e,1/l),h=a.aT([],r,a.aQ([],c,a.aW(r,c))),u=a.a_(h);if(u>0){const e=Math.sqrt(1-c[3]*c[3]),l=a.aQ([],c,-c[3]),p=a.aR([],l,a.aQ([],h,e/u));return a.b0(r,p)}return null}(l,x);if(null!==v){const e=v/a.aW(y[0],x);p=Math.min(p,e)}for(let r=0;r<4;r++){const a=Math.min(p,g[r]);e[r+u]=[e[r+h][0]+y[r][0]*a,e[r+h][1]+y[r][1]*a,e[r+h][2]+y[r][2]*a,1]}}(g,u[0],c,h);const y=u.map((e=>{const r=a.aT([],g[e[0]],g[e[1]]),l=a.aT([],g[e[2]],g[e[1]]),c=a.aU([],a.aV([],r,l)),h=-a.aW(c,g[e[1]]);return c.concat(h)})),x=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],v=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of g)for(let r=0;r<3;r++)x[r]=Math.min(x[r],e[r]),v[r]=Math.max(v[r],e[r]);return new At(g,y,new zt(x,v))}}class Lt{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,r,a){return this._helper.interpolatePadding(e,r,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,r,a=!0){this._helper.resize(e,r,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,r){this._helper.overrideNearFarZ(e,r)}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 nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,r){}constructor(e,r,a,l,c){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Rt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,r)=>this.getConstrained(e,r)},e,r,a,l,c),this._coveringTilesDetailsProvider=new Dt}clone(){const e=new Lt;return e.apply(this),e}apply(e,r,a){this._helper.apply(e,r,a)}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 r=[new a.b1(0,e)];if(this._helper._renderWorldCopies){const l=this.screenPointToMercatorCoordinate(new a.P(0,0)),c=this.screenPointToMercatorCoordinate(new a.P(this._helper._width,0)),h=this.screenPointToMercatorCoordinate(new a.P(this._helper._width,this._helper._height)),u=this.screenPointToMercatorCoordinate(new a.P(0,this._helper._height)),p=Math.floor(Math.min(l.x,c.x,h.x,u.x)),g=Math.floor(Math.max(l.x,c.x,h.x,u.x)),y=1;for(let l=p-y;l<=g+y;l++)0!==l&&r.push(new a.b1(l,e))}return r}getCameraFrustum(){return At.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const r=this.screenPointToLocation(this.centerPoint,e),a=e?e.getElevationForLngLatZoom(r,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(a)}setLocationAtPoint(e,r){const l=a.ai(this.elevation,this.center.lat),c=this.screenPointToMercatorCoordinateAtZ(r,l),h=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,l),u=a.a0.fromLngLat(e),p=new a.a0(u.x-(c.x-h.x),u.y-(c.y-h.y));this.setCenter(null==p?void 0:p.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,r){return r?this.coordinatePoint(a.a0.fromLngLat(e),r.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(a.a0.fromLngLat(e))}screenPointToLocation(e,r){var a;return null===(a=this.screenPointToMercatorCoordinate(e,r))||void 0===a?void 0:a.toLngLat()}screenPointToMercatorCoordinate(e,r){if(r){const a=r.pointCoordinate(e);if(null!=a)return a}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,r){const l=r||0,c=[e.x,e.y,0,1],h=[e.x,e.y,1,1];a.av(c,c,this._pixelMatrixInverse),a.av(h,h,this._pixelMatrixInverse);const u=c[3],p=h[3],g=c[1]/u,y=h[1]/p,x=c[2]/u,v=h[2]/p,w=x===v?0:(l-x)/(v-x);return new a.a0(a.C.number(c[0]/u,h[0]/p,w)/this.worldSize,a.C.number(g,y,w)/this.worldSize,l)}coordinatePoint(e,r=0,l=this._pixelMatrix){const c=[e.x*this.worldSize,e.y*this.worldSize,r,1];return a.av(c,c,l),new a.P(c[0]/c[3],c[1]/c[3])}getBounds(){const e=Math.max(0,this._helper._height/2-Ct(this));return(new G).extend(this.screenPointToLocation(new a.P(0,e))).extend(this.screenPointToLocation(new a.P(this._helper._width,e))).extend(this.screenPointToLocation(new a.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new a.P(0,this._helper._height)))}isPointOnMapSurface(e,r){return r?null!=r.pointCoordinate(e):e.y>this.height/2-Ct(this)}calculatePosMatrix(e,r=!1,l){var c;const h=null!==(c=e.key)&&void 0!==c?c:a.b2(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),u=r?this._alignedPosMatrixCache:this._posMatrixCache;if(u.has(h)){const e=u.get(h);return l?e.f32:e.f64}const p=Et(e,this.worldSize);a.O(p,r?this._alignedProjMatrix:this._viewProjMatrix,p);const g={f64:p,f32:new Float32Array(p)};return u.set(h,g),l?g.f32:g.f64}calculateFogMatrix(e){const r=e.key,l=this._fogMatrixCacheF32;if(l.has(r))return l.get(r);const c=Et(e,this.worldSize);return a.O(c,this._fogMatrix,c),l.set(r,new Float32Array(c)),l.get(r)}getConstrained(e,r){r=a.ag(+r,this.minZoom,this.maxZoom);const l={center:new a.S(e.lng,e.lat),zoom:r};let c=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===c){const e=180-1e-10;c=[-e,e]}const h=this.tileSize*a.ae(l.zoom);let u=0,p=h,g=0,y=h,x=0,v=0;const{x:w,y:M}=this.size;if(this._helper._latRange){const e=this._helper._latRange;u=a.U(e[1])*h,p=a.U(e[0])*h,p-up&&(R=p-e)}if(c){const e=(g+y)/2;let r=C;this._helper._renderWorldCopies&&(r=a.aN(C,e-h/2,e+h/2));const l=w/2;r-ly&&(k=y-l)}if(void 0!==k||void 0!==R){const e=new a.P(null!=k?k:C,null!=R?R:A);l.center=St(h,e).wrap()}return l}calculateCenterFromCameraLngLatAlt(e,r,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,r,a,l)}_calculateNearFarZIfNeeded(e,r,l){if(!this._helper.autoCalculateNearFarZ)return;const c=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),h=e-c*this._helper._pixelPerMeter/Math.cos(r),u=c<0?h:e,p=Math.PI/2+this.pitchInRadians,g=a.ad(this.fov)*(Math.abs(Math.cos(a.ad(this.roll)))*this.height+Math.abs(Math.sin(a.ad(this.roll)))*this.width)/this.height*(.5+l.y/this.height),y=Math.sin(g)*u/Math.sin(a.ag(Math.PI-p-g,.01,Math.PI-.01)),x=Ct(this),v=Math.atan(x/this._helper.cameraToCenterDistance),w=a.ad(.75),M=v>w?2*v*(.5+l.y/(2*x)):w,C=Math.sin(M)*u/Math.sin(a.ag(Math.PI-p-M,.01,Math.PI-.01)),A=Math.min(y,C);this._helper._farZ=1.01*(Math.cos(Math.PI/2-r)*A+u),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,r=Pt(this.worldSize,this.center),l=r.x,c=r.y;this._helper._pixelPerMeter=a.ai(1,this.center.lat)*this.worldSize;const h=a.ad(Math.min(this.pitch,yt)),u=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(h));let p;this._calculateNearFarZIfNeeded(u,h,e),p=new Float64Array(16),a.b3(p,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),a.ap(this._invProjMatrix,p),p[8]=2*-e.x/this._helper._width,p[9]=2*e.y/this._helper._height,this._projectionMatrix=a.b4(p),a.N(p,p,[1,-1,1]),a.M(p,p,[0,0,-this._helper.cameraToCenterDistance]),a.b5(p,p,-this.rollInRadians),a.b6(p,p,this.pitchInRadians),a.b5(p,p,-this.bearingInRadians),a.M(p,p,[-l,-c,0]),this._mercatorMatrix=a.N([],p,[this.worldSize,this.worldSize,this.worldSize]),a.N(p,p,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=a.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,p),a.M(p,p,[0,0,-this.elevation]),this._viewProjMatrix=p,this._invViewProjMatrix=a.ap([],p);const g=[0,0,-1,1];a.av(g,g,this._invViewProjMatrix),this._cameraPosition=[g[0]/g[3],g[1]/g[3],g[2]/g[3]],this._fogMatrix=new Float64Array(16),a.b3(this._fogMatrix,this.fovInRadians,this.width/this.height,u,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,a.N(this._fogMatrix,this._fogMatrix,[1,-1,1]),a.M(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),a.b5(this._fogMatrix,this._fogMatrix,-this.rollInRadians),a.b6(this._fogMatrix,this._fogMatrix,this.pitchInRadians),a.b5(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),a.M(this._fogMatrix,this._fogMatrix,[-l,-c,0]),a.N(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),a.M(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=a.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,p);const y=this._helper._width%2/2,x=this._helper._height%2/2,v=Math.cos(this.bearingInRadians),w=Math.sin(-this.bearingInRadians),M=l-Math.round(l)+v*y+w*x,C=c-Math.round(c)+v*x+w*y,A=new Float64Array(p);if(a.M(A,A,[M>.5?M-1:M,C>.5?C-1:C,0]),this._alignedProjMatrix=A,p=a.ap(new Float64Array(16),this._pixelMatrix),!p)throw new Error("failed to invert matrix");this._pixelMatrixInverse=p,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new a.P(0,0)),r=[e.x*this.worldSize,e.y*this.worldSize,0,1];return a.av(r,r,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=a.ai(1,this.center.lat)*this.worldSize;return kt(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,r){const l=a.a0.fromLngLat(e),c=[l.x*this.worldSize,l.y*this.worldSize,r,1];return a.av(c,c,this._viewProjMatrix),c[2]/c[3]}getProjectionData(e){const{overscaledTileID:r,aligned:l,applyTerrainMatrix:c}=e,h=this._helper.getMercatorTileCoordinates(r),u=r?this.calculatePosMatrix(r,l,!0):null;let p;return p=r&&r.terrainRttPosMatrix32f&&c?r.terrainRttPosMatrix32f:u||a.b7(),{mainMatrix:p,tileMercatorCoords:h,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:p}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,r,a){return 1}transformLightDirection(e){return a.aS(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,r,l,c){const h=this.calculatePosMatrix(l);let u;c?(u=[e,r,c(e,r),1],a.av(u,u,h)):(u=[e,r,0,1],ze(u,u,h));const p=u[3];return{point:new a.P(u[0]/p,u[1]/p),signedDistanceFromCamera:p,isOccluded:!1}}populateCache(e){for(const r of e)this.calculatePosMatrix(r)}getMatrixForModel(e,r){const l=a.a0.fromLngLat(e,r),c=l.meterInMercatorCoordinateUnits(),h=a.b8();return a.M(h,h,[l.x,l.y,l.z]),a.b5(h,h,Math.PI),a.b6(h,h,Math.PI/2),a.N(h,h,[-c,c,c]),h}getProjectionDataForCustomLayer(e=!0){const r=new a.Z(0,0,0,0,0),l=this.getProjectionData({overscaledTileID:r,applyGlobeMatrix:e}),c=Et(r,this.worldSize);a.O(c,this._viewProjMatrix,c),l.tileMercatorCoords=[0,0,1,1];const h=[a.$,a.$,this.worldSize/this._helper.pixelsPerMeter],u=a.b9();return a.N(u,c,h),l.fallbackMatrix=u,l.mainMatrix=u,l}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Mi(){a.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Ii(e){if(e.useSlerp)if(e.k<1){const r=a.ba(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),l=a.ba(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),c=new Float64Array(4);a.bb(c,r,l,e.k);const h=a.bc(c);e.tr.setRoll(h.roll),e.tr.setPitch(h.pitch),e.tr.setBearing(h.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(a.C.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(a.C.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(a.C.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Ci(e,r,l,c,h){const u=h.padding,p=Pt(h.worldSize,l.getNorthWest()),g=Pt(h.worldSize,l.getNorthEast()),y=Pt(h.worldSize,l.getSouthEast()),x=Pt(h.worldSize,l.getSouthWest()),v=a.ad(-c),w=p.rotate(v),M=g.rotate(v),C=y.rotate(v),A=x.rotate(v),k=new a.P(Math.max(w.x,M.x,A.x,C.x),Math.max(w.y,M.y,A.y,C.y)),R=new a.P(Math.min(w.x,M.x,A.x,C.x),Math.min(w.y,M.y,A.y,C.y)),D=k.sub(R),L=(h.width-(u.left+u.right+r.left+r.right))/D.x,B=(h.height-(u.top+u.bottom+r.top+r.bottom))/D.y;if(B<0||L<0)return void Mi();const O=Math.min(a.aj(h.scale*Math.min(L,B)),e.maxZoom),j=a.P.convert(e.offset),N=new a.P((r.left-r.right)/2,(r.top-r.bottom)/2).rotate(a.ad(c)),U=j.add(N).mult(h.scale/a.ae(O));return{center:St(h.worldSize,p.add(y).div(2).sub(U)),zoom:O,bearing:c}}class Ot{get useGlobeControls(){return!1}handlePanInertia(e,r){return{easingOffset:e,easingCenter:r.center}}handleMapControlsRollPitchBearingZoom(e,r){e.bearingDelta&&r.setBearing(r.bearing+e.bearingDelta),e.pitchDelta&&r.setPitch(r.pitch+e.pitchDelta),e.rollDelta&&r.setRoll(r.roll+e.rollDelta),e.zoomDelta&&r.setZoom(r.zoom+e.zoomDelta)}handleMapControlsPan(e,r,a){e.around.distSqr(r.centerPoint)<.01||r.setLocationAtPoint(a,e.around)}cameraForBoxAndBearing(e,r,a,l,c){return Ci(e,r,a,l,c)}handleJumpToCenterZoom(e,r){e.zoom!==(void 0!==r.zoom?+r.zoom:e.zoom)&&e.setZoom(+r.zoom),void 0!==r.center&&e.setCenter(a.S.convert(r.center))}handleEaseTo(e,r){const l=e.zoom,c=e.padding,h={roll:e.roll,pitch:e.pitch,bearing:e.bearing},u={roll:void 0===r.roll?e.roll:r.roll,pitch:void 0===r.pitch?e.pitch:r.pitch,bearing:void 0===r.bearing?e.bearing:r.bearing},p=void 0!==r.zoom,g=!e.isPaddingEqual(r.padding);let y=!1;const x=p?+r.zoom:e.zoom;let v=e.centerPoint.add(r.offsetAsPoint);const w=e.screenPointToLocation(v),{center:M,zoom:C}=e.getConstrained(a.S.convert(r.center||w),null!=x?x:l);xi(e,M);const A=Pt(e.worldSize,w),k=Pt(e.worldSize,M).sub(A),R=a.ae(C-l);return y=C!==l,{easeFunc:p=>{if(y&&e.setZoom(a.C.number(l,C,p)),a.bd(h,u)||Ii({startEulerAngles:h,endEulerAngles:u,tr:e,k:p,useSlerp:h.roll!=u.roll}),g&&(e.interpolatePadding(c,r.padding,p),v=e.centerPoint.add(r.offsetAsPoint)),r.around)e.setLocationAtPoint(r.around,r.aroundPoint);else{const r=a.ae(e.zoom-l),c=C>l?Math.min(2,R):Math.max(.5,R),h=Math.pow(c,1-p),u=St(e.worldSize,A.add(k.mult(p*h)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?u.wrap():u,v)}},isZooming:y,elevationCenter:M}}handleFlyTo(e,r){const l=void 0!==r.zoom,c=e.zoom,h=e.getConstrained(a.S.convert(r.center||r.locationAtOffset),l?+r.zoom:c),u=h.center,p=h.zoom;xi(e,u);const g=Pt(e.worldSize,r.locationAtOffset),y=Pt(e.worldSize,u).sub(g),x=y.mag(),v=a.ae(p-c);let w;if(void 0!==r.minZoom){const l=Math.min(+r.minZoom,c,p),h=e.getConstrained(u,l).zoom;w=a.ae(h-c)}return{easeFunc:(r,l,h,x)=>{e.setZoom(1===r?p:c+a.aj(l));const v=1===r?u:St(e.worldSize,g.add(y.mult(h)).mult(l));e.setLocationAtPoint(e.renderWorldCopies?v.wrap():v,x)},scaleOfZoom:v,targetCenter:u,scaleOfMinZoom:w,pixelPathLength:x}}}class jt{constructor(e,r,a){this.blendFunction=e,this.blendColor=r,this.mask=a}}jt.Replace=[1,0],jt.disabled=new jt(jt.Replace,a.be.transparent,[!1,!1,!1,!1]),jt.unblended=new jt(jt.Replace,a.be.transparent,[!0,!0,!0,!0]),jt.alphaBlended=new jt([1,771],a.be.transparent,[!0,!0,!0,!0]);const Ei=2305;class Zt{constructor(e,r,a){this.enable=e,this.mode=r,this.frontFace=a}}Zt.disabled=new Zt(!1,1029,Ei),Zt.backCCW=new Zt(!0,1029,Ei),Zt.frontCCW=new Zt(!0,1028,Ei);class Ut{constructor(e,r,a){this.func=e,this.mask=r,this.range=a}}Ut.ReadOnly=!1,Ut.ReadWrite=!0,Ut.disabled=new Ut(519,Ut.ReadOnly,[0,1]);const Ai=7680;class Vt{constructor(e,r,a,l,c,h){this.test=e,this.ref=r,this.mask=a,this.fail=l,this.depthFail=c,this.pass=h}}Vt.disabled=new Vt({func:519,mask:0},0,0,Ai,Ai,Ai);const zi=new WeakMap;function ki(e){var r;if(zi.has(e))return zi.get(e);{const a=null===(r=e.getParameter(e.VERSION))||void 0===r?void 0:r.startsWith("WebGL 2.0");return zi.set(e,a),a}}class Wt{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 r=e.context,l=r.gl;this._texFormat=l.RGBA,this._texType=l.UNSIGNED_BYTE;const c=new a.aK;c.emplaceBack(-1,-1),c.emplaceBack(2,-1),c.emplaceBack(-1,2);const h=new a.aM;h.emplaceBack(0,1,2),this._fullscreenTriangle=new wt(r.createVertexBuffer(c,mi.members),r.createIndexBuffer(h),a.aL.simpleSegment(0,0,c.length,h.length)),this._resultBuffer=new Uint8Array(4),r.activeTexture.set(l.TEXTURE1);const u=l.createTexture();l.bindTexture(l.TEXTURE_2D,u),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=r.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(u),ki(l)&&(this._pbo=l.createBuffer(),l.bindBuffer(l.PIXEL_PACK_BUFFER,this._pbo),l.bufferData(l.PIXEL_PACK_BUFFER,4,l.STREAM_READ),l.bindBuffer(l.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,r){const a=this._updateCount;return this._readbackQueue?a>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():a>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,r),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,r=e.gl;e.activeTexture.set(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,r){const l=this._cachedRenderContext.context,c=l.gl;if(this._bindFramebuffer(),l.viewport.set([0,0,this._texWidth,this._texHeight]),l.clear({color:a.be.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(l,c.TRIANGLES,Ut.disabled,Vt.disabled,jt.unblended,Zt.disabled,((e,r)=>({u_input:e,u_output_expected:r}))(e,r),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&ki(c)){c.bindBuffer(c.PIXEL_PACK_BUFFER,this._pbo),c.readBuffer(c.COLOR_ATTACHMENT0),c.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null);const e=c.fenceSync(c.SYNC_GPU_COMMANDS_COMPLETE,0);c.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&&ki(e)){const r=e.clientWaitSync(this._readbackQueue.sync,0,0);if(r===e.WAIT_FAILED)return a.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(r===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=Wt._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let r=0;return r+=e[0]/256,r+=e[1]/65536,r+=e[2]/16777216,e[3]<127&&(r=-r),r/128}}const Ri=a.$/128;function Di(e,r){const l=void 0!==e.granularity?Math.max(e.granularity,1):1,c=l+(e.generateBorders?2:0),h=l+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),u=c+1,p=h+1,g=e.generateBorders?-1:0,y=e.generateBorders||e.extendToNorthPole?-1:0,x=l+(e.generateBorders?1:0),v=l+(e.generateBorders||e.extendToSouthPole?1:0),w=u*p,M=c*h*6,C=u*p>65536;if(C&&"16bit"===r)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const A=C||"32bit"===r,k=new Int16Array(2*w);let R=0;for(let r=y;r<=v;r++)for(let c=g;c<=x;c++){let h=c/l*a.$;-1===c&&(h=-Ri),c===l+1&&(h=a.$+Ri);let u=r/l*a.$;-1===r&&(u=e.extendToNorthPole?a.bg:-Ri),r===l+1&&(u=e.extendToSouthPole?a.bh:a.$+Ri),k[R++]=h,k[R++]=u}const D=A?new Uint32Array(M):new Uint16Array(M);let L=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,r,a,l,c){return this.currentProjection.getMeshFromTileID(e,r,a,l,c)}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 Bi(e){const r=Vi(e.worldSize,e.center.lat);return 2*Math.PI*r}function Oi(e,r,l,c,h){const u=1/(1<1e-6){const c=e[0]/l,h=Math.acos(e[2]/l),u=(c>0?h:-h)/Math.PI*180;return new a.S(a.aN(u,-180,180),r)}return new a.S(0,r)}function Ui(e){return Math.cos(e*Math.PI/180)}function Zi(e,r){const l=Ui(e),c=Ui(r);return a.aj(c/l)}function $i(e,r){const l=e.rotate(r.bearingInRadians),c=r.zoom+Zi(r.center.lat,0),h=a.bj(1/Ui(r.center.lat),1/Ui(Math.min(Math.abs(r.center.lat),60)),a.bm(c,7,3,0,1)),u=360/Bi({worldSize:r.worldSize,center:{lat:r.center.lat}});return new a.S(r.center.lng-l.x*u*h,a.ag(r.center.lat+l.y*u,-a.ah,a.ah))}function Gi(e){const r=.5*e,a=Math.sin(r),l=Math.cos(r);return Math.log(a+l)-Math.log(l-a)}function qi(e,r,l,c){const h=e.lat+l*c;if(Math.abs(l)>1){const u=(Math.sign(e.lat+l)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,p=Math.abs(e.lat+l)*Math.PI/180,g=Gi(u+c*(p-u)),y=Gi(u),x=Gi(p);return new a.S(e.lng+r*((g-y)/(x-y)),h)}return new a.S(e.lng+r*c,h)}class hi{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,r,a,l){const c=`${e.z}_${e.x}_${e.y}_${(null==l?void 0:l.terrain)?"t":""}`,h=this._cache.get(c);if(h)return h;const u=this._cachePrevious.get(c);if(u)return this._cache.set(c,u),u;const p=this._boundingVolumeFactory(e,r,a,l);return this._cache.set(c,p),this._hadAnyChanges=!0,p}}class ui{constructor(e,r,a,l){this.min=a,this.max=l,this.points=e,this.planes=r}static fromAabb(e,r){const a=[];for(let l=0;l<8;l++)a.push([1&~l?e[0]:r[0],1==(l>>1&1)?r[1]:e[1],1==(l>>2&1)?r[2]:e[2]]);return new ui(a,[[-1,0,0,r[0]],[1,0,0,-e[0]],[0,-1,0,r[1]],[0,1,0,-e[1]],[0,0,-1,r[2]],[0,0,1,-e[2]]],e,r)}static fromCenterSizeAngles(e,r,l){const c=a.bq([],l[0],l[1],l[2]),h=a.br([],[r[0],0,0],c),u=a.br([],[0,r[1],0],c),p=a.br([],[0,0,r[2]],c),g=[...e],y=[...e];for(let r=0;r<8;r++)for(let a=0;a<3;a++){const l=e[a]+h[a]*(1&~r?-1:1)+u[a]*(1==(r>>1&1)?1:-1)+p[a]*(1==(r>>2&1)?1:-1);g[a]=Math.min(g[a],l),y[a]=Math.max(y[a],l)}const x=[];for(let r=0;r<8;r++){const l=[...e];a.aR(l,l,a.aQ([],h,1&~r?-1:1)),a.aR(l,l,a.aQ([],u,1==(r>>1&1)?1:-1)),a.aR(l,l,a.aQ([],p,1==(r>>2&1)?1:-1)),x.push(l)}return new ui(x,[[...h,-a.aW(h,x[0])],[...u,-a.aW(u,x[0])],[...p,-a.aW(p,x[0])],[-h[0],-h[1],-h[2],-a.aW(h,x[7])],[-u[0],-u[1],-u[2],-a.aW(u,x[7])],[-p[0],-p[1],-p[2],-a.aW(p,x[7])]],g,y)}intersectsFrustum(e){let r=!0;const a=this.points.length,l=this.planes.length,c=e.planes.length,h=e.points.length;for(let l=0;l=0&&h++}if(0===h)return 0;h=0&&l++}if(0===l)return 0}return 1}intersectsPlane(e){const r=this.points.length;let a=0;for(let l=0;l=0&&a++}return a===r?2:0===a?0:1}}function Wi(e,r,a){const l=e-r;return l<0?-l:Math.max(0,l-a)}function Hi(e,r,a,l,c){const h=e-a;let u;return u=h<0?Math.min(-h,1+h-c):h>1?Math.min(Math.max(h-c,0),1-h):0,Math.max(u,Wi(r,l,c))}class pi{constructor(){this._boundingVolumeCache=new hi(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,r,a,l){const c=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,r,a,l){return this._boundingVolumeCache.getTileBoundingVolume(e,r,a,l)}_computeTileBoundingVolume(e,r,l,c){var h,u;let p=l,g=l;if(null==c?void 0:c.terrain){const y=new a.Z(e.z,r,e.z,e.x,e.y),x=c.terrain.getMinMaxElevation(y);p=null!==(h=x.minElevation)&&void 0!==h?h:l,g=null!==(u=x.maxElevation)&&void 0!==u?u:l}if(p/=a.bt,g/=a.bt,p+=1,g+=1,e.z<=0)return ui.fromAabb([-g,-g,-g],[g,g,g]);if(1===e.z)return ui.fromAabb([0===e.x?-g:0,0===e.y?0:-g,-g],[0===e.x?0:g,0===e.y?g:0,g]);{const r=[Oi(0,0,e.x,e.y,e.z),Oi(a.$,0,e.x,e.y,e.z),Oi(a.$,a.$,e.x,e.y,e.z),Oi(0,a.$,e.x,e.y,e.z)],l=[];for(const e of r)l.push(a.aQ([],e,g));if(g!==p)for(const e of r)l.push(a.aQ([],e,p));0===e.y&&l.push([0,1,0]),e.y===(1<=(1<{this._calcMatrices()},getConstrained:(e,r)=>this.getConstrained(e,r)}),this._coveringTilesDetailsProvider=new pi}clone(){const e=new fi;return e.apply(this),e}apply(e,r){this._globeLatitudeErrorCorrectionRadians=r||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=a.bo();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:r,applyGlobeMatrix:a}=e,l=this._helper.getMercatorTileCoordinates(r);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:l,clippingPlane:this._cachedClippingPlane,projectionTransition:a?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const r=this.pitchInRadians,l=this.cameraToCenterDistance/e,c=Math.sin(r)*l,h=Math.cos(r)*l+1,u=1/Math.sqrt(c*c+h*h)*1;let p=-c,g=h;const y=Math.sqrt(p*p+g*g);p/=y,g/=y;const x=[0,p,g];a.bv(x,x,[0,0,0],-this.bearingInRadians),a.bw(x,x,[0,0,0],-1*this.center.lat*Math.PI/180),a.bx(x,x,[0,0,0],this.center.lng*Math.PI/180);const v=1/a.aY(x);return a.aQ(x,x,v),[...x,-u*v]}isLocationOccluded(e){return!this.isSurfacePointVisible(ji(e))}transformLightDirection(e){const r=this._helper._center.lng*Math.PI/180,l=this._helper._center.lat*Math.PI/180,c=Math.cos(l),h=[Math.sin(r)*c,Math.sin(l),Math.cos(r)*c],u=[h[2],0,-h[0]],p=[0,0,0];a.aV(p,u,h),a.aU(u,u),a.aU(p,p);const g=[0,0,0];return a.aU(g,[u[0]*e[0]+p[0]*e[1]+h[0]*e[2],u[1]*e[0]+p[1]*e[1]+h[1]*e[2],u[2]*e[0]+p[2]*e[1]+h[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,r,l){const c=function(e,r,l){const c=1/(1<h&&(h=r),lp&&(p=l)}const x=[y.lng+u,y.lat+g,y.lng+h,y.lat+p];return this.isSurfacePointOnScreen([0,1,0])&&(x[3]=90,x[0]=-180,x[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(x[1]=-90,x[0]=-180,x[2]=180),new G(x)}getConstrained(e,r){const l=a.ag(e.lat,-a.ah,a.ah),c=a.ag(+r,this.minZoom+Zi(0,l),this.maxZoom);return{center:new a.S(e.lng,l),zoom:c}}calculateCenterFromCameraLngLatAlt(e,r,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,r,a,l)}setLocationAtPoint(e,r){const l=ji(this.unprojectScreenPoint(r)),c=ji(e),h=a.bo();a.bA(h);const u=a.bo();a.bx(u,l,h,-this.center.lng*Math.PI/180),a.bw(u,u,h,this.center.lat*Math.PI/180);const p=c[0]*c[0]+c[2]*c[2],g=u[0]*u[0];if(p=-R&&C<=R,L=k>=-R&&k<=R;let B,O;if(D&&L){const e=this.center.lng*Math.PI/180,r=this.center.lat*Math.PI/180;a.bC(v,e)+a.bC(C,r)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const r=a.bu();return a.av(r,[...e,1],this._globeViewProjMatrixNoCorrection),r[0]/=r[3],r[1]/=r[3],r[2]/=r[3],r[0]>-1&&r[0]<1&&r[1]>-1&&r[1]<1&&r[2]>-1&&r[2]<1}rayPlanetIntersection(e,r){const l=a.aW(e,r),c=a.bo(),h=a.bo();a.aQ(h,r,l),a.aT(c,e,h);const u=1-a.aW(c,c);if(u<0)return null;const p=a.aW(e,e)-1,g=-l+(l<0?1:-1)*Math.sqrt(u),y=p/g,x=g;return{tMin:Math.min(y,x),tMax:Math.max(y,x)}}unprojectScreenPoint(e){const r=this._cameraPosition,l=this.getRayDirectionFromPixel(e),c=this.rayPlanetIntersection(r,l);if(c){const e=a.bo();a.aR(e,r,[l[0]*c.tMin,l[1]*c.tMin,l[2]*c.tMin]);const h=a.bo();return a.aU(h,e),Ni(h)}const h=this._cachedClippingPlane,u=h[0]*l[0]+h[1]*l[1]+h[2]*l[2],p=-a.b0(h,r)/u,g=a.bo();if(p>0)a.aR(g,r,[l[0]*p,l[1]*p,l[2]*p]);else{const e=a.bo();a.aR(e,r,[2*l[0],2*l[1],2*l[2]]);const c=a.b0(this._cachedClippingPlane,e);a.aT(g,e,[this._cachedClippingPlane[0]*c,this._cachedClippingPlane[1]*c,this._cachedClippingPlane[2]*c])}const y=function(e){const r=a.bo();return r[0]=e[0]*-e[3],r[1]=e[1]*-e[3],r[2]=e[2]*-e[3],{center:r,radius:Math.sqrt(1-e[3]*e[3])}}(h);return Ni(function(e,r,l){const c=a.bo();a.aT(c,l,e);const h=a.bo();return a.bp(h,e,c,r/a.a_(c)),h}(y.center,y.radius,g))}getMatrixForModel(e,r){const l=a.S.convert(e),c=1/a.bt,h=a.b8();return a.by(h,h,l.lng/180*Math.PI),a.b6(h,h,-l.lat/180*Math.PI),a.M(h,h,[0,0,1+r/a.bt]),a.b6(h,h,.5*Math.PI),a.N(h,h,[c,c,c]),h}getProjectionDataForCustomLayer(e=!0){const r=this.getProjectionData({overscaledTileID:new a.Z(0,0,0,0,0),applyGlobeMatrix:e});return r.tileMercatorCoords=[0,0,1,1],r}getFastPathSimpleProjectionMatrix(e){}}class gi{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,r,a){return this._helper.interpolatePadding(e,r,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,r,a=!0){this._helper.resize(e,r,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,r){this._helper.overrideNearFarZ(e,r)}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 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,r){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=r,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Rt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,r)=>this.getConstrained(e,r)}),this._globeness=1,this._mercatorTransform=new Lt,this._verticalPerspectiveTransform=new fi}clone(){const e=new gi;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const r=this._mercatorTransform.getProjectionData(e),a=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?a.mainMatrix:r.mainMatrix,clippingPlane:a.clippingPlane,tileMercatorCoords:a.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:r.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return a.bj(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return a.bj(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,r,l){const c=this._mercatorTransform.getPitchedTextCorrection(e,r,l),h=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,r,l);return a.bj(c,h,this._globeness)}projectTileCoordinates(e,r,a,l){return this.currentTransform.projectTileCoordinates(e,r,a,l)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,r){return this.currentTransform.lngLatToCameraDepth(e,r)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,r){return this.currentTransform.getConstrained(e,r)}calculateCenterFromCameraLngLatAlt(e,r,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,r,a,l)}setLocationAtPoint(e,r){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,r),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,r),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,r){return this.currentTransform.locationToScreenPoint(e,r)}screenPointToMercatorCoordinate(e,r){return this.currentTransform.screenPointToMercatorCoordinate(e,r)}screenPointToLocation(e,r){return this.currentTransform.screenPointToLocation(e,r)}isPointOnMapSurface(e,r){return this.currentTransform.isPointOnMapSurface(e,r)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,r){return this.currentTransform.getMatrixForModel(e,r)}getProjectionDataForCustomLayer(e=!0){const r=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return r;const a=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return a.fallbackMatrix=r.mainMatrix,a}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class vi{get useGlobeControls(){return!0}handlePanInertia(e,r){const l=$i(e,r);return Math.abs(l.lng-r.center.lng)>180&&(l.lng=r.center.lng+179.5*Math.sign(l.lng-r.center.lng)),{easingCenter:l,easingOffset:new a.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,r){const l=e.around,c=r.screenPointToLocation(l);e.bearingDelta&&r.setBearing(r.bearing+e.bearingDelta),e.pitchDelta&&r.setPitch(r.pitch+e.pitchDelta),e.rollDelta&&r.setRoll(r.roll+e.rollDelta);const h=r.zoom;e.zoomDelta&&r.setZoom(r.zoom+e.zoomDelta);const u=r.zoom-h;if(0===u)return;const p=a.bz(r.center.lng,c.lng),g=p/(Math.abs(p/180)+1),y=a.bz(r.center.lat,c.lat),x=r.getRayDirectionFromPixel(l),v=r.cameraPosition,w=-1*a.aW(v,x),M=a.bo();a.aR(M,v,[x[0]*w,x[1]*w,x[2]*w]);const C=a.aY(M)-1,A=Math.exp(.5*-Math.max(C-.3,0)),k=Vi(r.worldSize,r.center.lat)/Math.min(r.width,r.height),R=a.bm(k,.9,.5,1,.25),D=(1-a.ae(-u))*Math.min(A,R),L=r.center.lat,B=r.zoom,O=new a.S(r.center.lng+g*D,a.ag(r.center.lat+y*D,-a.ah,a.ah));r.setLocationAtPoint(c,l);const j=r.center,N=a.bm(Math.abs(p),45,85,0,1),U=a.bm(k,.75,.35,0,1),Z=Math.pow(Math.max(N,U),.25),J=a.bz(j.lng,O.lng),Q=a.bz(j.lat,O.lat);r.setCenter(new a.S(j.lng+J*Z,j.lat+Q*Z).wrap()),r.setZoom(B+Zi(L,r.center.lat))}handleMapControlsPan(e,r,a){if(!e.panDelta)return;const l=r.center.lat,c=r.zoom;r.setCenter($i(e.panDelta,r).wrap()),r.setZoom(c+Zi(l,r.center.lat))}cameraForBoxAndBearing(e,r,l,c,h){const u=Ci(e,r,l,c,h),p=r.left/h.width*2-1,g=(h.width-r.right)/h.width*2-1,y=r.top/h.height*-2+1,x=(h.height-r.bottom)/h.height*-2+1,v=a.bz(l.getWest(),l.getEast())<0,w=v?l.getEast():l.getWest(),M=v?l.getWest():l.getEast(),C=Math.max(l.getNorth(),l.getSouth()),A=Math.min(l.getNorth(),l.getSouth()),k=w+.5*a.bz(w,M),R=C+.5*a.bz(C,A),D=h.clone();D.setCenter(u.center),D.setBearing(u.bearing),D.setPitch(0),D.setRoll(0),D.setZoom(u.zoom);const L=D.modelViewProjectionMatrix,B=[ji(l.getNorthWest()),ji(l.getNorthEast()),ji(l.getSouthWest()),ji(l.getSouthEast()),ji(new a.S(M,R)),ji(new a.S(w,R)),ji(new a.S(k,C)),ji(new a.S(k,A))],O=ji(u.center);let j=Number.POSITIVE_INFINITY;for(const e of B)p<0&&(j=vi.getLesserNonNegativeNonNull(j,vi.solveVectorScale(e,O,L,"x",p))),g>0&&(j=vi.getLesserNonNegativeNonNull(j,vi.solveVectorScale(e,O,L,"x",g))),y>0&&(j=vi.getLesserNonNegativeNonNull(j,vi.solveVectorScale(e,O,L,"y",y))),x<0&&(j=vi.getLesserNonNegativeNonNull(j,vi.solveVectorScale(e,O,L,"y",x)));if(Number.isFinite(j)&&0!==j)return u.zoom=D.zoom+a.aj(j),u;Mi()}handleJumpToCenterZoom(e,r){const l=e.center.lat,c=e.getConstrained(r.center?a.S.convert(r.center):e.center,e.zoom).center;e.setCenter(c.wrap());const h=void 0!==r.zoom?+r.zoom:e.zoom+Zi(l,c.lat);e.zoom!==h&&e.setZoom(h)}handleEaseTo(e,r){const l=e.zoom,c=e.center,h=e.padding,u={roll:e.roll,pitch:e.pitch,bearing:e.bearing},p={roll:void 0===r.roll?e.roll:r.roll,pitch:void 0===r.pitch?e.pitch:r.pitch,bearing:void 0===r.bearing?e.bearing:r.bearing},g=void 0!==r.zoom,y=!e.isPaddingEqual(r.padding);let x=!1;const v=r.center?a.S.convert(r.center):c,w=e.getConstrained(v,l).center;xi(e,w);const M=e.clone();M.setCenter(w),M.setZoom(g?+r.zoom:l+Zi(c.lat,v.lat)),M.setBearing(r.bearing);const C=new a.P(a.ag(e.centerPoint.x+r.offsetAsPoint.x,0,e.width),a.ag(e.centerPoint.y+r.offsetAsPoint.y,0,e.height));M.setLocationAtPoint(w,C);const A=(r.offset&&r.offsetAsPoint.mag())>0?M.center:w,k=g?+r.zoom:l+Zi(c.lat,A.lat),R=l+Zi(c.lat,0),D=k+Zi(A.lat,0),L=a.bz(c.lng,A.lng),B=a.bz(c.lat,A.lat),O=a.ae(D-R);return x=k!==l,{easeFunc:l=>{if(a.bd(u,p)||Ii({startEulerAngles:u,endEulerAngles:p,tr:e,k:l,useSlerp:u.roll!=p.roll}),y&&e.interpolatePadding(h,r.padding,l),r.around)a.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(r.around,r.aroundPoint);else{const r=D>R?Math.min(2,O):Math.max(.5,O),a=Math.pow(r,1-l),h=qi(c,L,B,l*a);e.setCenter(h.wrap())}if(x){const r=a.C.number(R,D,l)+Zi(0,e.center.lat);e.setZoom(r)}},isZooming:x,elevationCenter:A}}handleFlyTo(e,r){const l=void 0!==r.zoom,c=e.center,h=e.zoom,u=e.padding,p=!e.isPaddingEqual(r.padding),g=e.getConstrained(a.S.convert(r.center||r.locationAtOffset),h).center,y=l?+r.zoom:e.zoom+Zi(e.center.lat,g.lat),x=e.clone();x.setCenter(g),x.setZoom(y),x.setBearing(r.bearing);const v=new a.P(a.ag(e.centerPoint.x+r.offsetAsPoint.x,0,e.width),a.ag(e.centerPoint.y+r.offsetAsPoint.y,0,e.height));x.setLocationAtPoint(g,v);const w=x.center;xi(e,w);const M=function(e,r,l){const c=ji(r),h=ji(l),u=a.aW(c,h),p=Math.acos(u),g=Bi(e);return p/(2*Math.PI)*g}(e,c,w),C=h+Zi(c.lat,0),A=y+Zi(w.lat,0),k=a.ae(A-C);let R;if("number"==typeof r.minZoom){const l=+r.minZoom+Zi(w.lat,0),c=Math.min(l,C,A)+Zi(0,w.lat),h=e.getConstrained(w,c).zoom+Zi(w.lat,0);R=a.ae(h-C)}const D=a.bz(c.lng,w.lng),L=a.bz(c.lat,w.lat);return{easeFunc:(l,h,g,x)=>{const v=qi(c,D,L,g);p&&e.interpolatePadding(u,r.padding,l);const M=1===l?w:v;e.setCenter(M.wrap());const A=C+a.aj(h);e.setZoom(1===l?y:A+Zi(0,M.lat))},scaleOfZoom:k,targetCenter:w,scaleOfMinZoom:R,pixelPathLength:M}}static solveVectorScale(e,r,a,l,c){const h="x"===l?[a[0],a[4],a[8],a[12]]:[a[1],a[5],a[9],a[13]],u=[a[3],a[7],a[11],a[15]],p=e[0]*h[0]+e[1]*h[1]+e[2]*h[2],g=e[0]*u[0]+e[1]*u[1]+e[2]*u[2],y=r[0]*h[0]+r[1]*h[1]+r[2]*h[2],x=r[0]*u[0]+r[1]*u[1]+r[2]*u[2];return y+c*g===p+c*x||u[3]*(p-y)+h[3]*(x-g)+p*x==y*g?null:(y+h[3]-c*x-c*u[3])/(y-p-c*x+c*g)}static getLesserNonNegativeNonNull(e,r){return null!==r&&r>=0&&ra.y(e,r&&r.filter((e=>"source.canvas"!==e.identifier))),Ki=a.bD();class wi extends a.E{constructor(e,r={}){super(),this._rtlPluginLoaded=()=>{for(const e in this.sourceCaches){const r=this.sourceCaches[e].getSource().type;"vector"!==r&&"geojson"!==r||this.sourceCaches[e].reload()}},this.map=e,this.dispatcher=new F(Q(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,r)=>this.getGlyphs(e,r))),this.dispatcher.registerMessageHandler("GI",((e,r)=>this.getImages(e,r))),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new T(e._requestManager,r.localIdeographFontFamily),this.lineAtlas=new E(256,512),this.crossTileSymbolIndex=new vt,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new a.bE,this._loaded=!1,this._availableImages=[],this._globalState={},this._resetUpdates(),this.dispatcher.broadcast("SR",a.bF()),ut().on(ct,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const r=this.sourceCaches[e.sourceId];if(!r)return;const a=r.getSource();if(a&&a.vectorLayerIds)for(const e in this._layers){const r=this._layers[e];r.source===a.id&&this._validateLayer(r)}}))}setGlobalStateProperty(e,r){var l,c,h;this._checkLoaded();const u=null===r?null!==(h=null===(c=null===(l=this.stylesheet.state)||void 0===l?void 0:l[e])||void 0===c?void 0:c.default)&&void 0!==h?h:null:r;if(a.bG(u,this._globalState[e]))return this;this._globalState[e]=u;const p=this._findGlobalStateAffectedSources([e]);for(const e in this.sourceCaches)p.has(e)&&(this._reloadSource(e),this._changed=!0)}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const r=[];for(const l in e)!a.bG(this._globalState[l],e[l].default)&&(r.push(l),this._globalState[l]=e[l].default);const l=this._findGlobalStateAffectedSources(r);for(const e in this.sourceCaches)l.has(e)&&(this._reloadSource(e),this._changed=!0)}_findGlobalStateAffectedSources(e){if(0===e.length)return new Set;const r=new Set;for(const a in this._layers){const l=this._layers[a],c=l.getLayoutAffectingGlobalStateRefs();for(const a of e)c.has(a)&&r.add(l.source)}return r}loadURL(e,r={},l){this.fire(new a.l("dataloading",{dataType:"style"})),r.validate="boolean"!=typeof r.validate||r.validate;const c=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const h=this._loadStyleRequest;a.j(c,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,r,l)})).catch((e=>{this._loadStyleRequest=null,e&&!h.signal.aborted&&this.fire(new a.k(e))}))}loadJSON(e,r={},l){this.fire(new a.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,p.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,r.validate=!1!==r.validate,this._load(e,r,l)})).catch((()=>{}))}loadEmpty(){this.fire(new a.l("dataloading",{dataType:"style"})),this._load(Ki,{validate:!1})}_load(e,r,l){var c,h,u;const p=r.transformStyle?r.transformStyle(l,e):e;if(!r.validate||!Yi(this,a.z(p))){this._loaded=!0,this.stylesheet=p;for(const e in p.sources)this.addSource(e,p.sources[e],{validate:!1});p.sprite?this._loadSprite(p.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(p.glyphs),this._createLayers(),this.light=new I(this.stylesheet.light),this._setProjectionInternal((null===(c=this.stylesheet.projection)||void 0===c?void 0:c.type)||"mercator"),this.sky=new S(this.stylesheet.sky),this.map.setTerrain(null!==(h=this.stylesheet.terrain)&&void 0!==h?h:null),this.setGlobalState(null!==(u=this.stylesheet.state)&&void 0!==u?u:null),this.fire(new a.l("data",{dataType:"style"})),this.fire(new a.l("style.load"))}}_createLayers(){const e=a.bH(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const r of e){const e=a.bI(r);e.setEventedParent(this,{layer:{id:r.id}}),this._layers[r.id]=e}}_loadSprite(e,r=!1,l=void 0){let c;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,r,l,c){return a._(this,void 0,void 0,(function*(){const h=A(e),u=l>1?"@2x":"",g={},y={};for(const{id:e,url:l}of h){const h=r.transformRequest(k(l,u,".json"),"SpriteJSON");g[e]=a.j(h,c);const p=r.transformRequest(k(l,u,".png"),"SpriteImage");y[e]=C.getImage(p,c)}return yield Promise.all([...Object.values(g),...Object.values(y)]),function(e,r){return a._(this,void 0,void 0,(function*(){const a={};for(const l in e){a[l]={};const c=p.getImageCanvasContext((yield r[l]).data),h=(yield e[l]).data;for(const e in h){const{width:r,height:u,x:p,y:g,sdf:y,pixelRatio:x,stretchX:v,stretchY:w,content:M,textFitWidth:C,textFitHeight:A}=h[e];a[l][e]={data:null,pixelRatio:x,sdf:y,stretchX:v,stretchY:w,content:M,textFitWidth:C,textFitHeight:A,spriteData:{width:r,height:u,x:p,y:g,context:c}}}}return a}))}(g,y)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const a in e){this._spritesImagesIds[a]=[];const l=this._spritesImagesIds[a]?this._spritesImagesIds[a].filter((r=>!(r in e))):[];for(const e of l)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const l in e[a]){const c="default"===a?l:`${a}:${l}`;this._spritesImagesIds[a].push(c),c in this.imageManager.images?this.imageManager.updateImage(c,e[a][l],!1):this.imageManager.addImage(c,e[a][l]),r&&(this._changedImages[c]=!0)}}})).catch((e=>{this._spriteRequest=null,c=e,this.fire(new a.k(c))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),r&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"})),l&&l(c)}))}_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 a.l("data",{dataType:"style"}))}_validateLayer(e){const r=this.sourceCaches[e.source];if(!r)return;const l=e.sourceLayer;if(!l)return;const c=r.getSource();("geojson"===c.type||c.vectorLayerIds&&-1===c.vectorLayerIds.indexOf(l))&&this.fire(new a.k(new Error(`Source layer "${l}" does not exist on source "${c.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.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,r=!1){const l=this._serializedAllLayers();if(!e||0===e.length)return Object.values(r?a.bJ(l):l);const c=[];for(const h of e)if(l[h]){const e=r?a.bJ(l[h]):l[h];c.push(e)}return c}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const r=Object.keys(this._layers);for(const a of r){const r=this._layers[a];"custom"!==r.type&&(e[a]=r.serialize())}return e}hasTransitions(){var e,r,a;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(r=this.sky)||void 0===r?void 0:r.hasTransition())return!0;if(null===(a=this.projection)||void 0===a?void 0:a.hasTransition())return!0;for(const e in this.sourceCaches)if(this.sourceCaches[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 r=this._changed;if(r){const r=Object.keys(this._updatedLayers),a=Object.keys(this._removedLayers);(r.length||a.length)&&this._updateWorkerLayers(r,a);for(const e in this._updatedSources){const r=this._updatedSources[e];if("reload"===r)this._reloadSource(e);else{if("clear"!==r)throw new Error(`Invalid action ${r}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const r in this._updatedPaintProps)this._layers[r].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const l={};for(const e in this.sourceCaches){const r=this.sourceCaches[e];l[e]=r.used,r.used=!1}for(const r of this._order){const a=this._layers[r];a.recalculate(e,this._availableImages),!a.isHidden(e.zoom)&&a.source&&(this.sourceCaches[a.source].used=!0)}for(const e in l){const r=this.sourceCaches[e];!!l[e]!=!!r.used&&r.fire(new a.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,r&&this.fire(new a.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const r in this.sourceCaches)this.sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,r){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,r={}){var l;this._checkLoaded();const c=this.serialize();if(e=r.transformStyle?r.transformStyle(c,e):e,(null===(l=r.validate)||void 0===l||l)&&Yi(this,a.z(e)))return!1;(e=a.bJ(e)).layers=a.bH(e.layers);const h=a.bK(c,e),u=this._getOperationsToPerform(h);if(u.unimplemented.length>0)throw new Error(`Unimplemented: ${u.unimplemented.join(", ")}.`);if(0===u.operations.length)return!1;for(const e of u.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const r=[],a=[];for(const l of e)switch(l.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":r.push((()=>this.addLayer.apply(this,l.args)));break;case"removeLayer":r.push((()=>this.removeLayer.apply(this,l.args)));break;case"setPaintProperty":r.push((()=>this.setPaintProperty.apply(this,l.args)));break;case"setLayoutProperty":r.push((()=>this.setLayoutProperty.apply(this,l.args)));break;case"setFilter":r.push((()=>this.setFilter.apply(this,l.args)));break;case"addSource":r.push((()=>this.addSource.apply(this,l.args)));break;case"removeSource":r.push((()=>this.removeSource.apply(this,l.args)));break;case"setLayerZoomRange":r.push((()=>this.setLayerZoomRange.apply(this,l.args)));break;case"setLight":r.push((()=>this.setLight.apply(this,l.args)));break;case"setGeoJSONSourceData":r.push((()=>this.setGeoJSONSourceData.apply(this,l.args)));break;case"setGlyphs":r.push((()=>this.setGlyphs.apply(this,l.args)));break;case"setSprite":r.push((()=>this.setSprite.apply(this,l.args)));break;case"setTerrain":r.push((()=>this.map.setTerrain.apply(this,l.args)));break;case"setSky":r.push((()=>this.setSky.apply(this,l.args)));break;case"setProjection":this.setProjection.apply(this,l.args);break;case"setGlobalState":r.push((()=>this.setGlobalState.apply(this,l.args)));break;case"setTransition":r.push((()=>{}));break;default:a.push(l.command)}return{operations:r,unimplemented:a}}addImage(e,r){if(this.getImage(e))return this.fire(new a.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,r),this._afterImageUpdated(e)}updateImage(e,r){this.imageManager.updateImage(e,r)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new a.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 a.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,r,l={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!r.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(r).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(r.type)>=0&&this._validate(a.z.source,`sources.${e}`,r,null,l))return;this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);const c=this.sourceCaches[e]=new xe(e,r,this.dispatcher);c.style=this,c.setEventedParent(this,(()=>({isSourceLoaded:c.loaded(),source:c.serialize(),sourceId:e}))),c.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const r in this._layers)if(this._layers[r].source===e)return this.fire(new a.k(new Error(`Source "${e}" cannot be removed while layer "${r}" is using it.`)));const r=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],r.fire(new a.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),r.setEventedParent(null),r.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,r){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error(`There is no source with this ID=${e}`);const a=this.sourceCaches[e].getSource();if("geojson"!==a.type)throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(r),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,r,l={}){this._checkLoaded();const c=e.id;if(this.getLayer(c))return void this.fire(new a.k(new Error(`Layer "${c}" already exists on this map.`)));let h;if("custom"===e.type){if(Yi(this,a.bL(e)))return;h=a.bI(e)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(c,e.source),e=a.bJ(e),e=a.e(e,{source:c})),this._validate(a.z.layer,`layers.${c}`,e,{arrayIndex:-1},l))return;h=a.bI(e),this._validateLayer(h),h.setEventedParent(this,{layer:{id:c}})}const u=r?this._order.indexOf(r):this._order.length;if(r&&-1===u)this.fire(new a.k(new Error(`Cannot add layer "${c}" before non-existing layer "${r}".`)));else{if(this._order.splice(u,0,c),this._layerOrderChanged=!0,this._layers[c]=h,this._removedLayers[c]&&h.source&&"custom"!==h.type){const e=this._removedLayers[c];delete this._removedLayers[c],e.type!==h.type?this._updatedSources[h.source]="clear":(this._updatedSources[h.source]="reload",this.sourceCaches[h.source].pause())}this._updateLayer(h),h.onAdd&&h.onAdd(this.map)}}moveLayer(e,r){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new a.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===r)return;const l=this._order.indexOf(e);this._order.splice(l,1);const c=r?this._order.indexOf(r):this._order.length;r&&-1===c?this.fire(new a.k(new Error(`Cannot move layer "${e}" before non-existing layer "${r}".`))):(this._order.splice(c,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const r=this._layers[e];if(!r)return void this.fire(new a.k(new Error(`Cannot remove non-existing layer "${e}".`)));r.setEventedParent(null);const l=this._order.indexOf(e);this._order.splice(l,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=r,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],r.onRemove&&r.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,r,l){this._checkLoaded();const c=this.getLayer(e);c?c.minzoom===r&&c.maxzoom===l||(null!=r&&(c.minzoom=r),null!=l&&(c.maxzoom=l),this._updateLayer(c)):this.fire(new a.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,r,l={}){this._checkLoaded();const c=this.getLayer(e);if(c){if(!a.bG(c.filter,r))return null==r?(c.setFilter(void 0),void this._updateLayer(c)):void(this._validate(a.z.filter,`layers.${c.id}.filter`,r,null,l)||(c.setFilter(a.bJ(r)),this._updateLayer(c)))}else this.fire(new a.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return a.bJ(this.getLayer(e).filter)}setLayoutProperty(e,r,l,c={}){this._checkLoaded();const h=this.getLayer(e);h?a.bG(h.getLayoutProperty(r),l)||(h.setLayoutProperty(r,l,c),this._updateLayer(h)):this.fire(new a.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,r){const l=this.getLayer(e);if(l)return l.getLayoutProperty(r);this.fire(new a.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,r,l,c={}){this._checkLoaded();const h=this.getLayer(e);h?a.bG(h.getPaintProperty(r),l)||(h.setPaintProperty(r,l,c)&&this._updateLayer(h),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new a.k(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(e,r){return this.getLayer(e).getPaintProperty(r)}setFeatureState(e,r){this._checkLoaded();const l=e.source,c=e.sourceLayer,h=this.sourceCaches[l];if(void 0===h)return void this.fire(new a.k(new Error(`The source '${l}' does not exist in the map's style.`)));const u=h.getSource().type;"geojson"===u&&c?this.fire(new a.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==u||c?(void 0===e.id&&this.fire(new a.k(new Error("The feature id parameter must be provided."))),h.setFeatureState(c,e.id,r)):this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,r){this._checkLoaded();const l=e.source,c=this.sourceCaches[l];if(void 0===c)return void this.fire(new a.k(new Error(`The source '${l}' does not exist in the map's style.`)));const h=c.getSource().type,u="vector"===h?e.sourceLayer:void 0;"vector"!==h||u?r&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new a.k(new Error("A feature id is required to remove its specific state property."))):c.removeFeatureState(u,e.id,r):this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const r=e.source,l=e.sourceLayer,c=this.sourceCaches[r];if(void 0!==c)return"vector"!==c.getSource().type||l?(void 0===e.id&&this.fire(new a.k(new Error("The feature id parameter must be provided."))),c.getFeatureState(l,e.id)):void this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new a.k(new Error(`The source '${r}' does not exist in the map's style.`)))}getTransition(){return a.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=a.bM(this.sourceCaches,(e=>e.serialize())),r=this._serializeByIds(this._order,!0),l=this.map.getTerrain()||void 0,c=this.stylesheet;return a.bN({version:c.version,name:c.name,metadata:c.metadata,light:c.light,sky:c.sky,center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,sprite:c.sprite,glyphs:c.glyphs,transition:c.transition,projection:c.projection,sources:e,layers:r,terrain:l},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.sourceCaches[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const r=e=>"fill-extrusion"===this._layers[e].type,a={},l=[];for(let c=this._order.length-1;c>=0;c--){const h=this._order[c];if(r(h)){a[h]=c;for(const r of e){const e=r[h];if(e)for(const r of e)l.push(r)}}}l.sort(((e,r)=>r.intersectionZ-e.intersectionZ));const c=[];for(let h=this._order.length-1;h>=0;h--){const u=this._order[h];if(r(u))for(let e=l.length-1;e>=0;e--){const r=l[e].feature;if(a[r.layer.id]this.map.terrain.getElevation(e,r,a):void 0));return this.placement&&h.push(function(e,r,a,l,c,h,u){const p={},g=h.queryRenderedSymbols(l),y=[];for(const e of Object.keys(g).map(Number))y.push(u[e]);y.sort(nt);for(const a of y){const l=a.featureIndex.lookupSymbolFeatures(g[a.bucketInstanceId],r,a.bucketIndex,a.sourceLayerIndex,c.filter,c.layers,c.availableImages,e);for(const e in l){const r=p[e]=p[e]||[],c=l[e];c.sort(((e,r)=>{const l=a.featureSortOrder;if(l){const a=l.indexOf(e.featureIndex);return l.indexOf(r.featureIndex)-a}return r.featureIndex-e.featureIndex}));for(const e of c)r.push(e)}}return function(e,r,a){for(const l in e)for(const c of e[l])st(c,a[r[l].source]);return e}(p,e,a)}(this._layers,u,this.sourceCaches,e,g,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(h)}querySourceFeatures(e,r){r&&r.filter&&this._validate(a.z.filter,"querySourceFeatures.filter",r.filter,null,r);const l=this.sourceCaches[e];return l?function(e,r){const a=e.getRenderableIds().map((r=>e.getTileByID(r))),l=[],c={};for(let e=0;ee.getTileByID(r))).sort(((e,r)=>r.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(r.tileID)?-1:1)))}const l=this.crossTileSymbolIndex.addLayer(a,g[a.source],e.center.lng);h=h||l}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((c=c||this._layerOrderChanged||0===a)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(p.now(),e.zoom))&&(this.pauseablePlacement=new _t(e,this.map.terrain,this._order,c,r,a,l,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,g),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(p.now()),u=!0),h&&this.pauseablePlacement.placement.setStale()),u||h)for(const e of this._order){const r=this._layers[e];"symbol"===r.type&&this.placement.updateLayerOpacities(r,g[r.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(p.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,r){return a._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(r.icons);this._updateTilesForChangedImages();const a=this.sourceCaches[r.source];return a&&a.setDependencies(r.tileID.key,r.type,r.icons),e}))}getGlyphs(e,r){return a._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(r.stacks),a=this.sourceCaches[r.source];return a&&a.setDependencies(r.tileID.key,r.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,r={}){this._checkLoaded(),e&&this._validate(a.z.glyphs,"glyphs",e,null,r)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,r,l={},c){this._checkLoaded();const h=[{id:e,url:r}],u=[...A(this.stylesheet.sprite),...h];this._validate(a.z.sprite,"sprite",u,null,l)||(this.stylesheet.sprite=u,this._loadSprite(h,!0,c))}removeSprite(e){this._checkLoaded();const r=A(this.stylesheet.sprite);if(r.find((r=>r.id===e))){if(this._spritesImagesIds[e])for(const r of this._spritesImagesIds[e])this.imageManager.removeImage(r),this._changedImages[r]=!0;r.splice(r.findIndex((r=>r.id===e)),1),this.stylesheet.sprite=r.length>0?r:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"}))}else this.fire(new a.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return A(this.stylesheet.sprite)}setSprite(e,r={},l){this._checkLoaded(),e&&this._validate(a.z.sprite,"sprite",e,null,r)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,l):(this._unloadSprite(),l&&l(null)))}}var Ji=a.aI([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Pi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,r,a,l,c,h,u,p,g){this.context=e;let y=this.boundPaintVertexBuffers.length!==l.length;for(let e=0;!y&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:r,u_fog_color:l?l.properties.get("fog-color"):a.be.white,u_fog_ground_blend:l?l.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:h?0:l?l.calculateFogBlendOpacity(c):0,u_horizon_color:l?l.properties.get("horizon-color"):a.be.white,u_horizon_fog_blend:l?l.properties.get("horizon-fog-blend"):1,u_is_globe_mode:h?1:0}),lr={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function cr(e){const r=[];for(let a=0;a({u_depth:new a.bO(e,r.u_depth),u_terrain:new a.bO(e,r.u_terrain),u_terrain_dim:new a.bf(e,r.u_terrain_dim),u_terrain_matrix:new a.bQ(e,r.u_terrain_matrix),u_terrain_unpack:new a.bR(e,r.u_terrain_unpack),u_terrain_exaggeration:new a.bf(e,r.u_terrain_exaggeration)}))(e,Z),this.projectionUniforms=((e,r)=>({u_projection_matrix:new a.bQ(e,r.u_projection_matrix),u_projection_tile_mercator_coords:new a.bR(e,r.u_projection_tile_mercator_coords),u_projection_clipping_plane:new a.bR(e,r.u_projection_clipping_plane),u_projection_transition:new a.bf(e,r.u_projection_transition),u_projection_fallback_matrix:new a.bQ(e,r.u_projection_fallback_matrix)}))(e,Z),this.binderUniforms=l?l.getUniforms(e,Z):[]}draw(e,r,a,l,c,h,u,p,g,y,x,v,w,M,C,A,k,R,D){const L=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(l),e.setColorMode(c),e.setCullFace(h),p){e.activeTexture.set(L.TEXTURE2),L.bindTexture(L.TEXTURE_2D,p.depthTexture),e.activeTexture.set(L.TEXTURE3),L.bindTexture(L.TEXTURE_2D,p.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(p[e])}if(g)for(const e in g)this.projectionUniforms[lr[e]].set(g[e]);if(u)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(u[e]);A&&A.setUniforms(e,this.binderUniforms,M,{zoom:C});let B=0;switch(r){case L.LINES:B=2;break;case L.TRIANGLES:B=3;break;case L.LINE_STRIP:B=1}for(const a of w.get()){const l=a.vaos||(a.vaos={});(l[y]||(l[y]=new Pi)).bind(e,this,x,A?A.getPaintVertexBuffers():[],v,a.vertexOffset,k,R,D),L.drawElements(r,a.primitiveLength*B,L.UNSIGNED_SHORT,a.primitiveOffset*B*2)}}}function hr(e,r,l){const c=1/a.aB(l,1,r.transform.tileZoom),h=Math.pow(2,l.tileID.overscaledZ),u=l.tileSize*Math.pow(2,r.transform.tileZoom)/h,p=u*(l.tileID.canonical.x+l.tileID.wrap*h),g=u*l.tileID.canonical.y;return{u_image:0,u_texsize:l.imageAtlasTexture.size,u_scale:[c,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[p>>16,g>>16],u_pixel_coord_lower:[65535&p,65535&g]}}const dr=(e,r,l,c)=>{const h=e.style.light,u=h.properties.get("position"),p=[u.x,u.y,u.z],g=a.bU();"viewport"===h.properties.get("anchor")&&a.bV(g,e.transform.bearingInRadians),a.bW(p,p,g);const y=e.transform.transformLightDirection(p),x=h.properties.get("color");return{u_lightpos:p,u_lightpos_globe:y,u_lightintensity:h.properties.get("intensity"),u_lightcolor:[x.r,x.g,x.b],u_vertical_gradient:+r,u_opacity:l,u_fill_translate:c}},pr=(e,r,l,c,h,u,p)=>a.e(dr(e,r,l,c),hr(u,e,p),{u_height_factor:-Math.pow(2,h.overscaledZ)/p.tileSize/8}),fr=(e,r,l,c)=>a.e(hr(r,e,l),{u_fill_translate:c}),mr=(e,r)=>({u_world:e,u_fill_translate:r}),_r=(e,r,l,c,h)=>a.e(fr(e,r,l,h),{u_world:c}),gr=(e,r,l,c,h)=>{const u=e.transform;let p,g,y=0;if("map"===l.paint.get("circle-pitch-alignment")){const e=a.aB(r,1,u.zoom);p=!0,g=[e,e],y=e/(a.$*Math.pow(2,r.tileID.overscaledZ))*2*Math.PI*h}else p=!1,g=u.pixelsToGLUnits;return{u_camera_to_center_distance:u.cameraToCenterDistance,u_scale_with_map:+("map"===l.paint.get("circle-pitch-scale")),u_pitch_with_map:+p,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:g,u_globe_extrude_scale:y,u_translate:c}},vr=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),br=e=>({u_viewport_size:[e.width,e.height]}),wr=(e,r=1)=>({u_color:e,u_overlay:0,u_overlay_scale:r}),Tr=(e,r,l,c)=>{const h=a.aB(e,1,r)/(a.$*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*c;return{u_extrude_scale:a.aB(e,1,r),u_intensity:l,u_globe_extrude_scale:h}},Sr=(e,r,l,c)=>{const h=a.L();a.bX(h,0,e.width,e.height,0,0,1);const u=e.context.gl;return{u_matrix:h,u_world:[u.drawingBufferWidth,u.drawingBufferHeight],u_image:l,u_color_ramp:c,u_opacity:r.paint.get("heatmap-opacity")}},Ir=(e,r,a)=>{const l=a.paint.get("hillshade-accent-color");let c;switch(a.paint.get("hillshade-method")){case"basic":c=4;break;case"combined":c=1;break;case"igor":c=2;break;case"multidirectional":c=3;break;default:c=0}const h=a.getIlluminationProperties();for(let r=0;r{const l=r.stride,c=a.L();return a.bX(c,0,a.$,-a.$,0,0,1),a.M(c,c,[0,-a.$,0]),{u_matrix:c,u_image:1,u_dimension:[l,l],u_zoom:e.overscaledZ,u_unpack:r.getUnpackVector()}};function kr(e,r){const l=Math.pow(2,r.canonical.z),c=r.canonical.y;return[new a.a0(0,c/l).toLngLat().lat,new a.a0(0,(c+1)/l).toLngLat().lat]}const Rr=(e,r,a=0)=>({u_image:0,u_unpack:r.getUnpackVector(),u_dimension:[r.stride,r.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:a,u_opacity:e.paint.get("color-relief-opacity")}),Dr=(e,r,l,c)=>{const h=e.transform;return{u_translation:Qr(e,r,l),u_ratio:c/a.aB(r,1,h.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/h.pixelsToGLUnits[0],1/h.pixelsToGLUnits[1]]}},Lr=(e,r,l,c,h)=>a.e(Dr(e,r,l,c),{u_image:0,u_image_height:h}),Or=(e,r,l,c,h)=>{const u=e.transform,p=Yr(r,u);return{u_translation:Qr(e,r,l),u_texsize:r.imageAtlasTexture.size,u_ratio:c/a.aB(r,1,u.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[p,h.fromScale,h.toScale],u_fade:h.t,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]]}},qr=(e,r,l,c,h,u)=>{const p=e.lineAtlas,g=Yr(r,e.transform),y="round"===l.layout.get("line-cap"),x=p.getDash(h.from,y),v=p.getDash(h.to,y),w=x.width*u.fromScale,M=v.width*u.toScale;return a.e(Dr(e,r,l,c),{u_patternscale_a:[g/w,-x.height/2],u_patternscale_b:[g/M,-v.height/2],u_sdfgamma:p.width/(256*Math.min(w,M)*e.pixelRatio)/2,u_image:0,u_tex_y_a:x.y,u_tex_y_b:v.y,u_mix:u.t})};function Yr(e,r){return 1/a.aB(e,1,r.tileZoom)}function Qr(e,r,l){return a.aC(e.transform,r,l.paint.get("line-translate"),l.paint.get("line-translate-anchor"))}const tn=(e,r,a,l,c)=>{return{u_tl_parent:e,u_scale_parent:r,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.opacity*l.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:l.paint.get("raster-brightness-min"),u_brightness_high:l.paint.get("raster-brightness-max"),u_saturation_factor:(u=l.paint.get("raster-saturation"),u>0?1-1/(1.001-u):-u),u_contrast_factor:(h=l.paint.get("raster-contrast"),h>0?1/(1-h):1+h),u_spin_weights:en(l.paint.get("raster-hue-rotate")),u_coords_top:[c[0].x,c[0].y,c[1].x,c[1].y],u_coords_bottom:[c[3].x,c[3].y,c[2].x,c[2].y]};var h,u};function en(e){e*=Math.PI/180;const r=Math.sin(e),a=Math.cos(e);return[(2*a+1)/3,(-Math.sqrt(3)*r-a+1)/3,(Math.sqrt(3)*r-a+1)/3]}const rn=(e,r,a,l,c,h,u,p,g,y,x,v,w)=>{const M=u.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:M.cameraToCenterDistance,u_pitch:M.pitch/360*2*Math.PI,u_rotate_symbol:+a,u_aspect_ratio:M.width/M.height,u_fade_change:u.options.fadeDuration?u.symbolFadeChange:1,u_label_plane_matrix:p,u_coord_matrix:g,u_is_text:+x,u_pitch_with_map:+l,u_is_along_line:c,u_is_variable_anchor:h,u_texsize:v,u_texture:0,u_translation:y,u_pitched_scale:w}},nn=(e,r,l,c,h,u,p,g,y,x,v,w,M,C)=>{const A=p.transform;return a.e(rn(e,r,l,c,h,u,p,g,y,x,v,w,C),{u_gamma_scale:c?Math.cos(A.pitch*Math.PI/180)*A.cameraToCenterDistance:1,u_device_pixel_ratio:p.pixelRatio,u_is_halo:1})},sn=(e,r,l,c,h,u,p,g,y,x,v,w,M)=>a.e(nn(e,r,l,c,h,u,p,g,y,x,!0,v,0,M),{u_texsize_icon:w,u_texture_icon:1}),on=(e,r)=>({u_opacity:e,u_color:r}),an=(e,r,l,c,h)=>a.e(function(e,r,l,c){const h=l.imageManager.getPattern(e.from.toString()),u=l.imageManager.getPattern(e.to.toString()),{width:p,height:g}=l.imageManager.getPixelSize(),y=Math.pow(2,c.tileID.overscaledZ),x=c.tileSize*Math.pow(2,l.transform.tileZoom)/y,v=x*(c.tileID.canonical.x+c.tileID.wrap*y),w=x*c.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:h.tl,u_pattern_br_a:h.br,u_pattern_tl_b:u.tl,u_pattern_br_b:u.br,u_texsize:[p,g],u_mix:r.t,u_pattern_size_a:h.displaySize,u_pattern_size_b:u.displaySize,u_scale_a:r.fromScale,u_scale_b:r.toScale,u_tile_units_to_pixels:1/a.aB(c,1,l.transform.tileZoom),u_pixel_coord_upper:[v>>16,w>>16],u_pixel_coord_lower:[65535&v,65535&w]}}(l,h,r,c),{u_opacity:e}),ln=(e,r)=>{},cn={fillExtrusion:(e,r)=>({u_lightpos:new a.bS(e,r.u_lightpos),u_lightpos_globe:new a.bS(e,r.u_lightpos_globe),u_lightintensity:new a.bf(e,r.u_lightintensity),u_lightcolor:new a.bS(e,r.u_lightcolor),u_vertical_gradient:new a.bf(e,r.u_vertical_gradient),u_opacity:new a.bf(e,r.u_opacity),u_fill_translate:new a.bT(e,r.u_fill_translate)}),fillExtrusionPattern:(e,r)=>({u_lightpos:new a.bS(e,r.u_lightpos),u_lightpos_globe:new a.bS(e,r.u_lightpos_globe),u_lightintensity:new a.bf(e,r.u_lightintensity),u_lightcolor:new a.bS(e,r.u_lightcolor),u_vertical_gradient:new a.bf(e,r.u_vertical_gradient),u_height_factor:new a.bf(e,r.u_height_factor),u_opacity:new a.bf(e,r.u_opacity),u_fill_translate:new a.bT(e,r.u_fill_translate),u_image:new a.bO(e,r.u_image),u_texsize:new a.bT(e,r.u_texsize),u_pixel_coord_upper:new a.bT(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new a.bT(e,r.u_pixel_coord_lower),u_scale:new a.bS(e,r.u_scale),u_fade:new a.bf(e,r.u_fade)}),fill:(e,r)=>({u_fill_translate:new a.bT(e,r.u_fill_translate)}),fillPattern:(e,r)=>({u_image:new a.bO(e,r.u_image),u_texsize:new a.bT(e,r.u_texsize),u_pixel_coord_upper:new a.bT(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new a.bT(e,r.u_pixel_coord_lower),u_scale:new a.bS(e,r.u_scale),u_fade:new a.bf(e,r.u_fade),u_fill_translate:new a.bT(e,r.u_fill_translate)}),fillOutline:(e,r)=>({u_world:new a.bT(e,r.u_world),u_fill_translate:new a.bT(e,r.u_fill_translate)}),fillOutlinePattern:(e,r)=>({u_world:new a.bT(e,r.u_world),u_image:new a.bO(e,r.u_image),u_texsize:new a.bT(e,r.u_texsize),u_pixel_coord_upper:new a.bT(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new a.bT(e,r.u_pixel_coord_lower),u_scale:new a.bS(e,r.u_scale),u_fade:new a.bf(e,r.u_fade),u_fill_translate:new a.bT(e,r.u_fill_translate)}),circle:(e,r)=>({u_camera_to_center_distance:new a.bf(e,r.u_camera_to_center_distance),u_scale_with_map:new a.bO(e,r.u_scale_with_map),u_pitch_with_map:new a.bO(e,r.u_pitch_with_map),u_extrude_scale:new a.bT(e,r.u_extrude_scale),u_device_pixel_ratio:new a.bf(e,r.u_device_pixel_ratio),u_globe_extrude_scale:new a.bf(e,r.u_globe_extrude_scale),u_translate:new a.bT(e,r.u_translate)}),collisionBox:(e,r)=>({u_pixel_extrude_scale:new a.bT(e,r.u_pixel_extrude_scale)}),collisionCircle:(e,r)=>({u_viewport_size:new a.bT(e,r.u_viewport_size)}),debug:(e,r)=>({u_color:new a.bP(e,r.u_color),u_overlay:new a.bO(e,r.u_overlay),u_overlay_scale:new a.bf(e,r.u_overlay_scale)}),depth:ln,clippingMask:ln,heatmap:(e,r)=>({u_extrude_scale:new a.bf(e,r.u_extrude_scale),u_intensity:new a.bf(e,r.u_intensity),u_globe_extrude_scale:new a.bf(e,r.u_globe_extrude_scale)}),heatmapTexture:(e,r)=>({u_matrix:new a.bQ(e,r.u_matrix),u_world:new a.bT(e,r.u_world),u_image:new a.bO(e,r.u_image),u_color_ramp:new a.bO(e,r.u_color_ramp),u_opacity:new a.bf(e,r.u_opacity)}),hillshade:(e,r)=>({u_image:new a.bO(e,r.u_image),u_latrange:new a.bT(e,r.u_latrange),u_exaggeration:new a.bf(e,r.u_exaggeration),u_altitudes:new a.bZ(e,r.u_altitudes),u_azimuths:new a.bZ(e,r.u_azimuths),u_accent:new a.bP(e,r.u_accent),u_method:new a.bO(e,r.u_method),u_shadows:new a.bY(e,r.u_shadows),u_highlights:new a.bY(e,r.u_highlights)}),hillshadePrepare:(e,r)=>({u_matrix:new a.bQ(e,r.u_matrix),u_image:new a.bO(e,r.u_image),u_dimension:new a.bT(e,r.u_dimension),u_zoom:new a.bf(e,r.u_zoom),u_unpack:new a.bR(e,r.u_unpack)}),colorRelief:(e,r)=>({u_image:new a.bO(e,r.u_image),u_unpack:new a.bR(e,r.u_unpack),u_dimension:new a.bT(e,r.u_dimension),u_elevation_stops:new a.bO(e,r.u_elevation_stops),u_color_stops:new a.bO(e,r.u_color_stops),u_color_ramp_size:new a.bO(e,r.u_color_ramp_size),u_opacity:new a.bf(e,r.u_opacity)}),line:(e,r)=>({u_translation:new a.bT(e,r.u_translation),u_ratio:new a.bf(e,r.u_ratio),u_device_pixel_ratio:new a.bf(e,r.u_device_pixel_ratio),u_units_to_pixels:new a.bT(e,r.u_units_to_pixels)}),lineGradient:(e,r)=>({u_translation:new a.bT(e,r.u_translation),u_ratio:new a.bf(e,r.u_ratio),u_device_pixel_ratio:new a.bf(e,r.u_device_pixel_ratio),u_units_to_pixels:new a.bT(e,r.u_units_to_pixels),u_image:new a.bO(e,r.u_image),u_image_height:new a.bf(e,r.u_image_height)}),linePattern:(e,r)=>({u_translation:new a.bT(e,r.u_translation),u_texsize:new a.bT(e,r.u_texsize),u_ratio:new a.bf(e,r.u_ratio),u_device_pixel_ratio:new a.bf(e,r.u_device_pixel_ratio),u_image:new a.bO(e,r.u_image),u_units_to_pixels:new a.bT(e,r.u_units_to_pixels),u_scale:new a.bS(e,r.u_scale),u_fade:new a.bf(e,r.u_fade)}),lineSDF:(e,r)=>({u_translation:new a.bT(e,r.u_translation),u_ratio:new a.bf(e,r.u_ratio),u_device_pixel_ratio:new a.bf(e,r.u_device_pixel_ratio),u_units_to_pixels:new a.bT(e,r.u_units_to_pixels),u_patternscale_a:new a.bT(e,r.u_patternscale_a),u_patternscale_b:new a.bT(e,r.u_patternscale_b),u_sdfgamma:new a.bf(e,r.u_sdfgamma),u_image:new a.bO(e,r.u_image),u_tex_y_a:new a.bf(e,r.u_tex_y_a),u_tex_y_b:new a.bf(e,r.u_tex_y_b),u_mix:new a.bf(e,r.u_mix)}),raster:(e,r)=>({u_tl_parent:new a.bT(e,r.u_tl_parent),u_scale_parent:new a.bf(e,r.u_scale_parent),u_buffer_scale:new a.bf(e,r.u_buffer_scale),u_fade_t:new a.bf(e,r.u_fade_t),u_opacity:new a.bf(e,r.u_opacity),u_image0:new a.bO(e,r.u_image0),u_image1:new a.bO(e,r.u_image1),u_brightness_low:new a.bf(e,r.u_brightness_low),u_brightness_high:new a.bf(e,r.u_brightness_high),u_saturation_factor:new a.bf(e,r.u_saturation_factor),u_contrast_factor:new a.bf(e,r.u_contrast_factor),u_spin_weights:new a.bS(e,r.u_spin_weights),u_coords_top:new a.bR(e,r.u_coords_top),u_coords_bottom:new a.bR(e,r.u_coords_bottom)}),symbolIcon:(e,r)=>({u_is_size_zoom_constant:new a.bO(e,r.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bO(e,r.u_is_size_feature_constant),u_size_t:new a.bf(e,r.u_size_t),u_size:new a.bf(e,r.u_size),u_camera_to_center_distance:new a.bf(e,r.u_camera_to_center_distance),u_pitch:new a.bf(e,r.u_pitch),u_rotate_symbol:new a.bO(e,r.u_rotate_symbol),u_aspect_ratio:new a.bf(e,r.u_aspect_ratio),u_fade_change:new a.bf(e,r.u_fade_change),u_label_plane_matrix:new a.bQ(e,r.u_label_plane_matrix),u_coord_matrix:new a.bQ(e,r.u_coord_matrix),u_is_text:new a.bO(e,r.u_is_text),u_pitch_with_map:new a.bO(e,r.u_pitch_with_map),u_is_along_line:new a.bO(e,r.u_is_along_line),u_is_variable_anchor:new a.bO(e,r.u_is_variable_anchor),u_texsize:new a.bT(e,r.u_texsize),u_texture:new a.bO(e,r.u_texture),u_translation:new a.bT(e,r.u_translation),u_pitched_scale:new a.bf(e,r.u_pitched_scale)}),symbolSDF:(e,r)=>({u_is_size_zoom_constant:new a.bO(e,r.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bO(e,r.u_is_size_feature_constant),u_size_t:new a.bf(e,r.u_size_t),u_size:new a.bf(e,r.u_size),u_camera_to_center_distance:new a.bf(e,r.u_camera_to_center_distance),u_pitch:new a.bf(e,r.u_pitch),u_rotate_symbol:new a.bO(e,r.u_rotate_symbol),u_aspect_ratio:new a.bf(e,r.u_aspect_ratio),u_fade_change:new a.bf(e,r.u_fade_change),u_label_plane_matrix:new a.bQ(e,r.u_label_plane_matrix),u_coord_matrix:new a.bQ(e,r.u_coord_matrix),u_is_text:new a.bO(e,r.u_is_text),u_pitch_with_map:new a.bO(e,r.u_pitch_with_map),u_is_along_line:new a.bO(e,r.u_is_along_line),u_is_variable_anchor:new a.bO(e,r.u_is_variable_anchor),u_texsize:new a.bT(e,r.u_texsize),u_texture:new a.bO(e,r.u_texture),u_gamma_scale:new a.bf(e,r.u_gamma_scale),u_device_pixel_ratio:new a.bf(e,r.u_device_pixel_ratio),u_is_halo:new a.bO(e,r.u_is_halo),u_translation:new a.bT(e,r.u_translation),u_pitched_scale:new a.bf(e,r.u_pitched_scale)}),symbolTextAndIcon:(e,r)=>({u_is_size_zoom_constant:new a.bO(e,r.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bO(e,r.u_is_size_feature_constant),u_size_t:new a.bf(e,r.u_size_t),u_size:new a.bf(e,r.u_size),u_camera_to_center_distance:new a.bf(e,r.u_camera_to_center_distance),u_pitch:new a.bf(e,r.u_pitch),u_rotate_symbol:new a.bO(e,r.u_rotate_symbol),u_aspect_ratio:new a.bf(e,r.u_aspect_ratio),u_fade_change:new a.bf(e,r.u_fade_change),u_label_plane_matrix:new a.bQ(e,r.u_label_plane_matrix),u_coord_matrix:new a.bQ(e,r.u_coord_matrix),u_is_text:new a.bO(e,r.u_is_text),u_pitch_with_map:new a.bO(e,r.u_pitch_with_map),u_is_along_line:new a.bO(e,r.u_is_along_line),u_is_variable_anchor:new a.bO(e,r.u_is_variable_anchor),u_texsize:new a.bT(e,r.u_texsize),u_texsize_icon:new a.bT(e,r.u_texsize_icon),u_texture:new a.bO(e,r.u_texture),u_texture_icon:new a.bO(e,r.u_texture_icon),u_gamma_scale:new a.bf(e,r.u_gamma_scale),u_device_pixel_ratio:new a.bf(e,r.u_device_pixel_ratio),u_is_halo:new a.bO(e,r.u_is_halo),u_translation:new a.bT(e,r.u_translation),u_pitched_scale:new a.bf(e,r.u_pitched_scale)}),background:(e,r)=>({u_opacity:new a.bf(e,r.u_opacity),u_color:new a.bP(e,r.u_color)}),backgroundPattern:(e,r)=>({u_opacity:new a.bf(e,r.u_opacity),u_image:new a.bO(e,r.u_image),u_pattern_tl_a:new a.bT(e,r.u_pattern_tl_a),u_pattern_br_a:new a.bT(e,r.u_pattern_br_a),u_pattern_tl_b:new a.bT(e,r.u_pattern_tl_b),u_pattern_br_b:new a.bT(e,r.u_pattern_br_b),u_texsize:new a.bT(e,r.u_texsize),u_mix:new a.bf(e,r.u_mix),u_pattern_size_a:new a.bT(e,r.u_pattern_size_a),u_pattern_size_b:new a.bT(e,r.u_pattern_size_b),u_scale_a:new a.bf(e,r.u_scale_a),u_scale_b:new a.bf(e,r.u_scale_b),u_pixel_coord_upper:new a.bT(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new a.bT(e,r.u_pixel_coord_lower),u_tile_units_to_pixels:new a.bf(e,r.u_tile_units_to_pixels)}),terrain:(e,r)=>({u_texture:new a.bO(e,r.u_texture),u_ele_delta:new a.bf(e,r.u_ele_delta),u_fog_matrix:new a.bQ(e,r.u_fog_matrix),u_fog_color:new a.bP(e,r.u_fog_color),u_fog_ground_blend:new a.bf(e,r.u_fog_ground_blend),u_fog_ground_blend_opacity:new a.bf(e,r.u_fog_ground_blend_opacity),u_horizon_color:new a.bP(e,r.u_horizon_color),u_horizon_fog_blend:new a.bf(e,r.u_horizon_fog_blend),u_is_globe_mode:new a.bf(e,r.u_is_globe_mode)}),terrainDepth:(e,r)=>({u_ele_delta:new a.bf(e,r.u_ele_delta)}),terrainCoords:(e,r)=>({u_texture:new a.bO(e,r.u_texture),u_terrain_coords_id:new a.bf(e,r.u_terrain_coords_id),u_ele_delta:new a.bf(e,r.u_ele_delta)}),projectionErrorMeasurement:(e,r)=>({u_input:new a.bf(e,r.u_input),u_output_expected:new a.bf(e,r.u_output_expected)}),atmosphere:(e,r)=>({u_sun_pos:new a.bS(e,r.u_sun_pos),u_atmosphere_blend:new a.bf(e,r.u_atmosphere_blend),u_globe_position:new a.bS(e,r.u_globe_position),u_globe_radius:new a.bf(e,r.u_globe_radius),u_inv_proj_matrix:new a.bQ(e,r.u_inv_proj_matrix)}),sky:(e,r)=>({u_sky_color:new a.bP(e,r.u_sky_color),u_horizon_color:new a.bP(e,r.u_horizon_color),u_horizon:new a.bT(e,r.u_horizon),u_horizon_normal:new a.bT(e,r.u_horizon_normal),u_sky_horizon_blend:new a.bf(e,r.u_sky_horizon_blend),u_sky_blend:new a.bf(e,r.u_sky_blend)})};class so{constructor(e,r,a){this.context=e;const l=e.gl;this.buffer=l.createBuffer(),this.dynamicDraw=Boolean(a),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),l.bufferData(l.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?l.DYNAMIC_DRAW:l.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const r=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const hn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class lo{constructor(e,r,a,l){this.length=r.length,this.attributes=a,this.itemSize=r.bytesPerElement,this.dynamicDraw=l,this.context=e;const c=e.gl;this.buffer=c.createBuffer(),e.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete r.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 r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,r){for(let a=0;a0&&(x.push({circleArray:k,circleOffset:w,coord:M}),v+=k.length/4,w=v),A&&y.draw(u,g.LINES,Ut.disabled,Vt.disabled,e.colorModeForRenderPass(),Zt.disabled,vr(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(M),p.getProjectionData({overscaledTileID:M,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),l.id,A.layoutVertexBuffer,A.indexBuffer,A.segments,null,e.transform.zoom,null,null,A.collisionVertexBuffer)}if(!h||!x.length)return;const M=e.useProgram("collisionCircle"),C=new a.b_;C.resize(4*v),C._trim();let A=0;for(const e of x)for(let r=0;r=0&&(k[R.associatedIconIndex]={shiftedAnchor:et,angle:it})}else Ae(R.numGlyphs,C)}if(y){A.clear();const r=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(g,r,a):null,a="map"===l.layout.get("text-rotation-alignment");de(y,e,h,ut,yt,D,x,a,g.toUnwrapped(),k.width,k.height,St,r)}const Bt=h&&U||kt,Nt=L||Bt?mn:D?ut:e.transform.clipSpaceToPixelsMatrix,$t=C&&0!==l.paint.get(h?"text-halo-width":"icon-halo-width").constantOr(1);let Gt;Gt=C?y.iconsInText?sn(N.kind,it,B,D,L,Bt,e,Nt,Pt,St,nt,lt,J):nn(N.kind,it,B,D,L,Bt,e,Nt,Pt,St,h,nt,0,J):rn(N.kind,it,B,D,L,Bt,e,Nt,Pt,St,h,nt,J);const qt={program:et,buffers:v,uniformValues:Gt,projectionData:Ct,atlasTexture:st,atlasTextureIcon:ct,atlasInterpolation:ot,atlasInterpolationIcon:at,isSDF:C,hasHalo:$t};if(O&&y.canOverlap){j=!0;const e=v.segments.get();for(const r of e)Z.push({segments:new a.aL([r]),sortKey:r.sortKey,state:qt,terrainData:rt})}else Z.push({segments:v.segments,sortKey:0,state:qt,terrainData:rt})}j&&Z.sort(((e,r)=>e.sortKey-r.sortKey));for(const r of Z){const a=r.state;if(C.activeTexture.set(A.TEXTURE0),a.atlasTexture.bind(a.atlasInterpolation,A.CLAMP_TO_EDGE),a.atlasTextureIcon&&(C.activeTexture.set(A.TEXTURE1),a.atlasTextureIcon&&a.atlasTextureIcon.bind(a.atlasInterpolationIcon,A.CLAMP_TO_EDGE)),a.isSDF){const c=a.uniformValues;a.hasHalo&&(c.u_is_halo=1,bn(a.buffers,r.segments,l,e,a.program,N,v,w,c,a.projectionData,r.terrainData)),c.u_is_halo=0}bn(a.buffers,r.segments,l,e,a.program,N,v,w,a.uniformValues,a.projectionData,r.terrainData)}}function bn(e,r,a,l,c,h,u,p,g,y,x){const v=l.context;c.draw(v,v.gl.TRIANGLES,h,u,p,Zt.backCCW,g,x,y,a.id,e.layoutVertexBuffer,e.indexBuffer,r,a.paint,l.transform.zoom,e.programConfigurations.get(a.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function wn(e,r,l,c,h){const u=e.context,p=u.gl,g=Vt.disabled,y=new jt([p.ONE,p.ONE],a.be.transparent,[!0,!0,!0,!0]),x=r.getBucket(l);if(!x)return;const v=c.key;let w=l.heatmapFbos.get(v);w||(w=Pn(u,r.tileSize,r.tileSize),l.heatmapFbos.set(v,w)),u.bindFramebuffer.set(w.framebuffer),u.viewport.set([0,0,r.tileSize,r.tileSize]),u.clear({color:a.be.transparent});const M=x.programConfigurations.get(l.id),C=e.useProgram("heatmap",M,!h),A=e.transform.getProjectionData({overscaledTileID:r.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),k=e.style.map.terrain.getTerrainData(c);C.draw(u,p.TRIANGLES,Ut.disabled,g,y,Zt.disabled,Tr(r,e.transform.zoom,l.paint.get("heatmap-intensity"),1),k,A,l.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,l.paint,e.transform.zoom,M)}function Tn(e,r,a,l,c){const h=e.context,u=h.gl,p=e.transform;h.setColorMode(e.colorModeForRenderPass());const g=Sn(h,r),y=a.key,x=r.heatmapFbos.get(y);if(!x)return;h.activeTexture.set(u.TEXTURE0),u.bindTexture(u.TEXTURE_2D,x.colorAttachment.get()),h.activeTexture.set(u.TEXTURE1),g.bind(u.LINEAR,u.CLAMP_TO_EDGE);const v=p.getProjectionData({overscaledTileID:a,applyTerrainMatrix:c,applyGlobeMatrix:!l});e.useProgram("heatmapTexture").draw(h,u.TRIANGLES,Ut.disabled,Vt.disabled,e.colorModeForRenderPass(),Zt.disabled,Sr(e,r,0,1),null,v,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,r.paint,p.zoom),x.destroy(),r.heatmapFbos.delete(y)}function Pn(e,r,a){var l,c;const h=e.gl,u=h.createTexture();h.bindTexture(h.TEXTURE_2D,u),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.LINEAR);const p=null!==(l=e.HALF_FLOAT)&&void 0!==l?l:h.UNSIGNED_BYTE,g=null!==(c=e.RGBA16F)&&void 0!==c?c:h.RGBA;h.texImage2D(h.TEXTURE_2D,0,g,r,a,0,h.RGBA,p,null);const y=e.createFramebuffer(r,a,!1,!1);return y.colorAttachment.set(u),y}function Sn(e,r){return r.colorRampTexture||(r.colorRampTexture=new a.T(e,r.colorRamp,e.gl.RGBA)),r.colorRampTexture}function Mn(e,r,a,l,c){if(!a||!l||!l.imageAtlas)return;const h=l.imageAtlas.patternPositions;let u=h[a.to.toString()],p=h[a.from.toString()];if(!u&&p&&(u=p),!p&&u&&(p=u),!u||!p){const e=c.getPaintProperty(r);u=h[e],p=h[e]}u&&p&&e.setConstantPatternPositions(u,p)}function In(e,r,l,c,h,u,p,g){const y=e.context.gl,x="fill-pattern",v=l.paint.get(x),w=v&&v.constantOr(1),M=l.getCrossfadeParameters();let C,A,k,R,D;const L=e.transform,B=l.paint.get("fill-translate"),O=l.paint.get("fill-translate-anchor");p?(A=w&&!l.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",C=y.LINES):(A=w?"fillPattern":"fill",C=y.TRIANGLES);const j=v.constantOr(null);for(const v of c){const c=r.getTile(v);if(w&&!c.patternsLoaded())continue;const N=c.getBucket(l);if(!N)continue;const U=N.programConfigurations.get(l.id),Z=e.useProgram(A,U),J=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v);w&&(e.context.activeTexture.set(y.TEXTURE0),c.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),U.updatePaintBuffers(M)),Mn(U,x,j,c,l);const Q=L.getProjectionData({overscaledTileID:v,applyGlobeMatrix:!g,applyTerrainMatrix:!0}),et=a.aC(L,c,B,O);if(p){R=N.indexBuffer2,D=N.segments2;const r=[y.drawingBufferWidth,y.drawingBufferHeight];k="fillOutlinePattern"===A&&w?_r(e,M,c,r,et):mr(r,et)}else R=N.indexBuffer,D=N.segments,k=w?fr(e,M,c,et):{u_fill_translate:et};const it=e.stencilModeForClipping(v);Z.draw(e.context,C,h,it,u,Zt.backCCW,k,J,Q,l.id,N.layoutVertexBuffer,R,D,l.paint,e.transform.zoom,U)}}function Cn(e,r,l,c,h,u,p,g){const y=e.context,x=y.gl,v="fill-extrusion-pattern",w=l.paint.get(v),M=w.constantOr(1),C=l.getCrossfadeParameters(),A=l.paint.get("fill-extrusion-opacity"),k=w.constantOr(null),R=e.transform;for(const w of c){const c=r.getTile(w),D=c.getBucket(l);if(!D)continue;const L=e.style.map.terrain&&e.style.map.terrain.getTerrainData(w),B=D.programConfigurations.get(l.id),O=e.useProgram(M?"fillExtrusionPattern":"fillExtrusion",B);M&&(e.context.activeTexture.set(x.TEXTURE0),c.imageAtlasTexture.bind(x.LINEAR,x.CLAMP_TO_EDGE),B.updatePaintBuffers(C));const j=R.getProjectionData({overscaledTileID:w,applyGlobeMatrix:!g,applyTerrainMatrix:!0});Mn(B,v,k,c,l);const N=a.aC(R,c,l.paint.get("fill-extrusion-translate"),l.paint.get("fill-extrusion-translate-anchor")),U=l.paint.get("fill-extrusion-vertical-gradient"),Z=M?pr(e,U,A,N,w,C,c):dr(e,U,A,N);O.draw(y,y.gl.TRIANGLES,h,u,p,Zt.backCCW,Z,L,j,l.id,D.layoutVertexBuffer,D.indexBuffer,D.segments,l.paint,e.transform.zoom,B,e.style.map.terrain&&D.centroidVertexBuffer)}}function An(e,r,a,l,c,h,u,p,g){var y;const x=e.style.projection,v=e.context,w=e.transform,M=v.gl,C=[`#define NUM_ILLUMINATION_SOURCES ${a.paint.get("hillshade-highlight-color").values.length}`],A=e.useProgram("hillshade",null,!1,C),k=!e.options.moving;for(const C of l){const l=r.getTile(C),R=l.fbo;if(!R)continue;const D=x.getMeshFromTileID(v,C.canonical,p,!0,"raster"),L=null===(y=e.style.map.terrain)||void 0===y?void 0:y.getTerrainData(C);v.activeTexture.set(M.TEXTURE0),M.bindTexture(M.TEXTURE_2D,R.colorAttachment.get());const B=w.getProjectionData({overscaledTileID:C,aligned:k,applyGlobeMatrix:!g,applyTerrainMatrix:!0});A.draw(v,M.TRIANGLES,h,c[C.overscaledZ],u,Zt.backCCW,Ir(e,l,a),L,B,a.id,D.vertexBuffer,D.indexBuffer,D.segments)}}function zn(e,r,l,c,h,u,p,g,y){var x;const v=e.style.projection,w=e.context,M=e.transform,C=w.gl,A=e.useProgram("colorRelief"),k=!e.options.moving;let R=!0,D=0;for(const L of c){const c=r.getTile(L),B=c.dem;if(R){const e=C.getParameter(C.MAX_TEXTURE_SIZE),{elevationTexture:r,colorTexture:a}=l.getColorRampTextures(w,e,B.getUnpackVector());w.activeTexture.set(C.TEXTURE1),r.bind(C.NEAREST,C.CLAMP_TO_EDGE),w.activeTexture.set(C.TEXTURE4),a.bind(C.LINEAR,C.CLAMP_TO_EDGE),R=!1,D=r.size[0]}if(!B||!B.data)continue;const O=B.stride,j=B.getPixels();if(w.activeTexture.set(C.TEXTURE0),w.pixelStoreUnpackPremultiplyAlpha.set(!1),c.demTexture=c.demTexture||e.getTileTexture(O),c.demTexture){const e=c.demTexture;e.update(j,{premultiply:!1}),e.bind(C.LINEAR,C.CLAMP_TO_EDGE)}else c.demTexture=new a.T(w,j,C.RGBA,{premultiply:!1}),c.demTexture.bind(C.LINEAR,C.CLAMP_TO_EDGE);const N=v.getMeshFromTileID(w,L.canonical,g,!0,"raster"),U=null===(x=e.style.map.terrain)||void 0===x?void 0:x.getTerrainData(L),Z=M.getProjectionData({overscaledTileID:L,aligned:k,applyGlobeMatrix:!y,applyTerrainMatrix:!0});A.draw(w,C.TRIANGLES,u,h[L.overscaledZ],p,Zt.backCCW,Rr(l,c.dem,D),U,Z,l.id,N.vertexBuffer,N.indexBuffer,N.segments)}}const kn=[new a.P(0,0),new a.P(a.$,0),new a.P(a.$,a.$),new a.P(0,a.$)];function Rn(e,r,a,l,c,h,u,p,g=!1,y=!1){const x=l[l.length-1].overscaledZ,v=e.context,w=v.gl,M=e.useProgram("raster"),C=e.transform,A=e.style.projection,k=e.colorModeForRenderPass(),R=!e.options.moving;for(const D of l){const l=e.getDepthModeForSublayer(D.overscaledZ-x,1===a.paint.get("raster-opacity")?Ut.ReadWrite:Ut.ReadOnly,w.LESS),L=r.getTile(D);L.registerFadeDuration(a.paint.get("raster-fade-duration"));const B=r.findLoadedParent(D,0),O=r.findLoadedSibling(D),j=Dn(L,B||O||null,r,a,e.transform,e.style.map.terrain);let N,U;const Z="nearest"===a.paint.get("raster-resampling")?w.NEAREST:w.LINEAR;v.activeTexture.set(w.TEXTURE0),L.texture.bind(Z,w.CLAMP_TO_EDGE,w.LINEAR_MIPMAP_NEAREST),v.activeTexture.set(w.TEXTURE1),B?(B.texture.bind(Z,w.CLAMP_TO_EDGE,w.LINEAR_MIPMAP_NEAREST),N=Math.pow(2,B.tileID.overscaledZ-L.tileID.overscaledZ),U=[L.tileID.canonical.x*N%1,L.tileID.canonical.y*N%1]):L.texture.bind(Z,w.CLAMP_TO_EDGE,w.LINEAR_MIPMAP_NEAREST),L.texture.useMipmap&&v.extTextureFilterAnisotropic&&e.transform.pitch>20&&w.texParameterf(w.TEXTURE_2D,v.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,v.extTextureFilterAnisotropicMax);const J=e.style.map.terrain&&e.style.map.terrain.getTerrainData(D),Q=C.getProjectionData({overscaledTileID:D,aligned:R,applyGlobeMatrix:!y,applyTerrainMatrix:!0}),et=tn(U||[0,0],N||1,j,a,p),it=A.getMeshFromTileID(v,D.canonical,h,u,"raster");M.draw(v,w.TRIANGLES,l,c?c[D.overscaledZ]:Vt.disabled,k,g?Zt.frontCCW:Zt.backCCW,et,J,Q,a.id,it.vertexBuffer,it.indexBuffer,it.segments)}}function Dn(e,r,l,c,h,u){const g=c.paint.get("raster-fade-duration");if(!u&&g>0){const c=p.now(),u=(c-e.timeAdded)/g,y=r?(c-r.timeAdded)/g:-1,x=l.getSource(),v=qt(h,{tileSize:x.tileSize,roundZoom:x.roundZoom}),w=!r||Math.abs(r.tileID.overscaledZ-v)>Math.abs(e.tileID.overscaledZ-v),M=w&&e.refreshedUponExpiration?1:a.ag(w?u:1-y,0,1);return e.refreshedUponExpiration&&u>=1&&(e.refreshedUponExpiration=!1),r?{opacity:1,mix:1-M}:{opacity:M,mix:0}}return{opacity:1,mix:0}}const Ln=new a.be(1,0,0,1),Fn=new a.be(0,1,0,1),On=new a.be(0,0,1,1),jn=new a.be(1,0,1,1),Nn=new a.be(0,1,1,1);function Un(e,r,a,l){$n(e,0,r+a/2,e.transform.width,a,l)}function Zn(e,r,a,l){$n(e,r-a/2,0,a,e.transform.height,l)}function $n(e,r,a,l,c,h){const u=e.context,p=u.gl;p.enable(p.SCISSOR_TEST),p.scissor(r*e.pixelRatio,a*e.pixelRatio,l*e.pixelRatio,c*e.pixelRatio),u.clear({color:h}),p.disable(p.SCISSOR_TEST)}function Gn(e,r,l){const c=e.context,h=c.gl,u=e.useProgram("debug"),p=Ut.disabled,g=Vt.disabled,y=e.colorModeForRenderPass(),x="$debug",v=e.style.map.terrain&&e.style.map.terrain.getTerrainData(l);c.activeTexture.set(h.TEXTURE0);const w=r.getTileByID(l.key).latestRawTileData,M=Math.floor((w&&w.byteLength||0)/1024),C=r.getTile(l).tileSize,A=512/Math.min(C,512)*(l.overscaledZ/e.transform.zoom)*.5;let k=l.canonical.toString();l.overscaledZ!==l.canonical.z&&(k+=` => ${l.overscaledZ}`),function(e,r){e.initDebugOverlayCanvas();const a=e.debugOverlayCanvas,l=e.context.gl,c=e.debugOverlayCanvas.getContext("2d");c.clearRect(0,0,a.width,a.height),c.shadowColor="white",c.shadowBlur=2,c.lineWidth=1.5,c.strokeStyle="white",c.textBaseline="top",c.font="bold 36px Open Sans, sans-serif",c.fillText(r,5,5),c.strokeText(r,5,5),e.debugOverlayTexture.update(a),e.debugOverlayTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE)}(e,`${k} ${M}kB`);const R=e.transform.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!0,applyTerrainMatrix:!0});u.draw(c,h.TRIANGLES,p,g,jt.alphaBlended,Zt.disabled,wr(a.be.transparent,A),null,R,x,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),u.draw(c,h.LINE_STRIP,p,g,y,Zt.disabled,wr(a.be.red),v,R,x,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function qn(e,r,a,l){const{isRenderingGlobe:c}=l,h=e.context,u=h.gl,p=e.transform,g=e.colorModeForRenderPass(),y=e.getDepthModeFor3D(),x=e.useProgram("terrain");h.bindFramebuffer.set(null),h.viewport.set([0,0,e.width,e.height]);for(const l of a){const a=r.getTerrainMesh(l.tileID),v=e.renderToTexture.getTexture(l),w=r.getTerrainData(l.tileID);h.activeTexture.set(u.TEXTURE0),u.bindTexture(u.TEXTURE_2D,v.texture);const M=r.getMeshFrameDelta(p.zoom),C=p.calculateFogMatrix(l.tileID.toUnwrapped()),A=Qi(M,C,e.style.sky,p.pitch,c),k=p.getProjectionData({overscaledTileID:l.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});x.draw(h,u.TRIANGLES,y,Vt.disabled,g,Zt.backCCW,A,w,k,"terrain",a.vertexBuffer,a.indexBuffer,a.segments)}}function Wn(e,r){if(!r.mesh){const l=new a.aK;l.emplaceBack(-1,-1),l.emplaceBack(1,-1),l.emplaceBack(1,1),l.emplaceBack(-1,1);const c=new a.aM;c.emplaceBack(0,1,2),c.emplaceBack(0,2,3),r.mesh=new wt(e.createVertexBuffer(l,mi.members),e.createIndexBuffer(c),a.aL.simpleSegment(0,0,l.length,c.length))}return r.mesh}class Mr{constructor(e,r){this.context=new Ho(e),this.transform=r,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:a.af(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=xe.maxUnderzooming+xe.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new vt}resize(e,r,a){if(this.width=Math.floor(e*a),this.height=Math.floor(r*a),this.pixelRatio=a,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,r=new a.aK;r.emplaceBack(0,0),r.emplaceBack(a.$,0),r.emplaceBack(0,a.$),r.emplaceBack(a.$,a.$),this.tileExtentBuffer=e.createVertexBuffer(r,mi.members),this.tileExtentSegments=a.aL.simpleSegment(0,0,4,2);const l=new a.aK;l.emplaceBack(0,0),l.emplaceBack(a.$,0),l.emplaceBack(0,a.$),l.emplaceBack(a.$,a.$),this.debugBuffer=e.createVertexBuffer(l,mi.members),this.debugSegments=a.aL.simpleSegment(0,0,4,5);const c=new a.c5;c.emplaceBack(0,0,0,0),c.emplaceBack(a.$,0,a.$,0),c.emplaceBack(0,a.$,0,a.$),c.emplaceBack(a.$,a.$,a.$,a.$),this.rasterBoundsBuffer=e.createVertexBuffer(c,Ji.members),this.rasterBoundsSegments=a.aL.simpleSegment(0,0,4,2);const h=new a.aK;h.emplaceBack(0,0),h.emplaceBack(a.$,0),h.emplaceBack(0,a.$),h.emplaceBack(a.$,a.$),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(h,mi.members),this.rasterBoundsSegmentsPosOnly=a.aL.simpleSegment(0,0,4,5);const u=new a.aK;u.emplaceBack(0,0),u.emplaceBack(1,0),u.emplaceBack(0,1),u.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(u,mi.members),this.viewportSegments=a.aL.simpleSegment(0,0,4,2);const p=new a.c6;p.emplaceBack(0),p.emplaceBack(1),p.emplaceBack(3),p.emplaceBack(2),p.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(p);const g=new a.aM;g.emplaceBack(1,0,2),g.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(g);const y=this.context.gl;this.stencilClearMode=new Vt({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO),this.tileExtentMesh=new wt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,r=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const l=a.L();a.bX(l,0,this.width,this.height,0,0,1),a.N(l,l,[r.drawingBufferWidth,r.drawingBufferHeight,0]);const c={mainMatrix:l,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:l};this.useProgram("clippingMask",null,!0).draw(e,r.TRIANGLES,Ut.disabled,this.stencilClearMode,jt.disabled,Zt.disabled,null,null,c,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,r,a){if(this.currentStencilSource===e.source||!e.isTileClipped()||!r||!r.length)return;this.currentStencilSource=e.source,this.nextStencilID+r.length>256&&this.clearStencil();const l=this.context;l.setColorMode(jt.disabled),l.setDepthMode(Ut.disabled);const c={};for(const e of r)c[e.key]=this.nextStencilID++;this._renderTileMasks(c,r,a,!0),this._renderTileMasks(c,r,a,!1),this._tileClippingMaskIDs=c}_renderTileMasks(e,r,a,l){const c=this.context,h=c.gl,u=this.style.projection,p=this.transform,g=this.useProgram("clippingMask");for(const y of r){const r=e[y.key],x=this.style.map.terrain&&this.style.map.terrain.getTerrainData(y),v=u.getMeshFromTileID(this.context,y.canonical,l,!0,"stencil"),w=p.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!a,applyTerrainMatrix:!0});g.draw(c,h.TRIANGLES,Ut.disabled,new Vt({func:h.ALWAYS,mask:0},r,255,h.KEEP,h.KEEP,h.REPLACE),jt.disabled,a?Zt.disabled:Zt.backCCW,null,x,w,"$clipping",v.vertexBuffer,v.indexBuffer,v.segments)}}_renderTilesDepthBuffer(){const e=this.context,r=e.gl,a=this.style.projection,l=this.transform,c=this.useProgram("depth"),h=this.getDepthModeFor3D(),u=Ht(l,{tileSize:l.tileSize});for(const p of u){const u=this.style.map.terrain&&this.style.map.terrain.getTerrainData(p),g=a.getMeshFromTileID(this.context,p.canonical,!0,!0,"raster"),y=l.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0});c.draw(e,r.TRIANGLES,h,Vt.disabled,jt.disabled,Zt.backCCW,null,u,y,"$clipping",g.vertexBuffer,g.indexBuffer,g.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,r=this.context.gl;return new Vt({func:r.NOTEQUAL,mask:255},e,255,r.KEEP,r.KEEP,r.REPLACE)}stencilModeForClipping(e){const r=this.context.gl;return new Vt({func:r.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,r.KEEP,r.KEEP,r.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const r=this.context.gl,a=e.sort(((e,r)=>r.overscaledZ-e.overscaledZ)),l=a[a.length-1].overscaledZ,c=a[0].overscaledZ-l+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();const e={};for(let a=0;ar.overscaledZ-e.overscaledZ)),l=a[a.length-1].overscaledZ,c=a[0].overscaledZ-l+1;if(this.clearStencil(),c>1){const e={},h={};for(let a=0;a0};for(const e in u){const r=u[e];r.used&&r.prepare(this.context),g[e]=r.getVisibleCoordinates(!1),y[e]=g[e].slice().reverse(),x[e]=r.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:r.showOverdrawInspector?a.be.black:a.be.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,r){const a=e.context,l=a.gl,c=((e,r,a)=>{const l=Math.cos(r.rollInRadians),c=Math.sin(r.rollInRadians),h=Ct(r),u=r.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:[(r.width/2-h*c)*a,(r.height/2+h*l)*a],u_horizon_normal:[-c,l],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*r.height/2*a,u_sky_blend:u}})(r,e.style.map.transform,e.pixelRatio),h=new Ut(l.LEQUAL,Ut.ReadWrite,[0,1]),u=Vt.disabled,p=e.colorModeForRenderPass(),g=e.useProgram("sky"),y=Wn(a,r);g.draw(a,l.TRIANGLES,h,u,p,Zt.disabled,c,null,void 0,"sky",y.vertexBuffer,y.indexBuffer,y.segments)}(this,this.style.sky),this._showOverdrawInspector=r.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=h.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[h[this.currentLayer]],r=u[e.source],a=g[e.source];this._renderTileClippingMasks(e,a,!1),this.renderLayer(this,r,e,a,v)}this.renderPass="translucent";let w=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:r,u_globe_position:a,u_globe_radius:l,u_inv_proj_matrix:c}))(y,v,[C[0],C[1],C[2]],w,M),k=Wn(c,r);u.draw(c,h.TRIANGLES,p,Vt.disabled,jt.alphaBlended,Zt.disabled,A,null,null,"atmosphere",k.vertexBuffer,k.indexBuffer,k.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,r){let a=null;const l=Object.values(e._layers).flatMap((a=>a.source&&!a.isHidden(r)?[e.sourceCaches[a.source]]:[])),c=l.filter((e=>"vector"===e.getSource().type)),h=l.filter((e=>"vector"!==e.getSource().type)),u=e=>{(!a||a.getSource().maxzoomu(e))),a||h.forEach((e=>u(e))),a}(this.style,this.transform.zoom);e&&function(e,r,a){for(let l=0;lv.getElevation(h,e,r):null;yn(u,w,M,y,x,k,r,C,R,a.aC(x,e,p,g),h.toUnwrapped(),l)}}}(c,e,l,r,l.layout.get("text-rotation-alignment"),l.layout.get("text-pitch-alignment"),l.paint.get("text-translate"),l.paint.get("text-translate-anchor"),h),0!==l.paint.get("icon-opacity").constantOr(1)&&vn(e,r,l,c,!1,l.paint.get("icon-translate"),l.paint.get("icon-translate-anchor"),l.layout.get("icon-rotation-alignment"),l.layout.get("icon-pitch-alignment"),l.layout.get("icon-keep-upright"),g,y,p),0!==l.paint.get("text-opacity").constantOr(1)&&vn(e,r,l,c,!0,l.paint.get("text-translate"),l.paint.get("text-translate-anchor"),l.layout.get("text-rotation-alignment"),l.layout.get("text-pitch-alignment"),l.layout.get("text-keep-upright"),g,y,p),r.map.showCollisionBoxes&&(fn(e,r,l,c,!0),fn(e,r,l,c,!1))}(e,r,l,c,this.style.placement.variableOffsets,h):a.cb(l)?function(e,r,l,c,h){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:u}=h,p=l.paint.get("circle-opacity"),g=l.paint.get("circle-stroke-width"),y=l.paint.get("circle-stroke-opacity"),x=!l.layout.get("circle-sort-key").isConstant();if(0===p.constantOr(1)&&(0===g.constantOr(1)||0===y.constantOr(1)))return;const v=e.context,w=v.gl,M=e.transform,C=e.getDepthModeForSublayer(0,Ut.ReadOnly),A=Vt.disabled,k=e.colorModeForRenderPass(),R=[],D=M.getCircleRadiusCorrection();for(let h=0;he.sortKey-r.sortKey));for(const r of R){const{programConfiguration:a,program:c,layoutVertexBuffer:h,indexBuffer:u,uniformValues:p,terrainData:g,projectionData:y}=r.state;c.draw(v,w.TRIANGLES,C,A,k,Zt.backCCW,p,g,y,l.id,h,u,r.segments,l.paint,e.transform.zoom,a)}}(e,r,l,c,h):a.cc(l)?function(e,r,l,c,h){if(0===l.paint.get("heatmap-opacity"))return;const u=e.context,{isRenderingToTexture:p,isRenderingGlobe:g}=h;if(e.style.map.terrain){for(const a of c){const c=r.getTile(a);r.hasRenderableParent(a)||("offscreen"===e.renderPass?wn(e,c,l,a,g):"translucent"===e.renderPass&&Tn(e,l,a,p,g))}u.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,r,l,c){const h=e.context,u=h.gl,p=e.transform,g=Vt.disabled,y=new jt([u.ONE,u.ONE],a.be.transparent,[!0,!0,!0,!0]);(function(e,r,l){const c=e.gl;e.activeTexture.set(c.TEXTURE1),e.viewport.set([0,0,r.width/4,r.height/4]);let h=l.heatmapFbos.get(a.c1);h?(c.bindTexture(c.TEXTURE_2D,h.colorAttachment.get()),e.bindFramebuffer.set(h.framebuffer)):(h=Pn(e,r.width/4,r.height/4),l.heatmapFbos.set(a.c1,h))})(h,e,l),h.clear({color:a.be.transparent});for(let a=0;a0?r.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const r=this.imageManager.getPattern(e.from.toString()),a=this.imageManager.getPattern(e.to.toString());return!r||!a}useProgram(e,r,a=!1,l=[]){this.cache=this.cache||{};const c=!!this.style.map.terrain,h=this.style.projection,u=a?ci.projectionMercator:h.shaderPreludeCode,p=a?_i:h.shaderDefine,g=e+(r?r.cacheKey:"")+`/${a?yi:h.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(c?"/terrain":"")+(l?`/${l.join("/")}`:"");return this.cache[g]||(this.cache[g]=new Si(this.context,ci[e],r,cn[e],this._showOverdrawInspector,c,u,p,l)),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 a.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:r}=this.context.gl;return this.width!==e||this.height!==r}}function Hn(r,a){let l,c=!1,h=null,u=null;const p=()=>{h=null,c&&(r.apply(u,l),h=setTimeout(p,a),c=!1)};return(...r)=>(c=!0,u=this||e,l=r,h||p(),h)}class Er{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let r;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(r=e)})),(r&&r[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const r=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:r,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 r=e.join("/");let a=r;a.split("&").length>0&&(a=a.split("&")[0]),this._hashName&&(a=`${this._hashName}=${r}`);let l=window.location.hash.replace(a,"");l.startsWith("#&")?l=l.slice(0,1)+l.slice(2):"#"===l&&(l="");let c=window.location.href.replace(/(#.+)?$/,l);c=c.replace("&&","&"),window.history.replaceState(window.history.state,null,c)},this._updateHash=Hn(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 r=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,l=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,l),h=Math.round(r.lng*c)/c,u=Math.round(r.lat*c)/c,p=this._map.getBearing(),g=this._map.getPitch();let y="";if(y+=e?`/${h}/${u}/${a}`:`${a}/${u}/${h}`,(p||g)&&(y+="/"+Math.round(10*p)/10),g&&(y+=`/${Math.round(g)}`),this._hashName){const e=this._hashName;let r=!1;const a=window.location.hash.slice(1).split("&").map((a=>{const l=a.split("=")[0];return l===e?(r=!0,`${l}=${y}`):a})).filter((e=>e));return r||a.push(`${e}=${y}`),`#${a.join("&")}`}return`#${y}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new a.S(+e[2],+e[1])}catch(e){return!1}const r=+e[0],l=+(e[3]||0),c=+(e[4]||0);return r>=this._map.getMinZoom()&&r<=this._map.getMaxZoom()&&l>=-180&&l<=180&&c>=this._map.getMinPitch()&&c<=this._map.getMaxPitch()}}const Xn={linearity:.3,easing:a.cl(0,0,.3,1)},Yn=a.e({deceleration:2500,maxSpeed:1400},Xn),Kn=a.e({deceleration:20,maxSpeed:1400},Xn),Jn=a.e({deceleration:1e3,maxSpeed:360},Xn),Qn=a.e({deceleration:1e3,maxSpeed:90},Xn),ts=a.e({deceleration:1e3,maxSpeed:360},Xn);class Fr{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:p.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,r=p.now();for(;e.length>0&&r-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const r={zoom:0,bearing:0,pitch:0,roll:0,pan:new a.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)r.zoom+=e.zoomDelta||0,r.bearing+=e.bearingDelta||0,r.pitch+=e.pitchDelta||0,r.roll+=e.rollDelta||0,e.panDelta&&r.pan._add(e.panDelta),e.around&&(r.around=e.around),e.pinchAround&&(r.pinchAround=e.pinchAround);const l=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(r.pan.mag()){const h=is(r.pan.mag(),l,a.e({},Yn,e||{})),u=r.pan.mult(h.amount/r.pan.mag()),p=this._map.cameraHelper.handlePanInertia(u,this._map.transform);c.center=p.easingCenter,c.offset=p.easingOffset,es(c,h)}if(r.zoom){const e=is(r.zoom,l,Kn);c.zoom=this._map.transform.zoom+e.amount,es(c,e)}if(r.bearing){const e=is(r.bearing,l,Jn);c.bearing=this._map.transform.bearing+a.ag(e.amount,-179,179),es(c,e)}if(r.pitch){const e=is(r.pitch,l,Qn);c.pitch=this._map.transform.pitch+e.amount,es(c,e)}if(r.roll){const e=is(r.roll,l,ts);c.roll=this._map.transform.roll+a.ag(e.amount,-179,179),es(c,e)}if(c.zoom||c.bearing){const e=void 0===r.pinchAround?r.around:r.pinchAround;c.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),a.e(c,{noMoveStart:!0})}}function es(e,r){(!e.duration||e.durationr.unproject(e))),p=h.reduce(((e,r,a,l)=>e.add(r.div(l.length))),new a.P(0,0));super(e,{points:h,point:p,lngLats:u,lngLat:r.unproject(p),originalEvent:l}),this._defaultPrevented=!1}}class Zr extends a.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,r,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class Ur{constructor(e,r){this._map=e,this._clickTolerance=r.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Zr(e.type,this._map,e))}mousedown(e,r){return this._mousedownPos=r,this._firePreventable(new jr(e.type,this._map,e))}mouseup(e){this._map.fire(new jr(e.type,this._map,e))}click(e,r){this._mousedownPos&&this._mousedownPos.dist(r)>=this._clickTolerance||this._map.fire(new jr(e.type,this._map,e))}dblclick(e){return this._firePreventable(new jr(e.type,this._map,e))}mouseover(e){this._map.fire(new jr(e.type,this._map,e))}mouseout(e){this._map.fire(new jr(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Nr(e.type,this._map,e))}touchmove(e){this._map.fire(new Nr(e.type,this._map,e))}touchend(e){this._map.fire(new Nr(e.type,this._map,e))}touchcancel(e){this._map.fire(new Nr(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Gr{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new jr(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new jr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new jr(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Vr{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(a.P.convert(e),this._map.terrain)}}class $r{constructor(e,r){this._map=e,this._tr=new Vr(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=r.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,r){this.isEnabled()&&e.shiftKey&&0===e.button&&(n.disableDrag(),this._startPos=this._lastPos=r,this._active=!0)}mousemoveWindow(e,r){if(!this._active)return;const a=r;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)e.fitScreenCoordinates(l,c,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&&(n.remove(this._box),this._box=null),n.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,r){return this._map.fire(new a.l(e,{originalEvent:r}))}}function rs(e,r){if(e.length!==r.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${r.length}`);const a={};for(let l=0;lthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),l.length===this.numTouches&&(this.centroid=function(e){const r=new a.P(0,0);for(const a of e)r._add(a);return r.div(e.length)}(r),this.touches=rs(l,r)))}touchmove(e,r,a){if(this.aborted||!this.centroid)return;const l=rs(a,r);for(const e in this.touches){const r=l[e];(!r||r.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,r,a){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===a.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Hr{constructor(e){this.singleTap=new Wr(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,r,a){this.singleTap.touchstart(e,r,a)}touchmove(e,r,a){this.singleTap.touchmove(e,r,a)}touchend(e,r,a){const l=this.singleTap.touchend(e,r,a);if(l){const r=e.timeStamp-this.lastTime<500,a=!this.lastTap||this.lastTap.dist(l)<30;if(r&&a||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=l,this.count===this.numTaps)return this.reset(),l}}}class Xr{constructor(e){this._tr=new Vr(e),this._zoomIn=new Hr({numTouches:1,numTaps:2}),this._zoomOut=new Hr({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,r,a){this._zoomIn.touchstart(e,r,a),this._zoomOut.touchstart(e,r,a)}touchmove(e,r,a){this._zoomIn.touchmove(e,r,a),this._zoomOut.touchmove(e,r,a)}touchend(e,r,a){const l=this._zoomIn.touchend(e,r,a),c=this._zoomOut.touchend(e,r,a),h=this._tr;return l?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:r=>r.easeTo({duration:300,zoom:h.zoom+1,around:h.unproject(l)},{originalEvent:e})}):c?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:r=>r.easeTo({duration:300,zoom:h.zoom-1,around:h.unproject(c)},{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 Kr{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 r=this._moveFunction(...e);if(r.bearingDelta||r.pitchDelta||r.rollDelta||r.around||r.panDelta)return this._active=!0,r}dragStart(e,r){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(r)?r[0]:r,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,r){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const l=Array.isArray(r)?r[0]:r;return!this._moved&&l.dist(a)!0}),r=new ta){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=r}_executeRelevantHandler(e,r,a){return e instanceof MouseEvent?r(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?a(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 ls=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class ra{constructor(e,r){this._clickTolerance=e.clickTolerance||1,this._map=r,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new a.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,r,a){return this._calculateTransform(e,r,a)}touchmove(e,r,a){if(this._active){if(!this._shouldBePrevented(a.length))return e.preventDefault(),this._calculateTransform(e,r,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,r,a){this._calculateTransform(e,r,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,r,l){l.length>0&&(this._active=!0);const c=rs(l,r),h=new a.P(0,0),u=new a.P(0,0);let p=0;for(const e in c){const r=c[e],a=this._touches[e];a&&(h._add(r),u._add(r.sub(a)),p++,c[e]=r)}if(this._touches=c,this._shouldBePrevented(p)||!u.mag())return;const g=u.div(p);return this._sum._add(g),this._sum.mag()Math.abs(e.x)}class da extends aa{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,r,a){super.touchstart(e,r,a),this._currentTouchCount=a.length}_start(e){this._lastPoints=e,ds(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,r,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const l=e[0].sub(this._lastPoints[0]),c=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(l,c,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(l.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(e,r,a){if(void 0!==this._valid)return this._valid;const l=e.mag()>=2,c=r.mag()>=2;if(!l&&!c)return;if(!l||!c)return void 0===this._firstMove&&(this._firstMove=a),a-this._firstMove<100&&void 0;const h=e.y>0==r.y>0;return ds(e)&&ds(r)&&h}}const ps={panStep:100,bearingStep:15,pitchStep:10};class pa{constructor(e){this._tr=new Vr(e);const r=ps;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let r=0,a=0,l=0,c=0,h=0;switch(e.keyCode){case 61:case 107:case 171:case 187:r=1;break;case 189:case 109:case 173:r=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),c=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),c=1);break;case 38:e.shiftKey?l=1:(e.preventDefault(),h=-1);break;case 40:e.shiftKey?l=-1:(e.preventDefault(),h=1);break;default:return}return this._rotationDisabled&&(a=0,l=0),{cameraAnimation:u=>{const p=this._tr;u.easeTo({duration:300,easeId:"keyboardHandler",easing:fs,zoom:r?Math.round(p.zoom)+r*(e.shiftKey?2:1):p.zoom,bearing:p.bearing+a*this._bearingStep,pitch:p.pitch+l*this._pitchStep,offset:[-c*this._panStep,-h*this._panStep],center:p.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 fs(e){return e*(2-e)}const ms=4.000244140625,_s=1/450;class va{constructor(e,r){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new Vr(e),this._triggerRenderFrame=r,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=_s}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 r=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const a=p.now(),l=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,0!==r&&r%ms==0?this._type="wheel":0!==r&&Math.abs(r)<4?this._type="trackpad":l>400?(this._type=null,this._lastValue=r,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(l*r)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,r+=this._lastValue)),e.shiftKey&&r&&(r/=4),this._type&&(this._lastWheelEvent=e,this._delta-=r,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 r=n.mousePos(this._map.getCanvas(),e),l=this._tr;this._aroundPoint=this._aroundCenter?l.transform.locationToScreenPoint(a.S.convert(l.center)):r,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 r=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=r),"number"==typeof this._targetZoom&&(this._targetZoom+=r)}if(0!==this._delta){const r="wheel"===this._type&&Math.abs(this._delta)>ms?this._wheelZoomRate:this._defaultZoomRate;let l=2/(1+Math.exp(-Math.abs(this._delta*r)));this._delta<0&&0!==l&&(l=1/l);const c="number"!=typeof this._targetZoom?e.scale:a.ae(this._targetZoom);this._targetZoom=e.getConstrained(e.getCameraLngLat(),a.aj(c*l)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,l=this._startZoom,c=this._easing;let h,u=!1;if("wheel"===this._type&&l&&c){const e=p.now()-this._lastWheelEventTime,g=Math.min((e+5)/200,1),y=c(g);h=a.C.number(l,r,y),g<1?this._frameId||(this._frameId=!0):u=!0}else h=r,u=!0;return this._active=!0,u&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=h,{noInertia:!0,needsRenderFrame:!u,zoomDelta:h-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let r=a.cn;if(this._prevEase){const e=this._prevEase,l=(p.now()-e.start)/e.duration,c=e.easing(l+.01)-e.easing(l),h=.27/Math.sqrt(c*c+1e-4)*.01,u=Math.sqrt(.0729-h*h);r=a.cl(h,u,.25,1)}return this._prevEase={start:p.now(),duration:e,easing:r},r}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class ba{constructor(e,r){this._clickZoom=e,this._tapZoom=r}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 xa{constructor(e){this._tr=new Vr(e),this.reset()}reset(){this._active=!1}dblclick(e,r){return e.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(r)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ya{constructor(){this._tap=new Hr({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,r,a){if(!this._swipePoint)if(this._tapTime){const l=r[0],c=e.timeStamp-this._tapTime<500,h=this._tapPoint.dist(l)<30;c&&h?a.length>0&&(this._swipePoint=l,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(e,r,a)}touchmove(e,r,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const l=r[0],c=l.y-this._swipePoint.y;return this._swipePoint=l,e.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(e,r,a)}touchend(e,r,a){if(this._tapTime)this._swipePoint&&0===a.length&&this.reset();else{const l=this._tap.touchend(e,r,a);l&&(this._tapTime=e.timeStamp,this._tapPoint=l)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class wa{constructor(e,r,a){this._el=e,this._mousePan=r,this._touchPan=a}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 Ta{constructor(e,r,a,l){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=r,this._mousePitch=a,this._mouseRoll=l}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 Pa{constructor(e,r,a,l){this._el=e,this._touchZoom=r,this._touchRotate=a,this._tapDragZoom=l,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 Ca{constructor(e,r){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=r,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=n.create("div","maplibregl-cooperative-gesture-screen",e);let r=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(r=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),l=document.createElement("div");l.className="maplibregl-desktop-message",l.textContent=r,this._container.appendChild(l);const c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=a,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(n.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,r){this._enabled&&(this._map.fire(new a.l("cooperativegestureprevented",{gestureType:e,originalEvent:r})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const gs=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Ma extends a.l{}function xs(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Ea{constructor(e,r){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,r)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const l="renderFrame"===e.type?void 0:e,c={needsRenderFrame:!1},h={},u={};for(const{handlerName:p,handler:g,allowed:y}of this._handlers){if(!g.isEnabled())continue;let x;if(this._blockedByActive(u,y,p))g.reset();else if(g[r||e.type]){if(a.co(e,r||e.type)){const a=n.mousePos(this._map.getCanvas(),e);x=g[r||e.type](e,a)}else if(a.cp(e,r||e.type)){const a=this._getMapTouches(e.touches),l=n.touchPos(this._map.getCanvas(),a);x=g[r||e.type](e,l,a)}else a.cq(r||e.type)||(x=g[r||e.type](e));this.mergeHandlerResult(c,h,x,p,l),x&&x.needsRenderFrame&&this._triggerRenderFrame()}(x||g.isActive())&&(u[p]=g)}const p={};for(const e in this._previousActiveHandlers)u[e]||(p[e]=l);this._previousActiveHandlers=u,(Object.keys(p).length||xs(c))&&(this._changes.push([c,h,p]),this._triggerRenderFrame()),(Object.keys(u).length||xs(c))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:g}=c;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 Fr(e),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(r);const l=this._el;this._listeners=[[l,"touchstart",{passive:!0}],[l,"touchmove",{passive:!1}],[l,"touchend",void 0],[l,"touchcancel",void 0],[l,"mousedown",void 0],[l,"mousemove",void 0],[l,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[l,"mouseover",void 0],[l,"mouseout",void 0],[l,"dblclick",void 0],[l,"click",void 0],[l,"keydown",{capture:!1}],[l,"keyup",void 0],[l,"wheel",{passive:!1}],[l,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,r,a]of this._listeners)n.addEventListener(e,r,e===document?this.handleWindowEvent:this.handleEvent,a)}destroy(){for(const[e,r,a]of this._listeners)n.removeEventListener(e,r,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){const r=this._map,l=r.getCanvasContainer();this._add("mapEvent",new Ur(r,e));const c=r.boxZoom=new $r(r,e);this._add("boxZoom",c),e.interactive&&e.boxZoom&&c.enable();const h=r.cooperativeGestures=new Ca(r,e.cooperativeGestures);this._add("cooperativeGestures",h),e.cooperativeGestures&&h.enable();const u=new Xr(r),p=new xa(r);r.doubleClickZoom=new ba(p,u),this._add("tapZoom",u),this._add("clickZoom",p),e.interactive&&e.doubleClickZoom&&r.doubleClickZoom.enable();const g=new ya;this._add("tapDragZoom",g);const y=r.touchPitch=new da(r);this._add("touchPitch",y),e.interactive&&e.touchPitch&&r.touchPitch.enable(e.touchPitch);const x=()=>r.project(r.getCenter()),v=function({enable:e,clickTolerance:r,aroundCenter:l=!0,minPixelCenterThreshold:c=100,rotateDegreesPerPixelMoved:h=.8},u){const p=new ea({checkCorrectEvent:e=>0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)&&!e.ctrlKey});return new Kr({clickTolerance:r,move:(e,r)=>{const p=u();if(l&&Math.abs(p.y-e.y)>c)return{bearingDelta:a.cm(new a.P(e.x,r.y),r,p)};let g=(r.x-e.x)*h;return l&&r.y0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)});return new Kr({clickTolerance:r,move:(e,r)=>({pitchDelta:(r.y-e.y)*a}),moveStateManager:l,enable:e,assignEvents:ls})}(e),M=function({enable:e,clickTolerance:r,rollDegreesPerPixelMoved:a=.3},l){const c=new ea({checkCorrectEvent:e=>2===n.mouseButton(e)&&e.ctrlKey});return new Kr({clickTolerance:r,move:(e,r)=>{const c=l();let h=(r.x-e.x)*a;return r.y0===n.mouseButton(e)&&!e.ctrlKey});return new Kr({clickTolerance:r,move:(e,r)=>({around:r,panDelta:r.sub(e)}),activateOnStart:!0,moveStateManager:a,enable:e,assignEvents:ls})}(e),A=new ra(e,r);r.dragPan=new wa(l,C,A),this._add("mousePan",C),this._add("touchPan",A,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&r.dragPan.enable(e.dragPan);const k=new ha,R=new la;r.touchZoomRotate=new Pa(l,R,k,g),this._add("touchRotate",k,["touchPan","touchZoom"]),this._add("touchZoom",R,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&r.touchZoomRotate.enable(e.touchZoomRotate);const D=r.scrollZoom=new va(r,(()=>this._triggerRenderFrame()));this._add("scrollZoom",D,["mousePan"]),e.interactive&&e.scrollZoom&&r.scrollZoom.enable(e.scrollZoom);const L=r.keyboard=new pa(r);this._add("keyboard",L),e.interactive&&e.keyboard&&r.keyboard.enable(),this._add("blockableMapEvent",new Gr(r))}_add(e,r,a){this._handlers.push({handlerName:e,handler:r,allowed:a}),this._handlersById[e]=r}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(gs(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,r,a){for(const l in e)if(l!==a&&(!r||r.indexOf(l)<0))return!0;return!1}_getMapTouches(e){const r=[];for(const a of e)this._el.contains(a.target)&&r.push(a);return r}mergeHandlerResult(e,r,l,c,h){if(!l)return;a.e(e,l);const u={handlerName:c,originalEvent:l.originalEvent||h};void 0!==l.zoomDelta&&(r.zoom=u),void 0!==l.panDelta&&(r.drag=u),void 0!==l.rollDelta&&(r.roll=u),void 0!==l.pitchDelta&&(r.pitch=u),void 0!==l.bearingDelta&&(r.rotate=u)}_applyChanges(){const e={},r={},l={};for(const[c,h,u]of this._changes)c.panDelta&&(e.panDelta=(e.panDelta||new a.P(0,0))._add(c.panDelta)),c.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+c.zoomDelta),c.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+c.bearingDelta),c.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+c.pitchDelta),c.rollDelta&&(e.rollDelta=(e.rollDelta||0)+c.rollDelta),void 0!==c.around&&(e.around=c.around),void 0!==c.pinchAround&&(e.pinchAround=c.pinchAround),c.noInertia&&(e.noInertia=c.noInertia),a.e(r,h),a.e(l,u);this._updateMapTransform(e,r,l),this._changes=[]}_updateMapTransform(e,r,a){const l=this._map,c=l._getTransformForUpdate(),h=l.terrain;if(!(xs(e)||h&&this._terrainMovement))return this._fireEvents(r,a,!0);l._stop(!0);let{panDelta:u,zoomDelta:p,bearingDelta:g,pitchDelta:y,rollDelta:x,around:v,pinchAround:w}=e;void 0!==w&&(v=w),v=v||l.transform.centerPoint,h&&!c.isPointOnMapSurface(v)&&(v=c.centerPoint);const M={panDelta:u,zoomDelta:p,rollDelta:x,pitchDelta:y,bearingDelta:g,around:v};this._map.cameraHelper.useGlobeControls&&!c.isPointOnMapSurface(v)&&(v=c.centerPoint);const C=v.distSqr(c.centerPoint)<.01?c.center:c.screenPointToLocation(u?v.sub(u):v);h?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(M,c),this._terrainMovement||!r.drag&&!r.zoom?r.drag&&this._terrainMovement?c.setCenter(c.screenPointToLocation(c.centerPoint.sub(u))):this._map.cameraHelper.handleMapControlsPan(M,c,C):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(M,c,C))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(M,c),this._map.cameraHelper.handleMapControlsPan(M,c,C)),l._applyUpdatedTransform(c),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(r,a,!0)}_fireEvents(e,r,l){const c=gs(this._eventsInProgress),h=gs(e),u={};for(const r in e){const{originalEvent:a}=e[r];this._eventsInProgress[r]||(u[`${r}start`]=a),this._eventsInProgress[r]=e[r]}!c&&h&&this._fireEvent("movestart",h.originalEvent);for(const e in u)this._fireEvent(e,u[e]);h&&this._fireEvent("move",h.originalEvent);for(const r in e){const{originalEvent:a}=e[r];this._fireEvent(r,a)}const g={};let y;for(const e in this._eventsInProgress){const{handlerName:a,originalEvent:l}=this._eventsInProgress[e];this._handlersById[a].isActive()||(delete this._eventsInProgress[e],y=r[a]||l,g[`${e}end`]=y)}for(const e in g)this._fireEvent(e,g[e]);const x=gs(this._eventsInProgress),v=(c||h)&&!x;if(v&&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(l&&v){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),r=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Ma("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Ra extends a.E{constructor(e,r,a){super(),this._renderFrameCallback=()=>{const e=Math.min((p.now()-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=a.bearingSnap,this.cameraHelper=r,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(e,r){e.apply(this.transform),this.transform=e,this.cameraHelper=r}getCenter(){return new a.S(this.transform.center.lng,this.transform.center.lat)}setCenter(e,r){return this.jumpTo({center:e},r)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,r){return this.jumpTo({elevation:e},r),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,r,l){return e=a.P.convert(e).mult(-1),this.panTo(this.transform.center,a.e({offset:e},r),l)}panTo(e,r,l){return this.easeTo(a.e({center:e},r),l)}getZoom(){return this.transform.zoom}setZoom(e,r){return this.jumpTo({zoom:e},r),this}zoomTo(e,r,l){return this.easeTo(a.e({zoom:e},r),l)}zoomIn(e,r){return this.zoomTo(this.getZoom()+1,e,r),this}zoomOut(e,r){return this.zoomTo(this.getZoom()-1,e,r),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,r){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new a.l("movestart",r)).fire(new a.l("move",r)).fire(new a.l("moveend",r))),this}getBearing(){return this.transform.bearing}setBearing(e,r){return this.jumpTo({bearing:e},r),this}getPadding(){return this.transform.padding}setPadding(e,r){return this.jumpTo({padding:e},r),this}rotateTo(e,r,l){return this.easeTo(a.e({bearing:e},r),l)}resetNorth(e,r){return this.rotateTo(0,a.e({duration:1e3},e),r),this}resetNorthPitch(e,r){return this.easeTo(a.e({bearing:0,pitch:0,roll:0,duration:1e3},e),r),this}snapToNorth(e,r){return Math.abs(this.getBearing()){k.easeFunc(a),this.terrain&&!e.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(l),this._fireMoveEvents(r)}),(a=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(r,a)}),e),this}_prepareEase(e,r,l={}){this._moving=!0,r||l.moving||this.fire(new a.l("movestart",e)),this._zooming&&!l.zooming&&this.fire(new a.l("zoomstart",e)),this._rotating&&!l.rotating&&this.fire(new a.l("rotatestart",e)),this._pitching&&!l.pitching&&this.fire(new a.l("pitchstart",e)),this._rolling&&!l.rolling&&this.fire(new a.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){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const r=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&r!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(a-(r-(a*e+this._elevationStart))/(1-e)),this._elevationTarget=r}this.transform.setElevation(a.C.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 r=e.getCameraLngLat(),a=e.getCameraAltitude(),l=this.terrain?this.terrain.getElevationForLngLatZoom(r,e.zoom):0;if(athis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&r.push((e=>this.transformCameraUpdate(e))),!r.length)return;const a=e.clone();for(const e of r){const r=a.clone(),{center:l,zoom:c,roll:h,pitch:u,bearing:p,elevation:g}=e(r);l&&r.setCenter(l),void 0!==g&&r.setElevation(g),void 0!==c&&r.setZoom(c),void 0!==h&&r.setRoll(h),void 0!==u&&r.setPitch(u),void 0!==p&&r.setBearing(p),a.apply(r)}this.transform.apply(a)}_fireMoveEvents(e){this.fire(new a.l("move",e)),this._zooming&&this.fire(new a.l("zoom",e)),this._rotating&&this.fire(new a.l("rotate",e)),this._pitching&&this.fire(new a.l("pitch",e)),this._rolling&&this.fire(new a.l("roll",e))}_afterEase(e,r){if(this._easeId&&r&&this._easeId===r)return;delete this._easeId;const l=this._zooming,c=this._rotating,h=this._pitching,u=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,l&&this.fire(new a.l("zoomend",e)),c&&this.fire(new a.l("rotateend",e)),h&&this.fire(new a.l("pitchend",e)),u&&this.fire(new a.l("rollend",e)),this.fire(new a.l("moveend",e))}flyTo(e,r){if(!e.essential&&p.prefersReducedMotion){const l=a.Q(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(l,r)}this.stop(),e=a.e({offset:[0,0],speed:1.2,curve:1.42,easing:a.cn},e);const l=this._getTransformForUpdate(),c=l.bearing,h=l.pitch,u=l.roll,g=l.padding,y="bearing"in e?this._normalizeBearing(e.bearing,c):c,x="pitch"in e?+e.pitch:h,v="roll"in e?this._normalizeBearing(e.roll,u):u,w="padding"in e?e.padding:l.padding,M=a.P.convert(e.offset);let C=l.centerPoint.add(M);const A=l.screenPointToLocation(C),k=this.cameraHelper.handleFlyTo(l,{bearing:y,pitch:x,roll:v,padding:w,locationAtOffset:A,offsetAsPoint:M,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let R=e.curve;const D=Math.max(l.width,l.height),L=D/k.scaleOfZoom,B=k.pixelPathLength;"number"==typeof k.scaleOfMinZoom&&(R=Math.sqrt(D/k.scaleOfMinZoom/B*2));const O=R*R;function j(e){const r=(L*L-D*D+(e?-1:1)*O*O*B*B)/(2*(e?L:D)*O*B);return Math.log(Math.sqrt(r*r+1)-r)}function N(e){return(Math.exp(e)-Math.exp(-e))/2}function U(e){return(Math.exp(e)+Math.exp(-e))/2}const Z=j(!1);let J=function(e){return U(Z)/U(Z+R*e)},Q=function(e){return D*((U(Z)*(N(r=Z+R*e)/U(r))-N(Z))/O)/B;var r},et=(j(!0)-Z)/R;if(Math.abs(B)<2e-6||!isFinite(et)){if(Math.abs(D-L)<1e-6)return this.easeTo(e,r);const a=L0,J=e=>Math.exp(a*R*e)}return e.duration="duration"in e?+e.duration:1e3*et/("screenSpeed"in e?+e.screenSpeed/R:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=c!==y,this._pitching=x!==h,this._rolling=v!==u,this._padding=!l.isPaddingEqual(w),this._prepareEase(r,!1),this.terrain&&this._prepareElevation(k.targetCenter),this._ease((p=>{const A=p*et,R=1/J(A),D=Q(A);this._rotating&&l.setBearing(a.C.number(c,y,p)),this._pitching&&l.setPitch(a.C.number(h,x,p)),this._rolling&&l.setRoll(a.C.number(u,v,p)),this._padding&&(l.interpolatePadding(g,w,p),C=l.centerPoint.add(M)),k.easeFunc(p,R,D,C),this.terrain&&!e.freezeElevation&&this._updateElevation(p),this._applyUpdatedTransform(l),this._fireMoveEvents(r)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(r)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,r){var a;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,r)}return e||null===(a=this.handlers)||void 0===a||a.stop(!1),this}_ease(e,r,a){!1===a.animate||0===a.duration?(e(1),r()):(this._easeStart=p.now(),this._easeOptions=a,this._onEaseFrame=e,this._onEaseEnd=r,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,r){e=a.aN(e,-180,180);const l=Math.abs(e-r);return Math.abs(e-360-r)MapLibre'};class Da{constructor(e=vs){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=n.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=n.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.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(){n.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,r){const a=this._map._getUIString(`AttributionControl.${r}`);e.title=a,e.setAttribute("aria-label",a)}_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 r=this._map.style.sourceCaches;for(const a in r){const l=r[a];if(l.used||l.usedForTerrain){const r=l.getSource();r.attribution&&e.indexOf(r.attribution)<0&&e.push(r.attribution)}}e=e.filter((e=>String(e).trim())),e.sort(((e,r)=>e.length-r.length)),e=e.filter(((r,a)=>{for(let l=a+1;l=0)return!1;return!0}));const a=e.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,e.length?(this._innerContainer.innerHTML=n.sanitize(a),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Aa{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const r=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&r.classList.add("maplibregl-compact"):r.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=n.create("div","maplibregl-ctrl");const r=n.create("a","maplibregl-ctrl-logo");return r.target="_blank",r.rel="noopener nofollow",r.href="https://maplibre.org/",r.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),r.setAttribute("rel","noopener nofollow"),this._container.appendChild(r),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){n.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class La{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const r=++this._id;return this._queue.push({callback:e,id:r,cancelled:!1}),r}remove(e){const r=this._currentlyRunning,a=r?this._queue.concat(r):this._queue;for(const r of a)if(r.id===e)return void(r.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const r=this._currentlyRunning=this._queue;this._queue=[];for(const a of r)if(!a.cancelled&&(a.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var bs=a.aI([{name:"a_pos3d",type:"Int16",components:3}]);class Fa extends a.E{constructor(e){super(),this._lastTilesetChange=p.now(),this.sourceCache=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.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,r){this.sourceCache.update(e,r),this._renderableTilesKeys=[];const l={};for(const c of Ht(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:r,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))l[c.key]=!0,this._renderableTilesKeys.push(c.key),this._tiles[c.key]||(c.terrainRttPosMatrix32f=new Float64Array(16),a.bX(c.terrainRttPosMatrix32f,0,a.$,a.$,0,0,1),this._tiles[c.key]=new re(c,this.tileSize),this._lastTilesetChange=p.now());for(const e in this._tiles)l[e]||delete this._tiles[e]}freeRtt(e){for(const r in this._tiles){const a=this._tiles[r];(!e||a.tileID.equals(e)||a.tileID.isChildOf(e)||e.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,r){return r?this._getTerrainCoordsForTileRanges(e,r):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const r={};for(const l of this._renderableTilesKeys){const c=this._tiles[l].tileID,h=e.clone(),u=a.b9();if(c.canonical.equals(e.canonical))a.bX(u,0,a.$,a.$,0,0,1);else if(c.canonical.isChildOf(e.canonical)){const r=c.canonical.z-e.canonical.z,l=c.canonical.x-(c.canonical.x>>r<>r<>r;a.bX(u,0,p,p,0,0,1),a.M(u,u,[-l*p,-h*p,0])}else{if(!e.canonical.isChildOf(c.canonical))continue;{const r=e.canonical.z-c.canonical.z,l=e.canonical.x-(e.canonical.x>>r<>r<>r;a.bX(u,0,a.$,a.$,0,0,1),a.M(u,u,[l*p,h*p,0]),a.N(u,u,[1/2**r,1/2**r,0])}}h.terrainRttPosMatrix32f=new Float32Array(u),r[l]=h}return r}_getTerrainCoordsForTileRanges(e,r){const l={};for(const c of this._renderableTilesKeys){const h=this._tiles[c].tileID;if(!this._isWithinTileRanges(h,r))continue;const u=e.clone(),p=a.b9();if(h.canonical.z===e.canonical.z){const r=e.canonical.x-h.canonical.x,l=e.canonical.y-h.canonical.y;a.bX(p,0,a.$,a.$,0,0,1),a.M(p,p,[r*a.$,l*a.$,0])}else if(h.canonical.z>e.canonical.z){const r=h.canonical.z-e.canonical.z,l=h.canonical.x-(h.canonical.x>>r<>r<>r),g=e.canonical.y-(h.canonical.y>>r),y=a.$>>r;a.bX(p,0,y,y,0,0,1),a.M(p,p,[-l*y+u*a.$,-c*y+g*a.$,0])}else{const r=e.canonical.z-h.canonical.z,l=e.canonical.x-(e.canonical.x>>r<>r<>r)-h.canonical.x,g=(e.canonical.y>>r)-h.canonical.y,y=a.$<a.maxzoom&&(l=a.maxzoom),l=a.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(e.scaledTo(l--).key);return c}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,r){return r[e.canonical.z]&&e.canonical.x>=r[e.canonical.z].minTileX&&e.canonical.x<=r[e.canonical.z].maxTileX&&e.canonical.y>=r[e.canonical.z].minTileY&&e.canonical.y<=r[e.canonical.z].maxTileY}}class Ba{constructor(e,r,a){this._meshCache={},this.painter=e,this.sourceCache=new Fa(r),this.options=a,this.exaggeration="number"==typeof a.exaggeration?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,r,l,c=a.$){var h;if(!(r>=0&&r=0&&le.canonical.z&&(e.canonical.z>=l?c=e.canonical.z-l:a.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const h=e.canonical.x-(e.canonical.x>>c<>c<>8<<4|e>>8,r[a+3]=0;const l=new a.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(r.buffer)),c=new a.T(e,l,e.gl.RGBA,{premultiply:!1});return c.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=c,c}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const r=new Uint8Array(4),l=this.painter.context,c=l.gl,h=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),u=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),p=Math.round(this.painter.height/devicePixelRatio);l.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),c.readPixels(h,p-u-1,1,1,c.RGBA,c.UNSIGNED_BYTE,r),l.bindFramebuffer.set(null);const g=r[0]+(r[2]>>4<<8),y=r[1]+((15&r[2])<<8),x=this.coordsIndex[255-r[3]],v=x&&this.sourceCache.getTileByID(x);if(!v)return null;const w=this._coordsTextureSize,M=(1<0,c=l&&0===e.canonical.y,h=l&&e.canonical.y===(1<e.id!==r)),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 ws={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class Na{constructor(e,r){this.painter=e,this.terrain=r,this.pool=new Oa(e.context,30,r.sourceCache.tileSize*r.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,r){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((a=>!e._layers[a].isHidden(r))),this._coordsAscending={};for(const r in e.sourceCaches){this._coordsAscending[r]={};const a=e.sourceCaches[r].getVisibleCoordinates(),l=e.sourceCaches[r].getSource(),c=l instanceof X?l.terrainTileRanges:null;for(const e of a){const a=this.terrain.sourceCache.getTerrainCoords(e,c);for(const e in a)this._coordsAscending[r][e]||(this._coordsAscending[r][e]=[]),this._coordsAscending[r][e].push(a[e])}}this._coordsAscendingStr={};for(const r of e._order){const a=e._layers[r],l=a.source;if(ws[a.type]&&!this._coordsAscendingStr[l]){this._coordsAscendingStr[l]={};for(const e in this._coordsAscending[l])this._coordsAscendingStr[l][e]=this._coordsAscending[l][e].map((e=>e.key)).sort().join()}}for(const e of this._renderableTiles)for(const r in this._coordsAscendingStr){const a=this._coordsAscendingStr[r][e.tileID.key];a&&a!==e.rttCoords[r]&&(e.rtt=[])}}renderLayer(e,r){if(e.isHidden(this.painter.transform.zoom))return!1;const l=Object.assign(Object.assign({},r),{isRenderingToTexture:!0}),c=e.type,h=this.painter,u=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(ws[c]&&(this._prevType&&ws[this._prevType]||this._stacks.push([]),this._prevType=c,this._stacks[this._stacks.length-1].push(e.id),!u))return!0;if(ws[this._prevType]||ws[c]&&u){this._prevType=c;const e=this._stacks.length-1,r=this._stacks[e]||[];for(const c of this._renderableTiles){if(this.pool.isFull()&&(qn(this.painter,this.terrain,this._rttTiles,l),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(c),c.rtt[e]){const r=this.pool.getObjectForId(c.rtt[e].id);if(r.stamp===c.rtt[e].stamp){this.pool.useObject(r);continue}}const u=this.pool.getOrCreateFreeObject();this.pool.useObject(u),this.pool.stampObject(u),c.rtt[e]={id:u.id,stamp:u.stamp},h.context.bindFramebuffer.set(u.fbo.framebuffer),h.context.clear({color:a.be.transparent,stencil:0}),h.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,n.mousePos(this.element,e)),n.addEventListener(window,"mousemove",this.mousemove),n.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,n.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHanlder.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),n.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=n.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._rotatePitchHanlder.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=r;const c=new ia;this._rotatePitchHanlder=new Kr({clickTolerance:3,move:(e,c)=>{const h=r.getBoundingClientRect(),u=new a.P((h.bottom-h.top)/2,(h.right-h.left)/2);return{bearingDelta:a.cm(new a.P(e.x,c.y),c,u),pitchDelta:l?-.5*(c.y-e.y):void 0}},moveStateManager:c,enable:!0,assignEvents:()=>{}}),this.map=e,n.addEventListener(r,"mousedown",this.mousedown),n.addEventListener(r,"touchstart",this.touchstart,{passive:!1}),n.addEventListener(r,"touchcancel",this.reset)}startMove(e,r){this._rotatePitchHanlder.dragStart(e,r),n.disableDrag()}move(e,r){const a=this.map,{bearingDelta:l,pitchDelta:c}=this._rotatePitchHanlder.dragMove(e,r)||{};l&&a.setBearing(a.getBearing()+l),c&&a.setPitch(a.getPitch()+c)}off(){const e=this.element;n.removeEventListener(e,"mousedown",this.mousedown),n.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend),n.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){n.enableDrag(),n.removeEventListener(window,"mousemove",this.mousemove),n.removeEventListener(window,"mouseup",this.mouseup),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend)}}let As;function zs(e,r,l,c=!1){if(c||!l.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const h=new a.S(e.lng,e.lat);if(e=new a.S(e.lng,e.lat),r){const c=new a.S(e.lng-360,e.lat),h=new a.S(e.lng+360,e.lat),u=l.locationToScreenPoint(e).distSqr(r);l.locationToScreenPoint(c).distSqr(r)180;){const r=l.locationToScreenPoint(e);if(r.x>=0&&r.y>=0&&r.x<=l.width&&r.y<=l.height)break;e.lng>l.center.lng?e.lng-=360:e.lng+=360}return e.lng!==h.lng&&l.isPointOnMapSurface(l.locationToScreenPoint(e))?e:h}const ks={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 Zs(e,r,a){const l=e.classList;for(const e in ks)l.remove(`maplibregl-${a}-anchor-${e}`);l.add(`maplibregl-${a}-anchor-${r}`)}class Ka extends a.E{constructor(e){if(super(),this._onKeyPress=e=>{const r=e.code,a=e.charCode||e.keyCode;"Space"!==r&&"Enter"!==r&&32!==a&&13!==a||this.togglePopup()},this._onMapClick=e=>{const r=e.originalEvent.target,a=this._element;this._popup&&(r===a||a.contains(r))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const r=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!r)&&this._map.once("render",this._update),this._lngLat=zs(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 a="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?a=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(a=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let l="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?l="rotateX(0deg)":"map"===this._pitchAlignment&&(l=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),n.setTransform(this._element,`${ks[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${l} ${a}`),p.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){const r=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=r}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 a.l("dragstart"))),this.fire(new a.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 a.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=a.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=n.create("div");const r=n.createNS("http://www.w3.org/2000/svg","svg"),l=41,c=27;r.setAttributeNS(null,"display","block"),r.setAttributeNS(null,"height",`${l}px`),r.setAttributeNS(null,"width",`${c}px`),r.setAttributeNS(null,"viewBox",`0 0 ${c} ${l}`);const h=n.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"stroke","none"),h.setAttributeNS(null,"stroke-width","1"),h.setAttributeNS(null,"fill","none"),h.setAttributeNS(null,"fill-rule","evenodd");const u=n.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"fill-rule","nonzero");const p=n.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(3.0, 29.0)"),p.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 r=n.createNS("http://www.w3.org/2000/svg","ellipse");r.setAttributeNS(null,"opacity","0.04"),r.setAttributeNS(null,"cx","10.5"),r.setAttributeNS(null,"cy","5.80029008"),r.setAttributeNS(null,"rx",e.rx),r.setAttributeNS(null,"ry",e.ry),p.appendChild(r)}const y=n.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"fill",this._color);const x=n.createNS("http://www.w3.org/2000/svg","path");x.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(x);const v=n.createNS("http://www.w3.org/2000/svg","g");v.setAttributeNS(null,"opacity","0.25"),v.setAttributeNS(null,"fill","#000000");const w=n.createNS("http://www.w3.org/2000/svg","path");w.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"),v.appendChild(w);const M=n.createNS("http://www.w3.org/2000/svg","g");M.setAttributeNS(null,"transform","translate(6.0, 7.0)"),M.setAttributeNS(null,"fill","#FFFFFF");const C=n.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"transform","translate(8.0, 8.0)");const A=n.createNS("http://www.w3.org/2000/svg","circle");A.setAttributeNS(null,"fill","#000000"),A.setAttributeNS(null,"opacity","0.25"),A.setAttributeNS(null,"cx","5.5"),A.setAttributeNS(null,"cy","5.5"),A.setAttributeNS(null,"r","5.4999962");const k=n.createNS("http://www.w3.org/2000/svg","circle");k.setAttributeNS(null,"fill","#FFFFFF"),k.setAttributeNS(null,"cx","5.5"),k.setAttributeNS(null,"cy","5.5"),k.setAttributeNS(null,"r","5.4999962"),C.appendChild(A),C.appendChild(k),u.appendChild(p),u.appendChild(y),u.appendChild(v),u.appendChild(M),u.appendChild(C),r.appendChild(u),r.setAttributeNS(null,"height",l*this._scale+"px"),r.setAttributeNS(null,"width",c*this._scale+"px"),this._element.appendChild(r),this._offset=a.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()})),Zs(this._element,this._anchor,"marker"),e&&e.className)for(const r of e.className.split(" "))this._element.classList.add(r);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")),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),n.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=a.S.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 r=38.1,a=13.5,l=Math.abs(a)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-r],"bottom-left":[l,-1*(r-a+l)],"bottom-right":[-l,-1*(r-a+l)],left:[a,-1*(r-a)],right:[-a,-1*(r-a)]}: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 r,l;const c=null===(r=this._map)||void 0===r?void 0:r.terrain,h=this._map.transform.isLocationOccluded(this._lngLat);if(!c||h){const e=h?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 u=this._map,p=u.terrain.depthAtPoint(this._pos),g=u.terrain.getElevationForLngLatZoom(this._lngLat,u.transform.tileZoom);if(u.transform.lngLatToCameraDepth(this._lngLat,g)-p<.006)return void(this._element.style.opacity=this._opacity);const y=-this._offset.y/u.transform.pixelsPerMeter,x=Math.sin(u.getPitch()*Math.PI/180)*y,v=u.terrain.depthAtPoint(new a.P(this._pos.x,this._pos.y-this._offset.y)),w=u.transform.lngLatToCameraDepth(this._lngLat,g+x)-v>.006;(null===(l=this._popup)||void 0===l?void 0:l.isOpen())&&w&&this._popup.remove(),this._element.style.opacity=w?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=a.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,r){return(void 0===this._opacity||void 0===e&&void 0===r)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==r&&(this._opacityWhenCovered=r),this._map&&this._updateOpacity(!0),this}}const Gs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Ks=0,Js=!1;const to={maxWidth:100,unit:"metric"};function eo(e,r,a){const l=a&&a.maxWidth||100,c=e._container.clientHeight/2,h=e._container.clientWidth/2,u=e.unproject([h-l/2,c]),p=e.unproject([h+l/2,c]),g=Math.round(e.project(p).x-e.project(u).x),y=Math.min(l,g,e._container.clientWidth),x=u.distanceTo(p);if(a&&"imperial"===a.unit){const a=3.2808*x;a>5280?io(r,y,a/5280,e._getUIString("ScaleControl.Miles")):io(r,y,a,e._getUIString("ScaleControl.Feet"))}else a&&"nautical"===a.unit?io(r,y,x/1852,e._getUIString("ScaleControl.NauticalMiles")):x>=1e3?io(r,y,x/1e3,e._getUIString("ScaleControl.Kilometers")):io(r,y,x,e._getUIString("ScaleControl.Meters"))}function io(e,r,a,l){const c=function(e){const r=Math.pow(10,`${Math.floor(e)}`.length-1);let a=e/r;return a=a>=10?10:a>=5?5:a>=3?3:a>=2?2:a>=1?1:function(e){const r=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*r)/r}(a),r*a}(a);e.style.width=r*(c/a)+"px",e.innerHTML=`${c} ${l}`}const ro={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},no=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function oo(e){if(e){if("number"==typeof e){const r=Math.round(Math.abs(e)/Math.SQRT2);return{center:new a.P(0,0),top:new a.P(0,e),"top-left":new a.P(r,r),"top-right":new a.P(-r,r),bottom:new a.P(0,-e),"bottom-left":new a.P(r,-r),"bottom-right":new a.P(-r,-r),left:new a.P(e,0),right:new a.P(-e,0)}}if(e instanceof a.P||Array.isArray(e)){const r=a.P.convert(e);return{center:r,top:r,"top-left":r,"top-right":r,bottom:r,"bottom-left":r,"bottom-right":r,left:r,right:r}}return{center:a.P.convert(e.center||[0,0]),top:a.P.convert(e.top||[0,0]),"top-left":a.P.convert(e["top-left"]||[0,0]),"top-right":a.P.convert(e["top-right"]||[0,0]),bottom:a.P.convert(e.bottom||[0,0]),"bottom-left":a.P.convert(e["bottom-left"]||[0,0]),"bottom-right":a.P.convert(e["bottom-right"]||[0,0]),left:a.P.convert(e.left||[0,0]),right:a.P.convert(e.right||[0,0])}}return oo(new a.P(0,0))}const qo=l;r.AJAXError=a.cy,r.Event=a.l,r.Evented=a.E,r.LngLat=a.S,r.MercatorCoordinate=a.a0,r.Point=a.P,r.addProtocol=a.cz,r.config=a.a,r.removeProtocol=a.cA,r.AttributionControl=Da,r.BoxZoomHandler=$r,r.CanvasSource=Y,r.CooperativeGesturesHandler=Ca,r.DoubleClickZoomHandler=ba,r.DragPanHandler=wa,r.DragRotateHandler=Ta,r.EdgeInsets=Mt,r.FullscreenControl=class extends a.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let r=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==r?void 0:r.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)r=r.shadowRoot.fullscreenElement;r===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:a.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=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){n.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);n.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 a.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new a.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()}},r.GeoJSONSource=H,r.GeolocateControl=class extends a.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new a.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 a.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const r=new a.S(e.coords.longitude,e.coords.latitude),l=e.coords.accuracy,c=this._map.getBearing(),h=a.e({bearing:c},this.options.fitBoundsOptions),u=G.fromLngLat(r,l);this._map.fitBounds(u,h,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const r=new a.S(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},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&&Js)return;this.options.trackUserLocation&&this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new a.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=n.create("button","maplibregl-ctrl-geolocate",this._container),n.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){a.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=n.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ka({element:this._dotElement}),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ka({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new a.l("trackuserlocationend")),this.fire(new a.l("userlocationlostfocus")))}))}},this.options=a.e({},Gs,e)}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return a._(this,arguments,void 0,(function*(e=!1){if(void 0!==As&&!e)return As;if(void 0===window.navigator.permissions)return As=!!window.navigator.geolocation,As;try{const e=yield window.navigator.permissions.query({name:"geolocation"});As="denied"!==e.state}catch(e){As=!!window.navigator.geolocation}return As}))}().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(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Ks=0,Js=!1}_isOutOfMapMaxBounds(e){const r=this._map.getMaxBounds(),a=e.coords;return r&&(a.longituder.getEast()||a.latituder.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":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const e=this._map.getBounds(),r=e.getSouthEast(),a=e.getNorthEast(),l=r.distanceTo(a),c=Math.ceil(this._accuracy/(l/this._map._container.clientHeight)*2);this._circleElement.style.width=`${c}px`,this._circleElement.style.height=`${c}px`}trigger(){if(!this._setup)return a.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 a.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Ks--,Js=!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 a.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 a.l("trackuserlocationstart")),this.fire(new a.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"),Ks++,Ks>1?(e={maximumAge:6e5,timeout:0},Js=!0):(e=this.options.positionOptions,Js=!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)}},r.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const r=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==r&&r?{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=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=n.create("button","maplibregl-ctrl-globe",this._container),n.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(){n.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},r.Hash=Er,r.ImageSource=X,r.KeyboardHandler=pa,r.LngLatBounds=G,r.LogoControl=Aa,r.Map=class extends Ra{constructor(e){var r,l;a.cv.mark(a.cw.create);const c=Object.assign(Object.assign(Object.assign({},Ms),e),{canvasContextAttributes:Object.assign(Object.assign({},Ms.canvasContextAttributes),e.canvasContextAttributes)});if(null!=c.minZoom&&null!=c.maxZoom&&c.minZoom>c.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=c.minPitch&&null!=c.maxPitch&&c.minPitch>c.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=c.minPitch&&c.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=c.maxPitch&&c.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const h=new Lt,u=new Ot;if(void 0!==c.minZoom&&h.setMinZoom(c.minZoom),void 0!==c.maxZoom&&h.setMaxZoom(c.maxZoom),void 0!==c.minPitch&&h.setMinPitch(c.minPitch),void 0!==c.maxPitch&&h.setMaxPitch(c.maxPitch),void 0!==c.renderWorldCopies&&h.setRenderWorldCopies(c.renderWorldCopies),super(h,u,{bearingSnap:c.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new La,this._controls=[],this._mapId=a.a6(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new a.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new a.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=c.interactive,this._maxTileCacheSize=c.maxTileCacheSize,this._maxTileCacheZoomLevels=c.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},c.canvasContextAttributes),this._trackResize=!0===c.trackResize,this._bearingSnap=c.bearingSnap,this._centerClampedToGround=c.centerClampedToGround,this._refreshExpiredTiles=!0===c.refreshExpiredTiles,this._fadeDuration=c.fadeDuration,this._crossSourceCollisions=!0===c.crossSourceCollisions,this._collectResourceTiming=!0===c.collectResourceTiming,this._locale=Object.assign(Object.assign({},Ps),c.locale),this._clickTolerance=c.clickTolerance,this._overridePixelRatio=c.pixelRatio,this._maxCanvasSize=c.maxCanvasSize,this.transformCameraUpdate=c.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===c.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=C.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(c.transformRequest),"string"==typeof c.container){if(this._container=document.getElementById(c.container),!this._container)throw new Error(`Container '${c.container}' not found.`)}else{if(!(c.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=c.container}if(c.maxBounds&&this.setMaxBounds(c.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const r=Hn((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50);this._resizeObserver=new ResizeObserver((a=>{e?r(a):e=!0})),this._resizeObserver.observe(this._container)}this.handlers=new Ea(this,c),this._hash=c.hash&&new Er("string"==typeof c.hash&&c.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:c.center,elevation:c.elevation,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,roll:c.roll}),c.bounds&&(this.resize(),this.fitBounds(c.bounds,a.e({},c.fitBoundsOptions,{duration:0}))));const p="string"==typeof c.style||!("globe"===(null===(l=null===(r=c.style)||void 0===r?void 0:r.projection)||void 0===l?void 0:l.type));this.resize(null,p),this._localIdeographFontFamily=c.localIdeographFontFamily,this._validateStyle=c.validateStyle,c.style&&this.setStyle(c.style,{localIdeographFontFamily:c.localIdeographFontFamily}),c.attributionControl&&this.addControl(new Da("boolean"==typeof c.attributionControl?void 0:c.attributionControl)),c.maplibreLogo&&this.addControl(new Aa,c.logoPosition),this.on("style.load",(()=>{if(p||this._resizeTransform(),this.transform.unmodified){const e=a.Q(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new a.l(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new a.l(`${e.dataType}dataloading`,e))})),this.on("dataabort",(e=>{this.fire(new a.l("sourcedataabort",e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,r){return this.style.setGlobalStateProperty(e,r),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,r){if(void 0===r&&(r=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new a.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const l=e.onAdd(this);this._controls.push(e);const c=this._controlPositions[r];return-1!==r.indexOf("bottom")?c.insertBefore(l,c.firstChild):c.appendChild(l),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new a.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(e);return r>-1&&this._controls.splice(r,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}calculateCameraOptionsFromTo(e,r,a,l){return null==l&&this.terrain&&(l=this.terrain.getElevationForLngLatZoom(a,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,r,a,l)}resize(e,r=!0){const[l,c]=this._containerDimensions(),h=this._getClampedPixelRatio(l,c);if(this._resizeCanvas(l,c,h),this.painter.resize(l,c,h),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const r=this._getClampedPixelRatio(l,c);this._resizeCanvas(l,c,r),this.painter.resize(l,c,r)}this._resizeTransform(r);const u=!this._moving;return u&&(this.stop(),this.fire(new a.l("movestart",e)).fire(new a.l("move",e))),this.fire(new a.l("resize",e)),u&&this.fire(new a.l("moveend",e)),this}_resizeTransform(e=!0){var r;const[a,l]=this._containerDimensions();this.transform.resize(a,l,e),null===(r=this._requestedCameraState)||void 0===r||r.resize(a,l,e)}_getClampedPixelRatio(e,r){const{0:a,1:l}=this._maxCanvasSize,c=this.getPixelRatio(),h=e*c,u=r*c;return Math.min(h>a?a/h:1,u>l?l/u:1)*c}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(G.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(a.S.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(a.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,r,a){if("mouseenter"===e||"mouseover"===e){let l=!1;const c=c=>{const h=r.filter((e=>this.getLayer(e))),u=0!==h.length?this.queryRenderedFeatures(c.point,{layers:h}):[];u.length?l||(l=!0,a.call(this,new jr(e,this,c.originalEvent,{features:u}))):l=!1};return{layers:r,listener:a,delegates:{mousemove:c,mouseout:()=>{l=!1}}}}if("mouseleave"===e||"mouseout"===e){let l=!1;const c=c=>{const h=r.filter((e=>this.getLayer(e)));(0!==h.length?this.queryRenderedFeatures(c.point,{layers:h}):[]).length?l=!0:l&&(l=!1,a.call(this,new jr(e,this,c.originalEvent)))},h=r=>{l&&(l=!1,a.call(this,new jr(e,this,r.originalEvent)))};return{layers:r,listener:a,delegates:{mousemove:c,mouseout:h}}}{const l=e=>{const l=r.filter((e=>this.getLayer(e))),c=0!==l.length?this.queryRenderedFeatures(e.point,{layers:l}):[];c.length&&(e.features=c,a.call(this,e),delete e.features)};return{layers:r,listener:a,delegates:{[e]:l}}}}_saveDelegatedListener(e,r){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r)}_removeDelegatedListener(e,r,a){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const l=this._delegatedListeners[e];for(let e=0;er.includes(e)))){for(const e in c.delegates)this.off(e,c.delegates[e]);return void l.splice(e,1)}}}on(e,r,a){if(void 0===a)return super.on(e,r);const l="string"==typeof r?[r]:r,c=this._createDelegatedListener(e,l,a);this._saveDelegatedListener(e,c);for(const e in c.delegates)this.on(e,c.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,l,a)}}}once(e,r,a){if(void 0===a)return super.once(e,r);const l="string"==typeof r?[r]:r,c=this._createDelegatedListener(e,l,a);for(const r in c.delegates){const h=c.delegates[r];c.delegates[r]=(...r)=>{this._removeDelegatedListener(e,l,a),h(...r)}}this._saveDelegatedListener(e,c);for(const e in c.delegates)this.once(e,c.delegates[e]);return this}off(e,r,a){return void 0===a?super.off(e,r):(this._removeDelegatedListener(e,"string"==typeof r?[r]:r,a),this)}queryRenderedFeatures(e,r){if(!this.style)return[];let l;const c=e instanceof a.P||Array.isArray(e),h=c?e:[[0,0],[this.transform.width,this.transform.height]];if(r=r||(c?{}:e)||{},h instanceof a.P||"number"==typeof h[0])l=[a.P.convert(h)];else{const e=a.P.convert(h[0]),r=a.P.convert(h[1]);l=[e,new a.P(r.x,e.y),r,new a.P(e.x,r.y),e]}return this.style.queryRenderedFeatures(l,r,this.transform)}querySourceFeatures(e,r){return this.style.querySourceFeatures(e,r)}setStyle(e,r){return!1!==(r=a.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},r)).diff&&r.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,r),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._updateStyle(e,r))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const r=this._locale[e];if(null==r)throw new Error(`Missing UI string '${e}'`);return r}_updateStyle(e,r){var a,l;if(r.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,r)));const c=this.style&&r.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new wi(this,r||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,r,c):this.style.loadJSON(e,r,c),this):(null===(l=null===(a=this.style)||void 0===a?void 0:a.projection)||void 0===l||l.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new wi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,r){if("string"==typeof e){const l=this._requestManager.transformRequest(e,"Style");a.j(l,new AbortController).then((e=>{this._updateDiff(e.data,r)})).catch((e=>{e&&this.fire(new a.k(e))}))}else"object"==typeof e&&this._updateDiff(e,r)}_updateDiff(e,r){try{this.style.setState(e,r)&&this._update(!0)}catch(l){a.w(`Unable to perform style diff: ${l.message||l.error||l}. Rebuilding the style from scratch.`),this._updateStyle(e,r)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():a.w("There is no style added to the map.")}addSource(e,r){return this._lazyInitEmptyStyle(),this.style.addSource(e,r),this._update(!0)}isSourceLoaded(e){const r=this.style&&this.style.sourceCaches[e];if(void 0!==r)return r.loaded();this.fire(new a.k(new Error(`There is no source with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const r=this.style.sourceCaches[e.source];if(!r)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&r.reload();for(const r in this.style._layers){const l=this.style._layers[r];"hillshade"===l.type&&l.source===e.source&&a.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"===l.type&&l.source===e.source&&a.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 Ba(this.painter,r,e),this.painter.renderToTexture=new Na(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=r=>{var a;"style"===r.dataType?this.terrain.sourceCache.freeRtt():"source"===r.dataType&&r.tile&&(r.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===(a=r.source)||void 0===a?void 0:a.type)?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(r.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.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 a.l("terrain",{terrain:e})),this}getTerrain(){var e,r;return null!==(r=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==r?r:null}areTilesLoaded(){const e=this.style&&this.style.sourceCaches;for(const r in e){const a=e[r]._tiles;for(const e in a){const r=a[e];if("loaded"!==r.state&&"errored"!==r.state)return!1}}return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,r,a){if(a){const l=this.getSource(a);if(!l)throw new Error(`There is no source with ID "${a}", cannot set LOD parameters`);l.calculateTileZoom=$t(Math.max(1,e),Math.max(1,r))}else for(const a in this.style.sourceCaches)this.style.sourceCaches[a].getSource().calculateTileZoom=$t(Math.max(1,e),Math.max(1,r));return this._update(!0),this}refreshTiles(e,r){const l=this.style.sourceCaches[e];if(!l)throw new Error(`There is no source cache with ID "${e}", cannot refresh tile`);void 0===r?l.reload(!0):l.refreshTiles(r.map((e=>new a.a3(e.z,e.x,e.y))))}addImage(e,r,l={}){const{pixelRatio:c=1,sdf:h=!1,stretchX:u,stretchY:g,content:y,textFitWidth:x,textFitHeight:v}=l;if(this._lazyInitEmptyStyle(),!(r instanceof HTMLImageElement||a.b(r))){if(void 0===r.width||void 0===r.height)return this.fire(new a.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:l,height:p,data:w}=r,M=r;return this.style.addImage(e,{data:new a.R({width:l,height:p},new Uint8Array(w)),pixelRatio:c,stretchX:u,stretchY:g,content:y,textFitWidth:x,textFitHeight:v,sdf:h,version:0,userImage:M}),M.onAdd&&M.onAdd(this,e),this}}{const{width:l,height:w,data:M}=p.getImageData(r);this.style.addImage(e,{data:new a.R({width:l,height:w},M),pixelRatio:c,stretchX:u,stretchY:g,content:y,textFitWidth:x,textFitHeight:v,sdf:h,version:0})}}updateImage(e,r){const l=this.style.getImage(e);if(!l)return this.fire(new a.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const c=r instanceof HTMLImageElement||a.b(r)?p.getImageData(r):r,{width:h,height:u,data:g}=c;if(void 0===h||void 0===u)return this.fire(new a.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(h!==l.data.width||u!==l.data.height)return this.fire(new a.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const y=!(r instanceof HTMLImageElement||a.b(r));return l.data.replace(g,y),this.style.updateImage(e,l),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new a.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return C.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,r){return this._lazyInitEmptyStyle(),this.style.addLayer(e,r),this._update(!0)}moveLayer(e,r){return this.style.moveLayer(e,r),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,r,a){return this.style.setLayerZoomRange(e,r,a),this._update(!0)}setFilter(e,r,a={}){return this.style.setFilter(e,r,a),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,r,a,l={}){return this.style.setPaintProperty(e,r,a,l),this._update(!0)}getPaintProperty(e,r){return this.style.getPaintProperty(e,r)}setLayoutProperty(e,r,a,l={}){return this.style.setLayoutProperty(e,r,a,l),this._update(!0)}getLayoutProperty(e,r){return this.style.getLayoutProperty(e,r)}setGlyphs(e,r={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,r),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,r,a={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,r,a,(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,r={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,r,(e=>{e||this._update(!0)})),this}setLight(e,r={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,r),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,r={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,r),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,r){return this.style.setFeatureState(e,r),this._update()}removeFeatureState(e,r){return this.style.removeFeatureState(e,r),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,r=0;return this._container&&(e=this._container.clientWidth||400,r=this._container.clientHeight||300),[e,r]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const r=this._canvasContainer=n.create("div","maplibregl-canvas-container",e);this._interactive&&r.classList.add("maplibregl-interactive"),this._canvas=n.create("canvas","maplibregl-canvas",r),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 a=this._containerDimensions(),l=this._getClampedPixelRatio(a[0],a[1]);this._resizeCanvas(a[0],a[1],l);const c=this._controlContainer=n.create("div","maplibregl-control-container",e),h=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{h[e]=n.create("div",`maplibregl-ctrl-${e} `,c)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,r,a){this._canvas.width=Math.floor(a*e),this._canvas.height=Math.floor(a*r),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${r}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let r=null;this._canvas.addEventListener("webglcontextcreationerror",(a=>{r={requestedAttributes:e},a&&(r.statusMessage=a.statusMessage,r.type=a.type)}),{once:!0});let a=null;if(a=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!a){const e="Failed to initialize WebGL";throw r?(r.message=e,new Error(JSON.stringify(r))):new Error(e)}this.painter=new Mr(a,this.transform),g.testSupport(a)}migrateProjection(e,r){super.migrateProjection(e,r),this.painter.transform=e,this.fire(new a.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 r,l,c,h,u;const g=this._idleTriggered?this._fadeDuration:0,y=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let x=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,r=p.now();this.style.zoomHistory.update(e,r);const l=new a.F(e,{now:r,fadeDuration:g,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition(),globalState:this.style.getGlobalState()}),c=l.crossFadingFactor();1===c&&c===this._crossFadingFactor||(x=!0,this._crossFadingFactor=c),this.style.update(l)}const v=(null===(l=this.style.projection)||void 0===l?void 0:l.transitionState)>0!==y;null===(c=this.style.projection)||void 0===c||c.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(h=this.style.projection)||void 0===h?void 0:h.transitionState,null===(u=this.style.projection)||void 0===u?void 0:u.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||v)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.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,g,this._crossSourceCollisions,v),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:g,showPadding:this.showPadding}),this.fire(new a.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,a.cv.mark(a.cw.load),this.fire(new a.l("load"))),this.style&&(this.style.hasTransitions()||x)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const w=this._sourcesDirty||this._styleDirty||this._placementDirty;return w||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new a.l("idle")),!this._loaded||this._fullyLoaded||w||(this._fullyLoaded=!0,a.cv.mark(a.cw.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),C.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const r=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==r?void 0:r.loseContext)&&r.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),n.remove(this._canvasContainer),n.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),a.cv.clearMetrics(),this._removed=!0,this.fire(new a.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,p.frame(this._frameRequest,(e=>{a.cv.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!a.cx(e)&&!function(e){return e.message===dn}(e))throw e}}),(()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return Ss}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},r.MapMouseEvent=jr,r.MapTouchEvent=Nr,r.MapWheelEvent=Zr,r.Marker=Ka,r.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),r=e===this._map.getMaxZoom(),a=e===this._map.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",r.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.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,r)=>{const a=this._map._getUIString(`NavigationControl.${r}`);e.title=a,e.setAttribute("aria-label",a)},this.options=a.e({},Is,e),this._container=n.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}))),n.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}))),n.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=n.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 $a(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){n.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,r){const a=n.create("button",e,this._container);return a.type="button",a.addEventListener("click",r),a}},r.Popup=class extends a.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&&n.remove(this._content),this._container&&(n.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 a.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=n.create("div","maplibregl-popup",this._map.getContainer()),this._tip=n.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=zs(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const r=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 a=this.options.anchor;const l=oo(this.options.offset);if(!a){const e=this._container.offsetWidth,c=this._container.offsetHeight;let h;h=r.y+l.bottom.ythis._map.transform.height-c?["bottom"]:[],r.xthis._map.transform.width-e/2&&h.push("right"),a=0===h.length?"bottom":h.join("-")}let c=r.add(l[a]);this.options.subpixelPositioning||(c=c.round()),n.setTransform(this._container,`${ks[a]} translate(${c.x}px,${c.y}px)`),Zs(this._container,a,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=a.e(Object.create(ro),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 a.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=a.S.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 r=document.createDocumentFragment(),a=document.createElement("body");let l;for(a.innerHTML=e;l=a.firstChild,l;)r.appendChild(l);return this.setDOMContent(r)}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=n.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=n.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(no);e&&e.focus()}},r.RasterDEMTileSource=W,r.RasterTileSource=q,r.ScaleControl=class{constructor(e){this._onMove=()=>{eo(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,eo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},to),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},r.ScrollZoomHandler=va,r.Style=wi,r.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=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=n.create("button","maplibregl-ctrl-terrain",this._container),n.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(){n.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},r.TwoFingersTouchPitchHandler=da,r.TwoFingersTouchRotateHandler=ha,r.TwoFingersTouchZoomHandler=la,r.TwoFingersTouchZoomRotateHandler=Pa,r.VectorTileSource=$,r.VideoSource=K,r.addSourceType=(e,r)=>a._(void 0,void 0,void 0,(function*(){if(lt(e))throw new Error(`A source type called "${e}" already exists.`);((e,r)=>{at[e]=r})(e,r)})),r.clearPrewarmedResources=function(){const e=Z;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(N),Z=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()"))},r.createTileMesh=Di,r.getMaxParallelImageRequests=function(){return a.a.MAX_PARALLEL_IMAGE_REQUESTS},r.getRTLTextPluginStatus=function(){return ut().getRTLTextPluginStatus()},r.getVersion=function(){return qo},r.getWorkerCount=function(){return z.workerCount},r.getWorkerUrl=function(){return a.a.WORKER_URL},r.importScriptInWorkers=function(e){return et().broadcast("IS",e)},r.prewarm=function(){Q().acquire(N)},r.setMaxParallelImageRequests=function(e){a.a.MAX_PARALLEL_IMAGE_REQUESTS=e},r.setRTLTextPlugin=function(e,r){return ut().setRTLTextPlugin(e,r)},r.setWorkerCount=function(e){z.workerCount=e},r.setWorkerUrl=function(e){a.a.WORKER_URL=e}}));var c=r;return c}));var a=r;export{a as default}; + * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.6.2/LICENSE.txt + */(function(e,a){s=a()})(0,(function(){var s={};var a={};function l(e,l,c){a[e]=c;if(e==="index"){var u="var sharedModule = {}; ("+a.shared+")(sharedModule); ("+a.worker+")(sharedModule);";var p={};a.shared(p);a.index(s,p);typeof window!=="undefined"&&s.setWorkerUrl(window.URL.createObjectURL(new Blob([u],{type:"text/javascript"})));return s}}l("shared",["exports"],(function(s){function a(e,s,a,l){return new(a||(a=Promise))((function(c,u){function p(e){try{_(l.next(e))}catch(e){u(e)}}function f(e){try{_(l.throw(e))}catch(e){u(e)}}function _(e){var s;e.done?c(e.value):(s=e.value,s instanceof a?s:new a((function(e){e(s)}))).then(p,f)}_((l=l.apply(e,s||[])).next())}))}function l(s,a){(this||e).x=s,(this||e).y=a}function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var u,p;"function"==typeof SuppressedError&&SuppressedError,l.prototype={clone(){return new l((this||e).x,(this||e).y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,s){return this.clone()._rotateAround(e,s)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt((this||e).x*(this||e).x+(this||e).y*(this||e).y)},equals(s){return(this||e).x===s.x&&(this||e).y===s.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(s){const a=s.x-(this||e).x,l=s.y-(this||e).y;return a*a+l*l},angle(){return Math.atan2((this||e).y,(this||e).x)},angleTo(s){return Math.atan2((this||e).y-s.y,(this||e).x-s.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(s,a){return Math.atan2((this||e).x*a-(this||e).y*s,(this||e).x*s+(this||e).y*a)},_matMult(s){const a=s[2]*(this||e).x+s[3]*(this||e).y;return(this||e).x=s[0]*(this||e).x+s[1]*(this||e).y,(this||e).y=a,this||e},_add(s){return(this||e).x+=s.x,(this||e).y+=s.y,this||e},_sub(s){return(this||e).x-=s.x,(this||e).y-=s.y,this||e},_mult(s){return(this||e).x*=s,(this||e).y*=s,this||e},_div(s){return(this||e).x/=s,(this||e).y/=s,this||e},_multByPoint(s){return(this||e).x*=s.x,(this||e).y*=s.y,this||e},_divByPoint(s){return(this||e).x/=s.x,(this||e).y/=s.y,this||e},_unit(){return this._div(this.mag()),this||e},_perp(){const s=(this||e).y;return(this||e).y=(this||e).x,(this||e).x=-s,this||e},_rotate(s){const a=Math.cos(s),l=Math.sin(s),c=l*(this||e).x+a*(this||e).y;return(this||e).x=a*(this||e).x-l*(this||e).y,(this||e).y=c,this||e},_rotateAround(s,a){const l=Math.cos(s),c=Math.sin(s),u=a.y+c*((this||e).x-a.x)+l*((this||e).y-a.y);return(this||e).x=a.x+l*((this||e).x-a.x)-c*((this||e).y-a.y),(this||e).y=u,this||e},_round(){return(this||e).x=Math.round((this||e).x),(this||e).y=Math.round((this||e).y),this||e},constructor:l},l.convert=function(e){if(e instanceof l)return e;if(Array.isArray(e))return new l(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new l(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var f=function(){if(p)return u;function s(s,a,l,c){(this||e).cx=3*s,(this||e).bx=3*(l-s)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*a,(this||e).by=3*(c-a)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=s,(this||e).p1y=a,(this||e).p2x=l,(this||e).p2y=c}return p=1,u=s,s.prototype={sampleCurveX:function(s){return(((this||e).ax*s+(this||e).bx)*s+(this||e).cx)*s},sampleCurveY:function(s){return(((this||e).ay*s+(this||e).by)*s+(this||e).cy)*s},sampleCurveDerivativeX:function(s){return(3*(this||e).ax*s+2*(this||e).bx)*s+(this||e).cx},solveCurveX:function(e,s){if(void 0===s&&(s=1e-6),e<0)return 0;if(e>1)return 1;for(var a=e,l=0;l<8;l++){var c=this.sampleCurveX(a)-e;if(Math.abs(c)c?p=a:f=a,a=.5*(f-p)+p;return a},solve:function(e,s){return this.sampleCurveY(this.solveCurveX(e,s))}},u}(),_=c(f);let g,y;function x(){return null==g&&(g="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),g}function v(){if(null==y&&(y=!1,x())){const e=5,s=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(s){for(let a=0;a=1)return 1;const s=e*e,a=s*e;return 4*(e<.5?a:3*(e-s)+a-.75)}function lt(e,s,a,l){const c=new _(e,s,a,l);return e=>c.solve(e)}const ct=lt(.25,.1,.25,1);function ht(e,s,a){return Math.min(a,Math.max(s,e))}function pt(e,s,a){const l=a-s,c=((e-s)%l+l)%l+s;return c===s?a:c}function xt(e,...s){for(const a of s)for(const s in a)e[s]=a[s];return e}let bt=1;function Tt(s,a,l){const c={};for(const l in s)c[l]=a.call(this||e,s[l],l,s);return c}function Pt(s,a,l){const c={};for(const l in s)a.call(this||e,s[l],l,s)&&(c[l]=s[l]);return c}function St(e){return Array.isArray(e)?e.map(St):"object"==typeof e&&e?Tt(e,St):e}const Et={};function kt(e){Et[e]||("undefined"!=typeof console&&console.warn(e),Et[e]=!0)}function Ft(e,s,a){return(a.y-e.y)*(s.x-e.x)>(s.y-e.y)*(a.x-e.x)}function Nt(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let $t=null;function Gt(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const qt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Xt(s,l,c,u,p){return a(this||e,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(s,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const f=a.startsWith("BGR"),_=new Uint8ClampedArray(u*p*4);if(yield e.copyTo(_,function(e,s,a,l,c){const u=4*Math.max(-s,0),p=(Math.max(0,a)-a)*l*4+u,f=4*l,_=Math.max(0,s),g=Math.max(0,a);return{rect:{x:_,y:g,width:Math.min(e.width,s+l)-_,height:Math.min(e.height,a+c)-g},layout:[{offset:p,stride:f}]}}(s,l,c,u,p)),f)for(let e=0;e<_.length;e+=4){const s=_[e];_[e]=_[e+2],_[e+2]=s}return _}finally{e.close()}}))}let Ht,Kt;function Qt(e,s,a,l){return e.addEventListener(s,a,l),{unsubscribe:()=>{e.removeEventListener(s,a,l)}}}function ee(e){return e*Math.PI/180}function ie(e){return e/Math.PI*180}const ne={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},le={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},ce="AbortError";function he(){return new Error(ce)}const ue={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function de(e){return ue.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const pe="global-dispatcher";class ut extends Error{constructor(e,s,a,l){super(`AJAXError: ${s} (${e}): ${a}`),this.status=e,this.statusText=s,this.url=a,this.body=l}}const fe=()=>Nt(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,me=function(s,l){if(/:\/\//.test(s.url)&&!/^https?:|^file:/.test(s.url)){const e=de(s.url);if(e)return e(s,l);if(Nt(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:s,targetMapId:pe},l)}if(!(/^file:/.test(c=s.url)||/^file:/.test(fe())&&!/^\w+:/.test(c))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,l){return a(this||e,void 0,void 0,(function*(){const e=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:fe(),signal:l.signal});let a,c;"json"!==s.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{a=yield fetch(e)}catch(e){throw new ut(0,e.message,s.url,new Blob)}if(!a.ok){const e=yield a.blob();throw new ut(a.status,a.statusText,s.url,e)}c="arrayBuffer"===s.type||"image"===s.type?a.arrayBuffer():"json"===s.type?a.json():a.text();const u=yield c;if(l.signal.aborted)throw he();return{data:u,cacheControl:a.headers.get("Cache-Control"),expires:a.headers.get("Expires")}}))}(s,l);if(Nt(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:s,mustQueue:!0,targetMapId:pe},l)}var c;return function(e,s){return new Promise(((a,l)=>{var c;const u=new XMLHttpRequest;u.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(u.responseType="arraybuffer");for(const s in e.headers)u.setRequestHeader(s,e.headers[s]);"json"===e.type&&(u.responseType="text",(null===(c=e.headers)||void 0===c?void 0:c.Accept)||u.setRequestHeader("Accept","application/json")),u.withCredentials="include"===e.credentials,u.onerror=()=>{l(new Error(u.statusText))},u.onload=()=>{if(!s.signal.aborted)if((u.status>=200&&u.status<300||0===u.status)&&null!==u.response){let s=u.response;if("json"===e.type)try{s=JSON.parse(u.response)}catch(e){return void l(e)}a({data:s,cacheControl:u.getResponseHeader("Cache-Control"),expires:u.getResponseHeader("Expires")})}else{const s=new Blob([u.response],{type:u.getResponseHeader("Content-Type")});l(new ut(u.status,u.statusText,e.url,s))}},s.signal.addEventListener("abort",(()=>{u.abort(),l(he())})),u.send(e.body)}))}(s,l)};function _e(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const s=new URL(e),a=window.location;return s.protocol===a.protocol&&s.host===a.host}function ge(e,s,a){a[e]&&-1!==a[e].indexOf(s)||(a[e]=a[e]||[],a[e].push(s))}function ye(e,s,a){if(a&&a[e]){const l=a[e].indexOf(s);-1!==l&&a[e].splice(l,1)}}class yt{constructor(e,s={}){xt(this,s),this.type=e}}class mt extends yt{constructor(e,s={}){super("error",xt({error:e},s))}}class gt{on(e,s){return this._listeners=this._listeners||{},ge(e,s,this._listeners),{unsubscribe:()=>{this.off(e,s)}}}off(e,s){return ye(e,s,this._listeners),ye(e,s,this._oneTimeListeners),this}once(e,s){return s?(this._oneTimeListeners=this._oneTimeListeners||{},ge(e,s,this._oneTimeListeners),this):new Promise((s=>this.once(e,s)))}fire(e,s){"string"==typeof e&&(e=new yt(e,s||{}));const a=e.type;if(this.listens(a)){e.target=this;const s=this._listeners&&this._listeners[a]?this._listeners[a].slice():[];for(const a of s)a.call(this,e);const l=this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[];for(const s of l)ye(a,s,this._oneTimeListeners),s.call(this,e);const c=this._eventedParent;c&&(xt(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),c.fire(e))}else e instanceof mt&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,s){return this._eventedParent=e,this._eventedParentData=s,this}}var ve={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},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"},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},"*":{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:"*"},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","property-type":"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","property-type":"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","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"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","property-type":"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","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},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:"*",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"]},"property-type":"cross-faded"},"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"}}};const be=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function we(e,s){const a={};for(const s in e)"ref"!==s&&(a[s]=e[s]);return be.forEach((e=>{e in s&&(a[e]=s[e])})),a}function Se(e,s){if(Array.isArray(e)){if(!Array.isArray(s)||e.length!==s.length)return!1;for(let a=0;a`:"value"===e.itemType.kind?"array":`array<${s}>`}return e.kind}const zi=[ei,ri,si,oi,li,ci,yi,di,Ei(mi),xi,Mi,Ti,Ci,Ii];function ki(e,s){if("error"===s.kind)return null;if("array"===e.kind){if("array"===s.kind&&(0===s.N&&"value"===s.itemType.kind||!ki(e.itemType,s.itemType))&&("number"!=typeof e.N||e.N===s.N))return null}else{if(e.kind===s.kind)return null;if("value"===e.kind)for(const e of zi)if(!ki(e,s))return null}return`Expected ${Ai(e)} but found ${Ai(s)} instead.`}function Di(e,s){return s.some((s=>s.kind===e.kind))}function Ri(e,s){return s.some((s=>"null"===s?null===e:"array"===s?Array.isArray(e):"object"===s?e&&!Array.isArray(e)&&"object"==typeof e:s===typeof e))}function Li(e,s){return"array"===e.kind&&"array"===s.kind?e.itemType.kind===s.itemType.kind&&"number"==typeof e.N:e.kind===s.kind}const Bi=.96422,Fi=.82521,Oi=4/29,ji=6/29,Vi=3*ji*ji,Ui=ji*ji*ji,Ni=Math.PI/180,$i=180/Math.PI;function Zi(e){return(e%=360)<0&&(e+=360),e}function Gi([e,s,a,l]){let c,u;const p=Wi((.2225045*(e=qi(e))+.7168786*(s=qi(s))+.0606169*(a=qi(a)))/1);e===s&&s===a?c=u=p:(c=Wi((.4360747*e+.3850649*s+.1430804*a)/Bi),u=Wi((.0139322*e+.0971045*s+.7141733*a)/Fi));const f=116*p-16;return[f<0?0:f,500*(c-p),200*(p-u),l]}function qi(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Wi(e){return e>Ui?Math.pow(e,1/3):e/Vi+Oi}function Xi([e,s,a,l]){let c=(e+16)/116,u=isNaN(s)?c:c+s/500,p=isNaN(a)?c:c-a/200;return c=1*Yi(c),u=Bi*Yi(u),p=Fi*Yi(p),[Hi(3.1338561*u-1.6168667*c-.4906146*p),Hi(-.9787684*u+1.9161415*c+.033454*p),Hi(.0719453*u-.2289914*c+1.4052427*p),l]}function Hi(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function Yi(e){return e>ji?e*e*e:Vi*(e-Oi)}const Ki=Object.hasOwn||function(e,s){return Object.prototype.hasOwnProperty.call(e,s)};function Ji(e,s){return Ki(e,s)?e[s]:void 0}function Qi(e){return parseInt(e.padEnd(2,e),16)/255}function sr(e,s){return or(s?e/100:e,0,1)}function or(e,s,a){return Math.min(Math.max(s,e),a)}function lr(e){return!e.some(Number.isNaN)}const cr={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 hr(e,s,a){return e+a*(s-e)}function ur(e,s,a){return e.map(((e,l)=>hr(e,s[l],a)))}class Me{constructor(e,s,a,l=1,c=!0){this.r=e,this.g=s,this.b=a,this.a=l,c||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[e,s,a,l]))}static parse(e){if(e instanceof Me)return e;if("string"!=typeof e)return;const s=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const s=Ji(cr,e);if(s){const[e,a,l]=s;return[e/255,a/255,l/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const s=e.length<6?1:2;let a=1;return[Qi(e.slice(a,a+=s)),Qi(e.slice(a,a+=s)),Qi(e.slice(a,a+=s)),Qi(e.slice(a,a+s)||"ff")]}if(e.startsWith("rgb")){const s=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(s){const[e,a,l,c,u,p,f,_,g,y,x,v]=s,w=[c||" ",f||" ",y].join("");if(" "===w||" /"===w||",,"===w||",,,"===w){const e=[l,p,g].join(""),s="%%%"===e?100:""===e?255:0;if(s){const e=[or(+a/s,0,1),or(+u/s,0,1),or(+_/s,0,1),x?sr(+x,v):1];if(lr(e))return e}}return}}const a=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(a){const[e,s,l,c,u,p,f,_,g]=a,y=[l||" ",u||" ",f].join("");if(" "===y||" /"===y||",,"===y||",,,"===y){const e=[+s,or(+c,0,100),or(+p,0,100),_?sr(+_,g):1];if(lr(e))return function([e,s,a,l]){function c(l){const c=(l+e/30)%12,u=s*Math.min(a,1-a);return a-u*Math.max(-1,Math.min(c-3,9-c,1))}return e=Zi(e),s/=100,a/=100,[c(0),c(8),c(4),l]}(e)}}}(e);return s?new Me(...s,!1):void 0}get rgb(){const{r:e,g:s,b:a,a:l}=this,c=l||1/0;return this.overwriteGetter("rgb",[e/c,s/c,a/c,l])}get hcl(){return this.overwriteGetter("hcl",function(e){const[s,a,l,c]=Gi(e),u=Math.sqrt(a*a+l*l);return[Math.round(1e4*u)?Zi(Math.atan2(l,a)*$i):NaN,u,s,c]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Gi(this.rgb))}overwriteGetter(e,s){return Object.defineProperty(this,e,{value:s}),s}toString(){const[e,s,a,l]=this.rgb;return`rgba(${[e,s,a].map((e=>Math.round(255*e))).join(",")},${l})`}static interpolate(e,s,a,l="rgb"){switch(l){case"rgb":{const[l,c,u,p]=ur(e.rgb,s.rgb,a);return new Me(l,c,u,p,!1)}case"hcl":{const[l,c,u,p]=e.hcl,[f,_,g,y]=s.hcl;let x,v;if(isNaN(l)||isNaN(f))isNaN(l)?isNaN(f)?x=NaN:(x=f,1!==u&&0!==u||(v=_)):(x=l,1!==g&&0!==g||(v=c));else{let e=f-l;f>l&&e>180?e-=360:f180&&(e+=360),x=l+a*e}const[w,C,A,k]=function([e,s,a,l]){return e=isNaN(e)?0:e*Ni,Xi([a,Math.cos(e)*s,Math.sin(e)*s,l])}([x,null!=v?v:hr(c,_,a),hr(u,g,a),hr(p,y,a)]);return new Me(w,C,A,k,!1)}case"lab":{const[l,c,u,p]=Xi(ur(e.lab,s.lab,a));return new Me(l,c,u,p,!1)}}}}Me.black=new Me(0,0,0,1),Me.white=new Me(1,1,1,1),Me.transparent=new Me(0,0,0,0),Me.red=new Me(1,0,0,1);class Ie{constructor(e,s,a){this.sensitivity=e?s?"variant":"case":s?"accent":"base",this.locale=a,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,s){return this.collator.compare(e,s)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const dr=["bottom","center","top"];class Pe{constructor(e,s,a,l,c,u){this.text=e,this.image=s,this.scale=a,this.fontStack=l,this.textColor=c,this.verticalAlign=u}}class Ce{constructor(e){this.sections=e}static fromString(e){return new Ce([new Pe(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 Ce?e:Ce.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}}class Ee{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ee)return e;if("number"==typeof e)return new Ee([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const s of e)if("number"!=typeof s)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Ee(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,s,a){return new Ee(ur(e.values,s.values,a))}}class Be{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Be)return e;if("number"==typeof e)return new Be([e]);if(Array.isArray(e)){for(const s of e)if("number"!=typeof s)return;return new Be(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,s,a){return new Be(ur(e.values,s.values,a))}}class Ve{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ve)return e;if("string"==typeof e){const s=Me.parse(e);if(!s)return;return new Ve([s])}if(!Array.isArray(e))return;const s=[];for(const a of e){if("string"!=typeof a)return;const e=Me.parse(a);if(!e)return;s.push(e)}return new Ve(s)}toString(){return JSON.stringify(this.values)}static interpolate(e,s,a,l="rgb"){const c=[];if(e.values.length!=s.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${s.values.length}), cannot interpolate.`);for(let u=0;u=0&&e<=255&&"number"==typeof s&&s>=0&&s<=255&&"number"==typeof a&&a>=0&&a<=255?void 0===l||"number"==typeof l&&l>=0&&l<=1?null:`Invalid rgba value [${[e,s,a,l].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof l?[e,s,a,l]:[e,s,a]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function _r(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Oe||e instanceof Me||e instanceof Ie||e instanceof Ce||e instanceof Ee||e instanceof Be||e instanceof Ve||e instanceof $e||e instanceof Le)return!0;if(Array.isArray(e)){for(const s of e)if(!_r(s))return!1;return!0}if("object"==typeof e){for(const s in e)if(!_r(e[s]))return!1;return!0}return!1}function gr(e){if(null===e)return ei;if("string"==typeof e)return si;if("boolean"==typeof e)return oi;if("number"==typeof e)return ri;if(e instanceof Me)return li;if(e instanceof Oe)return ci;if(e instanceof Ie)return _i;if(e instanceof Ce)return yi;if(e instanceof Ee)return xi;if(e instanceof Be)return Mi;if(e instanceof Ve)return Ti;if(e instanceof $e)return Ii;if(e instanceof Le)return Ci;if(Array.isArray(e)){const s=e.length;let a;for(const s of e){const e=gr(s);if(a){if(a===e)continue;a=mi;break}a=e}return Ei(a||mi,s)}return di}function xr(e){const s=typeof e;return null===e?"":"string"===s||"number"===s||"boolean"===s?String(e):e instanceof Me||e instanceof Oe||e instanceof Ce||e instanceof Ee||e instanceof Be||e instanceof Ve||e instanceof $e||e instanceof Le?e.toString():JSON.stringify(e)}class Ne{constructor(e,s){this.type=e,this.value=s}static parse(e,s){if(2!==e.length)return s.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!_r(e[1]))return s.error("invalid value");const a=e[1];let l=gr(a);const c=s.expectedType;return"array"!==l.kind||0!==l.N||!c||"array"!==c.kind||"number"==typeof c.N&&0!==c.N||(l=c),new Ne(l,a)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const vr={string:si,number:ri,boolean:oi,object:di};class Ge{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");let a,l=1;const c=e[0];if("array"===c){let c,u;if(e.length>2){const a=e[1];if("string"!=typeof a||!(a in vr)||"object"===a)return s.error('The item type argument of "array" must be one of string, number, boolean',1);c=vr[a],l++}else c=mi;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return s.error('The length argument to "array" must be a positive integer literal',2);u=e[2],l++}a=Ei(c,u)}else{if(!vr[c])throw new Error(`Types doesn't contain name = ${c}`);a=vr[c]}const u=[];for(;le.outputDefined()))}}const br={"to-boolean":oi,"to-color":li,"to-number":ri,"to-string":si};class Ze{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");const a=e[0];if(!br[a])throw new Error(`Can't parse ${a} as it is not part of the known types`);if(("to-boolean"===a||"to-string"===a)&&2!==e.length)return s.error("Expected one argument.");const l=br[a],c=[];for(let a=1;a4?`Invalid rgba value ${JSON.stringify(s)}: expected an array containing either three or four numeric values.`:mr(s[0],s[1],s[2],s[3]),!a))return new Me(s[0]/255,s[1]/255,s[2]/255,s[3])}throw new Te(a||`Could not parse color from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"padding":{let s;for(const a of this.args){s=a.evaluate(e);const l=Ee.parse(s);if(l)return l}throw new Te(`Could not parse padding from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"numberArray":{let s;for(const a of this.args){s=a.evaluate(e);const l=Be.parse(s);if(l)return l}throw new Te(`Could not parse numberArray from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"colorArray":{let s;for(const a of this.args){s=a.evaluate(e);const l=Ve.parse(s);if(l)return l}throw new Te(`Could not parse colorArray from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"variableAnchorOffsetCollection":{let s;for(const a of this.args){s=a.evaluate(e);const l=$e.parse(s);if(l)return l}throw new Te(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"number":{let s=null;for(const a of this.args){if(s=a.evaluate(e),null===s)return 0;const l=Number(s);if(!isNaN(l))return l}throw new Te(`Could not convert ${JSON.stringify(s)} to number.`)}case"formatted":return Ce.fromString(xr(this.args[0].evaluate(e)));case"resolvedImage":return Le.fromString(xr(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return xr(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const wr=["Unknown","Point","LineString","Polygon"];class He{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?wr[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let s=this._parseColorCache.get(e);return s||(s=Me.parse(e),this._parseColorCache.set(e,s)),s}}class Ke{constructor(e,s,a=[],l,c=new Vt,u=[]){this.registry=e,this.path=a,this.key=a.map((e=>`[${e}]`)).join(""),this.scope=c,this.errors=u,this.expectedType=l,this._isConstant=s}parse(e,s,a,l,c={}){return s?this.concat(s,a,l)._parse(e,c):this._parse(e,c)}_parse(e,s){function a(e,s,a){return"assert"===a?new Ge(s,[e]):"coerce"===a?new Ze(s,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const l=e[0];if("string"!=typeof l)return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const c=this.registry[l];if(c){let l=c.parse(e,this);if(!l)return null;if(this.expectedType){const e=this.expectedType,c=l.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==c.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(c.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(c.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(c.kind)||"colorArray"===e.kind&&["value","string","array"].includes(c.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(c.kind))l=a(l,e,s.typeAnnotation||"coerce");else if(this.checkSubtype(e,c))return null}else l=a(l,e,s.typeAnnotation||"assert")}if(!(l instanceof Ne)&&"resolvedImage"!==l.type.kind&&this._isConstant(l)){const s=new He;try{l=new Ne(l.type,l.evaluate(s))}catch(e){return this.error(e.message),null}}return l}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,s,a){const l="number"==typeof e?this.path.concat(e):this.path,c=a?this.scope.concat(a):this.scope;return new Ke(this.registry,this._isConstant,l,s||null,c,this.errors)}error(e,...s){const a=`${this.key}${s.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Bt(a,e))}checkSubtype(e,s){const a=ki(e,s);return a&&this.error(a),a}}class Je{constructor(e,s){this.type=s.type,this.bindings=[].concat(e),this.result=s}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const s of this.bindings)e(s[1]);e(this.result)}static parse(e,s){if(e.length<4)return s.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const a=[];for(let l=1;l=a.length)throw new Te(`Array index out of bounds: ${s} > ${a.length-1}.`);if(s!==Math.floor(s))throw new Te(`Array index must be an integer, but found ${s} instead.`);return a[s]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class tr{constructor(e,s){this.type=oi,this.needle=e,this.haystack=s}static parse(e,s){if(3!==e.length)return s.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=s.parse(e[1],1,mi),l=s.parse(e[2],2,mi);return a&&l?Di(a.type,[oi,si,ri,ei,mi])?new tr(a,l):s.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(a.type)} instead`):null}evaluate(e){const s=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!a)return!1;if(!Ri(s,["boolean","string","number","null"]))throw new Te(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(gr(s))} instead.`);if(!Ri(a,["string","array"]))throw new Te(`Expected second argument to be of type array or string, but found ${Ai(gr(a))} instead.`);return a.indexOf(s)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class er{constructor(e,s,a){this.type=ri,this.needle=e,this.haystack=s,this.fromIndex=a}static parse(e,s){if(e.length<=2||e.length>=5)return s.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=s.parse(e[1],1,mi),l=s.parse(e[2],2,mi);if(!a||!l)return null;if(!Di(a.type,[oi,si,ri,ei,mi]))return s.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(a.type)} instead`);if(4===e.length){const c=s.parse(e[3],3,ri);return c?new er(a,l,c):null}return new er(a,l)}evaluate(e){const s=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!Ri(s,["boolean","string","number","null"]))throw new Te(`Expected first argument to be of type boolean, string, number or null, but found ${Ai(gr(s))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(e)),Ri(a,["string"])){const e=a.indexOf(s,l);return-1===e?-1:[...a.slice(0,e)].length}if(Ri(a,["array"]))return a.indexOf(s,l);throw new Te(`Expected second argument to be of type array or string, but found ${Ai(gr(a))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class rr{constructor(e,s,a,l,c,u){this.inputType=e,this.type=s,this.input=a,this.cases=l,this.outputs=c,this.otherwise=u}static parse(e,s){if(e.length<5)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return s.error("Expected an even number of arguments.");let a,l;s.expectedType&&"value"!==s.expectedType.kind&&(l=s.expectedType);const c={},u=[];for(let p=2;pNumber.MAX_SAFE_INTEGER)return g.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return g.error("Numeric branch labels must be integer values.");if(a){if(g.checkSubtype(a,gr(e)))return null}else a=gr(e);if(void 0!==c[String(e)])return g.error("Branch labels must be unique.");c[String(e)]=u.length}const y=s.parse(_,p,l);if(!y)return null;l=l||y.type,u.push(y)}const p=s.parse(e[1],1,mi);if(!p)return null;const f=s.parse(e[e.length-1],e.length-1,l);return f?"value"!==p.type.kind&&s.concat(1).checkSubtype(a,p.type)?null:new rr(a,l,p,c,u,f):null}evaluate(e){const s=this.input.evaluate(e);return(gr(s)===this.inputType&&this.outputs[this.cases[s]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class nr{constructor(e,s,a){this.type=e,this.branches=s,this.otherwise=a}static parse(e,s){if(e.length<4)return s.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return s.error("Expected an odd number of arguments.");let a;s.expectedType&&"value"!==s.expectedType.kind&&(a=s.expectedType);const l=[];for(let c=1;cs.outputDefined()))&&this.otherwise.outputDefined()}}class ir{constructor(e,s,a,l){this.type=e,this.input=s,this.beginIndex=a,this.endIndex=l}static parse(e,s){if(e.length<=2||e.length>=5)return s.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=s.parse(e[1],1,mi),l=s.parse(e[2],2,ri);if(!a||!l)return null;if(!Di(a.type,[Ei(mi),si,mi]))return s.error(`Expected first argument to be of type array or string, but found ${Ai(a.type)} instead`);if(4===e.length){const c=s.parse(e[3],3,ri);return c?new ir(a.type,a,l,c):null}return new ir(a.type,a,l)}evaluate(e){const s=this.input.evaluate(e),a=this.beginIndex.evaluate(e);let l;if(this.endIndex&&(l=this.endIndex.evaluate(e)),Ri(s,["string"]))return[...s].slice(a,l).join("");if(Ri(s,["array"]))return s.slice(a,l);throw new Te(`Expected first argument to be of type array or string, but found ${Ai(gr(s))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Tr(e,s){const a=e.length-1;let l,c,u=0,p=a,f=0;for(;u<=p;)if(f=Math.floor((u+p)/2),l=e[f],c=e[f+1],l<=s){if(f===a||ss))throw new Te("Input is not a number.");p=f-1}return 0}class ar{constructor(e,s,a){this.type=e,this.input=s,this.labels=[],this.outputs=[];for(const[e,s]of a)this.labels.push(e),this.outputs.push(s)}static parse(e,s){if(e.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return s.error("Expected an even number of arguments.");const a=s.parse(e[1],1,ri);if(!a)return null;const l=[];let c=null;s.expectedType&&"value"!==s.expectedType.kind&&(c=s.expectedType);for(let a=1;a=u)return s.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',f);const g=s.parse(p,_,c);if(!g)return null;c=c||g.type,l.push([u,g])}return new ar(c,a,l)}evaluate(e){const s=this.labels,a=this.outputs;if(1===s.length)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=s[0])return a[0].evaluate(e);const c=s.length;return l>=s[c-1]?a[c-1].evaluate(e):a[Tr(s,l)].evaluate(e)}eachChild(e){e(this.input);for(const s of this.outputs)e(s)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Sr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Cr,Ar,Dr=function(){if(Ar)return Cr;function s(s,a,l,c){(this||e).cx=3*s,(this||e).bx=3*(l-s)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*a,(this||e).by=3*(c-a)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=s,(this||e).p1y=a,(this||e).p2x=l,(this||e).p2y=c}return Ar=1,Cr=s,s.prototype={sampleCurveX:function(s){return(((this||e).ax*s+(this||e).bx)*s+(this||e).cx)*s},sampleCurveY:function(s){return(((this||e).ay*s+(this||e).by)*s+(this||e).cy)*s},sampleCurveDerivativeX:function(s){return(3*(this||e).ax*s+2*(this||e).bx)*s+(this||e).cx},solveCurveX:function(e,s){if(void 0===s&&(s=1e-6),e<0)return 0;if(e>1)return 1;for(var a=e,l=0;l<8;l++){var c=this.sampleCurveX(a)-e;if(Math.abs(c)c?p=a:f=a,a=.5*(f-p)+p;return a},solve:function(e,s){return this.sampleCurveY(this.solveCurveX(e,s))}},Cr}(),Rr=Sr(Dr);class pr{constructor(e,s,a,l,c){this.type=e,this.operator=s,this.interpolation=a,this.input=l,this.labels=[],this.outputs=[];for(const[e,s]of c)this.labels.push(e),this.outputs.push(s)}static interpolationFactor(e,s,a,l){let c=0;if("exponential"===e.name)c=Lr(s,e.base,a,l);else if("linear"===e.name)c=Lr(s,1,a,l);else if("cubic-bezier"===e.name){const u=e.controlPoints;c=new Rr(u[0],u[1],u[2],u[3]).solve(Lr(s,1,a,l))}return c}static parse(e,s){let[a,l,c,...u]=e;if(!Array.isArray(l)||0===l.length)return s.error("Expected an interpolation type expression.",1);if("linear"===l[0])l={name:"linear"};else if("exponential"===l[0]){const e=l[1];if("number"!=typeof e)return s.error("Exponential interpolation requires a numeric base.",1,1);l={name:"exponential",base:e}}else{if("cubic-bezier"!==l[0])return s.error(`Unknown interpolation type ${String(l[0])}`,1,0);{const e=l.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return s.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return s.error("Expected an even number of arguments.");if(c=s.parse(c,2,ri),!c)return null;const p=[];let f=null;"interpolate-hcl"!==a&&"interpolate-lab"!==a||s.expectedType==Ti?s.expectedType&&"value"!==s.expectedType.kind&&(f=s.expectedType):f=li;for(let e=0;e=a)return s.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',c);const g=s.parse(l,_,f);if(!g)return null;f=f||g.type,p.push([a,g])}return Li(f,ri)||Li(f,ci)||Li(f,li)||Li(f,xi)||Li(f,Mi)||Li(f,Ti)||Li(f,Ii)||Li(f,Ei(ri))?new pr(f,a,l,c,p):s.error(`Type ${Ai(f)} is not interpolatable.`)}evaluate(e){const s=this.labels,a=this.outputs;if(1===s.length)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=s[0])return a[0].evaluate(e);const c=s.length;if(l>=s[c-1])return a[c-1].evaluate(e);const u=Tr(s,l),p=pr.interpolationFactor(this.interpolation,l,s[u],s[u+1]),f=a[u].evaluate(e),_=a[u+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return hr(f,_,p);case"color":return Me.interpolate(f,_,p);case"padding":return Ee.interpolate(f,_,p);case"colorArray":return Ve.interpolate(f,_,p);case"numberArray":return Be.interpolate(f,_,p);case"variableAnchorOffsetCollection":return $e.interpolate(f,_,p);case"array":return ur(f,_,p);case"projectionDefinition":return Oe.interpolate(f,_,p)}case"interpolate-hcl":switch(this.type.kind){case"color":return Me.interpolate(f,_,p,"hcl");case"colorArray":return Ve.interpolate(f,_,p,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Me.interpolate(f,_,p,"lab");case"colorArray":return Ve.interpolate(f,_,p,"lab")}}}eachChild(e){e(this.input);for(const s of this.outputs)e(s)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Lr(e,s,a,l){const c=l-a,u=e-a;return 0===c?0:1===s?u/c:(Math.pow(s,u)-1)/(Math.pow(s,c)-1)}const Br={color:Me.interpolate,number:hr,padding:Ee.interpolate,numberArray:Be.interpolate,colorArray:Ve.interpolate,variableAnchorOffsetCollection:$e.interpolate,array:ur};class yr{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");let a=null;const l=s.expectedType;l&&"value"!==l.kind&&(a=l);const c=[];for(const l of e.slice(1)){const e=s.parse(l,1+c.length,a,void 0,{typeAnnotation:"omit"});if(!e)return null;a=a||e.type,c.push(e)}if(!a)throw new Error("No output type");const u=l&&c.some((e=>ki(l,e.type)));return new yr(u?mi:a,c)}evaluate(e){let s,a=null,l=0;for(const c of this.args)if(l++,a=c.evaluate(e),a&&a instanceof Le&&!a.available&&(s||(s=a.name),a=null,l===this.args.length&&(a=s)),null!==a)break;return a}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function Or(e,s){return"=="===e||"!="===e?"boolean"===s.kind||"string"===s.kind||"number"===s.kind||"null"===s.kind||"value"===s.kind:"string"===s.kind||"number"===s.kind||"value"===s.kind}function qr(e,s,a,l){return 0===l.compare(s,a)}function Jr(e,s,a){const l="=="!==e&&"!="!==e;return class i{constructor(e,s,a){this.type=oi,this.lhs=e,this.rhs=s,this.collator=a,this.hasUntypedArgument="value"===e.type.kind||"value"===s.type.kind}static parse(e,s){if(3!==e.length&&4!==e.length)return s.error("Expected two or three arguments.");const a=e[0];let c=s.parse(e[1],1,mi);if(!c)return null;if(!Or(a,c.type))return s.concat(1).error(`"${a}" comparisons are not supported for type '${Ai(c.type)}'.`);let u=s.parse(e[2],2,mi);if(!u)return null;if(!Or(a,u.type))return s.concat(2).error(`"${a}" comparisons are not supported for type '${Ai(u.type)}'.`);if(c.type.kind!==u.type.kind&&"value"!==c.type.kind&&"value"!==u.type.kind)return s.error(`Cannot compare types '${Ai(c.type)}' and '${Ai(u.type)}'.`);l&&("value"===c.type.kind&&"value"!==u.type.kind?c=new Ge(u.type,[c]):"value"!==c.type.kind&&"value"===u.type.kind&&(u=new Ge(c.type,[u])));let p=null;if(4===e.length){if("string"!==c.type.kind&&"string"!==u.type.kind&&"value"!==c.type.kind&&"value"!==u.type.kind)return s.error("Cannot use collator to compare non-string types.");if(p=s.parse(e[3],3,_i),!p)return null}return new i(c,u,p)}evaluate(c){const u=this.lhs.evaluate(c),p=this.rhs.evaluate(c);if(l&&this.hasUntypedArgument){const s=gr(u),a=gr(p);if(s.kind!==a.kind||"string"!==s.kind&&"number"!==s.kind)throw new Te(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${s.kind}, ${a.kind}) instead.`)}if(this.collator&&!l&&this.hasUntypedArgument){const e=gr(u),a=gr(p);if("string"!==e.kind||"string"!==a.kind)return s(c,u,p)}return this.collator?a(c,u,p,this.collator.evaluate(c)):s(c,u,p)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const Qr=Jr("==",(function(e,s,a){return s===a}),qr),tn=Jr("!=",(function(e,s,a){return s!==a}),(function(e,s,a,l){return!qr(0,s,a,l)})),en=Jr("<",(function(e,s,a){return s",(function(e,s,a){return s>a}),(function(e,s,a,l){return l.compare(s,a)>0})),nn=Jr("<=",(function(e,s,a){return s<=a}),(function(e,s,a,l){return l.compare(s,a)<=0})),sn=Jr(">=",(function(e,s,a){return s>=a}),(function(e,s,a,l){return l.compare(s,a)>=0}));class kr{constructor(e,s,a){this.type=_i,this.locale=a,this.caseSensitive=e,this.diacriticSensitive=s}static parse(e,s){if(2!==e.length)return s.error("Expected one argument.");const a=e[1];if("object"!=typeof a||Array.isArray(a))return s.error("Collator options argument must be an object.");const l=s.parse(void 0!==a["case-sensitive"]&&a["case-sensitive"],1,oi);if(!l)return null;const c=s.parse(void 0!==a["diacritic-sensitive"]&&a["diacritic-sensitive"],1,oi);if(!c)return null;let u=null;return a.locale&&(u=s.parse(a.locale,1,si),!u)?null:new kr(l,c,u)}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 Mr{constructor(e,s,a,l,c){this.type=si,this.number=e,this.locale=s,this.currency=a,this.minFractionDigits=l,this.maxFractionDigits=c}static parse(e,s){if(3!==e.length)return s.error("Expected two arguments.");const a=s.parse(e[1],1,ri);if(!a)return null;const l=e[2];if("object"!=typeof l||Array.isArray(l))return s.error("NumberFormat options argument must be an object.");let c=null;if(l.locale&&(c=s.parse(l.locale,1,si),!c))return null;let u=null;if(l.currency&&(u=s.parse(l.currency,1,si),!u))return null;let p=null;if(l["min-fraction-digits"]&&(p=s.parse(l["min-fraction-digits"],1,ri),!p))return null;let f=null;return l["max-fraction-digits"]&&(f=s.parse(l["max-fraction-digits"],1,ri),!f)?null:new Mr(a,c,u,p,f)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Ir{constructor(e){this.type=yi,this.sections=e}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");const a=e[1];if(!Array.isArray(a)&&"object"==typeof a)return s.error("First argument must be an image or text section.");const l=[];let c=!1;for(let a=1;a<=e.length-1;++a){const u=e[a];if(c&&"object"==typeof u&&!Array.isArray(u)){c=!1;let e=null;if(u["font-scale"]&&(e=s.parse(u["font-scale"],1,ri),!e))return null;let a=null;if(u["text-font"]&&(a=s.parse(u["text-font"],1,Ei(si)),!a))return null;let p=null;if(u["text-color"]&&(p=s.parse(u["text-color"],1,li),!p))return null;let f=null;if(u["vertical-align"]){if("string"==typeof u["vertical-align"]&&!dr.includes(u["vertical-align"]))return s.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${u["vertical-align"]}' instead.`);if(f=s.parse(u["vertical-align"],1,si),!f)return null}const _=l[l.length-1];_.scale=e,_.font=a,_.textColor=p,_.verticalAlign=f}else{const u=s.parse(e[a],1,mi);if(!u)return null;const p=u.type.kind;if("string"!==p&&"value"!==p&&"null"!==p&&"resolvedImage"!==p)return s.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");c=!0,l.push({content:u,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Ir(l)}evaluate(e){return new Ce(this.sections.map((s=>{const a=s.content.evaluate(e);return gr(a)===Ci?new Pe("",a,null,null,null,s.verticalAlign?s.verticalAlign.evaluate(e):null):new Pe(xr(a),null,s.scale?s.scale.evaluate(e):null,s.font?s.font.evaluate(e).join(","):null,s.textColor?s.textColor.evaluate(e):null,s.verticalAlign?s.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const s of this.sections)e(s.content),s.scale&&e(s.scale),s.font&&e(s.font),s.textColor&&e(s.textColor),s.verticalAlign&&e(s.verticalAlign)}outputDefined(){return!1}}class zr{constructor(e){this.type=Ci,this.input=e}static parse(e,s){if(2!==e.length)return s.error("Expected two arguments.");const a=s.parse(e[1],1,si);return a?new zr(a):s.error("No image name provided.")}evaluate(e){const s=this.input.evaluate(e),a=Le.fromString(s);return a&&e.availableImages&&(a.available=e.availableImages.indexOf(s)>-1),a}eachChild(e){e(this.input)}outputDefined(){return!1}}class Pr{constructor(e){this.type=ri,this.input=e}static parse(e,s){if(2!==e.length)return s.error(`Expected 1 argument, but found ${e.length-1} instead.`);const a=s.parse(e[1],1);return a?"array"!==a.type.kind&&"string"!==a.type.kind&&"value"!==a.type.kind?s.error(`Expected argument of type string or array, but found ${Ai(a.type)} instead.`):new Pr(a):null}evaluate(e){const s=this.input.evaluate(e);if("string"==typeof s)return[...s].length;if(Array.isArray(s))return s.length;throw new Te(`Expected value to be of type string or array, but found ${Ai(gr(s))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const on=8192;function ln(e,s){const a=(180+e[0])/360,l=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,c=Math.pow(2,s.z);return[Math.round(a*c*on),Math.round(l*c*on)]}function cn(e,s){const a=Math.pow(2,s.z);return[(c=(e[0]/on+s.x)/a,360*c-180),(l=(e[1]/on+s.y)/a,360/Math.PI*Math.atan(Math.exp((180-360*l)*Math.PI/180))-90)];var l,c}function hn(e,s){e[0]=Math.min(e[0],s[0]),e[1]=Math.min(e[1],s[1]),e[2]=Math.max(e[2],s[0]),e[3]=Math.max(e[3],s[1])}function un(e,s){return!(e[0]<=s[0]||e[2]>=s[2]||e[1]<=s[1]||e[3]>=s[3])}function dn(e,s,a){const l=e[0]-s[0],c=e[1]-s[1],u=e[0]-a[0],p=e[1]-a[1];return l*p-u*c==0&&l*u<=0&&c*p<=0}function pn(e,s,a,l){return 0!=(c=[l[0]-a[0],l[1]-a[1]])[0]*(u=[s[0]-e[0],s[1]-e[1]])[1]-c[1]*u[0]&&!(!xn(e,s,a,l)||!xn(a,l,e,s));var c,u}function fn(e,s,a){for(const l of a)for(let a=0;a(c=e)[1]!=(p=f[s+1])[1]>c[1]&&c[0]<(p[0]-u[0])*(c[1]-u[1])/(p[1]-u[1])+u[0]&&(l=!l)}var c,u,p;return l}function _n(e,s){for(const a of s)if(mn(e,a))return!0;return!1}function gn(e,s){for(const a of e)if(!mn(a,s))return!1;for(let a=0;a0&&f<0||p<0&&f>0}function vn(e,s,a){const l=[];for(let c=0;ca[2]){const s=.5*l;let c=e[0]-a[0]>s?-l:a[0]-e[0]>s?l:0;0===c&&(c=e[0]-a[2]>s?-l:a[2]-e[0]>s?l:0),e[0]+=c}hn(s,e)}function Tn(e,s,a,l){const c=Math.pow(2,l.z)*on,u=[l.x*on,l.y*on],p=[];for(const l of e)for(const e of l){const l=[e.x+u[0],e.y+u[1]];wn(l,s,a,c),p.push(l)}return p}function Sn(e,s,a,l){const c=Math.pow(2,l.z)*on,u=[l.x*on,l.y*on],p=[];for(const a of e){const e=[];for(const l of a){const a=[l.x+u[0],l.y+u[1]];hn(s,a),e.push(a)}p.push(e)}if(s[2]-s[0]<=c/2){(f=s)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const e of p)for(const l of e)wn(l,s,a,c)}var f;return p}class Yr{constructor(e,s){this.type=oi,this.geojson=e,this.geometries=s}static parse(e,s){if(2!==e.length)return s.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(_r(e[1])){const s=e[1];if("FeatureCollection"===s.type){const e=[];for(const a of s.features){const{type:s,coordinates:l}=a.geometry;"Polygon"===s&&e.push(l),"MultiPolygon"===s&&e.push(...l)}if(e.length)return new Yr(s,{type:"MultiPolygon",coordinates:e})}else if("Feature"===s.type){const e=s.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Yr(s,s.geometry)}else if("Polygon"===s.type||"MultiPolygon"===s.type)return new Yr(s,s)}return s.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,s){const a=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],c=e.canonicalID();if("Polygon"===s.type){const u=vn(s.coordinates,l,c),p=Tn(e.geometry(),a,l,c);if(!un(a,l))return!1;for(const e of p)if(!mn(e,u))return!1}if("MultiPolygon"===s.type){const u=bn(s.coordinates,l,c),p=Tn(e.geometry(),a,l,c);if(!un(a,l))return!1;for(const e of p)if(!_n(e,u))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,s){const a=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],c=e.canonicalID();if("Polygon"===s.type){const u=vn(s.coordinates,l,c),p=Sn(e.geometry(),a,l,c);if(!un(a,l))return!1;for(const e of p)if(!gn(e,u))return!1}if("MultiPolygon"===s.type){const u=bn(s.coordinates,l,c),p=Sn(e.geometry(),a,l,c);if(!un(a,l))return!1;for(const e of p)if(!yn(e,u))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Mn=class{constructor(e=[],s=(e,s)=>es?1:0){if(this.data=e,this.length=this.data.length,this.compare=s,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],s=this.data.pop();return--this.length>0&&(this.data[0]=s,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:s,compare:a}=this,l=s[e];for(;e>0;){const c=e-1>>1,u=s[c];if(a(l,u)>=0)break;s[e]=u,e=c}s[e]=l}_down(e){const{data:s,compare:a}=this,l=this.length>>1,c=s[e];for(;e=0)break;s[e]=s[l],e=l}s[e]=c}};function Cn(e,s,a=0,l=e.length-1,c=An){for(;l>a;){if(l-a>600){const u=l-a+1,p=s-a+1,f=Math.log(u),_=.5*Math.exp(2*f/3),g=.5*Math.sqrt(f*_*(u-_)/u)*(p-u/2<0?-1:1);Cn(e,s,Math.max(a,Math.floor(s-p*_/u+g)),Math.min(l,Math.floor(s+(u-p)*_/u+g)),c)}const u=e[s];let p=a,f=l;for(In(e,a,s),c(e[l],u)>0&&In(e,a,l);p0;)f--}0===c(e[a],u)?In(e,a,f):(f++,In(e,f,l)),f<=s&&(a=f+1),s<=f&&(l=f-1)}}function In(e,s,a){const l=e[s];e[s]=e[a],e[a]=l}function An(e,s){return es?1:0}function kn(e,s){if(e.length<=1)return[e];const a=[];let l,c;for(const s of e){const e=Rn(s);0!==e&&(s.area=Math.abs(e),void 0===c&&(c=e<0),c===e<0?(l&&a.push(l),l=[s]):l.push(s))}if(l&&a.push(l),s>1)for(let e=0;e1?(_=e[f+1][0],g=e[f+1][1]):v>0&&(_+=y/this.kx*v,g+=x/this.ky*v)),y=this.wrap(s[0]-_)*this.kx,x=(s[1]-g)*this.ky;const w=y*y+x*x;w180;)e-=360;return e}}function On(e,s){return s[0]-e[0]}function jn(e){return e[1]-e[0]+1}function Vn(e,s){return e[1]>=e[0]&&e[1]e[1])return[null,null];const a=jn(e);if(s){if(2===a)return[e,null];const s=Math.floor(a/2);return[[e[0],e[0]+s],[e[0]+s,e[1]]]}if(1===a)return[e,null];const l=Math.floor(a/2)-1;return[[e[0],e[0]+l],[e[0]+l+1,e[1]]]}function Nn(e,s){if(!Vn(s,e.length))return[1/0,1/0,-1/0,-1/0];const a=[1/0,1/0,-1/0,-1/0];for(let l=s[0];l<=s[1];++l)hn(a,e[l]);return a}function $n(e){const s=[1/0,1/0,-1/0,-1/0];for(const a of e)for(const e of a)hn(s,e);return s}function Zn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Gn(e,s,a){if(!Zn(e)||!Zn(s))return NaN;let l=0,c=0;return e[2]s[2]&&(l=e[0]-s[2]),e[1]>s[3]&&(c=e[1]-s[3]),e[3]=l)return l;if(un(c,u)){if(Jn(e,s))return 0}else if(Jn(s,e))return 0;let p=1/0;for(const l of e)for(let e=0,c=l.length,u=c-1;e0;){const c=p.pop();if(c[0]>=u)continue;const _=c[1],g=s?50:100;if(jn(_)<=g){if(!Vn(_,e.length))return NaN;if(s){const s=Kn(e,_,a,l);if(isNaN(s)||0===s)return s;u=Math.min(u,s)}else for(let s=_[0];s<=_[1];++s){const c=Yn(e[s],a,l);if(u=Math.min(u,c),0===u)return 0}}else{const a=Un(_,s);ts(p,u,l,e,f,a[0]),ts(p,u,l,e,f,a[1])}}return u}function ns(e,s,a,l,c,u=1/0){let p=Math.min(u,c.distance(e[0],a[0]));if(0===p)return p;const f=new Mn([[0,[0,e.length-1],[0,a.length-1]]],On);for(;f.length>0;){const u=f.pop();if(u[0]>=p)continue;const _=u[1],g=u[2],y=s?50:100,x=l?50:100;if(jn(_)<=y&&jn(g)<=x){if(!Vn(_,e.length)&&Vn(g,a.length))return NaN;let u;if(s&&l)u=Xn(e,_,a,g,c),p=Math.min(p,u);else if(s&&!l){const s=e.slice(_[0],_[1]+1);for(let e=g[0];e<=g[1];++e)if(u=qn(a[e],s,c),p=Math.min(p,u),0===p)return p}else if(!s&&l){const s=a.slice(g[0],g[1]+1);for(let a=_[0];a<=_[1];++a)if(u=qn(e[a],s,c),p=Math.min(p,u),0===p)return p}else u=Hn(e,_,a,g,c),p=Math.min(p,u)}else{const u=Un(_,s),y=Un(g,l);es(f,p,c,e,a,u[0],y[0]),es(f,p,c,e,a,u[0],y[1]),es(f,p,c,e,a,u[1],y[0]),es(f,p,c,e,a,u[1],y[1])}}return p}function ss(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 zn{constructor(e,s){this.type=ri,this.geojson=e,this.geometries=s}static parse(e,s){if(2!==e.length)return s.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(_r(e[1])){const s=e[1];if("FeatureCollection"===s.type)return new zn(s,s.features.map((e=>ss(e.geometry))).flat());if("Feature"===s.type)return new zn(s,ss(s.geometry));if("type"in s&&"coordinates"in s)return new zn(s,ss(s))}return s.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,s){const a=e.geometry(),l=a.flat().map((s=>cn([s.x,s.y],e.canonical)));if(0===a.length)return NaN;const c=new an(l[0][1]);let u=1/0;for(const e of s){switch(e.type){case"Point":u=Math.min(u,ns(l,!1,[e.coordinates],!1,c,u));break;case"LineString":u=Math.min(u,ns(l,!1,e.coordinates,!0,c,u));break;case"Polygon":u=Math.min(u,rs(l,!1,e.coordinates,c,u))}if(0===u)return u}return u}(e,this.geometries);if("LineString"===e.geometryType())return function(e,s){const a=e.geometry(),l=a.flat().map((s=>cn([s.x,s.y],e.canonical)));if(0===a.length)return NaN;const c=new an(l[0][1]);let u=1/0;for(const e of s){switch(e.type){case"Point":u=Math.min(u,ns(l,!0,[e.coordinates],!1,c,u));break;case"LineString":u=Math.min(u,ns(l,!0,e.coordinates,!0,c,u));break;case"Polygon":u=Math.min(u,rs(l,!0,e.coordinates,c,u))}if(0===u)return u}return u}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,s){const a=e.geometry();if(0===a.length||0===a[0].length)return NaN;const l=kn(a,0).map((s=>s.map((s=>s.map((s=>cn([s.x,s.y],e.canonical))))))),c=new an(l[0][0][0][1]);let u=1/0;for(const e of s)for(const s of l){switch(e.type){case"Point":u=Math.min(u,rs([e.coordinates],!1,s,c,u));break;case"LineString":u=Math.min(u,rs(e.coordinates,!0,s,c,u));break;case"Polygon":u=Math.min(u,Qn(s,e.coordinates,c,u))}if(0===u)return u}return u}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Pn{constructor(e){this.type=mi,this.key=e}static parse(e,s){if(2!==e.length)return s.error(`Expected 1 argument, but found ${e.length-1} instead.`);const a=e[1];return null==a?s.error("Global state property must be defined."):"string"!=typeof a?s.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Pn(a)}evaluate(e){var s;const a=null===(s=e.globals)||void 0===s?void 0:s.globalState;return a&&0!==Object.keys(a).length?Ji(a,this.key):null}eachChild(){}outputDefined(){return!1}}const os={"==":Qr,"!=":tn,">":rn,"<":en,">=":sn,"<=":nn,array:Ge,at:Qe,boolean:Ge,case:nr,coalesce:yr,collator:kr,format:Ir,image:zr,in:tr,"index-of":er,interpolate:pr,"interpolate-hcl":pr,"interpolate-lab":pr,length:Pr,let:Je,literal:Ne,match:rr,number:Ge,"number-format":Mr,object:Ge,slice:ir,step:ar,string:Ge,"to-boolean":Ze,"to-color":Ze,"to-number":Ze,"to-string":Ze,var:We,within:Yr,distance:zn,"global-state":Pn};class En{constructor(e,s,a,l){this.name=e,this.type=s,this._evaluate=a,this.args=l}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,s){const a=e[0],l=En.definitions[a];if(!l)return s.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0);const c=Array.isArray(l)?l[0]:l.type,u=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,p=u.filter((([s])=>!Array.isArray(s)||s.length===e.length-1));let f=null;for(const[l,u]of p){f=new Ke(s.registry,us,s.path,null,s.scope);const p=[];let _=!1;for(let s=1;s{return s=e,Array.isArray(s)?`(${s.map(Ai).join(", ")})`:`(${Ai(s.type)}...)`;var s})).join(" | "),l=[];for(let a=1;a{a=s?a&&us(e):a&&e instanceof Ne})),!!a&&ds(e)&&ms(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function ds(e){if(e instanceof En){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 Yr)return!1;if(e instanceof zn)return!1;let s=!0;return e.eachChild((e=>{s&&!ds(e)&&(s=!1)})),s}function fs(e){if(e instanceof En&&"feature-state"===e.name)return!1;let s=!0;return e.eachChild((e=>{s&&!fs(e)&&(s=!1)})),s}function ms(e,s){if(e instanceof En&&s.indexOf(e.name)>=0)return!1;let a=!0;return e.eachChild((e=>{a&&!ms(e,s)&&(a=!1)})),a}function _s(e){return{result:"success",value:e}}function gs(e){return{result:"error",value:e}}function ys(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function xs(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function vs(e){return!!e.expression&&e.expression.interpolated}function bs(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function ws(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&gr(e)===di}function Ss(e){return e}function Ms(e,s){const a=e.stops&&"object"==typeof e.stops[0][0],l=a||!(a||void 0!==e.property),c=e.type||(vs(s)?"exponential":"interval"),u=function(e){switch(e.type){case"color":return Me.parse;case"padding":return Ee.parse;case"numberArray":return Be.parse;case"colorArray":return Ve.parse;default:return null}}(s);if(u&&((e=qe({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],u(e[1])]))),e.default=u(e.default?e.default:s.default)),e.colorSpace&&"rgb"!==(p=e.colorSpace)&&"hcl"!==p&&"lab"!==p)throw new Error(`Unknown color space: "${e.colorSpace}"`);var p;const f=function(e){switch(e){case"exponential":return Zs;case"interval":return js;case"categorical":return ks;case"identity":return qs;default:throw new Error(`Unknown function type "${e}"`)}}(c);let _,g;if("categorical"===c){_=Object.create(null);for(const s of e.stops)_[s[0]]=s[1];g=typeof e.stops[0][0]}if(a){const a={},l=[];for(let s=0;se[0])),evaluate:({zoom:a},l)=>Zs({stops:c,base:e.base},s,a).evaluate(a,l)}}if(l){const a="exponential"===c?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:a,interpolationFactor:pr.interpolationFactor.bind(void 0,a),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:a})=>f(e,s,a,_,g)}}return{kind:"source",evaluate(a,l){const c=l&&l.properties?l.properties[e.property]:void 0;return void 0===c?As(e.default,s.default):f(e,s,c,_,g)}}}function As(e,s,a){return void 0!==e?e:void 0!==s?s:void 0!==a?a:void 0}function ks(e,s,a,l,c){return As(typeof a===c?l[a]:void 0,e.default,s.default)}function js(e,s,a){if("number"!==bs(a))return As(e.default,s.default);const l=e.stops.length;if(1===l)return e.stops[0][1];if(a<=e.stops[0][0])return e.stops[0][1];if(a>=e.stops[l-1][0])return e.stops[l-1][1];const c=Tr(e.stops.map((e=>e[0])),a);return e.stops[c][1]}function Zs(e,s,a){const l=void 0!==e.base?e.base:1;if("number"!==bs(a))return As(e.default,s.default);const c=e.stops.length;if(1===c)return e.stops[0][1];if(a<=e.stops[0][0])return e.stops[0][1];if(a>=e.stops[c-1][0])return e.stops[c-1][1];const u=Tr(e.stops.map((e=>e[0])),a),p=function(e,s,a,l){const c=l-a,u=e-a;return 0===c?0:1===s?u/c:(Math.pow(s,u)-1)/(Math.pow(s,c)-1)}(a,l,e.stops[u][0],e.stops[u+1][0]),f=e.stops[u][1],_=e.stops[u+1][1],g=Br[s.type]||Ss;return"function"==typeof f.evaluate?{evaluate(...s){const a=f.evaluate.apply(void 0,s),l=_.evaluate.apply(void 0,s);if(void 0!==a&&void 0!==l)return g(a,l,p,e.colorSpace)}}:g(f,_,p,e.colorSpace)}function qs(e,s,a){switch(s.type){case"color":a=Me.parse(a);break;case"formatted":a=Ce.fromString(a.toString());break;case"resolvedImage":a=Le.fromString(a.toString());break;case"padding":a=Ee.parse(a);break;case"colorArray":a=Ve.parse(a);break;case"numberArray":a=Be.parse(a);break;default:bs(a)===s.type||"enum"===s.type&&s.values[a]||(a=void 0)}return As(a,e.default,s.default)}En.register(os,{error:[{kind:"error"},[si],(e,[s])=>{throw new Te(s.evaluate(e))}],typeof:[si,[mi],(e,[s])=>Ai(gr(s.evaluate(e)))],"to-rgba":[Ei(ri,4),[li],(e,[s])=>{const[a,l,c,u]=s.evaluate(e).rgb;return[255*a,255*l,255*c,u]}],rgb:[li,[ri,ri,ri],as],rgba:[li,[ri,ri,ri,ri],as],has:{type:oi,overloads:[[[si],(e,[s])=>ls(s.evaluate(e),e.properties())],[[si,di],(e,[s,a])=>ls(s.evaluate(e),a.evaluate(e))]]},get:{type:mi,overloads:[[[si],(e,[s])=>cs(s.evaluate(e),e.properties())],[[si,di],(e,[s,a])=>cs(s.evaluate(e),a.evaluate(e))]]},"feature-state":[mi,[si],(e,[s])=>cs(s.evaluate(e),e.featureState||{})],properties:[di,[],e=>e.properties()],"geometry-type":[si,[],e=>e.geometryType()],id:[mi,[],e=>e.id()],zoom:[ri,[],e=>e.globals.zoom],"heatmap-density":[ri,[],e=>e.globals.heatmapDensity||0],elevation:[ri,[],e=>e.globals.elevation||0],"line-progress":[ri,[],e=>e.globals.lineProgress||0],accumulated:[mi,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ri,hs(ri),(e,s)=>{let a=0;for(const l of s)a+=l.evaluate(e);return a}],"*":[ri,hs(ri),(e,s)=>{let a=1;for(const l of s)a*=l.evaluate(e);return a}],"-":{type:ri,overloads:[[[ri,ri],(e,[s,a])=>s.evaluate(e)-a.evaluate(e)],[[ri],(e,[s])=>-s.evaluate(e)]]},"/":[ri,[ri,ri],(e,[s,a])=>s.evaluate(e)/a.evaluate(e)],"%":[ri,[ri,ri],(e,[s,a])=>s.evaluate(e)%a.evaluate(e)],ln2:[ri,[],()=>Math.LN2],pi:[ri,[],()=>Math.PI],e:[ri,[],()=>Math.E],"^":[ri,[ri,ri],(e,[s,a])=>Math.pow(s.evaluate(e),a.evaluate(e))],sqrt:[ri,[ri],(e,[s])=>Math.sqrt(s.evaluate(e))],log10:[ri,[ri],(e,[s])=>Math.log(s.evaluate(e))/Math.LN10],ln:[ri,[ri],(e,[s])=>Math.log(s.evaluate(e))],log2:[ri,[ri],(e,[s])=>Math.log(s.evaluate(e))/Math.LN2],sin:[ri,[ri],(e,[s])=>Math.sin(s.evaluate(e))],cos:[ri,[ri],(e,[s])=>Math.cos(s.evaluate(e))],tan:[ri,[ri],(e,[s])=>Math.tan(s.evaluate(e))],asin:[ri,[ri],(e,[s])=>Math.asin(s.evaluate(e))],acos:[ri,[ri],(e,[s])=>Math.acos(s.evaluate(e))],atan:[ri,[ri],(e,[s])=>Math.atan(s.evaluate(e))],min:[ri,hs(ri),(e,s)=>Math.min(...s.map((s=>s.evaluate(e))))],max:[ri,hs(ri),(e,s)=>Math.max(...s.map((s=>s.evaluate(e))))],abs:[ri,[ri],(e,[s])=>Math.abs(s.evaluate(e))],round:[ri,[ri],(e,[s])=>{const a=s.evaluate(e);return a<0?-Math.round(-a):Math.round(a)}],floor:[ri,[ri],(e,[s])=>Math.floor(s.evaluate(e))],ceil:[ri,[ri],(e,[s])=>Math.ceil(s.evaluate(e))],"filter-==":[oi,[si,mi],(e,[s,a])=>e.properties()[s.value]===a.value],"filter-id-==":[oi,[mi],(e,[s])=>e.id()===s.value],"filter-type-==":[oi,[si],(e,[s])=>e.geometryType()===s.value],"filter-<":[oi,[si,mi],(e,[s,a])=>{const l=e.properties()[s.value],c=a.value;return typeof l==typeof c&&l{const a=e.id(),l=s.value;return typeof a==typeof l&&a":[oi,[si,mi],(e,[s,a])=>{const l=e.properties()[s.value],c=a.value;return typeof l==typeof c&&l>c}],"filter-id->":[oi,[mi],(e,[s])=>{const a=e.id(),l=s.value;return typeof a==typeof l&&a>l}],"filter-<=":[oi,[si,mi],(e,[s,a])=>{const l=e.properties()[s.value],c=a.value;return typeof l==typeof c&&l<=c}],"filter-id-<=":[oi,[mi],(e,[s])=>{const a=e.id(),l=s.value;return typeof a==typeof l&&a<=l}],"filter->=":[oi,[si,mi],(e,[s,a])=>{const l=e.properties()[s.value],c=a.value;return typeof l==typeof c&&l>=c}],"filter-id->=":[oi,[mi],(e,[s])=>{const a=e.id(),l=s.value;return typeof a==typeof l&&a>=l}],"filter-has":[oi,[mi],(e,[s])=>s.value in e.properties()],"filter-has-id":[oi,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[oi,[Ei(si)],(e,[s])=>s.value.indexOf(e.geometryType())>=0],"filter-id-in":[oi,[Ei(mi)],(e,[s])=>s.value.indexOf(e.id())>=0],"filter-in-small":[oi,[si,Ei(mi)],(e,[s,a])=>a.value.indexOf(e.properties()[s.value])>=0],"filter-in-large":[oi,[si,Ei(mi)],(e,[s,a])=>function(e,s,a,l){for(;a<=l;){const c=a+l>>1;if(s[c]===e)return!0;s[c]>e?l=c-1:a=c+1}return!1}(e.properties()[s.value],a.value,0,a.value.length-1)],all:{type:oi,overloads:[[[oi,oi],(e,[s,a])=>s.evaluate(e)&&a.evaluate(e)],[hs(oi),(e,s)=>{for(const a of s)if(!a.evaluate(e))return!1;return!0}]]},any:{type:oi,overloads:[[[oi,oi],(e,[s,a])=>s.evaluate(e)||a.evaluate(e)],[hs(oi),(e,s)=>{for(const a of s)if(a.evaluate(e))return!0;return!1}]]},"!":[oi,[oi],(e,[s])=>!s.evaluate(e)],"is-supported-script":[oi,[si],(e,[s])=>{const a=e.globals&&e.globals.isSupportedScript;return!a||a(s.evaluate(e))}],upcase:[si,[si],(e,[s])=>s.evaluate(e).toUpperCase()],downcase:[si,[si],(e,[s])=>s.evaluate(e).toLowerCase()],concat:[si,hs(mi),(e,s)=>s.map((s=>xr(s.evaluate(e)))).join("")],"resolved-locale":[si,[_i],(e,[s])=>s.evaluate(e).resolvedLocale()]});class ti{constructor(e,s){this.expression=e,this._warningHistory={},this._evaluator=new He,this._defaultValue=s?function(e){if("color"===e.type&&ws(e.default))return new Me(0,0,0,0);switch(e.type){case"color":return Me.parse(e.default)||null;case"padding":return Ee.parse(e.default)||null;case"numberArray":return Be.parse(e.default)||null;case"colorArray":return Ve.parse(e.default)||null;case"variableAnchorOffsetCollection":return $e.parse(e.default)||null;case"projectionDefinition":return Oe.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(s):null,this._enumValues=s&&"enum"===s.type?s.values:null}evaluateWithoutErrorHandling(e,s,a,l,c,u){return this._evaluator.globals=e,this._evaluator.feature=s,this._evaluator.featureState=a,this._evaluator.canonical=l,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=u,this.expression.evaluate(this._evaluator)}evaluate(e,s,a,l,c,u){this._evaluator.globals=e,this._evaluator.feature=s||null,this._evaluator.featureState=a||null,this._evaluator.canonical=l,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=u||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 Te(`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 Ys(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in os}function to(e,s){const a=new Ke(os,us,[],s?function(e){const s={color:li,string:si,number:ri,enum:si,boolean:oi,formatted:yi,padding:xi,numberArray:Mi,colorArray:Ti,projectionDefinition:ci,resolvedImage:Ci,variableAnchorOffsetCollection:Ii};return"array"===e.type?Ei(s[e.value]||mi,e.length):s[e.type]}(s):void 0),l=a.parse(e,void 0,void 0,void 0,s&&"string"===s.type?{typeAnnotation:"coerce"}:void 0);return l?_s(new ti(l,s)):gs(a.errors)}class ni{constructor(e,s){this.kind=e,this._styleExpression=s,this.isStateDependent="constant"!==e&&!fs(s.expression),this.globalStateRefs=ro(s.expression)}evaluateWithoutErrorHandling(e,s,a,l,c,u){return this._styleExpression.evaluateWithoutErrorHandling(e,s,a,l,c,u)}evaluate(e,s,a,l,c,u){return this._styleExpression.evaluate(e,s,a,l,c,u)}}class ii{constructor(e,s,a,l){this.kind=e,this.zoomStops=a,this._styleExpression=s,this.isStateDependent="camera"!==e&&!fs(s.expression),this.globalStateRefs=ro(s.expression),this.interpolationType=l}evaluateWithoutErrorHandling(e,s,a,l,c,u){return this._styleExpression.evaluateWithoutErrorHandling(e,s,a,l,c,u)}evaluate(e,s,a,l,c,u){return this._styleExpression.evaluate(e,s,a,l,c,u)}interpolationFactor(e,s,a){return this.interpolationType?pr.interpolationFactor(this.interpolationType,e,s,a):0}}function eo(e,s){const a=to(e,s);if("error"===a.result)return a;const l=a.value.expression,c=ds(l);if(!c&&!ys(s))return gs([new Bt("","data expressions not supported")]);const u=ms(l,["zoom"]);if(!u&&!xs(s))return gs([new Bt("","zoom expressions not supported")]);const p=io(l);return p||u?p instanceof Bt?gs([p]):p instanceof pr&&!vs(s)?gs([new Bt("",'"interpolate" expressions cannot be used with this property')]):_s(p?new ii(c?"camera":"composite",a.value,p.labels,p instanceof pr?p.interpolation:void 0):new ni(c?"constant":"source",a.value)):gs([new Bt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class ai{constructor(e,s){this._parameters=e,this._specification=s,qe(this,Ms(this._parameters,this._specification))}static deserialize(e){return new ai(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function io(e){let s=null;if(e instanceof Je)s=io(e.result);else if(e instanceof yr){for(const a of e.args)if(s=io(a),s)break}else(e instanceof ar||e instanceof pr)&&e.input instanceof En&&"zoom"===e.input.name&&(s=e);return s instanceof Bt||e.eachChild((e=>{const a=io(e);a instanceof Bt?s=a:!s&&a?s=new Bt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):s&&a&&s!==a&&(s=new Bt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),s}function ro(e,s=new Set){return e instanceof Pn&&s.add(e.key),e.eachChild((e=>{ro(e,s)})),s}function ao(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const s of e.slice(1))if(!ao(s)&&"boolean"!=typeof s)return!1;return!0;default:return!0}}const qo={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Xo(e){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};ao(e)||(e=Jo(e));const s=to(e,qo);if("error"===s.result)throw new Error(s.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,a,l)=>s.value.evaluate(e,a,{},l),needGeometry:Ko(e),getGlobalStateRefs:()=>ro(s.value.expression)}}function Yo(e,s){return es?1:0}function Ko(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let s=1;s"===s||"<="===s||">="===s?Qo(e[1],e[2],s):"any"===s?(a=e.slice(1),["any"].concat(a.map(Jo))):"all"===s?["all"].concat(e.slice(1).map(Jo)):"none"===s?["all"].concat(e.slice(1).map(Jo).map(qa)):"in"===s?Za(e[1],e.slice(2)):"!in"===s?qa(Za(e[1],e.slice(2))):"has"===s?Ga(e[1]):"!has"!==s||qa(Ga(e[1]));var a}function Qo(e,s,a){switch(e){case"$type":return[`filter-type-${a}`,s];case"$id":return[`filter-id-${a}`,s];default:return[`filter-${a}`,e,s]}}function Za(e,s){if(0===s.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",s]];case"$id":return["filter-id-in",["literal",s]];default:return s.length>200&&!s.some((e=>typeof e!=typeof s[0]))?["filter-in-large",e,["literal",s.sort(Yo)]]:["filter-in-small",e,["literal",s]]}}function Ga(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function qa(e){return["!",e]}function Wa(e){const s=typeof e;if("number"===s||"boolean"===s||"string"===s||null==e)return JSON.stringify(e);if(Array.isArray(e)){let s="[";for(const a of e)s+=`${Wa(a)},`;return`${s}]`}const a=Object.keys(e).sort();let l="{";for(let s=0;sl.maximum?[new Ct(s,a,`${a} is greater than the maximum value ${l.maximum}`)]:[]}function ol(e){const s=e.valueSpec,a=Ja(e.value.type);let l,c,u,p={};const f="categorical"!==a&&void 0===e.value.property,_=!f,g="array"===bs(e.value.stops)&&"array"===bs(e.value.stops[0])&&"object"===bs(e.value.stops[0][0]),y=tl({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"===a)return[new Ct(e.key,e.value,'identity function may not have a "stops" property')];let s=[];const l=e.value;return s=s.concat(il({key:e.key,value:l,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:x})),"array"===bs(l)&&0===l.length&&s.push(new Ct(e.key,l,"array must have at least one stop")),s},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:s,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===a&&f&&y.push(new Ct(e.key,e.value,'missing required property "property"')),"identity"===a||e.value.stops||y.push(new Ct(e.key,e.value,'missing required property "stops"')),"exponential"===a&&e.valueSpec.expression&&!vs(e.valueSpec)&&y.push(new Ct(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(_&&!ys(e.valueSpec)?y.push(new Ct(e.key,e.value,"property functions not supported")):f&&!xs(e.valueSpec)&&y.push(new Ct(e.key,e.value,"zoom functions not supported"))),"categorical"!==a&&!g||void 0!==e.value.property||y.push(new Ct(e.key,e.value,'"property" property is required')),y;function x(e){let a=[];const l=e.value,f=e.key;if("array"!==bs(l))return[new Ct(f,l,`array expected, ${bs(l)} found`)];if(2!==l.length)return[new Ct(f,l,`array length 2 expected, length ${l.length} found`)];if(g){if("object"!==bs(l[0]))return[new Ct(f,l,`object expected, ${bs(l[0])} found`)];if(void 0===l[0].zoom)return[new Ct(f,l,"object stop key must have zoom")];if(void 0===l[0].value)return[new Ct(f,l,"object stop key must have value")];if(u&&u>Ja(l[0].zoom))return[new Ct(f,l[0].zoom,"stop zoom values must appear in ascending order")];Ja(l[0].zoom)!==u&&(u=Ja(l[0].zoom),c=void 0,p={}),a=a.concat(tl({key:`${f}[0]`,value:l[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:nl,value:v}}))}else a=a.concat(v({key:`${f}[0]`,value:l[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},l));return Ys(Qa(l[1]))?a.concat([new Ct(`${f}[1]`,l[1],"expressions are not allowed in function stops.")]):a.concat(e.validateSpec({key:`${f}[1]`,value:l[1],valueSpec:s,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function v(e,u){const f=bs(e.value),_=Ja(e.value),g=null!==e.value?e.value:u;if(l){if(f!==l)return[new Ct(e.key,g,`${f} stop domain type must match previous stop domain type ${l}`)]}else l=f;if("number"!==f&&"string"!==f&&"boolean"!==f)return[new Ct(e.key,g,"stop domain value must be a number, string, or boolean")];if("number"!==f&&"categorical"!==a){let l=`number expected, ${f} found`;return ys(s)&&void 0===a&&(l+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ct(e.key,g,l)]}return"categorical"!==a||"number"!==f||isFinite(_)&&Math.floor(_)===_?"categorical"!==a&&"number"===f&&void 0!==c&&_new Ct(`${e.key}${s.key}`,e.value,s.message)));const a=s.value.expression||s.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!a.outputDefined())return[new Ct(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&&!fs(a))return[new Ct(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!fs(a))return[new Ct(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!ms(a,["zoom","feature-state"]))return[new Ct(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!ds(a))return[new Ct(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function cl(e){const s=e.key,a=e.value,l=bs(a);return"string"!==l?[new Ct(s,a,`color expected, ${l} found`)]:Me.parse(String(a))?[]:[new Ct(s,a,`color expected, "${a}" found`)]}function ul(e){const s=e.key,a=e.value,l=e.valueSpec,c=[];return Array.isArray(l.values)?-1===l.values.indexOf(Ja(a))&&c.push(new Ct(s,a,`expected one of [${l.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(l.values).indexOf(Ja(a))&&c.push(new Ct(s,a,`expected one of [${Object.keys(l.values).join(", ")}], ${JSON.stringify(a)} found`)),c}function fl(e){return ao(Qa(e.value))?al(qe({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):ml(e)}function ml(e){const s=e.value,a=e.key;if("array"!==bs(s))return[new Ct(a,s,`array expected, ${bs(s)} found`)];const l=e.styleSpec;let c,u=[];if(s.length<1)return[new Ct(a,s,"filter array must have at least 1 element")];switch(u=u.concat(ul({key:`${a}[0]`,value:s[0],valueSpec:l.filter_operator,style:e.style,styleSpec:e.styleSpec})),Ja(s[0])){case"<":case"<=":case">":case">=":s.length>=2&&"$type"===Ja(s[1])&&u.push(new Ct(a,s,`"$type" cannot be use with operator "${s[0]}"`));case"==":case"!=":3!==s.length&&u.push(new Ct(a,s,`filter array for operator "${s[0]}" must have 3 elements`));case"in":case"!in":s.length>=2&&(c=bs(s[1]),"string"!==c&&u.push(new Ct(`${a}[1]`,s[1],`string expected, ${c} found`)));for(let p=2;p{e in a&&s.push(new Ct(l,a[e],`"${e}" is prohibited for ref layers`))})),c.layers.forEach((s=>{Ja(s.id)===f&&(e=s)})),e?e.ref?s.push(new Ct(l,a.ref,"ref cannot reference another ref layer")):p=Ja(e.type):s.push(new Ct(l,a.ref,`ref layer "${f}" not found`))}else if("background"!==p)if(a.source){const e=c.sources&&c.sources[a.source],u=e&&Ja(e.type);e?"vector"===u&&"raster"===p?s.push(new Ct(l,a.source,`layer "${a.id}" requires a raster source`)):"raster-dem"!==u&&"hillshade"===p||"raster-dem"!==u&&"color-relief"===p?s.push(new Ct(l,a.source,`layer "${a.id}" requires a raster-dem source`)):"raster"===u&&"raster"!==p?s.push(new Ct(l,a.source,`layer "${a.id}" requires a vector source`)):"vector"!==u||a["source-layer"]?"raster-dem"===u&&"hillshade"!==p&&"color-relief"!==p?s.push(new Ct(l,a.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==p||!a.paint||!a.paint["line-gradient"]||"geojson"===u&&e.lineMetrics||s.push(new Ct(l,a,`layer "${a.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):s.push(new Ct(l,a,`layer "${a.id}" must specify a "source-layer"`)):s.push(new Ct(l,a.source,`source "${a.source}" not found`))}else s.push(new Ct(l,a,'missing required property "source"'));return s=s.concat(tl({key:l,value:a,valueSpec:u.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${l}.type`,value:a.type,valueSpec:u.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:a,objectKey:"type"}),filter:fl,layout:e=>tl({layer:a,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>yl(qe({layerType:p},e))}}),paint:e=>tl({layer:a,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>gl(qe({layerType:p},e))}})}})),s}function vl(e){const s=e.value,a=e.key,l=bs(s);return"string"!==l?[new Ct(a,s,`string expected, ${l} found`)]:[]}const bl={promoteId:function({key:e,value:s}){if("string"===bs(s))return vl({key:e,value:s});{const a=[];for(const l in s)a.push(...vl({key:`${e}.${l}`,value:s[l]}));return a}}};function wl(e){const s=e.value,a=e.key,l=e.styleSpec,c=e.style,u=e.validateSpec;if(!s.type)return[new Ct(a,s,'"type" is required')];const p=Ja(s.type);let f;switch(p){case"vector":case"raster":return f=tl({key:a,value:s,valueSpec:l[`source_${p.replace("-","_")}`],style:e.style,styleSpec:l,objectElementValidators:bl,validateSpec:u}),f;case"raster-dem":return f=function(e){var s;const a=null!==(s=e.sourceName)&&void 0!==s?s:"",l=e.value,c=e.styleSpec,u=c.source_raster_dem,p=e.style;let f=[];const _=bs(l);if(void 0===l)return f;if("object"!==_)return f.push(new Ct("source_raster_dem",l,`object expected, ${_} found`)),f;const g="custom"===Ja(l.encoding),y=["redFactor","greenFactor","blueFactor","baseShift"],x=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const s in l)!g&&y.includes(s)?f.push(new Ct(s,l[s],`In "${a}": "${s}" is only valid when "encoding" is set to "custom". ${x} encoding found`)):u[s]?f=f.concat(e.validateSpec({key:s,value:l[s],valueSpec:u[s],validateSpec:e.validateSpec,style:p,styleSpec:c})):f.push(new Ct(s,l[s],`unknown property "${s}"`));return f}({sourceName:a,value:s,style:e.style,styleSpec:l,validateSpec:u}),f;case"geojson":if(f=tl({key:a,value:s,valueSpec:l.source_geojson,style:c,styleSpec:l,validateSpec:u,objectElementValidators:bl}),s.cluster)for(const e in s.clusterProperties){const[l,c]=s.clusterProperties[e],u="string"==typeof l?[l,["accumulated"],["get",e]]:l;f.push(...al({key:`${a}.${e}.map`,value:c,expressionContext:"cluster-map"})),f.push(...al({key:`${a}.${e}.reduce`,value:u,expressionContext:"cluster-reduce"}))}return f;case"video":return tl({key:a,value:s,valueSpec:l.source_video,style:c,validateSpec:u,styleSpec:l});case"image":return tl({key:a,value:s,valueSpec:l.source_image,style:c,validateSpec:u,styleSpec:l});case"canvas":return[new Ct(a,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ul({key:`${a}.type`,value:s.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Tl(e){const s=e.value,a=e.styleSpec,l=a.light,c=e.style;let u=[];const p=bs(s);if(void 0===s)return u;if("object"!==p)return u=u.concat([new Ct("light",s,`object expected, ${p} found`)]),u;for(const p in s){const f=p.match(/^(.*)-transition$/);u=u.concat(f&&l[f[1]]&&l[f[1]].transition?e.validateSpec({key:p,value:s[p],valueSpec:a.transition,validateSpec:e.validateSpec,style:c,styleSpec:a}):l[p]?e.validateSpec({key:p,value:s[p],valueSpec:l[p],validateSpec:e.validateSpec,style:c,styleSpec:a}):[new Ct(p,s[p],`unknown property "${p}"`)])}return u}function Pl(e){const s=e.value,a=e.styleSpec,l=a.sky,c=e.style,u=bs(s);if(void 0===s)return[];if("object"!==u)return[new Ct("sky",s,`object expected, ${u} found`)];let p=[];for(const u in s)p=p.concat(l[u]?e.validateSpec({key:u,value:s[u],valueSpec:l[u],style:c,styleSpec:a}):[new Ct(u,s[u],`unknown property "${u}"`)]);return p}function Sl(e){const s=e.value,a=e.styleSpec,l=a.terrain,c=e.style;let u=[];const p=bs(s);if(void 0===s)return u;if("object"!==p)return u=u.concat([new Ct("terrain",s,`object expected, ${p} found`)]),u;for(const p in s)u=u.concat(l[p]?e.validateSpec({key:p,value:s[p],valueSpec:l[p],validateSpec:e.validateSpec,style:c,styleSpec:a}):[new Ct(p,s[p],`unknown property "${p}"`)]);return u}function Ml(e){let s=[];const a=e.value,l=e.key;if(Array.isArray(a)){const c=[],u=[];for(const p in a)a[p].id&&c.includes(a[p].id)&&s.push(new Ct(l,a,`all the sprites' ids must be unique, but ${a[p].id} is duplicated`)),c.push(a[p].id),a[p].url&&u.includes(a[p].url)&&s.push(new Ct(l,a,`all the sprites' URLs must be unique, but ${a[p].url} is duplicated`)),u.push(a[p].url),s=s.concat(tl({key:`${l}[${p}]`,value:a[p],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return s}return vl({key:l,value:a})}function Cl(e){return s=e.value,Boolean(s)&&s.constructor===Object?[]:[new Ct(e.key,e.value,`object expected, ${bs(e.value)} found`)];var s}const Il={"*":()=>[],array:il,boolean:function(e){const s=e.value,a=e.key,l=bs(s);return"boolean"!==l?[new Ct(a,s,`boolean expected, ${l} found`)]:[]},number:nl,color:cl,constants:Ya,enum:ul,filter:fl,function:ol,layer:xl,object:tl,source:wl,light:Tl,sky:Pl,terrain:Sl,projection:function(e){const s=e.value,a=e.styleSpec,l=a.projection,c=e.style,u=bs(s);if(void 0===s)return[];if("object"!==u)return[new Ct("projection",s,`object expected, ${u} found`)];let p=[];for(const u in s)p=p.concat(l[u]?e.validateSpec({key:u,value:s[u],valueSpec:l[u],style:c,styleSpec:a}):[new Ct(u,s[u],`unknown property "${u}"`)]);return p},projectionDefinition:function(e){const s=e.key;let a=e.value;a=a instanceof String?a.valueOf():a;const l=bs(a);return"array"!==l||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(a)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(a)?["array","string"].includes(l)?[]:[new Ct(s,a,`projection expected, invalid type "${l}" found`)]:[new Ct(s,a,`projection expected, invalid array ${JSON.stringify(a)} found`)]},string:vl,formatted:function(e){return 0===vl(e).length?[]:al(e)},resolvedImage:function(e){return 0===vl(e).length?[]:al(e)},padding:function(e){const s=e.key,a=e.value;if("array"===bs(a)){if(a.length<1||a.length>4)return[new Ct(s,a,`padding requires 1 to 4 values; ${a.length} values found`)];const l={type:"number"};let c=[];for(let u=0;u[]}})),e.constants&&(a=a.concat(Ya({key:"constants",value:e.constants}))),Dl(a)}function kl(e){return function(s){return e({...s,validateSpec:El})}}function Dl(e){return[].concat(e).sort(((e,s)=>e.line-s.line))}function Rl(s){return function(...a){return Dl(s.apply(this||e,a))}}zl.source=Rl(kl(wl)),zl.sprite=Rl(kl(Ml)),zl.glyphs=Rl(kl(Al)),zl.light=Rl(kl(Tl)),zl.sky=Rl(kl(Pl)),zl.terrain=Rl(kl(Sl)),zl.state=Rl(kl(Cl)),zl.layer=Rl(kl(xl)),zl.filter=Rl(kl(fl)),zl.paintProperty=Rl(kl(gl)),zl.layoutProperty=Rl(kl(yl));const Ll=zl,Bl=Ll.light,Fl=Ll.sky,Ol=Ll.paintProperty,jl=Ll.layoutProperty;function Vl(e,s){let a=!1;if(s&&s.length)for(const l of s)e.fire(new mt(new Error(l.message))),a=!0;return a}class is{constructor(e,s,a){const l=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const c=new Int32Array(this.arrayBuffer);e=c[0],this.d=(s=c[1])+2*(a=c[2]);for(let e=0;e=g[_+0]&&l>=g[_+1])?(p[x]=!0,u.push(c[x])):p[x]=!1}}}}_forEachCell(e,s,a,l,c,u,p,f){const _=this._convertToCellCoord(e),g=this._convertToCellCoord(s),y=this._convertToCellCoord(a),x=this._convertToCellCoord(l);for(let v=_;v<=y;v++)for(let _=g;_<=x;_++){const g=this.d*_+v;if((!f||f(this._convertFromCellCoord(v),this._convertFromCellCoord(_),this._convertFromCellCoord(v+1),this._convertFromCellCoord(_+1)))&&c.call(this,e,s,a,l,g,u,p,f))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,s=3+this.cells.length+1+1;let a=0;for(let e=0;e=0)continue;const u=e[l];c[l]=Ul[a].shallow.indexOf(l)>=0?u:Xl(u,s)}e instanceof Error&&(c.message=e.message)}if(c.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(c.$name=a),c}function Hl(e){if(Wl(e))return e;if(Array.isArray(e))return e.map(Hl);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const s=Zl(e)||"Object";if(!Ul[s])throw new Error(`can't deserialize unregistered class ${s}`);const{klass:a}=Ul[s];if(!a)throw new Error(`can't deserialize unregistered class ${s}`);if(a.deserialize)return a.deserialize(e);const l=Object.create(a.prototype);for(const a of Object.keys(e)){if("$name"===a)continue;const c=e[a];l[a]=Ul[s].shallow.indexOf(a)>=0?c:Hl(c)}return l}class ps{constructor(){this.first=!0}update(e,s){const a=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=s):this.lastFloorZoome>=128&&e<=255,"Hangul Jamo":e=>e>=4352&&e<=4607,Khmer:e=>e>=6016&&e<=6143,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Kanbun:e=>e>=12688&&e<=12703,"CJK Strokes":e=>e>=12736&&e<=12783,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Hangul Syllables":e=>e>=44032&&e<=55215,"Private Use Area":e=>e>=57344&&e<=63743,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519};function Jl(e){for(const s of e)if(nc(s.charCodeAt(0)))return!0;return!1}function Ql(e){for(const s of e)if(!ic(s.charCodeAt(0)))return!1;return!0}function tc(e){const s=e.map((e=>{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}})).filter((e=>e));return new RegExp(s.join("|"),"u")}const ec=tc(["Arab","Dupl","Mong","Ougr","Syrc"]);function ic(e){return!ec.test(String.fromCodePoint(e))}const rc=tc(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function nc(e){return!(746!==e&&747!==e&&(e<4352||!(Kl["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||Kl["CJK Compatibility"](e)||Kl["CJK Strokes"](e)||!(!Kl["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Kl["Enclosed CJK Letters and Months"](e)||Kl["Ideographic Description Characters"](e)||Kl.Kanbun(e)||Kl.Katakana(e)&&12540!==e||!(!Kl["Halfwidth and Fullwidth Forms"](e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!Kl["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||Kl["Vertical Forms"](e)||Kl["Yijing Hexagram Symbols"](e)||/\p{sc=Cans}/u.test(String.fromCodePoint(e))||/\p{sc=Hang}/u.test(String.fromCodePoint(e))||rc.test(String.fromCodePoint(e)))))}function sc(e){return!(nc(e)||function(e){return!!(Kl["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||Kl["General Punctuation"](e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||Kl["Letterlike Symbols"](e)||Kl["Number Forms"](e)||Kl["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||Kl["Control Pictures"](e)&&9251!==e||Kl["Optical Character Recognition"](e)||Kl["Enclosed Alphanumerics"](e)||Kl["Geometric Shapes"](e)||Kl["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Kl["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Kl["CJK Symbols and Punctuation"](e)||Kl.Katakana(e)||Kl["Private Use Area"](e)||Kl["CJK Compatibility Forms"](e)||Kl["Small Form Variants"](e)||Kl["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}const oc=tc(["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 ac(e){return oc.test(String.fromCodePoint(e))}function lc(e,s){return!(!s&&ac(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||Kl.Khmer(e))}function cc(e){for(const s of e)if(ac(s.charCodeAt(0)))return!0;return!1}const hc=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(hc.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,s){return a(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const a=e.pluginURL,l=new Promise((e=>{this.loadScriptResolve=e}));s(a);const c=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([l,c]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:a};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${a}`)}))}};class Is{constructor(e,s){this.zoom=e,s?(this.now=s.now||0,this.fadeDuration=s.fadeDuration||0,this.zoomHistory=s.zoomHistory||new ps,this.transition=s.transition||{},this.globalState=s.globalState||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ps,this.transition={},this.globalState={})}isSupportedScript(e){return function(e,s){for(const a of e)if(!lc(a.charCodeAt(0),s))return!1;return!0}(e,"loaded"===hc.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,s=e-Math.floor(e),a=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:s+(1-s)*a}:{fromScale:.5,toScale:1,t:1-(1-a)*s}}}class zs{constructor(e,s){this.property=e,this.value=s,this.expression=function(e,s){if(ws(e))return new ai(e,s);if(Ys(e)){const a=eo(e,s);if("error"===a.result)throw new Error(a.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return a.value}{let a=e;return"color"===s.type&&"string"==typeof e?a=Me.parse(e):"padding"!==s.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==s.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==s.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===s.type&&Array.isArray(e)?a=$e.parse(e):"projectionDefinition"===s.type&&"string"==typeof e&&(a=Oe.parse(e)):a=Ve.parse(e):a=Be.parse(e):a=Ee.parse(e),{globalStateRefs:new Set,kind:"constant",evaluate:()=>a}}}(void 0===s?e.specification.default:s,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,s,a){return this.property.possiblyEvaluate(this,e,s,a)}}class Ps{constructor(e){this.property=e,this.value=new zs(e,void 0)}transitioned(e,s){return new Es(this.property,this.value,s,xt({},e.transition,this.transition),e.now)}untransitioned(){return new Es(this.property,this.value,null,{},0)}}class Cs{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return St(this._values[e].value.value)}setValue(e,s){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ps(this._values[e].property)),this._values[e].value=new zs(this._values[e].property,null===s?void 0:St(s))}getTransition(e){return St(this._values[e].transition)}setTransition(e,s){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ps(this._values[e].property)),this._values[e].transition=St(s)||void 0}serialize(){const e={};for(const s of Object.keys(this._values)){const a=this.getValue(s);void 0!==a&&(e[s]=a);const l=this.getTransition(s);void 0!==l&&(e[`${s}-transition`]=l)}return e}transitioned(e,s){const a=new Bs(this._properties);for(const l of Object.keys(this._values))a._values[l]=this._values[l].transitioned(e,s._values[l]);return a}untransitioned(){const e=new Bs(this._properties);for(const s of Object.keys(this._values))e._values[s]=this._values[s].untransitioned();return e}}class Es{constructor(e,s,a,l,c){this.property=e,this.value=s,this.begin=c+l.delay||0,this.end=this.begin+l.duration||0,e.specification.transition&&(l.delay||l.duration)&&(this.prior=a)}possiblyEvaluate(e,s,a){const l=e.now||0,c=this.value.possiblyEvaluate(e,s,a),u=this.prior;if(u){if(l>this.end)return this.prior=null,c;if(this.value.isDataDriven())return this.prior=null,c;if(ll.zoomHistory.lastIntegerZoom?{from:e,to:s}:{from:a,to:s}}interpolate(e){return e}}class Ds{constructor(e){this.specification=e}possiblyEvaluate(e,s,a,l){if(void 0!==e.value){if("constant"===e.expression.kind){const c=e.expression.evaluate(s,null,{},a,l);return this._calculate(c,c,c,s)}return this._calculate(e.expression.evaluate(new Is(Math.floor(s.zoom-1),s)),e.expression.evaluate(new Is(Math.floor(s.zoom),s)),e.expression.evaluate(new Is(Math.floor(s.zoom+1),s)),s)}}_calculate(e,s,a,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:s}:{from:a,to:s}}interpolate(e){return e}}class Rs{constructor(e){this.specification=e}possiblyEvaluate(e,s,a,l){return!!e.expression.evaluate(s,null,{},a,l)}interpolate(){return!1}}class Us{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const s in e){const a=e[s];a.specification.overridable&&this.overridableProperties.push(s);const l=this.defaultPropertyValues[s]=new zs(a,void 0),c=this.defaultTransitionablePropertyValues[s]=new Ps(a);this.defaultTransitioningPropertyValues[s]=c.untransitioned(),this.defaultPossiblyEvaluatedValues[s]=l.possiblyEvaluate({})}}}Nl("DataDrivenProperty",Ls),Nl("DataConstantProperty",$s),Nl("CrossFadedDataDrivenProperty",Os),Nl("CrossFadedProperty",Ds),Nl("ColorRampProperty",Rs);const uc="-transition";class Ns extends gt{constructor(e,s){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},"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=Xo(e.filter)),s.layout&&(this._unevaluatedLayout=new Vs(s.layout)),s.paint)){this._transitionablePaint=new Cs(s.paint);for(const s in e.paint)this.setPaintProperty(s,e.paint[s],{validate:!1});for(const s in e.layout)this.setLayoutProperty(s,e.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Fs(s.paint)}}setFilter(e){this.filter=e,this._featureFilter=Xo(e)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;if(this._unevaluatedLayout)for(const s in this._unevaluatedLayout._values){const a=this._unevaluatedLayout._values[s];for(const s of a.getGlobalStateRefs())e.add(s)}for(const s of this._featureFilter.getGlobalStateRefs())e.add(s);return e}setLayoutProperty(e,s,a={}){null!=s&&this._validate(jl,`layers.${this.id}.layout.${e}`,e,s,a)||("visibility"!==e?this._unevaluatedLayout.setValue(e,s):this.visibility=s)}getPaintProperty(e){return e.endsWith(uc)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,s,a={}){if(null!=s&&this._validate(Ol,`layers.${this.id}.paint.${e}`,e,s,a))return!1;if(e.endsWith(uc))return this._transitionablePaint.setTransition(e.slice(0,-11),s||void 0),!1;{const a=this._transitionablePaint._values[e],l="cross-faded-data-driven"===a.property.specification["property-type"],c=a.value.isDataDriven(),u=a.value;this._transitionablePaint.setValue(e,s),this._handleSpecialPaintPropertyUpdate(e);const p=this._transitionablePaint._values[e].value;return p.isDataDriven()||c||l||this._handleOverridablePaintPropertyUpdate(e,u,p)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,s,a){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,s){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,s)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,s)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),Pt(e,((e,s)=>!(void 0===e||"layout"===s&&!Object.keys(e).length||"paint"===s&&!Object.keys(e).length)))}_validate(e,s,a,l,c={}){return(!c||!1!==c.validate)&&Vl(this,e.call(Ll,{key:s,layerType:this.type,objectKey:a,value:l,styleSpec:ve,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const s=this.paint.get(e);if(s instanceof Ts&&ys(s.property.specification)&&("source"===s.value.kind||"composite"===s.value.kind)&&s.value.isStateDependent)return!0}return!1}}const pc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Gs{constructor(e,s){this._structArray=e,this._pos1=s*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Xs{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,s){return e._trim(),s&&(e.isTransferred=!0,s.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const s=Object.create(this.prototype);return s.arrayBuffer=e.arrayBuffer,s.length=e.length,s.capacity=e.arrayBuffer.byteLength/s.bytesPerElement,s._refreshViews(),s}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const s=this.uint8;this._refreshViews(),s&&this.uint8.set(s)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function _c(e,s=1){let a=0,l=0;return{members:e.map((e=>{const c=pc[e.type].BYTES_PER_ELEMENT,u=a=yc(a,Math.max(s,c)),p=e.components||1;return l=Math.max(l,c),a+=c*p,{name:e.name,type:e.type,components:p,offset:u}})),size:yc(a,Math.max(l,s)),alignment:s}}function yc(e,s){return Math.ceil(e/s)*s}class Hs extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,s)}emplace(e,s,a){const l=2*e;return this.int16[l+0]=s,this.int16[l+1]=a,e}}Hs.prototype.bytesPerElement=4,Nl("StructArrayLayout2i4",Hs);class Ks extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,s,a)}emplace(e,s,a,l){const c=3*e;return this.int16[c+0]=s,this.int16[c+1]=a,this.int16[c+2]=l,e}}Ks.prototype.bytesPerElement=6,Nl("StructArrayLayout3i6",Ks);class Js extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,a,l)}emplace(e,s,a,l,c){const u=4*e;return this.int16[u+0]=s,this.int16[u+1]=a,this.int16[u+2]=l,this.int16[u+3]=c,e}}Js.prototype.bytesPerElement=8,Nl("StructArrayLayout4i8",Js);class Ws extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,s,a,l,c,u)}emplace(e,s,a,l,c,u,p){const f=6*e;return this.int16[f+0]=s,this.int16[f+1]=a,this.int16[f+2]=l,this.int16[f+3]=c,this.int16[f+4]=u,this.int16[f+5]=p,e}}Ws.prototype.bytesPerElement=12,Nl("StructArrayLayout2i4i12",Ws);class Qs extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,s,a,l,c,u)}emplace(e,s,a,l,c,u,p){const f=4*e,_=8*e;return this.int16[f+0]=s,this.int16[f+1]=a,this.uint8[_+4]=l,this.uint8[_+5]=c,this.uint8[_+6]=u,this.uint8[_+7]=p,e}}Qs.prototype.bytesPerElement=8,Nl("StructArrayLayout2i4ub8",Qs);class ta extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,s)}emplace(e,s,a){const l=2*e;return this.float32[l+0]=s,this.float32[l+1]=a,e}}ta.prototype.bytesPerElement=8,Nl("StructArrayLayout2f8",ta);class ea extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u,p,f,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,e,s,a,l,c,u,p,f,_,g)}emplace(e,s,a,l,c,u,p,f,_,g,y){const x=10*e;return this.uint16[x+0]=s,this.uint16[x+1]=a,this.uint16[x+2]=l,this.uint16[x+3]=c,this.uint16[x+4]=u,this.uint16[x+5]=p,this.uint16[x+6]=f,this.uint16[x+7]=_,this.uint16[x+8]=g,this.uint16[x+9]=y,e}}ea.prototype.bytesPerElement=20,Nl("StructArrayLayout10ui20",ea);class ra extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u,p,f,_,g,y,x){const v=this.length;return this.resize(v+1),this.emplace(v,e,s,a,l,c,u,p,f,_,g,y,x)}emplace(e,s,a,l,c,u,p,f,_,g,y,x,v){const w=12*e;return this.int16[w+0]=s,this.int16[w+1]=a,this.int16[w+2]=l,this.int16[w+3]=c,this.uint16[w+4]=u,this.uint16[w+5]=p,this.uint16[w+6]=f,this.uint16[w+7]=_,this.int16[w+8]=g,this.int16[w+9]=y,this.int16[w+10]=x,this.int16[w+11]=v,e}}ra.prototype.bytesPerElement=24,Nl("StructArrayLayout4i4ui4i24",ra);class na extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,s,a)}emplace(e,s,a,l){const c=3*e;return this.float32[c+0]=s,this.float32[c+1]=a,this.float32[c+2]=l,e}}na.prototype.bytesPerElement=12,Nl("StructArrayLayout3f12",na);class ia extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.uint32[1*e+0]=s,e}}ia.prototype.bytesPerElement=4,Nl("StructArrayLayout1ul4",ia);class sa extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u,p,f,_){const g=this.length;return this.resize(g+1),this.emplace(g,e,s,a,l,c,u,p,f,_)}emplace(e,s,a,l,c,u,p,f,_,g){const y=10*e,x=5*e;return this.int16[y+0]=s,this.int16[y+1]=a,this.int16[y+2]=l,this.int16[y+3]=c,this.int16[y+4]=u,this.int16[y+5]=p,this.uint32[x+3]=f,this.uint16[y+8]=_,this.uint16[y+9]=g,e}}sa.prototype.bytesPerElement=20,Nl("StructArrayLayout6i1ul2ui20",sa);class aa extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,s,a,l,c,u)}emplace(e,s,a,l,c,u,p){const f=6*e;return this.int16[f+0]=s,this.int16[f+1]=a,this.int16[f+2]=l,this.int16[f+3]=c,this.int16[f+4]=u,this.int16[f+5]=p,e}}aa.prototype.bytesPerElement=12,Nl("StructArrayLayout2i2i2i12",aa);class oa extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,s,a,l,c)}emplace(e,s,a,l,c,u){const p=4*e,f=8*e;return this.float32[p+0]=s,this.float32[p+1]=a,this.float32[p+2]=l,this.int16[f+6]=c,this.int16[f+7]=u,e}}oa.prototype.bytesPerElement=16,Nl("StructArrayLayout2f1f2i16",oa);class la extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,s,a,l,c,u)}emplace(e,s,a,l,c,u,p){const f=16*e,_=4*e,g=8*e;return this.uint8[f+0]=s,this.uint8[f+1]=a,this.float32[_+1]=l,this.float32[_+2]=c,this.int16[g+6]=u,this.int16[g+7]=p,e}}la.prototype.bytesPerElement=16,Nl("StructArrayLayout2ub2f2i16",la);class ua extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,s,a)}emplace(e,s,a,l){const c=3*e;return this.uint16[c+0]=s,this.uint16[c+1]=a,this.uint16[c+2]=l,e}}ua.prototype.bytesPerElement=6,Nl("StructArrayLayout3ui6",ua);class ca extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u,p,f,_,g,y,x,v,w,C,A,k){const D=this.length;return this.resize(D+1),this.emplace(D,e,s,a,l,c,u,p,f,_,g,y,x,v,w,C,A,k)}emplace(e,s,a,l,c,u,p,f,_,g,y,x,v,w,C,A,k,D){const R=24*e,L=12*e,B=48*e;return this.int16[R+0]=s,this.int16[R+1]=a,this.uint16[R+2]=l,this.uint16[R+3]=c,this.uint32[L+2]=u,this.uint32[L+3]=p,this.uint32[L+4]=f,this.uint16[R+10]=_,this.uint16[R+11]=g,this.uint16[R+12]=y,this.float32[L+7]=x,this.float32[L+8]=v,this.uint8[B+36]=w,this.uint8[B+37]=C,this.uint8[B+38]=A,this.uint32[L+10]=k,this.int16[R+22]=D,e}}ca.prototype.bytesPerElement=48,Nl("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ca);class ha extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u,p,f,_,g,y,x,v,w,C,A,k,D,R,L,B,O,j,U,N,Z,J,Q){const et=this.length;return this.resize(et+1),this.emplace(et,e,s,a,l,c,u,p,f,_,g,y,x,v,w,C,A,k,D,R,L,B,O,j,U,N,Z,J,Q)}emplace(e,s,a,l,c,u,p,f,_,g,y,x,v,w,C,A,k,D,R,L,B,O,j,U,N,Z,J,Q,et){const it=32*e,rt=16*e;return this.int16[it+0]=s,this.int16[it+1]=a,this.int16[it+2]=l,this.int16[it+3]=c,this.int16[it+4]=u,this.int16[it+5]=p,this.int16[it+6]=f,this.int16[it+7]=_,this.uint16[it+8]=g,this.uint16[it+9]=y,this.uint16[it+10]=x,this.uint16[it+11]=v,this.uint16[it+12]=w,this.uint16[it+13]=C,this.uint16[it+14]=A,this.uint16[it+15]=k,this.uint16[it+16]=D,this.uint16[it+17]=R,this.uint16[it+18]=L,this.uint16[it+19]=B,this.uint16[it+20]=O,this.uint16[it+21]=j,this.uint16[it+22]=U,this.uint32[rt+12]=N,this.float32[rt+13]=Z,this.float32[rt+14]=J,this.uint16[it+30]=Q,this.uint16[it+31]=et,e}}ha.prototype.bytesPerElement=64,Nl("StructArrayLayout8i15ui1ul2f2ui64",ha);class pa extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.float32[1*e+0]=s,e}}pa.prototype.bytesPerElement=4,Nl("StructArrayLayout1f4",pa);class fa extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,s,a)}emplace(e,s,a,l){const c=3*e;return this.uint16[6*e+0]=s,this.float32[c+1]=a,this.float32[c+2]=l,e}}fa.prototype.bytesPerElement=12,Nl("StructArrayLayout1ui2f12",fa);class da extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,s,a)}emplace(e,s,a,l){const c=4*e;return this.uint32[2*e+0]=s,this.uint16[c+2]=a,this.uint16[c+3]=l,e}}da.prototype.bytesPerElement=8,Nl("StructArrayLayout1ul2ui8",da);class ya extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,s)}emplace(e,s,a){const l=2*e;return this.uint16[l+0]=s,this.uint16[l+1]=a,e}}ya.prototype.bytesPerElement=4,Nl("StructArrayLayout2ui4",ya);class ma extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.uint16[1*e+0]=s,e}}ma.prototype.bytesPerElement=2,Nl("StructArrayLayout1ui2",ma);class ga extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,a,l)}emplace(e,s,a,l,c){const u=4*e;return this.float32[u+0]=s,this.float32[u+1]=a,this.float32[u+2]=l,this.float32[u+3]=c,e}}ga.prototype.bytesPerElement=16,Nl("StructArrayLayout4f16",ga);class xa extends Gs{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 l(this.anchorPointX,this.anchorPointY)}}xa.prototype.size=20;class va extends sa{get(e){return new xa(this,e)}}Nl("CollisionBoxArray",va);class ba extends Gs{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]}}ba.prototype.size=48;class wa extends ca{get(e){return new ba(this,e)}}Nl("PlacedSymbolArray",wa);class _a extends Gs{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]}}_a.prototype.size=64;class Sa extends ha{get(e){return new _a(this,e)}}Nl("SymbolInstanceArray",Sa);class Aa extends pa{getoffsetX(e){return this.float32[1*e+0]}}Nl("GlyphOffsetArray",Aa);class ka extends Ks{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Nl("SymbolLineVertexArray",ka);class Ma extends Gs{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]}}Ma.prototype.size=12;class Ia extends fa{get(e){return new Ma(this,e)}}Nl("TextAnchorOffsetArray",Ia);class za extends Gs{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]}}za.prototype.size=8;class Pa extends da{get(e){return new za(this,e)}}Nl("FeatureIndexArray",Pa);class Ca extends Hs{}class Ea extends Hs{}class Ba extends Hs{}class Va extends Ws{}class Ta extends Qs{}class Fa extends ta{}class $a extends ea{}class La extends ra{}class Oa extends na{}class Da extends ia{}class Ra extends aa{}class Ua extends la{}class ja extends ua{}class Na extends ya{}const xc=_c([{name:"a_pos",components:2,type:"Int16"}],4),{members:vc}=xc;class Xa{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,s,a,l){const c=this.segments[this.segments.length-1];return e>Xa.MAX_VERTEX_ARRAY_LENGTH&&kt(`Max vertices per segment is ${Xa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Xa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!c||c.vertexLength+e>Xa.MAX_VERTEX_ARRAY_LENGTH||c.sortKey!==l?this.createNewSegment(s,a,l):c}createNewSegment(e,s,a){const l={vertexOffset:e.length,primitiveOffset:s.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==a&&(l.sortKey=a),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(l),l}getOrCreateLatestSegment(e,s,a){return this.prepareSegment(0,e,s,a)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const s in e.vaos)e.vaos[s].destroy()}static simpleSegment(e,s,a,l){return new Xa([{vertexOffset:e,primitiveOffset:s,vertexLength:a,primitiveLength:l,vaos:{},sortKey:0}])}}function bc(e,s){return 256*(e=ht(Math.floor(e),0,255))+ht(Math.floor(s),0,255)}Xa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Nl("SegmentVector",Xa);const wc=_c([{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"}]);var Tc,Pc,Sc,Mc={exports:{}},Cc={exports:{}},Ic={exports:{}},Ec=function(){if(Sc)return Mc.exports;Sc=1;var e=(Tc||(Tc=1,Cc.exports=function(e,s){var a,l,c,u,p,f,_,g;for(l=e.length-(a=3&e.length),c=s,p=3432918353,f=461845907,g=0;g>>16)*p&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295)<<13|c>>>19))+((5*(c>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(_=0,a){case 3:_^=(255&e.charCodeAt(g+2))<<16;case 2:_^=(255&e.charCodeAt(g+1))<<8;case 1:c^=_=(65535&(_=(_=(65535&(_^=255&e.charCodeAt(g)))*p+(((_>>>16)*p&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295}return c^=e.length,c=2246822507*(65535&(c^=c>>>16))+((2246822507*(c>>>16)&65535)<<16)&4294967295,c=3266489909*(65535&(c^=c>>>13))+((3266489909*(c>>>16)&65535)<<16)&4294967295,(c^=c>>>16)>>>0}),Cc.exports),s=(Pc||(Pc=1,Ic.exports=function(e,s){for(var a,l=e.length,c=s^l,u=0;l>=4;)a=1540483477*(65535&(a=255&e.charCodeAt(u)|(255&e.charCodeAt(++u))<<8|(255&e.charCodeAt(++u))<<16|(255&e.charCodeAt(++u))<<24))+((1540483477*(a>>>16)&65535)<<16),c=1540483477*(65535&c)+((1540483477*(c>>>16)&65535)<<16)^(a=1540483477*(65535&(a^=a>>>24))+((1540483477*(a>>>16)&65535)<<16)),l-=4,++u;switch(l){case 3:c^=(255&e.charCodeAt(u+2))<<16;case 2:c^=(255&e.charCodeAt(u+1))<<8;case 1:c=1540483477*(65535&(c^=255&e.charCodeAt(u)))+((1540483477*(c>>>16)&65535)<<16)}return c=1540483477*(65535&(c^=c>>>13))+((1540483477*(c>>>16)&65535)<<16),(c^=c>>>15)>>>0}),Ic.exports);return Mc.exports=e,Mc.exports.murmur3=e,Mc.exports.murmur2=s,Mc.exports}(),Ac=c(Ec);class no{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,s,a,l){this.ids.push(zc(e)),this.positions.push(s,a,l)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const s=zc(e);let a=0,l=this.ids.length-1;for(;a>1;this.ids[e]>=s?l=e:a=e+1}const c=[];for(;this.ids[a]===s;)c.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return c}static serialize(e,s){const a=new Float64Array(e.ids),l=new Uint32Array(e.positions);return kc(a,l,0,a.length-1),s&&s.push(a.buffer,l.buffer),{ids:a,positions:l}}static deserialize(e){const s=new no;return s.ids=e.ids,s.positions=e.positions,s.indexed=!0,s}}function zc(e){const s=+e;return!isNaN(s)&&s<=Number.MAX_SAFE_INTEGER?s:Ac(String(e))}function kc(e,s,a,l){for(;a>1];let u=a-1,p=l+1;for(;;){do{u++}while(e[u]c);if(u>=p)break;Dc(e,u,p),Dc(s,3*u,3*p),Dc(s,3*u+1,3*p+1),Dc(s,3*u+2,3*p+2)}p-a`u_${e}`)),this.type=a}setUniform(e,s,a){e.set(a.constantOr(this.value))}getBinding(e,s,a){return"color"===this.type?new co(e,s):new lo(e,s)}}class yo{constructor(e,s){this.uniformNames=s.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,s){this.pixelRatioFrom=s.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=s.tlbr,this.patternTo=e.tlbr}setUniform(e,s,a,l){const c="u_pattern_to"===l?this.patternTo:"u_pattern_from"===l?this.patternFrom:"u_pixel_ratio_to"===l?this.pixelRatioTo:"u_pixel_ratio_from"===l?this.pixelRatioFrom:null;c&&e.set(c)}getBinding(e,s,a){return"u_pattern"===a.substr(0,9)?new uo(e,s):new lo(e,s)}}class mo{constructor(e,s,a,l){this.expression=e,this.type=a,this.maxValue=0,this.paintVertexAttributes=s.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===a?2:1,offset:0}))),this.paintVertexArray=new l}populatePaintArray(e,s,a,l,c){const u=this.paintVertexArray.length,p=this.expression.evaluate(new Is(0),s,{},l,[],c);this.paintVertexArray.resize(e),this._setPaintValue(u,e,p)}updatePaintArray(e,s,a,l){const c=this.expression.evaluate({zoom:0},a,l);this._setPaintValue(e,s,c)}_setPaintValue(e,s,a){if("color"===this.type){const l=Lc(a);for(let a=e;a`u_${e}_t`)),this.type=a,this.useIntegerZoom=l,this.zoom=c,this.maxValue=0,this.paintVertexAttributes=s.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===a?4:2,offset:0}))),this.paintVertexArray=new u}populatePaintArray(e,s,a,l,c){const u=this.expression.evaluate(new Is(this.zoom),s,{},l,[],c),p=this.expression.evaluate(new Is(this.zoom+1),s,{},l,[],c),f=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(f,e,u,p)}updatePaintArray(e,s,a,l){const c=this.expression.evaluate({zoom:this.zoom},a,l),u=this.expression.evaluate({zoom:this.zoom+1},a,l);this._setPaintValue(e,s,c,u)}_setPaintValue(e,s,a,l){if("color"===this.type){const c=Lc(a),u=Lc(l);for(let a=e;a`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const s in this.binders){const a=this.binders[s];if(a instanceof mo||a instanceof go)for(let s=0;s!0){this.programConfigurations={};for(const l of e)this.programConfigurations[l.id]=new vo(l,s,a);this.needsUpload=!1,this._featureMap=new no,this._bufferOffset=0}populatePaintArrays(e,s,a,l,c,u){for(const a in this.programConfigurations)this.programConfigurations[a].populatePaintArrays(e,s,l,c,u);void 0!==s.id&&this._featureMap.add(s.id,a,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,s,a,l){for(const c of a)this.needsUpload=this.programConfigurations[c.id].updatePaintArrays(e,this._featureMap,s,c,l)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const s in this.programConfigurations)this.programConfigurations[s].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Bc(e,s){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${s}-`,"").replace(/-/g,"_")]}function Fc(e,s,a){const l={color:{source:ta,composite:ga},number:{source:pa,composite:ta}},c=function(e){return{"line-pattern":{source:$a,composite:$a},"fill-pattern":{source:$a,composite:$a},"fill-extrusion-pattern":{source:$a,composite:$a}}[e]}(e);return c&&c[a]||l[s][a]}Nl("ConstantBinder",fo),Nl("CrossFadedConstantBinder",yo),Nl("SourceExpressionBinder",mo),Nl("CrossFadedCompositeBinder",xo),Nl("CompositeExpressionBinder",go),Nl("ProgramConfiguration",vo,{omit:["_buffers"]}),Nl("ProgramConfigurationSet",bo);const Oc=Math.pow(2,14)-1,jc=-Oc-1;function Vc(e){const s=rt/e.extent,a=e.loadGeometry();for(let e=0;ea.x+1||ua.y+1)&&kt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return a}function Uc(e,s){return{type:e.type,id:e.id,properties:e.properties,geometry:s?Vc(e):[]}}const Nc=-32768;function $c(e,s,a,l,c){e.emplaceBack(Nc+8*s+l,Nc+8*a+c)}class Po{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Ea,this.indexArray=new ja,this.segments=new Xa,this.programConfigurations=new bo(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,a){const l=this.layers[0],c=[];let u=null,p=!1,f="heatmap"===l.type;if("circle"===l.type){const e=l;u=e.layout.get("circle-sort-key"),p=!u.isConstant(),f=f||"map"===e.paint.get("circle-pitch-alignment")}const _=f?s.subdivisionGranularity.circle:1;for(const{feature:s,id:l,index:f,sourceLayerIndex:_}of e){const e=this.layers[0]._featureFilter.needGeometry,g=Uc(s,e);if(!this.layers[0]._featureFilter.filter(new Is(this.zoom,{globalState:this.globalState}),g,a))continue;const y=p?u.evaluate(g,{},a):void 0,x={id:l,properties:s.properties,type:s.type,sourceLayerIndex:_,index:f,geometry:e?g.geometry:Vc(s),patterns:{},sortKey:y};c.push(x)}p&&c.sort(((e,s)=>e.sortKey-s.sortKey));for(const l of c){const{geometry:c,index:u,sourceLayerIndex:p}=l,f=e[u].feature;this.addFeature(l,c,u,a,_),s.featureIndex.insert(f,c,u,p,this.index)}}update(e,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,a)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,vc),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,s,a,l,c=1){let u;switch(c){case 1:u=[0,7];break;case 3:u=[0,2,5,7];break;case 5:u=[0,1,3,4,6,7];break;case 7:u=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${c}; valid values are 1, 3, 5, 7.`)}const p=u.length;for(const a of s)for(const s of a){const a=s.x,l=s.y;if(a<0||a>=rt||l<0||l>=rt)continue;const c=this.segments.prepareSegment(p*p,this.layoutVertexArray,this.indexArray,e.sortKey),f=c.vertexLength;for(let e=0;e1){if(Jc(e,s))return!0;for(let l=0;l1?a:a.sub(s)._mult(c)._add(s))}function nh(e,s){let a,l,c,u=!1;for(let p=0;ps.y!=c.y>s.y&&s.x<(c.x-l.x)*(s.y-l.y)/(c.y-l.y)+l.x&&(u=!u)}return u}function lh(e,s){let a=!1;for(let l=0,c=e.length-1;ls.y!=p.y>s.y&&s.x<(p.x-u.x)*(s.y-u.y)/(p.y-u.y)+u.x&&(a=!a)}return a}function hh(e,s,a){const l=a[0],c=a[2];if(e.xc.x&&s.x>c.x||e.yc.y&&s.y>c.y)return!1;const u=Ft(e,s,a[0]);return u!==Ft(e,s,a[1])||u!==Ft(e,s,a[2])||u!==Ft(e,s,a[3])}function uh(e,s,a){const l=s.paint.get(e).value;return"constant"===l.kind?l.value:a.programConfigurations.get(s.id).getMaxValue(e)}function dh(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ph(e,s,a,c,u){if(!s[0]&&!s[1])return e;const p=l.convert(s)._mult(u);"viewport"===a&&p._rotate(-c);const f=[];for(let s=0;syh(e,s,a,l)))}(_,c,p,f),v=y?g*u:g;for(const e of l)for(const s of e){const e=y?s:yh(s,c,p,f);let a=v;const l=c.projectTileCoordinates(s.x,s.y,p,f).signedDistanceFromCamera;if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?a*=l/c.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(a*=c.cameraToCenterDistance/l),qc(x,e,a))return!0}return!1}}function yh(e,s,a,c){const u=s.projectTileCoordinates(e.x,e.y,a,c).point;return new l((.5*u.x+.5)*s.width,(.5*-u.y+.5)*s.height)}class Ho extends Po{}let vh;Nl("HeatmapBucket",Ho,{omit:["layers"]});var Th={get paint(){return vh=vh||new Us({"heatmap-radius":new Ls(ve.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ls(ve.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new $s(ve.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Rs(ve.paint_heatmap["heatmap-color"]),"heatmap-opacity":new $s(ve.paint_heatmap["heatmap-opacity"])})}};function Ph(e,{width:s,height:a},l,c){if(c){if(c instanceof Uint8ClampedArray)c=new Uint8Array(c.buffer);else if(c.length!==s*a*l)throw new RangeError(`mismatched image size. expected: ${c.length} but got: ${s*a*l}`)}else c=new Uint8Array(s*a*l);return e.width=s,e.height=a,e.data=c,e}function Sh(e,{width:s,height:a},l){if(s===e.width&&a===e.height)return;const c=Ph({},{width:s,height:a},l);Ch(e,c,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,s),height:Math.min(e.height,a)},l),e.width=s,e.height=a,e.data=c.data}function Ch(e,s,a,l,c,u){if(0===c.width||0===c.height)return s;if(c.width>e.width||c.height>e.height||a.x>e.width-c.width||a.y>e.height-c.height)throw new RangeError("out of range source coordinates for image copy");if(c.width>s.width||c.height>s.height||l.x>s.width-c.width||l.y>s.height-c.height)throw new RangeError("out of range destination coordinates for image copy");const p=e.data,f=s.data;if(p===f)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_{s[e.evaluationKey]=p;const f=e.expression.evaluate(s);c.setPixel(l/4/a,u/4,f)};if(e.clips)for(let s=0,c=0;sthis.max&&(this.max=a),a=this.dim+1||s<-1||s>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(s+1)*this.stride+(e+1)}unpack(e,s,a){return e*this.redFactor+s*this.greenFactor+a*this.blueFactor-this.baseShift}pack(e){return Oh(e,this.getUnpackVector())}getPixels(){return new rl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,s,a){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let l=s*this.dim,c=s*this.dim+this.dim,u=a*this.dim,p=a*this.dim+this.dim;switch(s){case-1:l=c-1;break;case 1:c=l+1}switch(a){case-1:u=p-1;break;case 1:p=u+1}const f=-s*this.dim,_=-a*this.dim;for(let s=u;s0)for(let c=s;c=s;c-=l)u=xu(c/l|0,e[c],e[c+1],u);return u&&uu(u,u.next)&&(vu(u),u=u.next),u}function Zh(e,s){if(!e)return e;s||(s=e);let a,l=e;do{if(a=!1,l.steiner||!uu(l,l.next)&&0!==cu(l.prev,l,l.next))l=l.next;else{if(vu(l),l=s=l.prev,l===l.next)break;a=!0}}while(a||l!==s);return s}function qh(e,s,a,l,c,u,p){if(!e)return;!p&&u&&function(e,s,a,l){let c=e;do{0===c.z&&(c.z=ru(c.x,c.y,s,a,l)),c.prevZ=c.prev,c.nextZ=c.next,c=c.next}while(c!==e);c.prevZ.nextZ=null,c.prevZ=null,function(e){let s,a=1;do{let l,c=e;e=null;let u=null;for(s=0;c;){s++;let p=c,f=0;for(let e=0;e0||_>0&&p;)0!==f&&(0===_||!p||c.z<=p.z)?(l=c,c=c.nextZ,f--):(l=p,p=p.nextZ,_--),u?u.nextZ=l:e=l,l.prevZ=u,u=l;c=p}u.nextZ=null,a*=2}while(s>1)}(c)}(e,l,c,u);let f=e;for(;e.prev!==e.next;){const _=e.prev,g=e.next;if(u?Hh(e,l,c,u):Wh(e))s.push(_.i,e.i,g.i),vu(e),e=g.next,f=g.next;else if((e=g)===f){p?1===p?qh(e=Yh(Zh(e),s),s,a,l,c,u,2):2===p&&Kh(e,s,a,l,c,u):qh(Zh(e),s,a,l,c,u,1);break}}}function Wh(e){const s=e.prev,a=e,l=e.next;if(cu(s,a,l)>=0)return!1;const c=s.x,u=a.x,p=l.x,f=s.y,_=a.y,g=l.y,y=Math.min(c,u,p),x=Math.min(f,_,g),v=Math.max(c,u,p),w=Math.max(f,_,g);let C=l.next;for(;C!==s;){if(C.x>=y&&C.x<=v&&C.y>=x&&C.y<=w&&ou(c,f,u,_,p,g,C.x,C.y)&&cu(C.prev,C,C.next)>=0)return!1;C=C.next}return!0}function Hh(e,s,a,l){const c=e.prev,u=e,p=e.next;if(cu(c,u,p)>=0)return!1;const f=c.x,_=u.x,g=p.x,y=c.y,x=u.y,v=p.y,w=Math.min(f,_,g),C=Math.min(y,x,v),A=Math.max(f,_,g),k=Math.max(y,x,v),D=ru(w,C,s,a,l),R=ru(A,k,s,a,l);let L=e.prevZ,B=e.nextZ;for(;L&&L.z>=D&&B&&B.z<=R;){if(L.x>=w&&L.x<=A&&L.y>=C&&L.y<=k&&L!==c&&L!==p&&ou(f,y,_,x,g,v,L.x,L.y)&&cu(L.prev,L,L.next)>=0)return!1;if(L=L.prevZ,B.x>=w&&B.x<=A&&B.y>=C&&B.y<=k&&B!==c&&B!==p&&ou(f,y,_,x,g,v,B.x,B.y)&&cu(B.prev,B,B.next)>=0)return!1;B=B.nextZ}for(;L&&L.z>=D;){if(L.x>=w&&L.x<=A&&L.y>=C&&L.y<=k&&L!==c&&L!==p&&ou(f,y,_,x,g,v,L.x,L.y)&&cu(L.prev,L,L.next)>=0)return!1;L=L.prevZ}for(;B&&B.z<=R;){if(B.x>=w&&B.x<=A&&B.y>=C&&B.y<=k&&B!==c&&B!==p&&ou(f,y,_,x,g,v,B.x,B.y)&&cu(B.prev,B,B.next)>=0)return!1;B=B.nextZ}return!0}function Yh(e,s){let a=e;do{const l=a.prev,c=a.next.next;!uu(l,c)&&du(l,a,a.next,c)&&_u(l,c)&&_u(c,l)&&(s.push(l.i,a.i,c.i),vu(a),vu(a.next),a=e=c),a=a.next}while(a!==e);return Zh(a)}function Kh(e,s,a,l,c,u){let p=e;do{let e=p.next.next;for(;e!==p.prev;){if(p.i!==e.i&&au(p,e)){let f=yu(p,e);return p=Zh(p,p.next),f=Zh(f,f.next),qh(p,s,a,l,c,u,0),void qh(f,s,a,l,c,u,0)}e=e.next}p=p.next}while(p!==e)}function Jh(e,s){let a=e.x-s.x;return 0===a&&(a=e.y-s.y,0===a)&&(a=(e.next.y-e.y)/(e.next.x-e.x)-(s.next.y-s.y)/(s.next.x-s.x)),a}function Qh(e,s){const a=function(e,s){let a=s;const l=e.x,c=e.y;let u,p=-1/0;if(uu(e,a))return a;do{if(uu(e,a.next))return a.next;if(c<=a.y&&c>=a.next.y&&a.next.y!==a.y){const e=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(e<=l&&e>p&&(p=e,u=a.x=a.x&&a.x>=_&&l!==a.x&&su(cu.x||a.x===u.x&&eu(u,a)))&&(u=a,y=s)}a=a.next}while(a!==f);return u}(e,s);if(!a)return s;const l=yu(a,e);return Zh(l,l.next),Zh(a,a.next)}function eu(e,s){return cu(e.prev,e,s.prev)<0&&cu(s.next,e,e.next)<0}function ru(e,s,a,l,c){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-a)*c|0)|e<<8))|e<<4))|e<<2))|e<<1))|(s=1431655765&((s=858993459&((s=252645135&((s=16711935&((s=(s-l)*c|0)|s<<8))|s<<4))|s<<2))|s<<1))<<1}function nu(e){let s=e,a=e;do{(s.x=(e-p)*(u-f)&&(e-p)*(l-f)>=(a-p)*(s-f)&&(a-p)*(u-f)>=(c-p)*(l-f)}function ou(e,s,a,l,c,u,p,f){return!(e===p&&s===f)&&su(e,s,a,l,c,u,p,f)}function au(e,s){return e.next.i!==s.i&&e.prev.i!==s.i&&!function(e,s){let a=e;do{if(a.i!==e.i&&a.next.i!==e.i&&a.i!==s.i&&a.next.i!==s.i&&du(a,a.next,e,s))return!0;a=a.next}while(a!==e);return!1}(e,s)&&(_u(e,s)&&_u(s,e)&&function(e,s){let a=e,l=!1;const c=(e.x+s.x)/2,u=(e.y+s.y)/2;do{a.y>u!=a.next.y>u&&a.next.y!==a.y&&c<(a.next.x-a.x)*(u-a.y)/(a.next.y-a.y)+a.x&&(l=!l),a=a.next}while(a!==e);return l}(e,s)&&(cu(e.prev,e,s.prev)||cu(e,s.prev,s))||uu(e,s)&&cu(e.prev,e,e.next)>0&&cu(s.prev,s,s.next)>0)}function cu(e,s,a){return(s.y-e.y)*(a.x-s.x)-(s.x-e.x)*(a.y-s.y)}function uu(e,s){return e.x===s.x&&e.y===s.y}function du(e,s,a,l){const c=mu(cu(e,s,a)),u=mu(cu(e,s,l)),p=mu(cu(a,l,e)),f=mu(cu(a,l,s));return c!==u&&p!==f||!(0!==c||!pu(e,a,s))||!(0!==u||!pu(e,l,s))||!(0!==p||!pu(a,e,l))||!(0!==f||!pu(a,s,l))}function pu(e,s,a){return s.x<=Math.max(e.x,a.x)&&s.x>=Math.min(e.x,a.x)&&s.y<=Math.max(e.y,a.y)&&s.y>=Math.min(e.y,a.y)}function mu(e){return e>0?1:e<0?-1:0}function _u(e,s){return cu(e.prev,e,e.next)<0?cu(e,s,e.next)>=0&&cu(e,e.prev,s)>=0:cu(e,s,e.prev)<0||cu(e,e.next,s)<0}function yu(e,s){const a=bu(e.i,e.x,e.y),l=bu(s.i,s.x,s.y),c=e.next,u=s.prev;return e.next=s,s.prev=e,a.next=c,c.prev=a,l.next=a,a.prev=l,u.next=l,l.prev=u,l}function xu(e,s,a,l){const c=bu(e,s,a);return l?(c.next=l.next,c.prev=l,l.next.prev=c,l.next=c):(c.prev=c,c.next=c),c}function vu(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 bu(e,s,a){return{i:e,x:s,y:a,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class ql{constructor(e,s){if(s>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=s}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||s>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const a=0|Math.round(e),l=0|Math.round(s),c=this._getKey(a,l);if(this._vertexDictionary.has(c))return this._vertexDictionary.get(c);const u=this._vertexBuffer.length/2;return this._vertexDictionary.set(c,u),this._vertexBuffer.push(a,l),u}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,s){const a=[];for(let l=0;l0?(a.push(c),a.push(p),a.push(u)):(a.push(c),a.push(u),a.push(p))}return a}(this._vertexBuffer,e);const s=[],a=e.length;for(let l=0;l=1||L<=0)||A&&(fc)){g>=l&&g<=c&&u.push(a[(e+1)%3]);continue}!A&&R>0&&u.push(this._vertexToIndex(p+v*R,f+w*R));const B=p+v*Math.max(R,0),O=p+v*Math.min(L,1);C||this._generateIntraEdgeVertices(u,p,f,_,g,B,O),!A&&L<1&&u.push(this._vertexToIndex(p+v*L,f+w*L)),(A||g>=l&&g<=c)&&u.push(a[(e+1)%3]),!A&&(g<=l||g>=c)&&this._generateInterEdgeVertices(u,p,f,_,g,y,x,O,l,c)}return u}_generateIntraEdgeVertices(e,s,a,l,c,u,p){const f=l-s,_=c-a,g=0===_,y=g?Math.min(s,l):Math.min(u,p),x=g?Math.max(s,l):Math.max(u,p),v=Math.floor(y/this._granularityCellSize)+1,w=Math.ceil(x/this._granularityCellSize)-1;if(g?s=v;l--){const c=l*this._granularityCellSize;e.push(this._vertexToIndex(c,a+_*(c-s)/f))}}_generateInterEdgeVertices(e,s,a,l,c,u,p,f,_,g){const y=c-a,x=u-l,v=p-c,w=(_-c)/v,C=(g-c)/v,A=Math.min(w,C),k=Math.max(w,C),D=l+x*A;let R=Math.floor(Math.min(D,f)/this._granularityCellSize)+1,L=Math.ceil(Math.max(D,f)/this._granularityCellSize)-1,B=f=1||k<=0){const e=a-p,l=u+(s-u)*Math.min((_-p)/e,(g-p)/e);R=Math.floor(Math.min(l,f)/this._granularityCellSize)+1,L=Math.ceil(Math.max(l,f)/this._granularityCellSize)-1,B=f0?g:_;if(B)for(let s=R;s<=L;s++)e.push(this._vertexToIndex(s*this._granularityCellSize,j));else for(let s=L;s>=R;s--)e.push(this._vertexToIndex(s*this._granularityCellSize,j))}_generateOutline(e){const s=[];for(const a of e){const e=Mu(a,this._granularity,!0),l=this._pointArrayToIndices(e),c=[];for(let e=1;ec!=(u===wu)?(e.push(s),e.push(a),e.push(this._vertexToIndex(l,u)),e.push(a),e.push(this._vertexToIndex(c,u)),e.push(this._vertexToIndex(l,u))):(e.push(a),e.push(s),e.push(this._vertexToIndex(l,u)),e.push(this._vertexToIndex(c,u)),e.push(a),e.push(this._vertexToIndex(l,u)))}_fillPoles(e,s,a){const l=this._vertexBuffer,c=rt,u=e.length;for(let p=2;p80*a){f=e[0],_=e[1];let s=f,l=_;for(let u=a;us&&(s=a),c>l&&(l=c)}g=Math.max(s-f,l-_),g=0!==g?32767/g:0}return qh(u,p,a,f,_,g,0),p}(a,l),s=this._convertIndices(a,e);c=this._subdivideTrianglesScanline(s)}catch(e){console.error(e)}let u=[];return s&&(u=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(c),{verticesFlattened:this._vertexBuffer,indicesTriangles:c,indicesLineList:u}}_convertIndices(e,s){const a=[];for(let l=0;l0?(Math.floor(R/f)+1)*f:(Math.ceil(R/f)-1)*f,s=A>0?(Math.floor(L/f)+1)*f:(Math.ceil(L/f)-1)*f,a=Math.abs(R-e),c=Math.abs(L-s),u=Math.abs(R-y),p=Math.abs(L-x),g=v?a/k:Number.POSITIVE_INFINITY,B=w?c/D:Number.POSITIVE_INFINITY;if((u<=a||!v)&&(p<=c||!w))break;if(g=0?p-1:u-1,c=(f+1)%u,_=e[2*s[l]],g=e[2*s[c]],y=e[2*s[p]],x=e[2*s[p]+1],v=e[2*s[f]+1];let w=!1;if(_g)w=!1;else{const a=v-x,u=-(e[2*s[f]]-y),p=x((g-y)*a+(e[2*s[c]+1]-x)*u)*p&&(w=!0)}if(w){const e=s[l],c=s[p],_=s[f];e!==c&&e!==_&&c!==_&&a.push(_,c,e),p--,p<0&&(p=u-1)}else{const e=s[c],l=s[p],_=s[f];e!==l&&e!==_&&l!==_&&a.push(_,l,e),f++,f>=u&&(f=0)}if(l===c)break}}function Iu(e,s,a,l,c,u,p,f,_){const g=c.length/2,y=p&&f&&_;if(gXa.MAX_VERTEX_ARRAY_LENGTH&&(g=e.createNewSegment(s,a),_=f.count,A=!0,k=!0,D=!0,y=0);const R=Eu(p,l,u,f,v,A,g),L=Eu(p,l,u,f,w,k,g),B=Eu(p,l,u,f,C,D,g);a.emplaceBack(y+R-_,y+L-_,y+B-_),g.primitiveLength++}}(s,a,l,c,u,e),y&&function(e,s,a,l,c,u){const p=[];for(let e=0;eXa.MAX_VERTEX_ARRAY_LENGTH&&(g=e.createNewSegment(s,a),_=f.count,C=!0,A=!0,y=0);const k=Eu(p,l,u,f,c,C,g),D=Eu(p,l,u,f,x,A,g);a.emplaceBack(y+k-_,y+D-_),g.primitiveLength++}}}(p,a,f,c,_,e),s.forceNewSegmentOnNextPrepare(),null==p||p.forceNewSegmentOnNextPrepare()}function Eu(e,s,a,l,c,u,p){if(u){const u=l.count;return a(s[2*c],s[2*c+1]),e[c]=l.count,l.count++,p.vertexLength++,u}return e[c]}class tu{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ba,this.indexArray=new ja,this.indexArray2=new Na,this.programConfigurations=new bo(e.layers,e.zoom),this.segments=new Xa,this.segments2=new Xa,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,a){this.hasPattern=Uh("fill",this.layers,s);const l=this.layers[0].layout.get("fill-sort-key"),c=!l.isConstant(),u=[];for(const{feature:p,id:f,index:_,sourceLayerIndex:g}of e){const e=this.layers[0]._featureFilter.needGeometry,y=Uc(p,e);if(!this.layers[0]._featureFilter.filter(new Is(this.zoom,{globalState:this.globalState}),y,a))continue;const x=c?l.evaluate(y,{},a,s.availableImages):void 0,v={id:f,properties:p.properties,type:p.type,sourceLayerIndex:g,index:_,geometry:e?y.geometry:Vc(p),patterns:{},sortKey:x};u.push(v)}c&&u.sort(((e,s)=>e.sortKey-s.sortKey));for(const l of u){const{geometry:c,index:u,sourceLayerIndex:p}=l;if(this.hasPattern){const e=Nh("fill",this.layers,l,this.zoom,s);this.patternFeatures.push(e)}else this.addFeature(l,c,u,a,{},s.subdivisionGranularity);s.featureIndex.insert(e[u].feature,c,u,p,this.index)}}update(e,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,a)}addFeatures(e,s,a){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,s,a,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,Vh),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,s,a,l,c,u){for(const e of kn(s,500)){const s=Pu(e,l,u.fill.getGranularityForZoomLevel(l.z)),a=this.layoutVertexArray;Iu(((e,s)=>{a.emplaceBack(e,s)}),this.segments,this.layoutVertexArray,this.indexArray,s.verticesFlattened,s.indicesTriangles,this.segments2,this.indexArray2,s.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,c,l)}}let Au,zu;Nl("FillBucket",tu,{omit:["layers","patternFeatures"]});var ku={get paint(){return zu=zu||new Us({"fill-antialias":new $s(ve.paint_fill["fill-antialias"]),"fill-opacity":new Ls(ve.paint_fill["fill-opacity"]),"fill-color":new Ls(ve.paint_fill["fill-color"]),"fill-outline-color":new Ls(ve.paint_fill["fill-outline-color"]),"fill-translate":new $s(ve.paint_fill["fill-translate"]),"fill-translate-anchor":new $s(ve.paint_fill["fill-translate-anchor"]),"fill-pattern":new Os(ve.paint_fill["fill-pattern"])})},get layout(){return Au=Au||new Us({"fill-sort-key":new Ls(ve.layout_fill["fill-sort-key"])})}};class iu extends Ns{constructor(e){super(e,ku)}recalculate(e,s){super.recalculate(e,s);const a=this.paint._values["fill-outline-color"];"constant"===a.value.kind&&void 0===a.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new tu(e)}queryRadius(){return dh(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:s,transform:a,pixelsToTileUnits:l}){return Hc(ph(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-a.bearingInRadians,l),s)}isTileClipped(){return!0}}const Du=_c([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Ru=_c([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Lu}=Du;class lu{constructor(e,s,a,l,c){this.properties={},this.extent=a,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=l,this._values=c,e.readFields(Fu,this,s)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const s=e.readVarint()+e.pos,a=[];let c,u=1,p=0,f=0,_=0;for(;e.pos>3}if(p--,1===u||2===u)f+=e.readSVarint(),_+=e.readSVarint(),1===u&&(c&&a.push(c),c=[]),c&&c.push(new l(f,_));else{if(7!==u)throw new Error(`unknown command ${u}`);c&&c.push(c[0].clone())}}return c&&a.push(c),a}bbox(){const e=this._pbf;e.pos=this._geometry;const s=e.readVarint()+e.pos;let a=1,l=0,c=0,u=0,p=1/0,f=-1/0,_=1/0,g=-1/0;for(;e.pos>3}if(l--,1===a||2===a)c+=e.readSVarint(),u+=e.readSVarint(),cf&&(f=c),u<_&&(_=u),u>g&&(g=u);else if(7!==a)throw new Error(`unknown command ${a}`)}return[p,_,f,g]}toGeoJSON(e,s,a){const l=this.extent*Math.pow(2,a),c=this.extent*e,u=this.extent*s,p=this.loadGeometry();function f(e){return[360*(e.x+c)/l-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+u)/l)*Math.PI))-90]}function _(e){return e.map(f)}let g;if(1===this.type){const e=[];for(const s of p)e.push(s[0]);const s=_(e);g=1===e.length?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s}}else if(2===this.type){const e=p.map(_);g=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const s=e.length;if(s<=1)return[e];const a=[];let l,c;for(let u=0;u=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const s=this._pbf.readVarint()+this._pbf.pos;return new lu(this._pbf,s,this.extent,this._keys,this._values)}}function Vu(e,s,a){15===e?s.version=a.readVarint():1===e?s.name=a.readString():5===e?s.extent=a.readVarint():2===e?s._features.push(a.pos):3===e?s._keys.push(a.readString()):4===e&&s._values.push(function(e){let s=null;const a=e.readVarint()+e.pos;for(;e.pos>3;s=1===a?e.readString():2===a?e.readFloat():3===a?e.readDouble():4===a?e.readVarint64():5===a?e.readVarint():6===a?e.readSVarint():7===a?e.readBoolean():null}if(null==s)throw new Error("unknown feature value");return s}(a))}class fu{constructor(e,s){this.layers=e.readFields(Uu,{},s)}}function Uu(e,s,a){if(3===e){const e=new hu(a,a.readVarint()+a.pos);e.length&&(s[e.name]=e)}}const Nu=Math.pow(2,13);function Zu(e,s,a,l,c,u,p,f){e.emplaceBack(s,a,2*Math.floor(l*Nu)+p,c*Nu*2,u*Nu*2,Math.round(f))}class gu{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Va,this.centroidVertexArray=new Ca,this.indexArray=new ja,this.programConfigurations=new bo(e.layers,e.zoom),this.segments=new Xa,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,a){this.features=[],this.hasPattern=Uh("fill-extrusion",this.layers,s);for(const{feature:l,id:c,index:u,sourceLayerIndex:p}of e){const e=this.layers[0]._featureFilter.needGeometry,f=Uc(l,e);if(!this.layers[0]._featureFilter.filter(new Is(this.zoom,{globalState:this.globalState}),f,a))continue;const _={id:c,sourceLayerIndex:p,index:u,geometry:e?f.geometry:Vc(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(Nh("fill-extrusion",this.layers,_,this.zoom,s)):this.addFeature(_,_.geometry,u,a,{},s.subdivisionGranularity),s.featureIndex.insert(l,_.geometry,u,p,this.index,!0)}}addFeatures(e,s,a){for(const l of this.features){const{geometry:c}=l;this.addFeature(l,c,l.index,s,a,e.subdivisionGranularity)}}update(e,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,a)}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,Lu),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Ru.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,s,a,l,c,u){for(const a of kn(s,500)){const s={x:0,y:0,sampleCount:0},c=this.layoutVertexArray.length;this.processPolygon(s,l,e,a,u);const p=this.layoutVertexArray.length-c,f=Math.floor(s.x/s.sampleCount),_=Math.floor(s.y/s.sampleCount);for(let e=0;e{Zu(g,e,s,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,_.verticesFlattened,_.indicesTriangles)}_generateSideFaces(e,s){let a=0;for(let l=1;lXa.MAX_VERTEX_ARRAY_LENGTH&&(s.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const p=c.sub(u)._perp()._unit(),f=u.dist(c);a+f>32768&&(a=0),Zu(this.layoutVertexArray,c.x,c.y,p.x,p.y,0,0,a),Zu(this.layoutVertexArray,c.x,c.y,p.x,p.y,0,1,a),a+=f,Zu(this.layoutVertexArray,u.x,u.y,p.x,p.y,0,0,a),Zu(this.layoutVertexArray,u.x,u.y,p.x,p.y,0,1,a);const _=s.segment.vertexLength;this.indexArray.emplaceBack(_,_+2,_+1),this.indexArray.emplaceBack(_+1,_+2,_+3),s.segment.vertexLength+=4,s.segment.primitiveLength+=2}}}function Gu(e,s){for(let a=0;art)||e.y===s.y&&(e.y<0||e.y>rt)}function Wu(e){return e.every((e=>e.x<0))||e.every((e=>e.x>rt))||e.every((e=>e.y<0))||e.every((e=>e.y>rt))}let Xu;Nl("FillExtrusionBucket",gu,{omit:["layers","features"]});var Hu={get paint(){return Xu=Xu||new Us({"fill-extrusion-opacity":new $s(ve["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ls(ve["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new $s(ve["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new $s(ve["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Os(ve["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ls(ve["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ls(ve["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new $s(ve["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Su extends Ns{constructor(e){super(e,Hu)}createBucket(e){return new gu(e)}queryRadius(){return dh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:a,geometry:c,transform:u,pixelsToTileUnits:p,pixelPosMatrix:f}){const _=ph(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-u.bearingInRadians,p),g=this.paint.get("fill-extrusion-height").evaluate(s,a),y=this.paint.get("fill-extrusion-base").evaluate(s,a),x=function(e,s){const a=[];for(const c of e){const e=[c.x,c.y,0,1];Z(e,e,s),a.push(new l(e[0]/e[3],e[1]/e[3]))}return a}(_,f),v=function(e,s,a,c){const u=[],p=[],f=c[8]*s,_=c[9]*s,g=c[10]*s,y=c[11]*s,x=c[8]*a,v=c[9]*a,w=c[10]*a,C=c[11]*a;for(const s of e){const e=[],a=[];for(const u of s){const s=u.x,p=u.y,A=c[0]*s+c[4]*p+c[12],k=c[1]*s+c[5]*p+c[13],D=c[2]*s+c[6]*p+c[14],R=c[3]*s+c[7]*p+c[15],L=D+g,B=R+y,O=A+x,j=k+v,U=D+w,N=R+C,Z=new l((A+f)/B,(k+_)/B);Z.z=L/B,e.push(Z);const J=new l(O/N,j/N);J.z=U/N,a.push(J)}u.push(e),p.push(a)}return[u,p]}(c,y,g,f);return function(e,s,a){let l=1/0;Hc(a,s)&&(l=Ku(a,s[0]));for(let c=0;ce.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new Ta,this.layoutVertexArray2=new Fa,this.indexArray=new ja,this.programConfigurations=new bo(e.layers,e.zoom),this.segments=new Xa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,a){this.hasPattern=Uh("line",this.layers,s);const l=this.layers[0].layout.get("line-sort-key"),c=!l.isConstant(),u=[];for(const{feature:s,id:p,index:f,sourceLayerIndex:_}of e){const e=this.layers[0]._featureFilter.needGeometry,g=Uc(s,e);if(!this.layers[0]._featureFilter.filter(new Is(this.zoom,{globalState:this.globalState}),g,a))continue;const y=c?l.evaluate(g,{},a):void 0,x={id:p,properties:s.properties,type:s.type,sourceLayerIndex:_,index:f,geometry:e?g.geometry:Vc(s),patterns:{},sortKey:y};u.push(x)}c&&u.sort(((e,s)=>e.sortKey-s.sortKey));for(const l of u){const{geometry:c,index:u,sourceLayerIndex:p}=l;if(this.hasPattern){const e=Nh("line",this.layers,l,this.zoom,s);this.patternFeatures.push(e)}else this.addFeature(l,c,u,a,{},s.subdivisionGranularity);s.featureIndex.insert(e[u].feature,c,u,p,this.index)}}update(e,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,a)}addFeatures(e,s,a){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,s,a,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,id)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,td),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,s,a,l,c,u){const p=this.layers[0].layout,f=p.get("line-join").evaluate(e,{}),_=p.get("line-cap"),g=p.get("line-miter-limit"),y=p.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const a of s)this.addLine(a,e,f,_,g,y,l,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,c,l)}addLine(e,s,a,l,c,u,p,f){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Mu(e,p?f.line.getGranularityForZoomLevel(p.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let s=0;s=2&&e[g-1].equals(e[g-2]);)g--;let y=0;for(;y0;if(O&&s>y){const e=w.dist(C);if(e>2*x){const s=w.sub(w.sub(C)._mult(x/e)._round());this.updateDistance(C,s),this.addCurrentVertex(s,k,0,0,v),C=s}}const U=C&&A;let N=U?a:_?"butt":l;if(U&&"round"===N&&(Lc&&(N="bevel"),"bevel"===N&&(L>2&&(N="flipbevel"),L100)p=D.mult(-1);else{const e=L*k.add(D).mag()/k.sub(D).mag();p._perp()._mult(e*(j?-1:1))}this.addCurrentVertex(w,p,0,0,v),this.addCurrentVertex(w,p.mult(-1),0,0,v)}else if("bevel"===N||"fakeround"===N){const e=-Math.sqrt(L*L-1),s=j?e:0,a=j?0:e;if(C&&this.addCurrentVertex(w,k,s,a,v),"fakeround"===N){const e=Math.round(180*B/Math.PI/20);for(let s=1;s2*x){const s=w.add(A.sub(w)._mult(x/e)._round());this.updateDistance(w,s),this.addCurrentVertex(s,D,0,0,v),w=s}}}}addCurrentVertex(e,s,a,l,c,u=!1){const p=s.y*l-s.x,f=-s.y-s.x*l;this.addHalfVertex(e,s.x+s.y*a,s.y-s.x*a,u,!1,a,c),this.addHalfVertex(e,p,f,u,!0,-l,c),this.distance>nd/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,s,a,l,c,u))}addHalfVertex({x:e,y:s},a,l,c,u,p,f){const _=.5*(this.lineClips?this.scaledDistance*(nd-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(c?1:0),(s<<1)+(u?1:0),Math.round(63*a)+128,Math.round(63*l)+128,1+(0===p?0:p<0?-1:1)|(63&_)<<2,_>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const g=f.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,g,this.e2),f.primitiveLength++),u?this.e2=g:this.e1=g}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,s){this.distance+=e.dist(s),this.updateScaledDistance()}}let sd,od;Nl("LineBucket",Bu,{omit:["layers","patternFeatures"]});var ad={get paint(){return od=od||new Us({"line-opacity":new Ls(ve.paint_line["line-opacity"]),"line-color":new Ls(ve.paint_line["line-color"]),"line-translate":new $s(ve.paint_line["line-translate"]),"line-translate-anchor":new $s(ve.paint_line["line-translate-anchor"]),"line-width":new Ls(ve.paint_line["line-width"]),"line-gap-width":new Ls(ve.paint_line["line-gap-width"]),"line-offset":new Ls(ve.paint_line["line-offset"]),"line-blur":new Ls(ve.paint_line["line-blur"]),"line-dasharray":new Ds(ve.paint_line["line-dasharray"]),"line-pattern":new Os(ve.paint_line["line-pattern"]),"line-gradient":new Rs(ve.paint_line["line-gradient"])})},get layout(){return sd=sd||new Us({"line-cap":new $s(ve.layout_line["line-cap"]),"line-join":new Ls(ve.layout_line["line-join"]),"line-miter-limit":new $s(ve.layout_line["line-miter-limit"]),"line-round-limit":new $s(ve.layout_line["line-round-limit"]),"line-sort-key":new Ls(ve.layout_line["line-sort-key"])})}};class $u extends Ls{possiblyEvaluate(e,s){return s=new Is(Math.floor(s.zoom),{now:s.now,fadeDuration:s.fadeDuration,zoomHistory:s.zoomHistory,transition:s.transition}),super.possiblyEvaluate(e,s)}evaluate(e,s,a,l){return s=xt({},s,{zoom:Math.floor(s.zoom)}),super.evaluate(e,s,a,l)}}let ld;class Ou extends Ns{constructor(e){super(e,ad),this.gradientVersion=0,ld||(ld=new $u(ad.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 ar,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,s){super.recalculate(e,s),this.paint._values["line-floorwidth"]=ld.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Bu(e)}queryRadius(e){const s=e,a=cd(uh("line-width",this,s),uh("line-gap-width",this,s)),l=uh("line-offset",this,s);return a/2+Math.abs(l)+dh(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:a,geometry:c,transform:u,pixelsToTileUnits:p}){const f=ph(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-u.bearingInRadians,p),_=p/2*cd(this.paint.get("line-width").evaluate(s,a),this.paint.get("line-gap-width").evaluate(s,a)),g=this.paint.get("line-offset").evaluate(s,a);return g&&(c=function(e,s){const a=[];for(let c=0;c=3)for(let s=0;s0?s+2*e:e}const hd=_c([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),ud=_c([{name:"a_projected_pos",components:3,type:"Float32"}],4);_c([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const dd=_c([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);_c([{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 pd=_c([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),fd=_c([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function md(e,s,a){return e.sections.forEach((e=>{e.text=function(e,s,a){const l=s.layout.get("text-transform").evaluate(a,{});return"uppercase"===l?e=e.toLocaleUpperCase():"lowercase"===l&&(e=e.toLocaleLowerCase()),hc.applyArabicShaping&&(e=hc.applyArabicShaping(e)),e}(e.text,s,a)})),e}_c([{name:"triangle",components:3,type:"Uint16"}]),_c([{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"}]),_c([{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"}]),_c([{type:"Float32",name:"offsetX"}]),_c([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),_c([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const _d={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var gd=24;const yd=4294967296,xd=1/yd,vd="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Ju{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,s,a=this.length){for(;this.pos>3,c=this.pos;this.type=7&a,e(l,s,this),this.pos===c&&this.skip(a)}return s}readMessage(e,s){return this.readFields(e,s,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*yd;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*yd;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const s=this.buf;let a,l;return l=s[this.pos++],a=127&l,l<128?a:(l=s[this.pos++],a|=(127&l)<<7,l<128?a:(l=s[this.pos++],a|=(127&l)<<14,l<128?a:(l=s[this.pos++],a|=(127&l)<<21,l<128?a:(l=s[this.pos],a|=(15&l)<<28,function(e,s,a){const l=a.buf;let c,u;if(u=l[a.pos++],c=(112&u)>>4,u<128)return bd(e,c,s);if(u=l[a.pos++],c|=(127&u)<<3,u<128)return bd(e,c,s);if(u=l[a.pos++],c|=(127&u)<<10,u<128)return bd(e,c,s);if(u=l[a.pos++],c|=(127&u)<<17,u<128)return bd(e,c,s);if(u=l[a.pos++],c|=(127&u)<<24,u<128)return bd(e,c,s);if(u=l[a.pos++],c|=(1&u)<<31,u<128)return bd(e,c,s);throw new Error("Expected varint not more than 10 bytes")}(a,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,s=this.pos;return this.pos=e,e-s>=12&&vd?vd.decode(this.buf.subarray(s,e)):function(e,s,a){let l="",c=s;for(;c239?4:s>223?3:s>191?2:1;if(c+g>a)break;1===g?s<128&&(_=s):2===g?(u=e[c+1],128==(192&u)&&(_=(31&s)<<6|63&u,_<=127&&(_=null))):3===g?(u=e[c+1],p=e[c+2],128==(192&u)&&128==(192&p)&&(_=(15&s)<<12|(63&u)<<6|63&p,(_<=2047||_>=55296&&_<=57343)&&(_=null))):4===g&&(u=e[c+1],p=e[c+2],f=e[c+3],128==(192&u)&&128==(192&p)&&128==(192&f)&&(_=(15&s)<<18|(63&u)<<12|(63&p)<<6|63&f,(_<=65535||_>=1114112)&&(_=null))),null===_?(_=65533,g=1):_>65535&&(_-=65536,l+=String.fromCharCode(_>>>10&1023|55296),_=56320|1023&_),l+=String.fromCharCode(_),c+=g}return l}(this.buf,s,e)}readBytes(){const e=this.readVarint()+this.pos,s=this.buf.subarray(this.pos,e);return this.pos=e,s}readPackedVarint(e=[],s){const a=this.readPackedEnd();for(;this.pos127;);else if(2===s)this.pos=this.readVarint()+this.pos;else if(5===s)this.pos+=4;else{if(1!==s)throw new Error(`Unimplemented type: ${s}`);this.pos+=8}}writeTag(e,s){this.writeVarint(e<<3|s)}realloc(e){let s=this.length||16;for(;s268435455||e<0?function(e,s){let a,l;if(e>=0?(a=e%4294967296|0,l=e/4294967296|0):(a=~(-e%4294967296),l=~(-e/4294967296),4294967295^a?a=a+1|0:(a=0,l=l+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),function(e,s,a){a.buf[a.pos++]=127&e|128,e>>>=7,a.buf[a.pos++]=127&e|128,e>>>=7,a.buf[a.pos++]=127&e|128,e>>>=7,a.buf[a.pos++]=127&e|128,a.buf[a.pos]=127&(e>>>=7)}(a,0,s),function(e,s){const a=(7&e)<<4;s.buf[s.pos++]|=a|((e>>>=3)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e)))))}(l,s)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const s=this.pos;this.pos=function(e,s,a){for(let l,c,u=0;u55295&&l<57344){if(!c){l>56319||u+1===s.length?(e[a++]=239,e[a++]=191,e[a++]=189):c=l;continue}if(l<56320){e[a++]=239,e[a++]=191,e[a++]=189,c=l;continue}l=c-55296<<10|l-56320|65536,c=null}else c&&(e[a++]=239,e[a++]=191,e[a++]=189,c=null);l<128?e[a++]=l:(l<2048?e[a++]=l>>6|192:(l<65536?e[a++]=l>>12|224:(e[a++]=l>>18|240,e[a++]=l>>12&63|128),e[a++]=l>>6&63|128),e[a++]=63&l|128)}return a}(this.buf,e,this.pos);const a=this.pos-s;a>=128&&wd(s,a,this),this.pos=s-1,this.writeVarint(a),this.pos+=a}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const s=e.length;this.writeVarint(s),this.realloc(s);for(let a=0;a=128&&wd(a,l,this),this.pos=a-1,this.writeVarint(l),this.pos+=l}writeMessage(e,s,a){this.writeTag(e,2),this.writeRawMessage(s,a)}writePackedVarint(e,s){s.length&&this.writeMessage(e,Td,s)}writePackedSVarint(e,s){s.length&&this.writeMessage(e,Pd,s)}writePackedBoolean(e,s){s.length&&this.writeMessage(e,Cd,s)}writePackedFloat(e,s){s.length&&this.writeMessage(e,Sd,s)}writePackedDouble(e,s){s.length&&this.writeMessage(e,Md,s)}writePackedFixed32(e,s){s.length&&this.writeMessage(e,Id,s)}writePackedSFixed32(e,s){s.length&&this.writeMessage(e,Ed,s)}writePackedFixed64(e,s){s.length&&this.writeMessage(e,Ad,s)}writePackedSFixed64(e,s){s.length&&this.writeMessage(e,zd,s)}writeBytesField(e,s){this.writeTag(e,2),this.writeBytes(s)}writeFixed32Field(e,s){this.writeTag(e,5),this.writeFixed32(s)}writeSFixed32Field(e,s){this.writeTag(e,5),this.writeSFixed32(s)}writeFixed64Field(e,s){this.writeTag(e,1),this.writeFixed64(s)}writeSFixed64Field(e,s){this.writeTag(e,1),this.writeSFixed64(s)}writeVarintField(e,s){this.writeTag(e,0),this.writeVarint(s)}writeSVarintField(e,s){this.writeTag(e,0),this.writeSVarint(s)}writeStringField(e,s){this.writeTag(e,2),this.writeString(s)}writeFloatField(e,s){this.writeTag(e,5),this.writeFloat(s)}writeDoubleField(e,s){this.writeTag(e,1),this.writeDouble(s)}writeBooleanField(e,s){this.writeVarintField(e,+s)}}function bd(e,s,a){return a?4294967296*s+(e>>>0):4294967296*(s>>>0)+(e>>>0)}function wd(e,s,a){const l=s<=16383?1:s<=2097151?2:s<=268435455?3:Math.floor(Math.log(s)/(7*Math.LN2));a.realloc(l);for(let s=a.pos-1;s>=e;s--)a.buf[s+l]=a.buf[s]}function Td(e,s){for(let a=0;as.h-e.h));const l=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(s/.95)),a),h:1/0}];let c=0,u=0;for(const s of e)for(let e=l.length-1;e>=0;e--){const a=l[e];if(!(s.w>a.w||s.h>a.h)){if(s.x=a.x,s.y=a.y,u=Math.max(u,s.y+s.h),c=Math.max(c,s.x+s.w),s.w===a.w&&s.h===a.h){const s=l.pop();s&&e=0&&a>=e&&Od[this.text.charCodeAt(a)];a--)s--;this.text=this.text.substring(e,s),this.sectionIndex=this.sectionIndex.slice(e,s)}substring(e,s){const a=new gc;return a.text=this.text.substring(e,s),a.sectionIndex=this.sectionIndex.slice(e,s),a.sections=this.sections,a}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,s)=>Math.max(e,this.sections[s].scale)),0)}getMaxImageSize(e){let s=0,a=0;for(let l=0;l=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Fd(e,a,l,c,u,p,f,_,g,y,x,v,w,C,A){const k=gc.fromFeature(e,u);let D;v===s.ao.vertical&&k.verticalizePunctuation();const{processBidirectionalText:R,processStyledBidirectionalText:L}=hc;if(R&&1===k.sections.length){D=[];const e=R(k.toString(),qd(k,y,p,a,c,C));for(const s of e){const e=new gc;e.text=s,e.sections=k.sections;for(let a=0;a=0;let g=0;for(let a=0;ag){const e=Math.ceil(u/g);c*=e/p,p=e}return{x1:l,y1:c,x2:l+u,y2:c+p}}function ip(e,s,a,l,c,u){const p=e.image;let f;if(p.content){const e=p.content,s=p.pixelRatio||1;f=[e[0]/s,e[1]/s,p.displaySize[0]-e[2]/s,p.displaySize[1]-e[3]/s]}const _=s.left*u,g=s.right*u;let y,x,v,w;"width"===a||"both"===a?(w=c[0]+_-l[3],x=c[0]+g+l[1]):(w=c[0]+(_+g-p.displaySize[0])/2,x=w+p.displaySize[0]);const C=s.top*u,A=s.bottom*u;return"height"===a||"both"===a?(y=c[1]+C-l[0],v=c[1]+A+l[2]):(y=c[1]+(C+A-p.displaySize[1])/2,v=y+p.displaySize[1]),{image:p,top:y,right:x,bottom:v,left:w,collisionPadding:f}}const rp=128,np=32640;function sp(e,s){const{expression:a}=s;if("constant"===a.kind)return{kind:"constant",layoutSize:a.evaluate(new Is(e+1))};if("source"===a.kind)return{kind:"source"};{const{zoomStops:s,interpolationType:l}=a;let c=0;for(;ce.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const a=this.layers[0]._unevaluatedLayout._values;this.textSizeData=sp(this.zoom,a["text-size"]),this.iconSizeData=sp(this.zoom,a["icon-size"]);const l=this.layers[0].layout,c=l.get("symbol-sort-key"),u=l.get("symbol-z-order");this.canOverlap="never"!==op(l,"text-overlap","text-allow-overlap")||"never"!==op(l,"icon-overlap","icon-allow-overlap")||l.get("text-ignore-placement")||l.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==u&&!c.isConstant(),this.sortFeaturesByY=("viewport-y"===u||"auto"===u&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===l.get("symbol-placement")&&(this.writingModes=l.get("text-writing-mode").map((e=>s.ao[e]))),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Xc(new bo(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new Xc(new bo(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new Aa,this.lineVertexArray=new ka,this.symbolInstances=new Sa,this.textAnchorOffsets=new Ia}calculateGlyphDependencies(e,s,a,l,c){for(let u=0;u0)&&("constant"!==p.value.kind||p.value.value.length>0),y="constant"!==_.value.kind||!!_.value.value||Object.keys(_.parameters).length>0,x=u.get("symbol-sort-key");if(this.features=[],!g&&!y)return;const v=a.iconDependencies,w=a.glyphDependencies,C=a.availableImages,A=new Is(this.zoom,{globalState:this.globalState});for(const{feature:a,id:f,index:_,sourceLayerIndex:k}of e){const e=c._featureFilter.needGeometry,D=Uc(a,e);if(!c._featureFilter.filter(A,D,l))continue;let R,L;if(e||(D.geometry=Vc(a)),g){const e=c.getValueAndResolveTokens("text-field",D,l,C),s=Ce.factory(e),a=this.hasRTLText=this.hasRTLText||up(s);(!a||"unavailable"===hc.getRTLTextPluginStatus()||a&&hc.isParsed())&&(R=md(s,c,D))}if(y){const e=c.getValueAndResolveTokens("icon-image",D,l,C);L=e instanceof Le?e:Le.fromString(e)}if(!R&&!L)continue;const B=this.sortFeaturesByKey?x.evaluate(D,{},l):void 0;if(this.features.push({id:f,text:R,icon:L,index:_,sourceLayerIndex:k,geometry:D.geometry,properties:a.properties,type:lu.types[a.type],sortKey:B}),L&&(v[L.name]=!0),R){const e=p.evaluate(D,{},l).join(","),a="viewport"!==u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(s.ao.vertical)>=0;for(const s of R.sections)if(s.image)v[s.image.name]=!0;else{const l=Jl(R.toString()),c=s.fontStack||e,u=w[c]=w[c]||{};this.calculateGlyphDependencies(s.text,u,a,this.allowVerticalPlacement,l)}}}"line"===u.get("symbol-placement")&&(this.features=function(e){const s={},a={},l=[];let c=0;function u(s){l.push(e[s]),c++}function p(e,s,c){const u=a[e];return delete a[e],a[s]=u,l[u].geometry[0].pop(),l[u].geometry[0]=l[u].geometry[0].concat(c[0]),u}function f(e,a,c){const u=s[a];return delete s[a],s[e]=u,l[u].geometry[0].shift(),l[u].geometry[0]=c[0].concat(l[u].geometry[0]),u}function _(e,s,a){const l=a?s[0][s[0].length-1]:s[0][0];return`${e}:${l.x}:${l.y}`}for(let g=0;ge.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,s)=>e.sortKey-s.sortKey))}update(e,s,a){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,s,this.layers,a),this.icon.programConfigurations.updatePaintArrays(e,s,this.layers,a))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,s){const a=this.lineVertexArray.length;if(void 0!==e.segment){let a=e.dist(s[e.segment+1]),l=e.dist(s[e.segment]);const c={};for(let l=e.segment+1;l=0;a--)c[a]={x:s[a].x,y:s[a].y,tileUnitDistanceFromAnchor:l},a>0&&(l+=s[a-1].dist(s[a]));for(let e=0;e0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,s){const a=e.placedSymbolArray.get(s),l=a.vertexStartIndex+4*a.numGlyphs;for(let s=a.vertexStartIndex;sl[e]-l[s]||c[s]-c[e])),u}addToSortKeyRanges(e,s){const a=this.sortKeyRanges[this.sortKeyRanges.length-1];a&&a.sortKey===s?a.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:s,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const s=this.symbolInstances.get(e);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach(((e,s,a)=>{e>=0&&a.indexOf(e)===s&&this.addIndicesForPlacedSymbol(this.text,e)})),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let dp,pp;Nl("SymbolBucket",Yc,{omit:["layers","collisionBoxArray","features","compareText"]}),Yc.MAX_GLYPHS=65535,Yc.addDynamicAttributes=hp;var fp={get paint(){return pp=pp||new Us({"icon-opacity":new Ls(ve.paint_symbol["icon-opacity"]),"icon-color":new Ls(ve.paint_symbol["icon-color"]),"icon-halo-color":new Ls(ve.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ls(ve.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ls(ve.paint_symbol["icon-halo-blur"]),"icon-translate":new $s(ve.paint_symbol["icon-translate"]),"icon-translate-anchor":new $s(ve.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ls(ve.paint_symbol["text-opacity"]),"text-color":new Ls(ve.paint_symbol["text-color"],{runtimeType:li,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Ls(ve.paint_symbol["text-halo-color"]),"text-halo-width":new Ls(ve.paint_symbol["text-halo-width"]),"text-halo-blur":new Ls(ve.paint_symbol["text-halo-blur"]),"text-translate":new $s(ve.paint_symbol["text-translate"]),"text-translate-anchor":new $s(ve.paint_symbol["text-translate-anchor"])})},get layout(){return dp=dp||new Us({"symbol-placement":new $s(ve.layout_symbol["symbol-placement"]),"symbol-spacing":new $s(ve.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new $s(ve.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ls(ve.layout_symbol["symbol-sort-key"]),"symbol-z-order":new $s(ve.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new $s(ve.layout_symbol["icon-allow-overlap"]),"icon-overlap":new $s(ve.layout_symbol["icon-overlap"]),"icon-ignore-placement":new $s(ve.layout_symbol["icon-ignore-placement"]),"icon-optional":new $s(ve.layout_symbol["icon-optional"]),"icon-rotation-alignment":new $s(ve.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ls(ve.layout_symbol["icon-size"]),"icon-text-fit":new $s(ve.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new $s(ve.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ls(ve.layout_symbol["icon-image"]),"icon-rotate":new Ls(ve.layout_symbol["icon-rotate"]),"icon-padding":new Ls(ve.layout_symbol["icon-padding"]),"icon-keep-upright":new $s(ve.layout_symbol["icon-keep-upright"]),"icon-offset":new Ls(ve.layout_symbol["icon-offset"]),"icon-anchor":new Ls(ve.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new $s(ve.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new $s(ve.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new $s(ve.layout_symbol["text-rotation-alignment"]),"text-field":new Ls(ve.layout_symbol["text-field"]),"text-font":new Ls(ve.layout_symbol["text-font"]),"text-size":new Ls(ve.layout_symbol["text-size"]),"text-max-width":new Ls(ve.layout_symbol["text-max-width"]),"text-line-height":new $s(ve.layout_symbol["text-line-height"]),"text-letter-spacing":new Ls(ve.layout_symbol["text-letter-spacing"]),"text-justify":new Ls(ve.layout_symbol["text-justify"]),"text-radial-offset":new Ls(ve.layout_symbol["text-radial-offset"]),"text-variable-anchor":new $s(ve.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Ls(ve.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Ls(ve.layout_symbol["text-anchor"]),"text-max-angle":new $s(ve.layout_symbol["text-max-angle"]),"text-writing-mode":new $s(ve.layout_symbol["text-writing-mode"]),"text-rotate":new Ls(ve.layout_symbol["text-rotate"]),"text-padding":new $s(ve.layout_symbol["text-padding"]),"text-keep-upright":new $s(ve.layout_symbol["text-keep-upright"]),"text-transform":new Ls(ve.layout_symbol["text-transform"]),"text-offset":new Ls(ve.layout_symbol["text-offset"]),"text-allow-overlap":new $s(ve.layout_symbol["text-allow-overlap"]),"text-overlap":new $s(ve.layout_symbol["text-overlap"]),"text-ignore-placement":new $s(ve.layout_symbol["text-ignore-placement"]),"text-optional":new $s(ve.layout_symbol["text-optional"])})}};class Wc{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:ei,this.defaultValue=e}evaluate(e){if(e.formattedSection){const s=this.defaultValue.property.overrides;if(s&&s.hasOverride(e.formattedSection))return s.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Nl("FormatSectionOverride",Wc,{omit:["defaultValue"]});class Qc extends Ns{constructor(e){super(e,fp)}recalculate(e,s){if(super.recalculate(e,s),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const s=[];for(const a of e)s.indexOf(a)<0&&s.push(a);this.layout._values["text-writing-mode"]=s}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,s,a,l){const c=this.layout.get(e).evaluate(s,{},a,l),u=this._unevaluatedLayout._values[e];return u.isDataDriven()||Ys(u.value)||!c?c:function(e,s){return s.replace(/{([^{}]+)}/g,((s,a)=>e&&a in e?String(e[a]):""))}(s.properties,c)}createBucket(e){return new Yc(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of fp.paint.overridableProperties){if(!Qc.hasPaintOverride(this.layout,e))continue;const s=this.paint.get(e),a=new Wc(s),l=new ti(a,s.property.specification);let c=null;c="constant"===s.value.kind||"source"===s.value.kind?new ni("source",l):new ii("composite",l,s.value.zoomStops),this.paint._values[e]=new Ts(s.property,c,s.parameters)}}_handleOverridablePaintPropertyUpdate(e,s,a){return!(!this.layout||s.isDataDriven()||a.isDataDriven())&&Qc.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,s){const a=e.get("text-field"),l=fp.paint.properties[s];let c=!1;const u=e=>{for(const s of e)if(l.overrides&&l.overrides.hasOverride(s))return void(c=!0)};if("constant"===a.value.kind&&a.value.value instanceof Ce)u(a.value.value.sections);else if("source"===a.value.kind){const e=s=>{c||(s instanceof Ne&&gr(s.value)===yi?u(s.value.sections):s instanceof Ir?u(s.sections):s.eachChild(e))},s=a.value;s._styleExpression&&e(s._styleExpression.expression)}return c}}let mp;var _p={get paint(){return mp=mp||new Us({"background-color":new $s(ve.paint_background["background-color"]),"background-pattern":new Ds(ve.paint_background["background-pattern"]),"background-opacity":new $s(ve.paint_background["background-opacity"])})}};class rh extends Ns{constructor(e){super(e,_p)}}let gp;var yp={get paint(){return gp=gp||new Us({"raster-opacity":new $s(ve.paint_raster["raster-opacity"]),"raster-hue-rotate":new $s(ve.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new $s(ve.paint_raster["raster-brightness-min"]),"raster-brightness-max":new $s(ve.paint_raster["raster-brightness-max"]),"raster-saturation":new $s(ve.paint_raster["raster-saturation"]),"raster-contrast":new $s(ve.paint_raster["raster-contrast"]),"raster-resampling":new $s(ve.paint_raster["raster-resampling"]),"raster-fade-duration":new $s(ve.paint_raster["raster-fade-duration"])})}};class sh extends Ns{constructor(e){super(e,yp)}}class ah extends Ns{constructor(e){super(e,{}),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 oh{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 xp={once:!0},vp=6371008.8;class ch{constructor(e,s){if(isNaN(e)||isNaN(s))throw new Error(`Invalid LngLat object: (${e}, ${s})`);if(this.lng=+e,this.lat=+s,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ch(pt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const s=Math.PI/180,a=this.lat*s,l=e.lat*s,c=Math.sin(a)*Math.sin(l)+Math.cos(a)*Math.cos(l)*Math.cos((e.lng-this.lng)*s);return vp*Math.acos(Math.min(c,1))}static convert(e){if(e instanceof ch)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new ch(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new ch(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 bp=2*Math.PI*vp;function wp(e){return bp*Math.cos(e*Math.PI/180)}function Tp(e){return(180+e)/360}function Pp(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Sp(e,s){return e/wp(s)}function Mp(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Cp(e,s){return e*wp(Mp(s))}class xh{constructor(e,s,a=0){this.x=+e,this.y=+s,this.z=+a}static fromLngLat(e,s=0){const a=ch.convert(e);return new xh(Tp(a.lng),Pp(a.lat),Sp(s,a.lat))}toLngLat(){return new ch(360*this.x-180,Mp(this.y))}toAltitude(){return Cp(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/bp*(e=Mp(this.y),1/Math.cos(e*Math.PI/180));var e}}function Ip(e,s,a){var l=2*Math.PI*6378137/256/Math.pow(2,a);return[e*l-2*Math.PI*6378137/2,s*l-2*Math.PI*6378137/2]}class bh{constructor(e,s,a){if(!function(e,s,a){return!(e<0||e>25||a<0||a>=Math.pow(2,e)||s<0||s>=Math.pow(2,e))}(e,s,a))throw new Error(`x=${s}, y=${a}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=s,this.y=a,this.key=Ep(0,e,e,s,a)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,s,a){const l=(u=this.y,p=this.z,f=Ip(256*(c=this.x),256*(u=Math.pow(2,p)-u-1),p),_=Ip(256*(c+1),256*(u+1),p),f[0]+","+f[1]+","+_[0]+","+_[1]);var c,u,p,f,_;const g=function(e,s,a){let l,c="";for(let u=e;u>0;u--)l=1<1?"@2x":"").replace(/{quadkey}/g,g).replace(/{bbox-epsg-3857}/g,l)}isChildOf(e){const s=this.z-e.z;return s>0&&e.x===this.x>>s&&e.y===this.y>>s}getTilePoint(e){const s=Math.pow(2,this.z);return new l((e.x*s-this.x)*rt,(e.y*s-this.y)*rt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class wh{constructor(e,s){this.wrap=e,this.canonical=s,this.key=Ep(e,s.z,s.z,s.x,s.y)}}class _h{constructor(e,s,a,l,c){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${a}`);this.overscaledZ=e,this.wrap=s,this.canonical=new bh(a,+l,+c),this.key=Ep(s,e,a,l,c)}clone(){return new _h(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-e;return e>this.canonical.z?new _h(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new _h(e,this.wrap,e,this.canonical.x>>s,this.canonical.y>>s)}calculateScaledKey(e,s){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const a=this.canonical.z-e;return e>this.canonical.z?Ep(this.wrap*+s,e,this.canonical.z,this.canonical.x,this.canonical.y):Ep(this.wrap*+s,e,e,this.canonical.x>>a,this.canonical.y>>a)}isChildOf(e){if(e.wrap!==this.wrap)return!1;const s=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>s&&e.canonical.y===this.canonical.y>>s}children(e){if(this.overscaledZ>=e)return[new _h(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const s=this.canonical.z+1,a=2*this.canonical.x,l=2*this.canonical.y;return[new _h(s,this.wrap,s,a,l),new _h(s,this.wrap,s,a+1,l),new _h(s,this.wrap,s,a,l+1),new _h(s,this.wrap,s,a+1,l+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ythis.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const s=new kh;return s.extend(e(new l(this.minX,this.minY))),s.extend(e(new l(this.maxX,this.minY))),s.extend(e(new l(this.minX,this.maxY))),s.extend(e(new l(this.maxX,this.maxY))),s}static fromPoints(e){const s=new kh;for(const a of e)s.extend(a);return s}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class Mh{constructor(e){this._stringToNumber={},this._numberToString=[];for(let s=0;s=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Ih{constructor(e,s,a,l,c){this.type="Feature",this._vectorTileFeature=e,e._z=s,e._x=a,e._y=l,this.properties=e.properties,this.id=c}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const s in this)"_geometry"!==s&&"_vectorTileFeature"!==s&&(e[s]=this[s]);return e}}class zh{constructor(e,s){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new is(rt,16,0),this.grid3D=new is(rt,16,0),this.featureIndexArray=new Pa,this.promoteId=s}insert(e,s,a,l,c,u){const p=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(a,l,c);const f=u?this.grid3D:this.grid;for(let e=0;e=0&&l[3]>=0&&f.insert(p,l[0],l[1],l[2],l[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new fu(new Ju(this.rawTileData)).layers,this.sourceLayerCoder=new Mh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,s,a,c){this.loadVTLayers();const u=e.params,p=rt/e.tileSize/e.scale,f=Xo(u.filter),_=e.queryGeometry,g=e.queryPadding*p,y=kh.fromPoints(_),x=this.grid.query(y.minX-g,y.minY-g,y.maxX+g,y.maxY+g),v=kh.fromPoints(e.cameraQueryGeometry).expandBy(g),w=this.grid3D.query(v.minX,v.minY,v.maxX,v.maxY,((s,a,c,u)=>function(e,s,a,c,u){for(const l of e)if(s<=l.x&&a<=l.y&&c>=l.x&&u>=l.y)return!0;const p=[new l(s,a),new l(s,u),new l(c,u),new l(c,a)];if(e.length>2)for(const s of p)if(lh(e,s))return!0;for(let s=0;s(v||(v=Vc(s)),a.queryIntersectsFeature({queryGeometry:_,feature:s,featureState:l,geometry:v,zoom:this.z,transform:e.transform,pixelsToTileUnits:p,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return C}loadMatchingFeature(e,s,a,l,c,u,p,f,_,g,y){const x=this.bucketLayerIDs[s];if(u&&!x.some((e=>u.has(e))))return;const v=this.sourceLayerCoder.decode(a),w=this.vtLayers[v].feature(l);if(c.needGeometry){const e=Uc(w,!0);if(!c.filter(new Is(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!c.filter(new Is(this.tileID.overscaledZ),w))return;const C=this.getId(w,v);for(let s=0;s{const p=s instanceof Fs?s.get(u):null;return p&&p.evaluate?p.evaluate(a,l,c):p}))}function kp(e,s){return s-e}function Dp(e,s,a,c,u){const p=[];for(let f=0;f=c&&y.x>=c||(f.x>=c?f=new l(c,f.y+(c-f.x)/(y.x-f.x)*(y.y-f.y))._round():y.x>=c&&(y=new l(c,f.y+(c-f.x)/(y.x-f.x)*(y.y-f.y))._round()),f.y>=u&&y.y>=u||(f.y>=u?f=new l(f.x+(u-f.y)/(y.y-f.y)*(y.x-f.x),u)._round():y.y>=u&&(y=new l(f.x+(u-f.y)/(y.y-f.y)*(y.x-f.x),u)._round()),g&&f.equals(g[g.length-1])||(g=[f],p.push(g)),g.push(y)))))}}return p}Nl("FeatureIndex",zh,{omit:["rawTileData","sourceLayerCoder"]});class Bh extends l{constructor(e,s,a,l){super(e,s),this.angle=a,void 0!==l&&(this.segment=l)}clone(){return new Bh(this.x,this.y,this.angle,this.segment)}}function Rp(e,s,a,l,c){if(void 0===s.segment||0===a)return!0;let u=s,p=s.segment+1,f=0;for(;f>-a/2;){if(p--,p<0)return!1;f-=e[p].dist(u),u=e[p]}f+=e[p].dist(e[p+1]),p++;const _=[];let g=0;for(;fl;)g-=_.shift().angleDelta;if(g>c)return!1;p++,f+=s.dist(a)}return!0}function Lp(e){let s=0;for(let a=0;ag){const y=(g-_)/u,x=Br.number(l.x,c.x,y),v=Br.number(l.y,c.y,y),w=new Bh(x,v,c.angleTo(l),a);return w._round(),!p||Rp(e,w,f,p,s)?w:void 0}_+=u}}function jp(e,s,a,l,c,u,p,f,_){const g=Bp(l,u,p),y=Fp(l,c),x=y*p,v=0===e[0].x||e[0].x===_||0===e[0].y||e[0].y===_;return s-x=0&&D<_&&R>=0&&R<_&&v-g>=0&&v+g<=y){const a=new Bh(D,R,A,s);a._round(),l&&!Rp(e,a,u,l,c)||w.push(a)}}x+=C}return f||w.length||p||(w=Vp(e,x/2,a,l,c,u,p,!0,_)),w}function Up(e,s,a,c){const u=[],p=e.image,f=p.pixelRatio,_=p.paddedRect.w-2,g=p.paddedRect.h-2;let y={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const x=p.stretchX||[[0,_]],v=p.stretchY||[[0,g]],w=(e,s)=>e+s[1]-s[0],C=x.reduce(w,0),A=v.reduce(w,0),k=_-C,D=g-A;let R=0,L=C,B=0,O=A,j=0,U=k,N=0,Z=D;if(p.content&&c){const s=p.content,a=s[2]-s[0],l=s[3]-s[1];(p.textFitWidth||p.textFitHeight)&&(y=ep(e)),R=Np(x,0,s[0]),B=Np(v,0,s[1]),L=Np(x,s[0],s[2]),O=Np(v,s[1],s[3]),j=s[0]-R,N=s[1]-B,U=a-L,Z=l-O}const J=y.x1,Q=y.y1,et=y.x2-J,it=y.y2-Q,rt=(e,c,u,_)=>{const g=Zp(e.stretch-R,L,et,J),y=Gp(e.fixed-j,U,e.stretch,C),x=Zp(c.stretch-B,O,it,Q),v=Gp(c.fixed-N,Z,c.stretch,A),w=Zp(u.stretch-R,L,et,J),k=Gp(u.fixed-j,U,u.stretch,C),D=Zp(_.stretch-B,O,it,Q),rt=Gp(_.fixed-N,Z,_.stretch,A),nt=new l(g,x),st=new l(w,x),ot=new l(w,D),at=new l(g,D),lt=new l(y/f,v/f),ct=new l(k/f,rt/f),ht=s*Math.PI/180;if(ht){const e=Math.sin(ht),s=Math.cos(ht),a=[s,-e,e,s];nt._matMult(a),st._matMult(a),at._matMult(a),ot._matMult(a)}const pt=e.stretch+e.fixed,xt=c.stretch+c.fixed;return{tl:nt,tr:st,bl:at,br:ot,tex:{x:p.paddedRect.x+1+pt,y:p.paddedRect.y+1+xt,w:u.stretch+u.fixed-pt,h:_.stretch+_.fixed-xt},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:lt,pixelOffsetBR:ct,minFontScaleX:U/f/et,minFontScaleY:Z/f/it,isSDF:a}};if(c&&(p.stretchX||p.stretchY)){const e=$p(x,k,C),s=$p(v,D,A);for(let a=0;a0&&(l=Math.max(10,l),this.circleDiameter=l)}else{const g=(null===(x=p.image)||void 0===x?void 0:x.content)&&(p.image.textFitWidth||p.image.textFitHeight)?ep(p):{x1:p.left,y1:p.top,x2:p.right,y2:p.bottom};g.y1=g.y1*f-_[0],g.y2=g.y2*f+_[2],g.x1=g.x1*f-_[3],g.x2=g.x2*f+_[1];const v=p.collisionPadding;if(v&&(g.x1-=v[0]*f,g.y1-=v[1]*f,g.x2+=v[2]*f,g.y2+=v[3]*f),y){const e=new l(g.x1,g.y1),s=new l(g.x2,g.y1),a=new l(g.x1,g.y2),c=new l(g.x2,g.y2),u=y*Math.PI/180;e._rotate(u),s._rotate(u),a._rotate(u),c._rotate(u),g.x1=Math.min(e.x,s.x,a.x,c.x),g.x2=Math.max(e.x,s.x,a.x,c.x),g.y1=Math.min(e.y,s.y,a.y,c.y),g.y2=Math.max(e.y,s.y,a.y,c.y)}e.emplaceBack(s.x,s.y,g.x1,g.y1,g.x2,g.y2,a,c,u)}this.boxEndIndex=e.length}}class Xh{constructor(e=[],s=(e,s)=>es?1:0){if(this.data=e,this.length=this.data.length,this.compare=s,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],s=this.data.pop();return--this.length>0&&(this.data[0]=s,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:s,compare:a}=this,l=s[e];for(;e>0;){const c=e-1>>1,u=s[c];if(a(l,u)>=0)break;s[e]=u,e=c}s[e]=l}_down(e){const{data:s,compare:a}=this,l=this.length>>1,c=s[e];for(;e=0)break;s[e]=s[l],e=l}s[e]=c}}function qp(e,s=1,a=!1){const c=kh.fromPoints(e[0]),u=Math.min(c.width(),c.height());let p=u/2;const f=new Xh([],Wp),{minX:_,minY:g,maxX:y,maxY:x}=c;if(0===u)return new l(_,g);for(let s=_;sv.d||!v.d)&&(v=l,a&&console.log("found best %d after %d probes",Math.round(1e4*l.d)/1e4,w)),l.max-v.d<=s||(p=l.h/2,f.push(new Xp(l.p.x-p,l.p.y-p,p,e)),f.push(new Xp(l.p.x+p,l.p.y-p,p,e)),f.push(new Xp(l.p.x-p,l.p.y+p,p,e)),f.push(new Xp(l.p.x+p,l.p.y+p,p,e)),w+=4)}return a&&(console.log(`num probes: ${w}`),console.log(`best distance: ${v.d}`)),v.p}function Wp(e,s){return s.max-e.max}function Xp(s,a,c,u){(this||e).p=new l(s,a),(this||e).h=c,(this||e).d=function(e,s){let a=!1,l=1/0;for(let c=0;ce.y!=f.y>e.y&&e.x<(f.x-c.x)*(e.y-c.y)/(f.y-c.y)+c.x&&(a=!a),l=Math.min(l,ih(e,c,f))}}return(a?1:-1)*Math.sqrt(l)}((this||e).p,u),(this||e).max=(this||e).d+(this||e).h*Math.SQRT2}var Hp;s.aE=void 0,(Hp=s.aE||(s.aE={}))[Hp.center=1]="center",Hp[Hp.left=2]="left",Hp[Hp.right=3]="right",Hp[Hp.top=4]="top",Hp[Hp.bottom=5]="bottom",Hp[Hp["top-left"]=6]="top-left",Hp[Hp["top-right"]=7]="top-right",Hp[Hp["bottom-left"]=8]="bottom-left",Hp[Hp["bottom-right"]=9]="bottom-right";const Yp=Number.POSITIVE_INFINITY;function Kp(e,s){return s[1]!==Yp?function(e,s,a){let l=0,c=0;switch(s=Math.abs(s),a=Math.abs(a),e){case"top-right":case"top-left":case"top":c=a-7;break;case"bottom-right":case"bottom-left":case"bottom":c=7-a}switch(e){case"top-right":case"bottom-right":case"right":l=-s;break;case"top-left":case"bottom-left":case"left":l=s}return[l,c]}(e,s[0],s[1]):function(e,s){let a=0,l=0;s<0&&(s=0);const c=s/Math.SQRT2;switch(e){case"top-right":case"top-left":l=c-7;break;case"bottom-right":case"bottom-left":l=7-c;break;case"bottom":l=7-s;break;case"top":l=s-7}switch(e){case"top-right":case"bottom-right":a=-c;break;case"top-left":case"bottom-left":a=c;break;case"left":a=s;break;case"right":a=-s}return[a,l]}(e,s[0])}function Jp(e,s,a){var l;const c=e.layout,u=null===(l=c.get("text-variable-anchor-offset"))||void 0===l?void 0:l.evaluate(s,{},a);if(u){const e=u.values,s=[];for(let a=0;ae*gd));l.startsWith("top")?c[1]-=7:l.startsWith("bottom")&&(c[1]+=7),s[a+1]=c}return new $e(s)}const p=c.get("text-variable-anchor");if(p){let l;l=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[c.get("text-radial-offset").evaluate(s,{},a)*gd,Yp]:c.get("text-offset").evaluate(s,{},a).map((e=>e*gd));const u=[];for(const e of p)u.push(e,Kp(e,l));return new $e(u)}return null}function Qp(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 tf(e,a,l,c,u,p,f,_,g,y,x,v){let w=p.textMaxSize.evaluate(a,{});void 0===w&&(w=f);const C=e.layers[0].layout,A=C.get("icon-offset").evaluate(a,{},x),k=rf(l.horizontal),D=f/24,R=e.tilePixelRatio*D,L=e.tilePixelRatio*w/24,B=e.tilePixelRatio*_,O=e.tilePixelRatio*C.get("symbol-spacing"),j=C.get("text-padding")*e.tilePixelRatio,U=function(e,s,a,l=1){const c=e.get("icon-padding").evaluate(s,{},a),u=c&&c.values;return[u[0]*l,u[1]*l,u[2]*l,u[3]*l]}(C,a,x,e.tilePixelRatio),N=C.get("text-max-angle")/180*Math.PI,Z="viewport"!==C.get("text-rotation-alignment")&&"point"!==C.get("symbol-placement"),J="map"===C.get("icon-rotation-alignment")&&"point"!==C.get("symbol-placement"),Q=C.get("symbol-placement"),et=O/2,it=C.get("icon-text-fit");let nt;c&&"none"!==it&&(e.allowVerticalPlacement&&l.vertical&&(nt=ip(c,l.vertical,it,C.get("icon-text-fit-padding"),A,D)),k&&(c=ip(c,k,it,C.get("icon-text-fit-padding"),A,D)));const st=x?v.line.getGranularityForZoomLevel(x.z):1,ot=(_,v)=>{v.x<0||v.x>=rt||v.y<0||v.y>=rt||function(e,a,l,c,u,p,f,_,g,y,x,v,w,C,A,k,D,R,L,B,O,j,U,N,Z){const J=e.addToLineVertexArray(a,l);let Q,et,it,rt,nt=0,st=0,ot=0,at=0,lt=-1,ct=-1;const ht={};let pt=Ac("");if(e.allowVerticalPlacement&&c.vertical){const e=_.layout.get("text-rotate").evaluate(O,{},N)+90;it=new Gh(g,a,y,x,v,c.vertical,w,C,A,e),f&&(rt=new Gh(g,a,y,x,v,f,D,R,A,e))}if(u){const l=_.layout.get("icon-rotate").evaluate(O,{}),c="none"!==_.layout.get("icon-text-fit"),p=Up(u,l,U,c),w=f?Up(f,l,U,c):void 0;et=new Gh(g,a,y,x,v,u,D,R,!1,l),nt=4*p.length;const C=e.iconSizeData;let A=null;"source"===C.kind?(A=[rp*_.layout.get("icon-size").evaluate(O,{})],A[0]>np&&kt(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===C.kind&&(A=[rp*j.compositeIconSizes[0].evaluate(O,{},N),rp*j.compositeIconSizes[1].evaluate(O,{},N)],(A[0]>np||A[1]>np)&&kt(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,p,A,B,L,O,s.ao.none,a,J.lineStartIndex,J.lineLength,-1,N),lt=e.icon.placedSymbolArray.length-1,w&&(st=4*w.length,e.addSymbols(e.icon,w,A,B,L,O,s.ao.vertical,a,J.lineStartIndex,J.lineLength,-1,N),ct=e.icon.placedSymbolArray.length-1)}const xt=Object.keys(c.horizontal);for(const l of xt){const u=c.horizontal[l];if(!Q){pt=Ac(u.text);const e=_.layout.get("text-rotate").evaluate(O,{},N);Q=new Gh(g,a,y,x,v,u,w,C,A,e)}const f=1===u.positionedLines.length;if(ot+=ef(e,a,u,p,_,A,O,k,J,c.vertical?s.ao.horizontal:s.ao.horizontalOnly,f?xt:[l],ht,lt,j,N),f)break}c.vertical&&(at+=ef(e,a,c.vertical,p,_,A,O,k,J,s.ao.vertical,["vertical"],ht,ct,j,N));const bt=Q?Q.boxStartIndex:e.collisionBoxArray.length,Tt=Q?Q.boxEndIndex:e.collisionBoxArray.length,Pt=it?it.boxStartIndex:e.collisionBoxArray.length,St=it?it.boxEndIndex:e.collisionBoxArray.length,Et=et?et.boxStartIndex:e.collisionBoxArray.length,Ft=et?et.boxEndIndex:e.collisionBoxArray.length,Nt=rt?rt.boxStartIndex:e.collisionBoxArray.length,$t=rt?rt.boxEndIndex:e.collisionBoxArray.length;let Gt=-1;const qt=(e,s)=>e&&e.circleDiameter?Math.max(e.circleDiameter,s):s;Gt=qt(Q,Gt),Gt=qt(it,Gt),Gt=qt(et,Gt),Gt=qt(rt,Gt);const Xt=Gt>-1?1:0;Xt&&(Gt*=Z/gd),e.glyphOffsetArray.length>=Yc.MAX_GLYPHS&&kt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==O.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,O.sortKey);const Ht=Jp(_,O,N),[Kt,Qt]=function(e,a){const l=e.length,c=null==a?void 0:a.values;if((null==c?void 0:c.length)>0)for(let a=0;a=0?ht.right:-1,ht.center>=0?ht.center:-1,ht.left>=0?ht.left:-1,ht.vertical||-1,lt,ct,pt,bt,Tt,Pt,St,Et,Ft,Nt,$t,y,ot,at,nt,st,Xt,0,w,Gt,Kt,Qt)}(e,v,_,l,c,u,nt,e.layers[0],e.collisionBoxArray,a.index,a.sourceLayerIndex,e.index,R,[j,j,j,j],Z,g,B,U,J,A,a,p,y,x,f)};if("line"===Q)for(const s of Dp(a.geometry,0,0,rt,rt)){const a=Mu(s,st),u=jp(a,O,N,l.vertical||k,c,24,L,e.overscaling,rt);for(const s of u)k&&nf(e,k.text,et,s)||ot(a,s)}else if("line-center"===Q){for(const e of a.geometry)if(e.length>1){const s=Mu(e,st),a=Op(s,N,l.vertical||k,c,24,L);a&&ot(s,a)}}else if("Polygon"===a.type)for(const e of kn(a.geometry,0)){const s=qp(e,16);ot(Mu(e[0],st,!0),new Bh(s.x,s.y,0))}else if("LineString"===a.type)for(const e of a.geometry){const s=Mu(e,st);ot(s,new Bh(s[0].x,s[0].y,0))}else if("Point"===a.type)for(const e of a.geometry)for(const s of e)ot([s],new Bh(s.x,s.y,0))}function ef(e,s,a,c,u,p,f,_,g,y,x,v,w,C,A){const k=function(e,s,a,c,u,p,f,_){const g=c.layout.get("text-rotate").evaluate(p,{})*Math.PI/180,y=[];for(const e of s.positionedLines)for(const c of e.positionedGlyphs){if(!c.rect)continue;const p=c.rect||{};let x=4,v=!0,w=1,C=0;const A=(u||_)&&c.vertical,k=c.metrics.advance*c.scale/2;if(_&&s.verticalizable&&(C=e.lineOffset/2-(c.imageName?-(gd-c.metrics.width*c.scale)/2:(c.scale-1)*gd)),c.imageName){const e=f[c.imageName];v=e.sdf,w=e.pixelRatio,x=1/w}const D=u?[c.x+k,c.y]:[0,0];let R=u?[0,0]:[c.x+k+a[0],c.y+a[1]-C],L=[0,0];A&&(L=R,R=[0,0]);const B=c.metrics.isDoubleResolution?2:1,O=(c.metrics.left-x)*c.scale-k+R[0],j=(-c.metrics.top-x)*c.scale+R[1],U=O+p.w/B*c.scale/w,N=j+p.h/B*c.scale/w,Z=new l(O,j),J=new l(U,j),Q=new l(O,N),et=new l(U,N);if(A){const e=new l(-k,k- -17),s=-Math.PI/2,a=12-k,u=new l(22-a,-(c.imageName?a:0)),p=new l(...L);Z._rotateAround(s,e)._add(u)._add(p),J._rotateAround(s,e)._add(u)._add(p),Q._rotateAround(s,e)._add(u)._add(p),et._rotateAround(s,e)._add(u)._add(p)}if(g){const e=Math.sin(g),s=Math.cos(g),a=[s,-e,e,s];Z._matMult(a),J._matMult(a),Q._matMult(a),et._matMult(a)}const it=new l(0,0),rt=new l(0,0);y.push({tl:Z,tr:J,bl:Q,br:et,tex:p,writingMode:s.writingMode,glyphOffset:D,sectionIndex:c.sectionIndex,isSDF:v,pixelOffsetTL:it,pixelOffsetBR:rt,minFontScaleX:0,minFontScaleY:0})}return y}(0,a,_,u,p,f,c,e.allowVerticalPlacement),D=e.textSizeData;let R=null;"source"===D.kind?(R=[rp*u.layout.get("text-size").evaluate(f,{})],R[0]>np&&kt(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===D.kind&&(R=[rp*C.compositeTextSizes[0].evaluate(f,{},A),rp*C.compositeTextSizes[1].evaluate(f,{},A)],(R[0]>np||R[1]>np)&&kt(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,k,R,_,p,f,y,s,g.lineStartIndex,g.lineLength,w,A);for(const s of x)v[s]=e.text.placedSymbolArray.length-1;return 4*k.length}function rf(e){for(const s in e)return e[s];return null}function nf(e,s,a,l){const c=e.compareText;if(s in c){const e=c[s];for(let s=e.length-1;s>=0;s--)if(l.dist(e[s])>4;if(1!==l)throw new Error(`Got v${l} data when expected v1.`);const c=sf[15&a];if(!c)throw new Error("Unrecognized array type.");const[u]=new Uint16Array(e,2,1),[p]=new Uint32Array(e,4,1);return new ap(p,u,c,e)}constructor(e,s=64,a=Float64Array,l){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+s,2),65535),this.ArrayType=a,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const c=sf.indexOf(this.ArrayType),u=2*e*this.ArrayType.BYTES_PER_ELEMENT,p=e*this.IndexArrayType.BYTES_PER_ELEMENT,f=(8-p%8)%8;if(c<0)throw new Error(`Unexpected typed array class: ${a}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+f,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+u+p+f),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+f,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+c]),new Uint16Array(this.data,2,1)[0]=s,new Uint32Array(this.data,4,1)[0]=e)}add(e,s){const a=this._pos>>1;return this.ids[a]=a,this.coords[this._pos++]=e,this.coords[this._pos++]=s,a}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return of(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,s,a,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:u,nodeSize:p}=this,f=[0,c.length-1,0],_=[];for(;f.length;){const g=f.pop()||0,y=f.pop()||0,x=f.pop()||0;if(y-x<=p){for(let p=x;p<=y;p++){const f=u[2*p],g=u[2*p+1];f>=e&&f<=a&&g>=s&&g<=l&&_.push(c[p])}continue}const v=x+y>>1,w=u[2*v],C=u[2*v+1];w>=e&&w<=a&&C>=s&&C<=l&&_.push(c[v]),(0===g?e<=w:s<=C)&&(f.push(x),f.push(v-1),f.push(1-g)),(0===g?a>=w:l>=C)&&(f.push(v+1),f.push(y),f.push(1-g))}return _}within(e,s,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:c,nodeSize:u}=this,p=[0,l.length-1,0],f=[],_=a*a;for(;p.length;){const g=p.pop()||0,y=p.pop()||0,x=p.pop()||0;if(y-x<=u){for(let a=x;a<=y;a++)hf(c[2*a],c[2*a+1],e,s)<=_&&f.push(l[a]);continue}const v=x+y>>1,w=c[2*v],C=c[2*v+1];hf(w,C,e,s)<=_&&f.push(l[v]),(0===g?e-a<=w:s-a<=C)&&(p.push(x),p.push(v-1),p.push(1-g)),(0===g?e+a>=w:s+a>=C)&&(p.push(v+1),p.push(y),p.push(1-g))}return f}}function of(e,s,a,l,c,u){if(c-l<=a)return;const p=l+c>>1;af(e,s,p,l,c,u),of(e,s,a,l,p-1,1-u),of(e,s,a,p+1,c,1-u)}function af(e,s,a,l,c,u){for(;c>l;){if(c-l>600){const p=c-l+1,f=a-l+1,_=Math.log(p),g=.5*Math.exp(2*_/3),y=.5*Math.sqrt(_*g*(p-g)/p)*(f-p/2<0?-1:1);af(e,s,a,Math.max(l,Math.floor(a-f*g/p+y)),Math.min(c,Math.floor(a+(p-f)*g/p+y)),u)}const p=s[2*a+u];let f=l,_=c;for(lf(e,s,l,a),s[2*c+u]>p&&lf(e,s,l,c);f<_;){for(lf(e,s,f,_),f++,_--;s[2*f+u]p;)_--}s[2*l+u]===p?lf(e,s,l,_):(_++,lf(e,s,_,c)),_<=a&&(l=_+1),a<=_&&(c=_-1)}}function lf(e,s,a,l){cf(e,a,l),cf(s,2*a,2*l),cf(s,2*a+1,2*l+1)}function cf(e,s,a){const l=e[s];e[s]=e[a],e[a]=l}function hf(e,s,a,l){const c=e-a,u=s-l;return c*c+u*u}var uf;s.cx=void 0,(uf=s.cx||(s.cx={})).create="create",uf.load="load",uf.fullLoad="fullLoad";let df=null,pf=[];const ff=1e3/60,mf="loadTime",_f="fullLoadTime",gf={mark(e){performance.mark(e)},frame(e){const s=e;null!=df&&pf.push(s-df),df=s},clearMetrics(){df=null,pf=[],performance.clearMeasures(mf),performance.clearMeasures(_f);for(const e in s.cx)performance.clearMarks(s.cx[e])},getPerformanceMetrics(){performance.measure(mf,s.cx.create,s.cx.load),performance.measure(_f,s.cx.create,s.cx.fullLoad);const e=performance.getEntriesByName(mf)[0].duration,a=performance.getEntriesByName(_f)[0].duration,l=pf.length,c=1/(pf.reduce(((e,s)=>e+s),0)/l/1e3),u=pf.filter((e=>e>ff)).reduce(((e,s)=>e+(s-ff)/ff),0);return{loadTime:e,fullLoadTime:a,fps:c,percentDroppedFrames:u/(l+u)*100,totalFrames:l}}};s.$=rt,s.A=C,s.B=function([e,s,a]){return s+=90,s*=Math.PI/180,a*=Math.PI/180,{x:e*Math.cos(s)*Math.sin(a),y:e*Math.sin(s)*Math.sin(a),z:e*Math.cos(a)}},s.C=Br,s.D=$s,s.E=gt,s.F=Is,s.G=Fl,s.H=function(e){if(null==$t){const s=e.navigator?e.navigator.userAgent:null;$t=!!e.safari||!(!s||!(/\b(iPad|iPhone|iPod)\b/.test(s)||s.match("Safari")&&!s.match("Chrome")))}return $t},s.I=fc,s.J=class{constructor(e,s){this.target=e,this.mapId=s,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new oh((()=>this.process())),this.subscription=Qt(this.target,"message",(e=>this.receive(e)),!1),this.globalScope=Nt(self)?e:window}registerMessageHandler(e,s){this.messageHandlers[e]=s}sendAsync(e,s){return new Promise(((a,l)=>{const c=Math.round(1e18*Math.random()).toString(36).substring(0,10),u=s?Qt(s.signal,"abort",(()=>{null==u||u.unsubscribe(),delete this.resolveRejects[c];const s={id:c,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(s)}),xp):null;this.resolveRejects[c]={resolve:e=>{null==u||u.unsubscribe(),a(e)},reject:e=>{null==u||u.unsubscribe(),l(e)}};const p=[],f=Object.assign(Object.assign({},e),{id:c,sourceMapId:this.mapId,origin:location.origin,data:Xl(e.data,p)});this.target.postMessage(f,{transfer:p})}))}receive(e){const s=e.data,a=s.id;if(!("file://"!==s.origin&&"file://"!==location.origin&&"resource://android"!==s.origin&&"resource://android"!==location.origin&&s.origin!==location.origin||s.targetMapId&&this.mapId!==s.targetMapId)){if(""===s.type){delete this.tasks[a];const e=this.abortControllers[a];return delete this.abortControllers[a],void(e&&e.abort())}if(Nt(self)||s.mustQueue)return this.tasks[a]=s,this.taskQueue.push(a),void this.invoker.trigger();this.processTask(a,s)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),s=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),s&&this.processTask(e,s)}processTask(e,s){return a(this,void 0,void 0,(function*(){if(""===s.type){const a=this.resolveRejects[e];if(delete this.resolveRejects[e],!a)return;return void(s.error?a.reject(Hl(s.error)):a.resolve(Hl(s.data)))}if(!this.messageHandlers[s.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${s.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const a=Hl(s.data),l=new AbortController;this.abortControllers[e]=l;try{const c=yield this.messageHandlers[s.type](s.sourceMapId,a,l);this.completeTask(e,null,c)}catch(a){this.completeTask(e,a)}}))}completeTask(e,s,a){const l=[];delete this.abortControllers[e];const c={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:s?Xl(s):null,data:Xl(a,l)};this.target.postMessage(c,{transfer:l})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},s.K=pe,s.L=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},s.M=function(e,s,a){var l,c,u,p,f,_,g,y,x,v,w,C,A=a[0],k=a[1],D=a[2];return s===e?(e[12]=s[0]*A+s[4]*k+s[8]*D+s[12],e[13]=s[1]*A+s[5]*k+s[9]*D+s[13],e[14]=s[2]*A+s[6]*k+s[10]*D+s[14],e[15]=s[3]*A+s[7]*k+s[11]*D+s[15]):(c=s[1],u=s[2],p=s[3],f=s[4],_=s[5],g=s[6],y=s[7],x=s[8],v=s[9],w=s[10],C=s[11],e[0]=l=s[0],e[1]=c,e[2]=u,e[3]=p,e[4]=f,e[5]=_,e[6]=g,e[7]=y,e[8]=x,e[9]=v,e[10]=w,e[11]=C,e[12]=l*A+f*k+x*D+s[12],e[13]=c*A+_*k+v*D+s[13],e[14]=u*A+g*k+w*D+s[14],e[15]=p*A+y*k+C*D+s[15]),e},s.N=function(e,s,a){var l=a[0],c=a[1],u=a[2];return e[0]=s[0]*l,e[1]=s[1]*l,e[2]=s[2]*l,e[3]=s[3]*l,e[4]=s[4]*c,e[5]=s[5]*c,e[6]=s[6]*c,e[7]=s[7]*c,e[8]=s[8]*u,e[9]=s[9]*u,e[10]=s[10]*u,e[11]=s[11]*u,e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],e},s.O=function(e,s,a){var l=s[0],c=s[1],u=s[2],p=s[3],f=s[4],_=s[5],g=s[6],y=s[7],x=s[8],v=s[9],w=s[10],C=s[11],A=s[12],k=s[13],D=s[14],R=s[15],L=a[0],B=a[1],O=a[2],j=a[3];return e[0]=L*l+B*f+O*x+j*A,e[1]=L*c+B*_+O*v+j*k,e[2]=L*u+B*g+O*w+j*D,e[3]=L*p+B*y+O*C+j*R,e[4]=(L=a[4])*l+(B=a[5])*f+(O=a[6])*x+(j=a[7])*A,e[5]=L*c+B*_+O*v+j*k,e[6]=L*u+B*g+O*w+j*D,e[7]=L*p+B*y+O*C+j*R,e[8]=(L=a[8])*l+(B=a[9])*f+(O=a[10])*x+(j=a[11])*A,e[9]=L*c+B*_+O*v+j*k,e[10]=L*u+B*g+O*w+j*D,e[11]=L*p+B*y+O*C+j*R,e[12]=(L=a[12])*l+(B=a[13])*f+(O=a[14])*x+(j=a[15])*A,e[13]=L*c+B*_+O*v+j*k,e[14]=L*u+B*g+O*w+j*D,e[15]=L*p+B*y+O*C+j*R,e},s.P=l,s.Q=function(e,s){const a={};for(let l=0;l[e.id,e])));p.add=Array.from(a.values())}if(s.update){const e=new Map(null===(a=p.update)||void 0===a?void 0:a.map((e=>[e.id,e])));for(const a of s.update){const s=null!==(l=e.get(a.id))&&void 0!==l?l:{id:a.id};a.newGeometry&&(s.newGeometry=a.newGeometry),a.addOrUpdateProperties&&(s.addOrUpdateProperties=(null!==(c=s.addOrUpdateProperties)&&void 0!==c?c:[]).concat(a.addOrUpdateProperties)),a.removeProperties&&(s.removeProperties=(null!==(u=s.removeProperties)&&void 0!==u?u:[]).concat(a.removeProperties)),a.removeAllProperties&&(s.removeAllProperties=!0),e.set(a.id,s)}p.update=Array.from(e.values())}return p},s.a1=xh,s.a2=kh,s.a3=25,s.a4=bh,s.a5=e=>{const s=window.document.createElement("video");return s.muted=!0,new Promise((a=>{s.onloadstart=()=>{a(s)};for(const a of e){const e=window.document.createElement("source");_e(a)||(s.crossOrigin="Anonymous"),e.src=a,s.appendChild(e)}}))},s.a6=Ct,s.a7=function(){return bt++},s.a8=va,s.a9=Yc,s.aA=function(e){let s=1/0,a=1/0,l=-1/0,c=-1/0;for(const u of e)s=Math.min(s,u.x),a=Math.min(a,u.y),l=Math.max(l,u.x),c=Math.max(c,u.y);return[s,a,l,c]},s.aB=gd,s.aC=nt,s.aD=function(e,s,a,l,c=!1){if(!a[0]&&!a[1])return[0,0];const u=c?"map"===l?-e.bearingInRadians:0:"viewport"===l?e.bearingInRadians:0;if(u){const e=Math.sin(u),s=Math.cos(u);a=[a[0]*s-a[1]*e,a[0]*e+a[1]*s]}return[c?a[0]:nt(s,a[0],e.zoom),c?a[1]:nt(s,a[1],e.zoom)]},s.aF=op,s.aG=Qp,s.aH=Wd,s.aI=ap,s.aJ=_c,s.aK=Gl,s.aL=Ca,s.aM=Xa,s.aN=ja,s.aO=pt,s.aP=ie,s.aQ=Cp,s.aR=O,s.aS=B,s.aT=function(e){var s=new C(3);return s[0]=e[0],s[1]=e[1],s[2]=e[2],s},s.aU=function(e,s,a){return e[0]=s[0]-a[0],e[1]=s[1]-a[1],e[2]=s[2]-a[2],e},s.aV=function(e,s){var a=s[0],l=s[1],c=s[2],u=a*a+l*l+c*c;return u>0&&(u=1/Math.sqrt(u)),e[0]=s[0]*u,e[1]=s[1]*u,e[2]=s[2]*u,e},s.aW=j,s.aX=function(e,s){return e[0]*s[0]+e[1]*s[1]+e[2]*s[2]},s.aY=function(e,s,a){return e[0]=s[0]*a[0],e[1]=s[1]*a[1],e[2]=s[2]*a[2],e[3]=s[3]*a[3],e},s.aZ=R,s.a_=function(e,s,a){const l=s[0]*a[0]+s[1]*a[1]+s[2]*a[2];return 0===l?null:(-(e[0]*a[0]+e[1]*a[1]+e[2]*a[2])-a[3])/l},s.aa=Xo,s.ab=Uc,s.ac=Ih,s.ad=function(e){const s={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,a,l,c)=>{const u=l||c;return s[a]=!u||u.toLowerCase(),""})),s["max-age"]){const e=parseInt(s["max-age"],10);isNaN(e)?delete s["max-age"]:s["max-age"]=e}return s},s.ae=ee,s.af=function(e){return Math.pow(2,e)},s.ag=k,s.ah=ht,s.ai=85.051129,s.aj=Sp,s.ak=function(e){return Math.log(e)/Math.LN2},s.al=function(e){var s=e[0],a=e[1];return s*s+a*a},s.am=function(e,s){const a=[];for(const l in e)l in s||a.push(l);return a},s.an=function(e,s){let a=0,l=0;if("constant"===e.kind)l=e.layoutSize;else if("source"!==e.kind){const{interpolationType:c,minZoom:u,maxZoom:p}=e,f=c?ht(pr.interpolationFactor(c,s,u,p),0,1):0;"camera"===e.kind?l=Br.number(e.minSize,e.maxSize,f):a=f}return{uSizeT:a,uSize:l}},s.ap=function(e,{uSize:s,uSizeT:a},{lowerSize:l,upperSize:c}){return"source"===e.kind?l/rp:"composite"===e.kind?Br.number(l/rp,c/rp,a):s},s.aq=function(e,s){var a=s[0],l=s[1],c=s[2],u=s[3],p=s[4],f=s[5],_=s[6],g=s[7],y=s[8],x=s[9],v=s[10],w=s[11],C=s[12],A=s[13],k=s[14],D=s[15],R=a*f-l*p,L=a*_-c*p,B=a*g-u*p,O=l*_-c*f,j=l*g-u*f,U=c*g-u*_,N=y*A-x*C,Z=y*k-v*C,J=y*D-w*C,Q=x*k-v*A,et=x*D-w*A,it=v*D-w*k,rt=R*it-L*et+B*Q+O*J-j*Z+U*N;return rt?(e[0]=(f*it-_*et+g*Q)*(rt=1/rt),e[1]=(c*et-l*it-u*Q)*rt,e[2]=(A*U-k*j+D*O)*rt,e[3]=(v*j-x*U-w*O)*rt,e[4]=(_*J-p*it-g*Z)*rt,e[5]=(a*it-c*J+u*Z)*rt,e[6]=(k*B-C*U-D*L)*rt,e[7]=(y*U-v*B+w*L)*rt,e[8]=(p*et-f*J+g*N)*rt,e[9]=(l*J-a*et-u*N)*rt,e[10]=(C*j-A*B+D*R)*rt,e[11]=(x*B-y*j-w*R)*rt,e[12]=(f*Z-p*Q-_*N)*rt,e[13]=(a*Q-l*Z+c*N)*rt,e[14]=(A*L-C*O-k*R)*rt,e[15]=(y*O-x*L+v*R)*rt,e):null},s.ar=et,s.as=function(e){return Math.hypot(e[0],e[1])},s.at=function(e){return e[0]=0,e[1]=0,e},s.au=function(e,s,a){return e[0]=s[0]*a,e[1]=s[1]*a,e},s.av=hp,s.aw=Z,s.ax=function(e,s,a,c){const u=s.y-e.y,p=s.x-e.x,f=c.y-a.y,_=c.x-a.x,g=f*p-_*u;if(0===g)return null;const y=(_*(e.y-a.y)-f*(e.x-a.x))/g;return new l(e.x+y*p,e.y+y*u)},s.ay=Dp,s.az=Gc,s.b=Gt,s.b$=class extends oa{},s.b0=function(e,s,a){return e[0]=s[0]*a,e[1]=s[1]*a,e[2]=s[2]*a,e[3]=s[3]*a,e},s.b1=function(e,s){return e[0]*s[0]+e[1]*s[1]+e[2]*s[2]+e[3]},s.b2=wh,s.b3=Ep,s.b4=function(e,s,a,l,c){var u,p=1/Math.tan(s/2);return e[0]=p/a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=p,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=c&&c!==1/0?(e[10]=(c+l)*(u=1/(l-c)),e[14]=2*c*l*u):(e[10]=-1,e[14]=-2*l),e},s.b5=function(e){var s=new C(16);return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],s[9]=e[9],s[10]=e[10],s[11]=e[11],s[12]=e[12],s[13]=e[13],s[14]=e[14],s[15]=e[15],s},s.b6=function(e,s,a){var l=Math.sin(a),c=Math.cos(a),u=s[0],p=s[1],f=s[2],_=s[3],g=s[4],y=s[5],x=s[6],v=s[7];return s!==e&&(e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15]),e[0]=u*c+g*l,e[1]=p*c+y*l,e[2]=f*c+x*l,e[3]=_*c+v*l,e[4]=g*c-u*l,e[5]=y*c-p*l,e[6]=x*c-f*l,e[7]=v*c-_*l,e},s.b7=function(e,s,a){var l=Math.sin(a),c=Math.cos(a),u=s[4],p=s[5],f=s[6],_=s[7],g=s[8],y=s[9],x=s[10],v=s[11];return s!==e&&(e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15]),e[4]=u*c+g*l,e[5]=p*c+y*l,e[6]=f*c+x*l,e[7]=_*c+v*l,e[8]=g*c-u*l,e[9]=y*c-p*l,e[10]=x*c-f*l,e[11]=v*c-_*l,e},s.b8=function(){const e=new Float32Array(16);return k(e),e},s.b9=function(){const e=new Float64Array(16);return k(e),e},s.bA=function(e,s){const a=st(e,360),l=st(s,360),c=l-a,u=l>a?c-360:c+360;return Math.abs(c)0?p:-p},s.bD=function(e,s){const a=st(e,2*Math.PI),l=st(s,2*Math.PI);return Math.min(Math.abs(a-l),Math.abs(a-l+2*Math.PI),Math.abs(a-l-2*Math.PI))},s.bE=function(){const e={},s=ve.$version;for(const a in ve.$root){const l=ve.$root[a];if(l.required){let c=null;c="version"===a?s:"array"===l.type?[]:{},null!=c&&(e[a]=c)}}return e},s.bF=ps,s.bG=fe,s.bH=function e(s,a){if(Array.isArray(s)){if(!Array.isArray(a)||s.length!==a.length)return!1;for(let l=0;l{"source"in e&&l[e.source]?a.push({command:"removeLayer",args:[e.id]}):u.push(e)})),a=a.concat(c),function(e,s,a){s=s||[];const l=(e=e||[]).map(je),c=s.map(je),u=e.reduce(Ue,{}),p=s.reduce(Ue,{}),f=l.slice(),_=Object.create(null);let g,y,x,v,w;for(let e=0,s=0;ew?(c=Math.acos(u),p=Math.sin(c),f=Math.sin((1-l)*c)/p,_=Math.sin(l*c)/p):(f=1-l,_=l),e[0]=f*g+_*C,e[1]=f*y+_*A,e[2]=f*x+_*k,e[3]=f*v+_*D,e},s.bd=function(e){const s=new Float64Array(9);var a,l,c,u,p,f,_,g,y,x,v,w,C,A,k,D,R,L;x=(c=(l=e)[0])*(_=c+c),v=(u=l[1])*_,C=(p=l[2])*_,A=p*(g=u+u),D=(f=l[3])*_,R=f*g,L=f*(y=p+p),(a=s)[0]=1-(w=u*g)-(k=p*y),a[3]=v-L,a[6]=C+R,a[1]=v+L,a[4]=1-x-k,a[7]=A-D,a[2]=C-R,a[5]=A+D,a[8]=1-x-w;const B=ie(-Math.asin(ht(s[2],-1,1)));let O,j;return Math.hypot(s[5],s[8])<.001?(O=0,j=-ie(Math.atan2(s[3],s[4]))):(O=ie(0===s[5]&&0===s[8]?0:Math.atan2(s[5],s[8])),j=ie(0===s[1]&&0===s[0]?0:Math.atan2(s[1],s[0]))),{roll:O,pitch:B+90,bearing:j}},s.be=function(e,s){return e.roll==s.roll&&e.pitch==s.pitch&&e.bearing==s.bearing},s.bf=Me,s.bg=lo,s.bh=wu,s.bi=Tu,s.bj=ql,s.bk=ot,s.bl=at,s.bm=Oe,s.bn=function(e,s,a,l,c){return ot(l,c,ht((e-s)/(a-s),0,1))},s.bo=st,s.bp=function(){return new Float64Array(3)},s.bq=function(e,s,a,l){return e[0]=s[0]+a[0]*l,e[1]=s[1]+a[1]*l,e[2]=s[2]+a[2]*l,e},s.br=Q,s.bs=function(e,s,a){var l=a[0],c=a[1],u=a[2],p=s[0],f=s[1],_=s[2],g=c*_-u*f,y=u*p-l*_,x=l*f-c*p,v=c*x-u*y,w=u*g-l*x,C=l*y-c*g,A=2*a[3];return y*=A,x*=A,w*=2,C*=2,e[0]=p+(g*=A)+(v*=2),e[1]=f+y+w,e[2]=_+x+C,e},s.bt=function(e,s,a){const l=(c=[e[0],e[1],e[2],s[0],s[1],s[2],a[0],a[1],a[2]])[0]*((y=c[8])*(p=c[4])-(f=c[5])*(g=c[7]))+c[1]*(-y*(u=c[3])+f*(_=c[6]))+c[2]*(g*u-p*_);var c,u,p,f,_,g,y;if(0===l)return null;const x=j([],[s[0],s[1],s[2]],[a[0],a[1],a[2]]),v=j([],[a[0],a[1],a[2]],[e[0],e[1],e[2]]),w=j([],[e[0],e[1],e[2]],[s[0],s[1],s[2]]),C=O([],x,-e[3]);return B(C,C,O([],v,-s[3])),B(C,C,O([],w,-a[3])),O(C,C,1/l),C},s.bu=vp,s.bv=function(){return new Float64Array(4)},s.bw=function(e,s,a,l){var c=[],u=[];return c[0]=s[0]-a[0],c[1]=s[1]-a[1],c[2]=s[2]-a[2],u[0]=c[0]*Math.cos(l)-c[1]*Math.sin(l),u[1]=c[0]*Math.sin(l)+c[1]*Math.cos(l),u[2]=c[2],e[0]=u[0]+a[0],e[1]=u[1]+a[1],e[2]=u[2]+a[2],e},s.bx=function(e,s,a,l){var c=[],u=[];return c[0]=s[0]-a[0],c[1]=s[1]-a[1],c[2]=s[2]-a[2],u[0]=c[0],u[1]=c[1]*Math.cos(l)-c[2]*Math.sin(l),u[2]=c[1]*Math.sin(l)+c[2]*Math.cos(l),e[0]=u[0]+a[0],e[1]=u[1]+a[1],e[2]=u[2]+a[2],e},s.by=function(e,s,a,l){var c=[],u=[];return c[0]=s[0]-a[0],c[1]=s[1]-a[1],c[2]=s[2]-a[2],u[0]=c[2]*Math.sin(l)+c[0]*Math.cos(l),u[1]=c[1],u[2]=c[2]*Math.cos(l)-c[0]*Math.sin(l),e[0]=u[0]+a[0],e[1]=u[1]+a[1],e[2]=u[2]+a[2],e},s.bz=function(e,s,a){var l=Math.sin(a),c=Math.cos(a),u=s[0],p=s[1],f=s[2],_=s[3],g=s[8],y=s[9],x=s[10],v=s[11];return s!==e&&(e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15]),e[0]=u*c-g*l,e[1]=p*c-y*l,e[2]=f*c-x*l,e[3]=_*c-v*l,e[8]=u*l+g*c,e[9]=p*l+y*c,e[10]=f*l+x*c,e[11]=_*l+v*c,e},s.c=he,s.c0=fd,s.c1=class extends ua{},s.c2=Ah,s.c3=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},s.c4=Eh,s.c5=function(e,s,a){var l=s[0],c=s[1],u=s[2],p=a[3]*l+a[7]*c+a[11]*u+a[15];return e[0]=(a[0]*l+a[4]*c+a[8]*u+a[12])/(p=p||1),e[1]=(a[1]*l+a[5]*c+a[9]*u+a[13])/p,e[2]=(a[2]*l+a[6]*c+a[10]*u+a[14])/p,e},s.c6=class extends Js{},s.c7=class extends ma{},s.c8=function(e,s){return e[0]===s[0]&&e[1]===s[1]&&e[2]===s[2]&&e[3]===s[3]&&e[4]===s[4]&&e[5]===s[5]&&e[6]===s[6]&&e[7]===s[7]&&e[8]===s[8]&&e[9]===s[9]&&e[10]===s[10]&&e[11]===s[11]&&e[12]===s[12]&&e[13]===s[13]&&e[14]===s[14]&&e[15]===s[15]},s.c9=function(e,s){var a=e[0],l=e[1],c=e[2],u=e[3],p=e[4],f=e[5],_=e[6],g=e[7],y=e[8],x=e[9],v=e[10],C=e[11],A=e[12],k=e[13],D=e[14],R=e[15],L=s[0],B=s[1],O=s[2],j=s[3],U=s[4],N=s[5],Z=s[6],J=s[7],Q=s[8],et=s[9],it=s[10],rt=s[11],nt=s[12],st=s[13],ot=s[14],at=s[15];return Math.abs(a-L)<=w*Math.max(1,Math.abs(a),Math.abs(L))&&Math.abs(l-B)<=w*Math.max(1,Math.abs(l),Math.abs(B))&&Math.abs(c-O)<=w*Math.max(1,Math.abs(c),Math.abs(O))&&Math.abs(u-j)<=w*Math.max(1,Math.abs(u),Math.abs(j))&&Math.abs(p-U)<=w*Math.max(1,Math.abs(p),Math.abs(U))&&Math.abs(f-N)<=w*Math.max(1,Math.abs(f),Math.abs(N))&&Math.abs(_-Z)<=w*Math.max(1,Math.abs(_),Math.abs(Z))&&Math.abs(g-J)<=w*Math.max(1,Math.abs(g),Math.abs(J))&&Math.abs(y-Q)<=w*Math.max(1,Math.abs(y),Math.abs(Q))&&Math.abs(x-et)<=w*Math.max(1,Math.abs(x),Math.abs(et))&&Math.abs(v-it)<=w*Math.max(1,Math.abs(v),Math.abs(it))&&Math.abs(C-rt)<=w*Math.max(1,Math.abs(C),Math.abs(rt))&&Math.abs(A-nt)<=w*Math.max(1,Math.abs(A),Math.abs(nt))&&Math.abs(k-st)<=w*Math.max(1,Math.abs(k),Math.abs(st))&&Math.abs(D-ot)<=w*Math.max(1,Math.abs(D),Math.abs(ot))&&Math.abs(R-at)<=w*Math.max(1,Math.abs(R),Math.abs(at))},s.cA=function(e,s){ue.REGISTERED_PROTOCOLS[e]=s},s.cB=function(e){delete ue.REGISTERED_PROTOCOLS[e]},s.cC=function(e,s){const a={};for(let l=0;le*gd))}let L=f?"center":l.get("text-justify").evaluate(c,{},e.canonical);const B="point"===l.get("symbol-placement")?l.get("text-max-width").evaluate(c,{},e.canonical)*gd:1/0,O=()=>{e.bucket.allowVerticalPlacement&&Jl(u)&&(C.vertical=Fd(A,e.glyphMap,e.glyphPositions,e.imagePositions,y,B,p,k,"left",w,D,s.ao.vertical,!0,v,x))};if(!f&&R){const a=new Set;if("auto"===L)for(let e=0;e0||(null===(c=a.addOrUpdateProperties)||void 0===c?void 0:c.length)>0);if((a.newGeometry||a.removeAllProperties||f)&&(s=Object.assign({},s),e.set(a.id,s),f&&(s.properties=Object.assign({},s.properties))),a.newGeometry&&(s.geometry=a.newGeometry),a.removeAllProperties)s.properties={};else if((null===(u=a.removeProperties)||void 0===u?void 0:u.length)>0)for(const e of a.removeProperties)Object.prototype.hasOwnProperty.call(s.properties,e)&&delete s.properties[e];if((null===(p=a.addOrUpdateProperties)||void 0===p?void 0:p.length)>0)for(const{key:e,value:l}of a.addOrUpdateProperties)s.properties[e]=l}},s.cX=hc,s.ca=function(e,s){return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],e},s.cb=e=>"symbol"===e.type,s.cc=e=>"circle"===e.type,s.cd=e=>"heatmap"===e.type,s.ce=e=>"line"===e.type,s.cf=e=>"fill"===e.type,s.cg=e=>"fill-extrusion"===e.type,s.ch=e=>"hillshade"===e.type,s.ci=e=>"color-relief"===e.type,s.cj=e=>"raster"===e.type,s.ck=e=>"background"===e.type,s.cl=e=>"custom"===e.type,s.cm=lt,s.cn=function(e,s,a){const l=it(s.x-a.x,s.y-a.y),c=it(e.x-a.x,e.y-a.y);var u,p;return ie(Math.atan2(l[0]*c[1]-l[1]*c[0],(u=l)[0]*(p=c)[0]+u[1]*p[1]))},s.co=ct,s.cp=function(e,s){return le[s]&&(e instanceof MouseEvent||e instanceof WheelEvent)},s.cq=function(e,s){return ne[s]&&"touches"in e},s.cr=function(e){return ne[e]||le[e]},s.cs=function(e,s,a){var l=s[0],c=s[1];return e[0]=a[0]*l+a[4]*c+a[12],e[1]=a[1]*l+a[5]*c+a[13],e},s.ct=function(e,s){const{x:a,y:l}=xh.fromLngLat(s);return!(e<0||e>25||l<0||l>=1||a<0||a>=1)},s.cu=function(e,s){return e[0]=s[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=s[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},s.cv=class extends Ks{},s.cw=gf,s.cy=function(e){return e.message===ce},s.cz=ut,s.d=_e,s.e=xt,s.f=e=>a(void 0,void 0,void 0,(function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const s=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(s)}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),s.g=de,s.h=e=>new Promise(((s,a)=>{const l=new Image;l.onload=()=>{s(l),URL.revokeObjectURL(l.src),l.onload=null,window.requestAnimationFrame((()=>{l.src=qt}))},l.onerror=()=>a(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 c=new Blob([new Uint8Array(e)],{type:"image/png"});l.src=e.byteLength?URL.createObjectURL(c):qt})),s.i=Nt,s.j=(e,s)=>me(xt(e,{type:"json"}),s),s.k=mt,s.l=yt,s.m=me,s.n=(e,s)=>me(xt(e,{type:"arrayBuffer"}),s),s.o=function(e){return new Ju(e).readFields(kd,[])},s.p=Ld,s.q=el,s.r=Us,s.s=Qt,s.t=Cs,s.u=Kl,s.v=ve,s.w=kt,s.x=Bl,s.y=Vl,s.z=Ll}));l("worker",["./shared"],(function(e){class t{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(s,a){for(const a of s){this._layerConfigs[a.id]=a;const s=this._layers[a.id]=e.bJ(a);s._featureFilter=e.aa(s.filter),this.keyCache[a.id]&&delete this.keyCache[a.id]}for(const e of a)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const l=e.cC(Object.values(this._layerConfigs),this.keyCache);for(const e of l){const s=e.map((e=>this._layers[e.id])),a=s[0];if("none"===a.visibility)continue;const l=a.source||"";let c=this.familiesBySource[l];c||(c=this.familiesBySource[l]={});const u=a.sourceLayer||"_geojsonTileLayer";let p=c[u];p||(p=c[u]=[]),p.push(s)}}}class i{constructor(s){const a={},l=[];for(const e in s){const c=s[e],u=a[e]={};for(const e in c){const s=c[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a={x:0,y:0,w:s.bitmap.width+2,h:s.bitmap.height+2};l.push(a),u[e]={rect:a,metrics:s.metrics}}}const{w:c,h:u}=e.p(l),p=new e.q({width:c||1,height:u||1});for(const l in s){const c=s[l];for(const s in c){const u=c[+s];if(!u||0===u.bitmap.width||0===u.bitmap.height)continue;const f=a[l][s].rect;e.q.copy(u.bitmap,p,{x:0,y:0},{x:f.x+1,y:f.y+1},u.bitmap)}}this.image=p,this.positions=a}}e.cD("GlyphAtlas",i);class o{constructor(s){this.tileID=new e.Z(s.tileID.overscaledZ,s.tileID.wrap,s.tileID.canonical.z,s.tileID.canonical.x,s.tileID.canonical.y),this.uid=s.uid,this.zoom=s.zoom,this.pixelRatio=s.pixelRatio,this.tileSize=s.tileSize,this.source=s.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=s.showCollisionBoxes,this.collectResourceTiming=!!s.collectResourceTiming,this.returnDependencies=!!s.returnDependencies,this.promoteId=s.promoteId,this.inFlightDependencies=[],this.globalState=s.globalState}parse(a,l,c,u,p){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=a,this.collisionBoxArray=new e.a8;const f=new e.cE(Object.keys(a.layers).sort()),_=new e.cF(this.tileID,this.promoteId);_.bucketLayerIDs=[];const g={},y={featureIndex:_,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:c,subdivisionGranularity:p},x=l.familiesBySource[this.source];for(const l in x){const u=a.layers[l];if(!u)continue;1===u.version&&e.w(`Vector tile source "${this.source}" layer "${l}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const p=f.encode(l),v=[];for(let e=0;e=l.maxzoom||"none"!==l.visibility&&(s(a,this.zoom,c),(g[l.id]=l.createBucket({index:_.bucketLayerIDs.length,layers:a,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:p,sourceID:this.source,globalState:this.globalState})).populate(v,y,this.tileID.canonical),_.bucketLayerIDs.push(a.map((e=>e.id))))}}const v=e.bN(y.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let w=Promise.resolve({});if(Object.keys(v).length){const e=new AbortController;this.inFlightDependencies.push(e),w=u.sendAsync({type:"GG",data:{stacks:v,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const C=Object.keys(y.iconDependencies);let A=Promise.resolve({});if(C.length){const e=new AbortController;this.inFlightDependencies.push(e),A=u.sendAsync({type:"GI",data:{icons:C,source:this.source,tileID:this.tileID,type:"icons"}},e)}const k=Object.keys(y.patternDependencies);let D=Promise.resolve({});if(k.length){const e=new AbortController;this.inFlightDependencies.push(e),D=u.sendAsync({type:"GI",data:{icons:k,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const[R,L,B]=yield Promise.all([w,A,D]),O=new i(R),j=new e.cG(L,B);for(const a in g){const l=g[a];l instanceof e.a9?(s(l.layers,this.zoom,c),e.cH({bucket:l,glyphMap:R,glyphPositions:O.positions,imageMap:L,imagePositions:j.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:y.subdivisionGranularity})):l.hasPattern&&(l instanceof e.cI||l instanceof e.cJ||l instanceof e.cK)&&(s(l.layers,this.zoom,c),l.addFeatures(y,this.tileID.canonical,j.patternPositions))}return this.status="done",{buckets:Object.values(g).filter((e=>!e.isEmpty())),featureIndex:_,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:O.image,imageAtlas:j,glyphMap:this.returnDependencies?R:null,iconMap:this.returnDependencies?L:null,glyphPositions:this.returnDependencies?O.positions:null}}))}}function s(s,a,l){const c=new e.F(a);for(const e of s)e.recalculate(c,l)}class n{constructor(e,s,a){this.actor=e,this.layerIndex=s,this.availableImages=a,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(s,a){return e._(this,void 0,void 0,(function*(){const l=yield e.n(s.request,a);try{return{vectorTile:new e.cL(new e.cM(l.data)),rawData:l.data,cacheControl:l.cacheControl,expires:l.expires}}catch(e){const a=new Uint8Array(l.data);let c=`Unable to parse the tile at ${s.request.url}, `;throw c+=31===a[0]&&139===a[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(c)}}))}loadTile(s){return e._(this,void 0,void 0,(function*(){const a=s.uid,l=!!(s&&s.request&&s.request.collectResourceTiming)&&new e.cN(s.request),c=new o(s);this.loading[a]=c;const u=new AbortController;c.abort=u;try{const p=yield this.loadVectorTile(s,u);if(delete this.loading[a],!p)return null;const f=p.rawData,_={};p.expires&&(_.expires=p.expires),p.cacheControl&&(_.cacheControl=p.cacheControl);const g={};if(l){const e=l.finish();e&&(g.resourceTiming=JSON.parse(JSON.stringify(e)))}c.vectorTile=p.vectorTile;const y=c.parse(p.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity);this.loaded[a]=c,this.fetching[a]={rawTileData:f,cacheControl:_,resourceTiming:g};try{const s=yield y;return e.e({rawTileData:f.slice(0)},s,_,g)}finally{delete this.fetching[a]}}catch(e){throw delete this.loading[a],c.status="done",this.loaded[a]=c,e}}))}reloadTile(s){return e._(this,void 0,void 0,(function*(){const a=s.uid;if(!this.loaded||!this.loaded[a])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const l=this.loaded[a];if(l.showCollisionBoxes=s.showCollisionBoxes,l.globalState=s.globalState,"parsing"===l.status){const c=yield l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity);let u;if(this.fetching[a]){const{rawTileData:s,cacheControl:l,resourceTiming:p}=this.fetching[a];delete this.fetching[a],u=e.e({rawTileData:s.slice(0)},c,l,p)}else u=c;return u}if("done"===l.status&&l.vectorTile)return l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity)}))}abortTile(s){return e._(this,void 0,void 0,(function*(){const e=this.loading,a=s.uid;e&&e[a]&&e[a].abort&&(e[a].abort.abort(),delete e[a])}))}removeTile(s){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[s.uid]&&delete this.loaded[s.uid]}))}}class r{constructor(){this.loaded={}}loadTile(s){return e._(this,void 0,void 0,(function*(){const{uid:a,encoding:l,rawImageData:c,redFactor:u,greenFactor:p,blueFactor:f,baseShift:_}=s,g=c.width+2,y=c.height+2,x=e.b(c)?new e.R({width:g,height:y},yield e.cO(c,-1,-1,g,y)):c,v=new e.cP(a,x,l,u,p,f,_);return this.loaded=this.loaded||{},this.loaded[a]=v,v}))}removeTile(e){const s=this.loaded,a=e.uid;s&&s[a]&&delete s[a]}}var a,l,c=function(){if(l)return a;function e(e,a){if(0!==e.length){s(e[0],a);for(var l=1;l=Math.abs(f)?a-_+f:f-_+a,a=_}a+l>=0!=!!s&&e.reverse()}return l=1,a=function s(a,l){var c,u=a&&a.type;if("FeatureCollection"===u)for(c=0;c>31}function x(e,s){const a=e.loadGeometry(),l=e.type;let c=0,u=0;for(const p of a){let a=1;1===l&&(a=p.length),s.writeVarint(g(1,a));const f=3===l?p.length-1:p.length;for(let e=0;ee},C=Math.fround||(A=new Float32Array(1),e=>(A[0]=+e,A[0]));var A;class M{constructor(e){this.options=Object.assign(Object.create(w),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:s,minZoom:a,maxZoom:l}=this.options;s&&console.time("total time");const c=`prepare ${e.length} points`;s&&console.time(c),this.points=e;const u=[];for(let s=0;s=a;e--){const a=+Date.now();p=this.trees[e]=this._createTree(this._cluster(p,e)),s&&console.log("z%d: %d clusters in %dms",e,p.numItems,+Date.now()-a)}return s&&console.timeEnd("total time"),this}getClusters(e,s){let a=((e[0]+180)%360+360)%360-180;const l=Math.max(-90,Math.min(90,e[1]));let c=180===e[2]?180:((e[2]+180)%360+360)%360-180;const u=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)a=-180,c=180;else if(a>c){const e=this.getClusters([a,l,180,u],s),p=this.getClusters([-180,l,c,u],s);return e.concat(p)}const p=this.trees[this._limitZoom(s)],f=p.range(R(a),L(u),R(c),L(l)),_=p.data,g=[];for(const e of f){const s=this.stride*e;g.push(_[s+5]>1?k(_,s,this.clusterProps):this.points[_[s+3]])}return g}getChildren(e){const s=this._getOriginId(e),a=this._getOriginZoom(e),l="No cluster with the specified id.",c=this.trees[a];if(!c)throw new Error(l);const u=c.data;if(s*this.stride>=u.length)throw new Error(l);const p=this.options.radius/(this.options.extent*Math.pow(2,a-1)),f=c.within(u[s*this.stride],u[s*this.stride+1],p),_=[];for(const s of f){const a=s*this.stride;u[a+4]===e&&_.push(u[a+5]>1?k(u,a,this.clusterProps):this.points[u[a+3]])}if(0===_.length)throw new Error(l);return _}getLeaves(e,s,a){const l=[];return this._appendLeaves(l,e,s=s||10,a=a||0,0),l}getTile(e,s,a){const l=this.trees[this._limitZoom(e)],c=Math.pow(2,e),{extent:u,radius:p}=this.options,f=p/u,_=(a-f)/c,g=(a+1+f)/c,y={features:[]};return this._addTileFeatures(l.range((s-f)/c,_,(s+1+f)/c,g),l.data,s,a,c,y),0===s&&this._addTileFeatures(l.range(1-f/c,_,1,g),l.data,c,a,c,y),s===c-1&&this._addTileFeatures(l.range(0,_,f/c,g),l.data,-1,a,c,y),y.features.length?y:null}getClusterExpansionZoom(e){let s=this._getOriginZoom(e)-1;for(;s<=this.options.maxZoom;){const a=this.getChildren(e);if(s++,1!==a.length)break;e=a[0].properties.cluster_id}return s}_appendLeaves(e,s,a,l,c){const u=this.getChildren(s);for(const s of u){const u=s.properties;if(u&&u.cluster?c+u.point_count<=l?c+=u.point_count:c=this._appendLeaves(e,u.cluster_id,a,l,c):c1;let _,g,y;if(f)_=D(s,e,this.clusterProps),g=s[e],y=s[e+1];else{const a=this.points[s[e+3]];_=a.properties;const[l,c]=a.geometry.coordinates;g=R(l),y=L(c)}const x={type:1,geometry:[[Math.round(this.options.extent*(g*c-a)),Math.round(this.options.extent*(y*c-l))]],tags:_};let v;v=f||this.options.generateId?s[e+3]:this.points[s[e+3]].id,void 0!==v&&(x.id=v),u.features.push(x)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,s){const{radius:a,extent:l,reduce:c,minPoints:u}=this.options,p=a/(l*Math.pow(2,s)),f=e.data,_=[],g=this.stride;for(let a=0;as&&(w+=f[a+5])}if(w>v&&w>=u){let e,u=l*v,p=y*v,C=-1;const A=(a/g<<5)+(s+1)+this.points.length;for(const l of x){const _=l*g;if(f[_+2]<=s)continue;f[_+2]=s;const y=f[_+5];u+=f[_]*y,p+=f[_+1]*y,f[_+4]=A,c&&(e||(e=this._map(f,a,!0),C=this.clusterProps.length,this.clusterProps.push(e)),c(e,this._map(f,_)))}f[a+4]=A,_.push(u/w,p/w,1/0,A,-1,w),c&&_.push(C)}else{for(let e=0;e1)for(const e of x){const a=e*g;if(!(f[a+2]<=s)){f[a+2]=s;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,s,a){if(e[s+5]>1){const l=this.clusterProps[e[s+6]];return a?Object.assign({},l):l}const l=this.points[e[s+3]].properties,c=this.options.map(l);return a&&c===l?Object.assign({},c):c}}function k(e,s,a){return{type:"Feature",id:e[s+3],properties:D(e,s,a),geometry:{type:"Point",coordinates:[(l=e[s],360*(l-.5)),B(e[s+1])]}};var l}function D(e,s,a){const l=e[s+5],c=l>=1e4?`${Math.round(l/1e3)}k`:l>=1e3?Math.round(l/100)/10+"k":l,u=e[s+6],p=-1===u?{}:Object.assign({},a[u]);return Object.assign(p,{cluster:!0,cluster_id:e[s+3],point_count:l,point_count_abbreviated:c})}function R(e){return e/360+.5}function L(e){const s=Math.sin(e*Math.PI/180),a=.5-.25*Math.log((1+s)/(1-s))/Math.PI;return a<0?0:a>1?1:a}function B(e){const s=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(s))/Math.PI-90}function O(e,s,a,l){let c=l;const u=s+(a-s>>1);let p,f=a-s;const _=e[s],g=e[s+1],y=e[a],x=e[a+1];for(let l=s+3;lc)p=l,c=s;else if(s===c){const e=Math.abs(l-u);el&&(p-s>3&&O(e,s,p,l),e[p+2]=c,a-p>3&&O(e,p,a,l))}function j(e,s,a,l,c,u){let p=c-a,f=u-l;if(0!==p||0!==f){const _=((e-a)*p+(s-l)*f)/(p*p+f*f);_>1?(a=c,l=u):_>0&&(a+=p*_,l+=f*_)}return p=e-a,f=s-l,p*p+f*f}function U(e,s,a,l){const c={id:null==e?null:e,type:s,geometry:a,tags:l,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===s||"MultiPoint"===s||"LineString"===s)N(c,a);else if("Polygon"===s)N(c,a[0]);else if("MultiLineString"===s)for(const e of a)N(c,e);else if("MultiPolygon"===s)for(const e of a)N(c,e[0]);return c}function N(e,s){for(let a=0;a0&&(p+=l?(c*_-f*u)/2:Math.sqrt(Math.pow(f-c,2)+Math.pow(_-u,2))),c=f,u=_}const f=s.length-3;s[2]=1,O(s,0,f,a),s[f+2]=1,s.size=Math.abs(p),s.start=0,s.end=s.size}function et(e,s,a,l){for(let c=0;c1?1:a}function nt(e,s,a,l,c,u,p,f){if(l/=s,u>=(a/=s)&&p=l)return null;const _=[];for(const s of e){const e=s.geometry;let u=s.type;const p=0===c?s.minX:s.minY,g=0===c?s.maxX:s.maxY;if(p>=a&&g=l)continue;let y=[];if("Point"===u||"MultiPoint"===u)st(e,y,a,l,c);else if("LineString"===u)ot(e,y,a,l,c,!1,f.lineMetrics);else if("MultiLineString"===u)lt(e,y,a,l,c,!1);else if("Polygon"===u)lt(e,y,a,l,c,!0);else if("MultiPolygon"===u)for(const s of e){const e=[];lt(s,e,a,l,c,!0),e.length&&y.push(e)}if(y.length){if(f.lineMetrics&&"LineString"===u){for(const e of y)_.push(U(s.id,u,e,s.tags));continue}"LineString"!==u&&"MultiLineString"!==u||(1===y.length?(u="LineString",y=y[0]):u="MultiLineString"),"Point"!==u&&"MultiPoint"!==u||(u=3===y.length?"Point":"MultiPoint"),_.push(U(s.id,u,y,s.tags))}}return _.length?_:null}function st(e,s,a,l,c){for(let u=0;u=a&&p<=l&&ct(s,e[u],e[u+1],e[u+2])}}function ot(e,s,a,l,c,u,p){let f=at(e);const _=0===c?ht:pt;let g,y,x=e.start;for(let v=0;va&&(y=_(f,w,C,k,D,a),p&&(f.start=x+g*y)):R>l?L=a&&(y=_(f,w,C,k,D,a),B=!0),L>l&&R<=l&&(y=_(f,w,C,k,D,l),B=!0),!u&&B&&(p&&(f.end=x+g*y),s.push(f),f=at(e)),p&&(x+=g)}let v=e.length-3;const w=e[v],C=e[v+1],A=0===c?w:C;A>=a&&A<=l&&ct(f,w,C,e[v+2]),v=f.length-3,u&&v>=3&&(f[v]!==f[0]||f[v+1]!==f[1])&&ct(f,f[0],f[1],f[2]),f.length&&s.push(f)}function at(e){const s=[];return s.size=e.size,s.start=e.start,s.end=e.end,s}function lt(e,s,a,l,c,u){for(const p of e)ot(p,s,a,l,c,u,!1)}function ct(e,s,a,l){e.push(s,a,l)}function ht(e,s,a,l,c,u){const p=(u-s)/(l-s);return ct(e,u,a+(c-a)*p,1),p}function pt(e,s,a,l,c,u){const p=(u-a)/(c-a);return ct(e,s+(l-s)*p,u,1),p}function xt(e,s){const a=[];for(let l=0;l0&&s.size<(c?p:l))return void(a.numPoints+=s.length/3);const f=[];for(let e=0;ep)&&(a.numSimplified++,f.push(s[e],s[e+1])),a.numPoints++;c&&function(e,s){let a=0;for(let s=0,l=e.length,c=l-2;s0===s)for(let s=0,a=e.length;s24)throw new Error("maxZoom should be in the 0-24 range");if(s.promoteId&&s.generateId)throw new Error("promoteId and generateId cannot be used together.");let l=function(e,s){const a=[];if("FeatureCollection"===e.type)for(let l=0;l1&&console.time("creation"),v=this.tiles[x]=St(e,s,a,l,_),this.tileCoords.push({z:s,x:a,y:l}),g)){g>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",s,a,l,v.numFeatures,v.numPoints,v.numSimplified),console.timeEnd("creation"));const e=`z${s}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(v.source=e,null==c){if(s===_.indexMaxZoom||v.numPoints<=_.indexMaxPoints)continue}else{if(s===_.maxZoom||s===c)continue;if(null!=c){const e=c-s;if(a!==u>>e||l!==p>>e)continue}}if(v.source=null,0===e.length)continue;g>1&&console.time("clipping");const w=.5*_.buffer/_.extent,C=.5-w,A=.5+w,k=1+w;let D=null,R=null,L=null,B=null,O=nt(e,y,a-w,a+A,0,v.minX,v.maxX,_),j=nt(e,y,a+C,a+k,0,v.minX,v.maxX,_);e=null,O&&(D=nt(O,y,l-w,l+A,1,v.minY,v.maxY,_),R=nt(O,y,l+C,l+k,1,v.minY,v.maxY,_),O=null),j&&(L=nt(j,y,l-w,l+A,1,v.minY,v.maxY,_),B=nt(j,y,l+C,l+k,1,v.minY,v.maxY,_),j=null),g>1&&console.timeEnd("clipping"),f.push(D||[],s+1,2*a,2*l),f.push(R||[],s+1,2*a,2*l+1),f.push(L||[],s+1,2*a+1,2*l),f.push(B||[],s+1,2*a+1,2*l+1)}}getTile(e,s,a){e=+e,s=+s,a=+a;const l=this.options,{extent:c,debug:u}=l;if(e<0||e>24)return null;const p=1<1&&console.log("drilling down to z%d-%d-%d",e,s,a);let _,g=e,y=s,x=a;for(;!_&&g>0;)g--,y>>=1,x>>=1,_=this.tiles[Nt(g,y,x)];return _&&_.source?(u>1&&(console.log("found parent tile z%d-%d-%d",g,y,x),console.time("drilling down")),this.splitTile(_.source,g,y,x,e,s,a),u>1&&console.timeEnd("drilling down"),this.tiles[f]?Tt(this.tiles[f],c):null):null}}function Nt(e,s,a){return 32*((1<{p.properties=e;const s={};for(const e of f)s[e]=l[e].evaluate(u,p);return s},s.reduce=(e,s)=>{p.properties=s;for(const s of f)u.accumulated=e[s],e[s]=c[s].evaluate(u,p)},s}(s)).load(a.features):function(e,s){return new te(e,s)}(a,s.geojsonVtOptions),this.loaded={};const c={data:a};if(l){const e=l.finish();e&&(c.resourceTiming={},c.resourceTiming[s.source]=JSON.parse(JSON.stringify(e)))}return c}catch(s){if(delete this._pendingRequest,e.cy(s))return{abandoned:!0};throw s}}))}getData(){return e._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){const s=this.loaded;return s&&s[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(s,a){return e._(this,void 0,void 0,(function*(){let l=yield this.loadGeoJSON(s,a);if(delete this._pendingRequest,"object"!=typeof l)throw new Error(`Input data given to '${s.source}' is not a valid GeoJSON object.`);if(u(l,!0),s.filter){const a=e.cT(s.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===a.result)throw new Error(a.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const c=l.features.filter((e=>a.value.evaluate({zoom:0},e)));l={type:"FeatureCollection",features:c}}return l}))}loadGeoJSON(s,a){return e._(this,void 0,void 0,(function*(){const{promoteId:l}=s;if(s.request){const c=yield e.j(s.request,a);return this._dataUpdateable=e.cV(c.data,l)?e.cU(c.data,l):void 0,c.data}if("string"==typeof s.data)try{const a=JSON.parse(s.data);return this._dataUpdateable=e.cV(a,l)?e.cU(a,l):void 0,a}catch(e){throw new Error(`Input data given to '${s.source}' is not a valid GeoJSON object.`)}if(!s.dataDiff)throw new Error(`Input data given to '${s.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${s.source}`);return e.cW(this._dataUpdateable,s.dataDiff,l),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(s){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class se{constructor(s){this.self=s,this.actor=new e.J(s),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,s)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=s},this.self.addProtocol=e.cA,this.self.removeProtocol=e.cB,this.self.registerRTLTextPlugin=s=>{e.cX.setMethods(s)},this.actor.registerMessageHandler("LDT",((e,s)=>this._getDEMWorkerSource(e,s.source).loadTile(s))),this.actor.registerMessageHandler("RDT",((s,a)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(s,a.source).removeTile(a)})))),this.actor.registerMessageHandler("GCEZ",((s,a)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,a.type,a.source).getClusterExpansionZoom(a)})))),this.actor.registerMessageHandler("GCC",((s,a)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,a.type,a.source).getClusterChildren(a)})))),this.actor.registerMessageHandler("GCL",((s,a)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,a.type,a.source).getClusterLeaves(a)})))),this.actor.registerMessageHandler("LD",((e,s)=>this._getWorkerSource(e,s.type,s.source).loadData(s))),this.actor.registerMessageHandler("GD",((e,s)=>this._getWorkerSource(e,s.type,s.source).getData())),this.actor.registerMessageHandler("LT",((e,s)=>this._getWorkerSource(e,s.type,s.source).loadTile(s))),this.actor.registerMessageHandler("RT",((e,s)=>this._getWorkerSource(e,s.type,s.source).reloadTile(s))),this.actor.registerMessageHandler("AT",((e,s)=>this._getWorkerSource(e,s.type,s.source).abortTile(s))),this.actor.registerMessageHandler("RMT",((e,s)=>this._getWorkerSource(e,s.type,s.source).removeTile(s))),this.actor.registerMessageHandler("RS",((s,a)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[s]||!this.workerSources[s][a.type]||!this.workerSources[s][a.type][a.source])return;const e=this.workerSources[s][a.type][a.source];delete this.workerSources[s][a.type][a.source],void 0!==e.removeSource&&e.removeSource(a)})))),this.actor.registerMessageHandler("RM",(s=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[s],delete this.availableImages[s],delete this.workerSources[s],delete this.demWorkerSources[s]})))),this.actor.registerMessageHandler("SR",((s,a)=>e._(this,void 0,void 0,(function*(){this.referrer=a})))),this.actor.registerMessageHandler("SRPS",((e,s)=>this._syncRTLPluginState(e,s))),this.actor.registerMessageHandler("IS",((s,a)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(a)})))),this.actor.registerMessageHandler("SI",((e,s)=>this._setImages(e,s))),this.actor.registerMessageHandler("UL",((s,a)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(s).update(a.layers,a.removedIds)})))),this.actor.registerMessageHandler("SL",((s,a)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(s).replace(a)}))))}_setImages(s,a){return e._(this,void 0,void 0,(function*(){this.availableImages[s]=a;for(const e in this.workerSources[s]){const l=this.workerSources[s][e];for(const e in l)l[e].availableImages=a}}))}_syncRTLPluginState(s,a){return e._(this,void 0,void 0,(function*(){return yield e.cX.syncState(a,this.self.importScripts)}))}_getAvailableImages(e){let s=this.availableImages[e];return s||(s=[]),s}_getLayerIndex(e){let s=this.layerIndexes[e];return s||(s=this.layerIndexes[e]=new t),s}_getWorkerSource(e,s,a){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][s]||(this.workerSources[e][s]={}),!this.workerSources[e][s][a]){const l={sendAsync:(s,a)=>(s.targetMapId=e,this.actor.sendAsync(s,a))};switch(s){case"vector":this.workerSources[e][s][a]=new n(l,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][s][a]=new oe(l,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][s][a]=new this.externalWorkerSourceTypes[s](l,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][s][a]}_getDEMWorkerSource(e,s){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][s]||(this.demWorkerSources[e][s]=new r),this.demWorkerSources[e][s]}}return e.i(self)&&(self.worker=new se(self)),se}));l("index",["exports","./shared"],(function(s,a){var l="5.6.2";function c(){var e=new a.A(4);return a.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let u,p;const f={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(e,s,l){const c=requestAnimationFrame((e=>{u(),s(e)})),{unsubscribe:u}=a.s(e.signal,"abort",(()=>{u(),cancelAnimationFrame(c),l(a.c())}),!1)},frameAsync(e){return new Promise(((s,a)=>{this.frame(e,s,a)}))},getImageData(e,s=0){return this.getImageCanvasContext(e).getImageData(-s,-s,e.width+2*s,e.height+2*s)},getImageCanvasContext(e){const s=window.document.createElement("canvas"),a=s.getContext("2d",{willReadFrequently:!0});if(!a)throw new Error("failed to create canvas 2d context");return s.width=e.width,s.height=e.height,a.drawImage(e,0,0,e.width,e.height),a},resolveURL:e=>(u||(u=document.createElement("a")),u.href=e,u.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==p&&(p=matchMedia("(prefers-reduced-motion: reduce)")),p.matches)}};class n{static testProp(e){if(!n.docStyle)return e[0];for(let s=0;s{window.removeEventListener("click",n.suppressClickInternal,!0)}),0)}static getScale(e){const s=e.getBoundingClientRect();return{x:s.width/e.offsetWidth||1,y:s.height/e.offsetHeight||1,boundingClientRect:s}}static getPoint(e,s,l){const c=s.boundingClientRect;return new a.P((l.clientX-c.left)/s.x-e.clientLeft,(l.clientY-c.top)/s.y-e.clientTop)}static mousePos(e,s){const a=n.getScale(e);return n.getPoint(e,a,s)}static touchPos(e,s){const a=[],l=n.getScale(e);for(let c=0;c{g&&w(g),g=null,v=!0},y.onerror=()=>{x=!0,g=null},y.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(s){let l,c,u,p;s.resetRequestQueue=()=>{l=[],c=0,u=0,p={}},s.addThrottleControl=e=>{const s=u++;return p[s]=e,s},s.removeThrottleControl=e=>{delete p[e],g()},s.getImage=(e,s,c=!0)=>new Promise(((u,p)=>{_.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),a.e(e,{type:"image"}),l.push({abortController:s,requestParameters:e,supportImageRefresh:c,state:"queued",onError:e=>{p(e)},onSuccess:e=>{u(e)}}),g()}));const f=s=>a._(this||e,void 0,void 0,(function*(){s.state="running";const{requestParameters:e,supportImageRefresh:l,onError:u,onSuccess:p,abortController:f}=s,_=!1===l&&!a.i(self)&&!a.g(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((e,s)=>e&&"accept"===s),!0));c++;const x=_?y(e,f):a.m(e,f);try{const e=yield x;delete s.abortController,s.state="completed",e.data instanceof HTMLImageElement||a.b(e.data)?p(e):e.data&&p({data:yield(v=e.data,"function"==typeof createImageBitmap?a.f(v):a.h(v)),cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete s.abortController,u(e)}finally{c--,g()}var v})),g=()=>{const e=(()=>{for(const e of Object.keys(p))if(p[e]())return!0;return!1})()?a.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:a.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let s=c;s0;s++){const e=l.shift();e.abortController.signal.aborted?s--:f(e)}},y=(e,s)=>new Promise(((l,c)=>{const u=new Image,p=e.url,f=e.credentials;f&&"include"===f?u.crossOrigin="use-credentials":(f&&"same-origin"===f||!a.d(p))&&(u.crossOrigin="anonymous"),s.signal.addEventListener("abort",(()=>{u.src="",c(a.c())})),u.fetchPriority="high",u.onload=()=>{u.onerror=u.onload=null,l({data:u})},u.onerror=()=>{u.onerror=u.onload=null,s.signal.aborted||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."))},u.src=p}))}(C||(C={})),C.resetRequestQueue();class m{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,s){return this._transformRequestFn&&this._transformRequestFn(e,s)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function A(e){const s=[];if("string"==typeof e)s.push({id:"default",url:e});else if(e&&e.length>0){const a=[];for(const{id:l,url:c}of e){const e=`${l}${c}`;-1===a.indexOf(e)&&(a.push(e),s.push({id:l,url:c}))}}return s}function k(e,s,a){try{const l=new URL(e);return l.pathname+=`${s}${a}`,l.toString()}catch(s){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function D(e){const{userImage:s}=e;return!!(s&&s.render&&s.render())&&(e.data.replace(new Uint8Array(s.data.buffer)),!0)}class b extends a.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:s}of this.requestors)s(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const s=this.images[e];if(s&&!s.data&&s.spriteData){const e=s.spriteData;s.data=new a.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),s.spriteData=null}return s}addImage(e,s){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,s)&&(this.images[e]=s)}_validate(e,s){let l=!0;const c=s.data||s.spriteData;return this._validateStretch(s.stretchX,c&&c.width)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "stretchX" value`))),l=!1),this._validateStretch(s.stretchY,c&&c.height)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "stretchY" value`))),l=!1),this._validateContent(s.content,s)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "content" value`))),l=!1),l}_validateStretch(e,s){if(!e)return!0;let a=0;for(const l of e){if(l[0]{let l=!0;if(!this.isLoaded())for(const s of e)this.images[s]||(l=!1);this.isLoaded()||l?s(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:s})}))}_getImagesForIds(e){const s={};for(const l of e){let e=this.getImage(l);e||(this.fire(new a.l("styleimagemissing",{id:l})),e=this.getImage(l)),e?s[l]={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)}:a.w(`Image "${l}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return s}getPixelSize(){const{width:e,height:s}=this.atlasImage;return{width:e,height:s}}getPattern(e){const s=this.patterns[e],l=this.getImage(e);if(!l)return null;if(s&&s.position.version===l.version)return s.position;if(s)s.position.version=l.version;else{const s={w:l.data.width+2,h:l.data.height+2,x:0,y:0},c=new a.I(s,l);this.patterns[e]={bin:s,position:c}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const s=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new a.T(e,this.atlasImage,s.RGBA),this.atlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const s in this.patterns)e.push(this.patterns[s].bin);const{w:s,h:l}=a.p(e),c=this.atlasImage;c.resize({width:s||1,height:l||1});for(const e in this.patterns){const{bin:s}=this.patterns[e],l=s.x+1,u=s.y+1,p=this.getImage(e).data,f=p.width,_=p.height;a.R.copy(p,c,{x:0,y:0},{x:l,y:u},{width:f,height:_}),a.R.copy(p,c,{x:0,y:_-1},{x:l,y:u-1},{width:f,height:1}),a.R.copy(p,c,{x:0,y:0},{x:l,y:u+_},{width:f,height:1}),a.R.copy(p,c,{x:f-1,y:0},{x:l-1,y:u},{width:1,height:_}),a.R.copy(p,c,{x:0,y:0},{x:l+f,y:u},{width:1,height:_})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const s of e){if(this.callbackDispatchedThisFrame[s])continue;this.callbackDispatchedThisFrame[s]=!0;const e=this.getImage(s);e||a.w(`Image with ID: "${s}" was not found`),D(e)&&this.updateImage(s,e)}}}const R=1e20;function L(e,s,a,l,c,u,p,f,_){for(let g=s;g-1);_++,u[_]=f,p[_]=g,p[_+1]=R}for(let f=0,_=0;f65535)throw new Error("glyphs > 65535 not supported");if(a.ranges[c])return{stack:e,id:s,glyph:l};if(!this.url)throw new Error("glyphsUrl is not set");if(!a.requests[c]){const s=T.loadGlyphRange(e,c,this.url,this.requestManager);a.requests[c]=s}const u=yield a.requests[c];for(const e in u)this._doesCharSupportLocalGlyph(+e)||(a.glyphs[+e]=u[+e]);return a.ranges[c]=!0,{stack:e,id:s,glyph:u[s]||null}}))}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))||a.u["CJK Unified Ideographs"](e)||a.u["Hangul Syllables"](e)||a.u.Hiragana(e)||a.u.Katakana(e)||a.u["CJK Symbols and Punctuation"](e)||a.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,s,l){const c=this.localIdeographFontFamily;if(!c)return;if(!this._doesCharSupportLocalGlyph(l))return;let u=e.tinySDF;if(!u){let a="400";/bold/i.test(s)?a="900":/medium/i.test(s)?a="500":/light/i.test(s)&&(a="200"),u=e.tinySDF=new T.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:c,fontWeight:a})}const p=u.draw(String.fromCharCode(l));return{id:l,bitmap:new a.q({width:p.width||60,height:p.height||60},p.data),metrics:{width:p.glyphWidth/2||24,height:p.glyphHeight/2||24,left:p.glyphLeft/2+.5||0,top:p.glyphTop/2-27.5||-8,advance:p.glyphAdvance/2||24,isDoubleResolution:!0}}}}T.loadGlyphRange=function(s,l,c,u){return a._(this||e,void 0,void 0,(function*(){const e=256*l,p=e+255,f=u.transformRequest(c.replace("{fontstack}",s).replace("{range}",`${e}-${p}`),"Glyphs"),_=yield a.n(f,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${l}, ${e}-${p}`);const g={};for(const e of a.o(_.data))g[e.id]=e;return g}))},T.TinySDF=class{constructor({fontSize:e=24,buffer:s=3,radius:a=8,cutoff:l=.25,fontFamily:c="sans-serif",fontWeight:u="normal",fontStyle:p="normal",lang:f=null}={}){this.buffer=s,this.cutoff=l,this.radius=a,this.lang=f;const _=this.size=e+4*s,g=this._createCanvas(_),y=this.ctx=g.getContext("2d",{willReadFrequently:!0});y.font=`${p} ${u} ${e}px ${c}`,y.textBaseline="alphabetic",y.textAlign="left",y.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(e){const s=document.createElement("canvas");return s.width=s.height=e,s}draw(e){const{width:s,actualBoundingBoxAscent:a,actualBoundingBoxDescent:l,actualBoundingBoxLeft:c,actualBoundingBoxRight:u}=this.ctx.measureText(e),p=Math.ceil(a),f=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(u-c))),_=Math.min(this.size-this.buffer,p+Math.ceil(l)),g=f+2*this.buffer,y=_+2*this.buffer,x=Math.max(g*y,0),v=new Uint8ClampedArray(x),w={data:v,width:g,height:y,glyphWidth:f,glyphHeight:_,glyphTop:p,glyphLeft:0,glyphAdvance:s};if(0===f||0===_)return w;const{ctx:C,buffer:A,gridInner:k,gridOuter:D}=this;this.lang&&(C.lang=this.lang),C.clearRect(A,A,f,_),C.fillText(e,A,A+p);const B=C.getImageData(A,A,f,_);D.fill(R,0,x),k.fill(0,0,x);for(let e=0;e<_;e++)for(let s=0;s0?e*e:0,k[l]=e<0?e*e:0}}L(D,0,0,g,y,g,this.f,this.v,this.z),L(k,A,A,f,_,g,this.f,this.v,this.z);for(let e=0;e1&&(p=e[++u]);const _=Math.abs(f-p.left),g=Math.abs(f-p.right),y=Math.min(_,g);let x;const v=s/a*(l+1);if(p.isDash){const e=l-Math.abs(v);x=Math.sqrt(y*y+e*e)}else x=l-Math.sqrt(y*y+v*v);this.data[c+f]=Math.max(0,Math.min(255,x+128))}}}addRegularDash(e){for(let s=e.length-1;s>=0;--s){const a=e[s],l=e[s+1];a.zeroLength?e.splice(s,1):l&&l.isDash===a.isDash&&(l.left=a.left,e.splice(s,1))}const s=e[0],a=e[e.length-1];s.isDash===a.isDash&&(s.left=a.left-this.width,a.right=s.right+this.width);const l=this.width*this.nextRow;let c=0,u=e[c];for(let s=0;s1&&(u=e[++c]);const a=Math.abs(s-u.left),p=Math.abs(s-u.right),f=Math.min(a,p);this.data[l+s]=Math.max(0,Math.min(255,(u.isDash?f:-f)+128))}}addDash(e,s){const l=s?7:0,c=2*l+1;if(this.nextRow+c>this.height)return a.w("LineAtlas out of space"),null;let u=0;for(let s=0;s{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[U]}numActive(){return Object.keys(this.active).length}}const N=Math.floor(f.hardwareConcurrency/2);let Z,J;function Q(){return Z||(Z=new z),Z}z.workerCount=a.H(globalThis)?Math.max(Math.min(N,3),1):1;class F{constructor(e,s){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=s;const l=this.workerPool.acquire(s);for(let e=0;e{e.remove()})),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,s){for(const a of this.actors)a.registerMessageHandler(e,s)}}function et(){return J||(J=new F(Q(),a.K),J.registerMessageHandler("GR",((e,s,l)=>a.m(s,l)))),J}function it(e,s){const l=a.L();return a.M(l,l,[1,1,0]),a.N(l,l,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?a.O(l,l,e.calculatePosMatrix(s.toUnwrapped())):l}function rt(e,s,a,l,c,u,p){var f;const _=function(e,s,a){if(e)for(const l of e){const e=s[l];if(e&&e.source===a&&"fill-extrusion"===e.type)return!0}else for(const e in s){const l=s[e];if(l.source===a&&"fill-extrusion"===l.type)return!0}return!1}(null!==(f=null==c?void 0:c.layers)&&void 0!==f?f:null,s,e.id),g=u.maxPitchScaleFactor(),y=e.tilesIn(l,g,_);y.sort(nt);const x=[];for(const l of y)x.push({wrappedTileID:l.tileID.wrapped().key,queryResults:l.tile.queryRenderedFeatures(s,a,e._state,l.queryGeometry,l.cameraQueryGeometry,l.scale,c,u,g,it(e.transform,l.tileID),p?(e,s)=>p(l.tileID,e,s):void 0)});return function(e,s){for(const a in e)for(const l of e[a])st(l,s);return e}(function(e){const s={},a={};for(const l of e){const e=l.queryResults,c=l.wrappedTileID,u=a[c]=a[c]||{};for(const a in e){const l=e[a],c=u[a]=u[a]||{},p=s[a]=s[a]||[];for(const e of l)c[e.featureIndex]||(c[e.featureIndex]=!0,p.push(e))}}return s}(x),e)}function nt(e,s){const a=e.tileID,l=s.tileID;return a.overscaledZ-l.overscaledZ||a.canonical.y-l.canonical.y||a.wrap-l.wrap||a.canonical.x-l.canonical.x}function st(e,s){const a=e.feature,l=s.getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=l}function ot(s,l,c){return a._(this||e,void 0,void 0,(function*(){let e=s;if(s.url?e=(yield a.j(l.transformRequest(s.url,"Source"),c)).data:yield f.frameAsync(c),!e)return null;const u=a.Q(a.e(e,s),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in e&&e.vector_layers&&(u.vectorLayerIds=e.vector_layers.map((e=>e.id))),u}))}class G{constructor(e,s){e&&(s?this.setSouthWest(e).setNorthEast(s):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof a.S?new a.S(e.lng,e.lat):a.S.convert(e),this}setSouthWest(e){return this._sw=e instanceof a.S?new a.S(e.lng,e.lat):a.S.convert(e),this}extend(e){const s=this._sw,l=this._ne;let c,u;if(e instanceof a.S)c=e,u=e;else{if(!(e instanceof G))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(G.convert(e)):this.extend(a.S.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(a.S.convert(e)):this;if(c=e._sw,u=e._ne,!c||!u)return this}return s||l?(s.lng=Math.min(c.lng,s.lng),s.lat=Math.min(c.lat,s.lat),l.lng=Math.max(u.lng,l.lng),l.lat=Math.max(u.lat,l.lat)):(this._sw=new a.S(c.lng,c.lat),this._ne=new a.S(u.lng,u.lat)),this}getCenter(){return new a.S((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 a.S(this.getWest(),this.getNorth())}getSouthEast(){return new a.S(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:s,lat:l}=a.S.convert(e);let c=this._sw.lng<=s&&s<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=s&&s>=this._ne.lng),this._sw.lat<=l&&l<=this._ne.lat&&c}static convert(e){return e instanceof G?e:e?new G(e):e}static fromLngLat(e,s=0){const l=360*s/40075017,c=l/Math.cos(Math.PI/180*e.lat);return new G(new a.S(e.lng-c,e.lat-l),new a.S(e.lng+c,e.lat+l))}adjustAntiMeridian(){const e=new a.S(this._sw.lng,this._sw.lat),s=new a.S(this._ne.lng,this._ne.lat);return new G(e,e.lng>s.lng?new a.S(s.lng+360,s.lat):s)}}class V{constructor(e,s,a){this.bounds=G.convert(this.validateBounds(e)),this.minzoom=s||0,this.maxzoom=a||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const s=Math.pow(2,e.z),l=Math.floor(a.V(this.bounds.getWest())*s),c=Math.floor(a.U(this.bounds.getNorth())*s),u=Math.ceil(a.V(this.bounds.getEast())*s),p=Math.ceil(a.U(this.bounds.getSouth())*s);return e.x>=l&&e.x=c&&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 a.e({},this._options)}loadTile(e){return a._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a={request:this.map._requestManager.transformRequest(s,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};a.request.collectResourceTiming=this._collectResourceTiming;let l="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((s,a)=>{e.reloadPromise={resolve:s,reject:a}}))}else e.actor=this.dispatcher.getActor(),l="LT";e.abortController=new AbortController;try{const s=yield e.actor.sendAsync({type:l,data:a},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,s)}catch(s){if(delete e.abortController,e.aborted)return;if(s&&404!==s.status)throw s;this._afterTileLoadWorkerResponse(e,null)}}))}_afterTileLoadWorkerResponse(e,s){if(s&&s.resourceTiming&&(e.resourceTiming=s.resourceTiming),s&&this.map._refreshExpiredTiles&&e.setExpiryData(s),e.loadVectorData(s,this.map.painter),e.reloadPromise){const s=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(s.resolve).catch(s.reject)}}abortTile(e){return a._(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 a._(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 q extends a.E{constructor(e,s,l,c){super(),this.id=e,this.dispatcher=l,this.setEventedParent(c),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=a.e({type:"raster"},s),a.e(this,a.Q(s,["url","scheme","tileSize"]))}load(){return a._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new a.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const s=yield ot(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,s&&(a.e(this,s),s.bounds&&(this.tileBounds=new V(s.bounds,this.minzoom,this.maxzoom)),this.fire(new a.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this.fire(new a.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 a.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return a._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const l=yield C.getImage(this.map._requestManager.transformRequest(s,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(l&&l.data){this.map._refreshExpiredTiles&&(l.cacheControl||l.expires)&&e.setExpiryData({cacheControl:l.cacheControl,expires:l.expires});const s=this.map.painter.context,c=s.gl,u=l.data;e.texture=this.map.painter.getTileTexture(u.width),e.texture?e.texture.update(u,{useMipmap:!0}):(e.texture=new a.T(s,u,c.RGBA,{useMipmap:!0}),e.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE,c.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(s){if(delete e.abortController,e.aborted)e.state="unloaded";else if(s)throw e.state="errored",s}}))}abortTile(e){return a._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return a._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class W extends q{constructor(e,s,l,c){super(e,s,l,c),this.type="raster-dem",this.maxzoom=22,this._options=a.e({type:"raster-dem"},s),this.encoding=s.encoding||"mapbox",this.redFactor=s.redFactor,this.greenFactor=s.greenFactor,this.blueFactor=s.blueFactor,this.baseShift=s.baseShift}loadTile(e){return a._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),l=this.map._requestManager.transformRequest(s,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const s=yield C.getImage(l,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(s&&s.data){const l=s.data;this.map._refreshExpiredTiles&&(s.cacheControl||s.expires)&&e.setExpiryData({cacheControl:s.cacheControl,expires:s.expires});const c=a.b(l)&&a.W()?l:yield this.readImageNow(l),u={type:this.type,uid:e.uid,source:this.id,rawImageData:c,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const s=yield e.actor.sendAsync({type:"LDT",data:u});e.dem=s,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(s){if(delete e.abortController,e.aborted)e.state="unloaded";else if(s)throw e.state="errored",s}}))}readImageNow(e){return a._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&a.X()){const s=e.width+2,l=e.height+2;try{return new a.R({width:s,height:l},yield a.Y(e,-1,-1,s,l))}catch(e){}}return f.getImageData(e,1)}))}_getNeighboringTiles(e){const s=e.canonical,l=Math.pow(2,s.z),c=(s.x-1+l)%l,u=0===s.x?e.wrap-1:e.wrap,p=(s.x+1+l)%l,f=s.x+1===l?e.wrap+1:e.wrap,_={};return _[new a.Z(e.overscaledZ,u,s.z,c,s.y).key]={backfilled:!1},_[new a.Z(e.overscaledZ,f,s.z,p,s.y).key]={backfilled:!1},s.y>0&&(_[new a.Z(e.overscaledZ,u,s.z,c,s.y-1).key]={backfilled:!1},_[new a.Z(e.overscaledZ,e.wrap,s.z,s.x,s.y-1).key]={backfilled:!1},_[new a.Z(e.overscaledZ,f,s.z,p,s.y-1).key]={backfilled:!1}),s.y+1e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return a._(this,void 0,void 0,(function*(){const e=new G,s=yield this.getData();let a;switch(s.type){case"FeatureCollection":a=s.features.map((e=>this.getCoordinatesFromGeometry(e.geometry))).flat(1/0);break;case"Feature":a=this.getCoordinatesFromGeometry(s.geometry);break;default:a=this.getCoordinatesFromGeometry(s)}if(0==a.length)return e;for(let s=0;s0&&a.e(c,{resourceTiming:s}),this.fire(new a.l("data",Object.assign(Object.assign({},c),{sourceDataType:"metadata"}))),this.fire(new a.l("data",Object.assign(Object.assign({},c),{sourceDataType:"content"})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new a.l("dataabort",{dataType:"source"}));this.fire(new a.k(e))}finally{(this._pendingWorkerUpdate.data||this._pendingWorkerUpdate.diff)&&this._updateWorkerData()}}))}loaded(){return!this._isUpdatingWorker&&void 0===this._pendingWorkerUpdate.data&&void 0===this._pendingWorkerUpdate.diff}loadTile(e){return a._(this,void 0,void 0,(function*(){const s=e.actor?"RT":"LT";e.actor=this.actor;const a={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,globalState:this.map.getGlobalState()};e.abortController=new AbortController;const l=yield this.actor.sendAsync({type:s,data:a},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(l,this.map.painter,"RT"===s)}))}abortTile(e){return a._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return a._(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 a.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class X extends a.E{constructor(e,s,a,l){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=a,this.coordinates=s.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(l),this.options=s}load(e){return a._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new a.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const s=yield C.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,s&&s.data&&(this.image=s.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,this.fire(new a.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 a.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const s=e.map(a.a1.fromLngLat);var l;return this.tileID=function(e){const s=a.a2.fromPoints(e),l=s.width(),c=s.height(),u=Math.max(l,c),p=Math.max(0,Math.floor(-Math.log(u)/Math.LN2)),f=Math.pow(2,p);return new a.a4(p,Math.floor((s.minX+s.maxX)/2*f),Math.floor((s.minY+s.maxY)/2*f))}(s),this.terrainTileRanges=this._getOverlappingTileRanges(s),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=s.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((l=this.tileCoords)[1].x-l[0].x)*(l[2].y-l[0].y)-(l[1].y-l[0].y)*(l[2].x-l[0].x)<0,this.fire(new a.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,s=e.gl;this.texture||(this.texture=new a.T(e,this.image,s.RGBA),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE));let l=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,l=!0)}l&&this.fire(new a.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return a._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:s,minY:l,maxX:c,maxY:u}=a.a2.fromPoints(e),p={};for(let e=0;e<=a.a3;e++){const a=Math.pow(2,e),f=Math.floor(s*a),_=Math.floor(l*a),g=Math.floor(c*a),y=Math.floor(u*a);p[e]={minTileX:f,minTileY:_,maxTileX:g,maxTileY:y}}return p}}class K extends X{constructor(e,s,a,l){super(e,s,a,l),this.roundZoom=!0,this.type="video",this.options=s}load(){return a._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const s of e.urls)this.urls.push(this.map._requestManager.transformRequest(s,"Source").url);try{const e=yield a.a5(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 a.k(e))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const s=this.video.seekable;es.end(0)?this.fire(new a.k(new a.a6(`sources.${this.id}`,null,`Playback for this video can be set only between the ${s.start(0)} and ${s.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,s=e.gl;this.texture?this.video.paused||(this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,this.video)):(this.texture=new a.T(e,this.video,s.RGBA),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE));let l=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,l=!0)}l&&this.fire(new a.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 Y extends X{constructor(e,s,l,c){super(e,s,l,c),s.coordinates?Array.isArray(s.coordinates)&&4===s.coordinates.length&&!s.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new a.k(new a.a6(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.k(new a.a6(`sources.${e}`,null,'missing required property "coordinates"'))),s.animate&&"boolean"!=typeof s.animate&&this.fire(new a.k(new a.a6(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),s.canvas?"string"==typeof s.canvas||s.canvas instanceof HTMLCanvasElement||this.fire(new a.k(new a.a6(`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 a.k(new a.a6(`sources.${e}`,null,'missing required property "canvas"'))),this.options=s,this.animate=void 0===s.animate||s.animate}load(){return a._(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 a.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const s=this.map.painter.context,l=s.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.T(s,this.canvas,l.RGBA,{premultiply:!0});let c=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,c=!0)}c&&this.fire(new a.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"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 at={},lt=e=>{switch(e){case"geojson":return H;case"image":return X;case"raster":return q;case"raster-dem":return W;case"vector":return $;case"video":return K;case"canvas":return Y}return at[e]},ct="RTLPluginLoaded";class te extends a.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=et()}_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 a._(this,arguments,void 0,(function*(e,s=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=f.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!s)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return a._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new a.l(ct))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let ht=null;function pt(){return ht||(ht=new te),ht}class re{constructor(e,s){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=a.a7(),this.uses=0,this.tileSize=s,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){const s=e+this.timeAdded;ss.getLayer(e))).filter(Boolean);if(0!==e.length){l.layers=e,l.stateDependentLayerIds&&(l.stateDependentLayers=l.stateDependentLayerIds.map((s=>e.filter((e=>e.id===s))[0])));for(const s of e)a[s.id]=l}}return a}(e.buckets,null==s?void 0:s.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const s=this.buckets[e];if(s instanceof a.a9){if(this.hasSymbolBuckets=!0,!l)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const s=this.buckets[e];if(s instanceof a.a9&&s.hasRTLText){this.hasRTLText=!0,pt().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const a=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,s.style.getLayer(e).queryRadius(a))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new a.a8}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.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const s in this.buckets){const a=this.buckets[s];a.uploadPending()&&a.upload(e)}const s=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new a.T(e,this.imageAtlas.image,s.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new a.T(e,this.glyphAtlasImage,s.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,s,a,l,c,u,p,f,_,g,y){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:l,cameraQueryGeometry:c,scale:u,tileSize:this.tileSize,pixelPosMatrix:g,transform:f,params:p,queryPadding:this.queryPadding*_,getElevation:y},e,s,a):{}}querySourceFeatures(e,s){const l=this.latestFeatureIndex;if(!l||!l.rawTileData)return;const c=l.loadVTLayers(),u=s&&s.sourceLayer?s.sourceLayer:"",p=c._geojsonTileLayer||c[u];if(!p)return;const f=a.aa(s&&s.filter),{z:_,x:g,y:y}=this.tileID.canonical,x={z:_,x:g,y:y};for(let s=0;se)a=!1;else if(s)if(this.expirationTime{this.remove(e,c)}),a)),this.data[l].push(c),this.order.push(l),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const s=this.data[e].shift();return s.timeout&&clearTimeout(s.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),s.value}getByKey(e){const s=this.data[e];return s?s[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,s){if(!this.has(e))return this;const a=e.wrapped().key,l=void 0===s?0:this.data[a].indexOf(s),c=this.data[a][l];return this.data[a].splice(l,1),c.timeout&&clearTimeout(c.timeout),0===this.data[a].length&&delete this.data[a],this.onRemove(c.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const s=[];for(const a in this.data)for(const l of this.data[a])e(l.value)||s.push(l);for(const e of s)this.remove(e.value.tileID,e)}}class se{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,s,l){const c=String(s);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][c]=this.stateChanges[e][c]||{},a.e(this.stateChanges[e][c],l),null===this.deletedStates[e]){this.deletedStates[e]={};for(const s in this.state[e])s!==c&&(this.deletedStates[e][s]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][c]){this.deletedStates[e][c]={};for(const s in this.state[e][c])l[s]||(this.deletedStates[e][c][s]=null)}else for(const s in l)this.deletedStates[e]&&this.deletedStates[e][c]&&null===this.deletedStates[e][c][s]&&delete this.deletedStates[e][c][s]}removeFeatureState(e,s,a){if(null===this.deletedStates[e])return;const l=String(s);if(this.deletedStates[e]=this.deletedStates[e]||{},a&&void 0!==s)null!==this.deletedStates[e][l]&&(this.deletedStates[e][l]=this.deletedStates[e][l]||{},this.deletedStates[e][l][a]=null);else if(void 0!==s)if(this.stateChanges[e]&&this.stateChanges[e][l])for(a in this.deletedStates[e][l]={},this.stateChanges[e][l])this.deletedStates[e][l][a]=null;else this.deletedStates[e][l]=null;else this.deletedStates[e]=null}getState(e,s){const l=String(s),c=a.e({},(this.state[e]||{})[l],(this.stateChanges[e]||{})[l]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const a=this.deletedStates[e][s];if(null===a)return{};for(const e in a)delete c[e]}return c}initializeTileState(e,s){e.setFeatureState(this.state,s)}coalesceChanges(e,s){const l={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const s={};for(const l in this.stateChanges[e])this.state[e][l]||(this.state[e][l]={}),a.e(this.state[e][l],this.stateChanges[e][l]),s[l]=this.state[e][l];l[e]=s}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const s={};if(null===this.deletedStates[e])for(const a in this.state[e])s[a]={},this.state[e][a]={};else for(const a in this.deletedStates[e]){if(null===this.deletedStates[e][a])this.state[e][a]={};else for(const s of Object.keys(this.deletedStates[e][a]))delete this.state[e][a][s];s[a]=this.state[e][a]}l[e]=l[e]||{},a.e(l[e],s)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(l).length)for(const a in e)e[a].setFeatureState(l,s)}}const xt=89.25;function bt(e,s){const l=a.ah(s.lat,-a.ai,a.ai);return new a.P(a.V(s.lng)*e,a.U(l)*e)}function Tt(e,s){return new a.a1(s.x/e,s.y/e).toLngLat()}function Pt(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(a.ae(90-e.pitch)),Math.tan(a.ae(xt-e.pitch)))}function St(e,s){const l=e.canonical,c=s/a.af(l.z),u=l.x+Math.pow(2,l.z)*e.wrap,p=a.ag(new Float64Array(16));return a.M(p,p,[u*c,l.y*c,0]),a.N(p,p,[c/a.$,c/a.$,1]),p}function Et(e,s,l,c,u){const p=a.a1.fromLngLat(e,s),f=u*a.aj(1,e.lat),_=f*Math.cos(a.ae(l)),g=Math.sqrt(f*f-_*_),y=g*Math.sin(a.ae(-c)),x=g*Math.cos(a.ae(-c));return new a.a1(p.x+y,p.y+x,p.z+_)}function kt(e,s,a){const l=s.intersectsFrustum(e);if(!a||0===l)return l;const c=s.intersectsPlane(a);return 0===c?0:2===l&&2===c?2:1}function Ft(e,s,a){let l=0;const c=(a-s)/10;for(let u=0;u<10;u++)l+=c*Math.pow(Math.cos(s+(u+.5)/10*(a-s)),e);return l}function Nt(e,s){return function(l,c,u,p,f){const _=2*((e-1)/a.ak(Math.cos(a.ae(xt-f))/Math.cos(a.ae(xt)))-1),g=Math.acos(u/p),y=2*Ft(_-1,0,a.ae(f/2)),x=Math.min(a.ae(xt),g+a.ae(f/2)),v=Ft(_-1,Math.min(x,g-a.ae(f/2)),x),w=Math.atan(c/u),C=Math.hypot(c,u);let A=l;return A+=a.ak(p/C/Math.max(.5,Math.cos(a.ae(f/2)))),A+=_*a.ak(Math.cos(w))/2,A-=a.ak(Math.max(1,v/y/s))/2,A}}const $t=Nt(9.314,3);function Gt(e,s){const l=(s.roundZoom?Math.round:Math.floor)(e.zoom+a.ak(e.tileSize/s.tileSize));return Math.max(0,l)}function qt(e,s){const l=e.getCameraFrustum(),c=e.getClippingPlane(),u=e.screenPointToMercatorCoordinate(e.getCameraPoint()),p=a.a1.fromLngLat(e.center,e.elevation);u.z=p.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const f=e.getCoveringTilesDetailsProvider(),_=f.allowVariableZoom(e,s),g=Gt(e,s),y=s.minzoom||0,x=void 0!==s.maxzoom?s.maxzoom:e.maxZoom,v=Math.min(Math.max(0,g),x),w=Math.pow(2,v),C=[w*u.x,w*u.y,0],A=[w*p.x,w*p.y,0],k=Math.hypot(p.x-u.x,p.y-u.y),D=Math.abs(p.z-u.z),R=Math.hypot(k,D),L=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),B=[],O=[];if(e.renderWorldCopies&&f.allowWorldCopies())for(let e=1;e<=3;e++)B.push(L(-e)),B.push(L(e));for(B.push(L(0));B.length>0;){const w=B.pop(),k=w.x,L=w.y;let j=w.fullyVisible;const U={x:k,y:L,z:w.zoom},N=f.getTileBoundingVolume(U,w.wrap,e.elevation,s);if(!j){const e=kt(l,N,c);if(0===e)continue;j=2===e}const Z=f.distanceToTile2d(u.x,u.y,U,N);let J=g;_&&(J=(s.calculateTileZoom||$t)(e.zoom+a.ak(e.tileSize/s.tileSize),Z,D,R,e.fov)),J=(s.roundZoom?Math.round:Math.floor)(J),J=Math.max(0,J);const Q=Math.min(J,x);if(w.wrap=f.getWrap(p,U,w.wrap),w.zoom>=Q){if(w.zoom>1),wrap:w.wrap,fullyVisible:j})}return O.sort(((e,s)=>e.distanceSq-s.distanceSq)).map((e=>e.tileID))}const Xt=a.a2.fromPoints([new a.P(0,0),new a.P(a.$,a.$)]);class xe extends a.E{constructor(e,s,a){super(),this.id=e,this.dispatcher=a,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((e,s,a,l)=>{const c=new(lt(s.type))(e,s,a,l);if(c.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${c.id}`);return c})(e,s,a,this),this._tiles={},this._cache=new ae(0,(e=>this._unloadTile(e))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new se,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){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}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 in this._tiles){const s=this._tiles[e];if("loaded"!==s.state&&"errored"!==s.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,s,l){return a._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,s,l)}catch(s){e.state="errored",404!==s.status?this._source.fire(new a.k(s,{tile:e})):this.update(this.transform,this.terrain)}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new a.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._tiles,this.map?this.map.painter:null);for(const s in this._tiles){const a=this._tiles[s];a.upload(e),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(Ht).map((e=>e.key))}getRenderableIds(e){const s=[];for(const a in this._tiles)this._isIdRenderable(a,e)&&s.push(this._tiles[a]);return e?s.sort(((e,s)=>{const l=e.tileID,c=s.tileID,u=new a.P(l.canonical.x,l.canonical.y)._rotate(-this.transform.bearingInRadians),p=new a.P(c.canonical.x,c.canonical.y)._rotate(-this.transform.bearingInRadians);return l.overscaledZ-c.overscaledZ||p.y-u.y||p.x-u.x})).map((e=>e.tileID.key)):s.map((e=>e.tileID)).sort(Ht).map((e=>e.key))}hasRenderableParent(e){const s=this.findLoadedParent(e,0);return!!s&&this._isIdRenderable(s.tileID.key)}_isIdRenderable(e,s){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(s||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const s in this._tiles)e?this._reloadTile(s,"expired"):"errored"!==this._tiles[s].state&&this._reloadTile(s,"reloading")}}_reloadTile(e,s){return a._(this,void 0,void 0,(function*(){const a=this._tiles[e];a&&("loading"!==a.state&&(a.state=s),yield this._loadTile(a,e,s))}))}_tileLoaded(e,s,l){e.timeAdded=f.now(),"expired"===l&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(s,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new a.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const s=this.getRenderableIds();for(let l=0;l1||(Math.abs(a)>1&&(1===Math.abs(a+c)?a+=c:1===Math.abs(a-c)&&(a-=c)),s.dem&&e.dem&&(e.dem.backfillBorder(s.dem,a,l),e.neighboringTiles&&e.neighboringTiles[u]&&(e.neighboringTiles[u].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,s,a,l){for(const c in this._tiles){let u=this._tiles[c];if(l[c]||!u.hasData()||u.tileID.overscaledZ<=s||u.tileID.overscaledZ>a)continue;let p=u.tileID;for(;u&&u.tileID.overscaledZ>s+1;){const e=u.tileID.scaledTo(u.tileID.overscaledZ-1);u=this._tiles[e.key],u&&u.hasData()&&(p=e)}let f=p;for(;f.overscaledZ>s;)if(f=f.scaledTo(f.overscaledZ-1),e[f.key]||e[f.canonical.key]){l[p.key]=p;break}}}findLoadedParent(e,s){if(e.key in this._loadedParentTiles){const a=this._loadedParentTiles[e.key];return a&&a.tileID.overscaledZ>=s?a:null}for(let a=e.overscaledZ-1;a>=s;a--){const s=e.scaledTo(a),l=this._getLoadedTile(s);if(l)return l}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const s=this._tiles[e.key];return s&&s.hasData()?s:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const s=Math.ceil(e.width/this._source.tileSize)+1,l=Math.ceil(e.height/this._source.tileSize)+1,c=Math.floor(s*l*(null===this._maxTileCacheZoomLevels?a.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),u="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,c):c;this._cache.setMaxSize(u)}handleWrapJump(e){const s=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,s){const e={};for(const a in this._tiles){const l=this._tiles[a];l.tileID=l.tileID.unwrapTo(l.tileID.wrap+s),e[l.tileID.key]=l}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e])}}_updateCoveredAndRetainedTiles(e,s,a,l,c,u){const p={},_={},g=Object.keys(e),y=f.now();for(const a of g){const l=e[a],c=this._tiles[a];if(!c||0!==c.fadeEndTime&&c.fadeEndTime<=y)continue;const u=this.findLoadedParent(l,s),f=this.findLoadedSibling(l),g=u||f||null;g&&(this._addTile(g.tileID),p[g.tileID.key]=g.tileID),_[a]=l}this._retainLoadedChildren(_,l,a,e);for(const s in p)e[s]||(this._coveredTiles[s]=!0,e[s]=p[s]);if(u){const s={},a={};for(const e of c)this._tiles[e.key].hasData()?s[e.key]=e:a[e.key]=e;for(const l in a){const c=a[l].children(this._source.maxzoom);this._tiles[c[0].key]&&this._tiles[c[1].key]&&this._tiles[c[2].key]&&this._tiles[c[3].key]&&(s[c[0].key]=e[c[0].key]=c[0],s[c[1].key]=e[c[1].key]=c[1],s[c[2].key]=e[c[2].key]=c[2],s[c[3].key]=e[c[3].key]=c[3],delete a[l])}for(const l in a){const c=a[l],u=this.findLoadedParent(c,this._source.minzoom),p=this.findLoadedSibling(c),f=u||p||null;if(f){s[f.tileID.key]=e[f.tileID.key]=f.tileID;for(const e in s)s[e].isChildOf(f.tileID)&&delete s[e]}}for(const e in this._tiles)s[e]||(this._coveredTiles[e]=!0)}}update(e,s){if(!this._sourceLoaded||this._paused)return;let l;this.transform=e,this.terrain=s,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?l=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new a.Z(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(l=qt(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:s,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(l=l.filter((e=>this._source.hasTile(e))))):l=[];const c=Gt(e,this._source),u=Math.max(c-xe.maxOverzooming,this._source.minzoom),p=Math.max(c+xe.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const e={};for(const s of l)if(s.canonical.z>this._source.minzoom){const a=s.scaledTo(s.canonical.z-1);e[a.key]=a;const l=s.scaledTo(Math.max(this._source.minzoom,Math.min(s.canonical.z,5)));e[l.key]=l}l=l.concat(Object.values(e))}const f=0===l.length&&!this._updated&&this._didEmitContent;this._updated=!0,f&&this.fire(new a.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const _=this._updateRetainedTiles(l,c);Kt(this._source.type)&&this._updateCoveredAndRetainedTiles(_,u,p,c,l,s);for(const e in _)this._tiles[e].clearFadeHold();const g=a.am(this._tiles,_);for(const e of g){const s=this._tiles[e];s.hasSymbolBuckets&&!s.holdingForFade()?s.setHoldDuration(this.map._fadeDuration):s.hasSymbolBuckets&&!s.symbolFadeFinished()||this._removeTile(e)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,s){var a;const l={},c={},u=Math.max(s-xe.maxOverzooming,this._source.minzoom),p=Math.max(s+xe.maxUnderzooming,this._source.minzoom),f={};for(const a of e){const e=this._addTile(a);l[a.key]=a,e.hasData()||sthis._source.maxzoom){const e=p.children(this._source.maxzoom)[0],s=this.getTile(e);if(s&&s.hasData()){l[e.key]=e;continue}}else{const e=p.children(this._source.maxzoom);if(l[e[0].key]&&l[e[1].key]&&l[e[2].key]&&l[e[3].key])continue}let f=e.wasRequested();for(let s=p.overscaledZ-1;s>=u;--s){const u=p.scaledTo(s);if(c[u.key])break;if(c[u.key]=!0,e=this.getTile(u),!e&&f&&(e=this._addTile(u)),e){const s=e.hasData();if((s||!(null===(a=this.map)||void 0===a?void 0:a.cancelPendingTileRequestsWhileZooming)||f)&&(l[u.key]=u),f=e.wasRequested(),s)break}}}return l}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const s=[];let a,l=this._tiles[e].tileID;for(;l.overscaledZ>0;){if(l.key in this._loadedParentTiles){a=this._loadedParentTiles[l.key];break}s.push(l.key);const e=l.scaledTo(l.overscaledZ-1);if(a=this._getLoadedTile(e),a)break;l=e}for(const e of s)this._loadedParentTiles[e]=a}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const s=this._tiles[e].tileID,a=this._getLoadedTile(s);this._loadedSiblingTiles[s.key]=a}}_addTile(e){let s=this._tiles[e.key];if(s)return s;s=this._cache.getAndRemove(e),s&&(this._setTileReloadTimer(e.key,s),s.tileID=e,this._state.initializeTileState(s,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,s)));const l=s;return s||(s=new re(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(s,e.key,s.state)),s.uses++,this._tiles[e.key]=s,l||this._source.fire(new a.l("dataloading",{tile:s,coord:s.tileID,dataType:"source"})),s}_setTileReloadTimer(e,s){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const a=s.getExpiryTimeout();a&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),a))}refreshTiles(e){for(const s in this._tiles)(this._isIdRenderable(s)||"errored"==this._tiles[s].state)&&e.some((e=>e.equals(this._tiles[s].tileID.canonical)))&&this._reloadTile(s,"expired")}_removeTile(e){const s=this._tiles[e];s&&(s.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),s.uses>0||(s.hasData()&&"reloading"!==s.state?this._cache.add(s.tileID,s,s.getExpiryTimeout()):(s.aborted=!0,this._abortTile(s),this._unloadTile(s))))}_dataHandler(e){const s=e.sourceDataType;"source"===e.dataType&&"metadata"===s&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===s&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,s,l){const c=[],u=this.transform;if(!u)return c;const p=u.getCoveringTilesDetailsProvider().allowWorldCopies(),f=l?u.getCameraQueryGeometry(e):e,_=e=>u.screenPointToMercatorCoordinate(e,this.terrain),g=this.transformBbox(e,_,!p),y=this.transformBbox(f,_,!p),x=this.getIds(),v=a.a2.fromPoints(y);for(let e=0;ee.getTilePoint(new a.a1(s.x,s.y))));if(s.expandBy(w),s.intersects(Xt)){const s=g.map((s=>e.getTilePoint(s))),a=y.map((s=>e.getTilePoint(s)));c.push({tile:l,tileID:p?e:e.unwrapTo(0),queryGeometry:s,cameraQueryGeometry:a,scale:_})}}}return c}transformBbox(e,s,l){let c=e.map(s);if(l){const l=a.a2.fromPoints(e);l.shrinkBy(.001*Math.min(l.width(),l.height()));const u=l.map(s);a.a2.fromPoints(c).covers(u)||(c=c.map((e=>e.x>.5?new a.a1(e.x-1,e.y,e.z):e)))}return c}getVisibleCoordinates(e){const s=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));return this.transform&&this.transform.populateCache(s),s}hasTransition(){if(this._source.hasTransition())return!0;if(Kt(this._source.type)){const e=f.now();for(const s in this._tiles)if(this._tiles[s].fadeEndTime>=e)return!0}return!1}setFeatureState(e,s,a){this._state.updateState(e=e||"_geojsonTileLayer",s,a)}removeFeatureState(e,s,a){this._state.removeFeatureState(e=e||"_geojsonTileLayer",s,a)}getFeatureState(e,s){return this._state.getState(e=e||"_geojsonTileLayer",s)}setDependencies(e,s,a){const l=this._tiles[e];l&&l.setDependencies(s,a)}reloadTilesForDependencies(e,s){for(const a in this._tiles)this._tiles[a].hasDependency(e,s)&&this._reloadTile(a,"reloading");this._cache.filter((a=>!a.hasDependency(e,s)))}}function Ht(e,s){const a=Math.abs(2*e.wrap)-+(e.wrap<0),l=Math.abs(2*s.wrap)-+(s.wrap<0);return e.overscaledZ-s.overscaledZ||l-a||s.canonical.y-e.canonical.y||s.canonical.x-e.canonical.x}function Kt(e){return"raster"===e||"image"===e||"video"===e}xe.maxOverzooming=10,xe.maxUnderzooming=3;class Te{constructor(e,s){this.reset(e,s)}reset(e,s){this.points=e||[],this._distances=[0];for(let e=1;e0?(c-p)/f:0;return this.points[u].mult(1-_).add(this.points[s].mult(_))}}function Qt(e,s){let a=!0;return"always"===e||"never"!==e&&"never"!==s||(a=!1),a}class Ce{constructor(e,s,a){const l=this.boxCells=[],c=this.circleCells=[];this.xCellCount=Math.ceil(e/a),this.yCellCount=Math.ceil(s/a);for(let e=0;ethis.width||l<0||s>this.height)return[];const f=[];if(e<=0&&s<=0&&this.width<=a&&this.height<=l){if(c)return[{key:null,x1:e,y1:s,x2:a,y2:l}];for(let e=0;e0}hitTestCircle(e,s,a,l,c){const u=e-a,p=e+a,f=s-a,_=s+a;if(p<0||u>this.width||_<0||f>this.height)return!1;const g=[];return this._forEachCell(u,f,p,_,this._queryCellCircle,g,{hitTest:!0,overlapMode:l,circle:{x:e,y:s,radius:a},seenUids:{box:{},circle:{}}},c),g.length>0}_queryCell(e,s,a,l,c,u,p,f){const{seenUids:_,hitTest:g,overlapMode:y}=p,x=this.boxCells[c];if(null!==x){const c=this.bboxes;for(const p of x)if(!_.box[p]){_.box[p]=!0;const x=4*p,v=this.boxKeys[p];if(e<=c[x+2]&&s<=c[x+3]&&a>=c[x+0]&&l>=c[x+1]&&(!f||f(v))&&(!g||!Qt(y,v.overlapMode))&&(u.push({key:v,x1:c[x],y1:c[x+1],x2:c[x+2],y2:c[x+3]}),g))return!0}}const v=this.circleCells[c];if(null!==v){const c=this.circles;for(const p of v)if(!_.circle[p]){_.circle[p]=!0;const x=3*p,v=this.circleKeys[p];if(this._circleAndRectCollide(c[x],c[x+1],c[x+2],e,s,a,l)&&(!f||f(v))&&(!g||!Qt(y,v.overlapMode))){const e=c[x],s=c[x+1],a=c[x+2];if(u.push({key:v,x1:e-a,y1:s-a,x2:e+a,y2:s+a}),g)return!0}}}return!1}_queryCellCircle(e,s,a,l,c,u,p,f){const{circle:_,seenUids:g,overlapMode:y}=p,x=this.boxCells[c];if(null!==x){const e=this.bboxes;for(const s of x)if(!g.box[s]){g.box[s]=!0;const a=4*s,l=this.boxKeys[s];if(this._circleAndRectCollide(_.x,_.y,_.radius,e[a+0],e[a+1],e[a+2],e[a+3])&&(!f||f(l))&&!Qt(y,l.overlapMode))return u.push(!0),!0}}const v=this.circleCells[c];if(null!==v){const e=this.circles;for(const s of v)if(!g.circle[s]){g.circle[s]=!0;const a=3*s,l=this.circleKeys[s];if(this._circlesCollide(e[a],e[a+1],e[a+2],_.x,_.y,_.radius)&&(!f||f(l))&&!Qt(y,l.overlapMode))return u.push(!0),!0}}}_forEachCell(e,s,a,l,c,u,p,f){const _=this._convertToXCellCoord(e),g=this._convertToYCellCoord(s),y=this._convertToXCellCoord(a),x=this._convertToYCellCoord(l);for(let v=_;v<=y;v++)for(let _=g;_<=x;_++)if(c.call(this,e,s,a,l,this.xCellCount*_+v,u,p,f))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,s,a,l,c,u){const p=l-e,f=c-s,_=a+u;return _*_>p*p+f*f}_circleAndRectCollide(e,s,a,l,c,u,p){const f=(u-l)/2,_=Math.abs(e-(l+f));if(_>f+a)return!1;const g=(p-c)/2,y=Math.abs(s-(c+g));if(y>g+a)return!1;if(_<=f||y<=g)return!0;const x=_-f,v=y-g;return x*x+v*v<=a*a}}function ee(e,s,l){const u=a.L();if(!e){const{vecSouth:e,vecEast:a}=ne(s),l=c();l[0]=a[0],l[1]=a[1],l[2]=e[0],l[3]=e[1],p=l,(v=(_=(f=l)[0])*(x=f[3])-(y=f[2])*(g=f[1]))&&(p[0]=x*(v=1/v),p[1]=-g*v,p[2]=-y*v,p[3]=_*v),u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3]}var p,f,_,g,y,x,v;return a.N(u,u,[1/l,1/l,1]),u}function ie(e,s,l,c){if(e){const e=a.L();if(!s){const{vecSouth:s,vecEast:a}=ne(l);e[0]=a[0],e[1]=a[1],e[4]=s[0],e[5]=s[1]}return a.N(e,e,[c,c,1]),e}return l.pixelsToClipSpaceMatrix}function ne(e){const s=Math.cos(e.rollInRadians),l=Math.sin(e.rollInRadians),c=Math.cos(e.pitchInRadians),u=Math.cos(e.bearingInRadians),p=Math.sin(e.bearingInRadians),f=a.ar();f[0]=-u*c*l-p*s,f[1]=-p*c*l+u*s;const _=a.as(f);_<1e-9?a.at(f):a.au(f,f,1/_);const g=a.ar();g[0]=u*c*s-p*l,g[1]=p*c*s+u*l;const y=a.as(g);return y<1e-9?a.at(g):a.au(g,g,1/y),{vecEast:g,vecSouth:f}}function le(e,s,l,c){let u;c?(u=[e,s,c(e,s),1],a.aw(u,u,l)):(u=[e,s,0,1],ke(u,u,l));const p=u[3];return{point:new a.P(u[0]/p,u[1]/p),signedDistanceFromCamera:p,isOccluded:!1}}function ce(e,s){return.5+e/s*.5}function he(e,s){return e.x>=-s[0]&&e.x<=s[0]&&e.y>=-s[1]&&e.y<=s[1]}function ue(e,s,l,c,u,p,f,_,g,y,x,v,w){const C=l?e.textSizeData:e.iconSizeData,A=a.an(C,s.transform.zoom),k=[256/s.width*2+1,256/s.height*2+1],D=l?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;D.clear();const R=e.lineVertexArray,L=l?e.text.placedSymbolArray:e.icon.placedSymbolArray,B=s.transform.width/s.transform.height;let O=!1;for(let l=0;lMath.abs(l.x-s.x)*c?{useVertical:!0}:(e===a.ao.vertical?s.yl.x)?{needsFlipping:!0}:null}function fe(e){const{projectionContext:s,pitchedLabelPlaneMatrixInverse:l,symbol:c,fontSize:u,flip:p,keepUpright:f,glyphOffsetArray:_,dynamicLayoutVertexArray:g,aspectRatio:y,rotateToLine:x}=e,v=u/24,w=c.lineOffsetX*v,C=c.lineOffsetY*v;let A;if(c.numGlyphs>1){const e=c.glyphStartIndex+c.numGlyphs,a=c.lineStartIndex,u=c.lineStartIndex+c.lineLength,g=de(v,_,w,C,p,c,x,s);if(!g)return{notEnoughRoom:!0};const k=ye(g.first.point.x,g.first.point.y,s,l),D=ye(g.last.point.x,g.last.point.y,s,l);if(f&&!p){const e=pe(c.writingMode,k,D,y);if(e)return e}A=[g.first];for(let l=c.glyphStartIndex+1;l0?f.point:me(s.tileAnchorPoint,p,e,1,s),g=ye(e.x,e.y,s,l),x=ye(_.x,_.y,s,l),v=pe(c.writingMode,g,x,y);if(v)return v}const e=Se(v*_.getoffsetX(c.glyphStartIndex),w,C,p,c.segment,c.lineStartIndex,c.lineStartIndex+c.lineLength,s,x);if(!e||s.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};A=[e]}for(const e of A)a.av(g,e.point,e.angle);return{}}function me(e,s,a,l,c){const u=e.add(e.sub(s)._unit()),p=ge(u.x,u.y,c).point,f=a.sub(p);return a.add(f._mult(l/f.mag()))}function _e(e,s,l){const c=s.projectionCache;if(c.projections[e])return c.projections[e];const u=new a.P(s.lineVertexArray.getx(e),s.lineVertexArray.gety(e)),p=ge(u.x,u.y,s);if(p.signedDistanceFromCamera>0)return c.projections[e]=p.point,c.anyProjectionOccluded=c.anyProjectionOccluded||p.isOccluded,p.point;const f=e-l.direction;return me(0===l.distanceFromAnchor?s.tileAnchorPoint:new a.P(s.lineVertexArray.getx(f),s.lineVertexArray.gety(f)),u,l.previousVertex,l.absOffsetX-l.distanceFromAnchor+1,s)}function ge(e,s,a){const l=e+a.translation[0],c=s+a.translation[1];let u;return a.pitchWithMap?(u=le(l,c,a.pitchedLabelPlaneMatrix,a.getElevation),u.isOccluded=!1):(u=a.transform.projectTileCoordinates(l,c,a.unwrappedTileID,a.getElevation),u.point.x=(.5*u.point.x+.5)*a.width,u.point.y=(.5*-u.point.y+.5)*a.height),u}function ye(e,s,l,c){if(l.pitchWithMap){const u=[e,s,0,1];return a.aw(u,u,c),l.transform.projectTileCoordinates(u[0]/u[3],u[1]/u[3],l.unwrappedTileID,l.getElevation).point}return{x:e/l.width*2-1,y:1-s/l.height*2}}function ve(e,s,a){return a.transform.projectTileCoordinates(e,s,a.unwrappedTileID,a.getElevation)}function be(e,s,a){return e._unit()._perp()._mult(s*a)}function we(e,s,l,c,u,p,f,_,g){if(_.projectionCache.offsets[e])return _.projectionCache.offsets[e];const y=l.add(s);if(e+g.direction=u)return _.projectionCache.offsets[e]=y,y;const x=_e(e+g.direction,_,g),v=be(x.sub(l),f,g.direction),w=l.add(v),C=x.add(v);return _.projectionCache.offsets[e]=a.ax(p,y,w,C)||y,_.projectionCache.offsets[e]}function Se(e,s,a,l,c,u,p,f,_){const g=l?e-s:e+s;let y=g>0?1:-1,x=0;l&&(y*=-1,x=Math.PI),y<0&&(x+=Math.PI);let v,w=y>0?u+c:u+c+1;f.projectionCache.cachedAnchorPoint?v=f.projectionCache.cachedAnchorPoint:(v=ge(f.tileAnchorPoint.x,f.tileAnchorPoint.y,f).point,f.projectionCache.cachedAnchorPoint=v);let C,A,k=v,D=v,R=0,L=0;const B=Math.abs(g),O=[];let j;for(;R+L<=B;){if(w+=y,w=p)return null;R+=L,D=k,A=C;const e={absOffsetX:B,direction:y,distanceFromAnchor:R,previousVertex:D};if(k=_e(w,f,e),0===a)O.push(D),j=k.sub(D);else{let s;const l=k.sub(D);s=0===l.mag()?be(_e(w+y,f,e).sub(k),a,y):be(l,a,y),A||(A=D.add(s)),C=we(w,s,k,u,p,A,a,f,e),O.push(A),j=C.sub(A)}L=j.mag()}const U=j._mult((B-R)/L)._add(A||D),N=x+Math.atan2(k.y-D.y,k.x-D.x);return O.push(U),{point:U,angle:_?N:0,path:O}}const Ae=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ze(e,s){for(let a=0;a=1;e--)w.push(p.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let k=[];if(w.length>0){const e=w[0].clone(),s=w[0].clone();for(let a=1;a=l.x&&s.x<=c.x&&e.y>=l.y&&s.y<=c.y?[w]:s.xc.x||s.yc.y?[]:a.ay([w],l.x,l.y,c.x,c.y)}for(const a of k){u.reset(a,.25*s);let l=0;l=u.length<=.5*s?1:Math.ceil(u.paddedLength/C)+1;for(let a=0;a{const a=le(e.x,e.y,l,s.getElevation),c=s.transform.projectTileCoordinates(a.point.x,a.point.y,s.unwrappedTileID,s.getElevation);return c.point.x=(.5*c.point.x+.5)*s.width,c.point.y=(.5*-c.point.y+.5)*s.height,c}))}(e,s);return function(e){let s=0,a=0,l=0,c=0;for(let u=0;ua&&(a=c,s=l));return e.slice(s,s+a)}(l)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const s=[],l=new a.a2;for(const c of e){const e=new a.P(c.x+De,c.y+De);l.extend(e),s.push(e)}const{minX:c,minY:u,maxX:p,maxY:f}=l,_=this.grid.query(c,u,p,f).concat(this.ignoredGrid.query(c,u,p,f)),g={},y={};for(const e of _){const l=e.key;if(void 0===g[l.bucketInstanceId]&&(g[l.bucketInstanceId]={}),g[l.bucketInstanceId][l.featureIndex])continue;const c=[new a.P(e.x1,e.y1),new a.P(e.x2,e.y1),new a.P(e.x2,e.y2),new a.P(e.x1,e.y2)];a.az(s,c)&&(g[l.bucketInstanceId][l.featureIndex]=!0,void 0===y[l.bucketInstanceId]&&(y[l.bucketInstanceId]=[]),y[l.bucketInstanceId].push(l.featureIndex))}return y}insertCollisionBox(e,s,a,l,c,u){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:c,collisionGroupID:u,overlapMode:s},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,s,a,l,c,u){const p=a?this.ignoredGrid:this.grid,f={bucketInstanceId:l,featureIndex:c,collisionGroupID:u,overlapMode:s};for(let s=0;s=this.screenRightBoundary||lthis.screenBottomBoundary}isInsideGrid(e,s,a,l){return a>=0&&e=0&&sthis.projectAndGetPerspectiveRatio(e.x,e.y,c,g,x)));it=e.some((e=>!e.isOccluded)),et=e.map((e=>new a.P(e.x,e.y)))}else it=!0;return{box:a.aA(et),allPointsOccluded:!it}}}class Xe{constructor(e,s,a,l){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?s:-s))):l&&a?1:0,this.placed=a}isHidden(){return 0===this.opacity&&!this.placed}}class Ke{constructor(e,s,a,l,c){this.text=new Xe(e?e.text:null,s,a,c),this.icon=new Xe(e?e.icon:null,s,l,c)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ye{constructor(e,s,a){this.text=e,this.icon=s,this.skipFade=a}}class Qe{constructor(e,s,a,l,c){this.bucketInstanceId=e,this.featureIndex=s,this.sourceLayerIndex=a,this.bucketIndex=l,this.tileID=c}}class Je{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const s=++this.maxGroupID;this.collisionGroups[e]={ID:s,predicate:e=>e.collisionGroupID===s}}return this.collisionGroups[e]}}function Re(e,s,l,c,u){const{horizontalAlign:p,verticalAlign:f}=a.aH(e);return new a.P(-(p-.5)*s+c[0]*u,-(f-.5)*l+c[1]*u)}class tt{constructor(e,s,a,l,c){this.transform=e.clone(),this.terrain=s,this.collisionIndex=new He(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new Je(l),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=c,c&&(c.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const s=this.terrain;return s?(a,l)=>s.getElevation(e,a,l):null}getBucketParts(e,s,l,c){const u=l.getBucket(s),p=l.latestFeatureIndex;if(!u||!p||s.id!==u.layerIds[0])return;const f=l.collisionBoxArray,_=u.layers[0].layout,g=u.layers[0].paint,y=Math.pow(2,this.transform.zoom-l.tileID.overscaledZ),x=l.tileSize/a.$,v=l.tileID.toUnwrapped(),w="map"===_.get("text-rotation-alignment"),C=a.aC(l,1,this.transform.zoom),A=a.aD(this.collisionIndex.transform,l,g.get("text-translate"),g.get("text-translate-anchor")),k=a.aD(this.collisionIndex.transform,l,g.get("icon-translate"),g.get("icon-translate-anchor")),D=ee(w,this.transform,C);this.retainedQueryData[u.bucketInstanceId]=new Qe(u.bucketInstanceId,p,u.sourceLayerIndex,u.index,l.tileID);const R={bucket:u,layout:_,translationText:A,translationIcon:k,unwrappedTileID:v,pitchedLabelPlaneMatrix:D,scale:y,textPixelRatio:x,holdingForFade:l.holdingForFade(),collisionBoxArray:f,partiallyEvaluatedTextSize:a.an(u.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(u.sourceID)};if(c)for(const s of u.sortKeyRanges){const{sortKey:a,symbolInstanceStart:l,symbolInstanceEnd:c}=s;e.push({sortKey:a,symbolInstanceStart:l,symbolInstanceEnd:c,parameters:R})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:u.symbolInstances.length,parameters:R})}attemptAnchorPlacement(e,s,l,c,u,p,f,_,g,y,x,v,w,C,A,k,D,R,L,B){const O=a.aE[e.textAnchor],j=[e.textOffset0,e.textOffset1],U=Re(O,l,c,j,u),N=this.collisionIndex.placeCollisionBox(s,v,_,g,y,f,p,k,x.predicate,L,U,B);if((!R||this.collisionIndex.placeCollisionBox(R,v,_,g,y,f,p,D,x.predicate,L,U,B).placeable)&&N.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[w.crossTileID]&&this.prevPlacement.placements[w.crossTileID]&&this.prevPlacement.placements[w.crossTileID].text&&(e=this.prevPlacement.variableOffsets[w.crossTileID].anchor),0===w.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[w.crossTileID]={textOffset:j,width:l,height:c,anchor:O,textBoxScale:u,prevAnchor:e},this.markUsedJustification(C,O,w,A),C.allowVerticalPlacement&&(this.markUsedOrientation(C,A,w),this.placedOrientations[w.crossTileID]=A),{shift:U,placedGlyphBoxes:N}}}placeLayerBucketPart(e,s,l){const{bucket:c,layout:u,translationText:p,translationIcon:f,unwrappedTileID:_,pitchedLabelPlaneMatrix:g,textPixelRatio:y,holdingForFade:x,collisionBoxArray:v,partiallyEvaluatedTextSize:w,collisionGroup:C}=e.parameters,A=u.get("text-optional"),k=u.get("icon-optional"),D=a.aF(u,"text-overlap","text-allow-overlap"),R="always"===D,L=a.aF(u,"icon-overlap","icon-allow-overlap"),B="always"===L,O="map"===u.get("text-rotation-alignment"),j="map"===u.get("text-pitch-alignment"),U="none"!==u.get("icon-text-fit"),N="viewport-y"===u.get("symbol-z-order"),Z=R&&(B||!c.hasIconData()||k),J=B&&(R||!c.hasTextData()||A);!c.collisionArrays&&v&&c.deserializeCollisionBoxes(v);const Q=this.retainedQueryData[c.bucketInstanceId].tileID,et=this._getTerrainElevationFunc(Q),it=this.transform.getFastPathSimpleProjectionMatrix(Q),rt=(e,v,B)=>{var N,rt;if(s[e.crossTileID])return;if(x)return void(this.placements[e.crossTileID]=new Ye(!1,!1,!1));let nt=!1,st=!1,ot=!0,at=null,lt={box:null,placeable:!1,offscreen:null,occluded:!1},ct={placeable:!1},ht=null,pt=null,xt=null,bt=0,Tt=0,Pt=0;v.textFeatureIndex?bt=v.textFeatureIndex:e.useRuntimeCollisionCircles&&(bt=e.featureIndex),v.verticalTextFeatureIndex&&(Tt=v.verticalTextFeatureIndex);const St=v.textBox;if(St){const s=s=>{let l=a.ao.horizontal;if(c.allowVerticalPlacement&&!s&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[e.crossTileID];s&&(this.placedOrientations[e.crossTileID]=s,l=s,this.markUsedOrientation(c,l,e))}return l},u=(s,l)=>{if(c.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&v.verticalTextBox){for(const e of c.writingModes)if(e===a.ao.vertical?(lt=l(),ct=lt):lt=s(),lt&<.placeable)break}else lt=s()},g=e.textAnchorOffsetStartIndex,x=e.textAnchorOffsetEndIndex;if(x===g){const l=(s,a)=>{const l=this.collisionIndex.placeCollisionBox(s,D,y,Q,_,j,O,p,C.predicate,et,void 0,it);return l&&l.placeable&&(this.markUsedOrientation(c,a,e),this.placedOrientations[e.crossTileID]=a),l};u((()=>l(St,a.ao.horizontal)),(()=>{const s=v.verticalTextBox;return c.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&s?l(s,a.ao.vertical):{box:null,offscreen:null}})),s(lt&<.placeable)}else{let w=a.aE[null===(rt=null===(N=this.prevPlacement)||void 0===N?void 0:N.variableOffsets[e.crossTileID])||void 0===rt?void 0:rt.anchor];const A=(s,a,u)=>{const v=s.x2-s.x1,A=s.y2-s.y1,k=e.textBoxScale,R=U&&"never"===L?a:null;let B=null,N="never"===D?1:2,Z="never";w&&N++;for(let a=0;aA(St,v.iconBox,a.ao.horizontal)),(()=>{const s=v.verticalTextBox;return c.allowVerticalPlacement&&(!lt||!lt.placeable)&&e.numVerticalGlyphVertices>0&&s?A(s,v.verticalIconBox,a.ao.vertical):{box:null,occluded:!0,offscreen:null}})),lt&&(nt=lt.placeable,ot=lt.offscreen);const k=s(lt&<.placeable);if(!nt&&this.prevPlacement){const s=this.prevPlacement.variableOffsets[e.crossTileID];s&&(this.variableOffsets[e.crossTileID]=s,this.markUsedJustification(c,s.anchor,e,k))}}}if(ht=lt,nt=ht&&ht.placeable,ot=ht&&ht.offscreen,e.useRuntimeCollisionCircles){const s=c.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),f=a.ap(c.textSizeData,w,s),y=u.get("text-padding");pt=this.collisionIndex.placeCollisionCircles(D,s,c.lineVertexArray,c.glyphOffsetArray,f,_,g,l,j,C.predicate,e.collisionCircleDiameter,y,p,et),pt.circles.length&&pt.collisionDetected&&!l&&a.w("Collisions detected, but collision boxes are not shown"),nt=R||pt.circles.length>0&&!pt.collisionDetected,ot=ot&&pt.offscreen}if(v.iconFeatureIndex&&(Pt=v.iconFeatureIndex),v.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,L,y,Q,_,j,O,f,C.predicate,et,U&&at?at:void 0,it);ct&&ct.placeable&&v.verticalIconBox?(xt=e(v.verticalIconBox),st=xt.placeable):(xt=e(v.iconBox),st=xt.placeable),ot=ot&&xt.offscreen}const Et=A||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,kt=k||0===e.numIconVertices;Et||kt?kt?Et||(st=st&&nt):nt=st&&nt:st=nt=st&&nt;const Ft=st&&xt.placeable;if(nt&&ht.placeable&&this.collisionIndex.insertCollisionBox(ht.box,D,u.get("text-ignore-placement"),c.bucketInstanceId,ct&&ct.placeable&&Tt?Tt:bt,C.ID),Ft&&this.collisionIndex.insertCollisionBox(xt.box,L,u.get("icon-ignore-placement"),c.bucketInstanceId,Pt,C.ID),pt&&nt&&this.collisionIndex.insertCollisionCircles(pt.circles,D,u.get("text-ignore-placement"),c.bucketInstanceId,bt,C.ID),l&&this.storeCollisionData(c.bucketInstanceId,B,v,ht,xt,pt),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===c.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Ye((nt||Z)&&!(null==ht?void 0:ht.occluded),(st||J)&&!(null==xt?void 0:xt.occluded),ot||c.justReloaded),s[e.crossTileID]=!0};if(N){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const s=c.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=s.length-1;e>=0;--e){const a=s[e];rt(c.symbolInstances.get(a),c.collisionArrays[a],a)}}else for(let s=e.symbolInstanceStart;s=0&&(e.text.placedSymbolArray.get(s).crossTileID=u>=0&&s!==u?0:l.crossTileID)}markUsedOrientation(e,s,l){const c=s===a.ao.horizontal||s===a.ao.horizontalOnly?s:0,u=s===a.ao.vertical?s:0,p=[l.leftJustifiedTextSymbolIndex,l.centerJustifiedTextSymbolIndex,l.rightJustifiedTextSymbolIndex];for(const s of p)e.text.placedSymbolArray.get(s).placedOrientation=c;l.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(l.verticalPlacedTextSymbolIndex).placedOrientation=u)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const s=this.prevPlacement;let a=!1;this.prevZoomAdjustment=s?s.zoomAdjustment(this.transform.zoom):0;const l=s?s.symbolFadeChange(e):1,c=s?s.opacities:{},u=s?s.variableOffsets:{},p=s?s.placedOrientations:{};for(const e in this.placements){const s=this.placements[e],u=c[e];u?(this.opacities[e]=new Ke(u,l,s.text,s.icon),a=a||s.text!==u.text.placed||s.icon!==u.icon.placed):(this.opacities[e]=new Ke(null,l,s.text,s.icon,s.skipFade),a=a||s.text||s.icon)}for(const e in c){const s=c[e];if(!this.opacities[e]){const c=new Ke(s,l,!1,!1);c.isHidden()||(this.opacities[e]=c,a=a||s.text.placed||s.icon.placed)}}for(const e in u)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=u[e]);for(const e in p)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=p[e]);if(s&&void 0===s.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=s?s.lastPlacementChangeTime:e)}updateLayerOpacities(e,s){const a={};for(const l of s){const s=l.getBucket(e);s&&l.latestFeatureIndex&&e.id===s.layerIds[0]&&this.updateBucketOpacities(s,l.tileID,a,l.collisionBoxArray)}}updateBucketOpacities(e,s,l,c){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 u=e.layers[0],p=u.layout,f=new Ke(null,0,!1,!1,!0),_=p.get("text-allow-overlap"),g=p.get("icon-allow-overlap"),y=u._unevaluatedLayout.hasValue("text-variable-anchor")||u._unevaluatedLayout.hasValue("text-variable-anchor-offset"),x="map"===p.get("text-rotation-alignment"),v="map"===p.get("text-pitch-alignment"),w="none"!==p.get("icon-text-fit"),C=new Ke(null,0,_&&(g||!e.hasIconData()||p.get("icon-optional")),g&&(_||!e.hasTextData()||p.get("text-optional")),!0);!e.collisionArrays&&c&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(c);const A=(e,s,a)=>{for(let l=0;l0,R=this.placedOrientations[c.crossTileID],L=R===a.ao.vertical,B=R===a.ao.horizontal||R===a.ao.horizontalOnly;if(u>0||p>0){const s=li(g.text);A(e.text,u,L?ci:s),A(e.text,p,B?ci:s);const a=g.text.isHidden();[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex].forEach((s=>{s>=0&&(e.text.placedSymbolArray.get(s).hidden=a||L?1:0)})),c.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).hidden=a||B?1:0);const l=this.variableOffsets[c.crossTileID];l&&this.markUsedJustification(e,l.anchor,c,R);const f=this.placedOrientations[c.crossTileID];f&&(this.markUsedJustification(e,"left",c,f),this.markUsedOrientation(e,f,c))}if(D){const s=li(g.icon),a=!(w&&c.verticalPlacedIconSymbolIndex&&L);c.placedIconSymbolIndex>=0&&(A(e.icon,c.numIconVertices,a?s:ci),e.icon.placedSymbolArray.get(c.placedIconSymbolIndex).hidden=g.icon.isHidden()),c.verticalPlacedIconSymbolIndex>=0&&(A(e.icon,c.numVerticalIconVertices,a?ci:s),e.icon.placedSymbolArray.get(c.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}const O=k&&k.has(s)?k.get(s):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const l=e.collisionArrays[s];if(l){let s=new a.P(0,0);if(l.textBox||l.verticalTextBox){let a=!0;if(y){const e=this.variableOffsets[_];e?(s=Re(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),x&&s._rotate(v?-this.transform.bearingInRadians:this.transform.bearingInRadians)):a=!1}if(l.textBox||l.verticalTextBox){let c;l.textBox&&(c=L),l.verticalTextBox&&(c=B),Fe(e.textCollisionBox.collisionVertexArray,g.text.placed,!a||c,O.text,s.x,s.y)}}if(l.iconBox||l.verticalIconBox){const a=Boolean(!B&&l.verticalIconBox);let c;l.iconBox&&(c=a),l.verticalIconBox&&(c=!a),Fe(e.iconCollisionBox.collisionVertexArray,g.icon.placed,c,O.icon,w?s.x:0,w?s.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function Fe(e,s,a,l,c,u){l&&0!==l.length||(l=[0,0,0,0]);const p=l[0]-De,f=l[1]-De,_=l[2]-De,g=l[3]-De;e.emplaceBack(s?1:0,a?1:0,c||0,u||0,p,f),e.emplaceBack(s?1:0,a?1:0,c||0,u||0,_,f),e.emplaceBack(s?1:0,a?1:0,c||0,u||0,_,g),e.emplaceBack(s?1:0,a?1:0,c||0,u||0,p,g)}const je=Math.pow(2,25),Ue=Math.pow(2,24),qe=Math.pow(2,17),ei=Math.pow(2,16),ri=Math.pow(2,9),si=Math.pow(2,8),oi=Math.pow(2,1);function li(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const s=e.placed?1:0,a=Math.floor(127*e.opacity);return a*je+s*Ue+a*qe+s*ei+a*ri+s*si+a*oi+s}const ci=0;class dt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,s,a,l,c){const u=this._bucketParts;for(;this._currentTileIndexe.sortKey-s.sortKey)));this._currentPartIndex!this._forceFullPlacement&&f.now()-l>2;for(;this._currentPlacementIndex>=0;){const l=s[e[this._currentPlacementIndex]],u=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=u)&&(!l.maxzoom||l.maxzoom>u)){if(this._inProgressLayer||(this._inProgressLayer=new dt(l)),this._inProgressLayer.continuePlacement(a[l.source],this.placement,this._showCollisionBoxes,l,c))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const di=512/a.$/2;class mt{constructor(e,s,l){this.tileID=e,this.bucketInstanceId=l,this._symbolsByKey={};const c=new Map;for(let e=0;e({x:Math.floor(e.anchorX*di),y:Math.floor(e.anchorY*di)}))),crossTileIDs:s.map((e=>e.crossTileID))};if(l.positions.length>128){const e=new a.aI(l.positions.length,16,Uint16Array);for(const{x:s,y:a}of l.positions)e.add(s,a);e.finish(),delete l.positions,l.index=e}this._symbolsByKey[e]=l}}getScaledCoordinates(e,s){const{x:l,y:c,z:u}=this.tileID.canonical,{x:p,y:f,z:_}=s.canonical,g=di/Math.pow(2,_-u),y=(f*a.$+e.anchorY)*g,x=c*a.$*di;return{x:Math.floor((p*a.$+e.anchorX)*g-l*a.$*di),y:Math.floor(y-x)}}findMatches(e,s,a){const l=this.tileID.canonical.ze))}}class ft{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class gt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const s=Math.round((e-this.lng)/360);if(0!==s)for(const e in this.indexes){const a=this.indexes[e],l={};for(const e in a){const c=a[e];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+s),l[c.tileID.key]=c}this.indexes[e]=l}this.lng=e}addBucket(e,s,a){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===s.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;ee.overscaledZ)for(const a in c){const u=c[a];u.tileID.isChildOf(e)&&u.findMatches(s.symbolInstances,e,l)}else{const u=c[e.scaledTo(Number(a)).key];u&&u.findMatches(s.symbolInstances,e,l)}}for(let e=0;e{s[e]=!0}));for(const e in this.layerIndexes)s[e]||delete this.layerIndexes[e]}}var mi="void main() {fragColor=vec4(1.0);}";const _i={prelude:yi("#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:yi("","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:yi("","#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:yi("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:yi("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:yi("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:yi(mi,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:yi("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:yi("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:yi("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:yi("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:yi("#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:yi("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:yi(mi,"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:yi("#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:yi("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:yi("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:yi("#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:yi("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:yi("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:yi("#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:yi("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:yi("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:yi("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:yi("#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:yi("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;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\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\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);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_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_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;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\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\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_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:yi("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:yi("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:yi("#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:yi("#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:yi("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:yi("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:yi("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:yi("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:yi("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:yi("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 yi(e,s){const a=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,l=s.match(/in ([\w]+) ([\w]+)/g),c=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),u=s.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),p=u?u.concat(c):c,f={};return{fragmentSource:e=e.replace(a,((e,s,a,l,c)=>(f[c]=!0,"define"===s?`\n#ifndef HAS_UNIFORM_u_${c}\nin ${a} ${l} ${c};\n#else\nuniform ${a} ${l} u_${c};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${c}\n ${a} ${l} ${c} = u_${c};\n#endif\n`))),vertexSource:s=s.replace(a,((e,s,a,l,c)=>{const u="float"===l?"vec2":"vec4",p=c.match(/color/)?"color":u;return f[c]?"define"===s?`\n#ifndef HAS_UNIFORM_u_${c}\nuniform lowp float u_${c}_t;\nin ${a} ${u} a_${c};\nout ${a} ${l} ${c};\n#else\nuniform ${a} ${l} u_${c};\n#endif\n`:"vec4"===p?`\n#ifndef HAS_UNIFORM_u_${c}\n ${c} = a_${c};\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${c}\n ${c} = unpack_mix_${p}(a_${c}, u_${c}_t);\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`:"define"===s?`\n#ifndef HAS_UNIFORM_u_${c}\nuniform lowp float u_${c}_t;\nin ${a} ${u} a_${c};\n#else\nuniform ${a} ${l} u_${c};\n#endif\n`:"vec4"===p?`\n#ifndef HAS_UNIFORM_u_${c}\n ${a} ${l} ${c} = a_${c};\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${c}\n ${a} ${l} ${c} = unpack_mix_${p}(a_${c}, u_${c}_t);\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`})),staticAttributes:l,staticUniforms:p}}class wt{constructor(e,s,a){this.vertexBuffer=e,this.indexBuffer=s,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var xi=a.aJ([{name:"a_pos",type:"Int16",components:2}]);const Ti="#define PROJECTION_MERCATOR",Mi="mercator";class It{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Mi}get shaderDefine(){return Ti}get shaderPreludeCode(){return _i.projectionMercator}get vertexShaderPreludeCode(){return _i.projectionMercator.vertexSource}get subdivisionGranularity(){return a.aK.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,s,l,c,u){if(this._cachedMesh)return this._cachedMesh;const p=new a.aL;p.emplaceBack(0,0),p.emplaceBack(a.$,0),p.emplaceBack(0,a.$),p.emplaceBack(a.$,a.$);const f=e.createVertexBuffer(p,xi.members),_=a.aM.simpleSegment(0,0,4,2),g=new a.aN;g.emplaceBack(1,0,2),g.emplaceBack(1,2,3);const y=e.createIndexBuffer(g);return this._cachedMesh=new wt(f,y,_),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Mt{constructor(e=0,s=0,a=0,l=0){if(isNaN(e)||e<0||isNaN(s)||s<0||isNaN(a)||a<0||isNaN(l)||l<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=s,this.left=a,this.right=l}interpolate(e,s,l){return null!=s.top&&null!=e.top&&(this.top=a.C.number(e.top,s.top,l)),null!=s.bottom&&null!=e.bottom&&(this.bottom=a.C.number(e.bottom,s.bottom,l)),null!=s.left&&null!=e.left&&(this.left=a.C.number(e.left,s.left,l)),null!=s.right&&null!=e.right&&(this.right=a.C.number(e.right,s.right,l)),this}getCenter(e,s){const l=a.ah((this.left+e-this.right)/2,0,e),c=a.ah((this.top+s-this.bottom)/2,0,s);return new a.P(l,c)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Mt(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Ci(e,s){if(!e.renderWorldCopies||e.lngRange)return;const a=s.lng-e.center.lng;s.lng+=a>180?-360:a<-180?360:0}function Ii(e){return Math.max(0,Math.floor(e))}class Rt{constructor(e,s,l,c,u,p){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===p||!!p,this._minZoom=s||0,this._maxZoom=l||22,this._minPitch=null==c?0:c,this._maxPitch=null==u?60:u,this.setMaxBounds(),this._width=0,this._height=0,this._center=new a.S(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Ii(this._zoom),this._scale=a.af(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Mt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,s,l){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=Ii(this._zoom),this._scale=a.af(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 Mt(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=!l&&e.autoCalculateNearFarZ,s&&this._constrain(),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.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(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 worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const s=a.aO(e,-180,180)*Math.PI/180;var l,u,p,f,_,g,y,x,v;this._bearingInRadians!==s&&(this._unmodified=!1,this._bearingInRadians=s,this._calcMatrices(),this._rotationMatrix=c(),l=this._rotationMatrix,p=-this._bearingInRadians,f=(u=this._rotationMatrix)[0],_=u[1],g=u[2],y=u[3],x=Math.sin(p),v=Math.cos(p),l[0]=f*v+g*x,l[1]=_*v+y*x,l[2]=f*-x+g*v,l[3]=_*-x+y*v)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const s=a.ah(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==s&&(this._unmodified=!1,this._pitchInRadians=s,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const s=e/180*Math.PI;this._rollInRadians!==s&&(this._unmodified=!1,this._rollInRadians=s,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return a.aP(this._fovInRadians)}setFov(e){e=a.ah(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=a.ae(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const s=this.getConstrained(this._center,e).zoom;this._zoom!==s&&(this._unmodified=!1,this._zoom=s,this._tileZoom=Math.max(0,Math.floor(s)),this._scale=a.af(s),this._constrain(),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._constrain(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,s){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=s,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,s,a){this._unmodified=!1,this._edgeInsets.interpolate(e,s,a),this._constrain(),this._calcMatrices()}resize(e,s,a=!0){this._width=e,this._height=s,a&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new G([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._constrain()):(this._lngRange=null,this._latRange=[-a.ai,a.ai])}getConstrained(e,s){return this._callbacks.getConstrained(e,s)}getCameraQueryGeometry(e,s){if(1===s.length)return[s[0],e];{const{minX:l,minY:c,maxX:u,maxY:p}=a.a2.fromPoints(s).extend(e);return[new a.P(l,c),new a.P(u,c),new a.P(u,p),new a.P(l,p),new a.P(l,c)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:s,zoom:a}=this.getConstrained(this.center,this.zoom);this.setCenter(s),this.setZoom(a),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=a.ag(new Float64Array(16));a.N(e,e,[this._width/2,-this._height/2,1]),a.M(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=a.ag(new Float64Array(16)),a.N(e,e,[1,-1,1]),a.M(e,e,[-1,-1,0]),a.N(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,s,l,c){const u=void 0!==l?l:this.bearing,p=c=void 0!==c?c:this.pitch,f=a.a1.fromLngLat(e,s),_=-Math.cos(a.ae(p)),g=Math.sin(a.ae(p)),y=g*Math.sin(a.ae(u)),x=-g*Math.cos(a.ae(u));let v=this.elevation;const w=s-v;let C;_*w>=0||Math.abs(_)<.1?(C=1e4,v=s+C*_):C=-w/_;let A,k,D=a.aQ(1,f.y),R=0;do{if(R+=1,R>10)break;k=C/D,A=new a.a1(f.x+y*k,f.y+x*k),D=1/A.meterInMercatorCoordinateUnits()}while(Math.abs(C-k*D)>1e-12);return{center:A.toLngLat(),elevation:v,zoom:a.ak(this.height/2/Math.tan(this.fovInRadians/2)/k/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const s=a.aj(1,this.center.lat)*this.worldSize,l=this.cameraToCenterDistance/s,c=a.a1.fromLngLat(this.center,this.elevation),u=Et(this.center,this.elevation,this.pitch,this.bearing,l);this._elevation=e;const p=this.calculateCenterFromCameraLngLatAlt(u.toLngLat(),a.aQ(u.z,c.y),this.bearing,this.pitch);this._elevation=p.elevation,this._center=p.center,this.setZoom(p.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.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=a.aj(1,this.center.lat)*this.worldSize;return Et(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const s=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(s+=e[l]*this.min[l],a+=e[l]*this.max[l]):(a+=e[l]*this.min[l],s+=e[l]*this.max[l]);return s>=0?2:a<0?0:1}}class Dt{distanceToTile2d(e,s,a,l){const c=l.distanceX([e,s]),u=l.distanceY([e,s]);return Math.hypot(c,u)}getWrap(e,s,a){return a}getTileBoundingVolume(e,s,l,c){var u,p;let f=0,_=0;if(null==c?void 0:c.terrain){const g=new a.Z(e.z,s,e.z,e.x,e.y),y=c.terrain.getMinMaxElevation(g);f=null!==(u=y.minElevation)&&void 0!==u?u:Math.min(0,l),_=null!==(p=y.maxElevation)&&void 0!==p?p:Math.max(0,l)}const g=1<c}allowWorldCopies(){return!0}prepareNextFrame(){}}class At{constructor(e,s,a){this.points=e,this.planes=s,this.aabb=a}static fromInvProjectionMatrix(e,s=1,l=0,c,u){const p=u?[[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]],f=Math.pow(2,l),_=[[-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((l=>function(e,s,l,c){const u=a.aw([],e,s),p=1/u[3]/l*c;return a.aY(u,u,[p,p,1/u[3],p])}(l,e,s,f)));c&&function(e,s,l,c){const u=c?4:0,p=c?0:4;let f=0;const _=[],g=[];for(let s=0;s<4;s++){const l=a.aU([],e[s+p],e[s+u]),c=a.aZ(l);a.aR(l,l,1/c),_.push(c),g.push(l)}for(let s=0;s<4;s++){const c=a.a_(e[s+u],g[s],l);f=null!==c&&c>=0?Math.max(f,c):Math.max(f,_[s])}const y=function(e,s){const l=a.aU([],e[s[0]],e[s[1]]),c=a.aU([],e[s[2]],e[s[1]]),u=[0,0,0,0];return a.aV(u,a.aW([],l,c)),u[3]=-a.aX(u,e[s[0]]),u}(e,s),x=function(e,s){const l=a.a$(e),c=a.b0([],e,1/l),u=a.aU([],s,a.aR([],c,a.aX(s,c))),p=a.a$(u);if(p>0){const e=Math.sqrt(1-c[3]*c[3]),l=a.aR([],c,-c[3]),f=a.aS([],l,a.aR([],u,e/p));return a.b1(s,f)}return null}(l,y);if(null!==x){const e=x/a.aX(g[0],y);f=Math.min(f,e)}for(let s=0;s<4;s++){const a=Math.min(f,_[s]);e[s+p]=[e[s+u][0]+g[s][0]*a,e[s+u][1]+g[s][1]*a,e[s+u][2]+g[s][2]*a,1]}}(_,p[0],c,u);const g=p.map((e=>{const s=a.aU([],_[e[0]],_[e[1]]),l=a.aU([],_[e[2]],_[e[1]]),c=a.aV([],a.aW([],s,l)),u=-a.aX(c,_[e[1]]);return c.concat(u)})),y=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],x=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of _)for(let s=0;s<3;s++)y[s]=Math.min(y[s],e[s]),x[s]=Math.max(x[s],e[s]);return new At(_,g,new zt(y,x))}}class Lt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,s,a){return this._helper.interpolatePadding(e,s,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,s,a=!0){this._helper.resize(e,s,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,s){this._helper.overrideNearFarZ(e,s)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,s){}constructor(e,s,a,l,c){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Rt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,s)=>this.getConstrained(e,s)},e,s,a,l,c),this._coveringTilesDetailsProvider=new Dt}clone(){const e=new Lt;return e.apply(this),e}apply(e,s,a){this._helper.apply(e,s,a)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const s=[new a.b2(0,e)];if(this._helper._renderWorldCopies){const l=this.screenPointToMercatorCoordinate(new a.P(0,0)),c=this.screenPointToMercatorCoordinate(new a.P(this._helper._width,0)),u=this.screenPointToMercatorCoordinate(new a.P(this._helper._width,this._helper._height)),p=this.screenPointToMercatorCoordinate(new a.P(0,this._helper._height)),f=Math.floor(Math.min(l.x,c.x,u.x,p.x)),_=Math.floor(Math.max(l.x,c.x,u.x,p.x)),g=1;for(let l=f-g;l<=_+g;l++)0!==l&&s.push(new a.b2(l,e))}return s}getCameraFrustum(){return At.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const s=this.screenPointToLocation(this.centerPoint,e),a=e?e.getElevationForLngLatZoom(s,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(a)}setLocationAtPoint(e,s){const l=a.aj(this.elevation,this.center.lat),c=this.screenPointToMercatorCoordinateAtZ(s,l),u=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,l),p=a.a1.fromLngLat(e),f=new a.a1(p.x-(c.x-u.x),p.y-(c.y-u.y));this.setCenter(null==f?void 0:f.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,s){return s?this.coordinatePoint(a.a1.fromLngLat(e),s.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(a.a1.fromLngLat(e))}screenPointToLocation(e,s){var a;return null===(a=this.screenPointToMercatorCoordinate(e,s))||void 0===a?void 0:a.toLngLat()}screenPointToMercatorCoordinate(e,s){if(s){const a=s.pointCoordinate(e);if(null!=a)return a}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,s){const l=s||0,c=[e.x,e.y,0,1],u=[e.x,e.y,1,1];a.aw(c,c,this._pixelMatrixInverse),a.aw(u,u,this._pixelMatrixInverse);const p=c[3],f=u[3],_=c[1]/p,g=u[1]/f,y=c[2]/p,x=u[2]/f,v=y===x?0:(l-y)/(x-y);return new a.a1(a.C.number(c[0]/p,u[0]/f,v)/this.worldSize,a.C.number(_,g,v)/this.worldSize,l)}coordinatePoint(e,s=0,l=this._pixelMatrix){const c=[e.x*this.worldSize,e.y*this.worldSize,s,1];return a.aw(c,c,l),new a.P(c[0]/c[3],c[1]/c[3])}getBounds(){const e=Math.max(0,this._helper._height/2-Pt(this));return(new G).extend(this.screenPointToLocation(new a.P(0,e))).extend(this.screenPointToLocation(new a.P(this._helper._width,e))).extend(this.screenPointToLocation(new a.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new a.P(0,this._helper._height)))}isPointOnMapSurface(e,s){return s?null!=s.pointCoordinate(e):e.y>this.height/2-Pt(this)}calculatePosMatrix(e,s=!1,l){var c;const u=null!==(c=e.key)&&void 0!==c?c:a.b3(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),p=s?this._alignedPosMatrixCache:this._posMatrixCache;if(p.has(u)){const e=p.get(u);return l?e.f32:e.f64}const f=St(e,this.worldSize);a.O(f,s?this._alignedProjMatrix:this._viewProjMatrix,f);const _={f64:f,f32:new Float32Array(f)};return p.set(u,_),l?_.f32:_.f64}calculateFogMatrix(e){const s=e.key,l=this._fogMatrixCacheF32;if(l.has(s))return l.get(s);const c=St(e,this.worldSize);return a.O(c,this._fogMatrix,c),l.set(s,new Float32Array(c)),l.get(s)}getConstrained(e,s){s=a.ah(+s,this.minZoom,this.maxZoom);const l={center:new a.S(e.lng,e.lat),zoom:s};let c=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===c){const e=180-1e-10;c=[-e,e]}const u=this.tileSize*a.af(l.zoom);let p=0,f=u,_=0,g=u,y=0,x=0;const{x:v,y:w}=this.size;if(this._helper._latRange){const e=this._helper._latRange;p=a.U(e[1])*u,f=a.U(e[0])*u,f-pf&&(D=f-e)}if(c){const e=(_+g)/2;let s=C;this._helper._renderWorldCopies&&(s=a.aO(C,e-u/2,e+u/2));const l=v/2;s-l<_&&(k=_+l),s+l>g&&(k=g-l)}if(void 0!==k||void 0!==D){const e=new a.P(null!=k?k:C,null!=D?D:A);l.center=Tt(u,e).wrap()}return l}calculateCenterFromCameraLngLatAlt(e,s,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,a,l)}_calculateNearFarZIfNeeded(e,s,l){if(!this._helper.autoCalculateNearFarZ)return;const c=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),u=e-c*this._helper._pixelPerMeter/Math.cos(s),p=c<0?u:e,f=Math.PI/2+this.pitchInRadians,_=a.ae(this.fov)*(Math.abs(Math.cos(a.ae(this.roll)))*this.height+Math.abs(Math.sin(a.ae(this.roll)))*this.width)/this.height*(.5+l.y/this.height),g=Math.sin(_)*p/Math.sin(a.ah(Math.PI-f-_,.01,Math.PI-.01)),y=Pt(this),x=Math.atan(y/this._helper.cameraToCenterDistance),v=a.ae(.75),w=x>v?2*x*(.5+l.y/(2*y)):v,C=Math.sin(w)*p/Math.sin(a.ah(Math.PI-f-w,.01,Math.PI-.01)),A=Math.min(g,C);this._helper._farZ=1.01*(Math.cos(Math.PI/2-s)*A+p),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,s=bt(this.worldSize,this.center),l=s.x,c=s.y;this._helper._pixelPerMeter=a.aj(1,this.center.lat)*this.worldSize;const u=a.ae(Math.min(this.pitch,xt)),p=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(u));let f;this._calculateNearFarZIfNeeded(p,u,e),f=new Float64Array(16),a.b4(f,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),a.aq(this._invProjMatrix,f),f[8]=2*-e.x/this._helper._width,f[9]=2*e.y/this._helper._height,this._projectionMatrix=a.b5(f),a.N(f,f,[1,-1,1]),a.M(f,f,[0,0,-this._helper.cameraToCenterDistance]),a.b6(f,f,-this.rollInRadians),a.b7(f,f,this.pitchInRadians),a.b6(f,f,-this.bearingInRadians),a.M(f,f,[-l,-c,0]),this._mercatorMatrix=a.N([],f,[this.worldSize,this.worldSize,this.worldSize]),a.N(f,f,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=a.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,f),a.M(f,f,[0,0,-this.elevation]),this._viewProjMatrix=f,this._invViewProjMatrix=a.aq([],f);const _=[0,0,-1,1];a.aw(_,_,this._invViewProjMatrix),this._cameraPosition=[_[0]/_[3],_[1]/_[3],_[2]/_[3]],this._fogMatrix=new Float64Array(16),a.b4(this._fogMatrix,this.fovInRadians,this.width/this.height,p,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,a.N(this._fogMatrix,this._fogMatrix,[1,-1,1]),a.M(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),a.b6(this._fogMatrix,this._fogMatrix,-this.rollInRadians),a.b7(this._fogMatrix,this._fogMatrix,this.pitchInRadians),a.b6(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),a.M(this._fogMatrix,this._fogMatrix,[-l,-c,0]),a.N(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),a.M(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=a.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,f);const g=this._helper._width%2/2,y=this._helper._height%2/2,x=Math.cos(this.bearingInRadians),v=Math.sin(-this.bearingInRadians),w=l-Math.round(l)+x*g+v*y,C=c-Math.round(c)+x*y+v*g,A=new Float64Array(f);if(a.M(A,A,[w>.5?w-1:w,C>.5?C-1:C,0]),this._alignedProjMatrix=A,f=a.aq(new Float64Array(16),this._pixelMatrix),!f)throw new Error("failed to invert matrix");this._pixelMatrixInverse=f,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new a.P(0,0)),s=[e.x*this.worldSize,e.y*this.worldSize,0,1];return a.aw(s,s,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=a.aj(1,this.center.lat)*this.worldSize;return Et(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,s){const l=a.a1.fromLngLat(e),c=[l.x*this.worldSize,l.y*this.worldSize,s,1];return a.aw(c,c,this._viewProjMatrix),c[2]/c[3]}getProjectionData(e){const{overscaledTileID:s,aligned:l,applyTerrainMatrix:c}=e,u=this._helper.getMercatorTileCoordinates(s),p=s?this.calculatePosMatrix(s,l,!0):null;let f;return f=s&&s.terrainRttPosMatrix32f&&c?s.terrainRttPosMatrix32f:p||a.b8(),{mainMatrix:f,tileMercatorCoords:u,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:f}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,s,a){return 1}transformLightDirection(e){return a.aT(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,s,l,c){const u=this.calculatePosMatrix(l);let p;c?(p=[e,s,c(e,s),1],a.aw(p,p,u)):(p=[e,s,0,1],ke(p,p,u));const f=p[3];return{point:new a.P(p[0]/f,p[1]/f),signedDistanceFromCamera:f,isOccluded:!1}}populateCache(e){for(const s of e)this.calculatePosMatrix(s)}getMatrixForModel(e,s){const l=a.a1.fromLngLat(e,s),c=l.meterInMercatorCoordinateUnits(),u=a.b9();return a.M(u,u,[l.x,l.y,l.z]),a.b6(u,u,Math.PI),a.b7(u,u,Math.PI/2),a.N(u,u,[-c,c,c]),u}getProjectionDataForCustomLayer(e=!0){const s=new a.Z(0,0,0,0,0),l=this.getProjectionData({overscaledTileID:s,applyGlobeMatrix:e}),c=St(s,this.worldSize);a.O(c,this._viewProjMatrix,c),l.tileMercatorCoords=[0,0,1,1];const u=[a.$,a.$,this.worldSize/this._helper.pixelsPerMeter],p=a.ba();return a.N(p,c,u),l.fallbackMatrix=p,l.mainMatrix=p,l}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Ei(){a.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Ai(e){if(e.useSlerp)if(e.k<1){const s=a.bb(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),l=a.bb(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),c=new Float64Array(4);a.bc(c,s,l,e.k);const u=a.bd(c);e.tr.setRoll(u.roll),e.tr.setPitch(u.pitch),e.tr.setBearing(u.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(a.C.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(a.C.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(a.C.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function zi(e,s,l,c,u){const p=u.padding,f=bt(u.worldSize,l.getNorthWest()),_=bt(u.worldSize,l.getNorthEast()),g=bt(u.worldSize,l.getSouthEast()),y=bt(u.worldSize,l.getSouthWest()),x=a.ae(-c),v=f.rotate(x),w=_.rotate(x),C=g.rotate(x),A=y.rotate(x),k=new a.P(Math.max(v.x,w.x,A.x,C.x),Math.max(v.y,w.y,A.y,C.y)),D=new a.P(Math.min(v.x,w.x,A.x,C.x),Math.min(v.y,w.y,A.y,C.y)),R=k.sub(D),L=(u.width-(p.left+p.right+s.left+s.right))/R.x,B=(u.height-(p.top+p.bottom+s.top+s.bottom))/R.y;if(B<0||L<0)return void Ei();const O=Math.min(a.ak(u.scale*Math.min(L,B)),e.maxZoom),j=a.P.convert(e.offset),U=new a.P((s.left-s.right)/2,(s.top-s.bottom)/2).rotate(a.ae(c)),N=j.add(U).mult(u.scale/a.af(O));return{center:Tt(u.worldSize,f.add(g).div(2).sub(N)),zoom:O,bearing:c}}class Ot{get useGlobeControls(){return!1}handlePanInertia(e,s){return{easingOffset:e,easingCenter:s.center}}handleMapControlsRollPitchBearingZoom(e,s){e.bearingDelta&&s.setBearing(s.bearing+e.bearingDelta),e.pitchDelta&&s.setPitch(s.pitch+e.pitchDelta),e.rollDelta&&s.setRoll(s.roll+e.rollDelta),e.zoomDelta&&s.setZoom(s.zoom+e.zoomDelta)}handleMapControlsPan(e,s,a){e.around.distSqr(s.centerPoint)<.01||s.setLocationAtPoint(a,e.around)}cameraForBoxAndBearing(e,s,a,l,c){return zi(e,s,a,l,c)}handleJumpToCenterZoom(e,s){e.zoom!==(void 0!==s.zoom?+s.zoom:e.zoom)&&e.setZoom(+s.zoom),void 0!==s.center&&e.setCenter(a.S.convert(s.center))}handleEaseTo(e,s){const l=e.zoom,c=e.padding,u={roll:e.roll,pitch:e.pitch,bearing:e.bearing},p={roll:void 0===s.roll?e.roll:s.roll,pitch:void 0===s.pitch?e.pitch:s.pitch,bearing:void 0===s.bearing?e.bearing:s.bearing},f=void 0!==s.zoom,_=!e.isPaddingEqual(s.padding);let g=!1;const y=f?+s.zoom:e.zoom;let x=e.centerPoint.add(s.offsetAsPoint);const v=e.screenPointToLocation(x),{center:w,zoom:C}=e.getConstrained(a.S.convert(s.center||v),null!=y?y:l);Ci(e,w);const A=bt(e.worldSize,v),k=bt(e.worldSize,w).sub(A),D=a.af(C-l);return g=C!==l,{easeFunc:f=>{if(g&&e.setZoom(a.C.number(l,C,f)),a.be(u,p)||Ai({startEulerAngles:u,endEulerAngles:p,tr:e,k:f,useSlerp:u.roll!=p.roll}),_&&(e.interpolatePadding(c,s.padding,f),x=e.centerPoint.add(s.offsetAsPoint)),s.around)e.setLocationAtPoint(s.around,s.aroundPoint);else{const s=a.af(e.zoom-l),c=C>l?Math.min(2,D):Math.max(.5,D),u=Math.pow(c,1-f),p=Tt(e.worldSize,A.add(k.mult(f*u)).mult(s));e.setLocationAtPoint(e.renderWorldCopies?p.wrap():p,x)}},isZooming:g,elevationCenter:w}}handleFlyTo(e,s){const l=void 0!==s.zoom,c=e.zoom,u=e.getConstrained(a.S.convert(s.center||s.locationAtOffset),l?+s.zoom:c),p=u.center,f=u.zoom;Ci(e,p);const _=bt(e.worldSize,s.locationAtOffset),g=bt(e.worldSize,p).sub(_),y=g.mag(),x=a.af(f-c);let v;if(void 0!==s.minZoom){const l=Math.min(+s.minZoom,c,f),u=e.getConstrained(p,l).zoom;v=a.af(u-c)}return{easeFunc:(s,l,u,y)=>{e.setZoom(1===s?f:c+a.ak(l));const x=1===s?p:Tt(e.worldSize,_.add(g.mult(u)).mult(l));e.setLocationAtPoint(e.renderWorldCopies?x.wrap():x,y)},scaleOfZoom:x,targetCenter:p,scaleOfMinZoom:v,pixelPathLength:y}}}class jt{constructor(e,s,a){this.blendFunction=e,this.blendColor=s,this.mask=a}}jt.Replace=[1,0],jt.disabled=new jt(jt.Replace,a.bf.transparent,[!1,!1,!1,!1]),jt.unblended=new jt(jt.Replace,a.bf.transparent,[!0,!0,!0,!0]),jt.alphaBlended=new jt([1,771],a.bf.transparent,[!0,!0,!0,!0]);const ki=2305;class Ut{constructor(e,s,a){this.enable=e,this.mode=s,this.frontFace=a}}Ut.disabled=new Ut(!1,1029,ki),Ut.backCCW=new Ut(!0,1029,ki),Ut.frontCCW=new Ut(!0,1028,ki);class Zt{constructor(e,s,a){this.func=e,this.mask=s,this.range=a}}Zt.ReadOnly=!1,Zt.ReadWrite=!0,Zt.disabled=new Zt(519,Zt.ReadOnly,[0,1]);const Di=7680;class Vt{constructor(e,s,a,l,c,u){this.test=e,this.ref=s,this.mask=a,this.fail=l,this.depthFail=c,this.pass=u}}Vt.disabled=new Vt({func:519,mask:0},0,0,Di,Di,Di);const Ri=new WeakMap;function Li(e){var s;if(Ri.has(e))return Ri.get(e);{const a=null===(s=e.getParameter(e.VERSION))||void 0===s?void 0:s.startsWith("WebGL 2.0");return Ri.set(e,a),a}}class Wt{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const s=e.context,l=s.gl;this._texFormat=l.RGBA,this._texType=l.UNSIGNED_BYTE;const c=new a.aL;c.emplaceBack(-1,-1),c.emplaceBack(2,-1),c.emplaceBack(-1,2);const u=new a.aN;u.emplaceBack(0,1,2),this._fullscreenTriangle=new wt(s.createVertexBuffer(c,xi.members),s.createIndexBuffer(u),a.aM.simpleSegment(0,0,c.length,u.length)),this._resultBuffer=new Uint8Array(4),s.activeTexture.set(l.TEXTURE1);const p=l.createTexture();l.bindTexture(l.TEXTURE_2D,p),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=s.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(p),Li(l)&&(this._pbo=l.createBuffer(),l.bindBuffer(l.PIXEL_PACK_BUFFER,this._pbo),l.bufferData(l.PIXEL_PACK_BUFFER,4,l.STREAM_READ),l.bindBuffer(l.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,s){const a=this._updateCount;return this._readbackQueue?a>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():a>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,s),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,s=e.gl;e.activeTexture.set(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,s){const l=this._cachedRenderContext.context,c=l.gl;if(this._bindFramebuffer(),l.viewport.set([0,0,this._texWidth,this._texHeight]),l.clear({color:a.bf.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(l,c.TRIANGLES,Zt.disabled,Vt.disabled,jt.unblended,Ut.disabled,((e,s)=>({u_input:e,u_output_expected:s}))(e,s),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Li(c)){c.bindBuffer(c.PIXEL_PACK_BUFFER,this._pbo),c.readBuffer(c.COLOR_ATTACHMENT0),c.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null);const e=c.fenceSync(c.SYNC_GPU_COMMANDS_COMPLETE,0);c.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&&Li(e)){const s=e.clientWaitSync(this._readbackQueue.sync,0,0);if(s===e.WAIT_FAILED)return a.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(s===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Wt._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let s=0;return s+=e[0]/256,s+=e[1]/65536,s+=e[2]/16777216,e[3]<127&&(s=-s),s/128}}const Bi=a.$/128;function Fi(e,s){const l=void 0!==e.granularity?Math.max(e.granularity,1):1,c=l+(e.generateBorders?2:0),u=l+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),p=c+1,f=u+1,_=e.generateBorders?-1:0,g=e.generateBorders||e.extendToNorthPole?-1:0,y=l+(e.generateBorders?1:0),x=l+(e.generateBorders||e.extendToSouthPole?1:0),v=p*f,w=c*u*6,C=p*f>65536;if(C&&"16bit"===s)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const A=C||"32bit"===s,k=new Int16Array(2*v);let D=0;for(let s=g;s<=x;s++)for(let c=_;c<=y;c++){let u=c/l*a.$;-1===c&&(u=-Bi),c===l+1&&(u=a.$+Bi);let p=s/l*a.$;-1===s&&(p=e.extendToNorthPole?a.bh:-Bi),s===l+1&&(p=e.extendToSouthPole?a.bi:a.$+Bi),k[D++]=u,k[D++]=p}const R=A?new Uint32Array(w):new Uint16Array(w);let L=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,s,a,l,c){return this.currentProjection.getMeshFromTileID(e,s,a,l,c)}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 Vi(e){const s=$i(e.worldSize,e.center.lat);return 2*Math.PI*s}function Ui(e,s,l,c,u){const p=1/(1<1e-6){const c=e[0]/l,u=Math.acos(e[2]/l),p=(c>0?u:-u)/Math.PI*180;return new a.S(a.aO(p,-180,180),s)}return new a.S(0,s)}function Gi(e){return Math.cos(e*Math.PI/180)}function qi(e,s){const l=Gi(e),c=Gi(s);return a.ak(c/l)}function Wi(e,s){const l=e.rotate(s.bearingInRadians),c=s.zoom+qi(s.center.lat,0),u=a.bk(1/Gi(s.center.lat),1/Gi(Math.min(Math.abs(s.center.lat),60)),a.bn(c,7,3,0,1)),p=360/Vi({worldSize:s.worldSize,center:{lat:s.center.lat}});return new a.S(s.center.lng-l.x*p*u,a.ah(s.center.lat+l.y*p,-a.ai,a.ai))}function Xi(e){const s=.5*e,a=Math.sin(s),l=Math.cos(s);return Math.log(a+l)-Math.log(l-a)}function Hi(e,s,l,c){const u=e.lat+l*c;if(Math.abs(l)>1){const p=(Math.sign(e.lat+l)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,f=Math.abs(e.lat+l)*Math.PI/180,_=Xi(p+c*(f-p)),g=Xi(p),y=Xi(f);return new a.S(e.lng+s*((_-g)/(y-g)),u)}return new a.S(e.lng+s*c,u)}class hi{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,s,a,l){const c=`${e.z}_${e.x}_${e.y}_${(null==l?void 0:l.terrain)?"t":""}`,u=this._cache.get(c);if(u)return u;const p=this._cachePrevious.get(c);if(p)return this._cache.set(c,p),p;const f=this._boundingVolumeFactory(e,s,a,l);return this._cache.set(c,f),this._hadAnyChanges=!0,f}}class ui{constructor(e,s,a,l){this.min=a,this.max=l,this.points=e,this.planes=s}static fromAabb(e,s){const a=[];for(let l=0;l<8;l++)a.push([1&~l?e[0]:s[0],1==(l>>1&1)?s[1]:e[1],1==(l>>2&1)?s[2]:e[2]]);return new ui(a,[[-1,0,0,s[0]],[1,0,0,-e[0]],[0,-1,0,s[1]],[0,1,0,-e[1]],[0,0,-1,s[2]],[0,0,1,-e[2]]],e,s)}static fromCenterSizeAngles(e,s,l){const c=a.br([],l[0],l[1],l[2]),u=a.bs([],[s[0],0,0],c),p=a.bs([],[0,s[1],0],c),f=a.bs([],[0,0,s[2]],c),_=[...e],g=[...e];for(let s=0;s<8;s++)for(let a=0;a<3;a++){const l=e[a]+u[a]*(1&~s?-1:1)+p[a]*(1==(s>>1&1)?1:-1)+f[a]*(1==(s>>2&1)?1:-1);_[a]=Math.min(_[a],l),g[a]=Math.max(g[a],l)}const y=[];for(let s=0;s<8;s++){const l=[...e];a.aS(l,l,a.aR([],u,1&~s?-1:1)),a.aS(l,l,a.aR([],p,1==(s>>1&1)?1:-1)),a.aS(l,l,a.aR([],f,1==(s>>2&1)?1:-1)),y.push(l)}return new ui(y,[[...u,-a.aX(u,y[0])],[...p,-a.aX(p,y[0])],[...f,-a.aX(f,y[0])],[-u[0],-u[1],-u[2],-a.aX(u,y[7])],[-p[0],-p[1],-p[2],-a.aX(p,y[7])],[-f[0],-f[1],-f[2],-a.aX(f,y[7])]],_,g)}intersectsFrustum(e){let s=!0;const a=this.points.length,l=this.planes.length,c=e.planes.length,u=e.points.length;for(let l=0;l=0&&u++}if(0===u)return 0;u=0&&l++}if(0===l)return 0}return 1}intersectsPlane(e){const s=this.points.length;let a=0;for(let l=0;l=0&&a++}return a===s?2:0===a?0:1}}function Yi(e,s,a){const l=e-s;return l<0?-l:Math.max(0,l-a)}function Ki(e,s,a,l,c){const u=e-a;let p;return p=u<0?Math.min(-u,1+u-c):u>1?Math.min(Math.max(u-c,0),1-u):0,Math.max(p,Yi(s,l,c))}class pi{constructor(){this._boundingVolumeCache=new hi(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,s,a,l){const c=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,s,a,l){return this._boundingVolumeCache.getTileBoundingVolume(e,s,a,l)}_computeTileBoundingVolume(e,s,l,c){var u,p;let f=0,_=0;if(null==c?void 0:c.terrain){const g=new a.Z(e.z,s,e.z,e.x,e.y),y=c.terrain.getMinMaxElevation(g);f=null!==(u=y.minElevation)&&void 0!==u?u:Math.min(0,l),_=null!==(p=y.maxElevation)&&void 0!==p?p:Math.max(0,l)}if(f/=a.bu,_/=a.bu,f+=1,_+=1,e.z<=0)return ui.fromAabb([-_,-_,-_],[_,_,_]);if(1===e.z)return ui.fromAabb([0===e.x?-_:0,0===e.y?0:-_,-_],[0===e.x?0:_,0===e.y?_:0,_]);{const s=[Ui(0,0,e.x,e.y,e.z),Ui(a.$,0,e.x,e.y,e.z),Ui(a.$,a.$,e.x,e.y,e.z),Ui(0,a.$,e.x,e.y,e.z)],l=[];for(const e of s)l.push(a.aR([],e,_));if(_!==f)for(const e of s)l.push(a.aR([],e,f));0===e.y&&l.push([0,1,0]),e.y===(1<=(1<{this._calcMatrices()},getConstrained:(e,s)=>this.getConstrained(e,s)}),this._coveringTilesDetailsProvider=new pi}clone(){const e=new fi;return e.apply(this),e}apply(e,s){this._globeLatitudeErrorCorrectionRadians=s||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=a.bp();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:s,applyGlobeMatrix:a}=e,l=this._helper.getMercatorTileCoordinates(s);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:l,clippingPlane:this._cachedClippingPlane,projectionTransition:a?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const s=this.pitchInRadians,l=this.cameraToCenterDistance/e,c=Math.sin(s)*l,u=Math.cos(s)*l+1,p=1/Math.sqrt(c*c+u*u)*1;let f=-c,_=u;const g=Math.sqrt(f*f+_*_);f/=g,_/=g;const y=[0,f,_];a.bw(y,y,[0,0,0],-this.bearingInRadians),a.bx(y,y,[0,0,0],-1*this.center.lat*Math.PI/180),a.by(y,y,[0,0,0],this.center.lng*Math.PI/180);const x=1/a.aZ(y);return a.aR(y,y,x),[...y,-p*x]}isLocationOccluded(e){return!this.isSurfacePointVisible(Ni(e))}transformLightDirection(e){const s=this._helper._center.lng*Math.PI/180,l=this._helper._center.lat*Math.PI/180,c=Math.cos(l),u=[Math.sin(s)*c,Math.sin(l),Math.cos(s)*c],p=[u[2],0,-u[0]],f=[0,0,0];a.aW(f,p,u),a.aV(p,p),a.aV(f,f);const _=[0,0,0];return a.aV(_,[p[0]*e[0]+f[0]*e[1]+u[0]*e[2],p[1]*e[0]+f[1]*e[1]+u[1]*e[2],p[2]*e[0]+f[2]*e[1]+u[2]*e[2]]),_}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,s,l){const c=function(e,s,l){const c=1/(1<u&&(u=s),l<_&&(_=l),l>f&&(f=l)}const y=[g.lng+p,g.lat+_,g.lng+u,g.lat+f];return this.isSurfacePointOnScreen([0,1,0])&&(y[3]=90,y[0]=-180,y[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(y[1]=-90,y[0]=-180,y[2]=180),new G(y)}getConstrained(e,s){const l=a.ah(e.lat,-a.ai,a.ai),c=a.ah(+s,this.minZoom+qi(0,l),this.maxZoom);return{center:new a.S(e.lng,l),zoom:c}}calculateCenterFromCameraLngLatAlt(e,s,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,a,l)}setLocationAtPoint(e,s){const l=Ni(this.unprojectScreenPoint(s)),c=Ni(e),u=a.bp();a.bB(u);const p=a.bp();a.by(p,l,u,-this.center.lng*Math.PI/180),a.bx(p,p,u,this.center.lat*Math.PI/180);const f=c[0]*c[0]+c[2]*c[2],_=p[0]*p[0];if(f<_)return;const g=Math.sqrt(f-_),y=-g,x=a.bC(c[0],c[2],p[0],g),v=a.bC(c[0],c[2],p[0],y),w=a.bp();a.by(w,c,u,-x);const C=a.bC(w[1],w[2],p[1],p[2]),A=a.bp();a.by(A,c,u,-v);const k=a.bC(A[1],A[2],p[1],p[2]),D=.5*Math.PI,R=C>=-D&&C<=D,L=k>=-D&&k<=D;let B,O;if(R&&L){const e=this.center.lng*Math.PI/180,s=this.center.lat*Math.PI/180;a.bD(x,e)+a.bD(C,s)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const s=a.bv();return a.aw(s,[...e,1],this._globeViewProjMatrixNoCorrection),s[0]/=s[3],s[1]/=s[3],s[2]/=s[3],s[0]>-1&&s[0]<1&&s[1]>-1&&s[1]<1&&s[2]>-1&&s[2]<1}rayPlanetIntersection(e,s){const l=a.aX(e,s),c=a.bp(),u=a.bp();a.aR(u,s,l),a.aU(c,e,u);const p=1-a.aX(c,c);if(p<0)return null;const f=a.aX(e,e)-1,_=-l+(l<0?1:-1)*Math.sqrt(p),g=f/_,y=_;return{tMin:Math.min(g,y),tMax:Math.max(g,y)}}unprojectScreenPoint(e){const s=this._cameraPosition,l=this.getRayDirectionFromPixel(e),c=this.rayPlanetIntersection(s,l);if(c){const e=a.bp();a.aS(e,s,[l[0]*c.tMin,l[1]*c.tMin,l[2]*c.tMin]);const u=a.bp();return a.aV(u,e),Zi(u)}const u=this._cachedClippingPlane,p=u[0]*l[0]+u[1]*l[1]+u[2]*l[2],f=-a.b1(u,s)/p,_=a.bp();if(f>0)a.aS(_,s,[l[0]*f,l[1]*f,l[2]*f]);else{const e=a.bp();a.aS(e,s,[2*l[0],2*l[1],2*l[2]]);const c=a.b1(this._cachedClippingPlane,e);a.aU(_,e,[this._cachedClippingPlane[0]*c,this._cachedClippingPlane[1]*c,this._cachedClippingPlane[2]*c])}const g=function(e){const s=a.bp();return s[0]=e[0]*-e[3],s[1]=e[1]*-e[3],s[2]=e[2]*-e[3],{center:s,radius:Math.sqrt(1-e[3]*e[3])}}(u);return Zi(function(e,s,l){const c=a.bp();a.aU(c,l,e);const u=a.bp();return a.bq(u,e,c,s/a.a$(c)),u}(g.center,g.radius,_))}getMatrixForModel(e,s){const l=a.S.convert(e),c=1/a.bu,u=a.b9();return a.bz(u,u,l.lng/180*Math.PI),a.b7(u,u,-l.lat/180*Math.PI),a.M(u,u,[0,0,1+s/a.bu]),a.b7(u,u,.5*Math.PI),a.N(u,u,[c,c,c]),u}getProjectionDataForCustomLayer(e=!0){const s=this.getProjectionData({overscaledTileID:new a.Z(0,0,0,0,0),applyGlobeMatrix:e});return s.tileMercatorCoords=[0,0,1,1],s}getFastPathSimpleProjectionMatrix(e){}}class gi{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,s,a){return this._helper.interpolatePadding(e,s,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,s,a=!0){this._helper.resize(e,s,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,s){this._helper.overrideNearFarZ(e,s)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,s){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=s,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Rt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,s)=>this.getConstrained(e,s)}),this._globeness=1,this._mercatorTransform=new Lt,this._verticalPerspectiveTransform=new fi}clone(){const e=new gi;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const s=this._mercatorTransform.getProjectionData(e),a=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?a.mainMatrix:s.mainMatrix,clippingPlane:a.clippingPlane,tileMercatorCoords:a.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:s.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return a.bk(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return a.bk(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,s,l){const c=this._mercatorTransform.getPitchedTextCorrection(e,s,l),u=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,s,l);return a.bk(c,u,this._globeness)}projectTileCoordinates(e,s,a,l){return this.currentTransform.projectTileCoordinates(e,s,a,l)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,s){return this.currentTransform.lngLatToCameraDepth(e,s)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,s){return this.currentTransform.getConstrained(e,s)}calculateCenterFromCameraLngLatAlt(e,s,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,a,l)}setLocationAtPoint(e,s){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,s),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,s),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,s){return this.currentTransform.locationToScreenPoint(e,s)}screenPointToMercatorCoordinate(e,s){return this.currentTransform.screenPointToMercatorCoordinate(e,s)}screenPointToLocation(e,s){return this.currentTransform.screenPointToLocation(e,s)}isPointOnMapSurface(e,s){return this.currentTransform.isPointOnMapSurface(e,s)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,s){return this.currentTransform.getMatrixForModel(e,s)}getProjectionDataForCustomLayer(e=!0){const s=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return s;const a=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return a.fallbackMatrix=s.mainMatrix,a}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class vi{get useGlobeControls(){return!0}handlePanInertia(e,s){const l=Wi(e,s);return Math.abs(l.lng-s.center.lng)>180&&(l.lng=s.center.lng+179.5*Math.sign(l.lng-s.center.lng)),{easingCenter:l,easingOffset:new a.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,s){const l=e.around,c=s.screenPointToLocation(l);e.bearingDelta&&s.setBearing(s.bearing+e.bearingDelta),e.pitchDelta&&s.setPitch(s.pitch+e.pitchDelta),e.rollDelta&&s.setRoll(s.roll+e.rollDelta);const u=s.zoom;e.zoomDelta&&s.setZoom(s.zoom+e.zoomDelta);const p=s.zoom-u;if(0===p)return;const f=a.bA(s.center.lng,c.lng),_=f/(Math.abs(f/180)+1),g=a.bA(s.center.lat,c.lat),y=s.getRayDirectionFromPixel(l),x=s.cameraPosition,v=-1*a.aX(x,y),w=a.bp();a.aS(w,x,[y[0]*v,y[1]*v,y[2]*v]);const C=a.aZ(w)-1,A=Math.exp(.5*-Math.max(C-.3,0)),k=$i(s.worldSize,s.center.lat)/Math.min(s.width,s.height),D=a.bn(k,.9,.5,1,.25),R=(1-a.af(-p))*Math.min(A,D),L=s.center.lat,B=s.zoom,O=new a.S(s.center.lng+_*R,a.ah(s.center.lat+g*R,-a.ai,a.ai));s.setLocationAtPoint(c,l);const j=s.center,U=a.bn(Math.abs(f),45,85,0,1),N=a.bn(k,.75,.35,0,1),Z=Math.pow(Math.max(U,N),.25),J=a.bA(j.lng,O.lng),Q=a.bA(j.lat,O.lat);s.setCenter(new a.S(j.lng+J*Z,j.lat+Q*Z).wrap()),s.setZoom(B+qi(L,s.center.lat))}handleMapControlsPan(e,s,a){if(!e.panDelta)return;const l=s.center.lat,c=s.zoom;s.setCenter(Wi(e.panDelta,s).wrap()),s.setZoom(c+qi(l,s.center.lat))}cameraForBoxAndBearing(e,s,l,c,u){const p=zi(e,s,l,c,u),f=s.left/u.width*2-1,_=(u.width-s.right)/u.width*2-1,g=s.top/u.height*-2+1,y=(u.height-s.bottom)/u.height*-2+1,x=a.bA(l.getWest(),l.getEast())<0,v=x?l.getEast():l.getWest(),w=x?l.getWest():l.getEast(),C=Math.max(l.getNorth(),l.getSouth()),A=Math.min(l.getNorth(),l.getSouth()),k=v+.5*a.bA(v,w),D=C+.5*a.bA(C,A),R=u.clone();R.setCenter(p.center),R.setBearing(p.bearing),R.setPitch(0),R.setRoll(0),R.setZoom(p.zoom);const L=R.modelViewProjectionMatrix,B=[Ni(l.getNorthWest()),Ni(l.getNorthEast()),Ni(l.getSouthWest()),Ni(l.getSouthEast()),Ni(new a.S(w,D)),Ni(new a.S(v,D)),Ni(new a.S(k,C)),Ni(new a.S(k,A))],O=Ni(p.center);let j=Number.POSITIVE_INFINITY;for(const e of B)f<0&&(j=vi.getLesserNonNegativeNonNull(j,vi.solveVectorScale(e,O,L,"x",f))),_>0&&(j=vi.getLesserNonNegativeNonNull(j,vi.solveVectorScale(e,O,L,"x",_))),g>0&&(j=vi.getLesserNonNegativeNonNull(j,vi.solveVectorScale(e,O,L,"y",g))),y<0&&(j=vi.getLesserNonNegativeNonNull(j,vi.solveVectorScale(e,O,L,"y",y)));if(Number.isFinite(j)&&0!==j)return p.zoom=R.zoom+a.ak(j),p;Ei()}handleJumpToCenterZoom(e,s){const l=e.center.lat,c=e.getConstrained(s.center?a.S.convert(s.center):e.center,e.zoom).center;e.setCenter(c.wrap());const u=void 0!==s.zoom?+s.zoom:e.zoom+qi(l,c.lat);e.zoom!==u&&e.setZoom(u)}handleEaseTo(e,s){const l=e.zoom,c=e.center,u=e.padding,p={roll:e.roll,pitch:e.pitch,bearing:e.bearing},f={roll:void 0===s.roll?e.roll:s.roll,pitch:void 0===s.pitch?e.pitch:s.pitch,bearing:void 0===s.bearing?e.bearing:s.bearing},_=void 0!==s.zoom,g=!e.isPaddingEqual(s.padding);let y=!1;const x=s.center?a.S.convert(s.center):c,v=e.getConstrained(x,l).center;Ci(e,v);const w=e.clone();w.setCenter(v),w.setZoom(_?+s.zoom:l+qi(c.lat,x.lat)),w.setBearing(s.bearing);const C=new a.P(a.ah(e.centerPoint.x+s.offsetAsPoint.x,0,e.width),a.ah(e.centerPoint.y+s.offsetAsPoint.y,0,e.height));w.setLocationAtPoint(v,C);const A=(s.offset&&s.offsetAsPoint.mag())>0?w.center:v,k=_?+s.zoom:l+qi(c.lat,A.lat),D=l+qi(c.lat,0),R=k+qi(A.lat,0),L=a.bA(c.lng,A.lng),B=a.bA(c.lat,A.lat),O=a.af(R-D);return y=k!==l,{easeFunc:l=>{if(a.be(p,f)||Ai({startEulerAngles:p,endEulerAngles:f,tr:e,k:l,useSlerp:p.roll!=f.roll}),g&&e.interpolatePadding(u,s.padding,l),s.around)a.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(s.around,s.aroundPoint);else{const s=R>D?Math.min(2,O):Math.max(.5,O),a=Math.pow(s,1-l),u=Hi(c,L,B,l*a);e.setCenter(u.wrap())}if(y){const s=a.C.number(D,R,l)+qi(0,e.center.lat);e.setZoom(s)}},isZooming:y,elevationCenter:A}}handleFlyTo(e,s){const l=void 0!==s.zoom,c=e.center,u=e.zoom,p=e.padding,f=!e.isPaddingEqual(s.padding),_=e.getConstrained(a.S.convert(s.center||s.locationAtOffset),u).center,g=l?+s.zoom:e.zoom+qi(e.center.lat,_.lat),y=e.clone();y.setCenter(_),y.setZoom(g),y.setBearing(s.bearing);const x=new a.P(a.ah(e.centerPoint.x+s.offsetAsPoint.x,0,e.width),a.ah(e.centerPoint.y+s.offsetAsPoint.y,0,e.height));y.setLocationAtPoint(_,x);const v=y.center;Ci(e,v);const w=function(e,s,l){const c=Ni(s),u=Ni(l),p=a.aX(c,u),f=Math.acos(p),_=Vi(e);return f/(2*Math.PI)*_}(e,c,v),C=u+qi(c.lat,0),A=g+qi(v.lat,0),k=a.af(A-C);let D;if("number"==typeof s.minZoom){const l=+s.minZoom+qi(v.lat,0),c=Math.min(l,C,A)+qi(0,v.lat),u=e.getConstrained(v,c).zoom+qi(v.lat,0);D=a.af(u-C)}const R=a.bA(c.lng,v.lng),L=a.bA(c.lat,v.lat);return{easeFunc:(l,u,_,y)=>{const x=Hi(c,R,L,_);f&&e.interpolatePadding(p,s.padding,l);const w=1===l?v:x;e.setCenter(w.wrap());const A=C+a.ak(u);e.setZoom(1===l?g:A+qi(0,w.lat))},scaleOfZoom:k,targetCenter:v,scaleOfMinZoom:D,pixelPathLength:w}}static solveVectorScale(e,s,a,l,c){const u="x"===l?[a[0],a[4],a[8],a[12]]:[a[1],a[5],a[9],a[13]],p=[a[3],a[7],a[11],a[15]],f=e[0]*u[0]+e[1]*u[1]+e[2]*u[2],_=e[0]*p[0]+e[1]*p[1]+e[2]*p[2],g=s[0]*u[0]+s[1]*u[1]+s[2]*u[2],y=s[0]*p[0]+s[1]*p[1]+s[2]*p[2];return g+c*_===f+c*y||p[3]*(f-g)+u[3]*(y-_)+f*y==g*_?null:(g+u[3]-c*y-c*p[3])/(g-f-c*y+c*_)}static getLesserNonNegativeNonNull(e,s){return null!==s&&s>=0&&sa.y(e,s&&s.filter((e=>"source.canvas"!==e.identifier))),sr=a.bE();class wi extends a.E{constructor(e,s={}){super(),this._rtlPluginLoaded=()=>{for(const e in this.sourceCaches){const s=this.sourceCaches[e].getSource().type;"vector"!==s&&"geojson"!==s||this.sourceCaches[e].reload()}},this.map=e,this.dispatcher=new F(Q(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,s)=>this.getGlyphs(e,s))),this.dispatcher.registerMessageHandler("GI",((e,s)=>this.getImages(e,s))),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new T(e._requestManager,s.localIdeographFontFamily),this.lineAtlas=new E(256,512),this.crossTileSymbolIndex=new vt,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new a.bF,this._loaded=!1,this._availableImages=[],this._globalState={},this._resetUpdates(),this.dispatcher.broadcast("SR",a.bG()),pt().on(ct,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const s=this.sourceCaches[e.sourceId];if(!s)return;const a=s.getSource();if(a&&a.vectorLayerIds)for(const e in this._layers){const s=this._layers[e];s.source===a.id&&this._validateLayer(s)}}))}setGlobalStateProperty(e,s){var l,c,u;this._checkLoaded();const p=null===s?null!==(u=null===(c=null===(l=this.stylesheet.state)||void 0===l?void 0:l[e])||void 0===c?void 0:c.default)&&void 0!==u?u:null:s;if(a.bH(p,this._globalState[e]))return this;this._globalState[e]=p;const f=this._findGlobalStateAffectedSources([e]);for(const e in this.sourceCaches)f.has(e)&&(this._reloadSource(e),this._changed=!0)}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const s=[];for(const l in e)!a.bH(this._globalState[l],e[l].default)&&(s.push(l),this._globalState[l]=e[l].default);const l=this._findGlobalStateAffectedSources(s);for(const e in this.sourceCaches)l.has(e)&&(this._reloadSource(e),this._changed=!0)}_findGlobalStateAffectedSources(e){if(0===e.length)return new Set;const s=new Set;for(const a in this._layers){const l=this._layers[a],c=l.getLayoutAffectingGlobalStateRefs();for(const a of e)c.has(a)&&s.add(l.source)}return s}loadURL(e,s={},l){this.fire(new a.l("dataloading",{dataType:"style"})),s.validate="boolean"!=typeof s.validate||s.validate;const c=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const u=this._loadStyleRequest;a.j(c,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,s,l)})).catch((e=>{this._loadStyleRequest=null,e&&!u.signal.aborted&&this.fire(new a.k(e))}))}loadJSON(e,s={},l){this.fire(new a.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,f.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,s.validate=!1!==s.validate,this._load(e,s,l)})).catch((()=>{}))}loadEmpty(){this.fire(new a.l("dataloading",{dataType:"style"})),this._load(sr,{validate:!1})}_load(e,s,l){var c,u,p;const f=s.transformStyle?s.transformStyle(l,e):e;if(!s.validate||!Qi(this,a.z(f))){this._loaded=!0,this.stylesheet=f;for(const e in f.sources)this.addSource(e,f.sources[e],{validate:!1});f.sprite?this._loadSprite(f.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(f.glyphs),this._createLayers(),this.light=new I(this.stylesheet.light),this._setProjectionInternal((null===(c=this.stylesheet.projection)||void 0===c?void 0:c.type)||"mercator"),this.sky=new S(this.stylesheet.sky),this.map.setTerrain(null!==(u=this.stylesheet.terrain)&&void 0!==u?u:null),this.setGlobalState(null!==(p=this.stylesheet.state)&&void 0!==p?p:null),this.fire(new a.l("data",{dataType:"style"})),this.fire(new a.l("style.load"))}}_createLayers(){const e=a.bI(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const s of e){const e=a.bJ(s);e.setEventedParent(this,{layer:{id:s.id}}),this._layers[s.id]=e}}_loadSprite(e,s=!1,l=void 0){let c;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,s,l,c){return a._(this,void 0,void 0,(function*(){const u=A(e),p=l>1?"@2x":"",_={},g={};for(const{id:e,url:l}of u){const u=s.transformRequest(k(l,p,".json"),"SpriteJSON");_[e]=a.j(u,c);const f=s.transformRequest(k(l,p,".png"),"SpriteImage");g[e]=C.getImage(f,c)}return yield Promise.all([...Object.values(_),...Object.values(g)]),function(e,s){return a._(this,void 0,void 0,(function*(){const a={};for(const l in e){a[l]={};const c=f.getImageCanvasContext((yield s[l]).data),u=(yield e[l]).data;for(const e in u){const{width:s,height:p,x:f,y:_,sdf:g,pixelRatio:y,stretchX:x,stretchY:v,content:w,textFitWidth:C,textFitHeight:A}=u[e];a[l][e]={data:null,pixelRatio:y,sdf:g,stretchX:x,stretchY:v,content:w,textFitWidth:C,textFitHeight:A,spriteData:{width:s,height:p,x:f,y:_,context:c}}}}return a}))}(_,g)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const a in e){this._spritesImagesIds[a]=[];const l=this._spritesImagesIds[a]?this._spritesImagesIds[a].filter((s=>!(s in e))):[];for(const e of l)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const l in e[a]){const c="default"===a?l:`${a}:${l}`;this._spritesImagesIds[a].push(c),c in this.imageManager.images?this.imageManager.updateImage(c,e[a][l],!1):this.imageManager.addImage(c,e[a][l]),s&&(this._changedImages[c]=!0)}}})).catch((e=>{this._spriteRequest=null,c=e,this.fire(new a.k(c))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),s&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"})),l&&l(c)}))}_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 a.l("data",{dataType:"style"}))}_validateLayer(e){const s=this.sourceCaches[e.source];if(!s)return;const l=e.sourceLayer;if(!l)return;const c=s.getSource();("geojson"===c.type||c.vectorLayerIds&&-1===c.vectorLayerIds.indexOf(l))&&this.fire(new a.k(new Error(`Source layer "${l}" does not exist on source "${c.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.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,s=!1){const l=this._serializedAllLayers();if(!e||0===e.length)return Object.values(s?a.bK(l):l);const c=[];for(const u of e)if(l[u]){const e=s?a.bK(l[u]):l[u];c.push(e)}return c}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const s=Object.keys(this._layers);for(const a of s){const s=this._layers[a];"custom"!==s.type&&(e[a]=s.serialize())}return e}hasTransitions(){var e,s,a;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(s=this.sky)||void 0===s?void 0:s.hasTransition())return!0;if(null===(a=this.projection)||void 0===a?void 0:a.hasTransition())return!0;for(const e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const s=this._changed;if(s){const s=Object.keys(this._updatedLayers),a=Object.keys(this._removedLayers);(s.length||a.length)&&this._updateWorkerLayers(s,a);for(const e in this._updatedSources){const s=this._updatedSources[e];if("reload"===s)this._reloadSource(e);else{if("clear"!==s)throw new Error(`Invalid action ${s}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const s in this._updatedPaintProps)this._layers[s].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const l={};for(const e in this.sourceCaches){const s=this.sourceCaches[e];l[e]=s.used,s.used=!1}for(const s of this._order){const a=this._layers[s];a.recalculate(e,this._availableImages),!a.isHidden(e.zoom)&&a.source&&(this.sourceCaches[a.source].used=!0)}for(const e in l){const s=this.sourceCaches[e];!!l[e]!=!!s.used&&s.fire(new a.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,s&&this.fire(new a.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const s in this.sourceCaches)this.sourceCaches[s].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,s){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:s})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,s={}){var l;this._checkLoaded();const c=this.serialize();if(e=s.transformStyle?s.transformStyle(c,e):e,(null===(l=s.validate)||void 0===l||l)&&Qi(this,a.z(e)))return!1;(e=a.bK(e)).layers=a.bI(e.layers);const u=a.bL(c,e),p=this._getOperationsToPerform(u);if(p.unimplemented.length>0)throw new Error(`Unimplemented: ${p.unimplemented.join(", ")}.`);if(0===p.operations.length)return!1;for(const e of p.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const s=[],a=[];for(const l of e)switch(l.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":s.push((()=>this.addLayer.apply(this,l.args)));break;case"removeLayer":s.push((()=>this.removeLayer.apply(this,l.args)));break;case"setPaintProperty":s.push((()=>this.setPaintProperty.apply(this,l.args)));break;case"setLayoutProperty":s.push((()=>this.setLayoutProperty.apply(this,l.args)));break;case"setFilter":s.push((()=>this.setFilter.apply(this,l.args)));break;case"addSource":s.push((()=>this.addSource.apply(this,l.args)));break;case"removeSource":s.push((()=>this.removeSource.apply(this,l.args)));break;case"setLayerZoomRange":s.push((()=>this.setLayerZoomRange.apply(this,l.args)));break;case"setLight":s.push((()=>this.setLight.apply(this,l.args)));break;case"setGeoJSONSourceData":s.push((()=>this.setGeoJSONSourceData.apply(this,l.args)));break;case"setGlyphs":s.push((()=>this.setGlyphs.apply(this,l.args)));break;case"setSprite":s.push((()=>this.setSprite.apply(this,l.args)));break;case"setTerrain":s.push((()=>this.map.setTerrain.apply(this,l.args)));break;case"setSky":s.push((()=>this.setSky.apply(this,l.args)));break;case"setProjection":this.setProjection.apply(this,l.args);break;case"setGlobalState":s.push((()=>this.setGlobalState.apply(this,l.args)));break;case"setTransition":s.push((()=>{}));break;default:a.push(l.command)}return{operations:s,unimplemented:a}}addImage(e,s){if(this.getImage(e))return this.fire(new a.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,s),this._afterImageUpdated(e)}updateImage(e,s){this.imageManager.updateImage(e,s)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new a.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 a.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,s,l={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!s.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(s).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(s.type)>=0&&this._validate(a.z.source,`sources.${e}`,s,null,l))return;this.map&&this.map._collectResourceTiming&&(s.collectResourceTiming=!0);const c=this.sourceCaches[e]=new xe(e,s,this.dispatcher);c.style=this,c.setEventedParent(this,(()=>({isSourceLoaded:c.loaded(),source:c.serialize(),sourceId:e}))),c.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const s in this._layers)if(this._layers[s].source===e)return this.fire(new a.k(new Error(`Source "${e}" cannot be removed while layer "${s}" is using it.`)));const s=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],s.fire(new a.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),s.setEventedParent(null),s.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,s){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error(`There is no source with this ID=${e}`);const a=this.sourceCaches[e].getSource();if("geojson"!==a.type)throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(s),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,s,l={}){this._checkLoaded();const c=e.id;if(this.getLayer(c))return void this.fire(new a.k(new Error(`Layer "${c}" already exists on this map.`)));let u;if("custom"===e.type){if(Qi(this,a.bM(e)))return;u=a.bJ(e)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(c,e.source),e=a.bK(e),e=a.e(e,{source:c})),this._validate(a.z.layer,`layers.${c}`,e,{arrayIndex:-1},l))return;u=a.bJ(e),this._validateLayer(u),u.setEventedParent(this,{layer:{id:c}})}const p=s?this._order.indexOf(s):this._order.length;if(s&&-1===p)this.fire(new a.k(new Error(`Cannot add layer "${c}" before non-existing layer "${s}".`)));else{if(this._order.splice(p,0,c),this._layerOrderChanged=!0,this._layers[c]=u,this._removedLayers[c]&&u.source&&"custom"!==u.type){const e=this._removedLayers[c];delete this._removedLayers[c],e.type!==u.type?this._updatedSources[u.source]="clear":(this._updatedSources[u.source]="reload",this.sourceCaches[u.source].pause())}this._updateLayer(u),u.onAdd&&u.onAdd(this.map)}}moveLayer(e,s){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new a.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===s)return;const l=this._order.indexOf(e);this._order.splice(l,1);const c=s?this._order.indexOf(s):this._order.length;s&&-1===c?this.fire(new a.k(new Error(`Cannot move layer "${e}" before non-existing layer "${s}".`))):(this._order.splice(c,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const s=this._layers[e];if(!s)return void this.fire(new a.k(new Error(`Cannot remove non-existing layer "${e}".`)));s.setEventedParent(null);const l=this._order.indexOf(e);this._order.splice(l,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=s,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],s.onRemove&&s.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,s,l){this._checkLoaded();const c=this.getLayer(e);c?c.minzoom===s&&c.maxzoom===l||(null!=s&&(c.minzoom=s),null!=l&&(c.maxzoom=l),this._updateLayer(c)):this.fire(new a.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,s,l={}){this._checkLoaded();const c=this.getLayer(e);if(c){if(!a.bH(c.filter,s))return null==s?(c.setFilter(void 0),void this._updateLayer(c)):void(this._validate(a.z.filter,`layers.${c.id}.filter`,s,null,l)||(c.setFilter(a.bK(s)),this._updateLayer(c)))}else this.fire(new a.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return a.bK(this.getLayer(e).filter)}setLayoutProperty(e,s,l,c={}){this._checkLoaded();const u=this.getLayer(e);u?a.bH(u.getLayoutProperty(s),l)||(u.setLayoutProperty(s,l,c),this._updateLayer(u)):this.fire(new a.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,s){const l=this.getLayer(e);if(l)return l.getLayoutProperty(s);this.fire(new a.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,s,l,c={}){this._checkLoaded();const u=this.getLayer(e);u?a.bH(u.getPaintProperty(s),l)||(u.setPaintProperty(s,l,c)&&this._updateLayer(u),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new a.k(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(e,s){return this.getLayer(e).getPaintProperty(s)}setFeatureState(e,s){this._checkLoaded();const l=e.source,c=e.sourceLayer,u=this.sourceCaches[l];if(void 0===u)return void this.fire(new a.k(new Error(`The source '${l}' does not exist in the map's style.`)));const p=u.getSource().type;"geojson"===p&&c?this.fire(new a.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==p||c?(void 0===e.id&&this.fire(new a.k(new Error("The feature id parameter must be provided."))),u.setFeatureState(c,e.id,s)):this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,s){this._checkLoaded();const l=e.source,c=this.sourceCaches[l];if(void 0===c)return void this.fire(new a.k(new Error(`The source '${l}' does not exist in the map's style.`)));const u=c.getSource().type,p="vector"===u?e.sourceLayer:void 0;"vector"!==u||p?s&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new a.k(new Error("A feature id is required to remove its specific state property."))):c.removeFeatureState(p,e.id,s):this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const s=e.source,l=e.sourceLayer,c=this.sourceCaches[s];if(void 0!==c)return"vector"!==c.getSource().type||l?(void 0===e.id&&this.fire(new a.k(new Error("The feature id parameter must be provided."))),c.getFeatureState(l,e.id)):void this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new a.k(new Error(`The source '${s}' does not exist in the map's style.`)))}getTransition(){return a.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=a.bN(this.sourceCaches,(e=>e.serialize())),s=this._serializeByIds(this._order,!0),l=this.map.getTerrain()||void 0,c=this.stylesheet;return a.bO({version:c.version,name:c.name,metadata:c.metadata,light:c.light,sky:c.sky,center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,sprite:c.sprite,glyphs:c.glyphs,transition:c.transition,projection:c.projection,sources:e,layers:s,terrain:l},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.sourceCaches[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const s=e=>"fill-extrusion"===this._layers[e].type,a={},l=[];for(let c=this._order.length-1;c>=0;c--){const u=this._order[c];if(s(u)){a[u]=c;for(const s of e){const e=s[u];if(e)for(const s of e)l.push(s)}}}l.sort(((e,s)=>s.intersectionZ-e.intersectionZ));const c=[];for(let u=this._order.length-1;u>=0;u--){const p=this._order[u];if(s(p))for(let e=l.length-1;e>=0;e--){const s=l[e].feature;if(a[s.layer.id]this.map.terrain.getElevation(e,s,a):void 0));return this.placement&&u.push(function(e,s,a,l,c,u,p){const f={},_=u.queryRenderedSymbols(l),g=[];for(const e of Object.keys(_).map(Number))g.push(p[e]);g.sort(nt);for(const a of g){const l=a.featureIndex.lookupSymbolFeatures(_[a.bucketInstanceId],s,a.bucketIndex,a.sourceLayerIndex,c.filter,c.layers,c.availableImages,e);for(const e in l){const s=f[e]=f[e]||[],c=l[e];c.sort(((e,s)=>{const l=a.featureSortOrder;if(l){const a=l.indexOf(e.featureIndex);return l.indexOf(s.featureIndex)-a}return s.featureIndex-e.featureIndex}));for(const e of c)s.push(e)}}return function(e,s,a){for(const l in e)for(const c of e[l])st(c,a[s[l].source]);return e}(f,e,a)}(this._layers,p,this.sourceCaches,e,_,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(u)}querySourceFeatures(e,s){s&&s.filter&&this._validate(a.z.filter,"querySourceFeatures.filter",s.filter,null,s);const l=this.sourceCaches[e];return l?function(e,s){const a=e.getRenderableIds().map((s=>e.getTileByID(s))),l=[],c={};for(let e=0;ee.getTileByID(s))).sort(((e,s)=>s.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(s.tileID)?-1:1)))}const l=this.crossTileSymbolIndex.addLayer(a,_[a.source],e.center.lng);u=u||l}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((c=c||this._layerOrderChanged||0===a)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(f.now(),e.zoom))&&(this.pauseablePlacement=new _t(e,this.map.terrain,this._order,c,s,a,l,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(f.now()),p=!0),u&&this.pauseablePlacement.placement.setStale()),p||u)for(const e of this._order){const s=this._layers[e];"symbol"===s.type&&this.placement.updateLayerOpacities(s,_[s.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(f.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,s){return a._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(s.icons);this._updateTilesForChangedImages();const a=this.sourceCaches[s.source];return a&&a.setDependencies(s.tileID.key,s.type,s.icons),e}))}getGlyphs(e,s){return a._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(s.stacks),a=this.sourceCaches[s.source];return a&&a.setDependencies(s.tileID.key,s.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,s={}){this._checkLoaded(),e&&this._validate(a.z.glyphs,"glyphs",e,null,s)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,s,l={},c){this._checkLoaded();const u=[{id:e,url:s}],p=[...A(this.stylesheet.sprite),...u];this._validate(a.z.sprite,"sprite",p,null,l)||(this.stylesheet.sprite=p,this._loadSprite(u,!0,c))}removeSprite(e){this._checkLoaded();const s=A(this.stylesheet.sprite);if(s.find((s=>s.id===e))){if(this._spritesImagesIds[e])for(const s of this._spritesImagesIds[e])this.imageManager.removeImage(s),this._changedImages[s]=!0;s.splice(s.findIndex((s=>s.id===e)),1),this.stylesheet.sprite=s.length>0?s:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"}))}else this.fire(new a.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return A(this.stylesheet.sprite)}setSprite(e,s={},l){this._checkLoaded(),e&&this._validate(a.z.sprite,"sprite",e,null,s)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,l):(this._unloadSprite(),l&&l(null)))}}var or=a.aJ([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Pi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,s,a,l,c,u,p,f,_){this.context=e;let g=this.boundPaintVertexBuffers.length!==l.length;for(let e=0;!g&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:s,u_fog_color:l?l.properties.get("fog-color"):a.bf.white,u_fog_ground_blend:l?l.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:u?0:l?l.calculateFogBlendOpacity(c):0,u_horizon_color:l?l.properties.get("horizon-color"):a.bf.white,u_horizon_fog_blend:l?l.properties.get("horizon-fog-blend"):1,u_is_globe_mode:u?1:0}),cr={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 hr(e){const s=[];for(let a=0;a({u_depth:new a.bP(e,s.u_depth),u_terrain:new a.bP(e,s.u_terrain),u_terrain_dim:new a.bg(e,s.u_terrain_dim),u_terrain_matrix:new a.bR(e,s.u_terrain_matrix),u_terrain_unpack:new a.bS(e,s.u_terrain_unpack),u_terrain_exaggeration:new a.bg(e,s.u_terrain_exaggeration)}))(e,Z),this.projectionUniforms=((e,s)=>({u_projection_matrix:new a.bR(e,s.u_projection_matrix),u_projection_tile_mercator_coords:new a.bS(e,s.u_projection_tile_mercator_coords),u_projection_clipping_plane:new a.bS(e,s.u_projection_clipping_plane),u_projection_transition:new a.bg(e,s.u_projection_transition),u_projection_fallback_matrix:new a.bR(e,s.u_projection_fallback_matrix)}))(e,Z),this.binderUniforms=l?l.getUniforms(e,Z):[]}draw(e,s,a,l,c,u,p,f,_,g,y,x,v,w,C,A,k,D,R){const L=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(l),e.setColorMode(c),e.setCullFace(u),f){e.activeTexture.set(L.TEXTURE2),L.bindTexture(L.TEXTURE_2D,f.depthTexture),e.activeTexture.set(L.TEXTURE3),L.bindTexture(L.TEXTURE_2D,f.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(f[e])}if(_)for(const e in _)this.projectionUniforms[cr[e]].set(_[e]);if(p)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(p[e]);A&&A.setUniforms(e,this.binderUniforms,w,{zoom:C});let B=0;switch(s){case L.LINES:B=2;break;case L.TRIANGLES:B=3;break;case L.LINE_STRIP:B=1}for(const a of v.get()){const l=a.vaos||(a.vaos={});(l[g]||(l[g]=new Pi)).bind(e,this,y,A?A.getPaintVertexBuffers():[],x,a.vertexOffset,k,D,R),L.drawElements(s,a.primitiveLength*B,L.UNSIGNED_SHORT,a.primitiveOffset*B*2)}}}function ur(e,s,l){const c=1/a.aC(l,1,s.transform.tileZoom),u=Math.pow(2,l.tileID.overscaledZ),p=l.tileSize*Math.pow(2,s.transform.tileZoom)/u,f=p*(l.tileID.canonical.x+l.tileID.wrap*u),_=p*l.tileID.canonical.y;return{u_image:0,u_texsize:l.imageAtlasTexture.size,u_scale:[c,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[f>>16,_>>16],u_pixel_coord_lower:[65535&f,65535&_]}}const dr=(e,s,l,c)=>{const u=e.style.light,p=u.properties.get("position"),f=[p.x,p.y,p.z],_=a.bV();"viewport"===u.properties.get("anchor")&&a.bW(_,e.transform.bearingInRadians),a.bX(f,f,_);const g=e.transform.transformLightDirection(f),y=u.properties.get("color");return{u_lightpos:f,u_lightpos_globe:g,u_lightintensity:u.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+s,u_opacity:l,u_fill_translate:c}},fr=(e,s,l,c,u,p,f)=>a.e(dr(e,s,l,c),ur(p,e,f),{u_height_factor:-Math.pow(2,u.overscaledZ)/f.tileSize/8}),mr=(e,s,l,c)=>a.e(ur(s,e,l),{u_fill_translate:c}),_r=(e,s)=>({u_world:e,u_fill_translate:s}),gr=(e,s,l,c,u)=>a.e(mr(e,s,l,u),{u_world:c}),xr=(e,s,l,c,u)=>{const p=e.transform;let f,_,g=0;if("map"===l.paint.get("circle-pitch-alignment")){const e=a.aC(s,1,p.zoom);f=!0,_=[e,e],g=e/(a.$*Math.pow(2,s.tileID.overscaledZ))*2*Math.PI*u}else f=!1,_=p.pixelsToGLUnits;return{u_camera_to_center_distance:p.cameraToCenterDistance,u_scale_with_map:+("map"===l.paint.get("circle-pitch-scale")),u_pitch_with_map:+f,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:_,u_globe_extrude_scale:g,u_translate:c}},vr=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),br=e=>({u_viewport_size:[e.width,e.height]}),wr=(e,s=1)=>({u_color:e,u_overlay:0,u_overlay_scale:s}),Tr=(e,s,l,c)=>{const u=a.aC(e,1,s)/(a.$*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*c;return{u_extrude_scale:a.aC(e,1,s),u_intensity:l,u_globe_extrude_scale:u}},Sr=(e,s,l,c)=>{const u=a.L();a.bY(u,0,e.width,e.height,0,0,1);const p=e.context.gl;return{u_matrix:u,u_world:[p.drawingBufferWidth,p.drawingBufferHeight],u_image:l,u_color_ramp:c,u_opacity:s.paint.get("heatmap-opacity")}},Cr=(e,s,a)=>{const l=a.paint.get("hillshade-accent-color");let c;switch(a.paint.get("hillshade-method")){case"basic":c=4;break;case"combined":c=1;break;case"igor":c=2;break;case"multidirectional":c=3;break;default:c=0}const u=a.getIlluminationProperties();for(let s=0;s{const l=s.stride,c=a.L();return a.bY(c,0,a.$,-a.$,0,0,1),a.M(c,c,[0,-a.$,0]),{u_matrix:c,u_image:1,u_dimension:[l,l],u_zoom:e.overscaledZ,u_unpack:s.getUnpackVector()}};function Dr(e,s){const l=Math.pow(2,s.canonical.z),c=s.canonical.y;return[new a.a1(0,c/l).toLngLat().lat,new a.a1(0,(c+1)/l).toLngLat().lat]}const Rr=(e,s,a=0)=>({u_image:0,u_unpack:s.getUnpackVector(),u_dimension:[s.stride,s.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:a,u_opacity:e.paint.get("color-relief-opacity")}),Lr=(e,s,l,c)=>{const u=e.transform;return{u_translation:Qr(e,s,l),u_ratio:c/a.aC(s,1,u.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]]}},Br=(e,s,l,c,u)=>a.e(Lr(e,s,l,c),{u_image:0,u_image_height:u}),Or=(e,s,l,c,u)=>{const p=e.transform,f=Jr(s,p);return{u_translation:Qr(e,s,l),u_texsize:s.imageAtlasTexture.size,u_ratio:c/a.aC(s,1,p.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[f,u.fromScale,u.toScale],u_fade:u.t,u_units_to_pixels:[1/p.pixelsToGLUnits[0],1/p.pixelsToGLUnits[1]]}},qr=(e,s,l,c,u,p)=>{const f=e.lineAtlas,_=Jr(s,e.transform),g="round"===l.layout.get("line-cap"),y=f.getDash(u.from,g),x=f.getDash(u.to,g),v=y.width*p.fromScale,w=x.width*p.toScale;return a.e(Lr(e,s,l,c),{u_patternscale_a:[_/v,-y.height/2],u_patternscale_b:[_/w,-x.height/2],u_sdfgamma:f.width/(256*Math.min(v,w)*e.pixelRatio)/2,u_image:0,u_tex_y_a:y.y,u_tex_y_b:x.y,u_mix:p.t})};function Jr(e,s){return 1/a.aC(e,1,s.tileZoom)}function Qr(e,s,l){return a.aD(e.transform,s,l.paint.get("line-translate"),l.paint.get("line-translate-anchor"))}const tn=(e,s,a,l,c)=>{return{u_tl_parent:e,u_scale_parent:s,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.opacity*l.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:l.paint.get("raster-brightness-min"),u_brightness_high:l.paint.get("raster-brightness-max"),u_saturation_factor:(p=l.paint.get("raster-saturation"),p>0?1-1/(1.001-p):-p),u_contrast_factor:(u=l.paint.get("raster-contrast"),u>0?1/(1-u):1+u),u_spin_weights:en(l.paint.get("raster-hue-rotate")),u_coords_top:[c[0].x,c[0].y,c[1].x,c[1].y],u_coords_bottom:[c[3].x,c[3].y,c[2].x,c[2].y]};var u,p};function en(e){e*=Math.PI/180;const s=Math.sin(e),a=Math.cos(e);return[(2*a+1)/3,(-Math.sqrt(3)*s-a+1)/3,(Math.sqrt(3)*s-a+1)/3]}const rn=(e,s,a,l,c,u,p,f,_,g,y,x,v)=>{const w=p.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:s?s.uSizeT:0,u_size:s?s.uSize:0,u_camera_to_center_distance:w.cameraToCenterDistance,u_pitch:w.pitch/360*2*Math.PI,u_rotate_symbol:+a,u_aspect_ratio:w.width/w.height,u_fade_change:p.options.fadeDuration?p.symbolFadeChange:1,u_label_plane_matrix:f,u_coord_matrix:_,u_is_text:+y,u_pitch_with_map:+l,u_is_along_line:c,u_is_variable_anchor:u,u_texsize:x,u_texture:0,u_translation:g,u_pitched_scale:v}},nn=(e,s,l,c,u,p,f,_,g,y,x,v,w,C)=>{const A=f.transform;return a.e(rn(e,s,l,c,u,p,f,_,g,y,x,v,C),{u_gamma_scale:c?Math.cos(A.pitch*Math.PI/180)*A.cameraToCenterDistance:1,u_device_pixel_ratio:f.pixelRatio,u_is_halo:1})},sn=(e,s,l,c,u,p,f,_,g,y,x,v,w)=>a.e(nn(e,s,l,c,u,p,f,_,g,y,!0,x,0,w),{u_texsize_icon:v,u_texture_icon:1}),on=(e,s)=>({u_opacity:e,u_color:s}),ln=(e,s,l,c,u)=>a.e(function(e,s,l,c){const u=l.imageManager.getPattern(e.from.toString()),p=l.imageManager.getPattern(e.to.toString()),{width:f,height:_}=l.imageManager.getPixelSize(),g=Math.pow(2,c.tileID.overscaledZ),y=c.tileSize*Math.pow(2,l.transform.tileZoom)/g,x=y*(c.tileID.canonical.x+c.tileID.wrap*g),v=y*c.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:u.tl,u_pattern_br_a:u.br,u_pattern_tl_b:p.tl,u_pattern_br_b:p.br,u_texsize:[f,_],u_mix:s.t,u_pattern_size_a:u.displaySize,u_pattern_size_b:p.displaySize,u_scale_a:s.fromScale,u_scale_b:s.toScale,u_tile_units_to_pixels:1/a.aC(c,1,l.transform.tileZoom),u_pixel_coord_upper:[x>>16,v>>16],u_pixel_coord_lower:[65535&x,65535&v]}}(l,u,s,c),{u_opacity:e}),cn=(e,s)=>{},hn={fillExtrusion:(e,s)=>({u_lightpos:new a.bT(e,s.u_lightpos),u_lightpos_globe:new a.bT(e,s.u_lightpos_globe),u_lightintensity:new a.bg(e,s.u_lightintensity),u_lightcolor:new a.bT(e,s.u_lightcolor),u_vertical_gradient:new a.bg(e,s.u_vertical_gradient),u_opacity:new a.bg(e,s.u_opacity),u_fill_translate:new a.bU(e,s.u_fill_translate)}),fillExtrusionPattern:(e,s)=>({u_lightpos:new a.bT(e,s.u_lightpos),u_lightpos_globe:new a.bT(e,s.u_lightpos_globe),u_lightintensity:new a.bg(e,s.u_lightintensity),u_lightcolor:new a.bT(e,s.u_lightcolor),u_vertical_gradient:new a.bg(e,s.u_vertical_gradient),u_height_factor:new a.bg(e,s.u_height_factor),u_opacity:new a.bg(e,s.u_opacity),u_fill_translate:new a.bU(e,s.u_fill_translate),u_image:new a.bP(e,s.u_image),u_texsize:new a.bU(e,s.u_texsize),u_pixel_coord_upper:new a.bU(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bU(e,s.u_pixel_coord_lower),u_scale:new a.bT(e,s.u_scale),u_fade:new a.bg(e,s.u_fade)}),fill:(e,s)=>({u_fill_translate:new a.bU(e,s.u_fill_translate)}),fillPattern:(e,s)=>({u_image:new a.bP(e,s.u_image),u_texsize:new a.bU(e,s.u_texsize),u_pixel_coord_upper:new a.bU(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bU(e,s.u_pixel_coord_lower),u_scale:new a.bT(e,s.u_scale),u_fade:new a.bg(e,s.u_fade),u_fill_translate:new a.bU(e,s.u_fill_translate)}),fillOutline:(e,s)=>({u_world:new a.bU(e,s.u_world),u_fill_translate:new a.bU(e,s.u_fill_translate)}),fillOutlinePattern:(e,s)=>({u_world:new a.bU(e,s.u_world),u_image:new a.bP(e,s.u_image),u_texsize:new a.bU(e,s.u_texsize),u_pixel_coord_upper:new a.bU(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bU(e,s.u_pixel_coord_lower),u_scale:new a.bT(e,s.u_scale),u_fade:new a.bg(e,s.u_fade),u_fill_translate:new a.bU(e,s.u_fill_translate)}),circle:(e,s)=>({u_camera_to_center_distance:new a.bg(e,s.u_camera_to_center_distance),u_scale_with_map:new a.bP(e,s.u_scale_with_map),u_pitch_with_map:new a.bP(e,s.u_pitch_with_map),u_extrude_scale:new a.bU(e,s.u_extrude_scale),u_device_pixel_ratio:new a.bg(e,s.u_device_pixel_ratio),u_globe_extrude_scale:new a.bg(e,s.u_globe_extrude_scale),u_translate:new a.bU(e,s.u_translate)}),collisionBox:(e,s)=>({u_pixel_extrude_scale:new a.bU(e,s.u_pixel_extrude_scale)}),collisionCircle:(e,s)=>({u_viewport_size:new a.bU(e,s.u_viewport_size)}),debug:(e,s)=>({u_color:new a.bQ(e,s.u_color),u_overlay:new a.bP(e,s.u_overlay),u_overlay_scale:new a.bg(e,s.u_overlay_scale)}),depth:cn,clippingMask:cn,heatmap:(e,s)=>({u_extrude_scale:new a.bg(e,s.u_extrude_scale),u_intensity:new a.bg(e,s.u_intensity),u_globe_extrude_scale:new a.bg(e,s.u_globe_extrude_scale)}),heatmapTexture:(e,s)=>({u_matrix:new a.bR(e,s.u_matrix),u_world:new a.bU(e,s.u_world),u_image:new a.bP(e,s.u_image),u_color_ramp:new a.bP(e,s.u_color_ramp),u_opacity:new a.bg(e,s.u_opacity)}),hillshade:(e,s)=>({u_image:new a.bP(e,s.u_image),u_latrange:new a.bU(e,s.u_latrange),u_exaggeration:new a.bg(e,s.u_exaggeration),u_altitudes:new a.b_(e,s.u_altitudes),u_azimuths:new a.b_(e,s.u_azimuths),u_accent:new a.bQ(e,s.u_accent),u_method:new a.bP(e,s.u_method),u_shadows:new a.bZ(e,s.u_shadows),u_highlights:new a.bZ(e,s.u_highlights)}),hillshadePrepare:(e,s)=>({u_matrix:new a.bR(e,s.u_matrix),u_image:new a.bP(e,s.u_image),u_dimension:new a.bU(e,s.u_dimension),u_zoom:new a.bg(e,s.u_zoom),u_unpack:new a.bS(e,s.u_unpack)}),colorRelief:(e,s)=>({u_image:new a.bP(e,s.u_image),u_unpack:new a.bS(e,s.u_unpack),u_dimension:new a.bU(e,s.u_dimension),u_elevation_stops:new a.bP(e,s.u_elevation_stops),u_color_stops:new a.bP(e,s.u_color_stops),u_color_ramp_size:new a.bP(e,s.u_color_ramp_size),u_opacity:new a.bg(e,s.u_opacity)}),line:(e,s)=>({u_translation:new a.bU(e,s.u_translation),u_ratio:new a.bg(e,s.u_ratio),u_device_pixel_ratio:new a.bg(e,s.u_device_pixel_ratio),u_units_to_pixels:new a.bU(e,s.u_units_to_pixels)}),lineGradient:(e,s)=>({u_translation:new a.bU(e,s.u_translation),u_ratio:new a.bg(e,s.u_ratio),u_device_pixel_ratio:new a.bg(e,s.u_device_pixel_ratio),u_units_to_pixels:new a.bU(e,s.u_units_to_pixels),u_image:new a.bP(e,s.u_image),u_image_height:new a.bg(e,s.u_image_height)}),linePattern:(e,s)=>({u_translation:new a.bU(e,s.u_translation),u_texsize:new a.bU(e,s.u_texsize),u_ratio:new a.bg(e,s.u_ratio),u_device_pixel_ratio:new a.bg(e,s.u_device_pixel_ratio),u_image:new a.bP(e,s.u_image),u_units_to_pixels:new a.bU(e,s.u_units_to_pixels),u_scale:new a.bT(e,s.u_scale),u_fade:new a.bg(e,s.u_fade)}),lineSDF:(e,s)=>({u_translation:new a.bU(e,s.u_translation),u_ratio:new a.bg(e,s.u_ratio),u_device_pixel_ratio:new a.bg(e,s.u_device_pixel_ratio),u_units_to_pixels:new a.bU(e,s.u_units_to_pixels),u_patternscale_a:new a.bU(e,s.u_patternscale_a),u_patternscale_b:new a.bU(e,s.u_patternscale_b),u_sdfgamma:new a.bg(e,s.u_sdfgamma),u_image:new a.bP(e,s.u_image),u_tex_y_a:new a.bg(e,s.u_tex_y_a),u_tex_y_b:new a.bg(e,s.u_tex_y_b),u_mix:new a.bg(e,s.u_mix)}),raster:(e,s)=>({u_tl_parent:new a.bU(e,s.u_tl_parent),u_scale_parent:new a.bg(e,s.u_scale_parent),u_buffer_scale:new a.bg(e,s.u_buffer_scale),u_fade_t:new a.bg(e,s.u_fade_t),u_opacity:new a.bg(e,s.u_opacity),u_image0:new a.bP(e,s.u_image0),u_image1:new a.bP(e,s.u_image1),u_brightness_low:new a.bg(e,s.u_brightness_low),u_brightness_high:new a.bg(e,s.u_brightness_high),u_saturation_factor:new a.bg(e,s.u_saturation_factor),u_contrast_factor:new a.bg(e,s.u_contrast_factor),u_spin_weights:new a.bT(e,s.u_spin_weights),u_coords_top:new a.bS(e,s.u_coords_top),u_coords_bottom:new a.bS(e,s.u_coords_bottom)}),symbolIcon:(e,s)=>({u_is_size_zoom_constant:new a.bP(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bP(e,s.u_is_size_feature_constant),u_size_t:new a.bg(e,s.u_size_t),u_size:new a.bg(e,s.u_size),u_camera_to_center_distance:new a.bg(e,s.u_camera_to_center_distance),u_pitch:new a.bg(e,s.u_pitch),u_rotate_symbol:new a.bP(e,s.u_rotate_symbol),u_aspect_ratio:new a.bg(e,s.u_aspect_ratio),u_fade_change:new a.bg(e,s.u_fade_change),u_label_plane_matrix:new a.bR(e,s.u_label_plane_matrix),u_coord_matrix:new a.bR(e,s.u_coord_matrix),u_is_text:new a.bP(e,s.u_is_text),u_pitch_with_map:new a.bP(e,s.u_pitch_with_map),u_is_along_line:new a.bP(e,s.u_is_along_line),u_is_variable_anchor:new a.bP(e,s.u_is_variable_anchor),u_texsize:new a.bU(e,s.u_texsize),u_texture:new a.bP(e,s.u_texture),u_translation:new a.bU(e,s.u_translation),u_pitched_scale:new a.bg(e,s.u_pitched_scale)}),symbolSDF:(e,s)=>({u_is_size_zoom_constant:new a.bP(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bP(e,s.u_is_size_feature_constant),u_size_t:new a.bg(e,s.u_size_t),u_size:new a.bg(e,s.u_size),u_camera_to_center_distance:new a.bg(e,s.u_camera_to_center_distance),u_pitch:new a.bg(e,s.u_pitch),u_rotate_symbol:new a.bP(e,s.u_rotate_symbol),u_aspect_ratio:new a.bg(e,s.u_aspect_ratio),u_fade_change:new a.bg(e,s.u_fade_change),u_label_plane_matrix:new a.bR(e,s.u_label_plane_matrix),u_coord_matrix:new a.bR(e,s.u_coord_matrix),u_is_text:new a.bP(e,s.u_is_text),u_pitch_with_map:new a.bP(e,s.u_pitch_with_map),u_is_along_line:new a.bP(e,s.u_is_along_line),u_is_variable_anchor:new a.bP(e,s.u_is_variable_anchor),u_texsize:new a.bU(e,s.u_texsize),u_texture:new a.bP(e,s.u_texture),u_gamma_scale:new a.bg(e,s.u_gamma_scale),u_device_pixel_ratio:new a.bg(e,s.u_device_pixel_ratio),u_is_halo:new a.bP(e,s.u_is_halo),u_translation:new a.bU(e,s.u_translation),u_pitched_scale:new a.bg(e,s.u_pitched_scale)}),symbolTextAndIcon:(e,s)=>({u_is_size_zoom_constant:new a.bP(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bP(e,s.u_is_size_feature_constant),u_size_t:new a.bg(e,s.u_size_t),u_size:new a.bg(e,s.u_size),u_camera_to_center_distance:new a.bg(e,s.u_camera_to_center_distance),u_pitch:new a.bg(e,s.u_pitch),u_rotate_symbol:new a.bP(e,s.u_rotate_symbol),u_aspect_ratio:new a.bg(e,s.u_aspect_ratio),u_fade_change:new a.bg(e,s.u_fade_change),u_label_plane_matrix:new a.bR(e,s.u_label_plane_matrix),u_coord_matrix:new a.bR(e,s.u_coord_matrix),u_is_text:new a.bP(e,s.u_is_text),u_pitch_with_map:new a.bP(e,s.u_pitch_with_map),u_is_along_line:new a.bP(e,s.u_is_along_line),u_is_variable_anchor:new a.bP(e,s.u_is_variable_anchor),u_texsize:new a.bU(e,s.u_texsize),u_texsize_icon:new a.bU(e,s.u_texsize_icon),u_texture:new a.bP(e,s.u_texture),u_texture_icon:new a.bP(e,s.u_texture_icon),u_gamma_scale:new a.bg(e,s.u_gamma_scale),u_device_pixel_ratio:new a.bg(e,s.u_device_pixel_ratio),u_is_halo:new a.bP(e,s.u_is_halo),u_translation:new a.bU(e,s.u_translation),u_pitched_scale:new a.bg(e,s.u_pitched_scale)}),background:(e,s)=>({u_opacity:new a.bg(e,s.u_opacity),u_color:new a.bQ(e,s.u_color)}),backgroundPattern:(e,s)=>({u_opacity:new a.bg(e,s.u_opacity),u_image:new a.bP(e,s.u_image),u_pattern_tl_a:new a.bU(e,s.u_pattern_tl_a),u_pattern_br_a:new a.bU(e,s.u_pattern_br_a),u_pattern_tl_b:new a.bU(e,s.u_pattern_tl_b),u_pattern_br_b:new a.bU(e,s.u_pattern_br_b),u_texsize:new a.bU(e,s.u_texsize),u_mix:new a.bg(e,s.u_mix),u_pattern_size_a:new a.bU(e,s.u_pattern_size_a),u_pattern_size_b:new a.bU(e,s.u_pattern_size_b),u_scale_a:new a.bg(e,s.u_scale_a),u_scale_b:new a.bg(e,s.u_scale_b),u_pixel_coord_upper:new a.bU(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bU(e,s.u_pixel_coord_lower),u_tile_units_to_pixels:new a.bg(e,s.u_tile_units_to_pixels)}),terrain:(e,s)=>({u_texture:new a.bP(e,s.u_texture),u_ele_delta:new a.bg(e,s.u_ele_delta),u_fog_matrix:new a.bR(e,s.u_fog_matrix),u_fog_color:new a.bQ(e,s.u_fog_color),u_fog_ground_blend:new a.bg(e,s.u_fog_ground_blend),u_fog_ground_blend_opacity:new a.bg(e,s.u_fog_ground_blend_opacity),u_horizon_color:new a.bQ(e,s.u_horizon_color),u_horizon_fog_blend:new a.bg(e,s.u_horizon_fog_blend),u_is_globe_mode:new a.bg(e,s.u_is_globe_mode)}),terrainDepth:(e,s)=>({u_ele_delta:new a.bg(e,s.u_ele_delta)}),terrainCoords:(e,s)=>({u_texture:new a.bP(e,s.u_texture),u_terrain_coords_id:new a.bg(e,s.u_terrain_coords_id),u_ele_delta:new a.bg(e,s.u_ele_delta)}),projectionErrorMeasurement:(e,s)=>({u_input:new a.bg(e,s.u_input),u_output_expected:new a.bg(e,s.u_output_expected)}),atmosphere:(e,s)=>({u_sun_pos:new a.bT(e,s.u_sun_pos),u_atmosphere_blend:new a.bg(e,s.u_atmosphere_blend),u_globe_position:new a.bT(e,s.u_globe_position),u_globe_radius:new a.bg(e,s.u_globe_radius),u_inv_proj_matrix:new a.bR(e,s.u_inv_proj_matrix)}),sky:(e,s)=>({u_sky_color:new a.bQ(e,s.u_sky_color),u_horizon_color:new a.bQ(e,s.u_horizon_color),u_horizon:new a.bU(e,s.u_horizon),u_horizon_normal:new a.bU(e,s.u_horizon_normal),u_sky_horizon_blend:new a.bg(e,s.u_sky_horizon_blend),u_sky_blend:new a.bg(e,s.u_sky_blend)})};class so{constructor(e,s,a){this.context=e;const l=e.gl;this.buffer=l.createBuffer(),this.dynamicDraw=Boolean(a),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),l.bufferData(l.ELEMENT_ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?l.DYNAMIC_DRAW:l.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const s=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),s.bufferSubData(s.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const un={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class lo{constructor(e,s,a,l){this.length=s.length,this.attributes=a,this.itemSize=s.bytesPerElement,this.dynamicDraw=l,this.context=e;const c=e.gl;this.buffer=c.createBuffer(),e.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const s=this.context.gl;this.bind(),s.bufferSubData(s.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,s){for(let a=0;a0&&(y.push({circleArray:k,circleOffset:v,coord:w}),x+=k.length/4,v=x),A&&g.draw(p,_.LINES,Zt.disabled,Vt.disabled,e.colorModeForRenderPass(),Ut.disabled,vr(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(w),f.getProjectionData({overscaledTileID:w,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),l.id,A.layoutVertexBuffer,A.indexBuffer,A.segments,null,e.transform.zoom,null,null,A.collisionVertexBuffer)}if(!u||!y.length)return;const w=e.useProgram("collisionCircle"),C=new a.b$;C.resize(4*x),C._trim();let A=0;for(const e of y)for(let s=0;s=0&&(k[D.associatedIconIndex]={shiftedAnchor:et,angle:it})}else ze(D.numGlyphs,C)}if(g){A.clear();const s=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(_,s,a):null,a="map"===l.layout.get("text-rotation-alignment");ue(g,e,u,pt,xt,R,y,a,_.toUnwrapped(),k.width,k.height,Tt,s)}const kt=u&&N||Et,Ft=L||kt?mn:R?pt:e.transform.clipSpaceToPixelsMatrix,Nt=C&&0!==l.paint.get(u?"text-halo-width":"icon-halo-width").constantOr(1);let $t;$t=C?g.iconsInText?sn(U.kind,it,B,R,L,kt,e,Ft,bt,Tt,nt,lt,J):nn(U.kind,it,B,R,L,kt,e,Ft,bt,Tt,u,nt,0,J):rn(U.kind,it,B,R,L,kt,e,Ft,bt,Tt,u,nt,J);const Gt={program:et,buffers:x,uniformValues:$t,projectionData:Pt,atlasTexture:st,atlasTextureIcon:ct,atlasInterpolation:ot,atlasInterpolationIcon:at,isSDF:C,hasHalo:Nt};if(O&&g.canOverlap){j=!0;const e=x.segments.get();for(const s of e)Z.push({segments:new a.aM([s]),sortKey:s.sortKey,state:Gt,terrainData:rt})}else Z.push({segments:x.segments,sortKey:0,state:Gt,terrainData:rt})}j&&Z.sort(((e,s)=>e.sortKey-s.sortKey));for(const s of Z){const a=s.state;if(C.activeTexture.set(A.TEXTURE0),a.atlasTexture.bind(a.atlasInterpolation,A.CLAMP_TO_EDGE),a.atlasTextureIcon&&(C.activeTexture.set(A.TEXTURE1),a.atlasTextureIcon&&a.atlasTextureIcon.bind(a.atlasInterpolationIcon,A.CLAMP_TO_EDGE)),a.isSDF){const c=a.uniformValues;a.hasHalo&&(c.u_is_halo=1,bn(a.buffers,s.segments,l,e,a.program,U,x,v,c,a.projectionData,s.terrainData)),c.u_is_halo=0}bn(a.buffers,s.segments,l,e,a.program,U,x,v,a.uniformValues,a.projectionData,s.terrainData)}}function bn(e,s,a,l,c,u,p,f,_,g,y){const x=l.context;c.draw(x,x.gl.TRIANGLES,u,p,f,Ut.backCCW,_,y,g,a.id,e.layoutVertexBuffer,e.indexBuffer,s,a.paint,l.transform.zoom,e.programConfigurations.get(a.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function wn(e,s,l,c,u){const p=e.context,f=p.gl,_=Vt.disabled,g=new jt([f.ONE,f.ONE],a.bf.transparent,[!0,!0,!0,!0]),y=s.getBucket(l);if(!y)return;const x=c.key;let v=l.heatmapFbos.get(x);v||(v=Sn(p,s.tileSize,s.tileSize),l.heatmapFbos.set(x,v)),p.bindFramebuffer.set(v.framebuffer),p.viewport.set([0,0,s.tileSize,s.tileSize]),p.clear({color:a.bf.transparent});const w=y.programConfigurations.get(l.id),C=e.useProgram("heatmap",w,!u),A=e.transform.getProjectionData({overscaledTileID:s.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),k=e.style.map.terrain.getTerrainData(c);C.draw(p,f.TRIANGLES,Zt.disabled,_,g,Ut.disabled,Tr(s,e.transform.zoom,l.paint.get("heatmap-intensity"),1),k,A,l.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,l.paint,e.transform.zoom,w)}function Tn(e,s,a,l,c){const u=e.context,p=u.gl,f=e.transform;u.setColorMode(e.colorModeForRenderPass());const _=Mn(u,s),g=a.key,y=s.heatmapFbos.get(g);if(!y)return;u.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,y.colorAttachment.get()),u.activeTexture.set(p.TEXTURE1),_.bind(p.LINEAR,p.CLAMP_TO_EDGE);const x=f.getProjectionData({overscaledTileID:a,applyTerrainMatrix:c,applyGlobeMatrix:!l});e.useProgram("heatmapTexture").draw(u,p.TRIANGLES,Zt.disabled,Vt.disabled,e.colorModeForRenderPass(),Ut.disabled,Sr(e,s,0,1),null,x,s.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,s.paint,f.zoom),y.destroy(),s.heatmapFbos.delete(g)}function Sn(e,s,a){var l,c;const u=e.gl,p=u.createTexture();u.bindTexture(u.TEXTURE_2D,p),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,u.LINEAR),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,u.LINEAR);const f=null!==(l=e.HALF_FLOAT)&&void 0!==l?l:u.UNSIGNED_BYTE,_=null!==(c=e.RGBA16F)&&void 0!==c?c:u.RGBA;u.texImage2D(u.TEXTURE_2D,0,_,s,a,0,u.RGBA,f,null);const g=e.createFramebuffer(s,a,!1,!1);return g.colorAttachment.set(p),g}function Mn(e,s){return s.colorRampTexture||(s.colorRampTexture=new a.T(e,s.colorRamp,e.gl.RGBA)),s.colorRampTexture}function Cn(e,s,a,l,c){if(!a||!l||!l.imageAtlas)return;const u=l.imageAtlas.patternPositions;let p=u[a.to.toString()],f=u[a.from.toString()];if(!p&&f&&(p=f),!f&&p&&(f=p),!p||!f){const e=c.getPaintProperty(s);p=u[e],f=u[e]}p&&f&&e.setConstantPatternPositions(p,f)}function In(e,s,l,c,u,p,f,_){const g=e.context.gl,y="fill-pattern",x=l.paint.get(y),v=x&&x.constantOr(1),w=l.getCrossfadeParameters();let C,A,k,D,R;const L=e.transform,B=l.paint.get("fill-translate"),O=l.paint.get("fill-translate-anchor");f?(A=v&&!l.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",C=g.LINES):(A=v?"fillPattern":"fill",C=g.TRIANGLES);const j=x.constantOr(null);for(const x of c){const c=s.getTile(x);if(v&&!c.patternsLoaded())continue;const U=c.getBucket(l);if(!U)continue;const N=U.programConfigurations.get(l.id),Z=e.useProgram(A,N),J=e.style.map.terrain&&e.style.map.terrain.getTerrainData(x);v&&(e.context.activeTexture.set(g.TEXTURE0),c.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),N.updatePaintBuffers(w)),Cn(N,y,j,c,l);const Q=L.getProjectionData({overscaledTileID:x,applyGlobeMatrix:!_,applyTerrainMatrix:!0}),et=a.aD(L,c,B,O);if(f){D=U.indexBuffer2,R=U.segments2;const s=[g.drawingBufferWidth,g.drawingBufferHeight];k="fillOutlinePattern"===A&&v?gr(e,w,c,s,et):_r(s,et)}else D=U.indexBuffer,R=U.segments,k=v?mr(e,w,c,et):{u_fill_translate:et};const it=e.stencilModeForClipping(x);Z.draw(e.context,C,u,it,p,Ut.backCCW,k,J,Q,l.id,U.layoutVertexBuffer,D,R,l.paint,e.transform.zoom,N)}}function An(e,s,l,c,u,p,f,_){const g=e.context,y=g.gl,x="fill-extrusion-pattern",v=l.paint.get(x),w=v.constantOr(1),C=l.getCrossfadeParameters(),A=l.paint.get("fill-extrusion-opacity"),k=v.constantOr(null),D=e.transform;for(const v of c){const c=s.getTile(v),R=c.getBucket(l);if(!R)continue;const L=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v),B=R.programConfigurations.get(l.id),O=e.useProgram(w?"fillExtrusionPattern":"fillExtrusion",B);w&&(e.context.activeTexture.set(y.TEXTURE0),c.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),B.updatePaintBuffers(C));const j=D.getProjectionData({overscaledTileID:v,applyGlobeMatrix:!_,applyTerrainMatrix:!0});Cn(B,x,k,c,l);const U=a.aD(D,c,l.paint.get("fill-extrusion-translate"),l.paint.get("fill-extrusion-translate-anchor")),N=l.paint.get("fill-extrusion-vertical-gradient"),Z=w?fr(e,N,A,U,v,C,c):dr(e,N,A,U);O.draw(g,g.gl.TRIANGLES,u,p,f,Ut.backCCW,Z,L,j,l.id,R.layoutVertexBuffer,R.indexBuffer,R.segments,l.paint,e.transform.zoom,B,e.style.map.terrain&&R.centroidVertexBuffer)}}function kn(e,s,a,l,c,u,p,f,_){var g;const y=e.style.projection,x=e.context,v=e.transform,w=x.gl,C=[`#define NUM_ILLUMINATION_SOURCES ${a.paint.get("hillshade-highlight-color").values.length}`],A=e.useProgram("hillshade",null,!1,C),k=!e.options.moving;for(const C of l){const l=s.getTile(C),D=l.fbo;if(!D)continue;const R=y.getMeshFromTileID(x,C.canonical,f,!0,"raster"),L=null===(g=e.style.map.terrain)||void 0===g?void 0:g.getTerrainData(C);x.activeTexture.set(w.TEXTURE0),w.bindTexture(w.TEXTURE_2D,D.colorAttachment.get());const B=v.getProjectionData({overscaledTileID:C,aligned:k,applyGlobeMatrix:!_,applyTerrainMatrix:!0});A.draw(x,w.TRIANGLES,u,c[C.overscaledZ],p,Ut.backCCW,Cr(e,l,a),L,B,a.id,R.vertexBuffer,R.indexBuffer,R.segments)}}function Dn(e,s,l,c,u,p,f,_,g){var y;const x=e.style.projection,v=e.context,w=e.transform,C=v.gl,A=e.useProgram("colorRelief"),k=!e.options.moving;let D=!0,R=0;for(const L of c){const c=s.getTile(L),B=c.dem;if(D){const e=C.getParameter(C.MAX_TEXTURE_SIZE),{elevationTexture:s,colorTexture:a}=l.getColorRampTextures(v,e,B.getUnpackVector());v.activeTexture.set(C.TEXTURE1),s.bind(C.NEAREST,C.CLAMP_TO_EDGE),v.activeTexture.set(C.TEXTURE4),a.bind(C.LINEAR,C.CLAMP_TO_EDGE),D=!1,R=s.size[0]}if(!B||!B.data)continue;const O=B.stride,j=B.getPixels();if(v.activeTexture.set(C.TEXTURE0),v.pixelStoreUnpackPremultiplyAlpha.set(!1),c.demTexture=c.demTexture||e.getTileTexture(O),c.demTexture){const e=c.demTexture;e.update(j,{premultiply:!1}),e.bind(C.LINEAR,C.CLAMP_TO_EDGE)}else c.demTexture=new a.T(v,j,C.RGBA,{premultiply:!1}),c.demTexture.bind(C.LINEAR,C.CLAMP_TO_EDGE);const U=x.getMeshFromTileID(v,L.canonical,_,!0,"raster"),N=null===(y=e.style.map.terrain)||void 0===y?void 0:y.getTerrainData(L),Z=w.getProjectionData({overscaledTileID:L,aligned:k,applyGlobeMatrix:!g,applyTerrainMatrix:!0});A.draw(v,C.TRIANGLES,p,u[L.overscaledZ],f,Ut.backCCW,Rr(l,c.dem,R),N,Z,l.id,U.vertexBuffer,U.indexBuffer,U.segments)}}const Rn=[new a.P(0,0),new a.P(a.$,0),new a.P(a.$,a.$),new a.P(0,a.$)];function Ln(e,s,a,l,c,u,p,f,_=!1,g=!1){const y=l[l.length-1].overscaledZ,x=e.context,v=x.gl,w=e.useProgram("raster"),C=e.transform,A=e.style.projection,k=e.colorModeForRenderPass(),D=!e.options.moving;for(const R of l){const l=e.getDepthModeForSublayer(R.overscaledZ-y,1===a.paint.get("raster-opacity")?Zt.ReadWrite:Zt.ReadOnly,v.LESS),L=s.getTile(R);L.registerFadeDuration(a.paint.get("raster-fade-duration"));const B=s.findLoadedParent(R,0),O=s.findLoadedSibling(R),j=Bn(L,B||O||null,s,a,e.transform,e.style.map.terrain);let U,N;const Z="nearest"===a.paint.get("raster-resampling")?v.NEAREST:v.LINEAR;x.activeTexture.set(v.TEXTURE0),L.texture.bind(Z,v.CLAMP_TO_EDGE,v.LINEAR_MIPMAP_NEAREST),x.activeTexture.set(v.TEXTURE1),B?(B.texture.bind(Z,v.CLAMP_TO_EDGE,v.LINEAR_MIPMAP_NEAREST),U=Math.pow(2,B.tileID.overscaledZ-L.tileID.overscaledZ),N=[L.tileID.canonical.x*U%1,L.tileID.canonical.y*U%1]):L.texture.bind(Z,v.CLAMP_TO_EDGE,v.LINEAR_MIPMAP_NEAREST),L.texture.useMipmap&&x.extTextureFilterAnisotropic&&e.transform.pitch>20&&v.texParameterf(v.TEXTURE_2D,x.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,x.extTextureFilterAnisotropicMax);const J=e.style.map.terrain&&e.style.map.terrain.getTerrainData(R),Q=C.getProjectionData({overscaledTileID:R,aligned:D,applyGlobeMatrix:!g,applyTerrainMatrix:!0}),et=tn(N||[0,0],U||1,j,a,f),it=A.getMeshFromTileID(x,R.canonical,u,p,"raster");w.draw(x,v.TRIANGLES,l,c?c[R.overscaledZ]:Vt.disabled,k,_?Ut.frontCCW:Ut.backCCW,et,J,Q,a.id,it.vertexBuffer,it.indexBuffer,it.segments)}}function Bn(e,s,l,c,u,p){const _=c.paint.get("raster-fade-duration");if(!p&&_>0){const c=f.now(),p=(c-e.timeAdded)/_,g=s?(c-s.timeAdded)/_:-1,y=l.getSource(),x=Gt(u,{tileSize:y.tileSize,roundZoom:y.roundZoom}),v=!s||Math.abs(s.tileID.overscaledZ-x)>Math.abs(e.tileID.overscaledZ-x),w=v&&e.refreshedUponExpiration?1:a.ah(v?p:1-g,0,1);return e.refreshedUponExpiration&&p>=1&&(e.refreshedUponExpiration=!1),s?{opacity:1,mix:1-w}:{opacity:w,mix:0}}return{opacity:1,mix:0}}const Fn=new a.bf(1,0,0,1),On=new a.bf(0,1,0,1),jn=new a.bf(0,0,1,1),Vn=new a.bf(1,0,1,1),Un=new a.bf(0,1,1,1);function Nn(e,s,a,l){Zn(e,0,s+a/2,e.transform.width,a,l)}function $n(e,s,a,l){Zn(e,s-a/2,0,a,e.transform.height,l)}function Zn(e,s,a,l,c,u){const p=e.context,f=p.gl;f.enable(f.SCISSOR_TEST),f.scissor(s*e.pixelRatio,a*e.pixelRatio,l*e.pixelRatio,c*e.pixelRatio),p.clear({color:u}),f.disable(f.SCISSOR_TEST)}function Gn(e,s,l){const c=e.context,u=c.gl,p=e.useProgram("debug"),f=Zt.disabled,_=Vt.disabled,g=e.colorModeForRenderPass(),y="$debug",x=e.style.map.terrain&&e.style.map.terrain.getTerrainData(l);c.activeTexture.set(u.TEXTURE0);const v=s.getTileByID(l.key).latestRawTileData,w=Math.floor((v&&v.byteLength||0)/1024),C=s.getTile(l).tileSize,A=512/Math.min(C,512)*(l.overscaledZ/e.transform.zoom)*.5;let k=l.canonical.toString();l.overscaledZ!==l.canonical.z&&(k+=` => ${l.overscaledZ}`),function(e,s){e.initDebugOverlayCanvas();const a=e.debugOverlayCanvas,l=e.context.gl,c=e.debugOverlayCanvas.getContext("2d");c.clearRect(0,0,a.width,a.height),c.shadowColor="white",c.shadowBlur=2,c.lineWidth=1.5,c.strokeStyle="white",c.textBaseline="top",c.font="bold 36px Open Sans, sans-serif",c.fillText(s,5,5),c.strokeText(s,5,5),e.debugOverlayTexture.update(a),e.debugOverlayTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE)}(e,`${k} ${w}kB`);const D=e.transform.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!0,applyTerrainMatrix:!0});p.draw(c,u.TRIANGLES,f,_,jt.alphaBlended,Ut.disabled,wr(a.bf.transparent,A),null,D,y,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),p.draw(c,u.LINE_STRIP,f,_,g,Ut.disabled,wr(a.bf.red),x,D,y,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function qn(e,s,a,l){const{isRenderingGlobe:c}=l,u=e.context,p=u.gl,f=e.transform,_=e.colorModeForRenderPass(),g=e.getDepthModeFor3D(),y=e.useProgram("terrain");u.bindFramebuffer.set(null),u.viewport.set([0,0,e.width,e.height]);for(const l of a){const a=s.getTerrainMesh(l.tileID),x=e.renderToTexture.getTexture(l),v=s.getTerrainData(l.tileID);u.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,x.texture);const w=s.getMeshFrameDelta(f.zoom),C=f.calculateFogMatrix(l.tileID.toUnwrapped()),A=lr(w,C,e.style.sky,f.pitch,c),k=f.getProjectionData({overscaledTileID:l.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});y.draw(u,p.TRIANGLES,g,Vt.disabled,_,Ut.backCCW,A,v,k,"terrain",a.vertexBuffer,a.indexBuffer,a.segments)}}function Wn(e,s){if(!s.mesh){const l=new a.aL;l.emplaceBack(-1,-1),l.emplaceBack(1,-1),l.emplaceBack(1,1),l.emplaceBack(-1,1);const c=new a.aN;c.emplaceBack(0,1,2),c.emplaceBack(0,2,3),s.mesh=new wt(e.createVertexBuffer(l,xi.members),e.createIndexBuffer(c),a.aM.simpleSegment(0,0,l.length,c.length))}return s.mesh}class Mr{constructor(e,s){this.context=new Ho(e),this.transform=s,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:a.ag(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=xe.maxUnderzooming+xe.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new vt}resize(e,s,a){if(this.width=Math.floor(e*a),this.height=Math.floor(s*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,s=new a.aL;s.emplaceBack(0,0),s.emplaceBack(a.$,0),s.emplaceBack(0,a.$),s.emplaceBack(a.$,a.$),this.tileExtentBuffer=e.createVertexBuffer(s,xi.members),this.tileExtentSegments=a.aM.simpleSegment(0,0,4,2);const l=new a.aL;l.emplaceBack(0,0),l.emplaceBack(a.$,0),l.emplaceBack(0,a.$),l.emplaceBack(a.$,a.$),this.debugBuffer=e.createVertexBuffer(l,xi.members),this.debugSegments=a.aM.simpleSegment(0,0,4,5);const c=new a.c6;c.emplaceBack(0,0,0,0),c.emplaceBack(a.$,0,a.$,0),c.emplaceBack(0,a.$,0,a.$),c.emplaceBack(a.$,a.$,a.$,a.$),this.rasterBoundsBuffer=e.createVertexBuffer(c,or.members),this.rasterBoundsSegments=a.aM.simpleSegment(0,0,4,2);const u=new a.aL;u.emplaceBack(0,0),u.emplaceBack(a.$,0),u.emplaceBack(0,a.$),u.emplaceBack(a.$,a.$),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(u,xi.members),this.rasterBoundsSegmentsPosOnly=a.aM.simpleSegment(0,0,4,5);const p=new a.aL;p.emplaceBack(0,0),p.emplaceBack(1,0),p.emplaceBack(0,1),p.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(p,xi.members),this.viewportSegments=a.aM.simpleSegment(0,0,4,2);const f=new a.c7;f.emplaceBack(0),f.emplaceBack(1),f.emplaceBack(3),f.emplaceBack(2),f.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(f);const _=new a.aN;_.emplaceBack(1,0,2),_.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(_);const g=this.context.gl;this.stencilClearMode=new Vt({func:g.ALWAYS,mask:0},0,255,g.ZERO,g.ZERO,g.ZERO),this.tileExtentMesh=new wt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,s=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const l=a.L();a.bY(l,0,this.width,this.height,0,0,1),a.N(l,l,[s.drawingBufferWidth,s.drawingBufferHeight,0]);const c={mainMatrix:l,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:l};this.useProgram("clippingMask",null,!0).draw(e,s.TRIANGLES,Zt.disabled,this.stencilClearMode,jt.disabled,Ut.disabled,null,null,c,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,s,a){if(this.currentStencilSource===e.source||!e.isTileClipped()||!s||!s.length)return;this.currentStencilSource=e.source,this.nextStencilID+s.length>256&&this.clearStencil();const l=this.context;l.setColorMode(jt.disabled),l.setDepthMode(Zt.disabled);const c={};for(const e of s)c[e.key]=this.nextStencilID++;this._renderTileMasks(c,s,a,!0),this._renderTileMasks(c,s,a,!1),this._tileClippingMaskIDs=c}_renderTileMasks(e,s,a,l){const c=this.context,u=c.gl,p=this.style.projection,f=this.transform,_=this.useProgram("clippingMask");for(const g of s){const s=e[g.key],y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(g),x=p.getMeshFromTileID(this.context,g.canonical,l,!0,"stencil"),v=f.getProjectionData({overscaledTileID:g,applyGlobeMatrix:!a,applyTerrainMatrix:!0});_.draw(c,u.TRIANGLES,Zt.disabled,new Vt({func:u.ALWAYS,mask:0},s,255,u.KEEP,u.KEEP,u.REPLACE),jt.disabled,a?Ut.disabled:Ut.backCCW,null,y,v,"$clipping",x.vertexBuffer,x.indexBuffer,x.segments)}}_renderTilesDepthBuffer(){const e=this.context,s=e.gl,a=this.style.projection,l=this.transform,c=this.useProgram("depth"),u=this.getDepthModeFor3D(),p=qt(l,{tileSize:l.tileSize});for(const f of p){const p=this.style.map.terrain&&this.style.map.terrain.getTerrainData(f),_=a.getMeshFromTileID(this.context,f.canonical,!0,!0,"raster"),g=l.getProjectionData({overscaledTileID:f,applyGlobeMatrix:!0,applyTerrainMatrix:!0});c.draw(e,s.TRIANGLES,u,Vt.disabled,jt.disabled,Ut.backCCW,null,p,g,"$clipping",_.vertexBuffer,_.indexBuffer,_.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,s=this.context.gl;return new Vt({func:s.NOTEQUAL,mask:255},e,255,s.KEEP,s.KEEP,s.REPLACE)}stencilModeForClipping(e){const s=this.context.gl;return new Vt({func:s.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,s.KEEP,s.KEEP,s.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const s=this.context.gl,a=e.sort(((e,s)=>s.overscaledZ-e.overscaledZ)),l=a[a.length-1].overscaledZ,c=a[0].overscaledZ-l+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();const e={};for(let a=0;as.overscaledZ-e.overscaledZ)),l=a[a.length-1].overscaledZ,c=a[0].overscaledZ-l+1;if(this.clearStencil(),c>1){const e={},u={};for(let a=0;a0};for(const e in p){const s=p[e];s.used&&s.prepare(this.context),_[e]=s.getVisibleCoordinates(!1),g[e]=_[e].slice().reverse(),y[e]=s.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:s.showOverdrawInspector?a.bf.black:a.bf.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,s){const a=e.context,l=a.gl,c=((e,s,a)=>{const l=Math.cos(s.rollInRadians),c=Math.sin(s.rollInRadians),u=Pt(s),p=s.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(s.width/2-u*c)*a,(s.height/2+u*l)*a],u_horizon_normal:[-c,l],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*s.height/2*a,u_sky_blend:p}})(s,e.style.map.transform,e.pixelRatio),u=new Zt(l.LEQUAL,Zt.ReadWrite,[0,1]),p=Vt.disabled,f=e.colorModeForRenderPass(),_=e.useProgram("sky"),g=Wn(a,s);_.draw(a,l.TRIANGLES,u,p,f,Ut.disabled,c,null,void 0,"sky",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky),this._showOverdrawInspector=s.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=u.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[u[this.currentLayer]],s=p[e.source],a=_[e.source];this._renderTileClippingMasks(e,a,!1),this.renderLayer(this,s,e,a,x)}this.renderPass="translucent";let v=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:s,u_globe_position:a,u_globe_radius:l,u_inv_proj_matrix:c}))(g,x,[C[0],C[1],C[2]],v,w),k=Wn(c,s);p.draw(c,u.TRIANGLES,f,Vt.disabled,jt.alphaBlended,Ut.disabled,A,null,null,"atmosphere",k.vertexBuffer,k.indexBuffer,k.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,s){let a=null;const l=Object.values(e._layers).flatMap((a=>a.source&&!a.isHidden(s)?[e.sourceCaches[a.source]]:[])),c=l.filter((e=>"vector"===e.getSource().type)),u=l.filter((e=>"vector"!==e.getSource().type)),p=e=>{(!a||a.getSource().maxzoomp(e))),a||u.forEach((e=>p(e))),a}(this.style,this.transform.zoom);e&&function(e,s,a){for(let l=0;lx.getElevation(u,e,s):null;yn(p,v,w,g,y,k,s,C,D,a.aD(y,e,f,_),u.toUnwrapped(),l)}}}(c,e,l,s,l.layout.get("text-rotation-alignment"),l.layout.get("text-pitch-alignment"),l.paint.get("text-translate"),l.paint.get("text-translate-anchor"),u),0!==l.paint.get("icon-opacity").constantOr(1)&&vn(e,s,l,c,!1,l.paint.get("icon-translate"),l.paint.get("icon-translate-anchor"),l.layout.get("icon-rotation-alignment"),l.layout.get("icon-pitch-alignment"),l.layout.get("icon-keep-upright"),_,g,f),0!==l.paint.get("text-opacity").constantOr(1)&&vn(e,s,l,c,!0,l.paint.get("text-translate"),l.paint.get("text-translate-anchor"),l.layout.get("text-rotation-alignment"),l.layout.get("text-pitch-alignment"),l.layout.get("text-keep-upright"),_,g,f),s.map.showCollisionBoxes&&(fn(e,s,l,c,!0),fn(e,s,l,c,!1))}(e,s,l,c,this.style.placement.variableOffsets,u):a.cc(l)?function(e,s,l,c,u){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:p}=u,f=l.paint.get("circle-opacity"),_=l.paint.get("circle-stroke-width"),g=l.paint.get("circle-stroke-opacity"),y=!l.layout.get("circle-sort-key").isConstant();if(0===f.constantOr(1)&&(0===_.constantOr(1)||0===g.constantOr(1)))return;const x=e.context,v=x.gl,w=e.transform,C=e.getDepthModeForSublayer(0,Zt.ReadOnly),A=Vt.disabled,k=e.colorModeForRenderPass(),D=[],R=w.getCircleRadiusCorrection();for(let u=0;ue.sortKey-s.sortKey));for(const s of D){const{programConfiguration:a,program:c,layoutVertexBuffer:u,indexBuffer:p,uniformValues:f,terrainData:_,projectionData:g}=s.state;c.draw(x,v.TRIANGLES,C,A,k,Ut.backCCW,f,_,g,l.id,u,p,s.segments,l.paint,e.transform.zoom,a)}}(e,s,l,c,u):a.cd(l)?function(e,s,l,c,u){if(0===l.paint.get("heatmap-opacity"))return;const p=e.context,{isRenderingToTexture:f,isRenderingGlobe:_}=u;if(e.style.map.terrain){for(const a of c){const c=s.getTile(a);s.hasRenderableParent(a)||("offscreen"===e.renderPass?wn(e,c,l,a,_):"translucent"===e.renderPass&&Tn(e,l,a,f,_))}p.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,s,l,c){const u=e.context,p=u.gl,f=e.transform,_=Vt.disabled,g=new jt([p.ONE,p.ONE],a.bf.transparent,[!0,!0,!0,!0]);(function(e,s,l){const c=e.gl;e.activeTexture.set(c.TEXTURE1),e.viewport.set([0,0,s.width/4,s.height/4]);let u=l.heatmapFbos.get(a.c2);u?(c.bindTexture(c.TEXTURE_2D,u.colorAttachment.get()),e.bindFramebuffer.set(u.framebuffer)):(u=Sn(e,s.width/4,s.height/4),l.heatmapFbos.set(a.c2,u))})(u,e,l),u.clear({color:a.bf.transparent});for(let a=0;a0?s.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const s=this.imageManager.getPattern(e.from.toString()),a=this.imageManager.getPattern(e.to.toString());return!s||!a}useProgram(e,s,a=!1,l=[]){this.cache=this.cache||{};const c=!!this.style.map.terrain,u=this.style.projection,p=a?_i.projectionMercator:u.shaderPreludeCode,f=a?Ti:u.shaderDefine,_=e+(s?s.cacheKey:"")+`/${a?Mi:u.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(c?"/terrain":"")+(l?`/${l.join("/")}`:"");return this.cache[_]||(this.cache[_]=new Si(this.context,_i[e],s,hn[e],this._showOverdrawInspector,c,p,f,l)),this.cache[_]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:s}=this.context.gl;return this.width!==e||this.height!==s}}function Xn(s,a){let l,c=!1,u=null,p=null;const f=()=>{u=null,c&&(s.apply(p,l),u=setTimeout(f,a),c=!1)};return(...s)=>(c=!0,p=this||e,l=s,u||f(),u)}class Er{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let s;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(s=e)})),(s&&s[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const s=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:s,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const s=e.join("/");let a=s;a.split("&").length>0&&(a=a.split("&")[0]),this._hashName&&(a=`${this._hashName}=${s}`);let l=window.location.hash.replace(a,"");l.startsWith("#&")?l=l.slice(0,1)+l.slice(2):"#"===l&&(l="");let c=window.location.href.replace(/(#.+)?$/,l);c=c.replace("&&","&"),window.history.replaceState(window.history.state,null,c)},this._updateHash=Xn(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const s=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,l=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,l),u=Math.round(s.lng*c)/c,p=Math.round(s.lat*c)/c,f=this._map.getBearing(),_=this._map.getPitch();let g="";if(g+=e?`/${u}/${p}/${a}`:`${a}/${p}/${u}`,(f||_)&&(g+="/"+Math.round(10*f)/10),_&&(g+=`/${Math.round(_)}`),this._hashName){const e=this._hashName;let s=!1;const a=window.location.hash.slice(1).split("&").map((a=>{const l=a.split("=")[0];return l===e?(s=!0,`${l}=${g}`):a})).filter((e=>e));return s||a.push(`${e}=${g}`),`#${a.join("&")}`}return`#${g}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new a.S(+e[2],+e[1])}catch(e){return!1}const s=+e[0],l=+(e[3]||0),c=+(e[4]||0);return s>=this._map.getMinZoom()&&s<=this._map.getMaxZoom()&&l>=-180&&l<=180&&c>=this._map.getMinPitch()&&c<=this._map.getMaxPitch()}}const Hn={linearity:.3,easing:a.cm(0,0,.3,1)},Yn=a.e({deceleration:2500,maxSpeed:1400},Hn),Kn=a.e({deceleration:20,maxSpeed:1400},Hn),Jn=a.e({deceleration:1e3,maxSpeed:360},Hn),Qn=a.e({deceleration:1e3,maxSpeed:90},Hn),ts=a.e({deceleration:1e3,maxSpeed:360},Hn);class Fr{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:f.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,s=f.now();for(;e.length>0&&s-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const s={zoom:0,bearing:0,pitch:0,roll:0,pan:new a.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)s.zoom+=e.zoomDelta||0,s.bearing+=e.bearingDelta||0,s.pitch+=e.pitchDelta||0,s.roll+=e.rollDelta||0,e.panDelta&&s.pan._add(e.panDelta),e.around&&(s.around=e.around),e.pinchAround&&(s.pinchAround=e.pinchAround);const l=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(s.pan.mag()){const u=rs(s.pan.mag(),l,a.e({},Yn,e||{})),p=s.pan.mult(u.amount/s.pan.mag()),f=this._map.cameraHelper.handlePanInertia(p,this._map.transform);c.center=f.easingCenter,c.offset=f.easingOffset,es(c,u)}if(s.zoom){const e=rs(s.zoom,l,Kn);c.zoom=this._map.transform.zoom+e.amount,es(c,e)}if(s.bearing){const e=rs(s.bearing,l,Jn);c.bearing=this._map.transform.bearing+a.ah(e.amount,-179,179),es(c,e)}if(s.pitch){const e=rs(s.pitch,l,Qn);c.pitch=this._map.transform.pitch+e.amount,es(c,e)}if(s.roll){const e=rs(s.roll,l,ts);c.roll=this._map.transform.roll+a.ah(e.amount,-179,179),es(c,e)}if(c.zoom||c.bearing){const e=void 0===s.pinchAround?s.around:s.pinchAround;c.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),a.e(c,{noMoveStart:!0})}}function es(e,s){(!e.duration||e.durations.unproject(e))),f=u.reduce(((e,s,a,l)=>e.add(s.div(l.length))),new a.P(0,0));super(e,{points:u,point:f,lngLats:p,lngLat:s.unproject(f),originalEvent:l}),this._defaultPrevented=!1}}class Ur extends a.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,s,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class Zr{constructor(e,s){this._map=e,this._clickTolerance=s.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Ur(e.type,this._map,e))}mousedown(e,s){return this._mousedownPos=s,this._firePreventable(new jr(e.type,this._map,e))}mouseup(e){this._map.fire(new jr(e.type,this._map,e))}click(e,s){this._mousedownPos&&this._mousedownPos.dist(s)>=this._clickTolerance||this._map.fire(new jr(e.type,this._map,e))}dblclick(e){return this._firePreventable(new jr(e.type,this._map,e))}mouseover(e){this._map.fire(new jr(e.type,this._map,e))}mouseout(e){this._map.fire(new jr(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Nr(e.type,this._map,e))}touchmove(e){this._map.fire(new Nr(e.type,this._map,e))}touchend(e){this._map.fire(new Nr(e.type,this._map,e))}touchcancel(e){this._map.fire(new Nr(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Gr{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new jr(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new jr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new jr(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Vr{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(a.P.convert(e),this._map.terrain)}}class $r{constructor(e,s){this._map=e,this._tr=new Vr(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=s.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,s){this.isEnabled()&&e.shiftKey&&0===e.button&&(n.disableDrag(),this._startPos=this._lastPos=s,this._active=!0)}mousemoveWindow(e,s){if(!this._active)return;const a=s;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)e.fitScreenCoordinates(l,c,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&&(n.remove(this._box),this._box=null),n.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,s){return this._map.fire(new a.l(e,{originalEvent:s}))}}function ns(e,s){if(e.length!==s.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${s.length}`);const a={};for(let l=0;lthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),l.length===this.numTouches&&(this.centroid=function(e){const s=new a.P(0,0);for(const a of e)s._add(a);return s.div(e.length)}(s),this.touches=ns(l,s)))}touchmove(e,s,a){if(this.aborted||!this.centroid)return;const l=ns(a,s);for(const e in this.touches){const s=l[e];(!s||s.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,s,a){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===a.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Hr{constructor(e){this.singleTap=new Wr(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,s,a){this.singleTap.touchstart(e,s,a)}touchmove(e,s,a){this.singleTap.touchmove(e,s,a)}touchend(e,s,a){const l=this.singleTap.touchend(e,s,a);if(l){const s=e.timeStamp-this.lastTime<500,a=!this.lastTap||this.lastTap.dist(l)<30;if(s&&a||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=l,this.count===this.numTaps)return this.reset(),l}}}class Xr{constructor(e){this._tr=new Vr(e),this._zoomIn=new Hr({numTouches:1,numTaps:2}),this._zoomOut=new Hr({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,s,a){this._zoomIn.touchstart(e,s,a),this._zoomOut.touchstart(e,s,a)}touchmove(e,s,a){this._zoomIn.touchmove(e,s,a),this._zoomOut.touchmove(e,s,a)}touchend(e,s,a){const l=this._zoomIn.touchend(e,s,a),c=this._zoomOut.touchend(e,s,a),u=this._tr;return l?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:u.zoom+1,around:u.unproject(l)},{originalEvent:e})}):c?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:u.zoom-1,around:u.unproject(c)},{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 Kr{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const s=this._moveFunction(...e);if(s.bearingDelta||s.pitchDelta||s.rollDelta||s.around||s.panDelta)return this._active=!0,s}dragStart(e,s){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(s)?s[0]:s,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,s){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const l=Array.isArray(s)?s[0]:s;return!this._moved&&l.dist(a)!0}),s=new ta){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=s}_executeRelevantHandler(e,s,a){return e instanceof MouseEvent?s(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?a(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 ls=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class ra{constructor(e,s){this._clickTolerance=e.clickTolerance||1,this._map=s,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new a.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,s,a){return this._calculateTransform(e,s,a)}touchmove(e,s,a){if(this._active){if(!this._shouldBePrevented(a.length))return e.preventDefault(),this._calculateTransform(e,s,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,s,a){this._calculateTransform(e,s,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,s,l){l.length>0&&(this._active=!0);const c=ns(l,s),u=new a.P(0,0),p=new a.P(0,0);let f=0;for(const e in c){const s=c[e],a=this._touches[e];a&&(u._add(s),p._add(s.sub(a)),f++,c[e]=s)}if(this._touches=c,this._shouldBePrevented(f)||!p.mag())return;const _=p.div(f);return this._sum._add(_),this._sum.mag()Math.abs(e.x)}class da extends aa{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,s,a){super.touchstart(e,s,a),this._currentTouchCount=a.length}_start(e){this._lastPoints=e,ds(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,s,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const l=e[0].sub(this._lastPoints[0]),c=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(l,c,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(l.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(e,s,a){if(void 0!==this._valid)return this._valid;const l=e.mag()>=2,c=s.mag()>=2;if(!l&&!c)return;if(!l||!c)return void 0===this._firstMove&&(this._firstMove=a),a-this._firstMove<100&&void 0;const u=e.y>0==s.y>0;return ds(e)&&ds(s)&&u}}const fs={panStep:100,bearingStep:15,pitchStep:10};class pa{constructor(e){this._tr=new Vr(e);const s=fs;this._panStep=s.panStep,this._bearingStep=s.bearingStep,this._pitchStep=s.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let s=0,a=0,l=0,c=0,u=0;switch(e.keyCode){case 61:case 107:case 171:case 187:s=1;break;case 189:case 109:case 173:s=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),c=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),c=1);break;case 38:e.shiftKey?l=1:(e.preventDefault(),u=-1);break;case 40:e.shiftKey?l=-1:(e.preventDefault(),u=1);break;default:return}return this._rotationDisabled&&(a=0,l=0),{cameraAnimation:p=>{const f=this._tr;p.easeTo({duration:300,easeId:"keyboardHandler",easing:ms,zoom:s?Math.round(f.zoom)+s*(e.shiftKey?2:1):f.zoom,bearing:f.bearing+a*this._bearingStep,pitch:f.pitch+l*this._pitchStep,offset:[-c*this._panStep,-u*this._panStep],center:f.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 ms(e){return e*(2-e)}const _s=4.000244140625,gs=1/450;class va{constructor(e,s){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new Vr(e),this._triggerRenderFrame=s,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=gs}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let s=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const a=f.now(),l=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,0!==s&&s%_s==0?this._type="wheel":0!==s&&Math.abs(s)<4?this._type="trackpad":l>400?(this._type=null,this._lastValue=s,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(l*s)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,s+=this._lastValue)),e.shiftKey&&s&&(s/=4),this._type&&(this._lastWheelEvent=e,this._delta-=s,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const s=n.mousePos(this._map.getCanvas(),e),l=this._tr;this._aroundPoint=this._aroundCenter?l.transform.locationToScreenPoint(a.S.convert(l.center)):s,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const s=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=s),"number"==typeof this._targetZoom&&(this._targetZoom+=s)}if(0!==this._delta){const s="wheel"===this._type&&Math.abs(this._delta)>_s?this._wheelZoomRate:this._defaultZoomRate;let l=2/(1+Math.exp(-Math.abs(this._delta*s)));this._delta<0&&0!==l&&(l=1/l);const c="number"!=typeof this._targetZoom?e.scale:a.af(this._targetZoom);this._targetZoom=e.getConstrained(e.getCameraLngLat(),a.ak(c*l)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const s="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,l=this._startZoom,c=this._easing;let u,p=!1;if("wheel"===this._type&&l&&c){const e=f.now()-this._lastWheelEventTime,_=Math.min((e+5)/200,1),g=c(_);u=a.C.number(l,s,g),_<1?this._frameId||(this._frameId=!0):p=!0}else u=s,p=!0;return this._active=!0,p&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=u,{noInertia:!0,needsRenderFrame:!p,zoomDelta:u-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let s=a.co;if(this._prevEase){const e=this._prevEase,l=(f.now()-e.start)/e.duration,c=e.easing(l+.01)-e.easing(l),u=.27/Math.sqrt(c*c+1e-4)*.01,p=Math.sqrt(.0729-u*u);s=a.cm(u,p,.25,1)}return this._prevEase={start:f.now(),duration:e,easing:s},s}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class ba{constructor(e,s){this._clickZoom=e,this._tapZoom=s}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class xa{constructor(e){this._tr=new Vr(e),this.reset()}reset(){this._active=!1}dblclick(e,s){return e.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(s)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ya{constructor(){this._tap=new Hr({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,s,a){if(!this._swipePoint)if(this._tapTime){const l=s[0],c=e.timeStamp-this._tapTime<500,u=this._tapPoint.dist(l)<30;c&&u?a.length>0&&(this._swipePoint=l,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(e,s,a)}touchmove(e,s,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const l=s[0],c=l.y-this._swipePoint.y;return this._swipePoint=l,e.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(e,s,a)}touchend(e,s,a){if(this._tapTime)this._swipePoint&&0===a.length&&this.reset();else{const l=this._tap.touchend(e,s,a);l&&(this._tapTime=e.timeStamp,this._tapPoint=l)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class wa{constructor(e,s,a){this._el=e,this._mousePan=s,this._touchPan=a}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 Ta{constructor(e,s,a,l){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=s,this._mousePitch=a,this._mouseRoll=l}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 Pa{constructor(e,s,a,l){this._el=e,this._touchZoom=s,this._touchRotate=a,this._tapDragZoom=l,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 Ca{constructor(e,s){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=s,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=n.create("div","maplibregl-cooperative-gesture-screen",e);let s=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(s=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),l=document.createElement("div");l.className="maplibregl-desktop-message",l.textContent=s,this._container.appendChild(l);const c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=a,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(n.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,s){this._enabled&&(this._map.fire(new a.l("cooperativegestureprevented",{gestureType:e,originalEvent:s})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const ys=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Ma extends a.l{}function xs(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Ea{constructor(e,s){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,s)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const l="renderFrame"===e.type?void 0:e,c={needsRenderFrame:!1},u={},p={};for(const{handlerName:f,handler:_,allowed:g}of this._handlers){if(!_.isEnabled())continue;let y;if(this._blockedByActive(p,g,f))_.reset();else if(_[s||e.type]){if(a.cp(e,s||e.type)){const a=n.mousePos(this._map.getCanvas(),e);y=_[s||e.type](e,a)}else if(a.cq(e,s||e.type)){const a=this._getMapTouches(e.touches),l=n.touchPos(this._map.getCanvas(),a);y=_[s||e.type](e,l,a)}else a.cr(s||e.type)||(y=_[s||e.type](e));this.mergeHandlerResult(c,u,y,f,l),y&&y.needsRenderFrame&&this._triggerRenderFrame()}(y||_.isActive())&&(p[f]=_)}const f={};for(const e in this._previousActiveHandlers)p[e]||(f[e]=l);this._previousActiveHandlers=p,(Object.keys(f).length||xs(c))&&(this._changes.push([c,u,f]),this._triggerRenderFrame()),(Object.keys(p).length||xs(c))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:_}=c;_&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],_(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Fr(e),this._bearingSnap=s.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(s);const l=this._el;this._listeners=[[l,"touchstart",{passive:!0}],[l,"touchmove",{passive:!1}],[l,"touchend",void 0],[l,"touchcancel",void 0],[l,"mousedown",void 0],[l,"mousemove",void 0],[l,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[l,"mouseover",void 0],[l,"mouseout",void 0],[l,"dblclick",void 0],[l,"click",void 0],[l,"keydown",{capture:!1}],[l,"keyup",void 0],[l,"wheel",{passive:!1}],[l,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,s,a]of this._listeners)n.addEventListener(e,s,e===document?this.handleWindowEvent:this.handleEvent,a)}destroy(){for(const[e,s,a]of this._listeners)n.removeEventListener(e,s,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){const s=this._map,l=s.getCanvasContainer();this._add("mapEvent",new Zr(s,e));const c=s.boxZoom=new $r(s,e);this._add("boxZoom",c),e.interactive&&e.boxZoom&&c.enable();const u=s.cooperativeGestures=new Ca(s,e.cooperativeGestures);this._add("cooperativeGestures",u),e.cooperativeGestures&&u.enable();const p=new Xr(s),f=new xa(s);s.doubleClickZoom=new ba(f,p),this._add("tapZoom",p),this._add("clickZoom",f),e.interactive&&e.doubleClickZoom&&s.doubleClickZoom.enable();const _=new ya;this._add("tapDragZoom",_);const g=s.touchPitch=new da(s);this._add("touchPitch",g),e.interactive&&e.touchPitch&&s.touchPitch.enable(e.touchPitch);const y=()=>s.project(s.getCenter()),x=function({enable:e,clickTolerance:s,aroundCenter:l=!0,minPixelCenterThreshold:c=100,rotateDegreesPerPixelMoved:u=.8},p){const f=new ea({checkCorrectEvent:e=>0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)&&!e.ctrlKey});return new Kr({clickTolerance:s,move:(e,s)=>{const f=p();if(l&&Math.abs(f.y-e.y)>c)return{bearingDelta:a.cn(new a.P(e.x,s.y),s,f)};let _=(s.x-e.x)*u;return l&&s.y0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)});return new Kr({clickTolerance:s,move:(e,s)=>({pitchDelta:(s.y-e.y)*a}),moveStateManager:l,enable:e,assignEvents:ls})}(e),w=function({enable:e,clickTolerance:s,rollDegreesPerPixelMoved:a=.3},l){const c=new ea({checkCorrectEvent:e=>2===n.mouseButton(e)&&e.ctrlKey});return new Kr({clickTolerance:s,move:(e,s)=>{const c=l();let u=(s.x-e.x)*a;return s.y0===n.mouseButton(e)&&!e.ctrlKey});return new Kr({clickTolerance:s,move:(e,s)=>({around:s,panDelta:s.sub(e)}),activateOnStart:!0,moveStateManager:a,enable:e,assignEvents:ls})}(e),A=new ra(e,s);s.dragPan=new wa(l,C,A),this._add("mousePan",C),this._add("touchPan",A,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&s.dragPan.enable(e.dragPan);const k=new ha,D=new la;s.touchZoomRotate=new Pa(l,D,k,_),this._add("touchRotate",k,["touchPan","touchZoom"]),this._add("touchZoom",D,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&s.touchZoomRotate.enable(e.touchZoomRotate);const R=s.scrollZoom=new va(s,(()=>this._triggerRenderFrame()));this._add("scrollZoom",R,["mousePan"]),e.interactive&&e.scrollZoom&&s.scrollZoom.enable(e.scrollZoom);const L=s.keyboard=new pa(s);this._add("keyboard",L),e.interactive&&e.keyboard&&s.keyboard.enable(),this._add("blockableMapEvent",new Gr(s))}_add(e,s,a){this._handlers.push({handlerName:e,handler:s,allowed:a}),this._handlersById[e]=s}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(ys(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,s,a){for(const l in e)if(l!==a&&(!s||s.indexOf(l)<0))return!0;return!1}_getMapTouches(e){const s=[];for(const a of e)this._el.contains(a.target)&&s.push(a);return s}mergeHandlerResult(e,s,l,c,u){if(!l)return;a.e(e,l);const p={handlerName:c,originalEvent:l.originalEvent||u};void 0!==l.zoomDelta&&(s.zoom=p),void 0!==l.panDelta&&(s.drag=p),void 0!==l.rollDelta&&(s.roll=p),void 0!==l.pitchDelta&&(s.pitch=p),void 0!==l.bearingDelta&&(s.rotate=p)}_applyChanges(){const e={},s={},l={};for(const[c,u,p]of this._changes)c.panDelta&&(e.panDelta=(e.panDelta||new a.P(0,0))._add(c.panDelta)),c.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+c.zoomDelta),c.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+c.bearingDelta),c.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+c.pitchDelta),c.rollDelta&&(e.rollDelta=(e.rollDelta||0)+c.rollDelta),void 0!==c.around&&(e.around=c.around),void 0!==c.pinchAround&&(e.pinchAround=c.pinchAround),c.noInertia&&(e.noInertia=c.noInertia),a.e(s,u),a.e(l,p);this._updateMapTransform(e,s,l),this._changes=[]}_updateMapTransform(e,s,a){const l=this._map,c=l._getTransformForUpdate(),u=l.terrain;if(!(xs(e)||u&&this._terrainMovement))return this._fireEvents(s,a,!0);l._stop(!0);let{panDelta:p,zoomDelta:f,bearingDelta:_,pitchDelta:g,rollDelta:y,around:x,pinchAround:v}=e;void 0!==v&&(x=v),x=x||l.transform.centerPoint,u&&!c.isPointOnMapSurface(x)&&(x=c.centerPoint);const w={panDelta:p,zoomDelta:f,rollDelta:y,pitchDelta:g,bearingDelta:_,around:x};this._map.cameraHelper.useGlobeControls&&!c.isPointOnMapSurface(x)&&(x=c.centerPoint);const C=x.distSqr(c.centerPoint)<.01?c.center:c.screenPointToLocation(p?x.sub(p):x);u?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(w,c),this._terrainMovement||!s.drag&&!s.zoom?s.drag&&this._terrainMovement?c.setCenter(c.screenPointToLocation(c.centerPoint.sub(p))):this._map.cameraHelper.handleMapControlsPan(w,c,C):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(w,c,C))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(w,c),this._map.cameraHelper.handleMapControlsPan(w,c,C)),l._applyUpdatedTransform(c),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(s,a,!0)}_fireEvents(e,s,l){const c=ys(this._eventsInProgress),u=ys(e),p={};for(const s in e){const{originalEvent:a}=e[s];this._eventsInProgress[s]||(p[`${s}start`]=a),this._eventsInProgress[s]=e[s]}!c&&u&&this._fireEvent("movestart",u.originalEvent);for(const e in p)this._fireEvent(e,p[e]);u&&this._fireEvent("move",u.originalEvent);for(const s in e){const{originalEvent:a}=e[s];this._fireEvent(s,a)}const _={};let g;for(const e in this._eventsInProgress){const{handlerName:a,originalEvent:l}=this._eventsInProgress[e];this._handlersById[a].isActive()||(delete this._eventsInProgress[e],g=s[a]||l,_[`${e}end`]=g)}for(const e in _)this._fireEvent(e,_[e]);const y=ys(this._eventsInProgress),x=(c||u)&&!y;if(x&&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(l&&x){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),s=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Ma("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Ra extends a.E{constructor(e,s,a){super(),this._renderFrameCallback=()=>{const e=Math.min((f.now()-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=a.bearingSnap,this.cameraHelper=s,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(e,s){e.apply(this.transform),this.transform=e,this.cameraHelper=s}getCenter(){return new a.S(this.transform.center.lng,this.transform.center.lat)}setCenter(e,s){return this.jumpTo({center:e},s)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,s){return this.jumpTo({elevation:e},s),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,s,l){return e=a.P.convert(e).mult(-1),this.panTo(this.transform.center,a.e({offset:e},s),l)}panTo(e,s,l){return this.easeTo(a.e({center:e},s),l)}getZoom(){return this.transform.zoom}setZoom(e,s){return this.jumpTo({zoom:e},s),this}zoomTo(e,s,l){return this.easeTo(a.e({zoom:e},s),l)}zoomIn(e,s){return this.zoomTo(this.getZoom()+1,e,s),this}zoomOut(e,s){return this.zoomTo(this.getZoom()-1,e,s),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,s){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new a.l("movestart",s)).fire(new a.l("move",s)).fire(new a.l("moveend",s))),this}getBearing(){return this.transform.bearing}setBearing(e,s){return this.jumpTo({bearing:e},s),this}getPadding(){return this.transform.padding}setPadding(e,s){return this.jumpTo({padding:e},s),this}rotateTo(e,s,l){return this.easeTo(a.e({bearing:e},s),l)}resetNorth(e,s){return this.rotateTo(0,a.e({duration:1e3},e),s),this}resetNorthPitch(e,s){return this.easeTo(a.e({bearing:0,pitch:0,roll:0,duration:1e3},e),s),this}snapToNorth(e,s){return Math.abs(this.getBearing()){k.easeFunc(a),this.terrain&&!e.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(l),this._fireMoveEvents(s)}),(a=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(s,a)}),e),this}_prepareEase(e,s,l={}){this._moving=!0,s||l.moving||this.fire(new a.l("movestart",e)),this._zooming&&!l.zooming&&this.fire(new a.l("zoomstart",e)),this._rotating&&!l.rotating&&this.fire(new a.l("rotatestart",e)),this._pitching&&!l.pitching&&this.fire(new a.l("pitchstart",e)),this._rolling&&!l.rolling&&this.fire(new a.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){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const s=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&s!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(a-(s-(a*e+this._elevationStart))/(1-e)),this._elevationTarget=s}this.transform.setElevation(a.C.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const s=e.getCameraLngLat(),a=e.getCameraAltitude(),l=this.terrain?this.terrain.getElevationForLngLatZoom(s,e.zoom):0;if(athis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&s.push((e=>this.transformCameraUpdate(e))),!s.length)return;const a=e.clone();for(const e of s){const s=a.clone(),{center:l,zoom:c,roll:u,pitch:p,bearing:f,elevation:_}=e(s);l&&s.setCenter(l),void 0!==_&&s.setElevation(_),void 0!==c&&s.setZoom(c),void 0!==u&&s.setRoll(u),void 0!==p&&s.setPitch(p),void 0!==f&&s.setBearing(f),a.apply(s)}this.transform.apply(a)}_fireMoveEvents(e){this.fire(new a.l("move",e)),this._zooming&&this.fire(new a.l("zoom",e)),this._rotating&&this.fire(new a.l("rotate",e)),this._pitching&&this.fire(new a.l("pitch",e)),this._rolling&&this.fire(new a.l("roll",e))}_afterEase(e,s){if(this._easeId&&s&&this._easeId===s)return;delete this._easeId;const l=this._zooming,c=this._rotating,u=this._pitching,p=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,l&&this.fire(new a.l("zoomend",e)),c&&this.fire(new a.l("rotateend",e)),u&&this.fire(new a.l("pitchend",e)),p&&this.fire(new a.l("rollend",e)),this.fire(new a.l("moveend",e))}flyTo(e,s){if(!e.essential&&f.prefersReducedMotion){const l=a.Q(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(l,s)}this.stop(),e=a.e({offset:[0,0],speed:1.2,curve:1.42,easing:a.co},e);const l=this._getTransformForUpdate(),c=l.bearing,u=l.pitch,p=l.roll,_=l.padding,g="bearing"in e?this._normalizeBearing(e.bearing,c):c,y="pitch"in e?+e.pitch:u,x="roll"in e?this._normalizeBearing(e.roll,p):p,v="padding"in e?e.padding:l.padding,w=a.P.convert(e.offset);let C=l.centerPoint.add(w);const A=l.screenPointToLocation(C),k=this.cameraHelper.handleFlyTo(l,{bearing:g,pitch:y,roll:x,padding:v,locationAtOffset:A,offsetAsPoint:w,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let D=e.curve;const R=Math.max(l.width,l.height),L=R/k.scaleOfZoom,B=k.pixelPathLength;"number"==typeof k.scaleOfMinZoom&&(D=Math.sqrt(R/k.scaleOfMinZoom/B*2));const O=D*D;function j(e){const s=(L*L-R*R+(e?-1:1)*O*O*B*B)/(2*(e?L:R)*O*B);return Math.log(Math.sqrt(s*s+1)-s)}function U(e){return(Math.exp(e)-Math.exp(-e))/2}function N(e){return(Math.exp(e)+Math.exp(-e))/2}const Z=j(!1);let J=function(e){return N(Z)/N(Z+D*e)},Q=function(e){return R*((N(Z)*(U(s=Z+D*e)/N(s))-U(Z))/O)/B;var s},et=(j(!0)-Z)/D;if(Math.abs(B)<2e-6||!isFinite(et)){if(Math.abs(R-L)<1e-6)return this.easeTo(e,s);const a=L0,J=e=>Math.exp(a*D*e)}return e.duration="duration"in e?+e.duration:1e3*et/("screenSpeed"in e?+e.screenSpeed/D:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=c!==g,this._pitching=y!==u,this._rolling=x!==p,this._padding=!l.isPaddingEqual(v),this._prepareEase(s,!1),this.terrain&&this._prepareElevation(k.targetCenter),this._ease((f=>{const A=f*et,D=1/J(A),R=Q(A);this._rotating&&l.setBearing(a.C.number(c,g,f)),this._pitching&&l.setPitch(a.C.number(u,y,f)),this._rolling&&l.setRoll(a.C.number(p,x,f)),this._padding&&(l.interpolatePadding(_,v,f),C=l.centerPoint.add(w)),k.easeFunc(f,D,R,C),this.terrain&&!e.freezeElevation&&this._updateElevation(f),this._applyUpdatedTransform(l),this._fireMoveEvents(s)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(s)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,s){var a;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,s)}return e||null===(a=this.handlers)||void 0===a||a.stop(!1),this}_ease(e,s,a){!1===a.animate||0===a.duration?(e(1),s()):(this._easeStart=f.now(),this._easeOptions=a,this._onEaseFrame=e,this._onEaseEnd=s,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,s){e=a.aO(e,-180,180);const l=Math.abs(e-s);return Math.abs(e-360-s)MapLibre'};class Da{constructor(e=vs){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=n.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=n.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.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(){n.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,s){const a=this._map._getUIString(`AttributionControl.${s}`);e.title=a,e.setAttribute("aria-label",a)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const s=this._map.style.sourceCaches;for(const a in s){const l=s[a];if(l.used||l.usedForTerrain){const s=l.getSource();s.attribution&&e.indexOf(s.attribution)<0&&e.push(s.attribution)}}e=e.filter((e=>String(e).trim())),e.sort(((e,s)=>e.length-s.length)),e=e.filter(((s,a)=>{for(let l=a+1;l=0)return!1;return!0}));const a=e.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,e.length?(this._innerContainer.innerHTML=n.sanitize(a),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Aa{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const s=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&s.classList.add("maplibregl-compact"):s.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=n.create("div","maplibregl-ctrl");const s=n.create("a","maplibregl-ctrl-logo");return s.target="_blank",s.rel="noopener nofollow",s.href="https://maplibre.org/",s.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),s.setAttribute("rel","noopener nofollow"),this._container.appendChild(s),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){n.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class La{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const s=++this._id;return this._queue.push({callback:e,id:s,cancelled:!1}),s}remove(e){const s=this._currentlyRunning,a=s?this._queue.concat(s):this._queue;for(const s of a)if(s.id===e)return void(s.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const s=this._currentlyRunning=this._queue;this._queue=[];for(const a of s)if(!a.cancelled&&(a.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var bs=a.aJ([{name:"a_pos3d",type:"Int16",components:3}]);class Fa extends a.E{constructor(e){super(),this._lastTilesetChange=f.now(),this.sourceCache=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.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,s){this.sourceCache.update(e,s),this._renderableTilesKeys=[];const l={};for(const c of qt(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:s,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))l[c.key]=!0,this._renderableTilesKeys.push(c.key),this._tiles[c.key]||(c.terrainRttPosMatrix32f=new Float64Array(16),a.bY(c.terrainRttPosMatrix32f,0,a.$,a.$,0,0,1),this._tiles[c.key]=new re(c,this.tileSize),this._lastTilesetChange=f.now());for(const e in this._tiles)l[e]||delete this._tiles[e]}freeRtt(e){for(const s in this._tiles){const a=this._tiles[s];(!e||a.tileID.equals(e)||a.tileID.isChildOf(e)||e.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,s){return s?this._getTerrainCoordsForTileRanges(e,s):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const s={};for(const l of this._renderableTilesKeys){const c=this._tiles[l].tileID,u=e.clone(),p=a.ba();if(c.canonical.equals(e.canonical))a.bY(p,0,a.$,a.$,0,0,1);else if(c.canonical.isChildOf(e.canonical)){const s=c.canonical.z-e.canonical.z,l=c.canonical.x-(c.canonical.x>>s<>s<>s;a.bY(p,0,f,f,0,0,1),a.M(p,p,[-l*f,-u*f,0])}else{if(!e.canonical.isChildOf(c.canonical))continue;{const s=e.canonical.z-c.canonical.z,l=e.canonical.x-(e.canonical.x>>s<>s<>s;a.bY(p,0,a.$,a.$,0,0,1),a.M(p,p,[l*f,u*f,0]),a.N(p,p,[1/2**s,1/2**s,0])}}u.terrainRttPosMatrix32f=new Float32Array(p),s[l]=u}return s}_getTerrainCoordsForTileRanges(e,s){const l={};for(const c of this._renderableTilesKeys){const u=this._tiles[c].tileID;if(!this._isWithinTileRanges(u,s))continue;const p=e.clone(),f=a.ba();if(u.canonical.z===e.canonical.z){const s=e.canonical.x-u.canonical.x,l=e.canonical.y-u.canonical.y;a.bY(f,0,a.$,a.$,0,0,1),a.M(f,f,[s*a.$,l*a.$,0])}else if(u.canonical.z>e.canonical.z){const s=u.canonical.z-e.canonical.z,l=u.canonical.x-(u.canonical.x>>s<>s<>s),_=e.canonical.y-(u.canonical.y>>s),g=a.$>>s;a.bY(f,0,g,g,0,0,1),a.M(f,f,[-l*g+p*a.$,-c*g+_*a.$,0])}else{const s=e.canonical.z-u.canonical.z,l=e.canonical.x-(e.canonical.x>>s<>s<>s)-u.canonical.x,_=(e.canonical.y>>s)-u.canonical.y,g=a.$<a.maxzoom&&(l=a.maxzoom),l=a.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(e.scaledTo(l--).key);return c}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,s){return s[e.canonical.z]&&e.canonical.x>=s[e.canonical.z].minTileX&&e.canonical.x<=s[e.canonical.z].maxTileX&&e.canonical.y>=s[e.canonical.z].minTileY&&e.canonical.y<=s[e.canonical.z].maxTileY}}class Ba{constructor(e,s,a){this._meshCache={},this.painter=e,this.sourceCache=new Fa(s),this.options=a,this.exaggeration="number"==typeof a.exaggeration?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,s,l,c=a.$){var u;if(!(s>=0&&s=0&&le.canonical.z&&(e.canonical.z>=l?c=e.canonical.z-l:a.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const u=e.canonical.x-(e.canonical.x>>c<>c<>8<<4|e>>8,s[a+3]=0;const l=new a.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(s.buffer)),c=new a.T(e,l,e.gl.RGBA,{premultiply:!1});return c.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=c,c}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const s=new Uint8Array(4),l=this.painter.context,c=l.gl,u=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),p=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),f=Math.round(this.painter.height/devicePixelRatio);l.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),c.readPixels(u,f-p-1,1,1,c.RGBA,c.UNSIGNED_BYTE,s),l.bindFramebuffer.set(null);const _=s[0]+(s[2]>>4<<8),g=s[1]+((15&s[2])<<8),y=this.coordsIndex[255-s[3]],x=y&&this.sourceCache.getTileByID(y);if(!x)return null;const v=this._coordsTextureSize,w=(1<0,c=l&&0===e.canonical.y,u=l&&e.canonical.y===(1<e.id!==s)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse))}}const ws={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class Na{constructor(e,s){this.painter=e,this.terrain=s,this.pool=new Oa(e.context,30,s.sourceCache.tileSize*s.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,s){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((a=>!e._layers[a].isHidden(s))),this._coordsAscending={};for(const s in e.sourceCaches){this._coordsAscending[s]={};const a=e.sourceCaches[s].getVisibleCoordinates(),l=e.sourceCaches[s].getSource(),c=l instanceof X?l.terrainTileRanges:null;for(const e of a){const a=this.terrain.sourceCache.getTerrainCoords(e,c);for(const e in a)this._coordsAscending[s][e]||(this._coordsAscending[s][e]=[]),this._coordsAscending[s][e].push(a[e])}}this._coordsAscendingStr={};for(const s of e._order){const a=e._layers[s],l=a.source;if(ws[a.type]&&!this._coordsAscendingStr[l]){this._coordsAscendingStr[l]={};for(const e in this._coordsAscending[l])this._coordsAscendingStr[l][e]=this._coordsAscending[l][e].map((e=>e.key)).sort().join()}}for(const e of this._renderableTiles)for(const s in this._coordsAscendingStr){const a=this._coordsAscendingStr[s][e.tileID.key];a&&a!==e.rttCoords[s]&&(e.rtt=[])}}renderLayer(e,s){if(e.isHidden(this.painter.transform.zoom))return!1;const l=Object.assign(Object.assign({},s),{isRenderingToTexture:!0}),c=e.type,u=this.painter,p=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(ws[c]&&(this._prevType&&ws[this._prevType]||this._stacks.push([]),this._prevType=c,this._stacks[this._stacks.length-1].push(e.id),!p))return!0;if(ws[this._prevType]||ws[c]&&p){this._prevType=c;const e=this._stacks.length-1,s=this._stacks[e]||[];for(const c of this._renderableTiles){if(this.pool.isFull()&&(qn(this.painter,this.terrain,this._rttTiles,l),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(c),c.rtt[e]){const s=this.pool.getObjectForId(c.rtt[e].id);if(s.stamp===c.rtt[e].stamp){this.pool.useObject(s);continue}}const p=this.pool.getOrCreateFreeObject();this.pool.useObject(p),this.pool.stampObject(p),c.rtt[e]={id:p.id,stamp:p.stamp},u.context.bindFramebuffer.set(p.fbo.framebuffer),u.context.clear({color:a.bf.transparent,stencil:0}),u.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,n.mousePos(this.element,e)),n.addEventListener(window,"mousemove",this.mousemove),n.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,n.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=n.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),n.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=s;const c=new ia;this._rotatePitchHandler=new Kr({clickTolerance:3,move:(e,c)=>{const u=s.getBoundingClientRect(),p=new a.P((u.bottom-u.top)/2,(u.right-u.left)/2);return{bearingDelta:a.cn(new a.P(e.x,c.y),c,p),pitchDelta:l?-.5*(c.y-e.y):void 0}},moveStateManager:c,enable:!0,assignEvents:()=>{}}),this.map=e,n.addEventListener(s,"mousedown",this.mousedown),n.addEventListener(s,"touchstart",this.touchstart,{passive:!1}),n.addEventListener(s,"touchcancel",this.reset)}startMove(e,s){this._rotatePitchHandler.dragStart(e,s),n.disableDrag()}move(e,s){const a=this.map,{bearingDelta:l,pitchDelta:c}=this._rotatePitchHandler.dragMove(e,s)||{};l&&a.setBearing(a.getBearing()+l),c&&a.setPitch(a.getPitch()+c)}off(){const e=this.element;n.removeEventListener(e,"mousedown",this.mousedown),n.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend),n.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){n.enableDrag(),n.removeEventListener(window,"mousemove",this.mousemove),n.removeEventListener(window,"mouseup",this.mouseup),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend)}}let js;function Zs(e,s,l,c=!1){if(c||!l.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const u=new a.S(e.lng,e.lat);if(e=new a.S(e.lng,e.lat),s){const c=new a.S(e.lng-360,e.lat),u=new a.S(e.lng+360,e.lat),p=l.locationToScreenPoint(e).distSqr(s);l.locationToScreenPoint(c).distSqr(s)180;){const s=l.locationToScreenPoint(e);if(s.x>=0&&s.y>=0&&s.x<=l.width&&s.y<=l.height)break;e.lng>l.center.lng?e.lng-=360:e.lng+=360}return e.lng!==u.lng&&l.isPointOnMapSurface(l.locationToScreenPoint(e))?e:u}const qs={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 Ys(e,s,a){const l=e.classList;for(const e in qs)l.remove(`maplibregl-${a}-anchor-${e}`);l.add(`maplibregl-${a}-anchor-${s}`)}class Ka extends a.E{constructor(e){if(super(),this._onKeyPress=e=>{const s=e.code,a=e.charCode||e.keyCode;"Space"!==s&&"Enter"!==s&&32!==a&&13!==a||this.togglePopup()},this._onMapClick=e=>{const s=e.originalEvent.target,a=this._element;this._popup&&(s===a||a.contains(s))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const s=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!s)&&this._map.once("render",this._update),this._lngLat=Zs(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 a="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?a=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(a=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let l="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?l="rotateX(0deg)":"map"===this._pitchAlignment&&(l=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),n.setTransform(this._element,`${qs[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${l} ${a}`),f.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){const s=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=s}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new a.l("dragstart"))),this.fire(new a.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 a.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=a.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=n.create("div");const s=n.createNS("http://www.w3.org/2000/svg","svg"),l=41,c=27;s.setAttributeNS(null,"display","block"),s.setAttributeNS(null,"height",`${l}px`),s.setAttributeNS(null,"width",`${c}px`),s.setAttributeNS(null,"viewBox",`0 0 ${c} ${l}`);const u=n.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"stroke","none"),u.setAttributeNS(null,"stroke-width","1"),u.setAttributeNS(null,"fill","none"),u.setAttributeNS(null,"fill-rule","evenodd");const p=n.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"fill-rule","nonzero");const f=n.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(3.0, 29.0)"),f.setAttributeNS(null,"fill","#000000");const _=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of _){const s=n.createNS("http://www.w3.org/2000/svg","ellipse");s.setAttributeNS(null,"opacity","0.04"),s.setAttributeNS(null,"cx","10.5"),s.setAttributeNS(null,"cy","5.80029008"),s.setAttributeNS(null,"rx",e.rx),s.setAttributeNS(null,"ry",e.ry),f.appendChild(s)}const g=n.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill",this._color);const y=n.createNS("http://www.w3.org/2000/svg","path");y.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),g.appendChild(y);const x=n.createNS("http://www.w3.org/2000/svg","g");x.setAttributeNS(null,"opacity","0.25"),x.setAttributeNS(null,"fill","#000000");const v=n.createNS("http://www.w3.org/2000/svg","path");v.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"),x.appendChild(v);const w=n.createNS("http://www.w3.org/2000/svg","g");w.setAttributeNS(null,"transform","translate(6.0, 7.0)"),w.setAttributeNS(null,"fill","#FFFFFF");const C=n.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"transform","translate(8.0, 8.0)");const A=n.createNS("http://www.w3.org/2000/svg","circle");A.setAttributeNS(null,"fill","#000000"),A.setAttributeNS(null,"opacity","0.25"),A.setAttributeNS(null,"cx","5.5"),A.setAttributeNS(null,"cy","5.5"),A.setAttributeNS(null,"r","5.4999962");const k=n.createNS("http://www.w3.org/2000/svg","circle");k.setAttributeNS(null,"fill","#FFFFFF"),k.setAttributeNS(null,"cx","5.5"),k.setAttributeNS(null,"cy","5.5"),k.setAttributeNS(null,"r","5.4999962"),C.appendChild(A),C.appendChild(k),p.appendChild(f),p.appendChild(g),p.appendChild(x),p.appendChild(w),p.appendChild(C),s.appendChild(p),s.setAttributeNS(null,"height",l*this._scale+"px"),s.setAttributeNS(null,"width",c*this._scale+"px"),this._element.appendChild(s),this._offset=a.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()})),Ys(this._element,this._anchor,"marker"),e&&e.className)for(const s of e.className.split(" "))this._element.classList.add(s);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),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),n.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=a.S.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const s=38.1,a=13.5,l=Math.abs(a)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-s],"bottom-left":[l,-1*(s-a+l)],"bottom-right":[-l,-1*(s-a+l)],left:[a,-1*(s-a)],right:[-a,-1*(s-a)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var s,l;const c=null===(s=this._map)||void 0===s?void 0:s.terrain,u=this._map.transform.isLocationOccluded(this._lngLat);if(!c||u){const e=u?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 p=this._map,f=p.terrain.depthAtPoint(this._pos),_=p.terrain.getElevationForLngLatZoom(this._lngLat,p.transform.tileZoom);if(p.transform.lngLatToCameraDepth(this._lngLat,_)-f<.006)return void(this._element.style.opacity=this._opacity);const g=-this._offset.y/p.transform.pixelsPerMeter,y=Math.sin(p.getPitch()*Math.PI/180)*g,x=p.terrain.depthAtPoint(new a.P(this._pos.x,this._pos.y-this._offset.y)),v=p.transform.lngLatToCameraDepth(this._lngLat,_+y)-x>.006;(null===(l=this._popup)||void 0===l?void 0:l.isOpen())&&v&&this._popup.remove(),this._element.style.opacity=v?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=a.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,s){return(void 0===this._opacity||void 0===e&&void 0===s)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==s&&(this._opacityWhenCovered=s),this._map&&this._updateOpacity(!0),this}}const to={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let eo=0,io=!1;const ro={maxWidth:100,unit:"metric"};function ao(e,s,a){const l=a&&a.maxWidth||100,c=e._container.clientHeight/2,u=e._container.clientWidth/2,p=e.unproject([u-l/2,c]),f=e.unproject([u+l/2,c]),_=Math.round(e.project(f).x-e.project(p).x),g=Math.min(l,_,e._container.clientWidth),y=p.distanceTo(f);if(a&&"imperial"===a.unit){const a=3.2808*y;a>5280?qo(s,g,a/5280,e._getUIString("ScaleControl.Miles")):qo(s,g,a,e._getUIString("ScaleControl.Feet"))}else a&&"nautical"===a.unit?qo(s,g,y/1852,e._getUIString("ScaleControl.NauticalMiles")):y>=1e3?qo(s,g,y/1e3,e._getUIString("ScaleControl.Kilometers")):qo(s,g,y,e._getUIString("ScaleControl.Meters"))}function qo(e,s,a,l){const c=function(e){const s=Math.pow(10,`${Math.floor(e)}`.length-1);let a=e/s;return a=a>=10?10:a>=5?5:a>=3?3:a>=2?2:a>=1?1:function(e){const s=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*s)/s}(a),s*a}(a);e.style.width=s*(c/a)+"px",e.innerHTML=`${c} ${l}`}const Xo={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},Yo=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ko(e){if(e){if("number"==typeof e){const s=Math.round(Math.abs(e)/Math.SQRT2);return{center:new a.P(0,0),top:new a.P(0,e),"top-left":new a.P(s,s),"top-right":new a.P(-s,s),bottom:new a.P(0,-e),"bottom-left":new a.P(s,-s),"bottom-right":new a.P(-s,-s),left:new a.P(e,0),right:new a.P(-e,0)}}if(e instanceof a.P||Array.isArray(e)){const s=a.P.convert(e);return{center:s,top:s,"top-left":s,"top-right":s,bottom:s,"bottom-left":s,"bottom-right":s,left:s,right:s}}return{center:a.P.convert(e.center||[0,0]),top:a.P.convert(e.top||[0,0]),"top-left":a.P.convert(e["top-left"]||[0,0]),"top-right":a.P.convert(e["top-right"]||[0,0]),bottom:a.P.convert(e.bottom||[0,0]),"bottom-left":a.P.convert(e["bottom-left"]||[0,0]),"bottom-right":a.P.convert(e["bottom-right"]||[0,0]),left:a.P.convert(e.left||[0,0]),right:a.P.convert(e.right||[0,0])}}return Ko(new a.P(0,0))}const Jo=l;s.AJAXError=a.cz,s.Event=a.l,s.Evented=a.E,s.LngLat=a.S,s.MercatorCoordinate=a.a1,s.Point=a.P,s.addProtocol=a.cA,s.config=a.a,s.removeProtocol=a.cB,s.AttributionControl=Da,s.BoxZoomHandler=$r,s.CanvasSource=Y,s.CooperativeGesturesHandler=Ca,s.DoubleClickZoomHandler=ba,s.DragPanHandler=wa,s.DragRotateHandler=Ta,s.EdgeInsets=Mt,s.FullscreenControl=class extends a.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let s=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==s?void 0:s.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)s=s.shadowRoot.fullscreenElement;s===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:a.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=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){n.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);n.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 a.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new a.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},s.GeoJSONSource=H,s.GeolocateControl=class extends a.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new a.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 a.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const s=new a.S(e.coords.longitude,e.coords.latitude),l=e.coords.accuracy,c=this._map.getBearing(),u=a.e({bearing:c},this.options.fitBoundsOptions),p=G.fromLngLat(s,l);this._map.fitBounds(p,u,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const s=new a.S(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(s).addTo(this._map),this._userLocationDotMarker.setLngLat(s).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},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&&io)return;this.options.trackUserLocation&&this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new a.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=n.create("button","maplibregl-ctrl-geolocate",this._container),n.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){a.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=n.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ka({element:this._dotElement}),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ka({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{const s=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||s||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new a.l("trackuserlocationend")),this.fire(new a.l("userlocationlostfocus")))}))}},this.options=a.e({},to,e)}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return a._(this,arguments,void 0,(function*(e=!1){if(void 0!==js&&!e)return js;if(void 0===window.navigator.permissions)return js=!!window.navigator.geolocation,js;try{const e=yield window.navigator.permissions.query({name:"geolocation"});js="denied"!==e.state}catch(e){js=!!window.navigator.geolocation}return js}))}().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(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,eo=0,io=!1}_isOutOfMapMaxBounds(e){const s=this._map.getMaxBounds(),a=e.coords;return s&&(a.longitudes.getEast()||a.latitudes.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const e=this._map.getBounds(),s=e.getSouthEast(),a=e.getNorthEast(),l=s.distanceTo(a),c=Math.ceil(this._accuracy/(l/this._map._container.clientHeight)*2);this._circleElement.style.width=`${c}px`,this._circleElement.style.height=`${c}px`}trigger(){if(!this._setup)return a.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 a.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":eo--,io=!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 a.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 a.l("trackuserlocationstart")),this.fire(new a.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"),eo++,eo>1?(e={maximumAge:6e5,timeout:0},io=!0):(e=this.options.positionOptions,io=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},s.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const s=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==s&&s?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=n.create("button","maplibregl-ctrl-globe",this._container),n.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(){n.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},s.Hash=Er,s.ImageSource=X,s.KeyboardHandler=pa,s.LngLatBounds=G,s.LogoControl=Aa,s.Map=class extends Ra{constructor(e){var s,l;a.cw.mark(a.cx.create);const c=Object.assign(Object.assign(Object.assign({},As),e),{canvasContextAttributes:Object.assign(Object.assign({},As.canvasContextAttributes),e.canvasContextAttributes)});if(null!=c.minZoom&&null!=c.maxZoom&&c.minZoom>c.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=c.minPitch&&null!=c.maxPitch&&c.minPitch>c.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=c.minPitch&&c.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=c.maxPitch&&c.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const u=new Lt,p=new Ot;if(void 0!==c.minZoom&&u.setMinZoom(c.minZoom),void 0!==c.maxZoom&&u.setMaxZoom(c.maxZoom),void 0!==c.minPitch&&u.setMinPitch(c.minPitch),void 0!==c.maxPitch&&u.setMaxPitch(c.maxPitch),void 0!==c.renderWorldCopies&&u.setRenderWorldCopies(c.renderWorldCopies),super(u,p,{bearingSnap:c.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new La,this._controls=[],this._mapId=a.a7(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new a.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new a.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=c.interactive,this._maxTileCacheSize=c.maxTileCacheSize,this._maxTileCacheZoomLevels=c.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},c.canvasContextAttributes),this._trackResize=!0===c.trackResize,this._bearingSnap=c.bearingSnap,this._centerClampedToGround=c.centerClampedToGround,this._refreshExpiredTiles=!0===c.refreshExpiredTiles,this._fadeDuration=c.fadeDuration,this._crossSourceCollisions=!0===c.crossSourceCollisions,this._collectResourceTiming=!0===c.collectResourceTiming,this._locale=Object.assign(Object.assign({},Ss),c.locale),this._clickTolerance=c.clickTolerance,this._overridePixelRatio=c.pixelRatio,this._maxCanvasSize=c.maxCanvasSize,this.transformCameraUpdate=c.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===c.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=C.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(c.transformRequest),"string"==typeof c.container){if(this._container=document.getElementById(c.container),!this._container)throw new Error(`Container '${c.container}' not found.`)}else{if(!(c.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=c.container}if(c.maxBounds&&this.setMaxBounds(c.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const s=Xn((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50);this._resizeObserver=new ResizeObserver((a=>{e?s(a):e=!0})),this._resizeObserver.observe(this._container)}this.handlers=new Ea(this,c),this._hash=c.hash&&new Er("string"==typeof c.hash&&c.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:c.center,elevation:c.elevation,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,roll:c.roll}),c.bounds&&(this.resize(),this.fitBounds(c.bounds,a.e({},c.fitBoundsOptions,{duration:0}))));const f="string"==typeof c.style||!("globe"===(null===(l=null===(s=c.style)||void 0===s?void 0:s.projection)||void 0===l?void 0:l.type));this.resize(null,f),this._localIdeographFontFamily=c.localIdeographFontFamily,this._validateStyle=c.validateStyle,c.style&&this.setStyle(c.style,{localIdeographFontFamily:c.localIdeographFontFamily}),c.attributionControl&&this.addControl(new Da("boolean"==typeof c.attributionControl?void 0:c.attributionControl)),c.maplibreLogo&&this.addControl(new Aa,c.logoPosition),this.on("style.load",(()=>{if(f||this._resizeTransform(),this.transform.unmodified){const e=a.Q(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new a.l(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new a.l(`${e.dataType}dataloading`,e))})),this.on("dataabort",(e=>{this.fire(new a.l("sourcedataabort",e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,s){return this.style.setGlobalStateProperty(e,s),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,s){if(void 0===s&&(s=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new a.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const l=e.onAdd(this);this._controls.push(e);const c=this._controlPositions[s];return-1!==s.indexOf("bottom")?c.insertBefore(l,c.firstChild):c.appendChild(l),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new a.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const s=this._controls.indexOf(e);return s>-1&&this._controls.splice(s,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}calculateCameraOptionsFromTo(e,s,a,l){return null==l&&this.terrain&&(l=this.terrain.getElevationForLngLatZoom(a,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,s,a,l)}resize(e,s=!0){const[l,c]=this._containerDimensions(),u=this._getClampedPixelRatio(l,c);if(this._resizeCanvas(l,c,u),this.painter.resize(l,c,u),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const s=this._getClampedPixelRatio(l,c);this._resizeCanvas(l,c,s),this.painter.resize(l,c,s)}this._resizeTransform(s);const p=!this._moving;return p&&(this.stop(),this.fire(new a.l("movestart",e)).fire(new a.l("move",e))),this.fire(new a.l("resize",e)),p&&this.fire(new a.l("moveend",e)),this}_resizeTransform(e=!0){var s;const[a,l]=this._containerDimensions();this.transform.resize(a,l,e),null===(s=this._requestedCameraState)||void 0===s||s.resize(a,l,e)}_getClampedPixelRatio(e,s){const{0:a,1:l}=this._maxCanvasSize,c=this.getPixelRatio(),u=e*c,p=s*c;return Math.min(u>a?a/u:1,p>l?l/p:1)*c}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(G.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(a.S.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(a.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,s,a){if("mouseenter"===e||"mouseover"===e){let l=!1;const c=c=>{const u=s.filter((e=>this.getLayer(e))),p=0!==u.length?this.queryRenderedFeatures(c.point,{layers:u}):[];p.length?l||(l=!0,a.call(this,new jr(e,this,c.originalEvent,{features:p}))):l=!1};return{layers:s,listener:a,delegates:{mousemove:c,mouseout:()=>{l=!1}}}}if("mouseleave"===e||"mouseout"===e){let l=!1;const c=c=>{const u=s.filter((e=>this.getLayer(e)));(0!==u.length?this.queryRenderedFeatures(c.point,{layers:u}):[]).length?l=!0:l&&(l=!1,a.call(this,new jr(e,this,c.originalEvent)))},u=s=>{l&&(l=!1,a.call(this,new jr(e,this,s.originalEvent)))};return{layers:s,listener:a,delegates:{mousemove:c,mouseout:u}}}{const l=e=>{const l=s.filter((e=>this.getLayer(e))),c=0!==l.length?this.queryRenderedFeatures(e.point,{layers:l}):[];c.length&&(e.features=c,a.call(this,e),delete e.features)};return{layers:s,listener:a,delegates:{[e]:l}}}}_saveDelegatedListener(e,s){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(s)}_removeDelegatedListener(e,s,a){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const l=this._delegatedListeners[e];for(let e=0;es.includes(e)))){for(const e in c.delegates)this.off(e,c.delegates[e]);return void l.splice(e,1)}}}on(e,s,a){if(void 0===a)return super.on(e,s);const l="string"==typeof s?[s]:s,c=this._createDelegatedListener(e,l,a);this._saveDelegatedListener(e,c);for(const e in c.delegates)this.on(e,c.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,l,a)}}}once(e,s,a){if(void 0===a)return super.once(e,s);const l="string"==typeof s?[s]:s,c=this._createDelegatedListener(e,l,a);for(const s in c.delegates){const u=c.delegates[s];c.delegates[s]=(...s)=>{this._removeDelegatedListener(e,l,a),u(...s)}}this._saveDelegatedListener(e,c);for(const e in c.delegates)this.once(e,c.delegates[e]);return this}off(e,s,a){return void 0===a?super.off(e,s):(this._removeDelegatedListener(e,"string"==typeof s?[s]:s,a),this)}queryRenderedFeatures(e,s){if(!this.style)return[];let l;const c=e instanceof a.P||Array.isArray(e),u=c?e:[[0,0],[this.transform.width,this.transform.height]];if(s=s||(c?{}:e)||{},u instanceof a.P||"number"==typeof u[0])l=[a.P.convert(u)];else{const e=a.P.convert(u[0]),s=a.P.convert(u[1]);l=[e,new a.P(s.x,e.y),s,new a.P(e.x,s.y),e]}return this.style.queryRenderedFeatures(l,s,this.transform)}querySourceFeatures(e,s){return this.style.querySourceFeatures(e,s)}setStyle(e,s){return!1!==(s=a.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},s)).diff&&s.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,s),this):(this._localIdeographFontFamily=s.localIdeographFontFamily,this._updateStyle(e,s))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const s=this._locale[e];if(null==s)throw new Error(`Missing UI string '${e}'`);return s}_updateStyle(e,s){var a,l;if(s.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,s)));const c=this.style&&s.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new wi(this,s||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,s,c):this.style.loadJSON(e,s,c),this):(null===(l=null===(a=this.style)||void 0===a?void 0:a.projection)||void 0===l||l.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new wi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,s){if("string"==typeof e){const l=this._requestManager.transformRequest(e,"Style");a.j(l,new AbortController).then((e=>{this._updateDiff(e.data,s)})).catch((e=>{e&&this.fire(new a.k(e))}))}else"object"==typeof e&&this._updateDiff(e,s)}_updateDiff(e,s){try{this.style.setState(e,s)&&this._update(!0)}catch(l){a.w(`Unable to perform style diff: ${l.message||l.error||l}. Rebuilding the style from scratch.`),this._updateStyle(e,s)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():a.w("There is no style added to the map.")}addSource(e,s){return this._lazyInitEmptyStyle(),this.style.addSource(e,s),this._update(!0)}isSourceLoaded(e){const s=this.style&&this.style.sourceCaches[e];if(void 0!==s)return s.loaded();this.fire(new a.k(new Error(`There is no source with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const s=this.style.sourceCaches[e.source];if(!s)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&s.reload();for(const s in this.style._layers){const l=this.style._layers[s];"hillshade"===l.type&&l.source===e.source&&a.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"===l.type&&l.source===e.source&&a.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 Ba(this.painter,s,e),this.painter.renderToTexture=new Na(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=s=>{var a;"style"===s.dataType?this.terrain.sourceCache.freeRtt():"source"===s.dataType&&s.tile&&(s.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(a=s.source)||void 0===a?void 0:a.type)?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(s.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.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 a.l("terrain",{terrain:e})),this}getTerrain(){var e,s;return null!==(s=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==s?s:null}areTilesLoaded(){const e=this.style&&this.style.sourceCaches;for(const s in e){const a=e[s]._tiles;for(const e in a){const s=a[e];if("loaded"!==s.state&&"errored"!==s.state)return!1}}return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,s,a){if(a){const l=this.getSource(a);if(!l)throw new Error(`There is no source with ID "${a}", cannot set LOD parameters`);l.calculateTileZoom=Nt(Math.max(1,e),Math.max(1,s))}else for(const a in this.style.sourceCaches)this.style.sourceCaches[a].getSource().calculateTileZoom=Nt(Math.max(1,e),Math.max(1,s));return this._update(!0),this}refreshTiles(e,s){const l=this.style.sourceCaches[e];if(!l)throw new Error(`There is no source cache with ID "${e}", cannot refresh tile`);void 0===s?l.reload(!0):l.refreshTiles(s.map((e=>new a.a4(e.z,e.x,e.y))))}addImage(e,s,l={}){const{pixelRatio:c=1,sdf:u=!1,stretchX:p,stretchY:_,content:g,textFitWidth:y,textFitHeight:x}=l;if(this._lazyInitEmptyStyle(),!(s instanceof HTMLImageElement||a.b(s))){if(void 0===s.width||void 0===s.height)return this.fire(new a.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:l,height:f,data:v}=s,w=s;return this.style.addImage(e,{data:new a.R({width:l,height:f},new Uint8Array(v)),pixelRatio:c,stretchX:p,stretchY:_,content:g,textFitWidth:y,textFitHeight:x,sdf:u,version:0,userImage:w}),w.onAdd&&w.onAdd(this,e),this}}{const{width:l,height:v,data:w}=f.getImageData(s);this.style.addImage(e,{data:new a.R({width:l,height:v},w),pixelRatio:c,stretchX:p,stretchY:_,content:g,textFitWidth:y,textFitHeight:x,sdf:u,version:0})}}updateImage(e,s){const l=this.style.getImage(e);if(!l)return this.fire(new a.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const c=s instanceof HTMLImageElement||a.b(s)?f.getImageData(s):s,{width:u,height:p,data:_}=c;if(void 0===u||void 0===p)return this.fire(new a.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(u!==l.data.width||p!==l.data.height)return this.fire(new a.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const g=!(s instanceof HTMLImageElement||a.b(s));return l.data.replace(_,g),this.style.updateImage(e,l),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new a.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return C.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,s){return this._lazyInitEmptyStyle(),this.style.addLayer(e,s),this._update(!0)}moveLayer(e,s){return this.style.moveLayer(e,s),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,s,a){return this.style.setLayerZoomRange(e,s,a),this._update(!0)}setFilter(e,s,a={}){return this.style.setFilter(e,s,a),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,s,a,l={}){return this.style.setPaintProperty(e,s,a,l),this._update(!0)}getPaintProperty(e,s){return this.style.getPaintProperty(e,s)}setLayoutProperty(e,s,a,l={}){return this.style.setLayoutProperty(e,s,a,l),this._update(!0)}getLayoutProperty(e,s){return this.style.getLayoutProperty(e,s)}setGlyphs(e,s={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,s),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,s,a={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,s,a,(e=>{e||this._update(!0)})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,s={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,s,(e=>{e||this._update(!0)})),this}setLight(e,s={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,s),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,s={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,s),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,s){return this.style.setFeatureState(e,s),this._update()}removeFeatureState(e,s){return this.style.removeFeatureState(e,s),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,s=0;return this._container&&(e=this._container.clientWidth||400,s=this._container.clientHeight||300),[e,s]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const s=this._canvasContainer=n.create("div","maplibregl-canvas-container",e);this._interactive&&s.classList.add("maplibregl-interactive"),this._canvas=n.create("canvas","maplibregl-canvas",s),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const a=this._containerDimensions(),l=this._getClampedPixelRatio(a[0],a[1]);this._resizeCanvas(a[0],a[1],l);const c=this._controlContainer=n.create("div","maplibregl-control-container",e),u=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{u[e]=n.create("div",`maplibregl-ctrl-${e} `,c)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,s,a){this._canvas.width=Math.floor(a*e),this._canvas.height=Math.floor(a*s),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${s}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let s=null;this._canvas.addEventListener("webglcontextcreationerror",(a=>{s={requestedAttributes:e},a&&(s.statusMessage=a.statusMessage,s.type=a.type)}),{once:!0});let a=null;if(a=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!a){const e="Failed to initialize WebGL";throw s?(s.message=e,new Error(JSON.stringify(s))):new Error(e)}this.painter=new Mr(a,this.transform),_.testSupport(a)}migrateProjection(e,s){super.migrateProjection(e,s),this.painter.transform=e,this.fire(new a.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var s,l,c,u,p;const _=this._idleTriggered?this._fadeDuration:0,g=(null===(s=this.style.projection)||void 0===s?void 0:s.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let y=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,s=f.now();this.style.zoomHistory.update(e,s);const l=new a.F(e,{now:s,fadeDuration:_,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition(),globalState:this.style.getGlobalState()}),c=l.crossFadingFactor();1===c&&c===this._crossFadingFactor||(y=!0,this._crossFadingFactor=c),this.style.update(l)}const x=(null===(l=this.style.projection)||void 0===l?void 0:l.transitionState)>0!==g;null===(c=this.style.projection)||void 0===c||c.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(u=this.style.projection)||void 0===u?void 0:u.transitionState,null===(p=this.style.projection)||void 0===p?void 0:p.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||x)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.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,x),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 a.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,a.cw.mark(a.cx.load),this.fire(new a.l("load"))),this.style&&(this.style.hasTransitions()||y)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const v=this._sourcesDirty||this._styleDirty||this._placementDirty;return v||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new a.l("idle")),!this._loaded||this._fullyLoaded||v||(this._fullyLoaded=!0,a.cw.mark(a.cx.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),C.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const s=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==s?void 0:s.loseContext)&&s.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),n.remove(this._canvasContainer),n.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),a.cw.clearMetrics(),this._removed=!0,this.fire(new a.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,f.frame(this._frameRequest,(e=>{a.cw.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!a.cy(e)&&!function(e){return e.message===dn}(e))throw e}}),(()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return Ms}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},s.MapMouseEvent=jr,s.MapTouchEvent=Nr,s.MapWheelEvent=Ur,s.Marker=Ka,s.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),s=e===this._map.getMaxZoom(),a=e===this._map.getMinZoom();this._zoomInButton.disabled=s,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",s.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,s)=>{const a=this._map._getUIString(`NavigationControl.${s}`);e.title=a,e.setAttribute("aria-label",a)},this.options=a.e({},ks,e),this._container=n.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}))),n.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}))),n.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=n.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 $a(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){n.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,s){const a=n.create("button",e,this._container);return a.type="button",a.addEventListener("click",s),a}},s.Popup=class extends a.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&&n.remove(this._content),this._container&&(n.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 a.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=n.create("div","maplibregl-popup",this._map.getContainer()),this._tip=n.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=Zs(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const s=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let a=this.options.anchor;const l=Ko(this.options.offset);if(!a){const e=this._container.offsetWidth,c=this._container.offsetHeight;let u;u=s.y+l.bottom.ythis._map.transform.height-c?["bottom"]:[],s.xthis._map.transform.width-e/2&&u.push("right"),a=0===u.length?"bottom":u.join("-")}let c=s.add(l[a]);this.options.subpixelPositioning||(c=c.round()),n.setTransform(this._container,`${qs[a]} translate(${c.x}px,${c.y}px)`),Ys(this._container,a,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=a.e(Object.create(Xo),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 a.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=a.S.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const s=document.createDocumentFragment(),a=document.createElement("body");let l;for(a.innerHTML=e;l=a.firstChild,l;)s.appendChild(l);return this.setDOMContent(s)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=n.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=n.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(Yo);e&&e.focus()}},s.RasterDEMTileSource=W,s.RasterTileSource=q,s.ScaleControl=class{constructor(e){this._onMove=()=>{ao(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,ao(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},ro),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},s.ScrollZoomHandler=va,s.Style=wi,s.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=n.create("button","maplibregl-ctrl-terrain",this._container),n.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(){n.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},s.TwoFingersTouchPitchHandler=da,s.TwoFingersTouchRotateHandler=ha,s.TwoFingersTouchZoomHandler=la,s.TwoFingersTouchZoomRotateHandler=Pa,s.VectorTileSource=$,s.VideoSource=K,s.addSourceType=(e,s)=>a._(void 0,void 0,void 0,(function*(){if(lt(e))throw new Error(`A source type called "${e}" already exists.`);((e,s)=>{at[e]=s})(e,s)})),s.clearPrewarmedResources=function(){const e=Z;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(U),Z=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},s.createTileMesh=Fi,s.getMaxParallelImageRequests=function(){return a.a.MAX_PARALLEL_IMAGE_REQUESTS},s.getRTLTextPluginStatus=function(){return pt().getRTLTextPluginStatus()},s.getVersion=function(){return Jo},s.getWorkerCount=function(){return z.workerCount},s.getWorkerUrl=function(){return a.a.WORKER_URL},s.importScriptInWorkers=function(e){return et().broadcast("IS",e)},s.prewarm=function(){Q().acquire(U)},s.setMaxParallelImageRequests=function(e){a.a.MAX_PARALLEL_IMAGE_REQUESTS=e},s.setRTLTextPlugin=function(e,s){return pt().setRTLTextPlugin(e,s)},s.setWorkerCount=function(e){z.workerCount=e},s.setWorkerUrl=function(e){a.a.WORKER_URL=e}}));var c=s;return c}));var a=s;export{a as default};