// maplibre-gl@5.10.0 downloaded from https://ga.jspm.io/npm:maplibre-gl@5.10.0/dist/maplibre-gl.js 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.10.0/LICENSE.txt */(function(e,a){s=a()})(0,(function(){var s={};var a={};function l(e,l,h){a[e]=h;if(e==="index"){var p="var sharedModule = {}; ("+a.shared+")(sharedModule); ("+a.worker+")(sharedModule);";var f={};a.shared(f);a.index(s,f);typeof window!=="undefined"&&s.setWorkerUrl(window.URL.createObjectURL(new Blob([p],{type:"text/javascript"})));return s}}l("shared",["exports"],(function(s){function a(e,s,a,l){return new(a||(a=Promise))((function(h,p){function f(e){try{_(l.next(e))}catch(e){p(e)}}function m(e){try{_(l.throw(e))}catch(e){p(e)}}function _(e){var s;e.done?h(e.value):(s=e.value,s instanceof a?s:new a((function(e){e(s)}))).then(f,m)}_((l=l.apply(e,s||[])).next())}))}function l(s,a){(this||e).x=s,(this||e).y=a}function h(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p,f;"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),h=l*(this||e).x+a*(this||e).y;return(this||e).x=a*(this||e).x-l*(this||e).y,(this||e).y=h,this||e},_rotateAround(s,a){const l=Math.cos(s),h=Math.sin(s),p=a.y+h*((this||e).x-a.x)+l*((this||e).y-a.y);return(this||e).x=a.x+l*((this||e).x-a.x)-h*((this||e).y-a.y),(this||e).y=p,this||e},_round(){return(this||e).x=Math.round((this||e).x),(this||e).y=Math.round((this||e).y),this||e},constructor: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 m=function(){if(f)return p;function s(s,a,l,h){(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*(h-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=h}return f=1,p=s,s.prototype={sampleCurveX:function(s){return(((this||e).ax*s+(this||e).bx)*s+(this||e).cx)*s},sampleCurveY:function(s){return(((this||e).ay*s+(this||e).by)*s+(this||e).cy)*s},sampleCurveDerivativeX:function(s){return(3*(this||e).ax*s+2*(this||e).bx)*s+(this||e).cx},solveCurveX:function(e,s){if(void 0===s&&(s=1e-6),e<0)return 0;if(e>1)return 1;for(var a=e,l=0;l<8;l++){var h=this.sampleCurveX(a)-e;if(Math.abs(h)h?f=a:m=a,a=.5*(m-f)+f;return a},solve:function(e,s){return this.sampleCurveY(this.solveCurveX(e,s))}},p}(),_=h(m);let x,v;function b(){return null==x&&(x="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),x}function w(){if(null==v&&(v=!1,b())){const e=5,s=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(s){for(let a=0;a4&&void 0!==arguments[4]?arguments[4]:"zyx",p=Math.PI/360;s*=p,l*=p,a*=p;var f=Math.sin(s),m=Math.cos(s),_=Math.sin(a),x=Math.cos(a),v=Math.sin(l),b=Math.cos(l);switch(h){case"xyz":e[0]=f*x*b+m*_*v,e[1]=m*_*b-f*x*v,e[2]=m*x*v+f*_*b,e[3]=m*x*b-f*_*v;break;case"xzy":e[0]=f*x*b-m*_*v,e[1]=m*_*b-f*x*v,e[2]=m*x*v+f*_*b,e[3]=m*x*b+f*_*v;break;case"yxz":e[0]=f*x*b+m*_*v,e[1]=m*_*b-f*x*v,e[2]=m*x*v-f*_*b,e[3]=m*x*b+f*_*v;break;case"yzx":e[0]=f*x*b+m*_*v,e[1]=m*_*b+f*x*v,e[2]=m*x*v-f*_*b,e[3]=m*x*b-f*_*v;break;case"zxy":e[0]=f*x*b-m*_*v,e[1]=m*_*b+f*x*v,e[2]=m*x*v+f*_*b,e[3]=m*x*b-f*_*v;break;case"zyx":e[0]=f*x*b-m*_*v,e[1]=m*_*b+f*x*v,e[2]=m*x*v-f*_*b,e[3]=m*x*b+f*_*v;break;default:throw new Error("Unknown angle order "+h)}return e}function nt(){var e=new P(2);return P!=Float32Array&&(e[0]=0,e[1]=0),e}function st(e,s){var a=new P(2);return a[0]=e,a[1]=s,a}z(),V=new P(4),P!=Float32Array&&(V[0]=0,V[1]=0,V[2]=0,V[3]=0),z(),L(1,0,0),L(0,1,0),G(),G(),M(),nt();const at=8192;function lt(e,s,a){return s*(at/(e.tileSize*Math.pow(2,a-e.tileID.overscaledZ)))}function ht(e,s){return(e%s+s)%s}function ut(e,s,a){return e*(1-a)+s*a}function dt(e){if(e<=0)return 0;if(e>=1)return 1;const s=e*e,a=s*e;return 4*(e<.5?a:3*(e-s)+a-.75)}function pt(e,s,a,l){const h=new _(e,s,a,l);return e=>h.solve(e)}const _t=pt(.25,.1,.25,1);function vt(e,s,a){return Math.min(a,Math.max(s,e))}function Tt(e,s,a){const l=a-s,h=((e-s)%l+l)%l+s;return h===s?a:h}function Pt(e,...s){for(const a of s)for(const s in a)e[s]=a[s];return e}let St=1;function Mt(s,a,l){const h={};for(const l in s)h[l]=a.call(this||e,s[l],l,s);return h}function Ct(s,a,l){const h={};for(const l in s)a.call(this||e,s[l],l,s)&&(h[l]=s[l]);return h}function At(e){return Array.isArray(e)?e.map(At):"object"==typeof e&&e?Mt(e,At):e}const zt={};function jt(e){zt[e]||("undefined"!=typeof console&&console.warn(e),zt[e]=!0)}function Nt(e,s,a){return(a.y-e.y)*(s.x-e.x)>(s.y-e.y)*(a.x-e.x)}function Zt(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let qt=null;function Xt(e){if(null==qt){const s=e.navigator?e.navigator.userAgent:null;qt=!!e.safari||!(!s||!(/\b(iPad|iPhone|iPod)\b/.test(s)||s.match("Safari")&&!s.match("Chrome")))}return qt}function Yt(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const Kt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Jt(s,l,h,p,f){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 m=a.startsWith("BGR"),_=new Uint8ClampedArray(p*f*4);if(yield e.copyTo(_,function(e,s,a,l,h){const p=4*Math.max(-s,0),f=(Math.max(0,a)-a)*l*4+p,m=4*l,_=Math.max(0,s),x=Math.max(0,a);return{rect:{x:_,y:x,width:Math.min(e.width,s+l)-_,height:Math.min(e.height,a+h)-x},layout:[{offset:f,stride:m}]}}(s,l,h,p,f)),m)for(let e=0;e<_.length;e+=4){const s=_[e];_[e]=_[e+2],_[e+2]=s}return _}finally{e.close()}}))}let ee,ie;function re(e,s,a,l){return e.addEventListener(s,a,l),{unsubscribe:()=>{e.removeEventListener(s,a,l)}}}function se(e){return e*Math.PI/180}function ae(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 ct 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 ye=()=>Zt(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,xe=function(s,l){if(/:\/\//.test(s.url)&&!/^https?:|^file:/.test(s.url)){const e=_e(s.url);if(e)return e(s,l);if(Zt(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:s,targetMapId:ge},l)}if(!(/^file:/.test(h=s.url)||/^file:/.test(ye())&&!/^\w+:/.test(h))){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:ye(),signal:l.signal});let a,h;"json"!==s.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{a=yield fetch(e)}catch(e){throw new ct(0,e.message,s.url,new Blob)}if(!a.ok){const e=yield a.blob();throw new ct(a.status,a.statusText,s.url,e)}h="arrayBuffer"===s.type||"image"===s.type?a.arrayBuffer():"json"===s.type?a.json():a.text();const p=yield h;if(l.signal.aborted)throw fe();return{data:p,cacheControl:a.headers.get("Cache-Control"),expires:a.headers.get("Expires")}}))}(s,l);if(Zt(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:s,mustQueue:!0,targetMapId:ge},l)}var h;return function(e,s){return new Promise(((a,l)=>{var h;const p=new XMLHttpRequest;p.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(p.responseType="arraybuffer");for(const s in e.headers)p.setRequestHeader(s,e.headers[s]);"json"===e.type&&(p.responseType="text",(null===(h=e.headers)||void 0===h?void 0:h.Accept)||p.setRequestHeader("Accept","application/json")),p.withCredentials="include"===e.credentials,p.onerror=()=>{l(new Error(p.statusText))},p.onload=()=>{if(!s.signal.aborted)if((p.status>=200&&p.status<300||0===p.status)&&null!==p.response){let s=p.response;if("json"===e.type)try{s=JSON.parse(p.response)}catch(e){return void l(e)}a({data:s,cacheControl:p.getResponseHeader("Cache-Control"),expires:p.getResponseHeader("Expires")})}else{const s=new Blob([p.response],{type:p.getResponseHeader("Content-Type")});l(new ct(p.status,p.statusText,e.url,s))}},s.signal.addEventListener("abort",(()=>{p.abort(),l(fe())})),p.send(e.body)}))}(s,l)};function ve(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 be(e,s,a){a[e]&&-1!==a[e].indexOf(s)||(a[e]=a[e]||[],a[e].push(s))}function we(e,s,a){if(a&&a[e]){const l=a[e].indexOf(s);-1!==l&&a[e].splice(l,1)}}class mt{constructor(e,s={}){Pt(this,s),this.type=e}}class gt extends mt{constructor(e,s={}){super("error",Pt({error:e},s))}}class xt{on(e,s){return this._listeners=this._listeners||{},be(e,s,this._listeners),{unsubscribe:()=>{this.off(e,s)}}}off(e,s){return we(e,s,this._listeners),we(e,s,this._oneTimeListeners),this}once(e,s){return s?(this._oneTimeListeners=this._oneTimeListeners||{},be(e,s,this._oneTimeListeners),this):new Promise((s=>this.once(e,s)))}fire(e,s){"string"==typeof e&&(e=new mt(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)we(a,s,this._oneTimeListeners),s.call(this,e);const h=this._eventedParent;h&&(Pt(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),h.fire(e))}else e instanceof gt&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,s){return this._eventedParent=e,this._eventedParentData=s,this}}var Se={$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"},"font-faces":{type:"array",value:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},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","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const Ae=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ke(e,s){const a={};for(const s in e)"ref"!==s&&(a[s]=e[s]);return Ae.forEach((e=>{e in s&&(a[e]=s[e])})),a}function De(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 Ri=[ai,li,ci,hi,ui,di,xi,fi,ki(_i),Pi,Ci,Mi,Ei,Ai];function Li(e,s){if("error"===s.kind)return null;if("array"===e.kind){if("array"===s.kind&&(0===s.N&&"value"===s.itemType.kind||!Li(e.itemType,s.itemType))&&("number"!=typeof e.N||e.N===s.N))return null}else{if(e.kind===s.kind)return null;if("value"===e.kind)for(const e of Ri)if(!Li(e,s))return null}return`Expected ${Di(e)} but found ${Di(s)} instead.`}function Fi(e,s){return s.some((s=>s.kind===e.kind))}function Bi(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 Oi(e,s){return"array"===e.kind&&"array"===s.kind?e.itemType.kind===s.itemType.kind&&"number"==typeof e.N:e.kind===s.kind}const ji=.96422,Vi=.82521,Ni=4/29,Ui=6/29,$i=3*Ui*Ui,Gi=Ui*Ui*Ui,Zi=Math.PI/180,qi=180/Math.PI;function Wi(e){return(e%=360)<0&&(e+=360),e}function Hi([e,s,a,l]){let h,p;const f=Yi((.2225045*(e=Xi(e))+.7168786*(s=Xi(s))+.0606169*(a=Xi(a)))/1);e===s&&s===a?h=p=f:(h=Yi((.4360747*e+.3850649*s+.1430804*a)/ji),p=Yi((.0139322*e+.0971045*s+.7141733*a)/Vi));const m=116*f-16;return[m<0?0:m,500*(h-f),200*(f-p),l]}function Xi(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Yi(e){return e>Gi?Math.pow(e,1/3):e/$i+Ni}function Ki([e,s,a,l]){let h=(e+16)/116,p=isNaN(s)?h:h+s/500,f=isNaN(a)?h:h-a/200;return h=1*Qi(h),p=ji*Qi(p),f=Vi*Qi(f),[Ji(3.1338561*p-1.6168667*h-.4906146*f),Ji(-.9787684*p+1.9161415*h+.033454*f),Ji(.0719453*p-.2289914*h+1.4052427*f),l]}function Ji(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function Qi(e){return e>Ui?e*e*e:$i*(e-Ni)}const lr=Object.hasOwn||function(e,s){return Object.prototype.hasOwnProperty.call(e,s)};function cr(e,s){return lr(e,s)?e[s]:void 0}function _r(e){return parseInt(e.padEnd(2,e),16)/255}function gr(e,s){return yr(s?e/100:e,0,1)}function yr(e,s,a){return Math.min(Math.max(s,e),a)}function xr(e){return!e.some(Number.isNaN)}const Tr={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 Fr(e,s,a){return e+a*(s-e)}function Or(e,s,a){return e.map(((e,l)=>Fr(e,s[l],a)))}class Ie{constructor(e,s,a,l=1,h=!0){this.r=e,this.g=s,this.b=a,this.a=l,h||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[e,s,a,l]))}static parse(e){if(e instanceof Ie)return e;if("string"!=typeof e)return;const s=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const s=cr(Tr,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[_r(e.slice(a,a+=s)),_r(e.slice(a,a+=s)),_r(e.slice(a,a+=s)),_r(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,h,p,f,m,_,x,v,b,w]=s,T=[h||" ",m||" ",v].join("");if(" "===T||" /"===T||",,"===T||",,,"===T){const e=[l,f,x].join(""),s="%%%"===e?100:""===e?255:0;if(s){const e=[yr(+a/s,0,1),yr(+p/s,0,1),yr(+_/s,0,1),b?gr(+b,w):1];if(xr(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,h,p,f,m,_,x]=a,v=[l||" ",p||" ",m].join("");if(" "===v||" /"===v||",,"===v||",,,"===v){const e=[+s,yr(+h,0,100),yr(+f,0,100),_?gr(+_,x):1];if(xr(e))return function([e,s,a,l]){function h(l){const h=(l+e/30)%12,p=s*Math.min(a,1-a);return a-p*Math.max(-1,Math.min(h-3,9-h,1))}return e=Wi(e),s/=100,a/=100,[h(0),h(8),h(4),l]}(e)}}}(e);return s?new Ie(...s,!1):void 0}get rgb(){const{r:e,g:s,b:a,a:l}=this,h=l||1/0;return this.overwriteGetter("rgb",[e/h,s/h,a/h,l])}get hcl(){return this.overwriteGetter("hcl",function(e){const[s,a,l,h]=Hi(e),p=Math.sqrt(a*a+l*l);return[Math.round(1e4*p)?Wi(Math.atan2(l,a)*qi):NaN,p,s,h]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Hi(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,h,p,f]=Or(e.rgb,s.rgb,a);return new Ie(l,h,p,f,!1)}case"hcl":{const[l,h,p,f]=e.hcl,[m,_,x,v]=s.hcl;let b,w;if(isNaN(l)||isNaN(m))isNaN(l)?isNaN(m)?b=NaN:(b=m,1!==p&&0!==p||(w=_)):(b=l,1!==x&&0!==x||(w=h));else{let e=m-l;m>l&&e>180?e-=360:m180&&(e+=360),b=l+a*e}const[T,P,M,E]=function([e,s,a,l]){return e=isNaN(e)?0:e*Zi,Ki([a,Math.cos(e)*s,Math.sin(e)*s,l])}([b,null!=w?w:Fr(h,_,a),Fr(p,x,a),Fr(f,v,a)]);return new Ie(T,P,M,E,!1)}case"lab":{const[l,h,p,f]=Ki(Or(e.lab,s.lab,a));return new Ie(l,h,p,f,!1)}}}}Ie.black=new Ie(0,0,0,1),Ie.white=new Ie(1,1,1,1),Ie.transparent=new Ie(0,0,0,0),Ie.red=new Ie(1,0,0,1);class ze{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 $r=["bottom","center","top"];class Ce{constructor(e,s,a,l,h,p){this.text=e,this.image=s,this.scale=a,this.fontStack=l,this.textColor=h,this.verticalAlign=p}}class Ee{constructor(e){this.sections=e}static fromString(e){return new Ee([new Ce(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 Ee?e:Ee.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}}class Te{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Te)return e;if("number"==typeof e)return new Te([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 Te(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,s,a){return new Te(Or(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(Or(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=Ie.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=Ie.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 h=[];if(e.values.length!=s.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${s.values.length}), cannot interpolate.`);for(let p=0;p=0&&e<=255&&"number"==typeof s&&s>=0&&s<=255&&"number"==typeof 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 Yr(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Oe||e instanceof Ie||e instanceof ze||e instanceof Ee||e instanceof Te||e instanceof Be||e instanceof Ve||e instanceof $e||e instanceof Le)return!0;if(Array.isArray(e)){for(const s of e)if(!Yr(s))return!1;return!0}if("object"==typeof e){for(const s in e)if(!Yr(e[s]))return!1;return!0}return!1}function Jr(e){if(null===e)return ai;if("string"==typeof e)return ci;if("boolean"==typeof e)return hi;if("number"==typeof e)return li;if(e instanceof Ie)return ui;if(e instanceof Oe)return di;if(e instanceof ze)return gi;if(e instanceof Ee)return xi;if(e instanceof Te)return Pi;if(e instanceof Be)return Ci;if(e instanceof Ve)return Mi;if(e instanceof $e)return Ai;if(e instanceof Le)return Ei;if(Array.isArray(e)){const s=e.length;let a;for(const s of e){const e=Jr(s);if(a){if(a===e)continue;a=_i;break}a=e}return ki(a||_i,s)}return fi}function Qr(e){const s=typeof e;return null===e?"":"string"===s||"number"===s||"boolean"===s?String(e):e instanceof Ie||e instanceof Oe||e instanceof Ee||e instanceof Te||e instanceof Be||e instanceof Ve||e instanceof $e||e instanceof Le?e.toString():JSON.stringify(e)}class qe{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(!Yr(e[1]))return s.error("invalid value");const a=e[1];let l=Jr(a);const h=s.expectedType;return"array"!==l.kind||0!==l.N||!h||"array"!==h.kind||"number"==typeof h.N&&0!==h.N||(l=h),new qe(l,a)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const tn={string:ci,number:li,boolean:hi,object:fi};class Xe{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");let a,l=1;const h=e[0];if("array"===h){let h,p;if(e.length>2){const a=e[1];if("string"!=typeof a||!(a in tn)||"object"===a)return s.error('The item type argument of "array" must be one of string, number, boolean',1);h=tn[a],l++}else h=_i;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return s.error('The length argument to "array" must be a positive integer literal',2);p=e[2],l++}a=ki(h,p)}else{if(!tn[h])throw new Error(`Types doesn't contain name = ${h}`);a=tn[h]}const p=[];for(;le.outputDefined()))}}const en={"to-boolean":hi,"to-color":ui,"to-number":li,"to-string":ci};class Ye{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(!en[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=en[a],h=[];for(let a=1;a4?`Invalid rgba value ${JSON.stringify(s)}: expected an array containing either three or four numeric values.`:Xr(s[0],s[1],s[2],s[3]),!a))return new Ie(s[0]/255,s[1]/255,s[2]/255,s[3])}throw new Fe(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=Te.parse(s);if(l)return l}throw new Fe(`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 Fe(`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 Fe(`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 Fe(`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 Fe(`Could not convert ${JSON.stringify(s)} to number.`)}case"formatted":return Ee.fromString(Qr(this.args[0].evaluate(e)));case"resolvedImage":return Le.fromString(Qr(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return Qr(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const rn=["Unknown","Point","LineString","Polygon"];class Ke{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?rn[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=Ie.parse(e),this._parseColorCache.set(e,s)),s}}class Je{constructor(e,s,a=[],l,h=new Vt,p=[]){this.registry=e,this.path=a,this.key=a.map((e=>`[${e}]`)).join(""),this.scope=h,this.errors=p,this.expectedType=l,this._isConstant=s}parse(e,s,a,l,h={}){return s?this.concat(s,a,l)._parse(e,h):this._parse(e,h)}_parse(e,s){function a(e,s,a){return"assert"===a?new Xe(s,[e]):"coerce"===a?new Ye(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 h=this.registry[l];if(h){let l=h.parse(e,this);if(!l)return null;if(this.expectedType){const e=this.expectedType,h=l.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==h.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(h.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(h.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(h.kind)||"colorArray"===e.kind&&["value","string","array"].includes(h.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(h.kind))l=a(l,e,s.typeAnnotation||"coerce");else if(this.checkSubtype(e,h))return null}else l=a(l,e,s.typeAnnotation||"assert")}if(!(l instanceof qe)&&"resolvedImage"!==l.type.kind&&this._isConstant(l)){const s=new Ke;try{l=new qe(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,h=a?this.scope.concat(a):this.scope;return new Je(this.registry,this._isConstant,l,s||null,h,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=Li(e,s);return a&&this.error(a),a}}class We{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 Fe(`Array index out of bounds: ${s} > ${a.length-1}.`);if(s!==Math.floor(s))throw new Fe(`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 er{constructor(e,s){this.type=hi,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,_i),l=s.parse(e[2],2,_i);return a&&l?Fi(a.type,[hi,ci,li,ai,_i])?new er(a,l):s.error(`Expected first argument to be of type boolean, string, number or null, but found ${Di(a.type)} instead`):null}evaluate(e){const s=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!a)return!1;if(!Bi(s,["boolean","string","number","null"]))throw new Fe(`Expected first argument to be of type boolean, string, number or null, but found ${Di(Jr(s))} instead.`);if(!Bi(a,["string","array"]))throw new Fe(`Expected second argument to be of type array or string, but found ${Di(Jr(a))} instead.`);return a.indexOf(s)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class rr{constructor(e,s,a){this.type=li,this.needle=e,this.haystack=s,this.fromIndex=a}static parse(e,s){if(e.length<=2||e.length>=5)return s.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const a=s.parse(e[1],1,_i),l=s.parse(e[2],2,_i);if(!a||!l)return null;if(!Fi(a.type,[hi,ci,li,ai,_i]))return s.error(`Expected first argument to be of type boolean, string, number or null, but found ${Di(a.type)} instead`);if(4===e.length){const h=s.parse(e[3],3,li);return h?new rr(a,l,h):null}return new rr(a,l)}evaluate(e){const s=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!Bi(s,["boolean","string","number","null"]))throw new Fe(`Expected first argument to be of type boolean, string, number or null, but found ${Di(Jr(s))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(e)),Bi(a,["string"])){const e=a.indexOf(s,l);return-1===e?-1:[...a.slice(0,e)].length}if(Bi(a,["array"]))return a.indexOf(s,l);throw new Fe(`Expected second argument to be of type array or string, but found ${Di(Jr(a))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class nr{constructor(e,s,a,l,h,p){this.inputType=e,this.type=s,this.input=a,this.cases=l,this.outputs=h,this.otherwise=p}static parse(e,s){if(e.length<5)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return s.error("Expected an even number of arguments.");let a,l;s.expectedType&&"value"!==s.expectedType.kind&&(l=s.expectedType);const h={},p=[];for(let f=2;fNumber.MAX_SAFE_INTEGER)return x.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return x.error("Numeric branch labels must be integer values.");if(a){if(x.checkSubtype(a,Jr(e)))return null}else a=Jr(e);if(void 0!==h[String(e)])return x.error("Branch labels must be unique.");h[String(e)]=p.length}const v=s.parse(_,f,l);if(!v)return null;l=l||v.type,p.push(v)}const f=s.parse(e[1],1,_i);if(!f)return null;const m=s.parse(e[e.length-1],e.length-1,l);return m?"value"!==f.type.kind&&s.concat(1).checkSubtype(a,f.type)?null:new nr(a,l,f,h,p,m):null}evaluate(e){const s=this.input.evaluate(e);return(Jr(s)===this.inputType&&this.outputs[this.cases[s]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class ir{constructor(e,s,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 h=1;hs.outputDefined()))&&this.otherwise.outputDefined()}}class sr{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 2 or 3 arguments, but found ${e.length-1} instead.`);const a=s.parse(e[1],1,_i),l=s.parse(e[2],2,li);if(!a||!l)return null;if(!Fi(a.type,[ki(_i),ci,_i]))return s.error(`Expected first argument to be of type array or string, but found ${Di(a.type)} instead`);if(4===e.length){const h=s.parse(e[3],3,li);return h?new sr(a.type,a,l,h):null}return new sr(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)),Bi(s,["string"]))return[...s].slice(a,l).join("");if(Bi(s,["array"]))return s.slice(a,l);throw new Fe(`Expected first argument to be of type array or string, but found ${Di(Jr(s))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function nn(e,s){const a=e.length-1;let l,h,p=0,f=a,m=0;for(;p<=f;)if(m=Math.floor((p+f)/2),l=e[m],h=e[m+1],l<=s){if(m===a||ss))throw new Fe("Input is not a number.");f=m-1}return 0}class or{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,li);if(!a)return null;const l=[];let h=null;s.expectedType&&"value"!==s.expectedType.kind&&(h=s.expectedType);for(let a=1;a=p)return s.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',m);const x=s.parse(f,_,h);if(!x)return null;h=h||x.type,l.push([p,x])}return new or(h,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 h=s.length;return l>=s[h-1]?a[h-1].evaluate(e):a[nn(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 sn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var an,ln,cn=function(){if(ln)return an;function s(s,a,l,h){(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*(h-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=h}return ln=1,an=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 h=this.sampleCurveX(a)-e;if(Math.abs(h)h?f=a:m=a,a=.5*(m-f)+f;return a},solve:function(e,s){return this.sampleCurveY(this.solveCurveX(e,s))}},an}(),hn=sn(cn);class fr{constructor(e,s,a,l,h){this.type=e,this.operator=s,this.interpolation=a,this.input=l,this.labels=[],this.outputs=[];for(const[e,s]of h)this.labels.push(e),this.outputs.push(s)}static interpolationFactor(e,s,a,l){let h=0;if("exponential"===e.name)h=un(s,e.base,a,l);else if("linear"===e.name)h=un(s,1,a,l);else if("cubic-bezier"===e.name){const p=e.controlPoints;h=new hn(p[0],p[1],p[2],p[3]).solve(un(s,1,a,l))}return h}static parse(e,s){let[a,l,h,...p]=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(h=s.parse(h,2,li),!h)return null;const f=[];let m=null;"interpolate-hcl"!==a&&"interpolate-lab"!==a||s.expectedType==Mi?s.expectedType&&"value"!==s.expectedType.kind&&(m=s.expectedType):m=ui;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.',h);const x=s.parse(l,_,m);if(!x)return null;m=m||x.type,f.push([a,x])}return Oi(m,li)||Oi(m,di)||Oi(m,ui)||Oi(m,Pi)||Oi(m,Ci)||Oi(m,Mi)||Oi(m,Ai)||Oi(m,ki(li))?new fr(m,a,l,h,f):s.error(`Type ${Di(m)} 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 h=s.length;if(l>=s[h-1])return a[h-1].evaluate(e);const p=nn(s,l),f=fr.interpolationFactor(this.interpolation,l,s[p],s[p+1]),m=a[p].evaluate(e),_=a[p+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Fr(m,_,f);case"color":return Ie.interpolate(m,_,f);case"padding":return Te.interpolate(m,_,f);case"colorArray":return Ve.interpolate(m,_,f);case"numberArray":return Be.interpolate(m,_,f);case"variableAnchorOffsetCollection":return $e.interpolate(m,_,f);case"array":return Or(m,_,f);case"projectionDefinition":return Oe.interpolate(m,_,f)}case"interpolate-hcl":switch(this.type.kind){case"color":return Ie.interpolate(m,_,f,"hcl");case"colorArray":return Ve.interpolate(m,_,f,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Ie.interpolate(m,_,f,"lab");case"colorArray":return Ve.interpolate(m,_,f,"lab")}}}eachChild(e){e(this.input);for(const s of this.outputs)e(s)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function un(e,s,a,l){const h=l-a,p=e-a;return 0===h?0:1===s?p/h:(Math.pow(s,p)-1)/(Math.pow(s,h)-1)}const dn={color:Ie.interpolate,number:Fr,padding:Te.interpolate,numberArray:Be.interpolate,colorArray:Ve.interpolate,variableAnchorOffsetCollection:$e.interpolate,array:Or};class mr{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");let a=null;const l=s.expectedType;l&&"value"!==l.kind&&(a=l);const h=[];for(const l of e.slice(1)){const e=s.parse(l,1+h.length,a,void 0,{typeAnnotation:"omit"});if(!e)return null;a=a||e.type,h.push(e)}if(!a)throw new Error("No output type");const p=l&&h.some((e=>Li(l,e.type)));return new mr(p?_i:a,h)}evaluate(e){let s,a=null,l=0;for(const h of this.args)if(l++,a=h.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 pn(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 fn(e,s,a,l){return 0===l.compare(s,a)}function mn(e,s,a){const l="=="!==e&&"!="!==e;return class i{constructor(e,s,a){this.type=hi,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 h=s.parse(e[1],1,_i);if(!h)return null;if(!pn(a,h.type))return s.concat(1).error(`"${a}" comparisons are not supported for type '${Di(h.type)}'.`);let p=s.parse(e[2],2,_i);if(!p)return null;if(!pn(a,p.type))return s.concat(2).error(`"${a}" comparisons are not supported for type '${Di(p.type)}'.`);if(h.type.kind!==p.type.kind&&"value"!==h.type.kind&&"value"!==p.type.kind)return s.error(`Cannot compare types '${Di(h.type)}' and '${Di(p.type)}'.`);l&&("value"===h.type.kind&&"value"!==p.type.kind?h=new Xe(p.type,[h]):"value"!==h.type.kind&&"value"===p.type.kind&&(p=new Xe(h.type,[p])));let f=null;if(4===e.length){if("string"!==h.type.kind&&"string"!==p.type.kind&&"value"!==h.type.kind&&"value"!==p.type.kind)return s.error("Cannot use collator to compare non-string types.");if(f=s.parse(e[3],3,gi),!f)return null}return new i(h,p,f)}evaluate(h){const p=this.lhs.evaluate(h),f=this.rhs.evaluate(h);if(l&&this.hasUntypedArgument){const s=Jr(p),a=Jr(f);if(s.kind!==a.kind||"string"!==s.kind&&"number"!==s.kind)throw new Fe(`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=Jr(p),a=Jr(f);if("string"!==e.kind||"string"!==a.kind)return s(h,p,f)}return this.collator?a(h,p,f,this.collator.evaluate(h)):s(h,p,f)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const _n=mn("==",(function(e,s,a){return s===a}),fn),gn=mn("!=",(function(e,s,a){return s!==a}),(function(e,s,a,l){return!fn(0,s,a,l)})),yn=mn("<",(function(e,s,a){return s",(function(e,s,a){return s>a}),(function(e,s,a,l){return l.compare(s,a)>0})),vn=mn("<=",(function(e,s,a){return s<=a}),(function(e,s,a,l){return l.compare(s,a)<=0})),bn=mn(">=",(function(e,s,a){return s>=a}),(function(e,s,a,l){return l.compare(s,a)>=0}));class Mr{constructor(e,s,a){this.type=gi,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,hi);if(!l)return null;const h=s.parse(void 0!==a["diacritic-sensitive"]&&a["diacritic-sensitive"],1,hi);if(!h)return null;let p=null;return a.locale&&(p=s.parse(a.locale,1,ci),!p)?null:new Mr(l,h,p)}evaluate(e){return new ze(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 Ir{constructor(e,s,a,l,h){this.type=ci,this.number=e,this.locale=s,this.currency=a,this.minFractionDigits=l,this.maxFractionDigits=h}static parse(e,s){if(3!==e.length)return s.error("Expected two arguments.");const a=s.parse(e[1],1,li);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 h=null;if(l.locale&&(h=s.parse(l.locale,1,ci),!h))return null;let p=null;if(l.currency&&(p=s.parse(l.currency,1,ci),!p))return null;let f=null;if(l["min-fraction-digits"]&&(f=s.parse(l["min-fraction-digits"],1,li),!f))return null;let m=null;return l["max-fraction-digits"]&&(m=s.parse(l["max-fraction-digits"],1,li),!m)?null:new Ir(a,h,p,f,m)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class zr{constructor(e){this.type=xi,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 h=!1;for(let a=1;a<=e.length-1;++a){const p=e[a];if(h&&"object"==typeof p&&!Array.isArray(p)){h=!1;let e=null;if(p["font-scale"]&&(e=s.parse(p["font-scale"],1,li),!e))return null;let a=null;if(p["text-font"]&&(a=s.parse(p["text-font"],1,ki(ci)),!a))return null;let f=null;if(p["text-color"]&&(f=s.parse(p["text-color"],1,ui),!f))return null;let m=null;if(p["vertical-align"]){if("string"==typeof p["vertical-align"]&&!$r.includes(p["vertical-align"]))return s.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${p["vertical-align"]}' instead.`);if(m=s.parse(p["vertical-align"],1,ci),!m)return null}const _=l[l.length-1];_.scale=e,_.font=a,_.textColor=f,_.verticalAlign=m}else{const p=s.parse(e[a],1,_i);if(!p)return null;const f=p.type.kind;if("string"!==f&&"value"!==f&&"null"!==f&&"resolvedImage"!==f)return s.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,l.push({content:p,scale:null,font:null,textColor:null,verticalAlign:null})}}return new zr(l)}evaluate(e){return new Ee(this.sections.map((s=>{const a=s.content.evaluate(e);return Jr(a)===Ei?new Ce("",a,null,null,null,s.verticalAlign?s.verticalAlign.evaluate(e):null):new Ce(Qr(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 Pr{constructor(e){this.type=Ei,this.input=e}static parse(e,s){if(2!==e.length)return s.error("Expected two arguments.");const a=s.parse(e[1],1,ci);return a?new Pr(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 Cr{constructor(e){this.type=li,this.input=e}static parse(e,s){if(2!==e.length)return s.error(`Expected 1 argument, but found ${e.length-1} instead.`);const 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 ${Di(a.type)} instead.`):new Cr(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 Fe(`Expected value to be of type string or array, but found ${Di(Jr(s))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const wn=8192;function Sn(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,h=Math.pow(2,s.z);return[Math.round(a*h*wn),Math.round(l*h*wn)]}function In(e,s){const a=Math.pow(2,s.z);return[(h=(e[0]/wn+s.x)/a,360*h-180),(l=(e[1]/wn+s.y)/a,360/Math.PI*Math.atan(Math.exp((180-360*l)*Math.PI/180))-90)];var l,h}function Mn(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 En(e,s){return!(e[0]<=s[0]||e[2]>=s[2]||e[1]<=s[1]||e[3]>=s[3])}function An(e,s,a){const l=e[0]-s[0],h=e[1]-s[1],p=e[0]-a[0],f=e[1]-a[1];return l*f-p*h==0&&l*p<=0&&h*f<=0}function zn(e,s,a,l){return 0!=(h=[l[0]-a[0],l[1]-a[1]])[0]*(p=[s[0]-e[0],s[1]-e[1]])[1]-h[1]*p[0]&&!(!Bn(e,s,a,l)||!Bn(a,l,e,s));var h,p}function kn(e,s,a){for(const l of a)for(let a=0;a(h=e)[1]!=(f=m[s+1])[1]>h[1]&&h[0]<(f[0]-p[0])*(h[1]-p[1])/(f[1]-p[1])+p[0]&&(l=!l)}var h,p,f;return l}function Rn(e,s){for(const a of s)if(Dn(e,a))return!0;return!1}function Ln(e,s){for(const a of e)if(!Dn(a,s))return!1;for(let a=0;a0&&m<0||f<0&&m>0}function On(e,s,a){const l=[];for(let h=0;ha[2]){const s=.5*l;let h=e[0]-a[0]>s?-l:a[0]-e[0]>s?l:0;0===h&&(h=e[0]-a[2]>s?-l:a[2]-e[0]>s?l:0),e[0]+=h}Mn(s,e)}function Nn(e,s,a,l){const h=Math.pow(2,l.z)*wn,p=[l.x*wn,l.y*wn],f=[];for(const l of e)for(const e of l){const l=[e.x+p[0],e.y+p[1]];Vn(l,s,a,h),f.push(l)}return f}function Un(e,s,a,l){const h=Math.pow(2,l.z)*wn,p=[l.x*wn,l.y*wn],f=[];for(const a of e){const e=[];for(const l of a){const a=[l.x+p[0],l.y+p[1]];Mn(s,a),e.push(a)}f.push(e)}if(s[2]-s[0]<=h/2){(m=s)[0]=m[1]=1/0,m[2]=m[3]=-1/0;for(const e of f)for(const l of e)Vn(l,s,a,h)}var m;return f}class Hr{constructor(e,s){this.type=hi,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(Yr(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 Hr(s,{type:"MultiPolygon",coordinates:e})}else if("Feature"===s.type){const e=s.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Hr(s,s.geometry)}else if("Polygon"===s.type||"MultiPolygon"===s.type)return new Hr(s,s)}return s.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,s){const a=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],h=e.canonicalID();if("Polygon"===s.type){const p=On(s.coordinates,l,h),f=Nn(e.geometry(),a,l,h);if(!En(a,l))return!1;for(const e of f)if(!Dn(e,p))return!1}if("MultiPolygon"===s.type){const p=jn(s.coordinates,l,h),f=Nn(e.geometry(),a,l,h);if(!En(a,l))return!1;for(const e of f)if(!Rn(e,p))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],h=e.canonicalID();if("Polygon"===s.type){const p=On(s.coordinates,l,h),f=Un(e.geometry(),a,l,h);if(!En(a,l))return!1;for(const e of f)if(!Ln(e,p))return!1}if("MultiPolygon"===s.type){const p=jn(s.coordinates,l,h),f=Un(e.geometry(),a,l,h);if(!En(a,l))return!1;for(const e of f)if(!Fn(e,p))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let $n=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 h=e-1>>1,p=s[h];if(a(l,p)>=0)break;s[e]=p,e=h}s[e]=l}_down(e){const{data:s,compare:a}=this,l=this.length>>1,h=s[e];for(;e=0)break;s[e]=s[l],e=l}s[e]=h}};function Gn(e,s,a=0,l=e.length-1,h=qn){for(;l>a;){if(l-a>600){const p=l-a+1,f=s-a+1,m=Math.log(p),_=.5*Math.exp(2*m/3),x=.5*Math.sqrt(m*_*(p-_)/p)*(f-p/2<0?-1:1);Gn(e,s,Math.max(a,Math.floor(s-f*_/p+x)),Math.min(l,Math.floor(s+(p-f)*_/p+x)),h)}const p=e[s];let f=a,m=l;for(Zn(e,a,s),h(e[l],p)>0&&Zn(e,a,l);f0;)m--}0===h(e[a],p)?Zn(e,a,m):(m++,Zn(e,m,l)),m<=s&&(a=m+1),s<=m&&(l=m-1)}}function Zn(e,s,a){const l=e[s];e[s]=e[a],e[a]=l}function qn(e,s){return es?1:0}function Wn(e,s){if(e.length<=1)return[e];const a=[];let l,h;for(const s of e){const e=Xn(s);0!==e&&(s.area=Math.abs(e),void 0===h&&(h=e<0),h===e<0?(l&&a.push(l),l=[s]):l.push(s))}if(l&&a.push(l),s>1)for(let e=0;e1?(_=e[m+1][0],x=e[m+1][1]):w>0&&(_+=v/this.kx*w,x+=b/this.ky*w)),v=this.wrap(s[0]-_)*this.kx,b=(s[1]-x)*this.ky;const T=v*v+b*b;T180;)e-=360;return e}}function Qn(e,s){return s[0]-e[0]}function es(e){return e[1]-e[0]+1}function is(e,s){return e[1]>=e[0]&&e[1]e[1])return[null,null];const a=es(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 ns(e,s){if(!is(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)Mn(a,e[l]);return a}function os(e){const s=[1/0,1/0,-1/0,-1/0];for(const a of e)for(const e of a)Mn(s,e);return s}function ls(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function cs(e,s,a){if(!ls(e)||!ls(s))return NaN;let l=0,h=0;return e[2]s[2]&&(l=e[0]-s[2]),e[1]>s[3]&&(h=e[1]-s[3]),e[3]=l)return l;if(En(h,p)){if(gs(e,s))return 0}else if(gs(s,e))return 0;let f=1/0;for(const l of e)for(let e=0,h=l.length,p=h-1;e0;){const h=f.pop();if(h[0]>=p)continue;const _=h[1],x=s?50:100;if(es(_)<=x){if(!is(_,e.length))return NaN;if(s){const s=_s(e,_,a,l);if(isNaN(s)||0===s)return s;p=Math.min(p,s)}else for(let s=_[0];s<=_[1];++s){const h=ms(e[s],a,l);if(p=Math.min(p,h),0===p)return 0}}else{const a=rs(_,s);xs(f,p,l,e,m,a[0]),xs(f,p,l,e,m,a[1])}}return p}function ws(e,s,a,l,h,p=1/0){let f=Math.min(p,h.distance(e[0],a[0]));if(0===f)return f;const m=new $n([[0,[0,e.length-1],[0,a.length-1]]],Qn);for(;m.length>0;){const p=m.pop();if(p[0]>=f)continue;const _=p[1],x=p[2],v=s?50:100,b=l?50:100;if(es(_)<=v&&es(x)<=b){if(!is(_,e.length)&&is(x,a.length))return NaN;let p;if(s&&l)p=ps(e,_,a,x,h),f=Math.min(f,p);else if(s&&!l){const s=e.slice(_[0],_[1]+1);for(let e=x[0];e<=x[1];++e)if(p=hs(a[e],s,h),f=Math.min(f,p),0===f)return f}else if(!s&&l){const s=a.slice(x[0],x[1]+1);for(let a=_[0];a<=_[1];++a)if(p=hs(e[a],s,h),f=Math.min(f,p),0===f)return f}else p=fs(e,_,a,x,h),f=Math.min(f,p)}else{const p=rs(_,s),v=rs(x,l);vs(m,f,h,e,a,p[0],v[0]),vs(m,f,h,e,a,p[0],v[1]),vs(m,f,h,e,a,p[1],v[0]),vs(m,f,h,e,a,p[1],v[1])}}return f}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 Pn{constructor(e,s){this.type=li,this.geojson=e,this.geometries=s}static parse(e,s){if(2!==e.length)return s.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Yr(e[1])){const s=e[1];if("FeatureCollection"===s.type)return new Pn(s,s.features.map((e=>Ss(e.geometry))).flat());if("Feature"===s.type)return new Pn(s,Ss(s.geometry));if("type"in s&&"coordinates"in s)return new Pn(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=>In([s.x,s.y],e.canonical)));if(0===a.length)return NaN;const h=new on(l[0][1]);let p=1/0;for(const e of s){switch(e.type){case"Point":p=Math.min(p,ws(l,!1,[e.coordinates],!1,h,p));break;case"LineString":p=Math.min(p,ws(l,!1,e.coordinates,!0,h,p));break;case"Polygon":p=Math.min(p,bs(l,!1,e.coordinates,h,p))}if(0===p)return p}return p}(e,this.geometries);if("LineString"===e.geometryType())return function(e,s){const a=e.geometry(),l=a.flat().map((s=>In([s.x,s.y],e.canonical)));if(0===a.length)return NaN;const h=new on(l[0][1]);let p=1/0;for(const e of s){switch(e.type){case"Point":p=Math.min(p,ws(l,!0,[e.coordinates],!1,h,p));break;case"LineString":p=Math.min(p,ws(l,!0,e.coordinates,!0,h,p));break;case"Polygon":p=Math.min(p,bs(l,!0,e.coordinates,h,p))}if(0===p)return p}return p}(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=Wn(a,0).map((s=>s.map((s=>s.map((s=>In([s.x,s.y],e.canonical))))))),h=new on(l[0][0][0][1]);let p=1/0;for(const e of s)for(const s of l){switch(e.type){case"Point":p=Math.min(p,bs([e.coordinates],!1,s,h,p));break;case"LineString":p=Math.min(p,bs(e.coordinates,!0,s,h,p));break;case"Polygon":p=Math.min(p,ys(s,e.coordinates,h,p))}if(0===p)return p}return p}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Cn{constructor(e){this.type=_i,this.key=e}static parse(e,s){if(2!==e.length)return s.error(`Expected 1 argument, but found ${e.length-1} instead.`);const 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 Cn(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?cr(a,this.key):null}eachChild(){}outputDefined(){return!1}}const Is={"==":_n,"!=":gn,">":xn,"<":yn,">=":bn,"<=":vn,array:Xe,at:tr,boolean:Xe,case:ir,coalesce:mr,collator:Mr,format:zr,image:Pr,in:er,"index-of":rr,interpolate:fr,"interpolate-hcl":fr,"interpolate-lab":fr,length:Cr,let:We,literal:qe,match:nr,number:Xe,"number-format":Ir,object:Xe,slice:sr,step:or,string:Xe,"to-boolean":Ye,"to-color":Ye,"to-number":Ye,"to-string":Ye,var:Qe,within:Hr,distance:Pn,"global-state":Cn};class Tn{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=Tn.definitions[a];if(!l)return s.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0);const h=Array.isArray(l)?l[0]:l.type,p=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,f=p.filter((([s])=>!Array.isArray(s)||s.length===e.length-1));let m=null;for(const[l,p]of f){m=new Je(s.registry,ks,s.path,null,s.scope);const f=[];let _=!1;for(let s=1;s{return s=e,Array.isArray(s)?`(${s.map(Di).join(", ")})`:`(${Di(s.type)}...)`;var s})).join(" | "),l=[];for(let a=1;a{a=s?a&&ks(e):a&&e instanceof qe})),!!a&&Gs(e)&&Ys(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Gs(e){if(e instanceof Tn){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Hr)return!1;if(e instanceof Pn)return!1;let s=!0;return e.eachChild((e=>{s&&!Gs(e)&&(s=!1)})),s}function Zs(e){if(e instanceof Tn&&"feature-state"===e.name)return!1;let s=!0;return e.eachChild((e=>{s&&!Zs(e)&&(s=!1)})),s}function Ys(e,s){if(e instanceof Tn&&s.indexOf(e.name)>=0)return!1;let a=!0;return e.eachChild((e=>{a&&!Ys(e,s)&&(a=!1)})),a}function Ks(e){return{result:"success",value:e}}function Qs(e){return{result:"error",value:e}}function eo(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function io(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function ro(e){return!!e.expression&&e.expression.interpolated}function no(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function so(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Jr(e)===fi}function oo(e){return e}function ao(e,s){const a=e.stops&&"object"==typeof e.stops[0][0],l=a||!(a||void 0!==e.property),h=e.type||(ro(s)?"exponential":"interval"),p=function(e){switch(e.type){case"color":return Ie.parse;case"padding":return Te.parse;case"numberArray":return Be.parse;case"colorArray":return Ve.parse;default:return null}}(s);if(p&&((e=ni({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],p(e[1])]))),e.default=p(e.default?e.default:s.default)),e.colorSpace&&"rgb"!==(f=e.colorSpace)&&"hcl"!==f&&"lab"!==f)throw new Error(`Unknown color space: "${e.colorSpace}"`);var f;const m=function(e){switch(e){case"exponential":return _o;case"interval":return ho;case"categorical":return co;case"identity":return Qo;default:throw new Error(`Unknown function type "${e}"`)}}(h);let _,x;if("categorical"===h){_=Object.create(null);for(const s of e.stops)_[s[0]]=s[1];x=typeof e.stops[0][0]}if(a){const a={},l=[];for(let s=0;se[0])),evaluate:({zoom:a},l)=>_o({stops:h,base:e.base},s,a).evaluate(a,l)}}if(l){const a="exponential"===h?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:a,interpolationFactor:fr.interpolationFactor.bind(void 0,a),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:a})=>m(e,s,a,_,x)}}return{kind:"source",evaluate(a,l){const h=l&&l.properties?l.properties[e.property]:void 0;return void 0===h?lo(e.default,s.default):m(e,s,h,_,x)}}}function lo(e,s,a){return void 0!==e?e:void 0!==s?s:void 0!==a?a:void 0}function co(e,s,a,l,h){return lo(typeof a===h?l[a]:void 0,e.default,s.default)}function ho(e,s,a){if("number"!==no(a))return lo(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 h=nn(e.stops.map((e=>e[0])),a);return e.stops[h][1]}function _o(e,s,a){const l=void 0!==e.base?e.base:1;if("number"!==no(a))return lo(e.default,s.default);const h=e.stops.length;if(1===h)return e.stops[0][1];if(a<=e.stops[0][0])return e.stops[0][1];if(a>=e.stops[h-1][0])return e.stops[h-1][1];const p=nn(e.stops.map((e=>e[0])),a),f=function(e,s,a,l){const h=l-a,p=e-a;return 0===h?0:1===s?p/h:(Math.pow(s,p)-1)/(Math.pow(s,h)-1)}(a,l,e.stops[p][0],e.stops[p+1][0]),m=e.stops[p][1],_=e.stops[p+1][1],x=dn[s.type]||oo;return"function"==typeof m.evaluate?{evaluate(...s){const a=m.evaluate.apply(void 0,s),l=_.evaluate.apply(void 0,s);if(void 0!==a&&void 0!==l)return x(a,l,f,e.colorSpace)}}:x(m,_,f,e.colorSpace)}function Qo(e,s,a){switch(s.type){case"color":a=Ie.parse(a);break;case"formatted":a=Ee.fromString(a.toString());break;case"resolvedImage":a=Le.fromString(a.toString());break;case"padding":a=Te.parse(a);break;case"colorArray":a=Ve.parse(a);break;case"numberArray":a=Be.parse(a);break;default:no(a)===s.type||"enum"===s.type&&s.values[a]||(a=void 0)}return lo(a,e.default,s.default)}Tn.register(Is,{error:[{kind:"error"},[ci],(e,[s])=>{throw new Fe(s.evaluate(e))}],typeof:[ci,[_i],(e,[s])=>Di(Jr(s.evaluate(e)))],"to-rgba":[ki(li,4),[ui],(e,[s])=>{const[a,l,h,p]=s.evaluate(e).rgb;return[255*a,255*l,255*h,p]}],rgb:[ui,[li,li,li],Ms],rgba:[ui,[li,li,li,li],Ms],has:{type:hi,overloads:[[[ci],(e,[s])=>Cs(s.evaluate(e),e.properties())],[[ci,fi],(e,[s,a])=>Cs(s.evaluate(e),a.evaluate(e))]]},get:{type:_i,overloads:[[[ci],(e,[s])=>As(s.evaluate(e),e.properties())],[[ci,fi],(e,[s,a])=>As(s.evaluate(e),a.evaluate(e))]]},"feature-state":[_i,[ci],(e,[s])=>As(s.evaluate(e),e.featureState||{})],properties:[fi,[],e=>e.properties()],"geometry-type":[ci,[],e=>e.geometryType()],id:[_i,[],e=>e.id()],zoom:[li,[],e=>e.globals.zoom],"heatmap-density":[li,[],e=>e.globals.heatmapDensity||0],elevation:[li,[],e=>e.globals.elevation||0],"line-progress":[li,[],e=>e.globals.lineProgress||0],accumulated:[_i,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[li,zs(li),(e,s)=>{let a=0;for(const l of s)a+=l.evaluate(e);return a}],"*":[li,zs(li),(e,s)=>{let a=1;for(const l of s)a*=l.evaluate(e);return a}],"-":{type:li,overloads:[[[li,li],(e,[s,a])=>s.evaluate(e)-a.evaluate(e)],[[li],(e,[s])=>-s.evaluate(e)]]},"/":[li,[li,li],(e,[s,a])=>s.evaluate(e)/a.evaluate(e)],"%":[li,[li,li],(e,[s,a])=>s.evaluate(e)%a.evaluate(e)],ln2:[li,[],()=>Math.LN2],pi:[li,[],()=>Math.PI],e:[li,[],()=>Math.E],"^":[li,[li,li],(e,[s,a])=>Math.pow(s.evaluate(e),a.evaluate(e))],sqrt:[li,[li],(e,[s])=>Math.sqrt(s.evaluate(e))],log10:[li,[li],(e,[s])=>Math.log(s.evaluate(e))/Math.LN10],ln:[li,[li],(e,[s])=>Math.log(s.evaluate(e))],log2:[li,[li],(e,[s])=>Math.log(s.evaluate(e))/Math.LN2],sin:[li,[li],(e,[s])=>Math.sin(s.evaluate(e))],cos:[li,[li],(e,[s])=>Math.cos(s.evaluate(e))],tan:[li,[li],(e,[s])=>Math.tan(s.evaluate(e))],asin:[li,[li],(e,[s])=>Math.asin(s.evaluate(e))],acos:[li,[li],(e,[s])=>Math.acos(s.evaluate(e))],atan:[li,[li],(e,[s])=>Math.atan(s.evaluate(e))],min:[li,zs(li),(e,s)=>Math.min(...s.map((s=>s.evaluate(e))))],max:[li,zs(li),(e,s)=>Math.max(...s.map((s=>s.evaluate(e))))],abs:[li,[li],(e,[s])=>Math.abs(s.evaluate(e))],round:[li,[li],(e,[s])=>{const a=s.evaluate(e);return a<0?-Math.round(-a):Math.round(a)}],floor:[li,[li],(e,[s])=>Math.floor(s.evaluate(e))],ceil:[li,[li],(e,[s])=>Math.ceil(s.evaluate(e))],"filter-==":[hi,[ci,_i],(e,[s,a])=>e.properties()[s.value]===a.value],"filter-id-==":[hi,[_i],(e,[s])=>e.id()===s.value],"filter-type-==":[hi,[ci],(e,[s])=>e.geometryType()===s.value],"filter-<":[hi,[ci,_i],(e,[s,a])=>{const l=e.properties()[s.value],h=a.value;return typeof l==typeof h&&l{const a=e.id(),l=s.value;return typeof a==typeof l&&a":[hi,[ci,_i],(e,[s,a])=>{const l=e.properties()[s.value],h=a.value;return typeof l==typeof h&&l>h}],"filter-id->":[hi,[_i],(e,[s])=>{const a=e.id(),l=s.value;return typeof a==typeof l&&a>l}],"filter-<=":[hi,[ci,_i],(e,[s,a])=>{const l=e.properties()[s.value],h=a.value;return typeof l==typeof h&&l<=h}],"filter-id-<=":[hi,[_i],(e,[s])=>{const a=e.id(),l=s.value;return typeof a==typeof l&&a<=l}],"filter->=":[hi,[ci,_i],(e,[s,a])=>{const l=e.properties()[s.value],h=a.value;return typeof l==typeof h&&l>=h}],"filter-id->=":[hi,[_i],(e,[s])=>{const a=e.id(),l=s.value;return typeof a==typeof l&&a>=l}],"filter-has":[hi,[_i],(e,[s])=>s.value in e.properties()],"filter-has-id":[hi,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[hi,[ki(ci)],(e,[s])=>s.value.indexOf(e.geometryType())>=0],"filter-id-in":[hi,[ki(_i)],(e,[s])=>s.value.indexOf(e.id())>=0],"filter-in-small":[hi,[ci,ki(_i)],(e,[s,a])=>a.value.indexOf(e.properties()[s.value])>=0],"filter-in-large":[hi,[ci,ki(_i)],(e,[s,a])=>function(e,s,a,l){for(;a<=l;){const h=a+l>>1;if(s[h]===e)return!0;s[h]>e?l=h-1:a=h+1}return!1}(e.properties()[s.value],a.value,0,a.value.length-1)],all:{type:hi,overloads:[[[hi,hi],(e,[s,a])=>s.evaluate(e)&&a.evaluate(e)],[zs(hi),(e,s)=>{for(const a of s)if(!a.evaluate(e))return!1;return!0}]]},any:{type:hi,overloads:[[[hi,hi],(e,[s,a])=>s.evaluate(e)||a.evaluate(e)],[zs(hi),(e,s)=>{for(const a of s)if(a.evaluate(e))return!0;return!1}]]},"!":[hi,[hi],(e,[s])=>!s.evaluate(e)],"is-supported-script":[hi,[ci],(e,[s])=>{const a=e.globals&&e.globals.isSupportedScript;return!a||a(s.evaluate(e))}],upcase:[ci,[ci],(e,[s])=>s.evaluate(e).toUpperCase()],downcase:[ci,[ci],(e,[s])=>s.evaluate(e).toLowerCase()],concat:[ci,zs(_i),(e,s)=>s.map((s=>Qr(s.evaluate(e)))).join("")],"resolved-locale":[ci,[gi],(e,[s])=>s.evaluate(e).resolvedLocale()]});class ei{constructor(e,s,a){this.expression=e,this._warningHistory={},this._evaluator=new Ke,this._defaultValue=s?function(e){if("color"===e.type&&so(e.default))return new Ie(0,0,0,0);switch(e.type){case"color":return Ie.parse(e.default)||null;case"padding":return Te.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,this._globalState=a}evaluateWithoutErrorHandling(e,s,a,l,h,p){return this._globalState&&(e=nl(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=s,this._evaluator.featureState=a,this._evaluator.canonical=l,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(e,s,a,l,h,p){this._globalState&&(e=nl(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=s||null,this._evaluator.featureState=a||null,this._evaluator.canonical=l,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=p||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Fe(`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 ta(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Is}function tl(e,s,a){const l=new Je(Is,ks,[],s?function(e){const s={color:ui,string:ci,number:li,enum:ci,boolean:hi,formatted:xi,padding:Pi,numberArray:Ci,colorArray:Mi,projectionDefinition:di,resolvedImage:Ei,variableAnchorOffsetCollection:Ai};return"array"===e.type?ki(s[e.value]||_i,e.length):s[e.type]}(s):void 0),h=l.parse(e,void 0,void 0,void 0,s&&"string"===s.type?{typeAnnotation:"coerce"}:void 0);return h?Ks(new ei(h,s,a)):Qs(l.errors)}class ii{constructor(e,s,a){this.kind=e,this._styleExpression=s,this.isStateDependent="constant"!==e&&!Zs(s.expression),this.globalStateRefs=rl(s.expression),this._globalState=a}evaluateWithoutErrorHandling(e,s,a,l,h,p){return this._globalState&&(e=nl(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,s,a,l,h,p)}evaluate(e,s,a,l,h,p){return this._globalState&&(e=nl(e,this._globalState)),this._styleExpression.evaluate(e,s,a,l,h,p)}}class si{constructor(e,s,a,l,h){this.kind=e,this.zoomStops=a,this._styleExpression=s,this.isStateDependent="camera"!==e&&!Zs(s.expression),this.globalStateRefs=rl(s.expression),this.interpolationType=l,this._globalState=h}evaluateWithoutErrorHandling(e,s,a,l,h,p){return this._globalState&&(e=nl(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,s,a,l,h,p)}evaluate(e,s,a,l,h,p){return this._globalState&&(e=nl(e,this._globalState)),this._styleExpression.evaluate(e,s,a,l,h,p)}interpolationFactor(e,s,a){return this.interpolationType?fr.interpolationFactor(this.interpolationType,e,s,a):0}}function el(e,s,a){const l=tl(e,s,a);if("error"===l.result)return l;const h=l.value.expression,p=Gs(h);if(!p&&!eo(s))return Qs([new Bt("","data expressions not supported")]);const f=Ys(h,["zoom"]);if(!f&&!io(s))return Qs([new Bt("","zoom expressions not supported")]);const m=il(h);return m||f?m instanceof Bt?Qs([m]):m instanceof fr&&!ro(s)?Qs([new Bt("",'"interpolate" expressions cannot be used with this property')]):Ks(m?new si(p?"camera":"composite",l.value,m.labels,m instanceof fr?m.interpolation:void 0,a):new ii(p?"constant":"source",l.value,a)):Qs([new Bt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class oi{constructor(e,s){this._parameters=e,this._specification=s,ni(this,ao(this._parameters,this._specification))}static deserialize(e){return new oi(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function il(e){let s=null;if(e instanceof We)s=il(e.result);else if(e instanceof mr){for(const a of e.args)if(s=il(a),s)break}else(e instanceof or||e instanceof fr)&&e.input instanceof Tn&&"zoom"===e.input.name&&(s=e);return s instanceof Bt||e.eachChild((e=>{const a=il(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 rl(e,s=new Set){return e instanceof Cn&&s.add(e.key),e.eachChild((e=>{rl(e,s)})),s}function nl(e,s){const{zoom:a,heatmapDensity:l,elevation:h,lineProgress:p,isSupportedScript:f,accumulated:m}=null!=e?e:{};return{zoom:a,heatmapDensity:l,elevation:h,lineProgress:p,isSupportedScript:f,accumulated:m,globalState:s}}function sl(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(!sl(s)&&"boolean"!=typeof s)return!1;return!0;default:return!0}}const ol={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function al(e,s){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};sl(e)||(e=dl(e));const a=tl(e,ol,s);if("error"===a.result)throw new Error(a.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,s,l)=>a.value.evaluate(e,s,{},l),needGeometry:ul(e),getGlobalStateRefs:()=>rl(a.value.expression)}}function ll(e,s){return es?1:0}function ul(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let s=1;s"===s||"<="===s||">="===s?pl(e[1],e[2],s):"any"===s?(a=e.slice(1),["any"].concat(a.map(dl))):"all"===s?["all"].concat(e.slice(1).map(dl)):"none"===s?["all"].concat(e.slice(1).map(dl).map(_l)):"in"===s?fl(e[1],e.slice(2)):"!in"===s?_l(fl(e[1],e.slice(2))):"has"===s?ml(e[1]):"!has"!==s||_l(ml(e[1]));var a}function pl(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 fl(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(ll)]]:["filter-in-small",e,["literal",s]]}}function ml(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function _l(e){return["!",e]}function yl(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+=`${yl(a)},`;return`${s}]`}const a=Object.keys(e).sort();let l="{";for(let s=0;sl.maximum?[new Et(s,a,`${a} is greater than the maximum value ${l.maximum}`)]:[]}function kl(e){const s=e.valueSpec,a=Tl(e.value.type);let l,h,p,f={};const m="categorical"!==a&&void 0===e.value.property,_=!m,x="array"===no(e.value.stops)&&"array"===no(e.value.stops[0])&&"object"===no(e.value.stops[0][0]),v=Sl({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 Et(e.key,e.value,'identity function may not have a "stops" property')];let s=[];const l=e.value;return s=s.concat(Ml({key:e.key,value:l,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:b})),"array"===no(l)&&0===l.length&&s.push(new Et(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&&m&&v.push(new Et(e.key,e.value,'missing required property "property"')),"identity"===a||e.value.stops||v.push(new Et(e.key,e.value,'missing required property "stops"')),"exponential"===a&&e.valueSpec.expression&&!ro(e.valueSpec)&&v.push(new Et(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(_&&!eo(e.valueSpec)?v.push(new Et(e.key,e.value,"property functions not supported")):m&&!io(e.valueSpec)&&v.push(new Et(e.key,e.value,"zoom functions not supported"))),"categorical"!==a&&!x||void 0!==e.value.property||v.push(new Et(e.key,e.value,'"property" property is required')),v;function b(e){let a=[];const l=e.value,m=e.key;if("array"!==no(l))return[new Et(m,l,`array expected, ${no(l)} found`)];if(2!==l.length)return[new Et(m,l,`array length 2 expected, length ${l.length} found`)];if(x){if("object"!==no(l[0]))return[new Et(m,l,`object expected, ${no(l[0])} found`)];if(void 0===l[0].zoom)return[new Et(m,l,"object stop key must have zoom")];if(void 0===l[0].value)return[new Et(m,l,"object stop key must have value")];if(p&&p>Tl(l[0].zoom))return[new Et(m,l[0].zoom,"stop zoom values must appear in ascending order")];Tl(l[0].zoom)!==p&&(p=Tl(l[0].zoom),h=void 0,f={}),a=a.concat(Sl({key:`${m}[0]`,value:l[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:El,value:w}}))}else a=a.concat(w({key:`${m}[0]`,value:l[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},l));return ta(Pl(l[1]))?a.concat([new Et(`${m}[1]`,l[1],"expressions are not allowed in function stops.")]):a.concat(e.validateSpec({key:`${m}[1]`,value:l[1],valueSpec:s,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function w(e,p){const m=no(e.value),_=Tl(e.value),x=null!==e.value?e.value:p;if(l){if(m!==l)return[new Et(e.key,x,`${m} stop domain type must match previous stop domain type ${l}`)]}else l=m;if("number"!==m&&"string"!==m&&"boolean"!==m)return[new Et(e.key,x,"stop domain value must be a number, string, or boolean")];if("number"!==m&&"categorical"!==a){let l=`number expected, ${m} found`;return eo(s)&&void 0===a&&(l+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Et(e.key,x,l)]}return"categorical"!==a||"number"!==m||isFinite(_)&&Math.floor(_)===_?"categorical"!==a&&"number"===m&&void 0!==h&&_new Et(`${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 Et(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&&!Zs(a))return[new Et(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!Zs(a))return[new Et(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Ys(a,["zoom","feature-state"]))return[new Et(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!Gs(a))return[new Et(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Rl(e){const s=e.key,a=e.value,l=no(a);return"string"!==l?[new Et(s,a,`color expected, ${l} found`)]:Ie.parse(String(a))?[]:[new Et(s,a,`color expected, "${a}" found`)]}function Ll(e){const s=e.key,a=e.value,l=e.valueSpec,h=[];return Array.isArray(l.values)?-1===l.values.indexOf(Tl(a))&&h.push(new Et(s,a,`expected one of [${l.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(l.values).indexOf(Tl(a))&&h.push(new Et(s,a,`expected one of [${Object.keys(l.values).join(", ")}], ${JSON.stringify(a)} found`)),h}function Fl(e){return sl(Pl(e.value))?Dl(ni({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Bl(e)}function Bl(e){const s=e.value,a=e.key;if("array"!==no(s))return[new Et(a,s,`array expected, ${no(s)} found`)];const l=e.styleSpec;let h,p=[];if(s.length<1)return[new Et(a,s,"filter array must have at least 1 element")];switch(p=p.concat(Ll({key:`${a}[0]`,value:s[0],valueSpec:l.filter_operator,style:e.style,styleSpec:e.styleSpec})),Tl(s[0])){case"<":case"<=":case">":case">=":s.length>=2&&"$type"===Tl(s[1])&&p.push(new Et(a,s,`"$type" cannot be use with operator "${s[0]}"`));case"==":case"!=":3!==s.length&&p.push(new Et(a,s,`filter array for operator "${s[0]}" must have 3 elements`));case"in":case"!in":s.length>=2&&(h=no(s[1]),"string"!==h&&p.push(new Et(`${a}[1]`,s[1],`string expected, ${h} found`)));for(let f=2;f{e in a&&s.push(new Et(l,a[e],`"${e}" is prohibited for ref layers`))})),h.layers.forEach((s=>{Tl(s.id)===m&&(e=s)})),e?e.ref?s.push(new Et(l,a.ref,"ref cannot reference another ref layer")):f=Tl(e.type):s.push(new Et(l,a.ref,`ref layer "${m}" not found`))}else if("background"!==f)if(a.source){const e=h.sources&&h.sources[a.source],p=e&&Tl(e.type);e?"vector"===p&&"raster"===f?s.push(new Et(l,a.source,`layer "${a.id}" requires a raster source`)):"raster-dem"!==p&&"hillshade"===f||"raster-dem"!==p&&"color-relief"===f?s.push(new Et(l,a.source,`layer "${a.id}" requires a raster-dem source`)):"raster"===p&&"raster"!==f?s.push(new Et(l,a.source,`layer "${a.id}" requires a vector source`)):"vector"!==p||a["source-layer"]?"raster-dem"===p&&"hillshade"!==f&&"color-relief"!==f?s.push(new Et(l,a.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==f||!a.paint||!a.paint["line-gradient"]||"geojson"===p&&e.lineMetrics||s.push(new Et(l,a,`layer "${a.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):s.push(new Et(l,a,`layer "${a.id}" must specify a "source-layer"`)):s.push(new Et(l,a.source,`source "${a.source}" not found`))}else s.push(new Et(l,a,'missing required property "source"'));return s=s.concat(Sl({key:l,value:a,valueSpec:p.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${l}.type`,value:a.type,valueSpec:p.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:a,objectKey:"type"}),filter:Fl,layout:e=>Sl({layer:a,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Vl(ni({layerType:f},e))}}),paint:e=>Sl({layer:a,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>jl(ni({layerType:f},e))}})}})),s}function Ul(e){const s=e.value,a=e.key,l=no(s);return"string"!==l?[new Et(a,s,`string expected, ${l} found`)]:[]}const $l={promoteId:function({key:e,value:s}){if("string"===no(s))return Ul({key:e,value:s});{const a=[];for(const l in s)a.push(...Ul({key:`${e}.${l}`,value:s[l]}));return a}}};function Gl(e){const s=e.value,a=e.key,l=e.styleSpec,h=e.style,p=e.validateSpec;if(!s.type)return[new Et(a,s,'"type" is required')];const f=Tl(s.type);let m;switch(f){case"vector":case"raster":return m=Sl({key:a,value:s,valueSpec:l[`source_${f.replace("-","_")}`],style:e.style,styleSpec:l,objectElementValidators:$l,validateSpec:p}),m;case"raster-dem":return m=function(e){var s;const a=null!==(s=e.sourceName)&&void 0!==s?s:"",l=e.value,h=e.styleSpec,p=h.source_raster_dem,f=e.style;let m=[];const _=no(l);if(void 0===l)return m;if("object"!==_)return m.push(new Et("source_raster_dem",l,`object expected, ${_} found`)),m;const x="custom"===Tl(l.encoding),v=["redFactor","greenFactor","blueFactor","baseShift"],b=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const s in l)!x&&v.includes(s)?m.push(new Et(s,l[s],`In "${a}": "${s}" is only valid when "encoding" is set to "custom". ${b} encoding found`)):p[s]?m=m.concat(e.validateSpec({key:s,value:l[s],valueSpec:p[s],validateSpec:e.validateSpec,style:f,styleSpec:h})):m.push(new Et(s,l[s],`unknown property "${s}"`));return m}({sourceName:a,value:s,style:e.style,styleSpec:l,validateSpec:p}),m;case"geojson":if(m=Sl({key:a,value:s,valueSpec:l.source_geojson,style:h,styleSpec:l,validateSpec:p,objectElementValidators:$l}),s.cluster)for(const e in s.clusterProperties){const[l,h]=s.clusterProperties[e],p="string"==typeof l?[l,["accumulated"],["get",e]]:l;m.push(...Dl({key:`${a}.${e}.map`,value:h,expressionContext:"cluster-map"})),m.push(...Dl({key:`${a}.${e}.reduce`,value:p,expressionContext:"cluster-reduce"}))}return m;case"video":return Sl({key:a,value:s,valueSpec:l.source_video,style:h,validateSpec:p,styleSpec:l});case"image":return Sl({key:a,value:s,valueSpec:l.source_image,style:h,validateSpec:p,styleSpec:l});case"canvas":return[new Et(a,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Ll({key:`${a}.type`,value:s.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Zl(e){const s=e.value,a=e.styleSpec,l=a.light,h=e.style;let p=[];const f=no(s);if(void 0===s)return p;if("object"!==f)return p=p.concat([new Et("light",s,`object expected, ${f} found`)]),p;for(const f in s){const m=f.match(/^(.*)-transition$/);p=p.concat(m&&l[m[1]]&&l[m[1]].transition?e.validateSpec({key:f,value:s[f],valueSpec:a.transition,validateSpec:e.validateSpec,style:h,styleSpec:a}):l[f]?e.validateSpec({key:f,value:s[f],valueSpec:l[f],validateSpec:e.validateSpec,style:h,styleSpec:a}):[new Et(f,s[f],`unknown property "${f}"`)])}return p}function ql(e){const s=e.value,a=e.styleSpec,l=a.sky,h=e.style,p=no(s);if(void 0===s)return[];if("object"!==p)return[new Et("sky",s,`object expected, ${p} found`)];let f=[];for(const p in s)f=f.concat(l[p]?e.validateSpec({key:p,value:s[p],valueSpec:l[p],style:h,styleSpec:a}):[new Et(p,s[p],`unknown property "${p}"`)]);return f}function Wl(e){const s=e.value,a=e.styleSpec,l=a.terrain,h=e.style;let p=[];const f=no(s);if(void 0===s)return p;if("object"!==f)return p=p.concat([new Et("terrain",s,`object expected, ${f} found`)]),p;for(const f in s)p=p.concat(l[f]?e.validateSpec({key:f,value:s[f],valueSpec:l[f],validateSpec:e.validateSpec,style:h,styleSpec:a}):[new Et(f,s[f],`unknown property "${f}"`)]);return p}function Hl(e){let s=[];const a=e.value,l=e.key;if(Array.isArray(a)){const h=[],p=[];for(const f in a)a[f].id&&h.includes(a[f].id)&&s.push(new Et(l,a,`all the sprites' ids must be unique, but ${a[f].id} is duplicated`)),h.push(a[f].id),a[f].url&&p.includes(a[f].url)&&s.push(new Et(l,a,`all the sprites' URLs must be unique, but ${a[f].url} is duplicated`)),p.push(a[f].url),s=s.concat(Sl({key:`${l}[${f}]`,value:a[f],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return s}return Ul({key:l,value:a})}function Xl(e){return s=e.value,Boolean(s)&&s.constructor===Object?[]:[new Et(e.key,e.value,`object expected, ${no(e.value)} found`)];var s}const Yl={"*":()=>[],array:Ml,boolean:function(e){const s=e.value,a=e.key,l=no(s);return"boolean"!==l?[new Et(a,s,`boolean expected, ${l} found`)]:[]},number:El,color:Rl,constants:bl,enum:Ll,filter:Fl,function:kl,layer:Nl,object:Sl,source:Gl,light:Zl,sky:ql,terrain:Wl,projection:function(e){const s=e.value,a=e.styleSpec,l=a.projection,h=e.style,p=no(s);if(void 0===s)return[];if("object"!==p)return[new Et("projection",s,`object expected, ${p} found`)];let f=[];for(const p in s)f=f.concat(l[p]?e.validateSpec({key:p,value:s[p],valueSpec:l[p],style:h,styleSpec:a}):[new Et(p,s[p],`unknown property "${p}"`)]);return f},projectionDefinition:function(e){const s=e.key;let a=e.value;a=a instanceof String?a.valueOf():a;const l=no(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 Et(s,a,`projection expected, invalid type "${l}" found`)]:[new Et(s,a,`projection expected, invalid array ${JSON.stringify(a)} found`)]},string:Ul,formatted:function(e){return 0===Ul(e).length?[]:Dl(e)},resolvedImage:function(e){return 0===Ul(e).length?[]:Dl(e)},padding:function(e){const s=e.key,a=e.value;if("array"===no(a)){if(a.length<1||a.length>4)return[new Et(s,a,`padding requires 1 to 4 values; ${a.length} values found`)];const l={type:"number"};let h=[];for(let p=0;p[]}})),e.constants&&(a=a.concat(bl({key:"constants",value:e.constants}))),ic(a)}function ec(e){return function(s){return e(Object.assign({},s,{validateSpec:Kl}))}}function ic(e){return[].concat(e).sort(((e,s)=>e.line-s.line))}function rc(s){return function(...a){return ic(s.apply(this||e,a))}}Ql.source=rc(ec(Gl)),Ql.sprite=rc(ec(Hl)),Ql.glyphs=rc(ec(Jl)),Ql.light=rc(ec(Zl)),Ql.sky=rc(ec(ql)),Ql.terrain=rc(ec(Wl)),Ql.state=rc(ec(Xl)),Ql.layer=rc(ec(Nl)),Ql.filter=rc(ec(Fl)),Ql.paintProperty=rc(ec(jl)),Ql.layoutProperty=rc(ec(Vl));const nc=Ql,sc=nc.light,oc=nc.sky,ac=nc.paintProperty,lc=nc.layoutProperty;function cc(e,s){let a=!1;if(s&&s.length)for(const l of s)e.fire(new gt(new Error(l.message))),a=!0;return a}class as{constructor(e,s,a){const l=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const h=new Int32Array(this.arrayBuffer);e=h[0],this.d=(s=h[1])+2*(a=h[2]);for(let e=0;e=x[_+0]&&l>=x[_+1])?(f[b]=!0,p.push(h[b])):f[b]=!1}}}}_forEachCell(e,s,a,l,h,p,f,m){const _=this._convertToCellCoord(e),x=this._convertToCellCoord(s),v=this._convertToCellCoord(a),b=this._convertToCellCoord(l);for(let w=_;w<=v;w++)for(let _=x;_<=b;_++){const x=this.d*_+w;if((!m||m(this._convertFromCellCoord(w),this._convertFromCellCoord(_),this._convertFromCellCoord(w+1),this._convertFromCellCoord(_+1)))&&h.call(this,e,s,a,l,x,p,f,m))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,s=3+this.cells.length+1+1;let a=0;for(let e=0;e=0)continue;const p=e[l];h[l]=hc[a].shallow.indexOf(l)>=0?p:_c(p,s)}e instanceof Error&&(h.message=e.message)}if(h.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(h.$name=a),h}function gc(e){if(mc(e))return e;if(Array.isArray(e))return e.map(gc);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const s=pc(e)||"Object";if(!hc[s])throw new Error(`can't deserialize unregistered class ${s}`);const{klass:a}=hc[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 h=e[a];l[a]=hc[s].shallow.indexOf(a)>=0?h:gc(h)}return l}class ds{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 xc(e){for(const s of e)if(Mc(s.charCodeAt(0)))return!0;return!1}function vc(e){for(const s of e)if(!Sc(s.charCodeAt(0)))return!1;return!0}function bc(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 wc=bc(["Arab","Dupl","Mong","Ougr","Syrc"]);function Sc(e){return!wc.test(String.fromCodePoint(e))}const Ic=bc(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function Mc(e){return!(746!==e&&747!==e&&(e<4352||!(yc["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||yc["CJK Compatibility"](e)||yc["CJK Strokes"](e)||!(!yc["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||yc["Enclosed CJK Letters and Months"](e)||yc["Ideographic Description Characters"](e)||yc.Kanbun(e)||yc.Katakana(e)&&12540!==e||!(!yc["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)||!(!yc["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||yc["Vertical Forms"](e)||yc["Yijing Hexagram Symbols"](e)||/\p{sc=Cans}/u.test(String.fromCodePoint(e))||/\p{sc=Hang}/u.test(String.fromCodePoint(e))||Ic.test(String.fromCodePoint(e)))))}function Ec(e){return!(Mc(e)||function(e){return!!(yc["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||yc["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)||yc["Letterlike Symbols"](e)||yc["Number Forms"](e)||yc["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)||yc["Control Pictures"](e)&&9251!==e||yc["Optical Character Recognition"](e)||yc["Enclosed Alphanumerics"](e)||yc["Geometric Shapes"](e)||yc["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||yc["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||yc["CJK Symbols and Punctuation"](e)||yc.Katakana(e)||yc["Private Use Area"](e)||yc["CJK Compatibility Forms"](e)||yc["Small Form Variants"](e)||yc["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 Ac=bc(["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 zc(e){return Ac.test(String.fromCodePoint(e))}function kc(e,s){return!(!s&&zc(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||yc.Khmer(e))}function Dc(e){for(const s of e)if(zc(s.charCodeAt(0)))return!0;return!1}const Rc=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(Rc.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 h=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([l,h]),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 Ps{constructor(e,s){this.isSupportedScript=Lc,this.zoom=e,s?(this.now=s.now||0,this.fadeDuration=s.fadeDuration||0,this.zoomHistory=s.zoomHistory||new ds,this.transition=s.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ds,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,s=e-Math.floor(e),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}}}function Lc(e){return function(e,s){for(const a of e)if(!kc(a.charCodeAt(0),s))return!1;return!0}(e,"loaded"===Rc.getRTLTextPluginStatus())}class Es{constructor(e,s,a){this.property=e,this.value=s,this.expression=function(e,s,a){if(so(e))return new oi(e,s);if(ta(e)){const l=el(e,s,a);if("error"===l.result)throw new Error(l.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return l.value}{let a=e;return"color"===s.type&&"string"==typeof e?a=Ie.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=Te.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>a}}}(void 0===s?e.specification.default:s,e.specification,a)}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 Ts{constructor(e,s){this.property=e,this.value=new Es(e,void 0,s)}transitioned(e,s){return new Vs(this.property,this.value,s,Pt({},e.transition,this.transition),e.now)}untransitioned(){return new Vs(this.property,this.value,null,{},0)}}class Bs{constructor(e,s){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=s}getValue(e){return At(this._values[e].value.value)}setValue(e,s){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ts(this._values[e].property,this._globalState)),this._values[e].value=new Es(this._values[e].property,null===s?void 0:At(s),this._globalState)}getTransition(e){return At(this._values[e].transition)}setTransition(e,s){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ts(this._values[e].property,this._globalState)),this._values[e].transition=At(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 Fs(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 Fs(this._properties);for(const s of Object.keys(this._values))e._values[s]=this._values[s].untransitioned();return e}}class Vs{constructor(e,s,a,l,h){this.property=e,this.value=s,this.begin=h+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,h=this.value.possiblyEvaluate(e,s,a),p=this.prior;if(p){if(l>this.end)return this.prior=null,h;if(this.value.isDataDriven())return this.prior=null,h;if(ll.zoomHistory.lastIntegerZoom?{from:e,to:s}:{from:a,to:s}}interpolate(e){return e}}class js{constructor(e){this.specification=e}possiblyEvaluate(e,s,a,l){if(void 0!==e.value){if("constant"===e.expression.kind){const h=e.expression.evaluate(s,null,{},a,l);return this._calculate(h,h,h,s)}return this._calculate(e.expression.evaluate(new Ps(Math.floor(s.zoom-1),s)),e.expression.evaluate(new Ps(Math.floor(s.zoom),s)),e.expression.evaluate(new Ps(Math.floor(s.zoom+1),s)),s)}}_calculate(e,s,a,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:s}:{from:a,to:s}}interpolate(e){return e}}class Ns{constructor(e){this.specification=e}possiblyEvaluate(e,s,a,l){return!!e.expression.evaluate(s,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 s in e){const a=e[s];a.specification.overridable&&this.overridableProperties.push(s);const l=this.defaultPropertyValues[s]=new Es(a,void 0,void 0),h=this.defaultTransitionablePropertyValues[s]=new Ts(a,void 0);this.defaultTransitioningPropertyValues[s]=h.untransitioned(),this.defaultPossiblyEvaluatedValues[s]=l.possiblyEvaluate({})}}}uc("DataDrivenProperty",Rs),uc("DataConstantProperty",Os),uc("CrossFadedDataDrivenProperty",Us),uc("CrossFadedProperty",js),uc("ColorRampProperty",Ns);const Fc="-transition";class Xs extends xt{constructor(e,s,a){if(super(),this.id=e.id,this.type=e.type,this._globalState=a,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=al(e.filter,a)),s.layout&&(this._unevaluatedLayout=new Ds(s.layout,a)),s.paint)){this._transitionablePaint=new Bs(s.paint,a);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 Ls(s.paint)}}setFilter(e){this.filter=e,this._featureFilter=al(e,this._globalState)}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}getPaintAffectingGlobalStateRefs(){var e;const s=new globalThis.Map;if(this._transitionablePaint)for(const a in this._transitionablePaint._values){const l=this._transitionablePaint._values[a].value;for(const h of l.getGlobalStateRefs()){const p=null!==(e=s.get(h))&&void 0!==e?e:[];p.push({name:a,value:l.value}),s.set(h,p)}}return s}setLayoutProperty(e,s,a={}){null!=s&&this._validate(lc,`layers.${this.id}.layout.${e}`,e,s,a)||("visibility"!==e?this._unevaluatedLayout.setValue(e,s):this.visibility=s)}getPaintProperty(e){return e.endsWith(Fc)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,s,a={}){if(null!=s&&this._validate(ac,`layers.${this.id}.paint.${e}`,e,s,a))return!1;if(e.endsWith(Fc))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"],h=a.value.isDataDriven(),p=a.value;this._transitionablePaint.setValue(e,s),this._handleSpecialPaintPropertyUpdate(e);const f=this._transitionablePaint._values[e].value;return f.isDataDriven()||h||l||this._handleOverridablePaintPropertyUpdate(e,p,f)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,s,a){return!1}isHidden(e,s=!1){return!!(this.minzoom&&e<(s?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&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),Ct(e,((e,s)=>!(void 0===e||"layout"===s&&!Object.keys(e).length||"paint"===s&&!Object.keys(e).length)))}_validate(e,s,a,l,h={}){return(!h||!1!==h.validate)&&cc(this,e.call(nc,{key:s,layerType:this.type,objectKey:a,value:l,styleSpec:Se,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 $s&&eo(s.property.specification)&&("source"===s.value.kind||"composite"===s.value.kind)&&s.value.isStateDependent)return!0}return!1}}let Oc;var jc={get paint(){return Oc=Oc||new qs({"raster-opacity":new Os(Se.paint_raster["raster-opacity"]),"raster-hue-rotate":new Os(Se.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Os(Se.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Os(Se.paint_raster["raster-brightness-max"]),"raster-saturation":new Os(Se.paint_raster["raster-saturation"]),"raster-contrast":new Os(Se.paint_raster["raster-contrast"]),"raster-resampling":new Os(Se.paint_raster["raster-resampling"]),"raster-fade-duration":new Os(Se.paint_raster["raster-fade-duration"])})}};class Hs extends Xs{constructor(e,s){super(e,jc,s)}}const Vc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Js{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 Ws{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 Nc(e,s=1){let a=0,l=0;return{members:e.map((e=>{const h=Vc[e.type].BYTES_PER_ELEMENT,p=a=Uc(a,Math.max(s,h)),f=e.components||1;return l=Math.max(l,h),a+=h*f,{name:e.name,type:e.type,components:f,offset:p}})),size:Uc(a,Math.max(l,s)),alignment:s}}function Uc(e,s){return Math.ceil(e/s)*s}class ea extends Ws{_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}}ea.prototype.bytesPerElement=4,uc("StructArrayLayout2i4",ea);class ra extends Ws{_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 h=3*e;return this.int16[h+0]=s,this.int16[h+1]=a,this.int16[h+2]=l,e}}ra.prototype.bytesPerElement=6,uc("StructArrayLayout3i6",ra);class na extends Ws{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,s,a,l)}emplace(e,s,a,l,h){const p=4*e;return this.int16[p+0]=s,this.int16[p+1]=a,this.int16[p+2]=l,this.int16[p+3]=h,e}}na.prototype.bytesPerElement=8,uc("StructArrayLayout4i8",na);class ia extends Ws{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,h,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,a,l,h,p)}emplace(e,s,a,l,h,p,f){const m=6*e;return this.int16[m+0]=s,this.int16[m+1]=a,this.int16[m+2]=l,this.int16[m+3]=h,this.int16[m+4]=p,this.int16[m+5]=f,e}}ia.prototype.bytesPerElement=12,uc("StructArrayLayout2i4i12",ia);class sa extends Ws{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,h,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,a,l,h,p)}emplace(e,s,a,l,h,p,f){const m=4*e,_=8*e;return this.int16[m+0]=s,this.int16[m+1]=a,this.uint8[_+4]=l,this.uint8[_+5]=h,this.uint8[_+6]=p,this.uint8[_+7]=f,e}}sa.prototype.bytesPerElement=8,uc("StructArrayLayout2i4ub8",sa);class aa extends Ws{_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}}aa.prototype.bytesPerElement=8,uc("StructArrayLayout2f8",aa);class oa extends Ws{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,h,p,f,m,_,x){const v=this.length;return this.resize(v+1),this.emplace(v,e,s,a,l,h,p,f,m,_,x)}emplace(e,s,a,l,h,p,f,m,_,x,v){const b=10*e;return this.uint16[b+0]=s,this.uint16[b+1]=a,this.uint16[b+2]=l,this.uint16[b+3]=h,this.uint16[b+4]=p,this.uint16[b+5]=f,this.uint16[b+6]=m,this.uint16[b+7]=_,this.uint16[b+8]=x,this.uint16[b+9]=v,e}}oa.prototype.bytesPerElement=20,uc("StructArrayLayout10ui20",oa);class la extends Ws{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,h,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,e,s,a,l,h,p,f,m)}emplace(e,s,a,l,h,p,f,m,_){const x=8*e;return this.uint16[x+0]=s,this.uint16[x+1]=a,this.uint16[x+2]=l,this.uint16[x+3]=h,this.uint16[x+4]=p,this.uint16[x+5]=f,this.uint16[x+6]=m,this.uint16[x+7]=_,e}}la.prototype.bytesPerElement=16,uc("StructArrayLayout8ui16",la);class ua extends Ws{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,h,p,f,m,_,x,v,b){const w=this.length;return this.resize(w+1),this.emplace(w,e,s,a,l,h,p,f,m,_,x,v,b)}emplace(e,s,a,l,h,p,f,m,_,x,v,b,w){const T=12*e;return this.int16[T+0]=s,this.int16[T+1]=a,this.int16[T+2]=l,this.int16[T+3]=h,this.uint16[T+4]=p,this.uint16[T+5]=f,this.uint16[T+6]=m,this.uint16[T+7]=_,this.int16[T+8]=x,this.int16[T+9]=v,this.int16[T+10]=b,this.int16[T+11]=w,e}}ua.prototype.bytesPerElement=24,uc("StructArrayLayout4i4ui4i24",ua);class ca extends Ws{_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 h=3*e;return this.float32[h+0]=s,this.float32[h+1]=a,this.float32[h+2]=l,e}}ca.prototype.bytesPerElement=12,uc("StructArrayLayout3f12",ca);class ha extends Ws{_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}}ha.prototype.bytesPerElement=4,uc("StructArrayLayout1ul4",ha);class pa extends Ws{_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,h,p,f,m,_){const x=this.length;return this.resize(x+1),this.emplace(x,e,s,a,l,h,p,f,m,_)}emplace(e,s,a,l,h,p,f,m,_,x){const v=10*e,b=5*e;return this.int16[v+0]=s,this.int16[v+1]=a,this.int16[v+2]=l,this.int16[v+3]=h,this.int16[v+4]=p,this.int16[v+5]=f,this.uint32[b+3]=m,this.uint16[v+8]=_,this.uint16[v+9]=x,e}}pa.prototype.bytesPerElement=20,uc("StructArrayLayout6i1ul2ui20",pa);class fa extends Ws{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,h,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,a,l,h,p)}emplace(e,s,a,l,h,p,f){const m=6*e;return this.int16[m+0]=s,this.int16[m+1]=a,this.int16[m+2]=l,this.int16[m+3]=h,this.int16[m+4]=p,this.int16[m+5]=f,e}}fa.prototype.bytesPerElement=12,uc("StructArrayLayout2i2i2i12",fa);class da extends Ws{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,s,a,l,h)}emplace(e,s,a,l,h,p){const f=4*e,m=8*e;return this.float32[f+0]=s,this.float32[f+1]=a,this.float32[f+2]=l,this.int16[m+6]=h,this.int16[m+7]=p,e}}da.prototype.bytesPerElement=16,uc("StructArrayLayout2f1f2i16",da);class ya extends Ws{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,h,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,a,l,h,p)}emplace(e,s,a,l,h,p,f){const m=16*e,_=4*e,x=8*e;return this.uint8[m+0]=s,this.uint8[m+1]=a,this.float32[_+1]=l,this.float32[_+2]=h,this.int16[x+6]=p,this.int16[x+7]=f,e}}ya.prototype.bytesPerElement=16,uc("StructArrayLayout2ub2f2i16",ya);class ma extends Ws{_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 h=3*e;return this.uint16[h+0]=s,this.uint16[h+1]=a,this.uint16[h+2]=l,e}}ma.prototype.bytesPerElement=6,uc("StructArrayLayout3ui6",ma);class ga extends Ws{_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,h,p,f,m,_,x,v,b,w,T,P,M,E){const z=this.length;return this.resize(z+1),this.emplace(z,e,s,a,l,h,p,f,m,_,x,v,b,w,T,P,M,E)}emplace(e,s,a,l,h,p,f,m,_,x,v,b,w,T,P,M,E,z){const k=24*e,L=12*e,F=48*e;return this.int16[k+0]=s,this.int16[k+1]=a,this.uint16[k+2]=l,this.uint16[k+3]=h,this.uint32[L+2]=p,this.uint32[L+3]=f,this.uint32[L+4]=m,this.uint16[k+10]=_,this.uint16[k+11]=x,this.uint16[k+12]=v,this.float32[L+7]=b,this.float32[L+8]=w,this.uint8[F+36]=T,this.uint8[F+37]=P,this.uint8[F+38]=M,this.uint32[L+10]=E,this.int16[k+22]=z,e}}ga.prototype.bytesPerElement=48,uc("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ga);class xa extends Ws{_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,h,p,f,m,_,x,v,b,w,T,P,M,E,z,k,L,F,B,j,V,N,U,G,Z){const nt=this.length;return this.resize(nt+1),this.emplace(nt,e,s,a,l,h,p,f,m,_,x,v,b,w,T,P,M,E,z,k,L,F,B,j,V,N,U,G,Z)}emplace(e,s,a,l,h,p,f,m,_,x,v,b,w,T,P,M,E,z,k,L,F,B,j,V,N,U,G,Z,nt){const st=32*e,at=16*e;return this.int16[st+0]=s,this.int16[st+1]=a,this.int16[st+2]=l,this.int16[st+3]=h,this.int16[st+4]=p,this.int16[st+5]=f,this.int16[st+6]=m,this.int16[st+7]=_,this.uint16[st+8]=x,this.uint16[st+9]=v,this.uint16[st+10]=b,this.uint16[st+11]=w,this.uint16[st+12]=T,this.uint16[st+13]=P,this.uint16[st+14]=M,this.uint16[st+15]=E,this.uint16[st+16]=z,this.uint16[st+17]=k,this.uint16[st+18]=L,this.uint16[st+19]=F,this.uint16[st+20]=B,this.uint16[st+21]=j,this.uint16[st+22]=V,this.uint32[at+12]=N,this.float32[at+13]=U,this.float32[at+14]=G,this.uint16[st+30]=Z,this.uint16[st+31]=nt,e}}xa.prototype.bytesPerElement=64,uc("StructArrayLayout8i15ui1ul2f2ui64",xa);class va extends Ws{_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}}va.prototype.bytesPerElement=4,uc("StructArrayLayout1f4",va);class ba extends Ws{_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 h=3*e;return this.uint16[6*e+0]=s,this.float32[h+1]=a,this.float32[h+2]=l,e}}ba.prototype.bytesPerElement=12,uc("StructArrayLayout1ui2f12",ba);class wa extends Ws{_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 h=4*e;return this.uint32[2*e+0]=s,this.uint16[h+2]=a,this.uint16[h+3]=l,e}}wa.prototype.bytesPerElement=8,uc("StructArrayLayout1ul2ui8",wa);class _a extends Ws{_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}}_a.prototype.bytesPerElement=4,uc("StructArrayLayout2ui4",_a);class Sa extends Ws{_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}}Sa.prototype.bytesPerElement=2,uc("StructArrayLayout1ui2",Sa);class Aa extends Ws{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,a,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,s,a,l)}emplace(e,s,a,l,h){const p=4*e;return this.float32[p+0]=s,this.float32[p+1]=a,this.float32[p+2]=l,this.float32[p+3]=h,e}}Aa.prototype.bytesPerElement=16,uc("StructArrayLayout4f16",Aa);class ka extends Js{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)}}ka.prototype.size=20;class Ma extends pa{get(e){return new ka(this,e)}}uc("CollisionBoxArray",Ma);class Ia extends Js{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]}}Ia.prototype.size=48;class za extends ga{get(e){return new Ia(this,e)}}uc("PlacedSymbolArray",za);class Pa extends Js{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Pa.prototype.size=64;class Ca extends xa{get(e){return new Pa(this,e)}}uc("SymbolInstanceArray",Ca);class Ea extends va{getoffsetX(e){return this.float32[1*e+0]}}uc("GlyphOffsetArray",Ea);class Ta extends ra{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}uc("SymbolLineVertexArray",Ta);class Ba extends Js{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]}}Ba.prototype.size=12;class Va extends ba{get(e){return new Ba(this,e)}}uc("TextAnchorOffsetArray",Va);class Fa extends Js{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]}}Fa.prototype.size=8;class Da extends wa{get(e){return new Fa(this,e)}}uc("FeatureIndexArray",Da);class $a extends ea{}class La extends ea{}class Oa extends ea{}class Ra extends ia{}class Ua extends sa{}class ja extends aa{}class Na extends oa{}class qa extends la{}class Ga extends ua{}class Xa extends ca{}class Za extends ha{}class Ya extends fa{}class Ha extends ya{}class Ka extends ma{}class Ja extends _a{}const $c=Nc([{name:"a_pos",components:2,type:"Int16"}],4),{members:Gc}=$c;class to{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,s,a,l){const h=this.segments[this.segments.length-1];return e>to.MAX_VERTEX_ARRAY_LENGTH&&jt(`Max vertices per segment is ${to.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${to.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!h||h.vertexLength+e>to.MAX_VERTEX_ARRAY_LENGTH||h.sortKey!==l?this.createNewSegment(s,a,l):h}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 to([{vertexOffset:e,primitiveOffset:s,vertexLength:a,primitiveLength:l,vaos:{},sortKey:0}])}}function Zc(e,s){return 256*(e=vt(Math.floor(e),0,255))+vt(Math.floor(s),0,255)}to.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,uc("SegmentVector",to);const qc=Nc([{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"}]),Wc=Nc([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var Hc,Xc,Yc,Kc={exports:{}},Jc={exports:{}},Qc={exports:{}},th=function(){if(Yc)return Kc.exports;Yc=1;var e=(Hc||(Hc=1,Jc.exports=function(e,s){var a,l,h,p,f,m,_,x;for(l=e.length-(a=3&e.length),h=s,f=3432918353,m=461845907,x=0;x>>16)*f&65535)<<16)&4294967295)<<15|_>>>17))*m+(((_>>>16)*m&65535)<<16)&4294967295)<<13|h>>>19))+((5*(h>>>16)&65535)<<16)&4294967295))+((58964+(p>>>16)&65535)<<16);switch(_=0,a){case 3:_^=(255&e.charCodeAt(x+2))<<16;case 2:_^=(255&e.charCodeAt(x+1))<<8;case 1:h^=_=(65535&(_=(_=(65535&(_^=255&e.charCodeAt(x)))*f+(((_>>>16)*f&65535)<<16)&4294967295)<<15|_>>>17))*m+(((_>>>16)*m&65535)<<16)&4294967295}return h^=e.length,h=2246822507*(65535&(h^=h>>>16))+((2246822507*(h>>>16)&65535)<<16)&4294967295,h=3266489909*(65535&(h^=h>>>13))+((3266489909*(h>>>16)&65535)<<16)&4294967295,(h^=h>>>16)>>>0}),Jc.exports),s=(Xc||(Xc=1,Qc.exports=function(e,s){for(var a,l=e.length,h=s^l,p=0;l>=4;)a=1540483477*(65535&(a=255&e.charCodeAt(p)|(255&e.charCodeAt(++p))<<8|(255&e.charCodeAt(++p))<<16|(255&e.charCodeAt(++p))<<24))+((1540483477*(a>>>16)&65535)<<16),h=1540483477*(65535&h)+((1540483477*(h>>>16)&65535)<<16)^(a=1540483477*(65535&(a^=a>>>24))+((1540483477*(a>>>16)&65535)<<16)),l-=4,++p;switch(l){case 3:h^=(255&e.charCodeAt(p+2))<<16;case 2:h^=(255&e.charCodeAt(p+1))<<8;case 1:h=1540483477*(65535&(h^=255&e.charCodeAt(p)))+((1540483477*(h>>>16)&65535)<<16)}return h=1540483477*(65535&(h^=h>>>13))+((1540483477*(h>>>16)&65535)<<16),(h^=h>>>15)>>>0}),Qc.exports);return Kc.exports=e,Kc.exports.murmur3=e,Kc.exports.murmur2=s,Kc.exports}(),eh=h(th);class po{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,s,a,l){this.ids.push(ih(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=ih(e);let a=0,l=this.ids.length-1;for(;a>1;this.ids[e]>=s?l=e:a=e+1}const h=[];for(;this.ids[a]===s;)h.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return h}static serialize(e,s){const a=new Float64Array(e.ids),l=new Uint32Array(e.positions);return rh(a,l,0,a.length-1),s&&s.push(a.buffer,l.buffer),{ids:a,positions:l}}static deserialize(e){const s=new po;return s.ids=e.ids,s.positions=e.positions,s.indexed=!0,s}}function ih(e){const s=+e;return!isNaN(s)&&s<=Number.MAX_SAFE_INTEGER?s:eh(String(e))}function rh(e,s,a,l){for(;a>1];let p=a-1,f=l+1;for(;;){do{p++}while(e[p]h);if(p>=f)break;nh(e,p,f),nh(s,3*p,3*f),nh(s,3*p+1,3*f+1),nh(s,3*p+2,3*f+2)}f-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 bo(e,s):new xo(e,s)}}class Ao{constructor(e,s){this.uniformNames=s.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,s){this.pixelRatioFrom=s.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=s.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,s){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,s.y,s.height,s.width]}setUniform(e,s,a,l){let h=null;"u_pattern_to"===l?h=this.patternTo:"u_pattern_from"===l?h=this.patternFrom:"u_dasharray_to"===l?h=this.dashTo:"u_dasharray_from"===l?h=this.dashFrom:"u_pixel_ratio_to"===l?h=this.pixelRatioTo:"u_pixel_ratio_from"===l&&(h=this.pixelRatioFrom),null!==h&&e.set(h)}getBinding(e,s,a){return"u_pattern"===a.substr(0,9)||"u_dasharray_"===a.substr(0,12)?new vo(e,s):new xo(e,s)}}class ko{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){const l=this.paintVertexArray.length,h=this.expression.evaluate(new Ps(0,a),s,{},a.canonical,[],a.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(l,e,h)}updatePaintArray(e,s,a,l,h){const p=this.expression.evaluate(new Ps(0,h),a,l);this._setPaintValue(e,s,p)}_setPaintValue(e,s,a){if("color"===this.type){const l=oh(a);for(let a=e;a`u_${e}_t`)),this.type=a,this.useIntegerZoom=l,this.zoom=h,this.maxValue=0,this.paintVertexAttributes=s.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===a?4:2,offset:0}))),this.paintVertexArray=new p}populatePaintArray(e,s,a){const l=this.expression.evaluate(new Ps(this.zoom,a),s,{},a.canonical,[],a.formattedSection),h=this.expression.evaluate(new Ps(this.zoom+1,a),s,{},a.canonical,[],a.formattedSection),p=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(p,e,l,h)}updatePaintArray(e,s,a,l,h){const p=this.expression.evaluate(new Ps(this.zoom,h),a,l),f=this.expression.evaluate(new Ps(this.zoom+1,h),a,l);this._setPaintValue(e,s,p,f)}_setPaintValue(e,s,a,l){if("color"===this.type){const h=oh(a),p=oh(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 ko||a instanceof Mo)for(let s=0;s!0){this.programConfigurations={};for(const l of e)this.programConfigurations[l.id]=new Co(l,s,a);this.needsUpload=!1,this._featureMap=new po,this._bufferOffset=0}populatePaintArrays(e,s,a,l){for(const a in this.programConfigurations)this.programConfigurations[a].populatePaintArrays(e,s,l);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 h of a)this.needsUpload=this.programConfigurations[h.id].updatePaintArrays(e,this._featureMap,s,h,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 ah(e,s){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${s}-`,"").replace(/-/g,"_")]}function hh(e,s,a){const l={color:{source:aa,composite:Aa},number:{source:va,composite:aa}},h=function(e){return{"line-pattern":{source:Na,composite:Na},"fill-pattern":{source:Na,composite:Na},"fill-extrusion-pattern":{source:Na,composite:Na},"line-dasharray":{source:qa,composite:qa}}[e]}(e);return h&&h[a]||l[s][a]}uc("ConstantBinder",So),uc("CrossFadedConstantBinder",Ao),uc("SourceExpressionBinder",ko),uc("CrossFadedPatternBinder",zo),uc("CrossFadedDasharrayBinder",Po),uc("CompositeExpressionBinder",Mo),uc("ProgramConfiguration",Co,{omit:["_buffers"]}),uc("ProgramConfigurationSet",Eo);const ph=Math.pow(2,14)-1,fh=-ph-1;function mh(e){const s=at/e.extent,a=e.loadGeometry();for(let e=0;ea.x+1||pa.y+1)&&jt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return a}function _h(e,s){return{type:e.type,id:e.id,properties:e.properties,geometry:s?mh(e):[]}}const gh=-32768;function wh(e,s,a,l,h){e.emplaceBack(gh+8*s+l,gh+8*a+h)}class Ro{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new La,this.indexArray=new Ka,this.segments=new to,this.programConfigurations=new Eo(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],h=[];let p=null,f=!1,m="heatmap"===l.type;if("circle"===l.type){const e=l;p=e.layout.get("circle-sort-key"),f=!p.isConstant(),m=m||"map"===e.paint.get("circle-pitch-alignment")}const _=m?s.subdivisionGranularity.circle:1;for(const{feature:s,id:l,index:m,sourceLayerIndex:_}of e){const e=this.layers[0]._featureFilter.needGeometry,x=_h(s,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),x,a))continue;const v=f?p.evaluate(x,{},a):void 0,b={id:l,properties:s.properties,type:s.type,sourceLayerIndex:_,index:m,geometry:e?x.geometry:mh(s),patterns:{},sortKey:v};h.push(b)}f&&h.sort(((e,s)=>e.sortKey-s.sortKey));for(const l of h){const{geometry:h,index:p,sourceLayerIndex:f}=l,m=e[p].feature;this.addFeature(l,h,p,a,_),s.featureIndex.insert(m,h,p,f,this.index)}}update(e,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:a})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Gc),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,h=1){let p;switch(h){case 1:p=[0,7];break;case 3:p=[0,2,5,7];break;case 5:p=[0,1,3,4,6,7];break;case 7:p=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${h}; valid values are 1, 3, 5, 7.`)}const f=p.length;for(const a of s)for(const s of a){const a=s.x,l=s.y;if(a<0||a>=at||l<0||l>=at)continue;const h=this.segments.prepareSegment(f*f,this.layoutVertexArray,this.indexArray,e.sortKey),m=h.vertexLength;for(let e=0;e1){if(Ch(e,s))return!0;for(let l=0;l1?a:a.sub(s)._mult(h)._add(s))}function Dh(e,s){let a,l,h,p=!1;for(let f=0;fs.y!=h.y>s.y&&s.x<(h.x-l.x)*(s.y-l.y)/(h.y-l.y)+l.x&&(p=!p)}return p}function jh(e,s){let a=!1;for(let l=0,h=e.length-1;ls.y!=f.y>s.y&&s.x<(f.x-p.x)*(s.y-p.y)/(f.y-p.y)+p.x&&(a=!a)}return a}function Nh(e,s,a){const l=a[0],h=a[2];if(e.xh.x&&s.x>h.x||e.yh.y&&s.y>h.y)return!1;const p=Nt(e,s,a[0]);return p!==Nt(e,s,a[1])||p!==Nt(e,s,a[2])||p!==Nt(e,s,a[3])}function $h(e,s,a){const l=s.paint.get(e).value;return"constant"===l.kind?l.value:a.programConfigurations.get(s.id).getMaxValue(e)}function Zh(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function qh(e,s,a,h,p){if(!s[0]&&!s[1])return e;const f=l.convert(s)._mult(p);"viewport"===a&&f._rotate(-h);const m=[];for(let s=0;sJh(e,s,a,l)))}(_,h,f,m),T=x),Kh({queryGeometry:w,size:T,transform:h,unwrappedTileID:f,getElevation:m,pitchAlignment:b,pitchScale:v},l)}}class hl extends Ro{}let iu;uc("HeatmapBucket",hl,{omit:["layers"]});var ru={get paint(){return iu=iu||new qs({"heatmap-radius":new Rs(Se.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Rs(Se.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Os(Se.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Ns(Se.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Os(Se.paint_heatmap["heatmap-opacity"])})}};function nu(e,{width:s,height:a},l,h){if(h){if(h instanceof Uint8ClampedArray)h=new Uint8Array(h.buffer);else if(h.length!==s*a*l)throw new RangeError(`mismatched image size. expected: ${h.length} but got: ${s*a*l}`)}else h=new Uint8Array(s*a*l);return e.width=s,e.height=a,e.data=h,e}function su(e,{width:s,height:a},l){if(s===e.width&&a===e.height)return;const h=nu({},{width:s,height:a},l);lu(e,h,{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=h.data}function lu(e,s,a,l,h,p){if(0===h.width||0===h.height)return s;if(h.width>e.width||h.height>e.height||a.x>e.width-h.width||a.y>e.height-h.height)throw new RangeError("out of range source coordinates for image copy");if(h.width>s.width||h.height>s.height||l.x>s.width-h.width||l.y>s.height-h.height)throw new RangeError("out of range destination coordinates for image copy");const f=e.data,m=s.data;if(f===m)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_{s[e.evaluationKey]=f;const m=e.expression.evaluate(s);h.setPixel(l/4/a,p/4,m)};if(e.clips)for(let s=0,h=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 gu(e,this.getUnpackVector())}getPixels(){return new xl({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,h=s*this.dim+this.dim,p=a*this.dim,f=a*this.dim+this.dim;switch(s){case-1:l=h-1;break;case 1:h=l+1}switch(a){case-1:p=f-1;break;case 1:f=p+1}const m=-s*this.dim,_=-a*this.dim;for(let s=p;s0)for(let h=s;h=s;h-=l)p=Ju(h/l|0,e[h],e[h+1],p);return p&&Gu(p,p.next)&&(Qu(p),p=p.next),p}function Su(e,s){if(!e)return e;s||(s=e);let a,l=e;do{if(a=!1,l.steiner||!Gu(l,l.next)&&0!==$u(l.prev,l,l.next))l=l.next;else{if(Qu(l),l=s=l.prev,l===l.next)break;a=!0}}while(a||l!==s);return s}function Mu(e,s,a,l,h,p,f){if(!e)return;!f&&p&&function(e,s,a,l){let h=e;do{0===h.z&&(h.z=Fu(h.x,h.y,s,a,l)),h.prevZ=h.prev,h.nextZ=h.next,h=h.next}while(h!==e);h.prevZ.nextZ=null,h.prevZ=null,function(e){let s,a=1;do{let l,h=e;e=null;let p=null;for(s=0;h;){s++;let f=h,m=0;for(let e=0;e0||_>0&&f;)0!==m&&(0===_||!f||h.z<=f.z)?(l=h,h=h.nextZ,m--):(l=f,f=f.nextZ,_--),p?p.nextZ=l:e=l,l.prevZ=p,p=l;h=f}p.nextZ=null,a*=2}while(s>1)}(h)}(e,l,h,p);let m=e;for(;e.prev!==e.next;){const _=e.prev,x=e.next;if(p?Eu(e,l,h,p):Cu(e))s.push(_.i,e.i,x.i),Qu(e),e=x.next,m=x.next;else if((e=x)===m){f?1===f?Mu(e=zu(Su(e),s),s,a,l,h,p,2):2===f&&ku(e,s,a,l,h,p):Mu(Su(e),s,a,l,h,p,1);break}}}function Cu(e){const s=e.prev,a=e,l=e.next;if($u(s,a,l)>=0)return!1;const h=s.x,p=a.x,f=l.x,m=s.y,_=a.y,x=l.y,v=Math.min(h,p,f),b=Math.min(m,_,x),w=Math.max(h,p,f),T=Math.max(m,_,x);let P=l.next;for(;P!==s;){if(P.x>=v&&P.x<=w&&P.y>=b&&P.y<=T&&Nu(h,m,p,_,f,x,P.x,P.y)&&$u(P.prev,P,P.next)>=0)return!1;P=P.next}return!0}function Eu(e,s,a,l){const h=e.prev,p=e,f=e.next;if($u(h,p,f)>=0)return!1;const m=h.x,_=p.x,x=f.x,v=h.y,b=p.y,w=f.y,T=Math.min(m,_,x),P=Math.min(v,b,w),M=Math.max(m,_,x),E=Math.max(v,b,w),z=Fu(T,P,s,a,l),k=Fu(M,E,s,a,l);let L=e.prevZ,F=e.nextZ;for(;L&&L.z>=z&&F&&F.z<=k;){if(L.x>=T&&L.x<=M&&L.y>=P&&L.y<=E&&L!==h&&L!==f&&Nu(m,v,_,b,x,w,L.x,L.y)&&$u(L.prev,L,L.next)>=0)return!1;if(L=L.prevZ,F.x>=T&&F.x<=M&&F.y>=P&&F.y<=E&&F!==h&&F!==f&&Nu(m,v,_,b,x,w,F.x,F.y)&&$u(F.prev,F,F.next)>=0)return!1;F=F.nextZ}for(;L&&L.z>=z;){if(L.x>=T&&L.x<=M&&L.y>=P&&L.y<=E&&L!==h&&L!==f&&Nu(m,v,_,b,x,w,L.x,L.y)&&$u(L.prev,L,L.next)>=0)return!1;L=L.prevZ}for(;F&&F.z<=k;){if(F.x>=T&&F.x<=M&&F.y>=P&&F.y<=E&&F!==h&&F!==f&&Nu(m,v,_,b,x,w,F.x,F.y)&&$u(F.prev,F,F.next)>=0)return!1;F=F.nextZ}return!0}function zu(e,s){let a=e;do{const l=a.prev,h=a.next.next;!Gu(l,h)&&Zu(l,a,a.next,h)&&Xu(l,h)&&Xu(h,l)&&(s.push(l.i,a.i,h.i),Qu(a),Qu(a.next),a=e=h),a=a.next}while(a!==e);return Su(a)}function ku(e,s,a,l,h,p){let f=e;do{let e=f.next.next;for(;e!==f.prev;){if(f.i!==e.i&&Uu(f,e)){let m=Ku(f,e);return f=Su(f,f.next),m=Su(m,m.next),Mu(f,s,a,l,h,p,0),void Mu(m,s,a,l,h,p,0)}e=e.next}f=f.next}while(f!==e)}function Du(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 Ru(e,s){const a=function(e,s){let a=s;const l=e.x,h=e.y;let p,f=-1/0;if(Gu(e,a))return a;do{if(Gu(e,a.next))return a.next;if(h<=a.y&&h>=a.next.y&&a.next.y!==a.y){const e=a.x+(h-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(e<=l&&e>f&&(f=e,p=a.x=a.x&&a.x>=_&&l!==a.x&&Vu(hp.x||a.x===p.x&&Lu(p,a)))&&(p=a,v=s)}a=a.next}while(a!==m);return p}(e,s);if(!a)return s;const l=Ku(a,e);return Su(l,l.next),Su(a,a.next)}function Lu(e,s){return $u(e.prev,e,s.prev)<0&&$u(s.next,e,e.next)<0}function Fu(e,s,a,l,h){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-a)*h|0)|e<<8))|e<<4))|e<<2))|e<<1))|(s=1431655765&((s=858993459&((s=252645135&((s=16711935&((s=(s-l)*h|0)|s<<8))|s<<4))|s<<2))|s<<1))<<1}function ju(e){let s=e,a=e;do{(s.x=(e-f)*(p-m)&&(e-f)*(l-m)>=(a-f)*(s-m)&&(a-f)*(p-m)>=(h-f)*(l-m)}function Nu(e,s,a,l,h,p,f,m){return!(e===f&&s===m)&&Vu(e,s,a,l,h,p,f,m)}function Uu(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&&Zu(a,a.next,e,s))return!0;a=a.next}while(a!==e);return!1}(e,s)&&(Xu(e,s)&&Xu(s,e)&&function(e,s){let a=e,l=!1;const h=(e.x+s.x)/2,p=(e.y+s.y)/2;do{a.y>p!=a.next.y>p&&a.next.y!==a.y&&h<(a.next.x-a.x)*(p-a.y)/(a.next.y-a.y)+a.x&&(l=!l),a=a.next}while(a!==e);return l}(e,s)&&($u(e.prev,e,s.prev)||$u(e,s.prev,s))||Gu(e,s)&&$u(e.prev,e,e.next)>0&&$u(s.prev,s,s.next)>0)}function $u(e,s,a){return(s.y-e.y)*(a.x-s.x)-(s.x-e.x)*(a.y-s.y)}function Gu(e,s){return e.x===s.x&&e.y===s.y}function Zu(e,s,a,l){const h=Hu($u(e,s,a)),p=Hu($u(e,s,l)),f=Hu($u(a,l,e)),m=Hu($u(a,l,s));return h!==p&&f!==m||!(0!==h||!qu(e,a,s))||!(0!==p||!qu(e,l,s))||!(0!==f||!qu(a,e,l))||!(0!==m||!qu(a,s,l))}function qu(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 Hu(e){return e>0?1:e<0?-1:0}function Xu(e,s){return $u(e.prev,e,e.next)<0?$u(e,s,e.next)>=0&&$u(e,e.prev,s)>=0:$u(e,s,e.prev)<0||$u(e,e.next,s)<0}function Ku(e,s){const a=td(e.i,e.x,e.y),l=td(s.i,s.x,s.y),h=e.next,p=s.prev;return e.next=s,s.prev=e,a.next=h,h.prev=a,l.next=a,a.prev=l,p.next=l,l.prev=p,l}function Ju(e,s,a,l){const h=td(e,s,a);return l?(h.next=l.next,h.prev=l,l.next.prev=h,l.next=h):(h.prev=h,h.next=h),h}function Qu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function td(e,s,a){return{i:e,x:s,y:a,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class au{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),h=this._getKey(a,l);if(this._vertexDictionary.has(h))return this._vertexDictionary.get(h);const p=this._vertexBuffer.length/2;return this._vertexDictionary.set(h,p),this._vertexBuffer.push(a,l),p}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,s){const a=[];for(let l=0;l0?(a.push(h),a.push(f),a.push(p)):(a.push(h),a.push(p),a.push(f))}return a}(this._vertexBuffer,e);const s=[],a=e.length;for(let l=0;l=1||L<=0)||M&&(mh)){x>=l&&x<=h&&p.push(a[(e+1)%3]);continue}!M&&k>0&&p.push(this._vertexToIndex(f+w*k,m+T*k));const F=f+w*Math.max(k,0),B=f+w*Math.min(L,1);P||this._generateIntraEdgeVertices(p,f,m,_,x,F,B),!M&&L<1&&p.push(this._vertexToIndex(f+w*L,m+T*L)),(M||x>=l&&x<=h)&&p.push(a[(e+1)%3]),!M&&(x<=l||x>=h)&&this._generateInterEdgeVertices(p,f,m,_,x,v,b,B,l,h)}return p}_generateIntraEdgeVertices(e,s,a,l,h,p,f){const m=l-s,_=h-a,x=0===_,v=x?Math.min(s,l):Math.min(p,f),b=x?Math.max(s,l):Math.max(p,f),w=Math.floor(v/this._granularityCellSize)+1,T=Math.ceil(b/this._granularityCellSize)-1;if(x?s=w;l--){const h=l*this._granularityCellSize;e.push(this._vertexToIndex(h,a+_*(h-s)/m))}}_generateInterEdgeVertices(e,s,a,l,h,p,f,m,_,x){const v=h-a,b=p-l,w=f-h,T=(_-h)/w,P=(x-h)/w,M=Math.min(T,P),E=Math.max(T,P),z=l+b*M;let k=Math.floor(Math.min(z,m)/this._granularityCellSize)+1,L=Math.ceil(Math.max(z,m)/this._granularityCellSize)-1,F=m=1||E<=0){const e=a-f,l=p+(s-p)*Math.min((_-f)/e,(x-f)/e);k=Math.floor(Math.min(l,m)/this._granularityCellSize)+1,L=Math.ceil(Math.max(l,m)/this._granularityCellSize)-1,F=m0?x:_;if(F)for(let s=k;s<=L;s++)e.push(this._vertexToIndex(s*this._granularityCellSize,j));else for(let s=L;s>=k;s--)e.push(this._vertexToIndex(s*this._granularityCellSize,j))}_generateOutline(e){const s=[];for(const a of e){const e=nd(a,this._granularity,!0),l=this._pointArrayToIndices(e),h=[];for(let e=1;eh!=(p===ed)?(e.push(s),e.push(a),e.push(this._vertexToIndex(l,p)),e.push(a),e.push(this._vertexToIndex(h,p)),e.push(this._vertexToIndex(l,p))):(e.push(a),e.push(s),e.push(this._vertexToIndex(l,p)),e.push(this._vertexToIndex(h,p)),e.push(a),e.push(this._vertexToIndex(l,p)))}_fillPoles(e,s,a){const l=this._vertexBuffer,h=at,p=e.length;for(let f=2;f80*a){m=e[0],_=e[1];let s=m,l=_;for(let p=a;ps&&(s=a),h>l&&(l=h)}x=Math.max(s-m,l-_),x=0!==x?32767/x:0}return Mu(p,f,a,m,_,x,0),f}(a,l),s=this._convertIndices(a,e);h=this._subdivideTrianglesScanline(s)}catch(e){console.error(e)}let p=[];return s&&(p=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(h),{verticesFlattened:this._vertexBuffer,indicesTriangles:h,indicesLineList:p}}_convertIndices(e,s){const a=[];for(let l=0;l0?(Math.floor(k/m)+1)*m:(Math.ceil(k/m)-1)*m,s=M>0?(Math.floor(L/m)+1)*m:(Math.ceil(L/m)-1)*m,a=Math.abs(k-e),h=Math.abs(L-s),p=Math.abs(k-v),f=Math.abs(L-b),x=w?a/E:Number.POSITIVE_INFINITY,F=T?h/z:Number.POSITIVE_INFINITY;if((p<=a||!w)&&(f<=h||!T))break;if(x=0?f-1:p-1,h=(m+1)%p,_=e[2*s[l]],x=e[2*s[h]],v=e[2*s[f]],b=e[2*s[f]+1],w=e[2*s[m]+1];let T=!1;if(_x)T=!1;else{const a=w-b,p=-(e[2*s[m]]-v),f=b((x-v)*a+(e[2*s[h]+1]-b)*p)*f&&(T=!0)}if(T){const e=s[l],h=s[f],_=s[m];e!==h&&e!==_&&h!==_&&a.push(_,h,e),f--,f<0&&(f=p-1)}else{const e=s[h],l=s[f],_=s[m];e!==l&&e!==_&&l!==_&&a.push(_,l,e),m++,m>=p&&(m=0)}if(l===h)break}}function od(e,s,a,l,h,p,f,m,_){const x=h.length/2,v=f&&m&&_;if(xto.MAX_VERTEX_ARRAY_LENGTH&&(x=e.createNewSegment(s,a),_=m.count,M=!0,E=!0,z=!0,v=0);const k=ad(f,l,p,m,w,M,x),L=ad(f,l,p,m,T,E,x),F=ad(f,l,p,m,P,z,x);a.emplaceBack(v+k-_,v+L-_,v+F-_),x.primitiveLength++}}(s,a,l,h,p,e),v&&function(e,s,a,l,h,p){const f=[];for(let e=0;eto.MAX_VERTEX_ARRAY_LENGTH&&(x=e.createNewSegment(s,a),_=m.count,P=!0,M=!0,v=0);const E=ad(f,l,p,m,h,P,x),z=ad(f,l,p,m,b,M,x);a.emplaceBack(v+E-_,v+z-_),x.primitiveLength++}}}(f,a,m,h,_,e),s.forceNewSegmentOnNextPrepare(),null==f||f.forceNewSegmentOnNextPrepare()}function ad(e,s,a,l,h,p,f){if(p){const p=l.count;return a(s[2*h],s[2*h+1]),e[h]=l.count,l.count++,f.vertexLength++,p}return e[h]}class mu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Oa,this.indexArray=new Ka,this.indexArray2=new Ja,this.programConfigurations=new Eo(e.layers,e.zoom),this.segments=new to,this.segments2=new to,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,a){this.hasDependencies=vu("fill",this.layers,s);const l=this.layers[0].layout.get("fill-sort-key"),h=!l.isConstant(),p=[];for(const{feature:f,id:m,index:_,sourceLayerIndex:x}of e){const e=this.layers[0]._featureFilter.needGeometry,v=_h(f,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),v,a))continue;const b=h?l.evaluate(v,{},a,s.availableImages):void 0,w={id:m,properties:f.properties,type:f.type,sourceLayerIndex:x,index:_,geometry:e?v.geometry:mh(f),patterns:{},sortKey:b};p.push(w)}h&&p.sort(((e,s)=>e.sortKey-s.sortKey));for(const l of p){const{geometry:h,index:p,sourceLayerIndex:f}=l;if(this.hasDependencies){const e=wu("fill",this.layers,l,{zoom:this.zoom},s);this.patternFeatures.push(e)}else this.addFeature(l,h,p,a,{},s.subdivisionGranularity);s.featureIndex.insert(e[p].feature,h,p,f,this.index)}}update(e,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions: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,xu),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,h,p){for(const e of Wn(s,500)){const s=rd(e,l,p.fill.getGranularityForZoomLevel(l.z)),a=this.layoutVertexArray;od(((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,{imagePositions:h,canonical:l})}}let ld,cd;uc("FillBucket",mu,{omit:["layers","patternFeatures"]});var hd={get paint(){return cd=cd||new qs({"fill-antialias":new Os(Se.paint_fill["fill-antialias"]),"fill-opacity":new Rs(Se.paint_fill["fill-opacity"]),"fill-color":new Rs(Se.paint_fill["fill-color"]),"fill-outline-color":new Rs(Se.paint_fill["fill-outline-color"]),"fill-translate":new Os(Se.paint_fill["fill-translate"]),"fill-translate-anchor":new Os(Se.paint_fill["fill-translate-anchor"]),"fill-pattern":new Us(Se.paint_fill["fill-pattern"])})},get layout(){return ld=ld||new qs({"fill-sort-key":new Rs(Se.layout_fill["fill-sort-key"])})}};class bu extends Xs{constructor(e,s){super(e,hd,s)}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 mu(e)}queryRadius(){return Zh(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:s,transform:a,pixelsToTileUnits:l}){return Ih(qh(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-a.bearingInRadians,l),s)}isTileClipped(){return!0}}const ud=Nc([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),dd=Nc([{name:"a_centroid",components:2,type:"Int16"}],4),{members:pd}=ud;class Au{constructor(e,s,a,l,h){this.properties={},this.extent=a,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=l,this._values=h,e.readFields(fd,this,s)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const s=e.readVarint()+e.pos,a=[];let h,p=1,f=0,m=0,_=0;for(;e.pos>3}if(f--,1===p||2===p)m+=e.readSVarint(),_+=e.readSVarint(),1===p&&(h&&a.push(h),h=[]),h&&h.push(new l(m,_));else{if(7!==p)throw new Error(`unknown command ${p}`);h&&h.push(h[0].clone())}}return h&&a.push(h),a}bbox(){const e=this._pbf;e.pos=this._geometry;const s=e.readVarint()+e.pos;let a=1,l=0,h=0,p=0,f=1/0,m=-1/0,_=1/0,x=-1/0;for(;e.pos>3}if(l--,1===a||2===a)h+=e.readSVarint(),p+=e.readSVarint(),hm&&(m=h),p<_&&(_=p),p>x&&(x=p);else if(7!==a)throw new Error(`unknown command ${a}`)}return[f,_,m,x]}toGeoJSON(e,s,a){const l=this.extent*Math.pow(2,a),h=this.extent*e,p=this.extent*s,f=this.loadGeometry();function m(e){return[360*(e.x+h)/l-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+p)/l)*Math.PI))-90]}function _(e){return e.map(m)}let x;if(1===this.type){const e=[];for(const s of f)e.push(s[0]);const s=_(e);x=1===e.length?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s}}else if(2===this.type){const e=f.map(_);x=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,h;for(let p=0;p=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 Au(this._pbf,s,this.extent,this._keys,this._values)}}function _d(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 Pu{constructor(e,s){this.layers=e.readFields(gd,{},s)}}function gd(e,s,a){if(3===e){const e=new Iu(a,a.readVarint()+a.pos);e.length&&(s[e.name]=e)}}const yd=Math.pow(2,13);function xd(e,s,a,l,h,p,f,m){e.emplaceBack(s,a,2*Math.floor(l*yd)+f,h*yd*2,p*yd*2,Math.round(m))}class Bu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Ra,this.centroidVertexArray=new $a,this.indexArray=new Ka,this.programConfigurations=new Eo(e.layers,e.zoom),this.segments=new to,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,a){this.features=[],this.hasDependencies=vu("fill-extrusion",this.layers,s);for(const{feature:l,id:h,index:p,sourceLayerIndex:f}of e){const e=this.layers[0]._featureFilter.needGeometry,m=_h(l,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),m,a))continue;const _={id:h,sourceLayerIndex:f,index:p,geometry:e?m.geometry:mh(l),properties:l.properties,type:l.type,patterns:{}};this.hasDependencies?this.features.push(wu("fill-extrusion",this.layers,_,{zoom:this.zoom},s)):this.addFeature(_,_.geometry,p,a,{},s.subdivisionGranularity),s.featureIndex.insert(l,_.geometry,p,f,this.index,!0)}}addFeatures(e,s,a){for(const l of this.features){const{geometry:h}=l;this.addFeature(l,h,l.index,s,a,e.subdivisionGranularity)}}update(e,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions: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,pd),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,dd.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,h,p){for(const a of Wn(s,500)){const s={x:0,y:0,sampleCount:0},h=this.layoutVertexArray.length;this.processPolygon(s,l,e,a,p);const f=this.layoutVertexArray.length-h,m=Math.floor(s.x/s.sampleCount),_=Math.floor(s.y/s.sampleCount);for(let e=0;e{xd(x,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;lto.MAX_VERTEX_ARRAY_LENGTH&&(s.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const f=h.sub(p)._perp()._unit(),m=p.dist(h);a+m>32768&&(a=0),xd(this.layoutVertexArray,h.x,h.y,f.x,f.y,0,0,a),xd(this.layoutVertexArray,h.x,h.y,f.x,f.y,0,1,a),a+=m,xd(this.layoutVertexArray,p.x,p.y,f.x,f.y,0,0,a),xd(this.layoutVertexArray,p.x,p.y,f.x,f.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 vd(e,s){for(let a=0;aat)||e.y===s.y&&(e.y<0||e.y>at)}function wd(e){return e.every((e=>e.x<0))||e.every((e=>e.x>at))||e.every((e=>e.y<0))||e.every((e=>e.y>at))}let Td;uc("FillExtrusionBucket",Bu,{omit:["layers","features"]});var Pd={get paint(){return Td=Td||new qs({"fill-extrusion-opacity":new Os(Se["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Rs(Se["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Os(Se["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Os(Se["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Us(Se["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Rs(Se["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Rs(Se["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Os(Se["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Ou extends Xs{constructor(e,s){super(e,Pd,s)}createBucket(e){return new Bu(e)}queryRadius(){return Zh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:a,geometry:h,transform:p,pixelsToTileUnits:f,pixelPosMatrix:m}){const _=qh(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-p.bearingInRadians,f),x=this.paint.get("fill-extrusion-height").evaluate(s,a),v=this.paint.get("fill-extrusion-base").evaluate(s,a),b=function(e,s){const a=[];for(const h of e){const e=[h.x,h.y,0,1];U(e,e,s),a.push(new l(e[0]/e[3],e[1]/e[3]))}return a}(_,m),w=function(e,s,a,h){const p=[],f=[],m=h[8]*s,_=h[9]*s,x=h[10]*s,v=h[11]*s,b=h[8]*a,w=h[9]*a,T=h[10]*a,P=h[11]*a;for(const s of e){const e=[],a=[];for(const p of s){const s=p.x,f=p.y,M=h[0]*s+h[4]*f+h[12],E=h[1]*s+h[5]*f+h[13],z=h[2]*s+h[6]*f+h[14],k=h[3]*s+h[7]*f+h[15],L=z+x,F=k+v,B=M+b,j=E+w,V=z+T,N=k+P,U=new l((M+m)/F,(E+_)/F);U.z=L/F,e.push(U);const G=new l(B/N,j/N);G.z=V/N,a.push(G)}p.push(e),f.push(a)}return[p,f]}(h,v,x,m);return function(e,s,a){let l=1/0;Ih(a,s)&&(l=Id(a,s[0]));for(let h=0;he.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new Ua,this.layoutVertexArray2=new ja,this.indexArray=new Ka,this.programConfigurations=new Eo(e.layers,e.zoom),this.segments=new to,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,a){this.hasDependencies=vu("line",this.layers,s)||this.hasLineDasharray(this.layers);const l=this.layers[0].layout.get("line-sort-key"),h=!l.isConstant(),p=[];for(const{feature:s,id:f,index:m,sourceLayerIndex:_}of e){const e=this.layers[0]._featureFilter.needGeometry,x=_h(s,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),x,a))continue;const v=h?l.evaluate(x,{},a):void 0,b={id:f,properties:s.properties,type:s.type,sourceLayerIndex:_,index:m,geometry:e?x.geometry:mh(s),patterns:{},dashes:{},sortKey:v};p.push(b)}h&&p.sort(((e,s)=>e.sortKey-s.sortKey));for(const l of p){const{geometry:h,index:p,sourceLayerIndex:f}=l;this.hasDependencies?(vu("line",this.layers,s)?wu("line",this.layers,l,{zoom:this.zoom},s):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,l,this.zoom,s),this.patternFeatures.push(l)):this.addFeature(l,h,p,a,{},{},s.subdivisionGranularity),s.featureIndex.insert(e[p].feature,h,p,f,this.index)}}update(e,s,a,l){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:a,dashPositions:l})}addFeatures(e,s,a,l){for(const h of this.patternFeatures)this.addFeature(h,h.geometry,h.index,s,a,l,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,Ad)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Cd),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,h,p,f){const m=this.layers[0].layout,_=m.get("line-join").evaluate(e,{}),x=m.get("line-cap"),v=m.get("line-miter-limit"),b=m.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const a of s)this.addLine(a,e,_,x,v,b,l,f);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,{imagePositions:h,dashPositions:p,canonical:l})}addLine(e,s,a,l,h,p,f,m){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=nd(e,f?m.line.getGranularityForZoomLevel(f.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let s=0;s=2&&e[x-1].equals(e[x-2]);)x--;let v=0;for(;v0;if(B&&s>v){const e=T.dist(P);if(e>2*b){const s=T.sub(T.sub(P)._mult(b/e)._round());this.updateDistance(P,s),this.addCurrentVertex(s,E,0,0,w),P=s}}const V=P&&M;let N=V?a:_?"butt":l;if(V&&"round"===N&&(Lh&&(N="bevel"),"bevel"===N&&(L>2&&(N="flipbevel"),L100)f=z.mult(-1);else{const e=L*E.add(z).mag()/E.sub(z).mag();f._perp()._mult(e*(j?-1:1))}this.addCurrentVertex(T,f,0,0,w),this.addCurrentVertex(T,f.mult(-1),0,0,w)}else if("bevel"===N||"fakeround"===N){const e=-Math.sqrt(L*L-1),s=j?e:0,a=j?0:e;if(P&&this.addCurrentVertex(T,E,s,a,w),"fakeround"===N){const e=Math.round(180*F/Math.PI/20);for(let s=1;s2*b){const s=T.add(M.sub(T)._mult(b/e)._round());this.updateDistance(T,s),this.addCurrentVertex(s,z,0,0,w),T=s}}}}addCurrentVertex(e,s,a,l,h,p=!1){const f=s.y*l-s.x,m=-s.y-s.x*l;this.addHalfVertex(e,s.x+s.y*a,s.y-s.x*a,p,!1,a,h),this.addHalfVertex(e,f,m,p,!0,-l,h),this.distance>kd/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,s,a,l,h,p))}addHalfVertex({x:e,y:s},a,l,h,p,f,m){const _=.5*(this.lineClips?this.scaledDistance*(kd-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(h?1:0),(s<<1)+(p?1:0),Math.round(63*a)+128,Math.round(63*l)+128,1+(0===f?0:f<0?-1:1)|(63&_)<<2,_>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const x=m.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,x,this.e2),m.primitiveLength++),p?this.e2=x:this.e1=x}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,s){this.distance+=e.dist(s),this.updateScaledDistance()}hasLineDasharray(e){for(const s of e){const e=s.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,s,a,l){for(const h of e){const e=h.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const p="round"===h.layout.get("line-cap"),f={dasharray:e.value.evaluate({zoom:a-1},s,{}),round:p},m={dasharray:e.value.evaluate({zoom:a},s,{}),round:p},_={dasharray:e.value.evaluate({zoom:a+1},s,{}),round:p},x=`${f.dasharray.join(",")},${f.round}`,v=`${m.dasharray.join(",")},${m.round}`,b=`${_.dasharray.join(",")},${_.round}`;l.dashDependencies[x]=f,l.dashDependencies[v]=m,l.dashDependencies[b]=_,s.dashes[h.id]={min:x,mid:v,max:b}}}}let Dd,Rd;uc("LineBucket",Yu,{omit:["layers","patternFeatures"]});var Ld={get paint(){return Rd=Rd||new qs({"line-opacity":new Rs(Se.paint_line["line-opacity"]),"line-color":new Rs(Se.paint_line["line-color"]),"line-translate":new Os(Se.paint_line["line-translate"]),"line-translate-anchor":new Os(Se.paint_line["line-translate-anchor"]),"line-width":new Rs(Se.paint_line["line-width"]),"line-gap-width":new Rs(Se.paint_line["line-gap-width"]),"line-offset":new Rs(Se.paint_line["line-offset"]),"line-blur":new Rs(Se.paint_line["line-blur"]),"line-dasharray":new Us(Se.paint_line["line-dasharray"]),"line-pattern":new Us(Se.paint_line["line-pattern"]),"line-gradient":new Ns(Se.paint_line["line-gradient"])})},get layout(){return Dd=Dd||new qs({"line-cap":new Os(Se.layout_line["line-cap"]),"line-join":new Rs(Se.layout_line["line-join"]),"line-miter-limit":new Os(Se.layout_line["line-miter-limit"]),"line-round-limit":new Os(Se.layout_line["line-round-limit"]),"line-sort-key":new Rs(Se.layout_line["line-sort-key"])})}};class Wu extends Rs{possiblyEvaluate(e,s){return s=new Ps(Math.floor(s.zoom),{now:s.now,fadeDuration:s.fadeDuration,zoomHistory:s.zoomHistory,transition:s.transition}),super.possiblyEvaluate(e,s)}evaluate(e,s,a,l){return s=Pt({},s,{zoom:Math.floor(s.zoom)}),super.evaluate(e,s,a,l)}}let Fd;class tc extends Xs{constructor(e,s){super(e,Ld,s),this.gradientVersion=0,Fd||(Fd=new Wu(Ld.paint.properties["line-width"].specification),Fd.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof or,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,s){super.recalculate(e,s),this.paint._values["line-floorwidth"]=Fd.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Yu(e)}queryRadius(e){const s=e,a=Bd($h("line-width",this,s),$h("line-gap-width",this,s)),l=$h("line-offset",this,s);return a/2+Math.abs(l)+Zh(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:a,geometry:h,transform:p,pixelsToTileUnits:f}){const m=qh(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-p.bearingInRadians,f),_=f/2*Bd(this.paint.get("line-width").evaluate(s,a),this.paint.get("line-gap-width").evaluate(s,a)),x=this.paint.get("line-offset").evaluate(s,a);return x&&(h=function(e,s){const a=[];for(let h=0;h=3)for(let s=0;s0?s+2*e:e}const Od=Nc([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),jd=Nc([{name:"a_projected_pos",components:3,type:"Float32"}],4);Nc([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Vd=Nc([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Nc([{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 Nd=Nc([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ud=Nc([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function $d(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()),Rc.applyArabicShaping&&(e=Rc.applyArabicShaping(e)),e}(e.text,s,a)})),e}Nc([{name:"triangle",components:3,type:"Uint16"}]),Nc([{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"}]),Nc([{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"}]),Nc([{type:"Float32",name:"offsetX"}]),Nc([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Nc([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Gd={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Zd=24;const qd=4294967296,Wd=1/qd,Hd="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class fc{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,h=this.pos;this.type=7&a,e(l,s,this),this.pos===h&&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)*qd;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*qd;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const 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 h,p;if(p=l[a.pos++],h=(112&p)>>4,p<128)return Xd(e,h,s);if(p=l[a.pos++],h|=(127&p)<<3,p<128)return Xd(e,h,s);if(p=l[a.pos++],h|=(127&p)<<10,p<128)return Xd(e,h,s);if(p=l[a.pos++],h|=(127&p)<<17,p<128)return Xd(e,h,s);if(p=l[a.pos++],h|=(127&p)<<24,p<128)return Xd(e,h,s);if(p=l[a.pos++],h|=(1&p)<<31,p<128)return Xd(e,h,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&&Hd?Hd.decode(this.buf.subarray(s,e)):function(e,s,a){let l="",h=s;for(;h239?4:s>223?3:s>191?2:1;if(h+x>a)break;1===x?s<128&&(_=s):2===x?(p=e[h+1],128==(192&p)&&(_=(31&s)<<6|63&p,_<=127&&(_=null))):3===x?(p=e[h+1],f=e[h+2],128==(192&p)&&128==(192&f)&&(_=(15&s)<<12|(63&p)<<6|63&f,(_<=2047||_>=55296&&_<=57343)&&(_=null))):4===x&&(p=e[h+1],f=e[h+2],m=e[h+3],128==(192&p)&&128==(192&f)&&128==(192&m)&&(_=(15&s)<<18|(63&p)<<12|(63&f)<<6|63&m,(_<=65535||_>=1114112)&&(_=null))),null===_?(_=65533,x=1):_>65535&&(_-=65536,l+=String.fromCharCode(_>>>10&1023|55296),_=56320|1023&_),l+=String.fromCharCode(_),h+=x}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,h,p=0;p55295&&l<57344){if(!h){l>56319||p+1===s.length?(e[a++]=239,e[a++]=191,e[a++]=189):h=l;continue}if(l<56320){e[a++]=239,e[a++]=191,e[a++]=189,h=l;continue}l=h-55296<<10|l-56320|65536,h=null}else h&&(e[a++]=239,e[a++]=191,e[a++]=189,h=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&&Yd(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&&Yd(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,Kd,s)}writePackedSVarint(e,s){s.length&&this.writeMessage(e,Jd,s)}writePackedBoolean(e,s){s.length&&this.writeMessage(e,ep,s)}writePackedFloat(e,s){s.length&&this.writeMessage(e,Qd,s)}writePackedDouble(e,s){s.length&&this.writeMessage(e,tp,s)}writePackedFixed32(e,s){s.length&&this.writeMessage(e,rp,s)}writePackedSFixed32(e,s){s.length&&this.writeMessage(e,np,s)}writePackedFixed64(e,s){s.length&&this.writeMessage(e,op,s)}writePackedSFixed64(e,s){s.length&&this.writeMessage(e,ap,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 Xd(e,s,a){return a?4294967296*s+(e>>>0):4294967296*(s>>>0)+(e>>>0)}function Yd(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 Kd(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 h=0,p=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,p=Math.max(p,s.y+s.h),h=Math.max(h,s.x+s.w),s.w===a.w&&s.h===a.h){const s=l.pop();s&&e=0&&a>=e&&fp[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 Bc;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 pp(e,a,l,h,p,f,m,_,x,v,b,w,T,P,M){const E=Bc.fromFeature(e,p);let z;w===s.ao.vertical&&E.verticalizePunctuation();const{processBidirectionalText:k,processStyledBidirectionalText:L}=Rc;if(k&&1===E.sections.length){z=[];const e=k(E.toString(),Tp(E,v,f,a,h,P));for(const s of e){const e=new Bc;e.text=s,e.sections=E.sections;for(let a=0;a=0;let x=0;for(let a=0;ax){const e=Math.ceil(p/x);h*=e/f,f=e}return{x1:l,y1:h,x2:l+p,y2:h+f}}function Dp(e,s,a,l,h,p){const f=e.image;let m;if(f.content){const e=f.content,s=f.pixelRatio||1;m=[e[0]/s,e[1]/s,f.displaySize[0]-e[2]/s,f.displaySize[1]-e[3]/s]}const _=s.left*p,x=s.right*p;let v,b,w,T;"width"===a||"both"===a?(T=h[0]+_-l[3],b=h[0]+x+l[1]):(T=h[0]+(_+x-f.displaySize[0])/2,b=T+f.displaySize[0]);const P=s.top*p,M=s.bottom*p;return"height"===a||"both"===a?(v=h[1]+P-l[0],w=h[1]+M+l[2]):(v=h[1]+(P+M-f.displaySize[1])/2,w=v+f.displaySize[1]),{image:f,top:v,right:b,bottom:w,left:T,collisionPadding:m}}const Rp=128,Lp=32640;function Fp(e,s){const{expression:a}=s;if("constant"===a.kind)return{kind:"constant",layoutSize:a.evaluate(new Ps(e+1))};if("source"===a.kind)return{kind:"source"};{const{zoomStops:s,interpolationType:l}=a;let h=0;for(;he.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const a=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fp(this.zoom,a["text-size"]),this.iconSizeData=Fp(this.zoom,a["icon-size"]);const l=this.layers[0].layout,h=l.get("symbol-sort-key"),p=l.get("symbol-z-order");this.canOverlap="never"!==Bp(l,"text-overlap","text-allow-overlap")||"never"!==Bp(l,"icon-overlap","icon-allow-overlap")||l.get("text-ignore-placement")||l.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==p&&!h.isConstant(),this.sortFeaturesByY=("viewport-y"===p||"auto"===p&&!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 lh(new Eo(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new lh(new Eo(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new Ea,this.lineVertexArray=new Ta,this.symbolInstances=new Ca,this.textAnchorOffsets=new Va}calculateGlyphDependencies(e,s,a,l,h){for(let p=0;p0)&&("constant"!==f.value.kind||f.value.value.length>0),v="constant"!==_.value.kind||!!_.value.value||Object.keys(_.parameters).length>0,b=p.get("symbol-sort-key");if(this.features=[],!x&&!v)return;const w=a.iconDependencies,T=a.glyphDependencies,P=a.availableImages,M=new Ps(this.zoom);for(const{feature:a,id:m,index:_,sourceLayerIndex:E}of e){const e=h._featureFilter.needGeometry,z=_h(a,e);if(!h._featureFilter.filter(M,z,l))continue;let k,L;if(e||(z.geometry=mh(a)),x){const e=h.getValueAndResolveTokens("text-field",z,l,P),s=Ee.factory(e),a=this.hasRTLText=this.hasRTLText||Np(s);(!a||"unavailable"===Rc.getRTLTextPluginStatus()||a&&Rc.isParsed())&&(k=$d(s,h,z))}if(v){const e=h.getValueAndResolveTokens("icon-image",z,l,P);L=e instanceof Le?e:Le.fromString(e)}if(!k&&!L)continue;const F=this.sortFeaturesByKey?b.evaluate(z,{},l):void 0;if(this.features.push({id:m,text:k,icon:L,index:_,sourceLayerIndex:E,geometry:z.geometry,properties:a.properties,type:Au.types[a.type],sortKey:F}),L&&(w[L.name]=!0),k){const e=f.evaluate(z,{},l).join(","),a="viewport"!==p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(s.ao.vertical)>=0;for(const s of k.sections)if(s.image)w[s.image.name]=!0;else{const l=xc(k.toString()),h=s.fontStack||e,p=T[h]=T[h]||{};this.calculateGlyphDependencies(s.text,p,a,this.allowVerticalPlacement,l)}}}"line"===p.get("symbol-placement")&&(this.features=function(e){const s={},a={},l=[];let h=0;function p(s){l.push(e[s]),h++}function f(e,s,h){const p=a[e];return delete a[e],a[s]=p,l[p].geometry[0].pop(),l[p].geometry[0]=l[p].geometry[0].concat(h[0]),p}function m(e,a,h){const p=s[a];return delete s[a],s[e]=p,l[p].geometry[0].shift(),l[p].geometry[0]=h[0].concat(l[p].geometry[0]),p}function _(e,s,a){const l=a?s[0][s[0].length-1]:s[0][0];return`${e}:${l.x}:${l.y}`}for(let x=0;xe.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,{imagePositions:a}),this.icon.programConfigurations.updatePaintArrays(e,s,this.layers,{imagePositions: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 h={};for(let l=e.segment+1;l=0;a--)h[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]||h[s]-h[e])),p}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 Up,$p;uc("SymbolBucket",ch,{omit:["layers","collisionBoxArray","features","compareText"]}),ch.MAX_GLYPHS=65535,ch.addDynamicAttributes=Vp;var Gp={get paint(){return $p=$p||new qs({"icon-opacity":new Rs(Se.paint_symbol["icon-opacity"]),"icon-color":new Rs(Se.paint_symbol["icon-color"]),"icon-halo-color":new Rs(Se.paint_symbol["icon-halo-color"]),"icon-halo-width":new Rs(Se.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Rs(Se.paint_symbol["icon-halo-blur"]),"icon-translate":new Os(Se.paint_symbol["icon-translate"]),"icon-translate-anchor":new Os(Se.paint_symbol["icon-translate-anchor"]),"text-opacity":new Rs(Se.paint_symbol["text-opacity"]),"text-color":new Rs(Se.paint_symbol["text-color"],{runtimeType:ui,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Rs(Se.paint_symbol["text-halo-color"]),"text-halo-width":new Rs(Se.paint_symbol["text-halo-width"]),"text-halo-blur":new Rs(Se.paint_symbol["text-halo-blur"]),"text-translate":new Os(Se.paint_symbol["text-translate"]),"text-translate-anchor":new Os(Se.paint_symbol["text-translate-anchor"])})},get layout(){return Up=Up||new qs({"symbol-placement":new Os(Se.layout_symbol["symbol-placement"]),"symbol-spacing":new Os(Se.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Os(Se.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Rs(Se.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Os(Se.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Os(Se.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Os(Se.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Os(Se.layout_symbol["icon-ignore-placement"]),"icon-optional":new Os(Se.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Os(Se.layout_symbol["icon-rotation-alignment"]),"icon-size":new Rs(Se.layout_symbol["icon-size"]),"icon-text-fit":new Os(Se.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Os(Se.layout_symbol["icon-text-fit-padding"]),"icon-image":new Rs(Se.layout_symbol["icon-image"]),"icon-rotate":new Rs(Se.layout_symbol["icon-rotate"]),"icon-padding":new Rs(Se.layout_symbol["icon-padding"]),"icon-keep-upright":new Os(Se.layout_symbol["icon-keep-upright"]),"icon-offset":new Rs(Se.layout_symbol["icon-offset"]),"icon-anchor":new Rs(Se.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Os(Se.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Os(Se.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Os(Se.layout_symbol["text-rotation-alignment"]),"text-field":new Rs(Se.layout_symbol["text-field"]),"text-font":new Rs(Se.layout_symbol["text-font"]),"text-size":new Rs(Se.layout_symbol["text-size"]),"text-max-width":new Rs(Se.layout_symbol["text-max-width"]),"text-line-height":new Os(Se.layout_symbol["text-line-height"]),"text-letter-spacing":new Rs(Se.layout_symbol["text-letter-spacing"]),"text-justify":new Rs(Se.layout_symbol["text-justify"]),"text-radial-offset":new Rs(Se.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Os(Se.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Rs(Se.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Rs(Se.layout_symbol["text-anchor"]),"text-max-angle":new Os(Se.layout_symbol["text-max-angle"]),"text-writing-mode":new Os(Se.layout_symbol["text-writing-mode"]),"text-rotate":new Rs(Se.layout_symbol["text-rotate"]),"text-padding":new Os(Se.layout_symbol["text-padding"]),"text-keep-upright":new Os(Se.layout_symbol["text-keep-upright"]),"text-transform":new Rs(Se.layout_symbol["text-transform"]),"text-offset":new Rs(Se.layout_symbol["text-offset"]),"text-allow-overlap":new Os(Se.layout_symbol["text-allow-overlap"]),"text-overlap":new Os(Se.layout_symbol["text-overlap"]),"text-ignore-placement":new Os(Se.layout_symbol["text-ignore-placement"]),"text-optional":new Os(Se.layout_symbol["text-optional"])})}};class dh{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:ai,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}}uc("FormatSectionOverride",dh,{omit:["defaultValue"]});class yh extends Xs{constructor(e,s){super(e,Gp,s)}recalculate(e,s){if(super.recalculate(e,s),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const s=[];for(const 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 h=this.layout.get(e).evaluate(s,{},a,l),p=this._unevaluatedLayout._values[e];return p.isDataDriven()||ta(p.value)||!h?h:function(e,s){return s.replace(/{([^{}]+)}/g,((s,a)=>e&&a in e?String(e[a]):""))}(s.properties,h)}createBucket(e){return new ch(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Gp.paint.overridableProperties){if(!yh.hasPaintOverride(this.layout,e))continue;const s=this.paint.get(e),a=new dh(s),l=new ei(a,s.property.specification);let h=null;h="constant"===s.value.kind||"source"===s.value.kind?new ii("source",l):new si("composite",l,s.value.zoomStops),this.paint._values[e]=new $s(s.property,h,s.parameters)}}_handleOverridablePaintPropertyUpdate(e,s,a){return!(!this.layout||s.isDataDriven()||a.isDataDriven())&&yh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,s){const a=e.get("text-field"),l=Gp.paint.properties[s];let h=!1;const p=e=>{for(const s of e)if(l.overrides&&l.overrides.hasOverride(s))return void(h=!0)};if("constant"===a.value.kind&&a.value.value instanceof Ee)p(a.value.value.sections);else if("source"===a.value.kind||"composite"===a.value.kind){const e=s=>{h||(s instanceof qe&&Jr(s.value)===xi?p(s.value.sections):s instanceof zr?p(s.sections):s.eachChild(e))},s=a.value;s._styleExpression&&e(s._styleExpression.expression)}return h}}let Zp;var qp={get paint(){return Zp=Zp||new qs({"background-color":new Os(Se.paint_background["background-color"]),"background-pattern":new js(Se.paint_background["background-pattern"]),"background-opacity":new Os(Se.paint_background["background-opacity"])})}};class xh extends Xs{constructor(e,s){super(e,qp,s)}}class vh extends Xs{constructor(e,s){super(e,{},s),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class bh{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},Hp=6371008.8;class Sh{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 Sh(Tt(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,h=Math.sin(a)*Math.sin(l)+Math.cos(a)*Math.cos(l)*Math.cos((e.lng-this.lng)*s);return Hp*Math.acos(Math.min(h,1))}static convert(e){if(e instanceof Sh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Sh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Sh(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Xp=2*Math.PI*Hp;function Yp(e){return Xp*Math.cos(e*Math.PI/180)}function Kp(e){return(180+e)/360}function Jp(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Qp(e,s){return e/Yp(s)}function tf(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function ef(e,s){return e*Yp(tf(s))}class Eh{constructor(e,s,a=0){this.x=+e,this.y=+s,this.z=+a}static fromLngLat(e,s=0){const a=Sh.convert(e);return new Eh(Kp(a.lng),Jp(a.lat),Qp(s,a.lat))}toLngLat(){return new Sh(360*this.x-180,tf(this.y))}toAltitude(){return ef(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Xp*(e=tf(this.y),1/Math.cos(e*Math.PI/180));var e}}function rf(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=nf(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=(p=this.y,f=this.z,m=rf(256*(h=this.x),256*(p=Math.pow(2,f)-p-1),f),_=rf(256*(h+1),256*(p+1),f),m[0]+","+m[1]+","+_[0]+","+_[1]);var h,p,f,m,_;const x=function(e,s,a){let l,h="";for(let p=e;p>0;p--)l=1<1?"@2x":"").replace(/{quadkey}/g,x).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)*at,(e.y*s-this.y)*at)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Vh{constructor(e,s){this.wrap=e,this.canonical=s,this.key=nf(e,s.z,s.z,s.x,s.y)}}class Fh{constructor(e,s,a,l,h){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${a}`);this.overscaledZ=e,this.wrap=s,this.canonical=new Bh(a,+l,+h),this.key=nf(s,e,a,l,h)}clone(){return new Fh(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 Fh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Fh(e,this.wrap,e,this.canonical.x>>s,this.canonical.y>>s)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,s){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const a=this.canonical.z-e;return e>this.canonical.z?nf(this.wrap*+s,e,this.canonical.z,this.canonical.x,this.canonical.y):nf(this.wrap*+s,e,e,this.canonical.x>>a,this.canonical.y>>a)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const s=this.canonical.z-e.canonical.z;return!(s<0)&&e.canonical.x===this.canonical.x>>s&&e.canonical.y===this.canonical.y>>s}children(e){if(this.overscaledZ>=e)return[new Fh(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 Fh(s,this.wrap,s,a,l),new Fh(s,this.wrap,s,a+1,l),new Fh(s,this.wrap,s,a,l+1),new Fh(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 Lh;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 Lh;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 Oh{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 Rh{constructor(e,s,a,l,h){this.type="Feature",this._vectorTileFeature=e,e._z=s,e._x=a,e._y=l,this.properties=e.properties,this.id=h}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 Uh{constructor(e,s){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new as(at,16,0),this.grid3D=new as(at,16,0),this.featureIndexArray=new Da,this.promoteId=s}insert(e,s,a,l,h,p){const f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(a,l,h);const m=p?this.grid3D:this.grid;for(let e=0;e=0&&l[3]>=0&&m.insert(f,l[0],l[1],l[2],l[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Pu(new fc(this.rawTileData)).layers,this.sourceLayerCoder=new Oh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,s,a,h){this.loadVTLayers();const p=e.params,f=at/e.tileSize/e.scale,m=al(p.filter,p.globalState),_=e.queryGeometry,x=e.queryPadding*f,v=Lh.fromPoints(_),b=this.grid.query(v.minX-x,v.minY-x,v.maxX+x,v.maxY+x),w=Lh.fromPoints(e.cameraQueryGeometry).expandBy(x),T=this.grid3D.query(w.minX,w.minY,w.maxX,w.maxY,((s,a,h,p)=>function(e,s,a,h,p){for(const l of e)if(s<=l.x&&a<=l.y&&h>=l.x&&p>=l.y)return!0;const f=[new l(s,a),new l(s,p),new l(h,p),new l(h,a)];if(e.length>2)for(const s of f)if(jh(e,s))return!0;for(let s=0;s(w||(w=mh(s)),a.queryIntersectsFeature({queryGeometry:_,feature:s,featureState:l,geometry:w,zoom:this.z,transform:e.transform,pixelsToTileUnits:f,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return P}loadMatchingFeature(e,s,a,l,h,p,f,m,_,x,v){const b=this.bucketLayerIDs[s];if(p&&!b.some((e=>p.has(e))))return;const w=this.sourceLayerCoder.decode(a),T=this.vtLayers[w].feature(l);if(h.needGeometry){const e=_h(T,!0);if(!h.filter(new Ps(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!h.filter(new Ps(this.tileID.overscaledZ),T))return;const P=this.getId(T,w);for(let s=0;s{const f=s instanceof Ls?s.get(p):null;return f&&f.evaluate?f.evaluate(a,l,h):f}))}function af(e,s){return s-e}function lf(e,s,a,h,p){const f=[];for(let m=0;m=h&&v.x>=h||(m.x>=h?m=new l(h,m.y+(h-m.x)/(v.x-m.x)*(v.y-m.y))._round():v.x>=h&&(v=new l(h,m.y+(h-m.x)/(v.x-m.x)*(v.y-m.y))._round()),m.y>=p&&v.y>=p||(m.y>=p?m=new l(m.x+(p-m.y)/(v.y-m.y)*(v.x-m.x),p)._round():v.y>=p&&(v=new l(m.x+(p-m.y)/(v.y-m.y)*(v.x-m.x),p)._round()),x&&m.equals(x[x.length-1])||(x=[m],f.push(x)),x.push(v)))))}}return f}uc("FeatureIndex",Uh,{omit:["rawTileData","sourceLayerCoder"]});class Gh extends l{constructor(e,s,a,l){super(e,s),this.angle=a,void 0!==l&&(this.segment=l)}clone(){return new Gh(this.x,this.y,this.angle,this.segment)}}function cf(e,s,a,l,h){if(void 0===s.segment||0===a)return!0;let p=s,f=s.segment+1,m=0;for(;m>-a/2;){if(f--,f<0)return!1;m-=e[f].dist(p),p=e[f]}m+=e[f].dist(e[f+1]),f++;const _=[];let x=0;for(;ml;)x-=_.shift().angleDelta;if(x>h)return!1;f++,m+=s.dist(a)}return!0}function hf(e){let s=0;for(let a=0;ax){const v=(x-_)/p,b=dn.number(l.x,h.x,v),w=dn.number(l.y,h.y,v),T=new Gh(b,w,h.angleTo(l),a);return T._round(),!f||cf(e,T,m,f,s)?T:void 0}_+=p}}function ff(e,s,a,l,h,p,f,m,_){const x=uf(l,p,f),v=df(l,h),b=v*f,w=0===e[0].x||e[0].x===_||0===e[0].y||e[0].y===_;return s-b=0&&z<_&&k>=0&&k<_&&w-x>=0&&w+x<=v){const a=new Gh(z,k,M,s);a._round(),l&&!cf(e,a,p,l,h)||T.push(a)}}b+=P}return m||T.length||f||(T=mf(e,b/2,a,l,h,p,f,!0,_)),T}function _f(e,s,a,h){const p=[],f=e.image,m=f.pixelRatio,_=f.paddedRect.w-2,x=f.paddedRect.h-2;let v={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const b=f.stretchX||[[0,_]],w=f.stretchY||[[0,x]],T=(e,s)=>e+s[1]-s[0],P=b.reduce(T,0),M=w.reduce(T,0),E=_-P,z=x-M;let k=0,L=P,F=0,B=M,j=0,V=E,N=0,U=z;if(f.content&&h){const s=f.content,a=s[2]-s[0],l=s[3]-s[1];(f.textFitWidth||f.textFitHeight)&&(v=kp(e)),k=gf(b,0,s[0]),F=gf(w,0,s[1]),L=gf(b,s[0],s[2]),B=gf(w,s[1],s[3]),j=s[0]-k,N=s[1]-F,V=a-L,U=l-B}const G=v.x1,Z=v.y1,nt=v.x2-G,st=v.y2-Z,at=(e,h,p,_)=>{const x=xf(e.stretch-k,L,nt,G),v=vf(e.fixed-j,V,e.stretch,P),b=xf(h.stretch-F,B,st,Z),w=vf(h.fixed-N,U,h.stretch,M),T=xf(p.stretch-k,L,nt,G),E=vf(p.fixed-j,V,p.stretch,P),z=xf(_.stretch-F,B,st,Z),at=vf(_.fixed-N,U,_.stretch,M),lt=new l(x,b),ht=new l(T,b),ut=new l(T,z),dt=new l(x,z),pt=new l(v/m,w/m),_t=new l(E/m,at/m),vt=s*Math.PI/180;if(vt){const e=Math.sin(vt),s=Math.cos(vt),a=[s,-e,e,s];lt._matMult(a),ht._matMult(a),dt._matMult(a),ut._matMult(a)}const Tt=e.stretch+e.fixed,Pt=h.stretch+h.fixed;return{tl:lt,tr:ht,bl:dt,br:ut,tex:{x:f.paddedRect.x+1+Tt,y:f.paddedRect.y+1+Pt,w:p.stretch+p.fixed-Tt,h:_.stretch+_.fixed-Pt},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:pt,pixelOffsetBR:_t,minFontScaleX:V/m/nt,minFontScaleY:U/m/st,isSDF:a}};if(h&&(f.stretchX||f.stretchY)){const e=yf(b,E,P),s=yf(w,z,M);for(let a=0;a0&&(l=Math.max(10,l),this.circleDiameter=l)}else{const x=(null===(b=f.image)||void 0===b?void 0:b.content)&&(f.image.textFitWidth||f.image.textFitHeight)?kp(f):{x1:f.left,y1:f.top,x2:f.right,y2:f.bottom};x.y1=x.y1*m-_[0],x.y2=x.y2*m+_[2],x.x1=x.x1*m-_[3],x.x2=x.x2*m+_[1];const w=f.collisionPadding;if(w&&(x.x1-=w[0]*m,x.y1-=w[1]*m,x.x2+=w[2]*m,x.y2+=w[3]*m),v){const e=new l(x.x1,x.y1),s=new l(x.x2,x.y1),a=new l(x.x1,x.y2),h=new l(x.x2,x.y2),p=v*Math.PI/180;e._rotate(p),s._rotate(p),a._rotate(p),h._rotate(p),x.x1=Math.min(e.x,s.x,a.x,h.x),x.x2=Math.max(e.x,s.x,a.x,h.x),x.y1=Math.min(e.y,s.y,a.y,h.y),x.y2=Math.max(e.y,s.y,a.y,h.y)}e.emplaceBack(s.x,s.y,x.x1,x.y1,x.x2,x.y2,a,h,p)}this.boxEndIndex=e.length}}class sp{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 h=e-1>>1,p=s[h];if(a(l,p)>=0)break;s[e]=p,e=h}s[e]=l}_down(e){const{data:s,compare:a}=this,l=this.length>>1,h=s[e];for(;e=0)break;s[e]=s[l],e=l}s[e]=h}}function bf(e,s=1,a=!1){const h=Lh.fromPoints(e[0]),p=Math.min(h.width(),h.height());let f=p/2;const m=new sp([],wf),{minX:_,minY:x,maxX:v,maxY:b}=h;if(0===p)return new l(_,x);for(let s=_;sw.d||!w.d)&&(w=l,a&&console.log("found best %d after %d probes",Math.round(1e4*l.d)/1e4,T)),l.max-w.d<=s||(f=l.h/2,m.push(new Tf(l.p.x-f,l.p.y-f,f,e)),m.push(new Tf(l.p.x+f,l.p.y-f,f,e)),m.push(new Tf(l.p.x-f,l.p.y+f,f,e)),m.push(new Tf(l.p.x+f,l.p.y+f,f,e)),T+=4)}return a&&(console.log(`num probes: ${T}`),console.log(`best distance: ${w.d}`)),w.p}function wf(e,s){return s.max-e.max}function Tf(s,a,h,p){(this||e).p=new l(s,a),(this||e).h=h,(this||e).d=function(e,s){let a=!1,l=1/0;for(let h=0;he.y!=m.y>e.y&&e.x<(m.x-h.x)*(e.y-h.y)/(m.y-h.y)+h.x&&(a=!a),l=Math.min(l,kh(e,h,m))}}return(a?1:-1)*Math.sqrt(l)}((this||e).p,p),(this||e).max=(this||e).d+(this||e).h*Math.SQRT2}var Pf;s.aE=void 0,(Pf=s.aE||(s.aE={}))[Pf.center=1]="center",Pf[Pf.left=2]="left",Pf[Pf.right=3]="right",Pf[Pf.top=4]="top",Pf[Pf.bottom=5]="bottom",Pf[Pf["top-left"]=6]="top-left",Pf[Pf["top-right"]=7]="top-right",Pf[Pf["bottom-left"]=8]="bottom-left",Pf[Pf["bottom-right"]=9]="bottom-right";const Sf=Number.POSITIVE_INFINITY;function If(e,s){return s[1]!==Sf?function(e,s,a){let l=0,h=0;switch(s=Math.abs(s),a=Math.abs(a),e){case"top-right":case"top-left":case"top":h=a-7;break;case"bottom-right":case"bottom-left":case"bottom":h=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,h]}(e,s[0],s[1]):function(e,s){let a=0,l=0;s<0&&(s=0);const h=s/Math.SQRT2;switch(e){case"top-right":case"top-left":l=h-7;break;case"bottom-right":case"bottom-left":l=7-h;break;case"bottom":l=7-s;break;case"top":l=s-7}switch(e){case"top-right":case"bottom-right":a=-h;break;case"top-left":case"bottom-left":a=h;break;case"left":a=s;break;case"right":a=-s}return[a,l]}(e,s[0])}function Mf(e,s,a){var l;const h=e.layout,p=null===(l=h.get("text-variable-anchor-offset"))||void 0===l?void 0:l.evaluate(s,{},a);if(p){const e=p.values,s=[];for(let a=0;ae*Zd));l.startsWith("top")?h[1]-=7:l.startsWith("bottom")&&(h[1]+=7),s[a+1]=h}return new $e(s)}const f=h.get("text-variable-anchor");if(f){let l;l=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[h.get("text-radial-offset").evaluate(s,{},a)*Zd,Sf]:h.get("text-offset").evaluate(s,{},a).map((e=>e*Zd));const p=[];for(const e of f)p.push(e,If(e,l));return new $e(p)}return null}function Cf(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 Ef(e,a,l,h,p,f,m,_,x,v,b,w){let T=f.textMaxSize.evaluate(a,{});void 0===T&&(T=m);const P=e.layers[0].layout,M=P.get("icon-offset").evaluate(a,{},b),E=zf(l.horizontal),z=m/24,k=e.tilePixelRatio*z,L=e.tilePixelRatio*T/24,F=e.tilePixelRatio*_,B=e.tilePixelRatio*P.get("symbol-spacing"),j=P.get("text-padding")*e.tilePixelRatio,V=function(e,s,a,l=1){const h=e.get("icon-padding").evaluate(s,{},a),p=h&&h.values;return[p[0]*l,p[1]*l,p[2]*l,p[3]*l]}(P,a,b,e.tilePixelRatio),N=P.get("text-max-angle")/180*Math.PI,U="viewport"!==P.get("text-rotation-alignment")&&"point"!==P.get("symbol-placement"),G="map"===P.get("icon-rotation-alignment")&&"point"!==P.get("symbol-placement"),Z=P.get("symbol-placement"),nt=B/2,st=P.get("icon-text-fit");let lt;h&&"none"!==st&&(e.allowVerticalPlacement&&l.vertical&&(lt=Dp(h,l.vertical,st,P.get("icon-text-fit-padding"),M,z)),E&&(h=Dp(h,E,st,P.get("icon-text-fit-padding"),M,z)));const ht=b?w.line.getGranularityForZoomLevel(b.z):1,ut=(_,w)=>{w.x<0||w.x>=at||w.y<0||w.y>=at||function(e,a,l,h,p,f,m,_,x,v,b,w,T,P,M,E,z,k,L,F,B,j,V,N,U){const G=e.addToLineVertexArray(a,l);let Z,nt,st,at,lt=0,ht=0,ut=0,dt=0,pt=-1,_t=-1;const vt={};let Tt=eh("");if(e.allowVerticalPlacement&&h.vertical){const e=_.layout.get("text-rotate").evaluate(B,{},N)+90;st=new ip(x,a,v,b,w,h.vertical,T,P,M,e),m&&(at=new ip(x,a,v,b,w,m,z,k,M,e))}if(p){const l=_.layout.get("icon-rotate").evaluate(B,{}),h="none"!==_.layout.get("icon-text-fit"),f=_f(p,l,V,h),T=m?_f(m,l,V,h):void 0;nt=new ip(x,a,v,b,w,p,z,k,!1,l),lt=4*f.length;const P=e.iconSizeData;let M=null;"source"===P.kind?(M=[Rp*_.layout.get("icon-size").evaluate(B,{})],M[0]>Lp&&jt(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===P.kind&&(M=[Rp*j.compositeIconSizes[0].evaluate(B,{},N),Rp*j.compositeIconSizes[1].evaluate(B,{},N)],(M[0]>Lp||M[1]>Lp)&&jt(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,f,M,F,L,B,s.ao.none,a,G.lineStartIndex,G.lineLength,-1,N),pt=e.icon.placedSymbolArray.length-1,T&&(ht=4*T.length,e.addSymbols(e.icon,T,M,F,L,B,s.ao.vertical,a,G.lineStartIndex,G.lineLength,-1,N),_t=e.icon.placedSymbolArray.length-1)}const Pt=Object.keys(h.horizontal);for(const l of Pt){const p=h.horizontal[l];if(!Z){Tt=eh(p.text);const e=_.layout.get("text-rotate").evaluate(B,{},N);Z=new ip(x,a,v,b,w,p,T,P,M,e)}const m=1===p.positionedLines.length;if(ut+=Af(e,a,p,f,_,M,B,E,G,h.vertical?s.ao.horizontal:s.ao.horizontalOnly,m?Pt:[l],vt,pt,j,N),m)break}h.vertical&&(dt+=Af(e,a,h.vertical,f,_,M,B,E,G,s.ao.vertical,["vertical"],vt,_t,j,N));const St=Z?Z.boxStartIndex:e.collisionBoxArray.length,Mt=Z?Z.boxEndIndex:e.collisionBoxArray.length,Ct=st?st.boxStartIndex:e.collisionBoxArray.length,At=st?st.boxEndIndex:e.collisionBoxArray.length,zt=nt?nt.boxStartIndex:e.collisionBoxArray.length,Nt=nt?nt.boxEndIndex:e.collisionBoxArray.length,Zt=at?at.boxStartIndex:e.collisionBoxArray.length,qt=at?at.boxEndIndex:e.collisionBoxArray.length;let Xt=-1;const Yt=(e,s)=>e&&e.circleDiameter?Math.max(e.circleDiameter,s):s;Xt=Yt(Z,Xt),Xt=Yt(st,Xt),Xt=Yt(nt,Xt),Xt=Yt(at,Xt);const Kt=Xt>-1?1:0;Kt&&(Xt*=U/Zd),e.glyphOffsetArray.length>=ch.MAX_GLYPHS&&jt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==B.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,B.sortKey);const Jt=Mf(_,B,N),[ee,ie]=function(e,a){const l=e.length,h=null==a?void 0:a.values;if((null==h?void 0:h.length)>0)for(let a=0;a=0?vt.right:-1,vt.center>=0?vt.center:-1,vt.left>=0?vt.left:-1,vt.vertical||-1,pt,_t,Tt,St,Mt,Ct,At,zt,Nt,Zt,qt,v,ut,dt,lt,ht,Kt,0,T,Xt,ee,ie)}(e,w,_,l,h,p,lt,e.layers[0],e.collisionBoxArray,a.index,a.sourceLayerIndex,e.index,k,[j,j,j,j],U,x,F,V,G,M,a,f,v,b,m)};if("line"===Z)for(const s of lf(a.geometry,0,0,at,at)){const a=nd(s,ht),p=ff(a,B,N,l.vertical||E,h,24,L,e.overscaling,at);for(const s of p)E&&kf(e,E.text,nt,s)||ut(a,s)}else if("line-center"===Z){for(const e of a.geometry)if(e.length>1){const s=nd(e,ht),a=pf(s,N,l.vertical||E,h,24,L);a&&ut(s,a)}}else if("Polygon"===a.type)for(const e of Wn(a.geometry,0)){const s=bf(e,16);ut(nd(e[0],ht,!0),new Gh(s.x,s.y,0))}else if("LineString"===a.type)for(const e of a.geometry){const s=nd(e,ht);ut(s,new Gh(s[0].x,s[0].y,0))}else if("Point"===a.type)for(const e of a.geometry)for(const s of e)ut([s],new Gh(s.x,s.y,0))}function Af(e,s,a,h,p,f,m,_,x,v,b,w,T,P,M){const E=function(e,s,a,h,p,f,m,_){const x=h.layout.get("text-rotate").evaluate(f,{})*Math.PI/180,v=[];for(const e of s.positionedLines)for(const h of e.positionedGlyphs){if(!h.rect)continue;const f=h.rect||{};let b=4,w=!0,T=1,P=0;const M=(p||_)&&h.vertical,E=h.metrics.advance*h.scale/2;if(_&&s.verticalizable&&(P=e.lineOffset/2-(h.imageName?-(Zd-h.metrics.width*h.scale)/2:(h.scale-1)*Zd)),h.imageName){const e=m[h.imageName];w=e.sdf,T=e.pixelRatio,b=1/T}const z=p?[h.x+E,h.y]:[0,0];let k=p?[0,0]:[h.x+E+a[0],h.y+a[1]-P],L=[0,0];M&&(L=k,k=[0,0]);const F=h.metrics.isDoubleResolution?2:1,B=(h.metrics.left-b)*h.scale-E+k[0],j=(-h.metrics.top-b)*h.scale+k[1],V=B+f.w/F*h.scale/T,N=j+f.h/F*h.scale/T,U=new l(B,j),G=new l(V,j),Z=new l(B,N),nt=new l(V,N);if(M){const e=new l(-E,E- -17),s=-Math.PI/2,a=12-E,p=new l(22-a,-(h.imageName?a:0)),f=new l(...L);U._rotateAround(s,e)._add(p)._add(f),G._rotateAround(s,e)._add(p)._add(f),Z._rotateAround(s,e)._add(p)._add(f),nt._rotateAround(s,e)._add(p)._add(f)}if(x){const e=Math.sin(x),s=Math.cos(x),a=[s,-e,e,s];U._matMult(a),G._matMult(a),Z._matMult(a),nt._matMult(a)}const st=new l(0,0),at=new l(0,0);v.push({tl:U,tr:G,bl:Z,br:nt,tex:f,writingMode:s.writingMode,glyphOffset:z,sectionIndex:h.sectionIndex,isSDF:w,pixelOffsetTL:st,pixelOffsetBR:at,minFontScaleX:0,minFontScaleY:0})}return v}(0,a,_,p,f,m,h,e.allowVerticalPlacement),z=e.textSizeData;let k=null;"source"===z.kind?(k=[Rp*p.layout.get("text-size").evaluate(m,{})],k[0]>Lp&&jt(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===z.kind&&(k=[Rp*P.compositeTextSizes[0].evaluate(m,{},M),Rp*P.compositeTextSizes[1].evaluate(m,{},M)],(k[0]>Lp||k[1]>Lp)&&jt(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,E,k,_,f,m,v,s,x.lineStartIndex,x.lineLength,T,M);for(const s of b)w[s]=e.text.placedSymbolArray.length-1;return 4*E.length}function zf(e){for(const s in e)return e[s];return null}function kf(e,s,a,l){const h=e.compareText;if(s in h){const e=h[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 h=Df[15&a];if(!h)throw new Error("Unrecognized array type.");const[p]=new Uint16Array(e,2,1),[f]=new Uint32Array(e,4,1);return new vp(f,p,h,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 h=Df.indexOf(this.ArrayType),p=2*e*this.ArrayType.BYTES_PER_ELEMENT,f=e*this.IndexArrayType.BYTES_PER_ELEMENT,m=(8-f%8)%8;if(h<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+f+m,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+p+f+m),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+f+m,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+h]),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 Rf(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:h,coords:p,nodeSize:f}=this,m=[0,h.length-1,0],_=[];for(;m.length;){const x=m.pop()||0,v=m.pop()||0,b=m.pop()||0;if(v-b<=f){for(let f=b;f<=v;f++){const m=p[2*f],x=p[2*f+1];m>=e&&m<=a&&x>=s&&x<=l&&_.push(h[f])}continue}const w=b+v>>1,T=p[2*w],P=p[2*w+1];T>=e&&T<=a&&P>=s&&P<=l&&_.push(h[w]),(0===x?e<=T:s<=P)&&(m.push(b),m.push(w-1),m.push(1-x)),(0===x?a>=T:l>=P)&&(m.push(w+1),m.push(v),m.push(1-x))}return _}within(e,s,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:h,nodeSize:p}=this,f=[0,l.length-1,0],m=[],_=a*a;for(;f.length;){const x=f.pop()||0,v=f.pop()||0,b=f.pop()||0;if(v-b<=p){for(let a=b;a<=v;a++)Of(h[2*a],h[2*a+1],e,s)<=_&&m.push(l[a]);continue}const w=b+v>>1,T=h[2*w],P=h[2*w+1];Of(T,P,e,s)<=_&&m.push(l[w]),(0===x?e-a<=T:s-a<=P)&&(f.push(b),f.push(w-1),f.push(1-x)),(0===x?e+a>=T:s+a>=P)&&(f.push(w+1),f.push(v),f.push(1-x))}return m}}function Rf(e,s,a,l,h,p){if(h-l<=a)return;const f=l+h>>1;Lf(e,s,f,l,h,p),Rf(e,s,a,l,f-1,1-p),Rf(e,s,a,f+1,h,1-p)}function Lf(e,s,a,l,h,p){for(;h>l;){if(h-l>600){const f=h-l+1,m=a-l+1,_=Math.log(f),x=.5*Math.exp(2*_/3),v=.5*Math.sqrt(_*x*(f-x)/f)*(m-f/2<0?-1:1);Lf(e,s,a,Math.max(l,Math.floor(a-m*x/f+v)),Math.min(h,Math.floor(a+(f-m)*x/f+v)),p)}const f=s[2*a+p];let m=l,_=h;for(Ff(e,s,l,a),s[2*h+p]>f&&Ff(e,s,l,h);m<_;){for(Ff(e,s,m,_),m++,_--;s[2*m+p]f;)_--}s[2*l+p]===f?Ff(e,s,l,_):(_++,Ff(e,s,_,h)),_<=a&&(l=_+1),a<=_&&(h=_-1)}}function Ff(e,s,a,l){Bf(e,a,l),Bf(s,2*a,2*l),Bf(s,2*a+1,2*l+1)}function Bf(e,s,a){const l=e[s];e[s]=e[a],e[a]=l}function Of(e,s,a,l){const h=e-a,p=s-l;return h*h+p*p}var jf;s.cx=void 0,(jf=s.cx||(s.cx={})).create="create",jf.load="load",jf.fullLoad="fullLoad";let Vf=null,Nf=[];const Uf=1e3/60,$f="loadTime",Gf="fullLoadTime",Zf={mark(e){performance.mark(e)},frame(e){const s=e;null!=Vf&&Nf.push(s-Vf),Vf=s},clearMetrics(){Vf=null,Nf=[],performance.clearMeasures($f),performance.clearMeasures(Gf);for(const e in s.cx)performance.clearMarks(s.cx[e])},getPerformanceMetrics(){performance.measure($f,s.cx.create,s.cx.load),performance.measure(Gf,s.cx.create,s.cx.fullLoad);const e=performance.getEntriesByName($f)[0].duration,a=performance.getEntriesByName(Gf)[0].duration,l=Nf.length,h=1/(Nf.reduce(((e,s)=>e+s),0)/l/1e3),p=Nf.filter((e=>e>Uf)).reduce(((e,s)=>e+(s-Uf)/Uf),0);return{loadTime:e,fullLoadTime:a,fps:h,percentDroppedFrames:p/(l+p)*100,totalFrames:l}}};s.$=at,s.A=P,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=dn,s.D=Os,s.E=xt,s.F=Ps,s.G=oc,s.H=Xt,s.I=Pc,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 bh((()=>this.process())),this.subscription=re(this.target,"message",(e=>this.receive(e)),!1),this.globalScope=Zt(self)?e:window}registerMessageHandler(e,s){this.messageHandlers[e]=s}sendAsync(e,s){return new Promise(((a,l)=>{const h=Math.round(1e18*Math.random()).toString(36).substring(0,10),p=s?re(s.signal,"abort",(()=>{null==p||p.unsubscribe(),delete this.resolveRejects[h];const s={id:h,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(s)}),Wp):null;this.resolveRejects[h]={resolve:e=>{null==p||p.unsubscribe(),a(e)},reject:e=>{null==p||p.unsubscribe(),l(e)}};const f=[],m=Object.assign(Object.assign({},e),{id:h,sourceMapId:this.mapId,origin:location.origin,data:_c(e.data,f)});this.target.postMessage(m,{transfer:f})}))}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(Zt(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(gc(s.error)):a.resolve(gc(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=gc(s.data),l=new AbortController;this.abortControllers[e]=l;try{const h=yield this.messageHandlers[s.type](s.sourceMapId,a,l);this.completeTask(e,null,h)}catch(a){this.completeTask(e,a)}}))}completeTask(e,s,a){const l=[];delete this.abortControllers[e];const h={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:s?_c(s):null,data:_c(a,l)};this.target.postMessage(h,{transfer:l})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},s.K=ge,s.L=function(){var e=new P(16);return P!=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,h,p,f,m,_,x,v,b,w,T,P,M=a[0],E=a[1],z=a[2];return s===e?(e[12]=s[0]*M+s[4]*E+s[8]*z+s[12],e[13]=s[1]*M+s[5]*E+s[9]*z+s[13],e[14]=s[2]*M+s[6]*E+s[10]*z+s[14],e[15]=s[3]*M+s[7]*E+s[11]*z+s[15]):(h=s[1],p=s[2],f=s[3],m=s[4],_=s[5],x=s[6],v=s[7],b=s[8],w=s[9],T=s[10],P=s[11],e[0]=l=s[0],e[1]=h,e[2]=p,e[3]=f,e[4]=m,e[5]=_,e[6]=x,e[7]=v,e[8]=b,e[9]=w,e[10]=T,e[11]=P,e[12]=l*M+m*E+b*z+s[12],e[13]=h*M+_*E+w*z+s[13],e[14]=p*M+x*E+T*z+s[14],e[15]=f*M+v*E+P*z+s[15]),e},s.N=function(e,s,a){var l=a[0],h=a[1],p=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]*h,e[5]=s[5]*h,e[6]=s[6]*h,e[7]=s[7]*h,e[8]=s[8]*p,e[9]=s[9]*p,e[10]=s[10]*p,e[11]=s[11]*p,e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],e},s.O=function(e,s,a){var l=s[0],h=s[1],p=s[2],f=s[3],m=s[4],_=s[5],x=s[6],v=s[7],b=s[8],w=s[9],T=s[10],P=s[11],M=s[12],E=s[13],z=s[14],k=s[15],L=a[0],F=a[1],B=a[2],j=a[3];return e[0]=L*l+F*m+B*b+j*M,e[1]=L*h+F*_+B*w+j*E,e[2]=L*p+F*x+B*T+j*z,e[3]=L*f+F*v+B*P+j*k,e[4]=(L=a[4])*l+(F=a[5])*m+(B=a[6])*b+(j=a[7])*M,e[5]=L*h+F*_+B*w+j*E,e[6]=L*p+F*x+B*T+j*z,e[7]=L*f+F*v+B*P+j*k,e[8]=(L=a[8])*l+(F=a[9])*m+(B=a[10])*b+(j=a[11])*M,e[9]=L*h+F*_+B*w+j*E,e[10]=L*p+F*x+B*T+j*z,e[11]=L*f+F*v+B*P+j*k,e[12]=(L=a[12])*l+(F=a[13])*m+(B=a[14])*b+(j=a[15])*M,e[13]=L*h+F*_+B*w+j*E,e[14]=L*p+F*x+B*T+j*z,e[15]=L*f+F*v+B*P+j*k,e},s.P=l,s.Q=function(e,s){const a={};for(let l=0;l!l.has(e.id)))),m.update&&(m.update=m.update.filter((e=>!l.has(e.id))));const h=new Set((null!==(a=e.add)&&void 0!==a?a:[]).map((e=>e.id)));s.remove=s.remove.filter((e=>!h.has(e)))}if(s.remove){const e=new Set(m.remove?m.remove.concat(s.remove):s.remove);m.remove=Array.from(e.values())}if(s.add){const e=m.add?m.add.concat(s.add):s.add,a=new Map(e.map((e=>[e.id,e])));m.add=Array.from(a.values())}if(s.update){const e=new Map(null===(l=m.update)||void 0===l?void 0:l.map((e=>[e.id,e])));for(const a of s.update){const s=null!==(h=e.get(a.id))&&void 0!==h?h:{id:a.id};a.newGeometry&&(s.newGeometry=a.newGeometry),a.addOrUpdateProperties&&(s.addOrUpdateProperties=(null!==(p=s.addOrUpdateProperties)&&void 0!==p?p:[]).concat(a.addOrUpdateProperties)),a.removeProperties&&(s.removeProperties=(null!==(f=s.removeProperties)&&void 0!==f?f:[]).concat(a.removeProperties)),a.removeAllProperties&&(s.removeAllProperties=!0),e.set(a.id,s)}m.update=Array.from(e.values())}return m.remove&&m.add&&(m.remove=m.remove.filter((e=>-1===m.add.findIndex((s=>s.id===e))))),m},s.a1=Eh,s.a2=Lh,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");ve(a)||(s.crossOrigin="Anonymous"),e.src=a,s.appendChild(e)}}))},s.a6=Et,s.a7=function(){return St++},s.a8=Ma,s.a9=ch,s.aA=function(e){let s=1/0,a=1/0,l=-1/0,h=-1/0;for(const p of e)s=Math.min(s,p.x),a=Math.min(a,p.y),l=Math.max(l,p.x),h=Math.max(h,p.y);return[s,a,l,h]},s.aB=Zd,s.aC=lt,s.aD=function(e,s,a,l,h=!1){if(!a[0]&&!a[1])return[0,0];const p=h?"map"===l?-e.bearingInRadians:0:"viewport"===l?e.bearingInRadians:0;if(p){const e=Math.sin(p),s=Math.cos(p);a=[a[0]*s-a[1]*e,a[0]*e+a[1]*s]}return[h?a[0]:lt(s,a[0],e.zoom),h?a[1]:lt(s,a[1],e.zoom)]},s.aF=Bp,s.aG=Cf,s.aH=Pp,s.aI=vp,s.aJ=Nc,s.aK=ou,s.aL=$a,s.aM=to,s.aN=Ka,s.aO=Tt,s.aP=ae,s.aQ=ef,s.aR=B,s.aS=F,s.aT=function(e){var s=new P(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],h=s[2],p=a*a+l*l+h*h;return p>0&&(p=1/Math.sqrt(p)),e[0]=s[0]*p,e[1]=s[1]*p,e[2]=s[2]*p,e},s.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=k,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=al,s.ab=_h,s.ac=Rh,s.ad=function(e){const s={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,a,l,h)=>{const p=l||h;return s[a]=!p||p.toLowerCase(),""})),s["max-age"]){const e=parseInt(s["max-age"],10);isNaN(e)?delete s["max-age"]:s["max-age"]=e}return s},s.ae=vt,s.af=85.051129,s.ag=se,s.ah=function(e){return Math.pow(2,e)},s.ai=E,s.aj=Qp,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){if(!e.length)return new Set;const s=Math.max(...e.map((e=>e.canonical.z)));let a=1/0,l=-1/0,h=1/0,p=-1/0;const f=[];for(const m of e){const{x:e,y:_,z:x}=m.canonical,v=Math.pow(2,s-x),b=e*v,w=_*v;f.push({id:m,x:b,y:w}),bl&&(l=b),wp&&(p=w)}const m=new Set;for(const e of f)e.x!==a&&e.x!==l&&e.y!==h&&e.y!==p||m.add(e.id);return m},s.an=function(e,s){let a=0,l=0;if("constant"===e.kind)l=e.layoutSize;else if("source"!==e.kind){const{interpolationType:h,minZoom:p,maxZoom:f}=e,m=h?vt(fr.interpolationFactor(h,s,p,f),0,1):0;"camera"===e.kind?l=dn.number(e.minSize,e.maxSize,m):a=m}return{uSizeT:a,uSize:l}},s.ap=function(e,{uSize:s,uSizeT:a},{lowerSize:l,upperSize:h}){return"source"===e.kind?l/Rp:"composite"===e.kind?dn.number(l/Rp,h/Rp,a):s},s.aq=function(e,s){var a=s[0],l=s[1],h=s[2],p=s[3],f=s[4],m=s[5],_=s[6],x=s[7],v=s[8],b=s[9],w=s[10],T=s[11],P=s[12],M=s[13],E=s[14],z=s[15],k=a*m-l*f,L=a*_-h*f,F=a*x-p*f,B=l*_-h*m,j=l*x-p*m,V=h*x-p*_,N=v*M-b*P,U=v*E-w*P,G=v*z-T*P,Z=b*E-w*M,nt=b*z-T*M,st=w*z-T*E,at=k*st-L*nt+F*Z+B*G-j*U+V*N;return at?(e[0]=(m*st-_*nt+x*Z)*(at=1/at),e[1]=(h*nt-l*st-p*Z)*at,e[2]=(M*V-E*j+z*B)*at,e[3]=(w*j-b*V-T*B)*at,e[4]=(_*G-f*st-x*U)*at,e[5]=(a*st-h*G+p*U)*at,e[6]=(E*F-P*V-z*L)*at,e[7]=(v*V-w*F+T*L)*at,e[8]=(f*nt-m*G+x*N)*at,e[9]=(l*G-a*nt-p*N)*at,e[10]=(P*j-M*F+z*k)*at,e[11]=(b*F-v*j-T*k)*at,e[12]=(m*U-f*Z-_*N)*at,e[13]=(a*Z-l*U+h*N)*at,e[14]=(M*L-P*B-E*k)*at,e[15]=(v*B-b*L+w*k)*at,e):null},s.ar=nt,s.as=function(e){var s=e[0],a=e[1];return Math.sqrt(s*s+a*a)},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=Vp,s.aw=U,s.ax=function(e,s,a,h){const p=s.y-e.y,f=s.x-e.x,m=h.y-a.y,_=h.x-a.x,x=m*f-_*p;if(0===x)return null;const v=(_*(e.y-a.y)-m*(e.x-a.x))/x;return new l(e.x+v*f,e.y+v*p)},s.ay=lf,s.az=Th,s.b=Yt,s.b$=class extends go{constructor(e,s){super(e,s),this.current=new Array}set(e){if(e!=this.current){this.current=e;const s=new Float32Array(e);this.gl.uniform1fv(this.location,s)}}},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=Vh,s.b3=nf,s.b4=function(e,s,a,l,h){var p=1/Math.tan(s/2);if(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!=h&&h!==1/0){var f=1/(l-h);e[10]=(h+l)*f,e[14]=2*h*l*f}else e[10]=-1,e[14]=-2*l;return e},s.b5=function(e){var s=new P(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),h=Math.cos(a),p=s[0],f=s[1],m=s[2],_=s[3],x=s[4],v=s[5],b=s[6],w=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]=p*h+x*l,e[1]=f*h+v*l,e[2]=m*h+b*l,e[3]=_*h+w*l,e[4]=x*h-p*l,e[5]=v*h-f*l,e[6]=b*h-m*l,e[7]=w*h-_*l,e},s.b7=function(e,s,a){var l=Math.sin(a),h=Math.cos(a),p=s[4],f=s[5],m=s[6],_=s[7],x=s[8],v=s[9],b=s[10],w=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]=p*h+x*l,e[5]=f*h+v*l,e[6]=m*h+b*l,e[7]=_*h+w*l,e[8]=x*h-p*l,e[9]=v*h-f*l,e[10]=b*h-m*l,e[11]=w*h-_*l,e},s.b8=function(){const e=new Float32Array(16);return E(e),e},s.b9=function(){const e=new Float64Array(16);return E(e),e},s.bA=function(e,s){const a=ht(e,360),l=ht(s,360),h=l-a,p=l>a?h-360:h+360;return Math.abs(h)0?f:-f},s.bD=function(e,s){const a=ht(e,2*Math.PI),l=ht(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=Se.$version;for(const a in Se.$root){const l=Se.$root[a];if(l.required){let h=null;h="version"===a?s:"array"===l.type?[]:{},null!=h&&(e[a]=h)}}return e},s.bF=ds,s.bG=ye,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"raster"===e.type,s.bL=At,s.bM=function(e,s){if(!e)return[{command:"setStyle",args:[s]}];let a=[];try{if(!De(e.version,s.version))return[{command:"setStyle",args:[s]}];De(e.center,s.center)||a.push({command:"setCenter",args:[s.center]}),De(e.state,s.state)||a.push({command:"setGlobalState",args:[s.state]}),De(e.centerAltitude,s.centerAltitude)||a.push({command:"setCenterAltitude",args:[s.centerAltitude]}),De(e.zoom,s.zoom)||a.push({command:"setZoom",args:[s.zoom]}),De(e.bearing,s.bearing)||a.push({command:"setBearing",args:[s.bearing]}),De(e.pitch,s.pitch)||a.push({command:"setPitch",args:[s.pitch]}),De(e.roll,s.roll)||a.push({command:"setRoll",args:[s.roll]}),De(e.sprite,s.sprite)||a.push({command:"setSprite",args:[s.sprite]}),De(e.glyphs,s.glyphs)||a.push({command:"setGlyphs",args:[s.glyphs]}),De(e.transition,s.transition)||a.push({command:"setTransition",args:[s.transition]}),De(e.light,s.light)||a.push({command:"setLight",args:[s.light]}),De(e.terrain,s.terrain)||a.push({command:"setTerrain",args:[s.terrain]}),De(e.sky,s.sky)||a.push({command:"setSky",args:[s.sky]}),De(e.projection,s.projection)||a.push({command:"setProjection",args:[s.projection]});const l={},h=[];!function(e,s,a,l){let h;for(h in s=s||{},e=e||{})Object.prototype.hasOwnProperty.call(e,h)&&(Object.prototype.hasOwnProperty.call(s,h)||Ne(h,a,l));for(h in s)Object.prototype.hasOwnProperty.call(s,h)&&(Object.prototype.hasOwnProperty.call(e,h)?De(e[h],s[h])||("geojson"===e[h].type&&"geojson"===s[h].type&&Ge(e,s,h)?Re(a,{command:"setGeoJSONSourceData",args:[h,s[h].data]}):Ue(h,s,a,l)):je(h,s,a))}(e.sources,s.sources,h,l);const p=[];e.layers&&e.layers.forEach((e=>{"source"in e&&l[e.source]?a.push({command:"removeLayer",args:[e.id]}):p.push(e)})),a=a.concat(h),function(e,s,a){s=s||[];const l=(e=e||[]).map(He),h=s.map(He),p=e.reduce(ri,{}),f=s.reduce(ri,{}),m=l.slice(),_=Object.create(null);let x,v,b,w,T;for(let e=0,s=0;eT?(h=Math.acos(p),f=Math.sin(h),m=Math.sin((1-l)*h)/f,_=Math.sin(l*h)/f):(m=1-l,_=l),e[0]=m*x+_*P,e[1]=m*v+_*M,e[2]=m*b+_*E,e[3]=m*w+_*z,e},s.bd=function(e){const s=new Float64Array(9);var a,l,h,p,f,m,_,x,v,b,w,T,P,M,E,z,k,L;b=(h=(l=e)[0])*(_=h+h),w=(p=l[1])*_,P=(f=l[2])*_,M=f*(x=p+p),z=(m=l[3])*_,k=m*x,L=m*(v=f+f),(a=s)[0]=1-(T=p*x)-(E=f*v),a[3]=w-L,a[6]=P+k,a[1]=w+L,a[4]=1-b-E,a[7]=M-z,a[2]=P-k,a[5]=M+z,a[8]=1-b-T;const F=ae(-Math.asin(vt(s[2],-1,1)));let B,j;return Math.hypot(s[5],s[8])<.001?(B=0,j=-ae(Math.atan2(s[3],s[4]))):(B=ae(0===s[5]&&0===s[8]?0:Math.atan2(s[5],s[8])),j=ae(0===s[1]&&0===s[0]?0:Math.atan2(s[1],s[0]))),{roll:B,pitch:F+90,bearing:j}},s.be=function(e,s){return e.roll==s.roll&&e.pitch==s.pitch&&e.bearing==s.bearing},s.bf=Ie,s.bg=xo,s.bh=ed,s.bi=id,s.bj=au,s.bk=ut,s.bl=dt,s.bm=Oe,s.bn=function(e,s,a,l,h){return ut(l,h,vt((e-s)/(a-s),0,1))},s.bo=ht,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=Z,s.bs=function(e,s,a){var l=a[0],h=a[1],p=a[2],f=a[3],m=s[0],_=s[1],x=s[2],v=h*x-p*_,b=p*m-l*x,w=l*_-h*m;return e[0]=m+f*(v+=v)+h*(w+=w)-p*(b+=b),e[1]=_+f*b+p*v-l*w,e[2]=x+f*w+l*b-h*v,e},s.bt=function(e,s,a){const l=(h=[e[0],e[1],e[2],s[0],s[1],s[2],a[0],a[1],a[2]])[0]*((v=h[8])*(f=h[4])-(m=h[5])*(x=h[7]))+h[1]*(-v*(p=h[3])+m*(_=h[6]))+h[2]*(x*p-f*_);var h,p,f,m,_,x,v;if(0===l)return null;const b=j([],[s[0],s[1],s[2]],[a[0],a[1],a[2]]),w=j([],[a[0],a[1],a[2]],[e[0],e[1],e[2]]),T=j([],[e[0],e[1],e[2]],[s[0],s[1],s[2]]),P=B([],b,-e[3]);return F(P,P,B([],w,-s[3])),F(P,P,B([],T,-a[3])),B(P,P,1/l),P},s.bu=Hp,s.bv=function(){return new Float64Array(4)},s.bw=function(e,s,a,l){var h=[],p=[];return h[0]=s[0]-a[0],h[1]=s[1]-a[1],h[2]=s[2]-a[2],p[0]=h[0]*Math.cos(l)-h[1]*Math.sin(l),p[1]=h[0]*Math.sin(l)+h[1]*Math.cos(l),p[2]=h[2],e[0]=p[0]+a[0],e[1]=p[1]+a[1],e[2]=p[2]+a[2],e},s.bx=function(e,s,a,l){var h=[],p=[];return h[0]=s[0]-a[0],h[1]=s[1]-a[1],h[2]=s[2]-a[2],p[0]=h[0],p[1]=h[1]*Math.cos(l)-h[2]*Math.sin(l),p[2]=h[1]*Math.sin(l)+h[2]*Math.cos(l),e[0]=p[0]+a[0],e[1]=p[1]+a[1],e[2]=p[2]+a[2],e},s.by=function(e,s,a,l){var h=[],p=[];return h[0]=s[0]-a[0],h[1]=s[1]-a[1],h[2]=s[2]-a[2],p[0]=h[2]*Math.sin(l)+h[0]*Math.cos(l),p[1]=h[1],p[2]=h[2]*Math.cos(l)-h[0]*Math.sin(l),e[0]=p[0]+a[0],e[1]=p[1]+a[1],e[2]=p[2]+a[2],e},s.bz=function(e,s,a){var l=Math.sin(a),h=Math.cos(a),p=s[0],f=s[1],m=s[2],_=s[3],x=s[8],v=s[9],b=s[10],w=s[11];return s!==e&&(e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15]),e[0]=p*h-x*l,e[1]=f*h-v*l,e[2]=m*h-b*l,e[3]=_*h-w*l,e[8]=p*l+x*h,e[9]=f*l+v*h,e[10]=m*l+b*h,e[11]=_*l+w*h,e},s.c=fe,s.c0=class extends da{},s.c1=Ud,s.c2=class extends ma{},s.c3=uu,s.c4=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},s.c5=hu,s.c6=function(e,s,a){var l=s[0],h=s[1],p=s[2],f=a[3]*l+a[7]*h+a[11]*p+a[15];return e[0]=(a[0]*l+a[4]*h+a[8]*p+a[12])/(f=f||1),e[1]=(a[1]*l+a[5]*h+a[9]*p+a[13])/f,e[2]=(a[2]*l+a[6]*h+a[10]*p+a[14])/f,e},s.c7=class extends na{},s.c8=class extends Sa{},s.c9=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.cA=function(e,s){me.REGISTERED_PROTOCOLS[e]=s},s.cB=function(e){delete me.REGISTERED_PROTOCOLS[e]},s.cC=function(e,s){const a={};for(let l=0;le*Zd))}let L=m?"center":l.get("text-justify").evaluate(h,{},e.canonical);const F="point"===l.get("symbol-placement")?l.get("text-max-width").evaluate(h,{},e.canonical)*Zd:1/0,B=()=>{e.bucket.allowVerticalPlacement&&xc(p)&&(P.vertical=pp(M,e.glyphMap,e.glyphPositions,e.imagePositions,v,F,f,E,"left",T,z,s.ao.vertical,!0,w,b))};if(!m&&k){const a=new Set;if("auto"===L)for(let e=0;e0||(null===(h=a.addOrUpdateProperties)||void 0===h?void 0:h.length)>0);if((a.newGeometry||a.removeAllProperties||m)&&(s=Object.assign({},s),e.set(a.id,s),m&&(s.properties=Object.assign({},s.properties))),a.newGeometry&&(s.geometry=a.newGeometry),a.removeAllProperties)s.properties={};else if((null===(p=a.removeProperties)||void 0===p?void 0:p.length)>0)for(const e of a.removeProperties)Object.prototype.hasOwnProperty.call(s.properties,e)&&delete s.properties[e];if((null===(f=a.addOrUpdateProperties)||void 0===f?void 0:f.length)>0)for(const{key:e,value:l}of a.addOrUpdateProperties)s.properties[e]=l}},s.cX=Rc,s.ca=function(e,s){var a=e[0],l=e[1],h=e[2],p=e[3],f=e[4],m=e[5],_=e[6],x=e[7],v=e[8],b=e[9],w=e[10],P=e[11],M=e[12],E=e[13],z=e[14],k=e[15],L=s[0],F=s[1],B=s[2],j=s[3],V=s[4],N=s[5],U=s[6],G=s[7],Z=s[8],nt=s[9],st=s[10],at=s[11],lt=s[12],ht=s[13],ut=s[14],dt=s[15];return Math.abs(a-L)<=T*Math.max(1,Math.abs(a),Math.abs(L))&&Math.abs(l-F)<=T*Math.max(1,Math.abs(l),Math.abs(F))&&Math.abs(h-B)<=T*Math.max(1,Math.abs(h),Math.abs(B))&&Math.abs(p-j)<=T*Math.max(1,Math.abs(p),Math.abs(j))&&Math.abs(f-V)<=T*Math.max(1,Math.abs(f),Math.abs(V))&&Math.abs(m-N)<=T*Math.max(1,Math.abs(m),Math.abs(N))&&Math.abs(_-U)<=T*Math.max(1,Math.abs(_),Math.abs(U))&&Math.abs(x-G)<=T*Math.max(1,Math.abs(x),Math.abs(G))&&Math.abs(v-Z)<=T*Math.max(1,Math.abs(v),Math.abs(Z))&&Math.abs(b-nt)<=T*Math.max(1,Math.abs(b),Math.abs(nt))&&Math.abs(w-st)<=T*Math.max(1,Math.abs(w),Math.abs(st))&&Math.abs(P-at)<=T*Math.max(1,Math.abs(P),Math.abs(at))&&Math.abs(M-lt)<=T*Math.max(1,Math.abs(M),Math.abs(lt))&&Math.abs(E-ht)<=T*Math.max(1,Math.abs(E),Math.abs(ht))&&Math.abs(z-ut)<=T*Math.max(1,Math.abs(z),Math.abs(ut))&&Math.abs(k-dt)<=T*Math.max(1,Math.abs(k),Math.abs(dt))},s.cb=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.cc=e=>"symbol"===e.type,s.cd=e=>"circle"===e.type,s.ce=e=>"heatmap"===e.type,s.cf=e=>"line"===e.type,s.cg=e=>"fill"===e.type,s.ch=e=>"fill-extrusion"===e.type,s.ci=e=>"hillshade"===e.type,s.cj=e=>"color-relief"===e.type,s.ck=e=>"background"===e.type,s.cl=e=>"custom"===e.type,s.cm=pt,s.cn=function(e,s,a){const l=st(s.x-a.x,s.y-a.y),h=st(e.x-a.x,e.y-a.y);var p,f;return ae(Math.atan2(l[0]*h[1]-l[1]*h[0],(p=l)[0]*(f=h)[0]+p[1]*f[1]))},s.co=_t,s.cp=function(e,s){return de[s]&&(e instanceof MouseEvent||e instanceof WheelEvent)},s.cq=function(e,s){return ue[s]&&"touches"in e},s.cr=function(e){return ue[e]||de[e]},s.cs=function(e,s,a){var l=s[0],h=s[1];return e[0]=a[0]*l+a[4]*h+a[12],e[1]=a[1]*l+a[5]*h+a[13],e},s.ct=function(e,s){const{x:a,y:l}=Eh.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 ra{},s.cw=Zf,s.cy=function(e){return e.message===pe},s.cz=ct,s.d=ve,s.e=Pt,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=_e,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=Kt}))},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 h=new Blob([new Uint8Array(e)],{type:"image/png"});l.src=e.byteLength?URL.createObjectURL(h):Kt})),s.i=Zt,s.j=(e,s)=>xe(Pt(e,{type:"json"}),s),s.k=gt,s.l=mt,s.m=xe,s.n=(e,s)=>xe(Pt(e,{type:"arrayBuffer"}),s),s.o=function(e){return new fc(e).readFields(lp,[])},s.p=up,s.q=gl,s.r=qs,s.s=re,s.t=Bs,s.u=yc,s.v=Se,s.w=jt,s.x=sc,s.y=cc,s.z=nc}));l("worker",["./shared"],(function(e){class t{constructor(e,s){this.keyCache={},e&&this.replace(e,s)}replace(e,s){this._layerConfigs={},this._layers={},this.update(e,[],s)}update(s,a,l){for(const a of s){this._layerConfigs[a.id]=a;const s=this._layers[a.id]=e.bJ(a,l);s._featureFilter=e.aa(s.filter,l),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 h=e.cC(Object.values(this._layerConfigs),this.keyCache);for(const e of h){const s=e.map((e=>this._layers[e.id])),a=s[0];if("none"===a.visibility)continue;const l=a.source||"";let h=this.familiesBySource[l];h||(h=this.familiesBySource[l]={});const p=a.sourceLayer||"_geojsonTileLayer";let f=h[p];f||(f=h[p]=[]),f.push(s)}}}class i{constructor(s){const a={},l=[];for(const e in s){const h=s[e],p=a[e]={};for(const e in h){const s=h[+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),p[e]={rect:a,metrics:s.metrics}}}const{w:h,h:p}=e.p(l),f=new e.q({width:h||1,height:p||1});for(const l in s){const h=s[l];for(const s in h){const p=h[+s];if(!p||0===p.bitmap.width||0===p.bitmap.height)continue;const m=a[l][s].rect;e.q.copy(p.bitmap,f,{x:0,y:0},{x:m.x+1,y:m.y+1},p.bitmap)}}this.image=f,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=[]}parse(a,l,h,p,f){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=a,this.collisionBoxArray=new e.a8;const m=new e.cE(Object.keys(a.layers).sort()),_=new e.cF(this.tileID,this.promoteId);_.bucketLayerIDs=[];const x={},v={featureIndex:_,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:h,subdivisionGranularity:f},b=l.familiesBySource[this.source];for(const l in b){const p=a.layers[l];if(!p)continue;1===p.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 f=m.encode(l),w=[];for(let e=0;ee.id))))}}const w=e.bO(v.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let T=Promise.resolve({});if(Object.keys(w).length){const e=new AbortController;this.inFlightDependencies.push(e),T=p.sendAsync({type:"GG",data:{stacks:w,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const P=Object.keys(v.iconDependencies);let M=Promise.resolve({});if(P.length){const e=new AbortController;this.inFlightDependencies.push(e),M=p.sendAsync({type:"GI",data:{icons:P,source:this.source,tileID:this.tileID,type:"icons"}},e)}const E=Object.keys(v.patternDependencies);let z=Promise.resolve({});if(E.length){const e=new AbortController;this.inFlightDependencies.push(e),z=p.sendAsync({type:"GI",data:{icons:E,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const k=v.dashDependencies;let L=Promise.resolve({});if(Object.keys(k).length){const e=new AbortController;this.inFlightDependencies.push(e),L=p.sendAsync({type:"GDA",data:{dashes:k}},e)}const[F,B,j,V]=yield Promise.all([T,M,z,L]),N=new i(F),U=new e.cG(B,j);for(const a in x){const l=x[a];l instanceof e.a9?(s(l.layers,this.zoom,h),e.cH({bucket:l,glyphMap:F,glyphPositions:N.positions,imageMap:B,imagePositions:U.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:v.subdivisionGranularity})):l.hasDependencies&&(l instanceof e.cI||l instanceof e.cJ||l instanceof e.cK)&&(s(l.layers,this.zoom,h),l.addFeatures(v,this.tileID.canonical,U.patternPositions,V))}return this.status="done",{buckets:Object.values(x).filter((e=>!e.isEmpty())),featureIndex:_,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:N.image,imageAtlas:U,dashPositions:V,glyphMap:this.returnDependencies?F:null,iconMap:this.returnDependencies?B:null,glyphPositions:this.returnDependencies?N.positions:null}}))}}function s(s,a,l){const h=new e.F(a);for(const e of s)e.recalculate(h,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 h=`Unable to parse the tile at ${s.request.url}, `;throw h+=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(h)}}))}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),h=new o(s);this.loading[a]=h;const p=new AbortController;h.abort=p;try{const f=yield this.loadVectorTile(s,p);if(delete this.loading[a],!f)return null;const m=f.rawData,_={};f.expires&&(_.expires=f.expires),f.cacheControl&&(_.cacheControl=f.cacheControl);const x={};if(l){const e=l.finish();e&&(x.resourceTiming=JSON.parse(JSON.stringify(e)))}h.vectorTile=f.vectorTile;const v=h.parse(f.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity);this.loaded[a]=h,this.fetching[a]={rawTileData:m,cacheControl:_,resourceTiming:x};try{const s=yield v;return e.e({rawTileData:m.slice(0)},s,_,x)}finally{delete this.fetching[a]}}catch(e){throw delete this.loading[a],h.status="done",this.loaded[a]=h,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,"parsing"===l.status){const h=yield l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity);let p;if(this.fetching[a]){const{rawTileData:s,cacheControl:l,resourceTiming:f}=this.fetching[a];delete this.fetching[a],p=e.e({rawTileData:s.slice(0)},h,l,f)}else p=h;return p}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:h,redFactor:p,greenFactor:f,blueFactor:m,baseShift:_}=s,x=h.width+2,v=h.height+2,b=e.b(h)?new e.R({width:x,height:v},yield e.cO(h,-1,-1,x,v)):h,w=new e.cP(a,b,l,p,f,m,_);return this.loaded=this.loaded||{},this.loaded[a]=w,w}))}removeTile(e){const s=this.loaded,a=e.uid;s&&s[a]&&delete s[a]}}var a,l,h=function(){if(l)return a;function e(e,a){if(0!==e.length){s(e[0],a);for(var l=1;l=Math.abs(m)?a-_+m:m-_+a,a=_}a+l>=0!=!!s&&e.reverse()}return l=1,a=function s(a,l){var h,p=a&&a.type;if("FeatureCollection"===p)for(h=0;h>31}function b(e,s){const a=e.loadGeometry(),l=e.type;let h=0,p=0;for(const f of a){let a=1;1===l&&(a=f.length),s.writeVarint(x(1,a));const m=3===l?f.length-1:f.length;for(let e=0;ee},P=Math.fround||(M=new Float32Array(1),e=>(M[0]=+e,M[0]));var M;class S{constructor(e){this.options=Object.assign(Object.create(T),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 h=`prepare ${e.length} points`;s&&console.time(h),this.points=e;const p=[];for(let s=0;s=a;e--){const a=+Date.now();f=this.trees[e]=this._createTree(this._cluster(f,e)),s&&console.log("z%d: %d clusters in %dms",e,f.numItems,+Date.now()-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 h=180===e[2]?180:((e[2]+180)%360+360)%360-180;const p=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)a=-180,h=180;else if(a>h){const e=this.getClusters([a,l,180,p],s),f=this.getClusters([-180,l,h,p],s);return e.concat(f)}const f=this.trees[this._limitZoom(s)],m=f.range(k(a),L(p),k(h),L(l)),_=f.data,x=[];for(const e of m){const s=this.stride*e;x.push(_[s+5]>1?E(_,s,this.clusterProps):this.points[_[s+3]])}return x}getChildren(e){const s=this._getOriginId(e),a=this._getOriginZoom(e),l="No cluster with the specified id.",h=this.trees[a];if(!h)throw new Error(l);const p=h.data;if(s*this.stride>=p.length)throw new Error(l);const f=this.options.radius/(this.options.extent*Math.pow(2,a-1)),m=h.within(p[s*this.stride],p[s*this.stride+1],f),_=[];for(const s of m){const a=s*this.stride;p[a+4]===e&&_.push(p[a+5]>1?E(p,a,this.clusterProps):this.points[p[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)],h=Math.pow(2,e),{extent:p,radius:f}=this.options,m=f/p,_=(a-m)/h,x=(a+1+m)/h,v={features:[]};return this._addTileFeatures(l.range((s-m)/h,_,(s+1+m)/h,x),l.data,s,a,h,v),0===s&&this._addTileFeatures(l.range(1-m/h,_,1,x),l.data,h,a,h,v),s===h-1&&this._addTileFeatures(l.range(0,_,m/h,x),l.data,-1,a,h,v),v.features.length?v: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,h){const p=this.getChildren(s);for(const s of p){const p=s.properties;if(p&&p.cluster?h+p.point_count<=l?h+=p.point_count:h=this._appendLeaves(e,p.cluster_id,a,l,h):h1;let _,x,v;if(m)_=z(s,e,this.clusterProps),x=s[e],v=s[e+1];else{const a=this.points[s[e+3]];_=a.properties;const[l,h]=a.geometry.coordinates;x=k(l),v=L(h)}const b={type:1,geometry:[[Math.round(this.options.extent*(x*h-a)),Math.round(this.options.extent*(v*h-l))]],tags:_};let w;w=m||this.options.generateId?s[e+3]:this.points[s[e+3]].id,void 0!==w&&(b.id=w),p.features.push(b)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,s){const{radius:a,extent:l,reduce:h,minPoints:p}=this.options,f=a/(l*Math.pow(2,s)),m=e.data,_=[],x=this.stride;for(let a=0;as&&(T+=m[a+5])}if(T>w&&T>=p){let e,p=l*w,f=v*w,P=-1;const M=(a/x<<5)+(s+1)+this.points.length;for(const l of b){const _=l*x;if(m[_+2]<=s)continue;m[_+2]=s;const v=m[_+5];p+=m[_]*v,f+=m[_+1]*v,m[_+4]=M,h&&(e||(e=this._map(m,a,!0),P=this.clusterProps.length,this.clusterProps.push(e)),h(e,this._map(m,_)))}m[a+4]=M,_.push(p/T,f/T,1/0,M,-1,T),h&&_.push(P)}else{for(let e=0;e1)for(const e of b){const a=e*x;if(!(m[a+2]<=s)){m[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,h=this.options.map(l);return a&&h===l?Object.assign({},h):h}}function E(e,s,a){return{type:"Feature",id:e[s+3],properties:z(e,s,a),geometry:{type:"Point",coordinates:[(l=e[s],360*(l-.5)),F(e[s+1])]}};var l}function z(e,s,a){const l=e[s+5],h=l>=1e4?`${Math.round(l/1e3)}k`:l>=1e3?Math.round(l/100)/10+"k":l,p=e[s+6],f=-1===p?{}:Object.assign({},a[p]);return Object.assign(f,{cluster:!0,cluster_id:e[s+3],point_count:l,point_count_abbreviated:h})}function k(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 F(e){const s=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(s))/Math.PI-90}function B(e,s,a,l){let h=l;const p=s+(a-s>>1);let f,m=a-s;const _=e[s],x=e[s+1],v=e[a],b=e[a+1];for(let l=s+3;lh)f=l,h=s;else if(s===h){const e=Math.abs(l-p);el&&(f-s>3&&B(e,s,f,l),e[f+2]=h,a-f>3&&B(e,f,a,l))}function j(e,s,a,l,h,p){let f=h-a,m=p-l;if(0!==f||0!==m){const _=((e-a)*f+(s-l)*m)/(f*f+m*m);_>1?(a=h,l=p):_>0&&(a+=f*_,l+=m*_)}return f=e-a,m=s-l,f*f+m*m}function V(e,s,a,l){const h={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(h,a);else if("Polygon"===s)N(h,a[0]);else if("MultiLineString"===s)for(const e of a)N(h,e);else if("MultiPolygon"===s)for(const e of a)N(h,e[0]);return h}function N(e,s){for(let a=0;a0&&(f+=l?(h*_-m*p)/2:Math.sqrt(Math.pow(m-h,2)+Math.pow(_-p,2))),h=m,p=_}const m=s.length-3;s[2]=1,B(s,0,m,a),s[m+2]=1,s.size=Math.abs(f),s.start=0,s.end=s.size}function nt(e,s,a,l){for(let h=0;h1?1:a}function lt(e,s,a,l,h,p,f,m){if(l/=s,p>=(a/=s)&&f=l)return null;const _=[];for(const s of e){const e=s.geometry;let p=s.type;const f=0===h?s.minX:s.minY,x=0===h?s.maxX:s.maxY;if(f>=a&&x=l)continue;let v=[];if("Point"===p||"MultiPoint"===p)ht(e,v,a,l,h);else if("LineString"===p)ut(e,v,a,l,h,!1,m.lineMetrics);else if("MultiLineString"===p)pt(e,v,a,l,h,!1);else if("Polygon"===p)pt(e,v,a,l,h,!0);else if("MultiPolygon"===p)for(const s of e){const e=[];pt(s,e,a,l,h,!0),e.length&&v.push(e)}if(v.length){if(m.lineMetrics&&"LineString"===p){for(const e of v)_.push(V(s.id,p,e,s.tags));continue}"LineString"!==p&&"MultiLineString"!==p||(1===v.length?(p="LineString",v=v[0]):p="MultiLineString"),"Point"!==p&&"MultiPoint"!==p||(p=3===v.length?"Point":"MultiPoint"),_.push(V(s.id,p,v,s.tags))}}return _.length?_:null}function ht(e,s,a,l,h){for(let p=0;p=a&&f<=l&&_t(s,e[p],e[p+1],e[p+2])}}function ut(e,s,a,l,h,p,f){let m=dt(e);const _=0===h?vt:Tt;let x,v,b=e.start;for(let w=0;wa&&(v=_(m,T,P,E,z,a),f&&(m.start=b+x*v)):k>l?L=a&&(v=_(m,T,P,E,z,a),F=!0),L>l&&k<=l&&(v=_(m,T,P,E,z,l),F=!0),!p&&F&&(f&&(m.end=b+x*v),s.push(m),m=dt(e)),f&&(b+=x)}let w=e.length-3;const T=e[w],P=e[w+1],M=0===h?T:P;M>=a&&M<=l&&_t(m,T,P,e[w+2]),w=m.length-3,p&&w>=3&&(m[w]!==m[0]||m[w+1]!==m[1])&&_t(m,m[0],m[1],m[2]),m.length&&s.push(m)}function dt(e){const s=[];return s.size=e.size,s.start=e.start,s.end=e.end,s}function pt(e,s,a,l,h,p){for(const f of e)ut(f,s,a,l,h,p,!1)}function _t(e,s,a,l){e.push(s,a,l)}function vt(e,s,a,l,h,p){const f=(p-s)/(l-s);return _t(e,p,a+(h-a)*f,1),f}function Tt(e,s,a,l,h,p){const f=(p-a)/(h-a);return _t(e,s+(l-s)*f,p,1),f}function Pt(e,s){const a=[];for(let l=0;l0&&s.size<(h?f:l))return void(a.numPoints+=s.length/3);const m=[];for(let e=0;ef)&&(a.numSimplified++,m.push(s[e],s[e+1])),a.numPoints++;h&&function(e,s){let a=0;for(let s=0,l=e.length,h=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"),w=this.tiles[b]=At(e,s,a,l,_),this.tileCoords.push({z:s,x:a,y:l}),x)){x>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",s,a,l,w.numFeatures,w.numPoints,w.numSimplified),console.timeEnd("creation"));const e=`z${s}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(w.source=e,null==h){if(s===_.indexMaxZoom||w.numPoints<=_.indexMaxPoints)continue}else{if(s===_.maxZoom||s===h)continue;if(null!=h){const e=h-s;if(a!==p>>e||l!==f>>e)continue}}if(w.source=null,0===e.length)continue;x>1&&console.time("clipping");const T=.5*_.buffer/_.extent,P=.5-T,M=.5+T,E=1+T;let z=null,k=null,L=null,F=null,B=lt(e,v,a-T,a+M,0,w.minX,w.maxX,_),j=lt(e,v,a+P,a+E,0,w.minX,w.maxX,_);e=null,B&&(z=lt(B,v,l-T,l+M,1,w.minY,w.maxY,_),k=lt(B,v,l+P,l+E,1,w.minY,w.maxY,_),B=null),j&&(L=lt(j,v,l-T,l+M,1,w.minY,w.maxY,_),F=lt(j,v,l+P,l+E,1,w.minY,w.maxY,_),j=null),x>1&&console.timeEnd("clipping"),m.push(z||[],s+1,2*a,2*l),m.push(k||[],s+1,2*a,2*l+1),m.push(L||[],s+1,2*a+1,2*l),m.push(F||[],s+1,2*a+1,2*l+1)}}getTile(e,s,a){e=+e,s=+s,a=+a;const l=this.options,{extent:h,debug:p}=l;if(e<0||e>24)return null;const f=1<1&&console.log("drilling down to z%d-%d-%d",e,s,a);let _,x=e,v=s,b=a;for(;!_&&x>0;)x--,v>>=1,b>>=1,_=this.tiles[Zt(x,v,b)];return _&&_.source?(p>1&&(console.log("found parent tile z%d-%d-%d",x,v,b),console.time("drilling down")),this.splitTile(_.source,x,v,b,e,s,a),p>1&&console.timeEnd("drilling down"),this.tiles[m]?Mt(this.tiles[m],h):null):null}}function Zt(e,s,a){return 32*((1<`${e.key}: ${e.message}`)).join(", "));const h=l.features.filter((e=>a.value.evaluate({zoom:0},e)));l={type:"FeatureCollection",features:h}}return l}))}loadGeoJSON(s,a){return e._(this,void 0,void 0,(function*(){const{promoteId:l}=s;if(s.request){const h=yield e.j(s.request,a);return this._dataUpdateable=e.cV(h.data,l)?e.cU(h.data,l):void 0,h.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)}}function qt(s,a){return a.cluster?new S(function({superclusterOptions:s,clusterProperties:a}){if(!a||!s)return s;const l={},h={},p={accumulated:null,zoom:0},f={properties:null},m=Object.keys(a);for(const s of m){const[p,f]=a[s],m=e.cT(f),_=e.cT("string"==typeof p?[p,["accumulated"],["get",s]]:p);l[s]=m.value,h[s]=_.value}return s.map=e=>{f.properties=e;const s={};for(const e of m)s[e]=l[e].evaluate(p,f);return s},s.reduce=(e,s)=>{f.properties=s;for(const s of m)p.accumulated=e[s],e[s]=h[s].evaluate(p,f)},s}(a)).load(s.features):function(e,s){return new te(e,s)}(s,a.geojsonVtOptions)}class ne{constructor(s){this.self=s,this.actor=new e.J(s),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,s)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=s},this.self.addProtocol=e.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.globalStates.delete(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._getGlobalState(s))})))),this.actor.registerMessageHandler("UGS",((s,a)=>e._(this,void 0,void 0,(function*(){const e=this._getGlobalState(s);for(const s in a)e[s]=a[s]})))),this.actor.registerMessageHandler("SL",((s,a)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(s).replace(a,this._getGlobalState(s))}))))}_getGlobalState(e){let s=this.globalStates.get(e);return s||(s={},this.globalStates.set(e,s)),s}_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 ne(self)),ne}));l("index",["exports","./shared"],(function(s,a){var l="5.10.0";function h(){var e=new a.A(4);return a.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let p,f;const m={frame(e,s,l){const h=requestAnimationFrame((e=>{p(),s(e)})),{unsubscribe:p}=a.s(e.signal,"abort",(()=>{p(),cancelAnimationFrame(h),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=>(p||(p=document.createElement("a")),p.href=e,p.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==f&&(f=matchMedia("(prefers-reduced-motion: reduce)")),f.matches)}},_=new class{constructor(){this._realTime="undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:this._realTime()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function x(){return _.getCurrentTime()}class c{static testProp(e){if(!c.docStyle)return e[0];for(let s=0;s{window.removeEventListener("click",c.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 h=s.boundingClientRect;return new a.P((l.clientX-h.left)/s.x-e.clientLeft,(l.clientY-h.top)/s.y-e.clientTop)}static mousePos(e,s){const a=c.getScale(e);return c.getPoint(e,a,s)}static touchPos(e,s){const a=[],l=c.getScale(e);for(let h=0;h{b&&M(b),b=null,P=!0},w.onerror=()=>{T=!0,b=null},w.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(s){let l,h,p,f;s.resetRequestQueue=()=>{l=[],h=0,p=0,f={}},s.addThrottleControl=e=>{const s=p++;return f[s]=e,s},s.removeThrottleControl=e=>{delete f[e],_()},s.getImage=(e,s,h=!0)=>new Promise(((p,f)=>{v.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),a.e(e,{type:"image"}),l.push({abortController:s,requestParameters:e,supportImageRefresh:h,state:"queued",onError:e=>{f(e)},onSuccess:e=>{p(e)}}),_()}));const m=s=>a._(this||e,void 0,void 0,(function*(){s.state="running";const{requestParameters:e,supportImageRefresh:l,onError:p,onSuccess:f,abortController:m}=s,v=!1===l&&!a.i(self)&&!a.g(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((e,s)=>e&&"accept"===s),!0));h++;const b=v?x(e,m):a.m(e,m);try{const e=yield b;delete s.abortController,s.state="completed",e.data instanceof HTMLImageElement||a.b(e.data)?f(e):e.data&&f({data:yield(w=e.data,"function"==typeof createImageBitmap?a.f(w):a.h(w)),cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete s.abortController,p(e)}finally{h--,_()}var w})),_=()=>{const e=(()=>{for(const e of Object.keys(f))if(f[e]())return!0;return!1})()?a.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:a.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let s=h;s0;s++){const e=l.shift();e.abortController.signal.aborted?s--:m(e)}},x=(e,s)=>new Promise(((l,h)=>{const p=new Image,f=e.url,m=e.credentials;m&&"include"===m?p.crossOrigin="use-credentials":(m&&"same-origin"===m||!a.d(f))&&(p.crossOrigin="anonymous"),s.signal.addEventListener("abort",(()=>{p.src="",h(a.c())})),p.fetchPriority="high",p.onload=()=>{p.onerror=p.onload=null,l({data:p})},p.onerror=()=>{p.onerror=p.onload=null,s.signal.aborted||h(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},p.src=f}))}(E||(E={})),E.resetRequestQueue();class g{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 z(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:h}of e){const e=`${l}${h}`;-1===a.indexOf(e)&&(a.push(e),s.push({id:l,url:h}))}}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 L(e){const{userImage:s}=e;return!!(s&&s.render&&s.render())&&(e.data.replace(new Uint8Array(s.data.buffer)),!0)}class y 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 h=s.data||s.spriteData;return this._validateStretch(s.stretchX,h&&h.width)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "stretchX" value`))),l=!1),this._validateStretch(s.stretchY,h&&h.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},h=new a.I(s,l);this.patterns[e]={bin:s,position:h}}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),h=this.atlasImage;h.resize({width:s||1,height:l||1});for(const e in this.patterns){const{bin:s}=this.patterns[e],l=s.x+1,p=s.y+1,f=this.getImage(e).data,m=f.width,_=f.height;a.R.copy(f,h,{x:0,y:0},{x:l,y:p},{width:m,height:_}),a.R.copy(f,h,{x:0,y:_-1},{x:l,y:p-1},{width:m,height:1}),a.R.copy(f,h,{x:0,y:0},{x:l,y:p+_},{width:m,height:1}),a.R.copy(f,h,{x:m-1,y:0},{x:l-1,y:p},{width:1,height:_}),a.R.copy(f,h,{x:0,y:0},{x:l+m,y:p},{width:1,height:_})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const s of e){if(this.callbackDispatchedThisFrame[s])continue;this.callbackDispatchedThisFrame[s]=!0;const e=this.getImage(s);e||a.w(`Image with ID: "${s}" was not found`),L(e)&&this.updateImage(s,e)}}}const F=1e20;function B(e,s,a,l,h,p,f,m,_){for(let x=s;x-1);_++,p[_]=m,f[_]=x,f[_+1]=F}for(let m=0,_=0;m65535)throw new Error("glyphs > 65535 not supported");if(a.ranges[h])return{stack:e,id:s,glyph:l};if(!this.url)throw new Error("glyphsUrl is not set");if(!a.requests[h]){const s=C.loadGlyphRange(e,h,this.url,this.requestManager);a.requests[h]=s}const p=yield a.requests[h];for(const e in p)this._doesCharSupportLocalGlyph(+e)||(a.glyphs[+e]=p[+e]);return a.ranges[h]=!0,{stack:e,id:s,glyph:p[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 h=this.localIdeographFontFamily;if(!h)return;if(!this._doesCharSupportLocalGlyph(l))return;let p=e.tinySDF;if(!p){let a="400";/bold/i.test(s)?a="900":/medium/i.test(s)?a="500":/light/i.test(s)&&(a="200"),p=e.tinySDF=new C.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,lang:this.lang,fontFamily:h,fontWeight:a})}const f=p.draw(String.fromCharCode(l));return{id:l,bitmap:new a.q({width:f.width||60,height:f.height||60},f.data),metrics:{width:f.glyphWidth/2||24,height:f.glyphHeight/2||24,left:f.glyphLeft/2+.5||0,top:f.glyphTop/2-27.5||-8,advance:f.glyphAdvance/2||24,isDoubleResolution:!0}}}}C.loadGlyphRange=function(s,l,h,p){return a._(this||e,void 0,void 0,(function*(){const e=256*l,f=e+255,m=p.transformRequest(h.replace("{fontstack}",s).replace("{range}",`${e}-${f}`),"Glyphs"),_=yield a.n(m,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${l}, ${e}-${f}`);const x={};for(const e of a.o(_.data))x[e.id]=e;return x}))},C.TinySDF=class{constructor({fontSize:e=24,buffer:s=3,radius:a=8,cutoff:l=.25,fontFamily:h="sans-serif",fontWeight:p="normal",fontStyle:f="normal",lang:m=null}={}){this.buffer=s,this.cutoff=l,this.radius=a,this.lang=m;const _=this.size=e+4*s,x=this._createCanvas(_),v=this.ctx=x.getContext("2d",{willReadFrequently:!0});v.font=`${f} ${p} ${e}px ${h}`,v.textBaseline="alphabetic",v.textAlign="left",v.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:h,actualBoundingBoxRight:p}=this.ctx.measureText(e),f=Math.ceil(a),m=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(p-h))),_=Math.min(this.size-this.buffer,f+Math.ceil(l)),x=m+2*this.buffer,v=_+2*this.buffer,b=Math.max(x*v,0),w=new Uint8ClampedArray(b),T={data:w,width:x,height:v,glyphWidth:m,glyphHeight:_,glyphTop:f,glyphLeft:0,glyphAdvance:s};if(0===m||0===_)return T;const{ctx:P,buffer:M,gridInner:E,gridOuter:z}=this;this.lang&&(P.lang=this.lang),P.clearRect(M,M,m,_),P.fillText(e,M,M+f);const k=P.getImageData(M,M,m,_);z.fill(F,0,b),E.fill(0,0,b);for(let e=0;e<_;e++)for(let s=0;s0?e*e:0,E[l]=e<0?e*e:0}}B(z,0,0,x,v,x,this.f,this.v,this.z),B(E,M,M,m,_,x,this.f,this.v,this.z);for(let e=0;e1&&(f=e[++p]);const _=Math.abs(m-f.left),x=Math.abs(m-f.right),v=Math.min(_,x);let b;const w=s/a*(l+1);if(f.isDash){const e=l-Math.abs(w);b=Math.sqrt(v*v+e*e)}else b=l-Math.sqrt(v*v+w*w);this.data[h+m]=Math.max(0,Math.min(255,b+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 h=0,p=e[h];for(let s=0;s1&&(p=e[++h]);const a=Math.abs(s-p.left),f=Math.abs(s-p.right),m=Math.min(a,f);this.data[l+s]=Math.max(0,Math.min(255,(p.isDash?m:-m)+128))}}addDash(e,s){const l=s?7:0,h=2*l+1;if(this.nextRow+h>this.height)return a.w("LineAtlas out of space"),null;let p=0;for(let s=0;s{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[U]}numActive(){return Object.keys(this.active).length}}const G=Math.floor(m.hardwareConcurrency/2);let Z,nt;function st(){return Z||(Z=new A),Z}A.workerCount=a.H(globalThis)?Math.max(Math.min(G,3),1):1;class O{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 at(){return nt||(nt=new O(st(),a.K),nt.registerMessageHandler("GR",((e,s,l)=>a.m(s,l)))),nt}function lt(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 ht(e,s,a,l,h,p,f){var m;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!==(m=null==h?void 0:h.layers)&&void 0!==m?m:null,s,e.id),x=p.maxPitchScaleFactor(),v=e.tilesIn(l,x,_);v.sort(ut);const b=[];for(const l of v)b.push({wrappedTileID:l.tileID.wrapped().key,queryResults:l.tile.queryRenderedFeatures(s,a,e._state,l.queryGeometry,l.cameraQueryGeometry,l.scale,h,p,x,lt(e.transform,l.tileID),f?(e,s)=>f(l.tileID,e,s):void 0)});return function(e,s){for(const a in e)for(const l of e[a])dt(l,s);return e}(function(e){const s={},a={};for(const l of e){const e=l.queryResults,h=l.wrappedTileID,p=a[h]=a[h]||{};for(const a in e){const l=e[a],h=p[a]=p[a]||{},f=s[a]=s[a]||[];for(const e of l)h[e.featureIndex]||(h[e.featureIndex]=!0,f.push(e))}}return s}(b),e)}function ut(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 dt(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 pt(s,l,h){return a._(this||e,void 0,void 0,(function*(){let e=s;if(s.url?e=(yield a.j(l.transformRequest(s.url,"Source"),h)).data:yield m.frameAsync(h),!e)return null;const p=a.Q(a.e(e,s),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in e&&e.vector_layers&&(p.vectorLayerIds=e.vector_layers.map((e=>e.id))),p}))}class ${constructor(e,s){e&&(s?this.setSouthWest(e).setNorthEast(s):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof 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 h,p;if(e instanceof a.S)h=e,p=e;else{if(!(e instanceof $))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend($.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(h=e._sw,p=e._ne,!h||!p)return this}return s||l?(s.lng=Math.min(h.lng,s.lng),s.lat=Math.min(h.lat,s.lat),l.lng=Math.max(p.lng,l.lng),l.lat=Math.max(p.lat,l.lat)):(this._sw=new a.S(h.lng,h.lat),this._ne=new a.S(p.lng,p.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 h=this._sw.lng<=s&&s<=this._ne.lng;return this._sw.lng>this._ne.lng&&(h=this._sw.lng>=s&&s>=this._ne.lng),this._sw.lat<=l&&l<=this._ne.lat&&h}static convert(e){return e instanceof $?e:e?new $(e):e}static fromLngLat(e,s=0){const l=360*s/40075017,h=l/Math.cos(Math.PI/180*e.lat);return new $(new a.S(e.lng-h,e.lat-l),new a.S(e.lng+h,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 $(e,e.lng>s.lng?new a.S(s.lng+360,s.lat):s)}}class W{constructor(e,s,a){this.bounds=$.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),h=Math.floor(a.U(this.bounds.getNorth())*s),p=Math.ceil(a.V(this.bounds.getEast())*s),f=Math.ceil(a.U(this.bounds.getSouth())*s);return e.x>=l&&e.x=h&&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};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 H extends a.E{constructor(e,s,l,h){super(),this.id=e,this.dispatcher=l,this.setEventedParent(h),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 pt(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,s&&(a.e(this,s),s.bounds&&(this.tileBounds=new W(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._loaded=!0,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 E.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,h=s.gl,p=l.data;e.texture=this.map.painter.getTileTexture(p.width),e.texture?e.texture.update(p,{useMipmap:!0}):(e.texture=new a.T(s,p,h.RGBA,{useMipmap:!0}),e.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE,h.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 X extends H{constructor(e,s,l,h){super(e,s,l,h),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 E.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 h=a.b(l)&&a.W()?l:yield this.readImageNow(l),p={type:this.type,uid:e.uid,source:this.id,rawImageData:h,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const s=yield e.actor.sendAsync({type:"LDT",data:p});e.dem=s,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(s){if(delete e.abortController,e.aborted)e.state="unloaded";else if(s)throw e.state="errored",s}}))}readImageNow(e){return 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 m.getImageData(e,1)}))}_getNeighboringTiles(e){const s=e.canonical,l=Math.pow(2,s.z),h=(s.x-1+l)%l,p=0===s.x?e.wrap-1:e.wrap,f=(s.x+1+l)%l,m=s.x+1===l?e.wrap+1:e.wrap,_={};return _[new a.Z(e.overscaledZ,p,s.z,h,s.y).key]={backfilled:!1},_[new a.Z(e.overscaledZ,m,s.z,f,s.y).key]={backfilled:!1},s.y>0&&(_[new a.Z(e.overscaledZ,p,s.z,h,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,m,s.z,f,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 $,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(h,{resourceTiming:s}),this.fire(new a.l("data",Object.assign(Object.assign({},h),{sourceDataType:"metadata"}))),this.fire(new a.l("data",Object.assign(Object.assign({},h),{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._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}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};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 Q 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 E.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(),h=s.height(),p=Math.max(l,h),f=Math.max(0,Math.floor(-Math.log(p)/Math.LN2)),m=Math.pow(2,f);return new a.a4(f,Math.floor((s.minX+s.maxX)/2*m),Math.floor((s.minY+s.maxY)/2*m))}(s),this.terrainTileRanges=this._getOverlappingTileRanges(s),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=s.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((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:h,maxY:p}=a.a2.fromPoints(e),f={};for(let e=0;e<=a.a3;e++){const a=Math.pow(2,e),m=Math.floor(s*a),_=Math.floor(l*a),x=Math.floor(h*a),v=Math.floor(p*a);f[e]={minTileX:m,minTileY:_,maxTileX:x,maxTileY:v}}return f}}class Y extends Q{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 J extends Q{constructor(e,s,l,h){super(e,s,l,h),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 h=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,h=!0)}h&&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 _t={},vt=e=>{switch(e){case"geojson":return K;case"image":return Q;case"raster":return H;case"raster-dem":return X;case"vector":return q;case"video":return Y;case"canvas":return J}return _t[e]},Tt="RTLPluginLoaded";class oe extends a.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=at()}_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=m.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(Tt))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let Pt=null;function St(){return Pt||(Pt=new oe),Pt}var Mt,Ct;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(Mt||(Mt={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(Ct||(Ct={}));class le{constructor(e,s){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,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"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:s,fadingParentID:a,fadeEndTime:l}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=s,this.fadingParentID=a,this.fadeEndTime=l}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=x(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,s,l){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,s){const a={};if(!s)return a;for(const l of e){const e=l.layerIds.map((e=>s.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,St().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),this.dashPositions=e.dashPositions}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.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const s in this.buckets){const 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,h,p,f,m,_,x,v){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:l,cameraQueryGeometry:h,scale:p,tileSize:this.tileSize,pixelPosMatrix:x,transform:m,params:f,queryPadding:this.queryPadding*_,getElevation:v},e,s,a):{}}querySourceFeatures(e,s){const l=this.latestFeatureIndex;if(!l||!l.rawTileData)return;const h=l.loadVTLayers(),p=s&&s.sourceLayer?s.sourceLayer:"",f=h._geojsonTileLayer||h[p];if(!f)return;const m=a.aa(null==s?void 0:s.filter,null==s?void 0:s.globalState),{z:_,x:x,y:v}=this.tileID.canonical,b={z:_,x:x,y:v};for(let s=0;se)a=!1;else if(s)if(this.expirationTime{this.remove(e,h)}),a)),this.data[l].push(h),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),h=this.data[a][l];return this.data[a].splice(l,1),h.timeout&&clearTimeout(h.timeout),0===this.data[a].length&&delete this.data[a],this.onRemove(h.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 he{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,s,l){const h=String(s);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][h]=this.stateChanges[e][h]||{},a.e(this.stateChanges[e][h],l),null===this.deletedStates[e]){this.deletedStates[e]={};for(const s in this.state[e])s!==h&&(this.deletedStates[e][s]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][h]){this.deletedStates[e][h]={};for(const s in this.state[e][h])l[s]||(this.deletedStates[e][h][s]=null)}else for(const s in l)this.deletedStates[e]&&this.deletedStates[e][h]&&null===this.deletedStates[e][h][s]&&delete this.deletedStates[e][h][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),h=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 h[e]}return h}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 At=89.25;function zt(e,s){const l=a.ae(s.lat,-a.af,a.af);return new a.P(a.V(s.lng)*e,a.U(l)*e)}function jt(e,s){return new a.a1(s.x/e,s.y/e).toLngLat()}function Nt(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(a.ag(90-e.pitch)),Math.tan(a.ag(At-e.pitch)))}function Zt(e,s){const l=e.canonical,h=s/a.ah(l.z),p=l.x+Math.pow(2,l.z)*e.wrap,f=a.ai(new Float64Array(16));return a.M(f,f,[p*h,l.y*h,0]),a.N(f,f,[h/a.$,h/a.$,1]),f}function qt(e,s,l,h,p){const f=a.a1.fromLngLat(e,s),m=p*a.aj(1,e.lat),_=m*Math.cos(a.ag(l)),x=Math.sqrt(m*m-_*_),v=x*Math.sin(a.ag(-h)),b=x*Math.cos(a.ag(-h));return new a.a1(f.x+v,f.y+b,f.z+_)}function Xt(e,s,a){const l=s.intersectsFrustum(e);if(!a||0===l)return l;const h=s.intersectsPlane(a);return 0===h?0:2===l&&2===h?2:1}function Yt(e,s,a){let l=0;const h=(a-s)/10;for(let p=0;p<10;p++)l+=h*Math.pow(Math.cos(s+(p+.5)/10*(a-s)),e);return l}function Kt(e,s){return function(l,h,p,f,m){const _=2*((e-1)/a.ak(Math.cos(a.ag(At-m))/Math.cos(a.ag(At)))-1),x=Math.acos(p/f),v=2*Yt(_-1,0,a.ag(m/2)),b=Math.min(a.ag(At),x+a.ag(m/2)),w=Yt(_-1,Math.min(b,x-a.ag(m/2)),b),T=Math.atan(h/p),P=Math.hypot(h,p);let M=l;return M+=a.ak(f/P/Math.max(.5,Math.cos(a.ag(m/2)))),M+=_*a.ak(Math.cos(T))/2,M-=a.ak(Math.max(1,w/v/s))/2,M}}const Jt=Kt(9.314,3);function ee(e,s){const l=(s.roundZoom?Math.round:Math.floor)(e.zoom+a.ak(e.tileSize/s.tileSize));return Math.max(0,l)}function ie(e,s){const l=e.getCameraFrustum(),h=e.getClippingPlane(),p=e.screenPointToMercatorCoordinate(e.getCameraPoint()),f=a.a1.fromLngLat(e.center,e.elevation);p.z=f.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const m=e.getCoveringTilesDetailsProvider(),_=m.allowVariableZoom(e,s),x=ee(e,s),v=s.minzoom||0,b=void 0!==s.maxzoom?s.maxzoom:e.maxZoom,w=Math.min(Math.max(0,x),b),T=Math.pow(2,w),P=[T*p.x,T*p.y,0],M=[T*f.x,T*f.y,0],E=Math.hypot(f.x-p.x,f.y-p.y),z=Math.abs(f.z-p.z),k=Math.hypot(E,z),L=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),F=[],B=[];if(e.renderWorldCopies&&m.allowWorldCopies())for(let e=1;e<=3;e++)F.push(L(-e)),F.push(L(e));for(F.push(L(0));F.length>0;){const T=F.pop(),E=T.x,L=T.y;let j=T.fullyVisible;const V={x:E,y:L,z:T.zoom},N=m.getTileBoundingVolume(V,T.wrap,e.elevation,s);if(!j){const e=Xt(l,N,h);if(0===e)continue;j=2===e}const U=m.distanceToTile2d(p.x,p.y,V,N);let G=x;_&&(G=(s.calculateTileZoom||Jt)(e.zoom+a.ak(e.tileSize/s.tileSize),U,z,k,e.fov)),G=(s.roundZoom?Math.round:Math.floor)(G),G=Math.max(0,G);const Z=Math.min(G,b);if(T.wrap=m.getWrap(f,V,T.wrap),T.zoom>=Z){if(T.zoom>1),wrap:T.wrap,fullyVisible:j})}return B.sort(((e,s)=>e.distanceSq-s.distanceSq)).map((e=>e.tileID))}const re=a.a2.fromPoints([new a.P(0,0),new a.P(a.$,a.$)]);class Pe 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 h=new(vt(s.type))(e,s,a,l);if(h.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${h.id}`);return h})(e,s,a,this),this._tiles={},this._cache=new ce(0,(e=>this._unloadTile(e))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new he,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(se).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,h=s.tileID,p=new a.P(l.canonical.x,l.canonical.y)._rotate(-this.transform.bearingInRadians),f=new a.P(h.canonical.x,h.canonical.y)._rotate(-this.transform.bearingInRadians);return l.overscaledZ-h.overscaledZ||f.y-p.y||f.x-p.x})).map((e=>e.tileID.key)):s.map((e=>e.tileID)).sort(se).map((e=>e.key))}hasRenderableParent(e){const s=e.overscaledZ-1;if(s>=this._source.minzoom){const a=this._getLoadedTile(e.scaledTo(s));if(a)return this._isIdRenderable(a.tileID.key)}return!1}_isIdRenderable(e,s=!1){var a;return null===(a=this._tiles[e])||void 0===a?void 0:a.isRenderable(s)}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=x(),"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+h)?a+=h:1===Math.abs(a-h)&&(a-=h)),s.dem&&e.dem&&(e.dem.backfillBorder(s.dem,a,l),e.neighboringTiles&&e.neighboringTiles[p]&&(e.neighboringTiles[p].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,s){const a=Object.values(e),l=this._getLoadedDescendents(a),h={};for(const e of a){const a=l[e.key];if(!(null==a?void 0:a.length)){h[e.key]=e;continue}const p=e.overscaledZ+Pe.maxUnderzooming,f=a.filter((e=>e.tileID.overscaledZ<=p));if(!f.length){h[e.key]=e;continue}const m=Math.min(...f.map((e=>e.tileID.overscaledZ))),_=f.filter((e=>e.tileID.overscaledZ===m)).map((e=>e.tileID));for(const e of _)s[e.key]=e;this._areDescendentsComplete(_,m,e.overscaledZ)||(h[e.key]=e)}return h}_getLoadedDescendents(e){var s;const a={};for(const l in this._tiles){const h=this._tiles[l];if(h.hasData())for(const l of e)h.tileID.isChildOf(l)&&(a[s=l.key]||(a[s]=[])).push(h)}return a}_areDescendentsComplete(e,s,a){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===s:Math.pow(4,s-a)===e.length}_getLoadedTile(e){const s=this._tiles[e.key];return(null==s?void 0:s.hasData())?s:null}updateCacheSize(e){const s=Math.ceil(e.width/this._source.tileSize)+1,l=Math.ceil(e.height/this._source.tileSize)+1,h=Math.floor(s*l*(null===this._maxTileCacheZoomLevels?a.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),p="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,h):h;this._cache.setMaxSize(p)}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,this._resetTileReloadTimers()}}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.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=ie(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=[],this.usedForTerrain&&(l=this._addTerrainIdealTiles(l));const h=0===l.length&&!this._updated&&this._didEmitContent;this._updated=!0,h&&this.fire(new a.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const p=ee(e,this._source),f=this._updateRetainedTiles(l,p),m=ae(this._source.type);m&&this._rasterFadeDuration>0&&!s&&this._updateFadingTiles(l,f),m?this._cleanUpRasterTiles(f):this._cleanUpVectorTiles(f)}_cleanUpRasterTiles(e){for(const s in this._tiles)e[s]||this._removeTile(s)}_cleanUpVectorTiles(e){for(const s in this._tiles){const a=this._tiles[s];e[s]?a.clearSymbolFadeHold():a.hasSymbolBuckets?a.holdingForSymbolFade()?a.symbolFadeFinished()&&this._removeTile(s):a.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(s)}}_addTerrainIdealTiles(e){const s=[];for(const a of e)if(a.canonical.z>this._source.minzoom){const e=a.scaledTo(a.canonical.z-1);s.push(e);const l=a.scaledTo(Math.max(this._source.minzoom,Math.min(a.canonical.z,5)));s.push(l)}return e.concat(s)}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,s){var a;const l={},h={},p=Math.max(s-Pe.maxOverzooming,this._source.minzoom);let f={};for(const s of e){const e=this._addTile(s);l[s.key]=s,e.hasData()||(f[s.key]=s)}f=this._retainLoadedChildren(f,l);for(const e in f){const s=f[e];let m=this._tiles[e],_=null==m?void 0:m.wasRequested();for(let e=s.overscaledZ-1;e>=p;--e){const p=s.scaledTo(e);if(h[p.key])break;if(h[p.key]=!0,m=this.getTile(p),!m&&_&&(m=this._addTile(p)),m){const e=m.hasData();if((e||!(null===(a=this.map)||void 0===a?void 0:a.cancelPendingTileRequestsWhileZooming)||_)&&(l[p.key]=p),_=m.wasRequested(),e)break}}}return l}_updateFadingTiles(e,s){const l=x(),h=a.am(e);for(const a of e){const e=this._tiles[a.key];e.fadingDirection!==Ct.Departing&&0!==e.fadeOpacity||e.resetFadeLogic(),this._updateFadingAncestor(e,s,l)||this._updateFadingDescendents(e,s,l)||this._updateFadingEdge(e,h,l)||e.resetFadeLogic()}}_updateFadingAncestor(e,s,a){if(!e.hasData())return!1;const{tileID:l,fadingRole:h,fadingDirection:p,fadingParentID:f}=e;if(h===Mt.Base&&p===Ct.Incoming&&f)return s[f.key]=f,!0;const m=Math.max(l.overscaledZ-this._maxFadingAncestorLevels,this._source.minzoom);for(let h=l.overscaledZ-1;h>=m;h--){const p=l.scaledTo(h),f=this._getLoadedTile(p);if(f)return e.setCrossFadeLogic({fadingRole:Mt.Base,fadingDirection:Ct.Incoming,fadingParentID:f.tileID,fadeEndTime:a+this._rasterFadeDuration}),f.setCrossFadeLogic({fadingRole:Mt.Parent,fadingDirection:Ct.Departing,fadeEndTime:a+this._rasterFadeDuration}),s[p.key]=p,!0}return!1}_updateFadingDescendents(e,s,a){if(!e.hasData())return!1;const l=e.tileID.children(this._source.maxzoom);let h=this._updateFadingChildren(e,l,s,a);if(h)return!0;for(const p of l){const l=p.children(this._source.maxzoom);this._updateFadingChildren(e,l,s,a)&&(h=!0)}return h}_updateFadingChildren(e,s,a,l){if(s[0].overscaledZ>=this._source.maxzoom)return!1;let h=!1;for(const p of s){const s=this._getLoadedTile(p);if(!s)continue;const{fadingRole:f,fadingDirection:m,fadingParentID:_}=s;f===Mt.Base&&m===Ct.Departing&&_||(s.setCrossFadeLogic({fadingRole:Mt.Base,fadingDirection:Ct.Departing,fadingParentID:e.tileID,fadeEndTime:l+this._rasterFadeDuration}),e.setCrossFadeLogic({fadingRole:Mt.Parent,fadingDirection:Ct.Incoming,fadeEndTime:l+this._rasterFadeDuration})),a[p.key]=p,h=!0}return h}_updateFadingEdge(e,s,a){const l=e.tileID;return!!e.selfFading||!e.hasData()&&!!s.has(l)&&(e.setSelfFadeLogic(a+this._rasterFadeDuration),!0)}_addTile(e){let s=this._tiles[e.key];if(s)return s;s=this._cache.getAndRemove(e),s&&(s.resetFadeLogic(),this._setTileReloadTimer(e.key,s),s.tileID=e,this._state.initializeTileState(s,this.map?this.map.painter:null));const l=s;return s||(s=new le(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){this._clearTileReloadTimer(e);const a=s.getExpiryTimeout();a&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),a))}_clearTileReloadTimer(e){const s=this._timers[e];s&&(clearTimeout(s),delete this._timers[e])}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e])}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._clearTileReloadTimer(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){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!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 h=[],p=this.transform;if(!p)return h;const f=p.getCoveringTilesDetailsProvider().allowWorldCopies(),m=l?p.getCameraQueryGeometry(e):e,_=e=>p.screenPointToMercatorCoordinate(e,this.terrain),x=this.transformBbox(e,_,!f),v=this.transformBbox(m,_,!f),b=this.getIds(),w=a.a2.fromPoints(v);for(let e=0;ee.getTilePoint(new a.a1(s.x,s.y))));if(s.expandBy(T),s.intersects(re)){const s=x.map((s=>e.getTilePoint(s))),a=v.map((s=>e.getTilePoint(s)));h.push({tile:l,tileID:f?e:e.unwrapTo(0),queryGeometry:s,cameraQueryGeometry:a,scale:_})}}}return h}transformBbox(e,s,l){let h=e.map(s);if(l){const l=a.a2.fromPoints(e);l.shrinkBy(.001*Math.min(l.width(),l.height()));const p=l.map(s);a.a2.fromPoints(h).covers(p)||(h=h.map((e=>e.x>.5?new a.a1(e.x-1,e.y,e.z):e)))}return h}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(ae(this._source.type)&&this._rasterFadeDuration>0){const e=x();for(const s in this._tiles)if(this._tiles[s].fadeEndTime>=e)return!0}return!1}setRasterFadeDuration(e){this._rasterFadeDuration=e}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 se(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 ae(e){return"raster"===e||"image"===e||"video"===e}Pe.maxOverzooming=10,Pe.maxUnderzooming=3;class Me{constructor(e,s){this.reset(e,s)}reset(e,s){this.points=e||[],this._distances=[0];for(let e=1;e0?(h-f)/m:0;return this.points[p].mult(1-_).add(this.points[s].mult(_))}}function ue(e,s){let a=!0;return"always"===e||"never"!==e&&"never"!==s||(a=!1),a}class Ee{constructor(e,s,a){const l=this.boxCells=[],h=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 m=[];if(e<=0&&s<=0&&this.width<=a&&this.height<=l){if(h)return[{key:null,x1:e,y1:s,x2:a,y2:l}];for(let e=0;e0}hitTestCircle(e,s,a,l,h){const p=e-a,f=e+a,m=s-a,_=s+a;if(f<0||p>this.width||_<0||m>this.height)return!1;const x=[];return this._forEachCell(p,m,f,_,this._queryCellCircle,x,{hitTest:!0,overlapMode:l,circle:{x:e,y:s,radius:a},seenUids:{box:{},circle:{}}},h),x.length>0}_queryCell(e,s,a,l,h,p,f,m){const{seenUids:_,hitTest:x,overlapMode:v}=f,b=this.boxCells[h];if(null!==b){const h=this.bboxes;for(const f of b)if(!_.box[f]){_.box[f]=!0;const b=4*f,w=this.boxKeys[f];if(e<=h[b+2]&&s<=h[b+3]&&a>=h[b+0]&&l>=h[b+1]&&(!m||m(w))&&(!x||!ue(v,w.overlapMode))&&(p.push({key:w,x1:h[b],y1:h[b+1],x2:h[b+2],y2:h[b+3]}),x))return!0}}const w=this.circleCells[h];if(null!==w){const h=this.circles;for(const f of w)if(!_.circle[f]){_.circle[f]=!0;const b=3*f,w=this.circleKeys[f];if(this._circleAndRectCollide(h[b],h[b+1],h[b+2],e,s,a,l)&&(!m||m(w))&&(!x||!ue(v,w.overlapMode))){const e=h[b],s=h[b+1],a=h[b+2];if(p.push({key:w,x1:e-a,y1:s-a,x2:e+a,y2:s+a}),x)return!0}}}return!1}_queryCellCircle(e,s,a,l,h,p,f,m){const{circle:_,seenUids:x,overlapMode:v}=f,b=this.boxCells[h];if(null!==b){const e=this.bboxes;for(const s of b)if(!x.box[s]){x.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])&&(!m||m(l))&&!ue(v,l.overlapMode))return p.push(!0),!0}}const w=this.circleCells[h];if(null!==w){const e=this.circles;for(const s of w)if(!x.circle[s]){x.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)&&(!m||m(l))&&!ue(v,l.overlapMode))return p.push(!0),!0}}}_forEachCell(e,s,a,l,h,p,f,m){const _=this._convertToXCellCoord(e),x=this._convertToYCellCoord(s),v=this._convertToXCellCoord(a),b=this._convertToYCellCoord(l);for(let w=_;w<=v;w++)for(let _=x;_<=b;_++)if(h.call(this,e,s,a,l,this.xCellCount*_+w,p,f,m))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,s,a,l,h,p){const f=l-e,m=h-s,_=a+p;return _*_>f*f+m*m}_circleAndRectCollide(e,s,a,l,h,p,f){const m=(p-l)/2,_=Math.abs(e-(l+m));if(_>m+a)return!1;const x=(f-h)/2,v=Math.abs(s-(h+x));if(v>x+a)return!1;if(_<=m||v<=x)return!0;const b=_-m,w=v-x;return b*b+w*w<=a*a}}function de(e,s,l){const p=a.L();if(!e){const{vecSouth:e,vecEast:a}=fe(s),l=h();l[0]=a[0],l[1]=a[1],l[2]=e[0],l[3]=e[1],f=l,(w=(_=(m=l)[0])*(b=m[3])-(v=m[2])*(x=m[1]))&&(f[0]=b*(w=1/w),f[1]=-x*w,f[2]=-v*w,f[3]=_*w),p[0]=l[0],p[1]=l[1],p[4]=l[2],p[5]=l[3]}var f,m,_,x,v,b,w;return a.N(p,p,[1/l,1/l,1]),p}function pe(e,s,l,h){if(e){const e=a.L();if(!s){const{vecSouth:s,vecEast:a}=fe(l);e[0]=a[0],e[1]=a[1],e[4]=s[0],e[5]=s[1]}return a.N(e,e,[h,h,1]),e}return l.pixelsToClipSpaceMatrix}function fe(e){const s=Math.cos(e.rollInRadians),l=Math.sin(e.rollInRadians),h=Math.cos(e.pitchInRadians),p=Math.cos(e.bearingInRadians),f=Math.sin(e.bearingInRadians),m=a.ar();m[0]=-p*h*l-f*s,m[1]=-f*h*l+p*s;const _=a.as(m);_<1e-9?a.at(m):a.au(m,m,1/_);const x=a.ar();x[0]=p*h*s-f*l,x[1]=f*h*s+p*l;const v=a.as(x);return v<1e-9?a.at(x):a.au(x,x,1/v),{vecEast:x,vecSouth:m}}function me(e,s,l,h){let p;h?(p=[e,s,h(e,s),1],a.aw(p,p,l)):(p=[e,s,0,1],Ze(p,p,l));const f=p[3];return{point:new a.P(p[0]/f,p[1]/f),signedDistanceFromCamera:f,isOccluded:!1}}function _e(e,s){return.5+e/s*.5}function ge(e,s){return e.x>=-s[0]&&e.x<=s[0]&&e.y>=-s[1]&&e.y<=s[1]}function ye(e,s,l,h,p,f,m,_,x,v,b,w,T){const P=l?e.textSizeData:e.iconSizeData,M=a.an(P,s.transform.zoom),E=[256/s.width*2+1,256/s.height*2+1],z=l?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;z.clear();const k=e.lineVertexArray,L=l?e.text.placedSymbolArray:e.icon.placedSymbolArray,F=s.transform.width/s.transform.height;let B=!1;for(let l=0;lMath.abs(l.x-s.x)*h?{useVertical:!0}:(e===a.ao.vertical?s.yl.x)?{needsFlipping:!0}:null}function be(e){const{projectionContext:s,pitchedLabelPlaneMatrixInverse:l,symbol:h,fontSize:p,flip:f,keepUpright:m,glyphOffsetArray:_,dynamicLayoutVertexArray:x,aspectRatio:v,rotateToLine:b}=e,w=p/24,T=h.lineOffsetX*w,P=h.lineOffsetY*w;let M;if(h.numGlyphs>1){const e=h.glyphStartIndex+h.numGlyphs,a=h.lineStartIndex,p=h.lineStartIndex+h.lineLength,x=xe(w,_,T,P,f,h,b,s);if(!x)return{notEnoughRoom:!0};const E=ke(x.first.point.x,x.first.point.y,s,l),z=ke(x.last.point.x,x.last.point.y,s,l);if(m&&!f){const e=ve(h.writingMode,E,z,v);if(e)return e}M=[x.first];for(let l=h.glyphStartIndex+1;l0?m.point:we(s.tileAnchorPoint,f,e,1,s),x=ke(e.x,e.y,s,l),b=ke(_.x,_.y,s,l),w=ve(h.writingMode,x,b,v);if(w)return w}const e=Ne(w*_.getoffsetX(h.glyphStartIndex),T,P,f,h.segment,h.lineStartIndex,h.lineStartIndex+h.lineLength,s,b);if(!e||s.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};M=[e]}for(const e of M)a.av(x,e.point,e.angle);return{}}function we(e,s,a,l,h){const p=e.add(e.sub(s)._unit()),f=Ae(p.x,p.y,h).point,m=a.sub(f);return a.add(m._mult(l/m.mag()))}function Se(e,s,l){const h=s.projectionCache;if(h.projections[e])return h.projections[e];const p=new a.P(s.lineVertexArray.getx(e),s.lineVertexArray.gety(e)),f=Ae(p.x,p.y,s);if(f.signedDistanceFromCamera>0)return h.projections[e]=f.point,h.anyProjectionOccluded=h.anyProjectionOccluded||f.isOccluded,f.point;const m=e-l.direction;return we(0===l.distanceFromAnchor?s.tileAnchorPoint:new a.P(s.lineVertexArray.getx(m),s.lineVertexArray.gety(m)),p,l.previousVertex,l.absOffsetX-l.distanceFromAnchor+1,s)}function Ae(e,s,a){const l=e+a.translation[0],h=s+a.translation[1];let p;return a.pitchWithMap?(p=me(l,h,a.pitchedLabelPlaneMatrix,a.getElevation),p.isOccluded=!1):(p=a.transform.projectTileCoordinates(l,h,a.unwrappedTileID,a.getElevation),p.point.x=(.5*p.point.x+.5)*a.width,p.point.y=(.5*-p.point.y+.5)*a.height),p}function ke(e,s,l,h){if(l.pitchWithMap){const p=[e,s,0,1];return a.aw(p,p,h),l.transform.projectTileCoordinates(p[0]/p[3],p[1]/p[3],l.unwrappedTileID,l.getElevation).point}return{x:e/l.width*2-1,y:1-s/l.height*2}}function De(e,s,a){return a.transform.projectTileCoordinates(e,s,a.unwrappedTileID,a.getElevation)}function Re(e,s,a){return e._unit()._perp()._mult(s*a)}function je(e,s,l,h,p,f,m,_,x){if(_.projectionCache.offsets[e])return _.projectionCache.offsets[e];const v=l.add(s);if(e+x.direction=p)return _.projectionCache.offsets[e]=v,v;const b=Se(e+x.direction,_,x),w=Re(b.sub(l),m,x.direction),T=l.add(w),P=b.add(w);return _.projectionCache.offsets[e]=a.ax(f,v,T,P)||v,_.projectionCache.offsets[e]}function Ne(e,s,a,l,h,p,f,m,_){const x=l?e-s:e+s;let v=x>0?1:-1,b=0;l&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let w,T=v>0?p+h:p+h+1;m.projectionCache.cachedAnchorPoint?w=m.projectionCache.cachedAnchorPoint:(w=Ae(m.tileAnchorPoint.x,m.tileAnchorPoint.y,m).point,m.projectionCache.cachedAnchorPoint=w);let P,M,E=w,z=w,k=0,L=0;const F=Math.abs(x),B=[];let j;for(;k+L<=F;){if(T+=v,T=f)return null;k+=L,z=E,M=P;const e={absOffsetX:F,direction:v,distanceFromAnchor:k,previousVertex:z};if(E=Se(T,m,e),0===a)B.push(z),j=E.sub(z);else{let s;const l=E.sub(z);s=0===l.mag()?Re(Se(T+v,m,e).sub(E),a,v):Re(l,a,v),M||(M=z.add(s)),P=je(T,s,E,p,f,M,a,m,e),B.push(M),j=P.sub(M)}L=j.mag()}const V=j._mult((F-k)/L)._add(M||z),N=b+Math.atan2(E.y-z.y,E.x-z.x);return B.push(V),{point:V,angle:_?N:0,path:B}}const Ue=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Ge(e,s){for(let a=0;a=1;e--)T.push(f.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let E=[];if(T.length>0){const e=T[0].clone(),s=T[0].clone();for(let a=1;a=l.x&&s.x<=h.x&&e.y>=l.y&&s.y<=h.y?[T]:s.xh.x||s.yh.y?[]:a.ay([T],l.x,l.y,h.x,h.y)}for(const a of E){p.reset(a,.25*s);let l=0;l=p.length<=.5*s?1:Math.ceil(p.paddedLength/P)+1;for(let a=0;a{const a=me(e.x,e.y,l,s.getElevation),h=s.transform.projectTileCoordinates(a.point.x,a.point.y,s.unwrappedTileID,s.getElevation);return h.point.x=(.5*h.point.x+.5)*s.width,h.point.y=(.5*-h.point.y+.5)*s.height,h}))}(e,s);return function(e){let s=0,a=0,l=0,h=0;for(let p=0;pa&&(a=h,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 h of e){const e=new a.P(h.x+He,h.y+He);l.extend(e),s.push(e)}const{minX:h,minY:p,maxX:f,maxY:m}=l,_=this.grid.query(h,p,f,m).concat(this.ignoredGrid.query(h,p,f,m)),x={},v={};for(const e of _){const l=e.key;if(void 0===x[l.bucketInstanceId]&&(x[l.bucketInstanceId]={}),x[l.bucketInstanceId][l.featureIndex])continue;const h=[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,h)&&(x[l.bucketInstanceId][l.featureIndex]=!0,void 0===v[l.bucketInstanceId]&&(v[l.bucketInstanceId]=[]),v[l.bucketInstanceId].push(l.featureIndex))}return v}insertCollisionBox(e,s,a,l,h,p){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:h,collisionGroupID:p,overlapMode:s},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,s,a,l,h,p){const f=a?this.ignoredGrid:this.grid,m={bucketInstanceId:l,featureIndex:h,collisionGroupID:p,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,h,x,b)));st=e.some((e=>!e.isOccluded)),nt=e.map((e=>new a.P(e.x,e.y)))}else st=!0;return{box:a.aA(nt),allPointsOccluded:!st}}}class Je{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 et{constructor(e,s,a,l,h){this.text=new Je(e?e.text:null,s,a,h),this.icon=new Je(e?e.icon:null,s,l,h)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class tt{constructor(e,s,a){this.text=e,this.icon=s,this.skipFade=a}}class it{constructor(e,s,a,l,h){this.bucketInstanceId=e,this.featureIndex=s,this.sourceLayerIndex=a,this.bucketIndex=l,this.tileID=h}}class ot{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 ri(e,s,l,h,p){const{horizontalAlign:f,verticalAlign:m}=a.aH(e);return new a.P(-(f-.5)*s+h[0]*p,-(m-.5)*l+h[1]*p)}class rt{constructor(e,s,a,l,h){this.transform=e.clone(),this.terrain=s,this.collisionIndex=new Ye(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new ot(l),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=h,h&&(h.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,h){const p=l.getBucket(s),f=l.latestFeatureIndex;if(!p||!f||s.id!==p.layerIds[0])return;const m=l.collisionBoxArray,_=p.layers[0].layout,x=p.layers[0].paint,v=Math.pow(2,this.transform.zoom-l.tileID.overscaledZ),b=l.tileSize/a.$,w=l.tileID.toUnwrapped(),T="map"===_.get("text-rotation-alignment"),P=a.aC(l,1,this.transform.zoom),M=a.aD(this.collisionIndex.transform,l,x.get("text-translate"),x.get("text-translate-anchor")),E=a.aD(this.collisionIndex.transform,l,x.get("icon-translate"),x.get("icon-translate-anchor")),z=de(T,this.transform,P);this.retainedQueryData[p.bucketInstanceId]=new it(p.bucketInstanceId,f,p.sourceLayerIndex,p.index,l.tileID);const k={bucket:p,layout:_,translationText:M,translationIcon:E,unwrappedTileID:w,pitchedLabelPlaneMatrix:z,scale:v,textPixelRatio:b,holdingForFade:l.holdingForSymbolFade(),collisionBoxArray:m,partiallyEvaluatedTextSize:a.an(p.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(p.sourceID)};if(h)for(const s of p.sortKeyRanges){const{sortKey:a,symbolInstanceStart:l,symbolInstanceEnd:h}=s;e.push({sortKey:a,symbolInstanceStart:l,symbolInstanceEnd:h,parameters:k})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:p.symbolInstances.length,parameters:k})}attemptAnchorPlacement(e,s,l,h,p,f,m,_,x,v,b,w,T,P,M,E,z,k,L,F){const B=a.aE[e.textAnchor],j=[e.textOffset0,e.textOffset1],V=ri(B,l,h,j,p),N=this.collisionIndex.placeCollisionBox(s,w,_,x,v,m,f,E,b.predicate,L,V,F);if((!k||this.collisionIndex.placeCollisionBox(k,w,_,x,v,m,f,z,b.predicate,L,V,F).placeable)&&N.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[T.crossTileID]&&this.prevPlacement.placements[T.crossTileID]&&this.prevPlacement.placements[T.crossTileID].text&&(e=this.prevPlacement.variableOffsets[T.crossTileID].anchor),0===T.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[T.crossTileID]={textOffset:j,width:l,height:h,anchor:B,textBoxScale:p,prevAnchor:e},this.markUsedJustification(P,B,T,M),P.allowVerticalPlacement&&(this.markUsedOrientation(P,M,T),this.placedOrientations[T.crossTileID]=M),{shift:V,placedGlyphBoxes:N}}}placeLayerBucketPart(e,s,l){const{bucket:h,layout:p,translationText:f,translationIcon:m,unwrappedTileID:_,pitchedLabelPlaneMatrix:x,textPixelRatio:v,holdingForFade:b,collisionBoxArray:w,partiallyEvaluatedTextSize:T,collisionGroup:P}=e.parameters,M=p.get("text-optional"),E=p.get("icon-optional"),z=a.aF(p,"text-overlap","text-allow-overlap"),k="always"===z,L=a.aF(p,"icon-overlap","icon-allow-overlap"),F="always"===L,B="map"===p.get("text-rotation-alignment"),j="map"===p.get("text-pitch-alignment"),V="none"!==p.get("icon-text-fit"),N="viewport-y"===p.get("symbol-z-order"),U=k&&(F||!h.hasIconData()||E),G=F&&(k||!h.hasTextData()||M);!h.collisionArrays&&w&&h.deserializeCollisionBoxes(w);const Z=this.retainedQueryData[h.bucketInstanceId].tileID,nt=this._getTerrainElevationFunc(Z),st=this.transform.getFastPathSimpleProjectionMatrix(Z),at=(e,w,F)=>{var N,at;if(s[e.crossTileID])return;if(b)return void(this.placements[e.crossTileID]=new tt(!1,!1,!1));let lt=!1,ht=!1,ut=!0,dt=null,pt={box:null,placeable:!1,offscreen:null,occluded:!1},_t={placeable:!1},vt=null,Tt=null,Pt=null,St=0,Mt=0,Ct=0;w.textFeatureIndex?St=w.textFeatureIndex:e.useRuntimeCollisionCircles&&(St=e.featureIndex),w.verticalTextFeatureIndex&&(Mt=w.verticalTextFeatureIndex);const At=w.textBox;if(At){const s=s=>{let l=a.ao.horizontal;if(h.allowVerticalPlacement&&!s&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[e.crossTileID];s&&(this.placedOrientations[e.crossTileID]=s,l=s,this.markUsedOrientation(h,l,e))}return l},p=(s,l)=>{if(h.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&w.verticalTextBox){for(const e of h.writingModes)if(e===a.ao.vertical?(pt=l(),_t=pt):pt=s(),pt&&pt.placeable)break}else pt=s()},x=e.textAnchorOffsetStartIndex,b=e.textAnchorOffsetEndIndex;if(b===x){const l=(s,a)=>{const l=this.collisionIndex.placeCollisionBox(s,z,v,Z,_,j,B,f,P.predicate,nt,void 0,st);return l&&l.placeable&&(this.markUsedOrientation(h,a,e),this.placedOrientations[e.crossTileID]=a),l};p((()=>l(At,a.ao.horizontal)),(()=>{const s=w.verticalTextBox;return h.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&s?l(s,a.ao.vertical):{box:null,offscreen:null}})),s(pt&&pt.placeable)}else{let T=a.aE[null===(at=null===(N=this.prevPlacement)||void 0===N?void 0:N.variableOffsets[e.crossTileID])||void 0===at?void 0:at.anchor];const M=(s,a,p)=>{const w=s.x2-s.x1,M=s.y2-s.y1,E=e.textBoxScale,k=V&&"never"===L?a:null;let F=null,N="never"===z?1:2,U="never";T&&N++;for(let a=0;aM(At,w.iconBox,a.ao.horizontal)),(()=>{const s=w.verticalTextBox;return h.allowVerticalPlacement&&(!pt||!pt.placeable)&&e.numVerticalGlyphVertices>0&&s?M(s,w.verticalIconBox,a.ao.vertical):{box:null,occluded:!0,offscreen:null}})),pt&&(lt=pt.placeable,ut=pt.offscreen);const E=s(pt&&pt.placeable);if(!lt&&this.prevPlacement){const s=this.prevPlacement.variableOffsets[e.crossTileID];s&&(this.variableOffsets[e.crossTileID]=s,this.markUsedJustification(h,s.anchor,e,E))}}}if(vt=pt,lt=vt&&vt.placeable,ut=vt&&vt.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const s=h.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),m=a.ap(h.textSizeData,T,s),v=p.get("text-padding");Tt=this.collisionIndex.placeCollisionCircles(z,s,h.lineVertexArray,h.glyphOffsetArray,m,_,x,l,j,P.predicate,e.collisionCircleDiameter,v,f,nt),Tt.circles.length&&Tt.collisionDetected&&!l&&a.w("Collisions detected, but collision boxes are not shown"),lt=k||Tt.circles.length>0&&!Tt.collisionDetected,ut=ut&&Tt.offscreen}if(w.iconFeatureIndex&&(Ct=w.iconFeatureIndex),w.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,L,v,Z,_,j,B,m,P.predicate,nt,V&&dt?dt:void 0,st);_t&&_t.placeable&&w.verticalIconBox?(Pt=e(w.verticalIconBox),ht=Pt.placeable):(Pt=e(w.iconBox),ht=Pt.placeable),ut=ut&&Pt.offscreen}const zt=M||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,jt=E||0===e.numIconVertices;zt||jt?jt?zt||(ht=ht&<):lt=ht&<:ht=lt=ht&<const Nt=ht&&Pt.placeable;if(lt&&vt.placeable&&this.collisionIndex.insertCollisionBox(vt.box,z,p.get("text-ignore-placement"),h.bucketInstanceId,_t&&_t.placeable&&Mt?Mt:St,P.ID),Nt&&this.collisionIndex.insertCollisionBox(Pt.box,L,p.get("icon-ignore-placement"),h.bucketInstanceId,Ct,P.ID),Tt&<&&this.collisionIndex.insertCollisionCircles(Tt.circles,z,p.get("text-ignore-placement"),h.bucketInstanceId,St,P.ID),l&&this.storeCollisionData(h.bucketInstanceId,F,w,vt,Pt,Tt),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===h.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new tt((lt||U)&&!(null==vt?void 0:vt.occluded),(ht||G)&&!(null==Pt?void 0:Pt.occluded),ut||h.justReloaded),s[e.crossTileID]=!0};if(N){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const s=h.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=s.length-1;e>=0;--e){const a=s[e];at(h.symbolInstances.get(a),h.collisionArrays[a],a)}}else for(let s=e.symbolInstanceStart;s=0&&(e.text.placedSymbolArray.get(s).crossTileID=p>=0&&s!==p?0:l.crossTileID)}markUsedOrientation(e,s,l){const h=s===a.ao.horizontal||s===a.ao.horizontalOnly?s:0,p=s===a.ao.vertical?s:0,f=[l.leftJustifiedTextSymbolIndex,l.centerJustifiedTextSymbolIndex,l.rightJustifiedTextSymbolIndex];for(const s of f)e.text.placedSymbolArray.get(s).placedOrientation=h;l.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(l.verticalPlacedTextSymbolIndex).placedOrientation=p)}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,h=s?s.opacities:{},p=s?s.variableOffsets:{},f=s?s.placedOrientations:{};for(const e in this.placements){const s=this.placements[e],p=h[e];p?(this.opacities[e]=new et(p,l,s.text,s.icon),a=a||s.text!==p.text.placed||s.icon!==p.icon.placed):(this.opacities[e]=new et(null,l,s.text,s.icon,s.skipFade),a=a||s.text||s.icon)}for(const e in h){const s=h[e];if(!this.opacities[e]){const h=new et(s,l,!1,!1);h.isHidden()||(this.opacities[e]=h,a=a||s.text.placed||s.icon.placed)}}for(const e in p)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=p[e]);for(const e in f)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=f[e]);if(s&&void 0===s.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");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,h){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const p=e.layers[0],f=p.layout,m=new et(null,0,!1,!1,!0),_=f.get("text-allow-overlap"),x=f.get("icon-allow-overlap"),v=p._unevaluatedLayout.hasValue("text-variable-anchor")||p._unevaluatedLayout.hasValue("text-variable-anchor-offset"),b="map"===f.get("text-rotation-alignment"),w="map"===f.get("text-pitch-alignment"),T="none"!==f.get("icon-text-fit"),P=new et(null,0,_&&(x||!e.hasIconData()||f.get("icon-optional")),x&&(_||!e.hasTextData()||f.get("text-optional")),!0);!e.collisionArrays&&h&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(h);const M=(e,s,a)=>{for(let l=0;l0,k=this.placedOrientations[h.crossTileID],L=k===a.ao.vertical,F=k===a.ao.horizontal||k===a.ao.horizontalOnly;if(p>0||f>0){const s=_i(x.text);M(e.text,p,L?gi:s),M(e.text,f,F?gi:s);const a=x.text.isHidden();[h.rightJustifiedTextSymbolIndex,h.centerJustifiedTextSymbolIndex,h.leftJustifiedTextSymbolIndex].forEach((s=>{s>=0&&(e.text.placedSymbolArray.get(s).hidden=a||L?1:0)})),h.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(h.verticalPlacedTextSymbolIndex).hidden=a||F?1:0);const l=this.variableOffsets[h.crossTileID];l&&this.markUsedJustification(e,l.anchor,h,k);const m=this.placedOrientations[h.crossTileID];m&&(this.markUsedJustification(e,"left",h,m),this.markUsedOrientation(e,m,h))}if(z){const s=_i(x.icon),a=!(T&&h.verticalPlacedIconSymbolIndex&&L);h.placedIconSymbolIndex>=0&&(M(e.icon,h.numIconVertices,a?s:gi),e.icon.placedSymbolArray.get(h.placedIconSymbolIndex).hidden=x.icon.isHidden()),h.verticalPlacedIconSymbolIndex>=0&&(M(e.icon,h.numVerticalIconVertices,a?gi:s),e.icon.placedSymbolArray.get(h.verticalPlacedIconSymbolIndex).hidden=x.icon.isHidden())}const B=E&&E.has(s)?E.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(v){const e=this.variableOffsets[_];e?(s=ri(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),b&&s._rotate(w?-this.transform.bearingInRadians:this.transform.bearingInRadians)):a=!1}if(l.textBox||l.verticalTextBox){let h;l.textBox&&(h=L),l.verticalTextBox&&(h=F),ni(e.textCollisionBox.collisionVertexArray,x.text.placed,!a||h,B.text,s.x,s.y)}}if(l.iconBox||l.verticalIconBox){const a=Boolean(!F&&l.verticalIconBox);let h;l.iconBox&&(h=a),l.verticalIconBox&&(h=!a),ni(e.iconCollisionBox.collisionVertexArray,x.icon.placed,h,B.icon,T?s.x:0,T?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 ni(e,s,a,l,h,p){l&&0!==l.length||(l=[0,0,0,0]);const f=l[0]-He,m=l[1]-He,_=l[2]-He,x=l[3]-He;e.emplaceBack(s?1:0,a?1:0,h||0,p||0,f,m),e.emplaceBack(s?1:0,a?1:0,h||0,p||0,_,m),e.emplaceBack(s?1:0,a?1:0,h||0,p||0,_,x),e.emplaceBack(s?1:0,a?1:0,h||0,p||0,f,x)}const ai=Math.pow(2,25),li=Math.pow(2,24),ci=Math.pow(2,17),hi=Math.pow(2,16),ui=Math.pow(2,9),di=Math.pow(2,8),fi=Math.pow(2,1);function _i(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*ai+s*li+a*ci+s*hi+a*ui+s*di+a*fi+s}const gi=0;class ft{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,h){const p=this._bucketParts;for(;this._currentTileIndexe.sortKey-s.sortKey)));this._currentPartIndex!this._forceFullPlacement&&x()-l>2;for(;this._currentPlacementIndex>=0;){const l=s[e[this._currentPlacementIndex]],p=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=p)&&(!l.maxzoom||l.maxzoom>p)){if(this._inProgressLayer||(this._inProgressLayer=new ft(l)),this._inProgressLayer.continuePlacement(a[l.source],this.placement,this._showCollisionBoxes,l,h))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const xi=512/a.$/2;class xt{constructor(e,s,l){this.tileID=e,this.bucketInstanceId=l,this._symbolsByKey={};const h=new Map;for(let e=0;e({x:Math.floor(e.anchorX*xi),y:Math.floor(e.anchorY*xi)}))),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:h,z:p}=this.tileID.canonical,{x:f,y:m,z:_}=s.canonical,x=xi/Math.pow(2,_-p),v=(m*a.$+e.anchorY)*x,b=h*a.$*xi;return{x:Math.floor((f*a.$+e.anchorX)*x-l*a.$*xi),y:Math.floor(v-b)}}findMatches(e,s,a){const l=this.tileID.canonical.ze))}}class bt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class yt{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 h=a[e];h.tileID=h.tileID.unwrapTo(h.tileID.wrap+s),l[h.tileID.key]=h}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 h){const p=h[a];p.tileID.isChildOf(e)&&p.findMatches(s.symbolInstances,e,l)}else{const p=h[e.scaledTo(Number(a)).key];p&&p.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 Pi="void main() {fragColor=vec4(1.0);}";const Mi={prelude:Ci("#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:Ci("","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:Ci("","#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:Ci("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:Ci("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:Ci("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:Ci(Pi,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Ci("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:Ci("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:Ci("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:Ci("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:Ci("#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:Ci("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:Ci(Pi,"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:Ci("#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:Ci("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:Ci("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:Ci("#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:Ci("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:Ci("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:Ci("#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:Ci("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:Ci("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:Ci("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:Ci("#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:Ci("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:Ci("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:Ci("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:Ci("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:Ci("#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:Ci("#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:Ci("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:Ci("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:Ci("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:Ci("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:Ci("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:Ci("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 Ci(e,s){const a=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,l=s.match(/in ([\w]+) ([\w]+)/g),h=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),p=s.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),f=p?p.concat(h):h,m={};return{fragmentSource:e=e.replace(a,((e,s,a,l,h)=>(m[h]=!0,"define"===s?`\n#ifndef HAS_UNIFORM_u_${h}\nin ${a} ${l} ${h};\n#else\nuniform ${a} ${l} u_${h};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${h}\n ${a} ${l} ${h} = u_${h};\n#endif\n`))),vertexSource:s=s.replace(a,((e,s,a,l,h)=>{const p="float"===l?"vec2":"vec4",f=h.match(/color/)?"color":p;return m[h]?"define"===s?`\n#ifndef HAS_UNIFORM_u_${h}\nuniform lowp float u_${h}_t;\nin ${a} ${p} a_${h};\nout ${a} ${l} ${h};\n#else\nuniform ${a} ${l} u_${h};\n#endif\n`:"vec4"===f?`\n#ifndef HAS_UNIFORM_u_${h}\n ${h} = a_${h};\n#else\n ${a} ${l} ${h} = u_${h};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${h}\n ${h} = unpack_mix_${f}(a_${h}, u_${h}_t);\n#else\n ${a} ${l} ${h} = u_${h};\n#endif\n`:"define"===s?`\n#ifndef HAS_UNIFORM_u_${h}\nuniform lowp float u_${h}_t;\nin ${a} ${p} a_${h};\n#else\nuniform ${a} ${l} u_${h};\n#endif\n`:"vec4"===f?`\n#ifndef HAS_UNIFORM_u_${h}\n ${a} ${l} ${h} = a_${h};\n#else\n ${a} ${l} ${h} = u_${h};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${h}\n ${a} ${l} ${h} = unpack_mix_${f}(a_${h}, u_${h}_t);\n#else\n ${a} ${l} ${h} = u_${h};\n#endif\n`})),staticAttributes:l,staticUniforms:f}}class It{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 Ei=a.aJ([{name:"a_pos",type:"Int16",components:2}]);const Ai="#define PROJECTION_MERCATOR",ki="mercator";class Rt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return ki}get shaderDefine(){return Ai}get shaderPreludeCode(){return Mi.projectionMercator}get vertexShaderPreludeCode(){return Mi.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,h,p){if(this._cachedMesh)return this._cachedMesh;const f=new a.aL;f.emplaceBack(0,0),f.emplaceBack(a.$,0),f.emplaceBack(0,a.$),f.emplaceBack(a.$,a.$);const m=e.createVertexBuffer(f,Ei.members),_=a.aM.simpleSegment(0,0,4,2),x=new a.aN;x.emplaceBack(1,0,2),x.emplaceBack(1,2,3);const v=e.createIndexBuffer(x);return this._cachedMesh=new It(m,v,_),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Dt{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.ae((this.left+e-this.right)/2,0,e),h=a.ae((this.top+s-this.bottom)/2,0,s);return new a.P(l,h)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Dt(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Di(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 Ri(e){return Math.max(0,Math.floor(e))}class Lt{constructor(e,s){var l;this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==s?void 0:s.renderWorldCopies)||!!(null==s?void 0:s.renderWorldCopies),this._minZoom=(null==s?void 0:s.minZoom)||0,this._maxZoom=(null==s?void 0:s.maxZoom)||22,this._minPitch=null==(null==s?void 0:s.minPitch)?0:null==s?void 0:s.minPitch,this._maxPitch=null==(null==s?void 0:s.maxPitch)?60:null==s?void 0:s.maxPitch,this._constrain=null!==(l=null==s?void 0:s.constrain)&&void 0!==l?l:this._callbacks.constrain,this.setMaxBounds(),this._width=0,this._height=0,this._center=new a.S(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Ri(this._zoom),this._scale=a.ah(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Dt,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=Ri(this._zoom),this._scale=a.ah(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 Dt(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.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.constrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.constrain(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 constrain(){return this._constrain}setConstrain(e){e||(e=this._callbacks.constrain),this._constrain=e,this.constrainInternal(),this._calcMatrices()}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new 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,p,f,m,_,x,v,b,w;this._bearingInRadians!==s&&(this._unmodified=!1,this._bearingInRadians=s,this._calcMatrices(),this._rotationMatrix=h(),l=this._rotationMatrix,f=-this._bearingInRadians,m=(p=this._rotationMatrix)[0],_=p[1],x=p[2],v=p[3],b=Math.sin(f),w=Math.cos(f),l[0]=m*w+x*b,l[1]=_*w+v*b,l[2]=m*-b+x*w,l[3]=_*-b+v*w)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const s=a.ae(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.ae(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=a.ag(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const s=this.constrain(this._center,e).zoom;this._zoom!==s&&(this._unmodified=!1,this._zoom=s,this._tileZoom=Math.max(0,Math.floor(s)),this._scale=a.ah(s),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,s){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=s,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,s,a){this._unmodified=!1,this._edgeInsets.interpolate(e,s,a),this.constrainInternal(),this._calcMatrices()}resize(e,s,a=!0){this._width=e,this._height=s,a&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new $([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-a.af,a.af])}getCameraQueryGeometry(e,s){if(1===s.length)return[s[0],e];{const{minX:l,minY:h,maxX:p,maxY:f}=a.a2.fromPoints(s).extend(e);return[new a.P(l,h),new a.P(p,h),new a.P(p,f),new a.P(l,f),new a.P(l,h)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:s,zoom:a}=this.constrain(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.ai(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.ai(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,h){const p=void 0!==l?l:this.bearing,f=h=void 0!==h?h:this.pitch,m=a.a1.fromLngLat(e,s),_=-Math.cos(a.ag(f)),x=Math.sin(a.ag(f)),v=x*Math.sin(a.ag(p)),b=-x*Math.cos(a.ag(p));let w=this.elevation;const T=s-w;let P;_*T>=0||Math.abs(_)<.1?(P=1e4,w=s+P*_):P=-T/_;let M,E,z=a.aQ(1,m.y),k=0;do{if(k+=1,k>10)break;E=P/z,M=new a.a1(m.x+v*E,m.y+b*E),z=1/M.meterInMercatorCoordinateUnits()}while(Math.abs(P-E*z)>1e-12);return{center:M.toLngLat(),elevation:w,zoom:a.ak(this.height/2/Math.tan(this.fovInRadians/2)/E/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const s=a.aj(1,this.center.lat)*this.worldSize,l=this.cameraToCenterDistance/s,h=a.a1.fromLngLat(this.center,this.elevation),p=qt(this.center,this.elevation,this.pitch,this.bearing,l);this._elevation=e;const f=this.calculateCenterFromCameraLngLatAlt(p.toLngLat(),a.aQ(p.z,h.y),this.bearing,this.pitch);this._elevation=f.elevation,this._center=f.center,this.setZoom(f.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 qt(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 Ft{distanceToTile2d(e,s,a,l){const h=l.distanceX([e,s]),p=l.distanceY([e,s]);return Math.hypot(h,p)}getWrap(e,s,a){return a}getTileBoundingVolume(e,s,l,h){var p,f;let m=0,_=0;if(null==h?void 0:h.terrain){const x=new a.Z(e.z,s,e.z,e.x,e.y),v=h.terrain.getMinMaxElevation(x);m=null!==(p=v.minElevation)&&void 0!==p?p:Math.min(0,l),_=null!==(f=v.maxElevation)&&void 0!==f?f:Math.max(0,l)}const x=1<h}allowWorldCopies(){return!0}prepareNextFrame(){}}class Bt{constructor(e,s,a){this.points=e,this.planes=s,this.aabb=a}static fromInvProjectionMatrix(e,s=1,l=0,h,p){const f=p?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],m=Math.pow(2,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,h){const p=a.aw([],e,s),f=1/p[3]/l*h;return a.aY(p,p,[f,f,1/p[3],f])}(l,e,s,m)));h&&function(e,s,l,h){const p=h?4:0,f=h?0:4;let m=0;const _=[],x=[];for(let s=0;s<4;s++){const l=a.aU([],e[s+f],e[s+p]),h=a.aZ(l);a.aR(l,l,1/h),_.push(h),x.push(l)}for(let s=0;s<4;s++){const h=a.a_(e[s+p],x[s],l);m=null!==h&&h>=0?Math.max(m,h):Math.max(m,_[s])}const v=function(e,s){const l=a.aU([],e[s[0]],e[s[1]]),h=a.aU([],e[s[2]],e[s[1]]),p=[0,0,0,0];return a.aV(p,a.aW([],l,h)),p[3]=-a.aX(p,e[s[0]]),p}(e,s),b=function(e,s){const l=a.a$(e),h=a.b0([],e,1/l),p=a.aU([],s,a.aR([],h,a.aX(s,h))),f=a.a$(p);if(f>0){const e=Math.sqrt(1-h[3]*h[3]),l=a.aR([],h,-h[3]),m=a.aS([],l,a.aR([],p,e/f));return a.b1(s,m)}return null}(l,v);if(null!==b){const e=b/a.aX(x[0],v);m=Math.min(m,e)}for(let s=0;s<4;s++){const a=Math.min(m,_[s]);e[s+f]=[e[s+p][0]+x[s][0]*a,e[s+p][1]+x[s][1]*a,e[s+p][2]+x[s][2]*a,1]}}(_,f[0],h,p);const x=f.map((e=>{const s=a.aU([],_[e[0]],_[e[1]]),l=a.aU([],_[e[2]],_[e[1]]),h=a.aV([],a.aW([],s,l)),p=-a.aX(h,_[e[1]]);return h.concat(p)})),v=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],b=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of _)for(let s=0;s<3;s++)v[s]=Math.min(v[s],e[s]),b[s]=Math.max(b[s],e[s]);return new Bt(_,x,new kt(v,b))}}class Ot{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)}setConstrain(e){this._helper.setConstrain(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 constrain(){return this._helper.constrain}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,s){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,s)=>{s=a.ae(+s,this.minZoom,this.maxZoom);const l={center:new a.S(e.lng,e.lat),zoom:s};let h=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===h){const e=180-1e-10;h=[-e,e]}const p=this.tileSize*a.ah(l.zoom);let f=0,m=p,_=0,x=p,v=0,b=0;const{x:w,y:T}=this.size;if(this._helper._latRange){const e=this._helper._latRange;f=a.U(e[1])*p,m=a.U(e[0])*p,m-fm&&(z=m-e)}if(h){const e=(_+x)/2;let s=P;this._helper._renderWorldCopies&&(s=a.aO(P,e-p/2,e+p/2));const l=w/2;s-l<_&&(E=_+l),s+l>x&&(E=x-l)}if(void 0!==E||void 0!==z){const e=new a.P(null!=E?E:P,null!=z?z:M);l.center=jt(p,e).wrap()}return l},this._helper=new Lt({calcMatrices:()=>{this._calcMatrices()},constrain:(e,s)=>this.defaultConstrain(e,s)},e),this._coveringTilesDetailsProvider=new Ft}clone(){const e=new Ot;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)),h=this.screenPointToMercatorCoordinate(new a.P(this._helper._width,0)),p=this.screenPointToMercatorCoordinate(new a.P(this._helper._width,this._helper._height)),f=this.screenPointToMercatorCoordinate(new a.P(0,this._helper._height)),m=Math.floor(Math.min(l.x,h.x,p.x,f.x)),_=Math.floor(Math.max(l.x,h.x,p.x,f.x)),x=1;for(let l=m-x;l<=_+x;l++)0!==l&&s.push(new a.b2(l,e))}return s}getCameraFrustum(){return Bt.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),h=this.screenPointToMercatorCoordinateAtZ(s,l),p=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,l),f=a.a1.fromLngLat(e),m=new a.a1(f.x-(h.x-p.x),f.y-(h.y-p.y));this.setCenter(null==m?void 0:m.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,s){return s?this.coordinatePoint(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,h=[e.x,e.y,0,1],p=[e.x,e.y,1,1];a.aw(h,h,this._pixelMatrixInverse),a.aw(p,p,this._pixelMatrixInverse);const f=h[3],m=p[3],_=h[1]/f,x=p[1]/m,v=h[2]/f,b=p[2]/m,w=v===b?0:(l-v)/(b-v);return new a.a1(a.C.number(h[0]/f,p[0]/m,w)/this.worldSize,a.C.number(_,x,w)/this.worldSize,l)}coordinatePoint(e,s=0,l=this._pixelMatrix){const h=[e.x*this.worldSize,e.y*this.worldSize,s,1];return a.aw(h,h,l),new a.P(h[0]/h[3],h[1]/h[3])}getBounds(){const e=Math.max(0,this._helper._height/2-Nt(this));return(new $).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-Nt(this)}calculatePosMatrix(e,s=!1,l){var h;const p=null!==(h=e.key)&&void 0!==h?h:a.b3(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),f=s?this._alignedPosMatrixCache:this._posMatrixCache;if(f.has(p)){const e=f.get(p);return l?e.f32:e.f64}const m=Zt(e,this.worldSize);a.O(m,s?this._alignedProjMatrix:this._viewProjMatrix,m);const _={f64:m,f32:new Float32Array(m)};return f.set(p,_),l?_.f32:_.f64}calculateFogMatrix(e){const s=e.key,l=this._fogMatrixCacheF32;if(l.has(s))return l.get(s);const h=Zt(e,this.worldSize);return a.O(h,this._fogMatrix,h),l.set(s,new Float32Array(h)),l.get(s)}calculateCenterFromCameraLngLatAlt(e,s,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,a,l)}_calculateNearFarZIfNeeded(e,s,l){if(!this._helper.autoCalculateNearFarZ)return;const h=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),p=e-h*this._helper._pixelPerMeter/Math.cos(s),f=h<0?p:e,m=Math.PI/2+this.pitchInRadians,_=a.ag(this.fov)*(Math.abs(Math.cos(a.ag(this.roll)))*this.height+Math.abs(Math.sin(a.ag(this.roll)))*this.width)/this.height*(.5+l.y/this.height),x=Math.sin(_)*f/Math.sin(a.ae(Math.PI-m-_,.01,Math.PI-.01)),v=Nt(this),b=Math.atan(v/this._helper.cameraToCenterDistance),w=a.ag(.75),T=b>w?2*b*(.5+l.y/(2*v)):w,P=Math.sin(T)*f/Math.sin(a.ae(Math.PI-m-T,.01,Math.PI-.01)),M=Math.min(x,P);this._helper._farZ=1.01*(Math.cos(Math.PI/2-s)*M+f),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,s=zt(this.worldSize,this.center),l=s.x,h=s.y;this._helper._pixelPerMeter=a.aj(1,this.center.lat)*this.worldSize;const p=a.ag(Math.min(this.pitch,At)),f=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(p));let m;this._calculateNearFarZIfNeeded(f,p,e),m=new Float64Array(16),a.b4(m,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),a.aq(this._invProjMatrix,m),m[8]=2*-e.x/this._helper._width,m[9]=2*e.y/this._helper._height,this._projectionMatrix=a.b5(m),a.N(m,m,[1,-1,1]),a.M(m,m,[0,0,-this._helper.cameraToCenterDistance]),a.b6(m,m,-this.rollInRadians),a.b7(m,m,this.pitchInRadians),a.b6(m,m,-this.bearingInRadians),a.M(m,m,[-l,-h,0]),this._mercatorMatrix=a.N([],m,[this.worldSize,this.worldSize,this.worldSize]),a.N(m,m,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=a.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,m),a.M(m,m,[0,0,-this.elevation]),this._viewProjMatrix=m,this._invViewProjMatrix=a.aq([],m);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,f,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,-h,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,m);const x=this._helper._width%2/2,v=this._helper._height%2/2,b=Math.cos(this.bearingInRadians),w=Math.sin(-this.bearingInRadians),T=l-Math.round(l)+b*x+w*v,P=h-Math.round(h)+b*v+w*x,M=new Float64Array(m);if(a.M(M,M,[T>.5?T-1:T,P>.5?P-1:P,0]),this._alignedProjMatrix=M,m=a.aq(new Float64Array(16),this._pixelMatrix),!m)throw new Error("failed to invert matrix");this._pixelMatrixInverse=m,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new 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 qt(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,s){const l=a.a1.fromLngLat(e),h=[l.x*this.worldSize,l.y*this.worldSize,s,1];return a.aw(h,h,this._viewProjMatrix),h[2]/h[3]}getProjectionData(e){const{overscaledTileID:s,aligned:l,applyTerrainMatrix:h}=e,p=this._helper.getMercatorTileCoordinates(s),f=s?this.calculatePosMatrix(s,l,!0):null;let m;return m=s&&s.terrainRttPosMatrix32f&&h?s.terrainRttPosMatrix32f:f||a.b8(),{mainMatrix:m,tileMercatorCoords:p,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:m}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,s,a){return 1}transformLightDirection(e){return a.aT(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,s,l,h){const p=this.calculatePosMatrix(l);let f;h?(f=[e,s,h(e,s),1],a.aw(f,f,p)):(f=[e,s,0,1],Ze(f,f,p));const m=f[3];return{point:new a.P(f[0]/m,f[1]/m),signedDistanceFromCamera:m,isOccluded:!1}}populateCache(e){for(const s of e)this.calculatePosMatrix(s)}getMatrixForModel(e,s){const l=a.a1.fromLngLat(e,s),h=l.meterInMercatorCoordinateUnits(),p=a.b9();return a.M(p,p,[l.x,l.y,l.z]),a.b6(p,p,Math.PI),a.b7(p,p,Math.PI/2),a.N(p,p,[-h,h,h]),p}getProjectionDataForCustomLayer(e=!0){const s=new a.Z(0,0,0,0,0),l=this.getProjectionData({overscaledTileID:s,applyGlobeMatrix:e}),h=Zt(s,this.worldSize);a.O(h,this._viewProjMatrix,h),l.tileMercatorCoords=[0,0,1,1];const p=[a.$,a.$,this.worldSize/this._helper.pixelsPerMeter],f=a.ba();return a.N(f,h,p),l.fallbackMatrix=f,l.mainMatrix=f,l}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Li(){a.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Fi(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),h=new Float64Array(4);a.bc(h,s,l,e.k);const p=a.bd(h);e.tr.setRoll(p.roll),e.tr.setPitch(p.pitch),e.tr.setBearing(p.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(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 Bi(e,s,l,h,p){const f=p.padding,m=zt(p.worldSize,l.getNorthWest()),_=zt(p.worldSize,l.getNorthEast()),x=zt(p.worldSize,l.getSouthEast()),v=zt(p.worldSize,l.getSouthWest()),b=a.ag(-h),w=m.rotate(b),T=_.rotate(b),P=x.rotate(b),M=v.rotate(b),E=new a.P(Math.max(w.x,T.x,M.x,P.x),Math.max(w.y,T.y,M.y,P.y)),z=new a.P(Math.min(w.x,T.x,M.x,P.x),Math.min(w.y,T.y,M.y,P.y)),k=E.sub(z),L=(p.width-(f.left+f.right+s.left+s.right))/k.x,F=(p.height-(f.top+f.bottom+s.top+s.bottom))/k.y;if(F<0||L<0)return void Li();const B=Math.min(a.ak(p.scale*Math.min(L,F)),e.maxZoom),j=a.P.convert(e.offset),V=new a.P((s.left-s.right)/2,(s.top-s.bottom)/2).rotate(a.ag(h)),N=j.add(V).mult(p.scale/a.ah(B));return{center:jt(p.worldSize,m.add(x).div(2).sub(N)),zoom:B,bearing:h}}class Ut{get useGlobeControls(){return!1}handlePanInertia(e,s){const a=e.mag(),l=Math.abs(Nt(s));return{easingOffset:e.mult(Math.min(.75*l/a,1)),easingCenter:s.center}}handleMapControlsRollPitchBearingZoom(e,s){e.bearingDelta&&s.setBearing(s.bearing+e.bearingDelta),e.pitchDelta&&s.setPitch(s.pitch+e.pitchDelta),e.rollDelta&&s.setRoll(s.roll+e.rollDelta),e.zoomDelta&&s.setZoom(s.zoom+e.zoomDelta)}handleMapControlsPan(e,s,a){e.around.distSqr(s.centerPoint)<.01||s.setLocationAtPoint(a,e.around)}cameraForBoxAndBearing(e,s,a,l,h){return Bi(e,s,a,l,h)}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,h=e.padding,p={roll:e.roll,pitch:e.pitch,bearing:e.bearing},f={roll:void 0===s.roll?e.roll:s.roll,pitch:void 0===s.pitch?e.pitch:s.pitch,bearing:void 0===s.bearing?e.bearing:s.bearing},m=void 0!==s.zoom,_=!e.isPaddingEqual(s.padding);let x=!1;const v=m?+s.zoom:e.zoom;let b=e.centerPoint.add(s.offsetAsPoint);const w=e.screenPointToLocation(b),{center:T,zoom:P}=e.constrain(a.S.convert(s.center||w),null!=v?v:l);Di(e,T);const M=zt(e.worldSize,w),E=zt(e.worldSize,T).sub(M),z=a.ah(P-l);return x=P!==l,{easeFunc:m=>{if(x&&e.setZoom(a.C.number(l,P,m)),a.be(p,f)||Fi({startEulerAngles:p,endEulerAngles:f,tr:e,k:m,useSlerp:p.roll!=f.roll}),_&&(e.interpolatePadding(h,s.padding,m),b=e.centerPoint.add(s.offsetAsPoint)),s.around)e.setLocationAtPoint(s.around,s.aroundPoint);else{const s=a.ah(e.zoom-l),h=P>l?Math.min(2,z):Math.max(.5,z),p=Math.pow(h,1-m),f=jt(e.worldSize,M.add(E.mult(m*p)).mult(s));e.setLocationAtPoint(e.renderWorldCopies?f.wrap():f,b)}},isZooming:x,elevationCenter:T}}handleFlyTo(e,s){const l=void 0!==s.zoom,h=e.zoom,p=e.constrain(a.S.convert(s.center||s.locationAtOffset),l?+s.zoom:h),f=p.center,m=p.zoom;Di(e,f);const _=zt(e.worldSize,s.locationAtOffset),x=zt(e.worldSize,f).sub(_),v=x.mag(),b=a.ah(m-h);let w;if(void 0!==s.minZoom){const l=Math.min(+s.minZoom,h,m),p=e.constrain(f,l).zoom;w=a.ah(p-h)}return{easeFunc:(s,l,p,v)=>{e.setZoom(1===s?m:h+a.ak(l));const b=1===s?f:jt(e.worldSize,_.add(x.mult(p)).mult(l));e.setLocationAtPoint(e.renderWorldCopies?b.wrap():b,v)},scaleOfZoom:b,targetCenter:f,scaleOfMinZoom:w,pixelPathLength:v}}}class Gt{constructor(e,s,a){this.blendFunction=e,this.blendColor=s,this.mask=a}}Gt.Replace=[1,0],Gt.disabled=new Gt(Gt.Replace,a.bf.transparent,[!1,!1,!1,!1]),Gt.unblended=new Gt(Gt.Replace,a.bf.transparent,[!0,!0,!0,!0]),Gt.alphaBlended=new Gt([1,771],a.bf.transparent,[!0,!0,!0,!0]);const Oi=2305;class $t{constructor(e,s,a){this.enable=e,this.mode=s,this.frontFace=a}}$t.disabled=new $t(!1,1029,Oi),$t.backCCW=new $t(!0,1029,Oi),$t.frontCCW=new $t(!0,1028,Oi);class Wt{constructor(e,s,a){this.func=e,this.mask=s,this.range=a}}Wt.ReadOnly=!1,Wt.ReadWrite=!0,Wt.disabled=new Wt(519,Wt.ReadOnly,[0,1]);const ji=7680;class Ht{constructor(e,s,a,l,h,p){this.test=e,this.ref=s,this.mask=a,this.fail=l,this.depthFail=h,this.pass=p}}Ht.disabled=new Ht({func:519,mask:0},0,0,ji,ji,ji);const Vi=new WeakMap;function Ni(e){var s;if(Vi.has(e))return Vi.get(e);{const a=null===(s=e.getParameter(e.VERSION))||void 0===s?void 0:s.startsWith("WebGL 2.0");return Vi.set(e,a),a}}class Qt{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 h=new a.aL;h.emplaceBack(-1,-1),h.emplaceBack(2,-1),h.emplaceBack(-1,2);const p=new a.aN;p.emplaceBack(0,1,2),this._fullscreenTriangle=new It(s.createVertexBuffer(h,Ei.members),s.createIndexBuffer(p),a.aM.simpleSegment(0,0,h.length,p.length)),this._resultBuffer=new Uint8Array(4),s.activeTexture.set(l.TEXTURE1);const f=l.createTexture();l.bindTexture(l.TEXTURE_2D,f),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(f),Ni(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,h=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,h.TRIANGLES,Wt.disabled,Ht.disabled,Gt.unblended,$t.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&&Ni(h)){h.bindBuffer(h.PIXEL_PACK_BUFFER,this._pbo),h.readBuffer(h.COLOR_ATTACHMENT0),h.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),h.bindBuffer(h.PIXEL_PACK_BUFFER,null);const e=h.fenceSync(h.SYNC_GPU_COMMANDS_COMPLETE,0);h.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&&Ni(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=Qt._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 Ui=a.$/128;function $i(e,s){const l=void 0!==e.granularity?Math.max(e.granularity,1):1,h=l+(e.generateBorders?2:0),p=l+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),f=h+1,m=p+1,_=e.generateBorders?-1:0,x=e.generateBorders||e.extendToNorthPole?-1:0,v=l+(e.generateBorders?1:0),b=l+(e.generateBorders||e.extendToSouthPole?1:0),w=f*m,T=h*p*6,P=f*m>65536;if(P&&"16bit"===s)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const M=P||"32bit"===s,E=new Int16Array(2*w);let z=0;for(let s=x;s<=b;s++)for(let h=_;h<=v;h++){let p=h/l*a.$;-1===h&&(p=-Ui),h===l+1&&(p=a.$+Ui);let f=s/l*a.$;-1===s&&(f=e.extendToNorthPole?a.bh:-Ui),s===l+1&&(f=e.extendToSouthPole?a.bi:a.$+Ui),E[z++]=p,E[z++]=f}const k=M?new Uint32Array(T):new Uint16Array(T);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,h){return this.currentProjection.getMeshFromTileID(e,s,a,l,h)}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 qi(e){const s=Xi(e.worldSize,e.center.lat);return 2*Math.PI*s}function Wi(e,s,l,h,p){const f=1/(1<1e-6){const h=e[0]/l,p=Math.acos(e[2]/l),f=(h>0?p:-p)/Math.PI*180;return new a.S(a.aO(f,-180,180),s)}return new a.S(0,s)}function Ki(e){return Math.cos(e*Math.PI/180)}function Ji(e,s){const l=Ki(e),h=Ki(s);return a.ak(h/l)}function Qi(e,s){const l=e.rotate(s.bearingInRadians),h=s.zoom+Ji(s.center.lat,0),p=a.bk(1/Ki(s.center.lat),1/Ki(Math.min(Math.abs(s.center.lat),60)),a.bn(h,7,3,0,1)),f=360/qi({worldSize:s.worldSize,center:{lat:s.center.lat}});return new a.S(s.center.lng-l.x*f*p,a.ae(s.center.lat+l.y*f,-a.af,a.af))}function lr(e){const s=.5*e,a=Math.sin(s),l=Math.cos(s);return Math.log(a+l)-Math.log(l-a)}function cr(e,s,l,h){const p=e.lat+l*h;if(Math.abs(l)>1){const f=(Math.sign(e.lat+l)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,m=Math.abs(e.lat+l)*Math.PI/180,_=lr(f+h*(m-f)),x=lr(f),v=lr(m);return new a.S(e.lng+s*((_-x)/(v-x)),p)}return new a.S(e.lng+s*h,p)}class pi{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 h=`${e.z}_${e.x}_${e.y}_${(null==l?void 0:l.terrain)?"t":""}`,p=this._cache.get(h);if(p)return p;const f=this._cachePrevious.get(h);if(f)return this._cache.set(h,f),f;const m=this._boundingVolumeFactory(e,s,a,l);return this._cache.set(h,m),this._hadAnyChanges=!0,m}}class mi{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 mi(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 h=a.br([],l[0],l[1],l[2]),p=a.bs([],[s[0],0,0],h),f=a.bs([],[0,s[1],0],h),m=a.bs([],[0,0,s[2]],h),_=[...e],x=[...e];for(let s=0;s<8;s++)for(let a=0;a<3;a++){const l=e[a]+p[a]*(1&~s?-1:1)+f[a]*(1==(s>>1&1)?1:-1)+m[a]*(1==(s>>2&1)?1:-1);_[a]=Math.min(_[a],l),x[a]=Math.max(x[a],l)}const v=[];for(let s=0;s<8;s++){const l=[...e];a.aS(l,l,a.aR([],p,1&~s?-1:1)),a.aS(l,l,a.aR([],f,1==(s>>1&1)?1:-1)),a.aS(l,l,a.aR([],m,1==(s>>2&1)?1:-1)),v.push(l)}return new mi(v,[[...p,-a.aX(p,v[0])],[...f,-a.aX(f,v[0])],[...m,-a.aX(m,v[0])],[-p[0],-p[1],-p[2],-a.aX(p,v[7])],[-f[0],-f[1],-f[2],-a.aX(f,v[7])],[-m[0],-m[1],-m[2],-a.aX(m,v[7])]],_,x)}intersectsFrustum(e){let s=!0;const a=this.points.length,l=this.planes.length,h=e.planes.length,p=e.points.length;for(let l=0;l=0&&p++}if(0===p)return 0;p=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 _r(e,s,a){const l=e-s;return l<0?-l:Math.max(0,l-a)}function gr(e,s,a,l,h){const p=e-a;let f;return f=p<0?Math.min(-p,1+p-h):p>1?Math.min(Math.max(p-h,0),1-p):0,Math.max(f,_r(s,l,h))}class vi{constructor(){this._boundingVolumeCache=new pi(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,s,a,l){const h=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,s,a,l){return this._boundingVolumeCache.getTileBoundingVolume(e,s,a,l)}_computeTileBoundingVolume(e,s,l,h){var p,f;let m=0,_=0;if(null==h?void 0:h.terrain){const x=new a.Z(e.z,s,e.z,e.x,e.y),v=h.terrain.getMinMaxElevation(x);m=null!==(p=v.minElevation)&&void 0!==p?p:Math.min(0,l),_=null!==(f=v.maxElevation)&&void 0!==f?f:Math.max(0,l)}if(m/=a.bu,_/=a.bu,m+=1,_+=1,e.z<=0)return mi.fromAabb([-_,-_,-_],[_,_,_]);if(1===e.z)return mi.fromAabb([0===e.x?-_:0,0===e.y?0:-_,-_],[0===e.x?0:_,0===e.y?_:0,_]);{const s=[Wi(0,0,e.x,e.y,e.z),Wi(a.$,0,e.x,e.y,e.z),Wi(a.$,a.$,e.x,e.y,e.z),Wi(0,a.$,e.x,e.y,e.z)],l=[];for(const e of s)l.push(a.aR([],e,_));if(_!==m)for(const e of s)l.push(a.aR([],e,m));0===e.y&&l.push([0,1,0]),e.y===(1<=(1<{const l=a.ae(e.lat,-a.af,a.af),h=a.ae(+s,this.minZoom+Ji(0,l),this.maxZoom);return{center:new a.S(e.lng,l),zoom:h}},this._helper=new Lt({calcMatrices:()=>{this._calcMatrices()},constrain:(e,s)=>this.defaultConstrain(e,s)},e),this._coveringTilesDetailsProvider=new vi}clone(){const e=new bi;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,h=Math.sin(s)*l,p=Math.cos(s)*l+1,f=1/Math.sqrt(h*h+p*p)*1;let m=-h,_=p;const x=Math.sqrt(m*m+_*_);m/=x,_/=x;const v=[0,m,_];a.bw(v,v,[0,0,0],-this.bearingInRadians),a.bx(v,v,[0,0,0],-1*this.center.lat*Math.PI/180),a.by(v,v,[0,0,0],this.center.lng*Math.PI/180);const b=1/a.aZ(v);return a.aR(v,v,b),[...v,-f*b]}isLocationOccluded(e){return!this.isSurfacePointVisible(Hi(e))}transformLightDirection(e){const s=this._helper._center.lng*Math.PI/180,l=this._helper._center.lat*Math.PI/180,h=Math.cos(l),p=[Math.sin(s)*h,Math.sin(l),Math.cos(s)*h],f=[p[2],0,-p[0]],m=[0,0,0];a.aW(m,f,p),a.aV(f,f),a.aV(m,m);const _=[0,0,0];return a.aV(_,[f[0]*e[0]+m[0]*e[1]+p[0]*e[2],f[1]*e[0]+m[1]*e[1]+p[1]*e[2],f[2]*e[0]+m[2]*e[1]+p[2]*e[2]]),_}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,s,l){const h=function(e,s,l){const h=1/(1<p&&(p=s),l<_&&(_=l),l>m&&(m=l)}const v=[x.lng+f,x.lat+_,x.lng+p,x.lat+m];return this.isSurfacePointOnScreen([0,1,0])&&(v[3]=90,v[0]=-180,v[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(v[1]=-90,v[0]=-180,v[2]=180),new $(v)}calculateCenterFromCameraLngLatAlt(e,s,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,a,l)}setLocationAtPoint(e,s){const l=Hi(this.unprojectScreenPoint(s)),h=Hi(e),p=a.bp();a.bB(p);const f=a.bp();a.by(f,l,p,-this.center.lng*Math.PI/180),a.bx(f,f,p,this.center.lat*Math.PI/180);const m=h[0]*h[0]+h[2]*h[2],_=f[0]*f[0];if(m<_)return;const x=Math.sqrt(m-_),v=-x,b=a.bC(h[0],h[2],f[0],x),w=a.bC(h[0],h[2],f[0],v),T=a.bp();a.by(T,h,p,-b);const P=a.bC(T[1],T[2],f[1],f[2]),M=a.bp();a.by(M,h,p,-w);const E=a.bC(M[1],M[2],f[1],f[2]),z=.5*Math.PI,k=P>=-z&&P<=z,L=E>=-z&&E<=z;let F,B;if(k&&L){const e=this.center.lng*Math.PI/180,s=this.center.lat*Math.PI/180;a.bD(b,e)+a.bD(P,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),h=a.bp(),p=a.bp();a.aR(p,s,l),a.aU(h,e,p);const f=1-a.aX(h,h);if(f<0)return null;const m=a.aX(e,e)-1,_=-l+(l<0?1:-1)*Math.sqrt(f),x=m/_,v=_;return{tMin:Math.min(x,v),tMax:Math.max(x,v)}}unprojectScreenPoint(e){const s=this._cameraPosition,l=this.getRayDirectionFromPixel(e),h=this.rayPlanetIntersection(s,l);if(h){const e=a.bp();a.aS(e,s,[l[0]*h.tMin,l[1]*h.tMin,l[2]*h.tMin]);const p=a.bp();return a.aV(p,e),Yi(p)}const p=this._cachedClippingPlane,f=p[0]*l[0]+p[1]*l[1]+p[2]*l[2],m=-a.b1(p,s)/f,_=a.bp();if(m>0)a.aS(_,s,[l[0]*m,l[1]*m,l[2]*m]);else{const e=a.bp();a.aS(e,s,[2*l[0],2*l[1],2*l[2]]);const h=a.b1(this._cachedClippingPlane,e);a.aU(_,e,[this._cachedClippingPlane[0]*h,this._cachedClippingPlane[1]*h,this._cachedClippingPlane[2]*h])}const x=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])}}(p);return Yi(function(e,s,l){const h=a.bp();a.aU(h,l,e);const p=a.bp();return a.bq(p,e,h,s/a.a$(h)),p}(x.center,x.radius,_))}getMatrixForModel(e,s){const l=a.S.convert(e),h=1/a.bu,p=a.b9();return a.bz(p,p,l.lng/180*Math.PI),a.b7(p,p,-l.lat/180*Math.PI),a.M(p,p,[0,0,1+s/a.bu]),a.b7(p,p,.5*Math.PI),a.N(p,p,[h,h,h]),p}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 yi{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)}setConstrain(e){this._helper.setConstrain(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 constrain(){return this._helper.constrain}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,s){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=s,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,s)=>this.currentTransform.defaultConstrain(e,s),this._helper=new Lt({calcMatrices:()=>{this._calcMatrices()},constrain:(e,s)=>this.defaultConstrain(e,s)},e),this._globeness=1,this._mercatorTransform=new Ot,this._verticalPerspectiveTransform=new bi}clone(){const e=new yi;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 h=this._mercatorTransform.getPitchedTextCorrection(e,s,l),p=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,s,l);return a.bk(h,p,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()}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 wi{get useGlobeControls(){return!0}handlePanInertia(e,s){const l=Qi(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,h=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 p=s.zoom;e.zoomDelta&&s.setZoom(s.zoom+e.zoomDelta);const f=s.zoom-p;if(0===f)return;const m=a.bA(s.center.lng,h.lng),_=m/(Math.abs(m/180)+1),x=a.bA(s.center.lat,h.lat),v=s.getRayDirectionFromPixel(l),b=s.cameraPosition,w=-1*a.aX(b,v),T=a.bp();a.aS(T,b,[v[0]*w,v[1]*w,v[2]*w]);const P=a.aZ(T)-1,M=Math.exp(.5*-Math.max(P-.3,0)),E=Xi(s.worldSize,s.center.lat)/Math.min(s.width,s.height),z=a.bn(E,.9,.5,1,.25),k=(1-a.ah(-f))*Math.min(M,z),L=s.center.lat,F=s.zoom,B=new a.S(s.center.lng+_*k,a.ae(s.center.lat+x*k,-a.af,a.af));s.setLocationAtPoint(h,l);const j=s.center,V=a.bn(Math.abs(m),45,85,0,1),N=a.bn(E,.75,.35,0,1),U=Math.pow(Math.max(V,N),.25),G=a.bA(j.lng,B.lng),Z=a.bA(j.lat,B.lat);s.setCenter(new a.S(j.lng+G*U,j.lat+Z*U).wrap()),s.setZoom(F+Ji(L,s.center.lat))}handleMapControlsPan(e,s,a){if(!e.panDelta)return;const l=s.center.lat,h=s.zoom;s.setCenter(Qi(e.panDelta,s).wrap()),s.setZoom(h+Ji(l,s.center.lat))}cameraForBoxAndBearing(e,s,l,h,p){const f=Bi(e,s,l,h,p),m=s.left/p.width*2-1,_=(p.width-s.right)/p.width*2-1,x=s.top/p.height*-2+1,v=(p.height-s.bottom)/p.height*-2+1,b=a.bA(l.getWest(),l.getEast())<0,w=b?l.getEast():l.getWest(),T=b?l.getWest():l.getEast(),P=Math.max(l.getNorth(),l.getSouth()),M=Math.min(l.getNorth(),l.getSouth()),E=w+.5*a.bA(w,T),z=P+.5*a.bA(P,M),k=p.clone();k.setCenter(f.center),k.setBearing(f.bearing),k.setPitch(0),k.setRoll(0),k.setZoom(f.zoom);const L=k.modelViewProjectionMatrix,F=[Hi(l.getNorthWest()),Hi(l.getNorthEast()),Hi(l.getSouthWest()),Hi(l.getSouthEast()),Hi(new a.S(T,z)),Hi(new a.S(w,z)),Hi(new a.S(E,P)),Hi(new a.S(E,M))],B=Hi(f.center);let j=Number.POSITIVE_INFINITY;for(const e of F)m<0&&(j=wi.getLesserNonNegativeNonNull(j,wi.solveVectorScale(e,B,L,"x",m))),_>0&&(j=wi.getLesserNonNegativeNonNull(j,wi.solveVectorScale(e,B,L,"x",_))),x>0&&(j=wi.getLesserNonNegativeNonNull(j,wi.solveVectorScale(e,B,L,"y",x))),v<0&&(j=wi.getLesserNonNegativeNonNull(j,wi.solveVectorScale(e,B,L,"y",v)));if(Number.isFinite(j)&&0!==j)return f.zoom=k.zoom+a.ak(j),f;Li()}handleJumpToCenterZoom(e,s){const l=e.center.lat,h=e.constrain(s.center?a.S.convert(s.center):e.center,e.zoom).center;e.setCenter(h.wrap());const p=void 0!==s.zoom?+s.zoom:e.zoom+Ji(l,h.lat);e.zoom!==p&&e.setZoom(p)}handleEaseTo(e,s){const l=e.zoom,h=e.center,p=e.padding,f={roll:e.roll,pitch:e.pitch,bearing:e.bearing},m={roll:void 0===s.roll?e.roll:s.roll,pitch:void 0===s.pitch?e.pitch:s.pitch,bearing:void 0===s.bearing?e.bearing:s.bearing},_=void 0!==s.zoom,x=!e.isPaddingEqual(s.padding);let v=!1;const b=s.center?a.S.convert(s.center):h,w=e.constrain(b,l).center;Di(e,w);const T=e.clone();T.setCenter(w),T.setZoom(_?+s.zoom:l+Ji(h.lat,b.lat)),T.setBearing(s.bearing);const P=new a.P(a.ae(e.centerPoint.x+s.offsetAsPoint.x,0,e.width),a.ae(e.centerPoint.y+s.offsetAsPoint.y,0,e.height));T.setLocationAtPoint(w,P);const M=(s.offset&&s.offsetAsPoint.mag())>0?T.center:w,E=_?+s.zoom:l+Ji(h.lat,M.lat),z=l+Ji(h.lat,0),k=E+Ji(M.lat,0),L=a.bA(h.lng,M.lng),F=a.bA(h.lat,M.lat),B=a.ah(k-z);return v=E!==l,{easeFunc:l=>{if(a.be(f,m)||Fi({startEulerAngles:f,endEulerAngles:m,tr:e,k:l,useSlerp:f.roll!=m.roll}),x&&e.interpolatePadding(p,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=k>z?Math.min(2,B):Math.max(.5,B),a=Math.pow(s,1-l),p=cr(h,L,F,l*a);e.setCenter(p.wrap())}if(v){const s=a.C.number(z,k,l)+Ji(0,e.center.lat);e.setZoom(s)}},isZooming:v,elevationCenter:M}}handleFlyTo(e,s){const l=void 0!==s.zoom,h=e.center,p=e.zoom,f=e.padding,m=!e.isPaddingEqual(s.padding),_=e.constrain(a.S.convert(s.center||s.locationAtOffset),p).center,x=l?+s.zoom:e.zoom+Ji(e.center.lat,_.lat),v=e.clone();v.setCenter(_),v.setZoom(x),v.setBearing(s.bearing);const b=new a.P(a.ae(e.centerPoint.x+s.offsetAsPoint.x,0,e.width),a.ae(e.centerPoint.y+s.offsetAsPoint.y,0,e.height));v.setLocationAtPoint(_,b);const w=v.center;Di(e,w);const T=function(e,s,l){const h=Hi(s),p=Hi(l),f=a.aX(h,p),m=Math.acos(f),_=qi(e);return m/(2*Math.PI)*_}(e,h,w),P=p+Ji(h.lat,0),M=x+Ji(w.lat,0),E=a.ah(M-P);let z;if("number"==typeof s.minZoom){const l=+s.minZoom+Ji(w.lat,0),h=Math.min(l,P,M)+Ji(0,w.lat),p=e.constrain(w,h).zoom+Ji(w.lat,0);z=a.ah(p-P)}const k=a.bA(h.lng,w.lng),L=a.bA(h.lat,w.lat);return{easeFunc:(l,p,_,v)=>{const b=cr(h,k,L,_);m&&e.interpolatePadding(f,s.padding,l);const T=1===l?w:b;e.setCenter(T.wrap());const M=P+a.ak(p);e.setZoom(1===l?x:M+Ji(0,T.lat))},scaleOfZoom:E,targetCenter:w,scaleOfMinZoom:z,pixelPathLength:T}}static solveVectorScale(e,s,a,l,h){const p="x"===l?[a[0],a[4],a[8],a[12]]:[a[1],a[5],a[9],a[13]],f=[a[3],a[7],a[11],a[15]],m=e[0]*p[0]+e[1]*p[1]+e[2]*p[2],_=e[0]*f[0]+e[1]*f[1]+e[2]*f[2],x=s[0]*p[0]+s[1]*p[1]+s[2]*p[2],v=s[0]*f[0]+s[1]*f[1]+s[2]*f[2];return x+h*_===m+h*v||f[3]*(m-x)+p[3]*(v-_)+m*v==x*_?null:(x+p[3]-h*v-h*f[3])/(x-m-h*v+h*_)}static getLesserNonNegativeNonNull(e,s){return null!==s&&s>=0&&sa.y(e,s&&s.filter((e=>"source.canvas"!==e.identifier))),Tr=a.bE();class Ii extends a.E{constructor(e,s={}){var l,h;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 O(st(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,s)=>this.getGlyphs(e,s))),this.dispatcher.registerMessageHandler("GI",((e,s)=>this.getImages(e,s))),this.dispatcher.registerMessageHandler("GDA",((e,s)=>this.getDashes(e,s))),this.imageManager=new y,this.imageManager.setEventedParent(this);const p=(null===(l=e._container)||void 0===l?void 0:l.lang)||"undefined"!=typeof document&&(null===(h=document.documentElement)||void 0===h?void 0:h.lang)||void 0;this.glyphManager=new C(e._requestManager,s.localIdeographFontFamily,p),this.lineAtlas=new D(256,512),this.crossTileSymbolIndex=new wt,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()),St().on(Tt,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,h,p;this._checkLoaded();const f=null===s?null!==(p=null===(h=null===(l=this.stylesheet.state)||void 0===l?void 0:l[e])||void 0===h?void 0:h.default)&&void 0!==p?p:null:s;if(a.bH(f,this._globalState[e]))return this;this._globalState[e]=f,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const s=[];for(const l in e)!a.bH(this._globalState[l],e[l].default)&&(s.push(l),this._globalState[l]=e[l].default);this._applyGlobalStateChanges(s)}_applyGlobalStateChanges(e){if(0===e.length)return;const s=new Set,a={};for(const l of e){a[l]=this._globalState[l];for(const e in this._layers){const a=this._layers[e],h=a.getLayoutAffectingGlobalStateRefs(),p=a.getPaintAffectingGlobalStateRefs();if(h.has(l)&&s.add(a.source),p.has(l))for(const{name:e,value:s}of p.get(l))this._updatePaintProperty(a,e,s)}}this.dispatcher.broadcast("UGS",a);for(const e in this.sourceCaches)s.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,s={},l){this.fire(new a.l("dataloading",{dataType:"style"})),s.validate="boolean"!=typeof s.validate||s.validate;const h=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const p=this._loadStyleRequest;a.j(h,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,s,l)})).catch((e=>{this._loadStyleRequest=null,e&&!p.signal.aborted&&this.fire(new a.k(e))}))}loadJSON(e,s={},l){this.fire(new a.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,m.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(Tr,{validate:!1})}_load(e,s,l){var h,p;let f=s.transformStyle?s.transformStyle(l,e):e;if(!s.validate||!xr(this,a.z(f))){f=Object.assign({},f),this._loaded=!0,this.stylesheet=f;for(const e in f.sources)this.addSource(e,f.sources[e],{validate:!1});f.sprite?this._loadSprite(f.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(f.glyphs),this._createLayers(),this.light=new S(this.stylesheet.light),this._setProjectionInternal((null===(h=this.stylesheet.projection)||void 0===h?void 0:h.type)||"mercator"),this.sky=new R(this.stylesheet.sky),this.map.setTerrain(null!==(p=this.stylesheet.terrain)&&void 0!==p?p:null),this.fire(new a.l("data",{dataType:"style"})),this.fire(new a.l("style.load"))}}_createLayers(){var e,s,l;const h=a.bI(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",h),this._order=h.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const e of h){const h=a.bJ(e,this._globalState);if(h.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=h,a.bK(h)&&this.sourceCaches[h.source]){const a=null!==(l=null===(s=e.paint)||void 0===s?void 0:s["raster-fade-duration"])&&void 0!==l?l:h.paint.get("raster-fade-duration");this.sourceCaches[h.source].setRasterFadeDuration(a)}}}_loadSprite(e,s=!1,l=void 0){let h;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,s,l,h){return a._(this,void 0,void 0,(function*(){const p=z(e),f=l>1?"@2x":"",_={},x={};for(const{id:e,url:l}of p){const p=s.transformRequest(k(l,f,".json"),"SpriteJSON");_[e]=a.j(p,h);const m=s.transformRequest(k(l,f,".png"),"SpriteImage");x[e]=E.getImage(m,h)}return yield Promise.all([...Object.values(_),...Object.values(x)]),function(e,s){return a._(this,void 0,void 0,(function*(){const a={};for(const l in e){a[l]={};const h=m.getImageCanvasContext((yield s[l]).data),p=(yield e[l]).data;for(const e in p){const{width:s,height:f,x:m,y:_,sdf:x,pixelRatio:v,stretchX:b,stretchY:w,content:T,textFitWidth:P,textFitHeight:M}=p[e];a[l][e]={data:null,pixelRatio:v,sdf:x,stretchX:b,stretchY:w,content:T,textFitWidth:P,textFitHeight:M,spriteData:{width:s,height:f,x:m,y:_,context:h}}}}return a}))}(_,x)}))}(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 h="default"===a?l:`${a}:${l}`;this._spritesImagesIds[a].push(h),h in this.imageManager.images?this.imageManager.updateImage(h,e[a][l],!1):this.imageManager.addImage(h,e[a][l]),s&&(this._changedImages[h]=!0)}}})).catch((e=>{this._spriteRequest=null,h=e,this.fire(new a.k(h))})).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(h)}))}_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 h=s.getSource();("geojson"===h.type||h.vectorLayerIds&&-1===h.vectorLayerIds.indexOf(l))&&this.fire(new a.k(new Error(`Source layer "${l}" does not exist on source "${h.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.bL(l):l);const h=[];for(const p of e)if(l[p]){const e=s?a.bL(l[p]):l[p];h.push(e)}return h}_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 h=this.serialize();if(e=s.transformStyle?s.transformStyle(h,e):e,(null===(l=s.validate)||void 0===l||l)&&xr(this,a.z(e)))return!1;(e=a.bL(e)).layers=a.bI(e.layers);const p=a.bM(h,e),f=this._getOperationsToPerform(p);if(f.unimplemented.length>0)throw new Error(`Unimplemented: ${f.unimplemented.join(", ")}.`);if(0===f.operations.length)return!1;for(const e of f.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const s=[],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 h=this.sourceCaches[e]=new Pe(e,s,this.dispatcher);h.style=this,h.setEventedParent(this,(()=>({isSourceLoaded:h.loaded(),source:h.serialize(),sourceId:e}))),h.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 h=e.id;if(this.getLayer(h))return void this.fire(new a.k(new Error(`Layer "${h}" already exists on this map.`)));let p;if("custom"===e.type){if(xr(this,a.bN(e)))return;p=a.bJ(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(h,e.source),e=a.bL(e),e=a.e(e,{source:h})),this._validate(a.z.layer,`layers.${h}`,e,{arrayIndex:-1},l))return;p=a.bJ(e,this._globalState),this._validateLayer(p),p.setEventedParent(this,{layer:{id:h}})}const f=s?this._order.indexOf(s):this._order.length;if(s&&-1===f)this.fire(new a.k(new Error(`Cannot add layer "${h}" before non-existing layer "${s}".`)));else{if(this._order.splice(f,0,h),this._layerOrderChanged=!0,this._layers[h]=p,this._removedLayers[h]&&p.source&&"custom"!==p.type){const e=this._removedLayers[h];delete this._removedLayers[h],e.type!==p.type?this._updatedSources[p.source]="clear":(this._updatedSources[p.source]="reload",this.sourceCaches[p.source].pause())}this._updateLayer(p),p.onAdd&&p.onAdd(this.map)}}moveLayer(e,s){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new 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 h=s?this._order.indexOf(s):this._order.length;s&&-1===h?this.fire(new a.k(new Error(`Cannot move layer "${e}" before non-existing layer "${s}".`))):(this._order.splice(h,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 h=this.getLayer(e);h?h.minzoom===s&&h.maxzoom===l||(null!=s&&(h.minzoom=s),null!=l&&(h.maxzoom=l),this._updateLayer(h)):this.fire(new a.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,s,l={}){this._checkLoaded();const h=this.getLayer(e);if(h){if(!a.bH(h.filter,s))return null==s?(h.setFilter(void 0),void this._updateLayer(h)):void(this._validate(a.z.filter,`layers.${h.id}.filter`,s,null,l)||(h.setFilter(a.bL(s)),this._updateLayer(h)))}else this.fire(new a.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return a.bL(this.getLayer(e).filter)}setLayoutProperty(e,s,l,h={}){this._checkLoaded();const p=this.getLayer(e);p?a.bH(p.getLayoutProperty(s),l)||(p.setLayoutProperty(s,l,h),this._updateLayer(p)):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,h={}){this._checkLoaded();const p=this.getLayer(e);p?a.bH(p.getPaintProperty(s),l)||this._updatePaintProperty(p,s,l,h):this.fire(new a.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,s,l,h={}){e.setPaintProperty(s,l,h)&&this._updateLayer(e),a.bK(e)&&"raster-fade-duration"===s&&this.sourceCaches[e.source].setRasterFadeDuration(l),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,s){return this.getLayer(e).getPaintProperty(s)}setFeatureState(e,s){this._checkLoaded();const l=e.source,h=e.sourceLayer,p=this.sourceCaches[l];if(void 0===p)return void this.fire(new a.k(new Error(`The source '${l}' does not exist in the map's style.`)));const f=p.getSource().type;"geojson"===f&&h?this.fire(new a.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==f||h?(void 0===e.id&&this.fire(new a.k(new Error("The feature id parameter must be provided."))),p.setFeatureState(h,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,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 p=h.getSource().type,f="vector"===p?e.sourceLayer:void 0;"vector"!==p||f?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."))):h.removeFeatureState(f,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,h=this.sourceCaches[s];if(void 0!==h)return"vector"!==h.getSource().type||l?(void 0===e.id&&this.fire(new a.k(new Error("The feature id parameter must be provided."))),h.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.bO(this.sourceCaches,(e=>e.serialize())),s=this._serializeByIds(this._order,!0),l=this.map.getTerrain()||void 0,h=this.stylesheet;return a.bP({version:h.version,name:h.name,metadata:h.metadata,light:h.light,sky:h.sky,center:h.center,zoom:h.zoom,bearing:h.bearing,pitch:h.pitch,sprite:h.sprite,glyphs:h.glyphs,transition:h.transition,projection:h.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 h=this._order.length-1;h>=0;h--){const p=this._order[h];if(s(p)){a[p]=h;for(const s of e){const e=s[p];if(e)for(const s of e)l.push(s)}}}l.sort(((e,s)=>s.intersectionZ-e.intersectionZ));const h=[];for(let p=this._order.length-1;p>=0;p--){const f=this._order[p];if(s(f))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&&p.push(function(e,s,a,l,h,p,f){const m={},_=p.queryRenderedSymbols(l),x=[];for(const e of Object.keys(_).map(Number))x.push(f[e]);x.sort(ut);for(const a of x){const l=a.featureIndex.lookupSymbolFeatures(_[a.bucketInstanceId],s,a.bucketIndex,a.sourceLayerIndex,{filterSpec:h.filter,globalState:h.globalState},h.layers,h.availableImages,e);for(const e in l){const s=m[e]=m[e]||[],h=l[e];h.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 h)s.push(e)}}return function(e,s,a){for(const l in e)for(const h of e[l])dt(h,a[s[l].source]);return e}(m,e,a)}(this._layers,f,this.sourceCaches,e,_,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(p)}querySourceFeatures(e,s){(null==s?void 0: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=[],h={};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,m[a.source],e.center.lng);p=p||l}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((h=h||this._layerOrderChanged||0===a)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(x(),e.zoom))&&(this.pauseablePlacement=new gt(e,this.map.terrain,this._order,h,s,a,l,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,m),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(x()),f=!0),p&&this.pauseablePlacement.placement.setStale()),f||p)for(const e of this._order){const s=this._layers[e];"symbol"===s.type&&this.placement.updateLayerOpacities(s,m[s.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(x())}_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))}getDashes(e,s){return a._(this,void 0,void 0,(function*(){const e={};for(const[a,l]of Object.entries(s.dashes))e[a]=this.lineAtlas.getDash(l.dasharray,l.round);return e}))}addSprite(e,s,l={},h){this._checkLoaded();const p=[{id:e,url:s}],f=[...z(this.stylesheet.sprite),...p];this._validate(a.z.sprite,"sprite",f,null,l)||(this.stylesheet.sprite=f,this._loadSprite(p,!0,h))}removeSprite(e){this._checkLoaded();const s=z(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 z(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 Fr=a.aJ([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Si{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,h,p,f,m,_){this.context=e;let x=this.boundPaintVertexBuffers.length!==l.length;for(let e=0;!x&&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:p?0:l?l.calculateFogBlendOpacity(h):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:p?1:0}),$r={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 Zr(e){const s=[];for(let a=0;a({u_depth:new a.bQ(e,s.u_depth),u_terrain:new a.bQ(e,s.u_terrain),u_terrain_dim:new a.bg(e,s.u_terrain_dim),u_terrain_matrix:new a.bS(e,s.u_terrain_matrix),u_terrain_unpack:new a.bT(e,s.u_terrain_unpack),u_terrain_exaggeration:new a.bg(e,s.u_terrain_exaggeration)}))(e,U),this.projectionUniforms=((e,s)=>({u_projection_matrix:new a.bS(e,s.u_projection_matrix),u_projection_tile_mercator_coords:new a.bT(e,s.u_projection_tile_mercator_coords),u_projection_clipping_plane:new a.bT(e,s.u_projection_clipping_plane),u_projection_transition:new a.bg(e,s.u_projection_transition),u_projection_fallback_matrix:new a.bS(e,s.u_projection_fallback_matrix)}))(e,U),this.binderUniforms=l?l.getUniforms(e,U):[]}draw(e,s,a,l,h,p,f,m,_,x,v,b,w,T,P,M,E,z,k){const L=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(l),e.setColorMode(h),e.setCullFace(p),m){e.activeTexture.set(L.TEXTURE2),L.bindTexture(L.TEXTURE_2D,m.depthTexture),e.activeTexture.set(L.TEXTURE3),L.bindTexture(L.TEXTURE_2D,m.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(m[e])}if(_)for(const e in _)this.projectionUniforms[$r[e]].set(_[e]);if(f)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(f[e]);M&&M.setUniforms(e,this.binderUniforms,T,{zoom:P});let F=0;switch(s){case L.LINES:F=2;break;case L.TRIANGLES:F=3;break;case L.LINE_STRIP:F=1}for(const a of w.get()){const l=a.vaos||(a.vaos={});(l[x]||(l[x]=new Si)).bind(e,this,v,M?M.getPaintVertexBuffers():[],b,a.vertexOffset,E,z,k),L.drawElements(s,a.primitiveLength*F,L.UNSIGNED_SHORT,a.primitiveOffset*F*2)}}}function Xr(e,s,l){const h=1/a.aC(l,1,s.transform.tileZoom),p=Math.pow(2,l.tileID.overscaledZ),f=l.tileSize*Math.pow(2,s.transform.tileZoom)/p,m=f*(l.tileID.canonical.x+l.tileID.wrap*p),_=f*l.tileID.canonical.y;return{u_image:0,u_texsize:l.imageAtlasTexture.size,u_scale:[h,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_]}}const Yr=(e,s,l,h)=>{const p=e.style.light,f=p.properties.get("position"),m=[f.x,f.y,f.z],_=a.bW();"viewport"===p.properties.get("anchor")&&a.bX(_,e.transform.bearingInRadians),a.bY(m,m,_);const x=e.transform.transformLightDirection(m),v=p.properties.get("color");return{u_lightpos:m,u_lightpos_globe:x,u_lightintensity:p.properties.get("intensity"),u_lightcolor:[v.r,v.g,v.b],u_vertical_gradient:+s,u_opacity:l,u_fill_translate:h}},Jr=(e,s,l,h,p,f,m)=>a.e(Yr(e,s,l,h),Xr(f,e,m),{u_height_factor:-Math.pow(2,p.overscaledZ)/m.tileSize/8}),Qr=(e,s,l,h)=>a.e(Xr(s,e,l),{u_fill_translate:h}),tn=(e,s)=>({u_world:e,u_fill_translate:s}),en=(e,s,l,h,p)=>a.e(Qr(e,s,l,p),{u_world:h}),rn=(e,s,l,h,p)=>{const f=e.transform;let m,_,x=0;if("map"===l.paint.get("circle-pitch-alignment")){const e=a.aC(s,1,f.zoom);m=!0,_=[e,e],x=e/(a.$*Math.pow(2,s.tileID.overscaledZ))*2*Math.PI*p}else m=!1,_=f.pixelsToGLUnits;return{u_camera_to_center_distance:f.cameraToCenterDistance,u_scale_with_map:+("map"===l.paint.get("circle-pitch-scale")),u_pitch_with_map:+m,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:_,u_globe_extrude_scale:x,u_translate:h}},nn=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),sn=e=>({u_viewport_size:[e.width,e.height]}),an=(e,s=1)=>({u_color:e,u_overlay:0,u_overlay_scale:s}),ln=(e,s,l,h)=>{const p=a.aC(e,1,s)/(a.$*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*h;return{u_extrude_scale:a.aC(e,1,s),u_intensity:l,u_globe_extrude_scale:p}},cn=(e,s,l,h)=>{const p=a.L();a.bZ(p,0,e.width,e.height,0,0,1);const f=e.context.gl;return{u_matrix:p,u_world:[f.drawingBufferWidth,f.drawingBufferHeight],u_image:l,u_color_ramp:h,u_opacity:s.paint.get("heatmap-opacity")}},hn=(e,s,a)=>{const l=a.paint.get("hillshade-accent-color");let h;switch(a.paint.get("hillshade-method")){case"basic":h=4;break;case"combined":h=1;break;case"igor":h=2;break;case"multidirectional":h=3;break;default:h=0}const p=a.getIlluminationProperties();for(let s=0;s{const l=s.stride,h=a.L();return a.bZ(h,0,a.$,-a.$,0,0,1),a.M(h,h,[0,-a.$,0]),{u_matrix:h,u_image:1,u_dimension:[l,l],u_zoom:e.overscaledZ,u_unpack:s.getUnpackVector()}};function dn(e,s){const l=Math.pow(2,s.canonical.z),h=s.canonical.y;return[new a.a1(0,h/l).toLngLat().lat,new a.a1(0,(h+1)/l).toLngLat().lat]}const pn=(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")}),fn=(e,s,l,h)=>{const p=e.transform;return{u_translation:vn(e,s,l),u_ratio:h/a.aC(s,1,p.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/p.pixelsToGLUnits[0],1/p.pixelsToGLUnits[1]]}},mn=(e,s,l,h,p)=>a.e(fn(e,s,l,h),{u_image:0,u_image_height:p}),_n=(e,s,l,h,p)=>{const f=e.transform,m=xn(s,f);return{u_translation:vn(e,s,l),u_texsize:s.imageAtlasTexture.size,u_ratio:h/a.aC(s,1,f.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[m,p.fromScale,p.toScale],u_fade:p.t,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]]}},gn=(e,s,l,h,p)=>{const f=xn(s,e.transform);return a.e(fn(e,s,l,h),{u_tileratio:f,u_crossfade_from:p.fromScale,u_crossfade_to:p.toScale,u_image:0,u_mix:p.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},yn=(e,s,l,h,p,f)=>{const m=xn(s,e.transform);return a.e(fn(e,s,l,h),{u_image:0,u_image_height:f,u_tileratio:m,u_crossfade_from:p.fromScale,u_crossfade_to:p.toScale,u_image_dash:1,u_mix:p.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function xn(e,s){return 1/a.aC(e,1,s.tileZoom)}function vn(e,s,l){return a.aD(e.transform,s,l.paint.get("line-translate"),l.paint.get("line-translate-anchor"))}const bn=(e,s,a,l,h)=>{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:(f=l.paint.get("raster-saturation"),f>0?1-1/(1.001-f):-f),u_contrast_factor:(p=l.paint.get("raster-contrast"),p>0?1/(1-p):1+p),u_spin_weights:wn(l.paint.get("raster-hue-rotate")),u_coords_top:[h[0].x,h[0].y,h[1].x,h[1].y],u_coords_bottom:[h[3].x,h[3].y,h[2].x,h[2].y]};var p,f};function wn(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 Sn=(e,s,a,l,h,p,f,m,_,x,v,b,w)=>{const T=f.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:s?s.uSizeT:0,u_size:s?s.uSize:0,u_camera_to_center_distance:T.cameraToCenterDistance,u_pitch:T.pitch/360*2*Math.PI,u_rotate_symbol:+a,u_aspect_ratio:T.width/T.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_label_plane_matrix:m,u_coord_matrix:_,u_is_text:+v,u_pitch_with_map:+l,u_is_along_line:h,u_is_variable_anchor:p,u_texsize:b,u_texture:0,u_translation:x,u_pitched_scale:w}},In=(e,s,l,h,p,f,m,_,x,v,b,w,T,P)=>{const M=m.transform;return a.e(Sn(e,s,l,h,p,f,m,_,x,v,b,w,P),{u_gamma_scale:h?Math.cos(M.pitch*Math.PI/180)*M.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:1})},Mn=(e,s,l,h,p,f,m,_,x,v,b,w,T)=>a.e(In(e,s,l,h,p,f,m,_,x,v,!0,b,0,T),{u_texsize_icon:w,u_texture_icon:1}),En=(e,s)=>({u_opacity:e,u_color:s}),An=(e,s,l,h,p)=>a.e(function(e,s,l,h){const p=l.imageManager.getPattern(e.from.toString()),f=l.imageManager.getPattern(e.to.toString()),{width:m,height:_}=l.imageManager.getPixelSize(),x=Math.pow(2,h.tileID.overscaledZ),v=h.tileSize*Math.pow(2,l.transform.tileZoom)/x,b=v*(h.tileID.canonical.x+h.tileID.wrap*x),w=v*h.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:p.tl,u_pattern_br_a:p.br,u_pattern_tl_b:f.tl,u_pattern_br_b:f.br,u_texsize:[m,_],u_mix:s.t,u_pattern_size_a:p.displaySize,u_pattern_size_b:f.displaySize,u_scale_a:s.fromScale,u_scale_b:s.toScale,u_tile_units_to_pixels:1/a.aC(h,1,l.transform.tileZoom),u_pixel_coord_upper:[b>>16,w>>16],u_pixel_coord_lower:[65535&b,65535&w]}}(l,p,s,h),{u_opacity:e}),zn=(e,s)=>{},kn={fillExtrusion:(e,s)=>({u_lightpos:new a.bU(e,s.u_lightpos),u_lightpos_globe:new a.bU(e,s.u_lightpos_globe),u_lightintensity:new a.bg(e,s.u_lightintensity),u_lightcolor:new a.bU(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.bV(e,s.u_fill_translate)}),fillExtrusionPattern:(e,s)=>({u_lightpos:new a.bU(e,s.u_lightpos),u_lightpos_globe:new a.bU(e,s.u_lightpos_globe),u_lightintensity:new a.bg(e,s.u_lightintensity),u_lightcolor:new a.bU(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.bV(e,s.u_fill_translate),u_image:new a.bQ(e,s.u_image),u_texsize:new a.bV(e,s.u_texsize),u_pixel_coord_upper:new a.bV(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bV(e,s.u_pixel_coord_lower),u_scale:new a.bU(e,s.u_scale),u_fade:new a.bg(e,s.u_fade)}),fill:(e,s)=>({u_fill_translate:new a.bV(e,s.u_fill_translate)}),fillPattern:(e,s)=>({u_image:new a.bQ(e,s.u_image),u_texsize:new a.bV(e,s.u_texsize),u_pixel_coord_upper:new a.bV(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bV(e,s.u_pixel_coord_lower),u_scale:new a.bU(e,s.u_scale),u_fade:new a.bg(e,s.u_fade),u_fill_translate:new a.bV(e,s.u_fill_translate)}),fillOutline:(e,s)=>({u_world:new a.bV(e,s.u_world),u_fill_translate:new a.bV(e,s.u_fill_translate)}),fillOutlinePattern:(e,s)=>({u_world:new a.bV(e,s.u_world),u_image:new a.bQ(e,s.u_image),u_texsize:new a.bV(e,s.u_texsize),u_pixel_coord_upper:new a.bV(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bV(e,s.u_pixel_coord_lower),u_scale:new a.bU(e,s.u_scale),u_fade:new a.bg(e,s.u_fade),u_fill_translate:new a.bV(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.bQ(e,s.u_scale_with_map),u_pitch_with_map:new a.bQ(e,s.u_pitch_with_map),u_extrude_scale:new a.bV(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.bV(e,s.u_translate)}),collisionBox:(e,s)=>({u_pixel_extrude_scale:new a.bV(e,s.u_pixel_extrude_scale)}),collisionCircle:(e,s)=>({u_viewport_size:new a.bV(e,s.u_viewport_size)}),debug:(e,s)=>({u_color:new a.bR(e,s.u_color),u_overlay:new a.bQ(e,s.u_overlay),u_overlay_scale:new a.bg(e,s.u_overlay_scale)}),depth:zn,clippingMask:zn,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.bS(e,s.u_matrix),u_world:new a.bV(e,s.u_world),u_image:new a.bQ(e,s.u_image),u_color_ramp:new a.bQ(e,s.u_color_ramp),u_opacity:new a.bg(e,s.u_opacity)}),hillshade:(e,s)=>({u_image:new a.bQ(e,s.u_image),u_latrange:new a.bV(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.bR(e,s.u_accent),u_method:new a.bQ(e,s.u_method),u_shadows:new a.b_(e,s.u_shadows),u_highlights:new a.b_(e,s.u_highlights)}),hillshadePrepare:(e,s)=>({u_matrix:new a.bS(e,s.u_matrix),u_image:new a.bQ(e,s.u_image),u_dimension:new a.bV(e,s.u_dimension),u_zoom:new a.bg(e,s.u_zoom),u_unpack:new a.bT(e,s.u_unpack)}),colorRelief:(e,s)=>({u_image:new a.bQ(e,s.u_image),u_unpack:new a.bT(e,s.u_unpack),u_dimension:new a.bV(e,s.u_dimension),u_elevation_stops:new a.bQ(e,s.u_elevation_stops),u_color_stops:new a.bQ(e,s.u_color_stops),u_color_ramp_size:new a.bQ(e,s.u_color_ramp_size),u_opacity:new a.bg(e,s.u_opacity)}),line:(e,s)=>({u_translation:new a.bV(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.bV(e,s.u_units_to_pixels)}),lineGradient:(e,s)=>({u_translation:new a.bV(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.bV(e,s.u_units_to_pixels),u_image:new a.bQ(e,s.u_image),u_image_height:new a.bg(e,s.u_image_height)}),linePattern:(e,s)=>({u_translation:new a.bV(e,s.u_translation),u_texsize:new a.bV(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.bQ(e,s.u_image),u_units_to_pixels:new a.bV(e,s.u_units_to_pixels),u_scale:new a.bU(e,s.u_scale),u_fade:new a.bg(e,s.u_fade)}),lineSDF:(e,s)=>({u_translation:new a.bV(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.bV(e,s.u_units_to_pixels),u_image:new a.bQ(e,s.u_image),u_mix:new a.bg(e,s.u_mix),u_tileratio:new a.bg(e,s.u_tileratio),u_crossfade_from:new a.bg(e,s.u_crossfade_from),u_crossfade_to:new a.bg(e,s.u_crossfade_to),u_lineatlas_width:new a.bg(e,s.u_lineatlas_width),u_lineatlas_height:new a.bg(e,s.u_lineatlas_height)}),lineGradientSDF:(e,s)=>({u_translation:new a.bV(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.bV(e,s.u_units_to_pixels),u_image:new a.bQ(e,s.u_image),u_image_height:new a.bg(e,s.u_image_height),u_tileratio:new a.bg(e,s.u_tileratio),u_crossfade_from:new a.bg(e,s.u_crossfade_from),u_crossfade_to:new a.bg(e,s.u_crossfade_to),u_image_dash:new a.bQ(e,s.u_image_dash),u_mix:new a.bg(e,s.u_mix),u_lineatlas_width:new a.bg(e,s.u_lineatlas_width),u_lineatlas_height:new a.bg(e,s.u_lineatlas_height)}),raster:(e,s)=>({u_tl_parent:new a.bV(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.bQ(e,s.u_image0),u_image1:new a.bQ(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.bU(e,s.u_spin_weights),u_coords_top:new a.bT(e,s.u_coords_top),u_coords_bottom:new a.bT(e,s.u_coords_bottom)}),symbolIcon:(e,s)=>({u_is_size_zoom_constant:new a.bQ(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bQ(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.bQ(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.bS(e,s.u_label_plane_matrix),u_coord_matrix:new a.bS(e,s.u_coord_matrix),u_is_text:new a.bQ(e,s.u_is_text),u_pitch_with_map:new a.bQ(e,s.u_pitch_with_map),u_is_along_line:new a.bQ(e,s.u_is_along_line),u_is_variable_anchor:new a.bQ(e,s.u_is_variable_anchor),u_texsize:new a.bV(e,s.u_texsize),u_texture:new a.bQ(e,s.u_texture),u_translation:new a.bV(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.bQ(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bQ(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.bQ(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.bS(e,s.u_label_plane_matrix),u_coord_matrix:new a.bS(e,s.u_coord_matrix),u_is_text:new a.bQ(e,s.u_is_text),u_pitch_with_map:new a.bQ(e,s.u_pitch_with_map),u_is_along_line:new a.bQ(e,s.u_is_along_line),u_is_variable_anchor:new a.bQ(e,s.u_is_variable_anchor),u_texsize:new a.bV(e,s.u_texsize),u_texture:new a.bQ(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.bQ(e,s.u_is_halo),u_translation:new a.bV(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.bQ(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bQ(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.bQ(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.bS(e,s.u_label_plane_matrix),u_coord_matrix:new a.bS(e,s.u_coord_matrix),u_is_text:new a.bQ(e,s.u_is_text),u_pitch_with_map:new a.bQ(e,s.u_pitch_with_map),u_is_along_line:new a.bQ(e,s.u_is_along_line),u_is_variable_anchor:new a.bQ(e,s.u_is_variable_anchor),u_texsize:new a.bV(e,s.u_texsize),u_texsize_icon:new a.bV(e,s.u_texsize_icon),u_texture:new a.bQ(e,s.u_texture),u_texture_icon:new a.bQ(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.bQ(e,s.u_is_halo),u_translation:new a.bV(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.bR(e,s.u_color)}),backgroundPattern:(e,s)=>({u_opacity:new a.bg(e,s.u_opacity),u_image:new a.bQ(e,s.u_image),u_pattern_tl_a:new a.bV(e,s.u_pattern_tl_a),u_pattern_br_a:new a.bV(e,s.u_pattern_br_a),u_pattern_tl_b:new a.bV(e,s.u_pattern_tl_b),u_pattern_br_b:new a.bV(e,s.u_pattern_br_b),u_texsize:new a.bV(e,s.u_texsize),u_mix:new a.bg(e,s.u_mix),u_pattern_size_a:new a.bV(e,s.u_pattern_size_a),u_pattern_size_b:new a.bV(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.bV(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bV(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.bQ(e,s.u_texture),u_ele_delta:new a.bg(e,s.u_ele_delta),u_fog_matrix:new a.bS(e,s.u_fog_matrix),u_fog_color:new a.bR(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.bR(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.bQ(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.bU(e,s.u_sun_pos),u_atmosphere_blend:new a.bg(e,s.u_atmosphere_blend),u_globe_position:new a.bU(e,s.u_globe_position),u_globe_radius:new a.bg(e,s.u_globe_radius),u_inv_proj_matrix:new a.bS(e,s.u_inv_proj_matrix)}),sky:(e,s)=>({u_sky_color:new a.bR(e,s.u_sky_color),u_horizon_color:new a.bR(e,s.u_horizon_color),u_horizon:new a.bV(e,s.u_horizon),u_horizon_normal:new a.bV(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 uo{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 Dn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class po{constructor(e,s,a,l){this.length=s.length,this.attributes=a,this.itemSize=s.bytesPerElement,this.dynamicDraw=l,this.context=e;const h=e.gl;this.buffer=h.createBuffer(),e.bindVertexBuffer.set(this.buffer),h.bufferData(h.ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?h.DYNAMIC_DRAW:h.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&&(v.push({circleArray:E,circleOffset:w,coord:T}),b+=E.length/4,w=b),M&&x.draw(f,_.LINES,Wt.disabled,Ht.disabled,e.colorModeForRenderPass(),$t.disabled,nn(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(T),m.getProjectionData({overscaledTileID:T,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),l.id,M.layoutVertexBuffer,M.indexBuffer,M.segments,null,e.transform.zoom,null,null,M.collisionVertexBuffer)}if(!p||!v.length)return;const T=e.useProgram("collisionCircle"),P=new a.c0;P.resize(4*b),P._trim();let M=0;for(const e of v)for(let s=0;s=0&&(E[z.associatedIconIndex]={shiftedAnchor:nt,angle:st})}else Ge(z.numGlyphs,P)}if(x){M.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");ye(x,e,p,Tt,Pt,k,v,a,_.toUnwrapped(),E.width,E.height,Mt,s)}const jt=p&&N||zt,Nt=L||jt?Bn:k?Tt:e.transform.clipSpaceToPixelsMatrix,Zt=P&&0!==l.paint.get(p?"text-halo-width":"icon-halo-width").constantOr(1);let qt;qt=P?x.iconsInText?Mn(V.kind,st,F,k,L,jt,e,Nt,St,Mt,lt,pt,G):In(V.kind,st,F,k,L,jt,e,Nt,St,Mt,p,lt,0,G):Sn(V.kind,st,F,k,L,jt,e,Nt,St,Mt,p,lt,G);const Xt={program:nt,buffers:b,uniformValues:qt,projectionData:Ct,atlasTexture:ht,atlasTextureIcon:_t,atlasInterpolation:ut,atlasInterpolationIcon:dt,isSDF:P,hasHalo:Zt};if(B&&x.canOverlap){j=!0;const e=b.segments.get();for(const s of e)U.push({segments:new a.aM([s]),sortKey:s.sortKey,state:Xt,terrainData:at})}else U.push({segments:b.segments,sortKey:0,state:Xt,terrainData:at})}j&&U.sort(((e,s)=>e.sortKey-s.sortKey));for(const s of U){const a=s.state;if(P.activeTexture.set(M.TEXTURE0),a.atlasTexture.bind(a.atlasInterpolation,M.CLAMP_TO_EDGE),a.atlasTextureIcon&&(P.activeTexture.set(M.TEXTURE1),a.atlasTextureIcon&&a.atlasTextureIcon.bind(a.atlasInterpolationIcon,M.CLAMP_TO_EDGE)),a.isSDF){const h=a.uniformValues;a.hasHalo&&(h.u_is_halo=1,$n(a.buffers,s.segments,l,e,a.program,V,b,w,h,a.projectionData,s.terrainData)),h.u_is_halo=0}$n(a.buffers,s.segments,l,e,a.program,V,b,w,a.uniformValues,a.projectionData,s.terrainData)}}function $n(e,s,a,l,h,p,f,m,_,x,v){const b=l.context;h.draw(b,b.gl.TRIANGLES,p,f,m,$t.backCCW,_,v,x,a.id,e.layoutVertexBuffer,e.indexBuffer,s,a.paint,l.transform.zoom,e.programConfigurations.get(a.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function Gn(e,s,l,h,p){const f=e.context,m=f.gl,_=Ht.disabled,x=new Gt([m.ONE,m.ONE],a.bf.transparent,[!0,!0,!0,!0]),v=s.getBucket(l);if(!v)return;const b=h.key;let w=l.heatmapFbos.get(b);w||(w=qn(f,s.tileSize,s.tileSize),l.heatmapFbos.set(b,w)),f.bindFramebuffer.set(w.framebuffer),f.viewport.set([0,0,s.tileSize,s.tileSize]),f.clear({color:a.bf.transparent});const T=v.programConfigurations.get(l.id),P=e.useProgram("heatmap",T,!p),M=e.transform.getProjectionData({overscaledTileID:s.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),E=e.style.map.terrain.getTerrainData(h);P.draw(f,m.TRIANGLES,Wt.disabled,_,x,$t.disabled,ln(s,e.transform.zoom,l.paint.get("heatmap-intensity"),1),E,M,l.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,l.paint,e.transform.zoom,T)}function Zn(e,s,a,l,h){const p=e.context,f=p.gl,m=e.transform;p.setColorMode(e.colorModeForRenderPass());const _=Wn(p,s),x=a.key,v=s.heatmapFbos.get(x);if(!v)return;p.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,v.colorAttachment.get()),p.activeTexture.set(f.TEXTURE1),_.bind(f.LINEAR,f.CLAMP_TO_EDGE);const b=m.getProjectionData({overscaledTileID:a,applyTerrainMatrix:h,applyGlobeMatrix:!l});e.useProgram("heatmapTexture").draw(p,f.TRIANGLES,Wt.disabled,Ht.disabled,e.colorModeForRenderPass(),$t.disabled,cn(e,s,0,1),null,b,s.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,s.paint,m.zoom),v.destroy(),s.heatmapFbos.delete(x)}function qn(e,s,a){var l,h;const p=e.gl,f=p.createTexture();p.bindTexture(p.TEXTURE_2D,f),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR);const m=null!==(l=e.HALF_FLOAT)&&void 0!==l?l:p.UNSIGNED_BYTE,_=null!==(h=e.RGBA16F)&&void 0!==h?h:p.RGBA;p.texImage2D(p.TEXTURE_2D,0,_,s,a,0,p.RGBA,m,null);const x=e.createFramebuffer(s,a,!1,!1);return x.colorAttachment.set(f),x}function Wn(e,s){return s.colorRampTexture||(s.colorRampTexture=new a.T(e,s.colorRamp,e.gl.RGBA)),s.colorRampTexture}function Hn(e,s,l,h,p,f,m,_){let x=256;if(p.stepInterpolant){const h=s.getSource().maxzoom,p=m.canonical.z===h?Math.ceil(1<20&&w.texParameterf(w.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);const st=e.style.map.terrain&&e.style.map.terrain.getTerrainData(j),at=P.getProjectionData({overscaledTileID:j,aligned:z,applyGlobeMatrix:!x,applyTerrainMatrix:!0}),lt=bn(Z,G,nt.fadeMix,a,m),ht=M.getMeshFromTileID(b,j.canonical,p,f,"raster");T.draw(b,w.TRIANGLES,l,h?h[j.overscaledZ]:Ht.disabled,E,_?$t.frontCCW:$t.backCCW,lt,st,at,a.id,ht.vertexBuffer,ht.indexBuffer,ht.segments)}}function cs(e,s,l,h){const p={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===l||h)return p;if(e.fadingParentID){const h=s._getLoadedTile(e.fadingParentID);if(!h)return p;const f=Math.pow(2,h.tileID.overscaledZ-e.tileID.overscaledZ),m=[e.tileID.canonical.x*f%1,e.tileID.canonical.y*f%1],_=function(e,s,l){const h=x(),p=(h-s.timeAdded)/l,f=e.fadingDirection===Ct.Incoming,m=a.ae((h-e.timeAdded)/l,0,1),_=a.ae(1-p,0,1),v=f?m:_;return{tileOpacity:v,parentTileOpacity:f?_:m,fadeMix:{opacity:1,mix:1-v}}}(e,h,l);return{parentTile:h,parentScaleBy:f,parentTopLeft:m,fadeValues:_}}if(e.selfFading){const s=function(e,s){const l=(x()-e.timeAdded)/s,h=a.ae(l,0,1);return{tileOpacity:h,fadeMix:{opacity:h,mix:0}}}(e,l);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:s}}return p}const hs=new a.bf(1,0,0,1),us=new a.bf(0,1,0,1),ps=new a.bf(0,0,1,1),fs=new a.bf(1,0,1,1),ms=new a.bf(0,1,1,1);function _s(e,s,a,l){ys(e,0,s+a/2,e.transform.width,a,l)}function gs(e,s,a,l){ys(e,s-a/2,0,a,e.transform.height,l)}function ys(e,s,a,l,h,p){const f=e.context,m=f.gl;m.enable(m.SCISSOR_TEST),m.scissor(s*e.pixelRatio,a*e.pixelRatio,l*e.pixelRatio,h*e.pixelRatio),f.clear({color:p}),m.disable(m.SCISSOR_TEST)}function xs(e,s,l){const h=e.context,p=h.gl,f=e.useProgram("debug"),m=Wt.disabled,_=Ht.disabled,x=e.colorModeForRenderPass(),v="$debug",b=e.style.map.terrain&&e.style.map.terrain.getTerrainData(l);h.activeTexture.set(p.TEXTURE0);const w=s.getTileByID(l.key).latestRawTileData,T=Math.floor((w&&w.byteLength||0)/1024),P=s.getTile(l).tileSize,M=512/Math.min(P,512)*(l.overscaledZ/e.transform.zoom)*.5;let E=l.canonical.toString();l.overscaledZ!==l.canonical.z&&(E+=` => ${l.overscaledZ}`),function(e,s){e.initDebugOverlayCanvas();const a=e.debugOverlayCanvas,l=e.context.gl,h=e.debugOverlayCanvas.getContext("2d");h.clearRect(0,0,a.width,a.height),h.shadowColor="white",h.shadowBlur=2,h.lineWidth=1.5,h.strokeStyle="white",h.textBaseline="top",h.font="bold 36px Open Sans, sans-serif",h.fillText(s,5,5),h.strokeText(s,5,5),e.debugOverlayTexture.update(a),e.debugOverlayTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE)}(e,`${E} ${T}kB`);const z=e.transform.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!0,applyTerrainMatrix:!0});f.draw(h,p.TRIANGLES,m,_,Gt.alphaBlended,$t.disabled,an(a.bf.transparent,M),null,z,v,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),f.draw(h,p.LINE_STRIP,m,_,x,$t.disabled,an(a.bf.red),b,z,v,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function vs(e,s,a,l){const{isRenderingGlobe:h}=l,p=e.context,f=p.gl,m=e.transform,_=e.colorModeForRenderPass(),x=e.getDepthModeFor3D(),v=e.useProgram("terrain");p.bindFramebuffer.set(null),p.viewport.set([0,0,e.width,e.height]);for(const l of a){const a=s.getTerrainMesh(l.tileID),b=e.renderToTexture.getTexture(l),w=s.getTerrainData(l.tileID);p.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,b.texture);const T=s.getMeshFrameDelta(m.zoom),P=m.calculateFogMatrix(l.tileID.toUnwrapped()),M=Or(T,P,e.style.sky,m.pitch,h),E=m.getProjectionData({overscaledTileID:l.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});v.draw(p,f.TRIANGLES,x,Ht.disabled,_,$t.backCCW,M,w,E,"terrain",a.vertexBuffer,a.indexBuffer,a.segments)}}function bs(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 h=new a.aN;h.emplaceBack(0,1,2),h.emplaceBack(0,2,3),s.mesh=new It(e.createVertexBuffer(l,Ei.members),e.createIndexBuffer(h),a.aM.simpleSegment(0,0,l.length,h.length))}return s.mesh}class Ba{constructor(e,s){this.context=new Jo(e),this.transform=s,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:a.ai(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Pe.maxUnderzooming+Pe.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new wt}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,Ei.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,Ei.members),this.debugSegments=a.aM.simpleSegment(0,0,4,5);const h=new a.c7;h.emplaceBack(0,0,0,0),h.emplaceBack(a.$,0,a.$,0),h.emplaceBack(0,a.$,0,a.$),h.emplaceBack(a.$,a.$,a.$,a.$),this.rasterBoundsBuffer=e.createVertexBuffer(h,Fr.members),this.rasterBoundsSegments=a.aM.simpleSegment(0,0,4,2);const p=new a.aL;p.emplaceBack(0,0),p.emplaceBack(a.$,0),p.emplaceBack(0,a.$),p.emplaceBack(a.$,a.$),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(p,Ei.members),this.rasterBoundsSegmentsPosOnly=a.aM.simpleSegment(0,0,4,5);const f=new a.aL;f.emplaceBack(0,0),f.emplaceBack(1,0),f.emplaceBack(0,1),f.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(f,Ei.members),this.viewportSegments=a.aM.simpleSegment(0,0,4,2);const m=new a.c8;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(m);const _=new a.aN;_.emplaceBack(1,0,2),_.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(_);const x=this.context.gl;this.stencilClearMode=new Ht({func:x.ALWAYS,mask:0},0,255,x.ZERO,x.ZERO,x.ZERO),this.tileExtentMesh=new It(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.bZ(l,0,this.width,this.height,0,0,1),a.N(l,l,[s.drawingBufferWidth,s.drawingBufferHeight,0]);const h={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,Wt.disabled,this.stencilClearMode,Gt.disabled,$t.disabled,null,null,h,"$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(Gt.disabled),l.setDepthMode(Wt.disabled);const h={};for(const e of s)h[e.key]=this.nextStencilID++;this._renderTileMasks(h,s,a,!0),this._renderTileMasks(h,s,a,!1),this._tileClippingMaskIDs=h}_renderTileMasks(e,s,a,l){const h=this.context,p=h.gl,f=this.style.projection,m=this.transform,_=this.useProgram("clippingMask");for(const x of s){const s=e[x.key],v=this.style.map.terrain&&this.style.map.terrain.getTerrainData(x),b=f.getMeshFromTileID(this.context,x.canonical,l,!0,"stencil"),w=m.getProjectionData({overscaledTileID:x,applyGlobeMatrix:!a,applyTerrainMatrix:!0});_.draw(h,p.TRIANGLES,Wt.disabled,new Ht({func:p.ALWAYS,mask:0},s,255,p.KEEP,p.KEEP,p.REPLACE),Gt.disabled,a?$t.disabled:$t.backCCW,null,v,w,"$clipping",b.vertexBuffer,b.indexBuffer,b.segments)}}_renderTilesDepthBuffer(){const e=this.context,s=e.gl,a=this.style.projection,l=this.transform,h=this.useProgram("depth"),p=this.getDepthModeFor3D(),f=ie(l,{tileSize:l.tileSize});for(const m of f){const f=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m),_=a.getMeshFromTileID(this.context,m.canonical,!0,!0,"raster"),x=l.getProjectionData({overscaledTileID:m,applyGlobeMatrix:!0,applyTerrainMatrix:!0});h.draw(e,s.TRIANGLES,p,Ht.disabled,Gt.disabled,$t.backCCW,null,f,x,"$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 Ht({func:s.NOTEQUAL,mask:255},e,255,s.KEEP,s.KEEP,s.REPLACE)}stencilModeForClipping(e){const s=this.context.gl;return new Ht({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,h=a[0].overscaledZ-l+1;if(h>1){this.currentStencilSource=void 0,this.nextStencilID+h>256&&this.clearStencil();const e={};for(let a=0;as.overscaledZ-e.overscaledZ)),l=a[a.length-1].overscaledZ,h=a[0].overscaledZ-l+1;if(this.clearStencil(),h>1){const e={},p={};for(let a=0;a0};for(const e in f){const s=f[e];s.used&&s.prepare(this.context),m[e]=s.getVisibleCoordinates(!1),_[e]=m[e].slice().reverse(),v[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,h=((e,s,a)=>{const l=Math.cos(s.rollInRadians),h=Math.sin(s.rollInRadians),p=Nt(s),f=s.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(s.width/2-p*h)*a,(s.height/2+p*l)*a],u_horizon_normal:[-h,l],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*s.height/2*a,u_sky_blend:f}})(s,e.style.map.transform,e.pixelRatio),p=new Wt(l.LEQUAL,Wt.ReadWrite,[0,1]),f=Ht.disabled,m=e.colorModeForRenderPass(),_=e.useProgram("sky"),x=bs(a,s);_.draw(a,l.TRIANGLES,p,f,m,$t.disabled,h,null,void 0,"sky",x.vertexBuffer,x.indexBuffer,x.segments)}(this,this.style.sky),this._showOverdrawInspector=s.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=p.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[p[this.currentLayer]],s=f[e.source],a=m[e.source];this._renderTileClippingMasks(e,a,!1),this.renderLayer(this,s,e,a,b)}this.renderPass="translucent";let w=!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:h}))(x,b,[P[0],P[1],P[2]],w,T),E=bs(h,s);f.draw(h,p.TRIANGLES,m,Ht.disabled,Gt.alphaBlended,$t.disabled,M,null,null,"atmosphere",E.vertexBuffer,E.indexBuffer,E.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]]:[])),h=l.filter((e=>"vector"===e.getSource().type)),p=l.filter((e=>"vector"!==e.getSource().type)),f=e=>{(!a||a.getSource().maxzoomf(e))),a||p.forEach((e=>f(e))),a}(this.style,this.transform.zoom);e&&function(e,s,a){for(let l=0;lb.getElevation(p,e,s):null;Vn(f,w,T,x,v,E,s,P,z,a.aD(v,e,m,_),p.toUnwrapped(),l)}}}(h,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"),p),0!==l.paint.get("icon-opacity").constantOr(1)&&Un(e,s,l,h,!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"),_,x,m),0!==l.paint.get("text-opacity").constantOr(1)&&Un(e,s,l,h,!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"),_,x,m),s.map.showCollisionBoxes&&(Fn(e,s,l,h,!0),Fn(e,s,l,h,!1))}(e,s,l,h,this.style.placement.variableOffsets,p):a.cd(l)?function(e,s,l,h,p){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:f}=p,m=l.paint.get("circle-opacity"),_=l.paint.get("circle-stroke-width"),x=l.paint.get("circle-stroke-opacity"),v=!l.layout.get("circle-sort-key").isConstant();if(0===m.constantOr(1)&&(0===_.constantOr(1)||0===x.constantOr(1)))return;const b=e.context,w=b.gl,T=e.transform,P=e.getDepthModeForSublayer(0,Wt.ReadOnly),M=Ht.disabled,E=e.colorModeForRenderPass(),z=[],k=T.getCircleRadiusCorrection();for(let p=0;pe.sortKey-s.sortKey));for(const s of z){const{programConfiguration:a,program:h,layoutVertexBuffer:p,indexBuffer:f,uniformValues:m,terrainData:_,projectionData:x}=s.state;h.draw(b,w.TRIANGLES,P,M,E,$t.backCCW,m,_,x,l.id,p,f,s.segments,l.paint,e.transform.zoom,a)}}(e,s,l,h,p):a.ce(l)?function(e,s,l,h,p){if(0===l.paint.get("heatmap-opacity"))return;const f=e.context,{isRenderingToTexture:m,isRenderingGlobe:_}=p;if(e.style.map.terrain){for(const a of h){const h=s.getTile(a);s.hasRenderableParent(a)||("offscreen"===e.renderPass?Gn(e,h,l,a,_):"translucent"===e.renderPass&&Zn(e,l,a,m,_))}f.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,s,l,h){const p=e.context,f=p.gl,m=e.transform,_=Ht.disabled,x=new Gt([f.ONE,f.ONE],a.bf.transparent,[!0,!0,!0,!0]);(function(e,s,l){const h=e.gl;e.activeTexture.set(h.TEXTURE1),e.viewport.set([0,0,s.width/4,s.height/4]);let p=l.heatmapFbos.get(a.c3);p?(h.bindTexture(h.TEXTURE_2D,p.colorAttachment.get()),e.bindFramebuffer.set(p.framebuffer)):(p=qn(e,s.width/4,s.height/4),l.heatmapFbos.set(a.c3,p))})(p,e,l),p.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 h=!!this.style.map.terrain,p=this.style.projection,f=a?Mi.projectionMercator:p.shaderPreludeCode,m=a?Ai:p.shaderDefine,_=e+(s?s.cacheKey:"")+`/${a?ki:p.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(h?"/terrain":"")+(l?`/${l.join("/")}`:"");return this.cache[_]||(this.cache[_]=new zi(this.context,Mi[e],s,kn[e],this._showOverdrawInspector,h,f,m,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 ws(s,a){let l,h=!1,p=null,f=null;const m=()=>{p=null,h&&(s.apply(f,l),p=setTimeout(m,a),h=!1)};return(...s)=>(h=!0,f=this||e,l=s,p||m(),p)}class ja{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 h=window.location.href.replace(/(#.+)?$/,l);h=h.replace("&&","&"),window.history.replaceState(window.history.state,null,h)},this._updateHash=ws(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),h=Math.pow(10,l),p=Math.round(s.lng*h)/h,f=Math.round(s.lat*h)/h,m=this._map.getBearing(),_=this._map.getPitch();let x="";if(x+=e?`/${p}/${f}/${a}`:`${a}/${f}/${p}`,(m||_)&&(x+="/"+Math.round(10*m)/10),_&&(x+=`/${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}=${x}`):a})).filter((e=>e));return s||a.push(`${e}=${x}`),`#${a.join("&")}`}return`#${x}`}_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),h=+(e[4]||0);return s>=this._map.getMinZoom()&&s<=this._map.getMaxZoom()&&l>=-180&&l<=180&&h>=this._map.getMinPitch()&&h<=this._map.getMaxPitch()}}const Ss={linearity:.3,easing:a.cm(0,0,.3,1)},Is=a.e({deceleration:2500,maxSpeed:1400},Ss),Ms=a.e({deceleration:20,maxSpeed:1400},Ss),Cs=a.e({deceleration:1e3,maxSpeed:360},Ss),As=a.e({deceleration:1e3,maxSpeed:90},Ss),zs=a.e({deceleration:1e3,maxSpeed:360},Ss);class Wa{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:x(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,s=x();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,h={};if(s.pan.mag()){const p=Gs(s.pan.mag(),l,a.e({},Is,e||{})),f=s.pan.mult(p.amount/s.pan.mag()),m=this._map.cameraHelper.handlePanInertia(f,this._map.transform);h.center=m.easingCenter,h.offset=m.easingOffset,ks(h,p)}if(s.zoom){const e=Gs(s.zoom,l,Ms);h.zoom=this._map.transform.zoom+e.amount,ks(h,e)}if(s.bearing){const e=Gs(s.bearing,l,Cs);h.bearing=this._map.transform.bearing+a.ae(e.amount,-179,179),ks(h,e)}if(s.pitch){const e=Gs(s.pitch,l,As);h.pitch=this._map.transform.pitch+e.amount,ks(h,e)}if(s.roll){const e=Gs(s.roll,l,zs);h.roll=this._map.transform.roll+a.ae(e.amount,-179,179),ks(h,e)}if(h.zoom||h.bearing){const e=void 0===s.pinchAround?s.around:s.pinchAround;h.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),a.e(h,{noMoveStart:!0})}}function ks(e,s){(!e.duration||e.durations.unproject(e))),m=p.reduce(((e,s,a,l)=>e.add(s.div(l.length))),new a.P(0,0));super(e,{points:p,point:m,lngLats:f,lngLat:s.unproject(m),originalEvent:l}),this._defaultPrevented=!1}}class Qa extends a.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,s,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class Ya{constructor(e,s){this._map=e,this._clickTolerance=s.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Qa(e.type,this._map,e))}mousedown(e,s){return this._mousedownPos=s,this._firePreventable(new Xa(e.type,this._map,e))}mouseup(e){this._map.fire(new Xa(e.type,this._map,e))}click(e,s){this._mousedownPos&&this._mousedownPos.dist(s)>=this._clickTolerance||this._map.fire(new Xa(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Xa(e.type,this._map,e))}mouseover(e){this._map.fire(new Xa(e.type,this._map,e))}mouseout(e){this._map.fire(new Xa(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Ka(e.type,this._map,e))}touchmove(e){this._map.fire(new Ka(e.type,this._map,e))}touchend(e){this._map.fire(new Ka(e.type,this._map,e))}touchcancel(e){this._map.fire(new Ka(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ja{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Xa(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Xa("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Xa(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class er{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 tr{constructor(e,s){this._map=e,this._tr=new er(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&&(c.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,h,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&&(c.remove(this._box),this._box=null),c.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,s){return this._map.fire(new a.l(e,{originalEvent:s}))}}function Zs(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=Zs(l,s)))}touchmove(e,s,a){if(this.aborted||!this.centroid)return;const l=Zs(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 ar{constructor(e){this.singleTap=new or(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 rr{constructor(e){this._tr=new er(e),this._zoomIn=new ar({numTouches:1,numTaps:2}),this._zoomOut=new ar({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),h=this._zoomOut.touchend(e,s,a),p=this._tr;return l?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:p.zoom+1,around:p.unproject(l)},{originalEvent:e})}):h?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:p.zoom-1,around:p.unproject(h)},{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 sr{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 ur){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 eo=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class pr{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 h=Zs(l,s),p=new a.P(0,0),f=new a.P(0,0);let m=0;for(const e in h){const s=h[e],a=this._touches[e];a&&(p._add(s),f._add(s.sub(a)),m++,h[e]=s)}if(this._touches=h,this._shouldBePrevented(m)||!f.mag())return;const _=f.div(m);return this._sum._add(_),this._sum.mag()Math.abs(e.x)}class wr extends mr{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,so(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]),h=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(l,h,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(l.y+h.y)/2*-.5}):void 0}gestureBeginsVertically(e,s,a){if(void 0!==this._valid)return this._valid;const l=e.mag()>=2,h=s.mag()>=2;if(!l&&!h)return;if(!l||!h)return void 0===this._firstMove&&(this._firstMove=a),a-this._firstMove<100&&void 0;const p=e.y>0==s.y>0;return so(e)&&so(s)&&p}}const oo={panStep:100,bearingStep:15,pitchStep:10};class Pr{constructor(e){this._tr=new er(e);const s=oo;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,h=0,p=0;switch(e.keyCode){case 61:case 107:case 171:case 187:s=1;break;case 189:case 109:case 173:s=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),h=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),h=1);break;case 38:e.shiftKey?l=1:(e.preventDefault(),p=-1);break;case 40:e.shiftKey?l=-1:(e.preventDefault(),p=1);break;default:return}return this._rotationDisabled&&(a=0,l=0),{cameraAnimation:f=>{const m=this._tr;f.easeTo({duration:300,easeId:"keyboardHandler",easing:ao,zoom:s?Math.round(m.zoom)+s*(e.shiftKey?2:1):m.zoom,bearing:m.bearing+a*this._bearingStep,pitch:m.pitch+l*this._pitchStep,offset:[-h*this._panStep,-p*this._panStep],center:m.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function ao(e){return e*(2-e)}const lo=4.000244140625,co=1/450;class Sr{constructor(e,s){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new er(e),this._triggerRenderFrame=s,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=co}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let s=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const a=x(),l=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,0!==s&&s%lo==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=c.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)>lo?this._wheelZoomRate:this._defaultZoomRate;let l=2/(1+Math.exp(-Math.abs(this._delta*s)));this._delta<0&&0!==l&&(l=1/l);const h="number"!=typeof this._targetZoom?e.scale:a.ah(this._targetZoom);this._targetZoom=e.constrain(e.getCameraLngLat(),a.ak(h*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,h=this._easing;let p,f=!1;if("wheel"===this._type&&l&&h){const e=x()-this._lastWheelEventTime,m=Math.min((e+5)/200,1),_=h(m);p=a.C.number(l,s,_),m<1?this._frameId||(this._frameId=!0):f=!0}else p=s,f=!0;return this._active=!0,f&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=p,{noInertia:!0,needsRenderFrame:!f,zoomDelta:p-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let s=a.co;if(this._prevEase){const e=this._prevEase,l=(x()-e.start)/e.duration,h=e.easing(l+.01)-e.easing(l),p=.27/Math.sqrt(h*h+1e-4)*.01,f=Math.sqrt(.0729-p*p);s=a.cm(p,f,.25,1)}return this._prevEase={start:x(),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 Er{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 Rr{constructor(e){this._tr=new er(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 Dr{constructor(){this._tap=new ar({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],h=e.timeStamp-this._tapTime<500,p=this._tapPoint.dist(l)<30;h&&p?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],h=l.y-this._swipePoint.y;return this._swipePoint=l,e.preventDefault(),this._active=!0,{zoomDelta:h/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 zr{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 Ar{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 Lr{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 kr{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=c.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 h=document.createElement("div");h.className="maplibregl-mobile-message",h.textContent=a,this._container.appendChild(h),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(c.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 ho=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Br extends a.l{}function _o(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class jr{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,h={needsRenderFrame:!1},p={},f={};for(const{handlerName:m,handler:_,allowed:x}of this._handlers){if(!_.isEnabled())continue;let v;if(this._blockedByActive(f,x,m))_.reset();else if(_[s||e.type]){if(a.cp(e,s||e.type)){const a=c.mousePos(this._map.getCanvas(),e);v=_[s||e.type](e,a)}else if(a.cq(e,s||e.type)){const a=this._getMapTouches(e.touches),l=c.touchPos(this._map.getCanvas(),a);v=_[s||e.type](e,l,a)}else a.cr(s||e.type)||(v=_[s||e.type](e));this.mergeHandlerResult(h,p,v,m,l),v&&v.needsRenderFrame&&this._triggerRenderFrame()}(v||_.isActive())&&(f[m]=_)}const m={};for(const e in this._previousActiveHandlers)f[e]||(m[e]=l);this._previousActiveHandlers=f,(Object.keys(m).length||_o(h))&&(this._changes.push([h,p,m]),this._triggerRenderFrame()),(Object.keys(f).length||_o(h))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:_}=h;_&&(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 Wa(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)c.addEventListener(e,s,e===document?this.handleWindowEvent:this.handleEvent,a)}destroy(){for(const[e,s,a]of this._listeners)c.removeEventListener(e,s,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){const s=this._map,l=s.getCanvasContainer();this._add("mapEvent",new Ya(s,e));const h=s.boxZoom=new tr(s,e);this._add("boxZoom",h),e.interactive&&e.boxZoom&&h.enable();const p=s.cooperativeGestures=new kr(s,e.cooperativeGestures);this._add("cooperativeGestures",p),e.cooperativeGestures&&p.enable();const f=new rr(s),m=new Rr(s);s.doubleClickZoom=new Er(m,f),this._add("tapZoom",f),this._add("clickZoom",m),e.interactive&&e.doubleClickZoom&&s.doubleClickZoom.enable();const _=new Dr;this._add("tapDragZoom",_);const x=s.touchPitch=new wr(s);this._add("touchPitch",x),e.interactive&&e.touchPitch&&s.touchPitch.enable(e.touchPitch);const v=()=>s.project(s.getCenter()),b=function({enable:e,clickTolerance:s,aroundCenter:l=!0,minPixelCenterThreshold:h=100,rotateDegreesPerPixelMoved:p=.8},f){const m=new hr({checkCorrectEvent:e=>0===c.mouseButton(e)&&e.ctrlKey||2===c.mouseButton(e)&&!e.ctrlKey});return new sr({clickTolerance:s,move:(e,s)=>{const m=f();if(l&&Math.abs(m.y-e.y)>h)return{bearingDelta:a.cn(new a.P(e.x,s.y),s,m)};let _=(s.x-e.x)*p;return l&&s.y0===c.mouseButton(e)&&e.ctrlKey||2===c.mouseButton(e)});return new sr({clickTolerance:s,move:(e,s)=>({pitchDelta:(s.y-e.y)*a}),moveStateManager:l,enable:e,assignEvents:eo})}(e),T=function({enable:e,clickTolerance:s,rollDegreesPerPixelMoved:a=.3},l){const h=new hr({checkCorrectEvent:e=>2===c.mouseButton(e)&&e.ctrlKey});return new sr({clickTolerance:s,move:(e,s)=>{const h=l();let p=(s.x-e.x)*a;return s.y0===c.mouseButton(e)&&!e.ctrlKey});return new sr({clickTolerance:s,move:(e,s)=>({around:s,panDelta:s.sub(e)}),activateOnStart:!0,moveStateManager:a,enable:e,assignEvents:eo})}(e),M=new pr(e,s);s.dragPan=new zr(l,P,M),this._add("mousePan",P),this._add("touchPan",M,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&s.dragPan.enable(e.dragPan);const E=new br,z=new vr;s.touchZoomRotate=new Lr(l,z,E,_),this._add("touchRotate",E,["touchPan","touchZoom"]),this._add("touchZoom",z,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&s.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new Ja(s));const k=s.scrollZoom=new Sr(s,(()=>this._triggerRenderFrame()));this._add("scrollZoom",k,["mousePan"]),e.interactive&&e.scrollZoom&&s.scrollZoom.enable(e.scrollZoom);const L=s.keyboard=new Pr(s);this._add("keyboard",L),e.interactive&&e.keyboard&&s.keyboard.enable()}_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(ho(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,h,p){if(!l)return;a.e(e,l);const f={handlerName:h,originalEvent:l.originalEvent||p};void 0!==l.zoomDelta&&(s.zoom=f),void 0!==l.panDelta&&(s.drag=f),void 0!==l.rollDelta&&(s.roll=f),void 0!==l.pitchDelta&&(s.pitch=f),void 0!==l.bearingDelta&&(s.rotate=f)}_applyChanges(){const e={},s={},l={};for(const[h,p,f]of this._changes)h.panDelta&&(e.panDelta=(e.panDelta||new a.P(0,0))._add(h.panDelta)),h.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+h.zoomDelta),h.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+h.bearingDelta),h.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+h.pitchDelta),h.rollDelta&&(e.rollDelta=(e.rollDelta||0)+h.rollDelta),void 0!==h.around&&(e.around=h.around),void 0!==h.pinchAround&&(e.pinchAround=h.pinchAround),h.noInertia&&(e.noInertia=h.noInertia),a.e(s,p),a.e(l,f);this._updateMapTransform(e,s,l),this._changes=[]}_updateMapTransform(e,s,a){const l=this._map,h=l._getTransformForUpdate(),p=l.terrain;if(!(_o(e)||p&&this._terrainMovement))return this._fireEvents(s,a,!0);l._stop(!0);let{panDelta:f,zoomDelta:m,bearingDelta:_,pitchDelta:x,rollDelta:v,around:b,pinchAround:w}=e;void 0!==w&&(b=w),b=b||l.transform.centerPoint,p&&!h.isPointOnMapSurface(b)&&(b=h.centerPoint);const T={panDelta:f,zoomDelta:m,rollDelta:v,pitchDelta:x,bearingDelta:_,around:b};this._map.cameraHelper.useGlobeControls&&!h.isPointOnMapSurface(b)&&(b=h.centerPoint);const P=b.distSqr(h.centerPoint)<.01?h.center:h.screenPointToLocation(f?b.sub(f):b);this._handleMapControls({terrain:p,tr:h,deltasForHelper:T,preZoomAroundLoc:P,combinedEventsInProgress:s,panDelta:f}),l._applyUpdatedTransform(h),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(s,a,!0)}_handleMapControls({terrain:e,tr:s,deltasForHelper:a,preZoomAroundLoc:l,combinedEventsInProgress:h,panDelta:p}){const f=this._map.cameraHelper;if(f.handleMapControlsRollPitchBearingZoom(a,s),e)return f.useGlobeControls?(this._terrainMovement||!h.drag&&!h.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void f.handleMapControlsPan(a,s,l)):this._terrainMovement||!h.drag&&!h.zoom?void(h.drag&&this._terrainMovement&&p?s.setCenter(s.screenPointToLocation(s.centerPoint.sub(p))):f.handleMapControlsPan(a,s,l)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void f.handleMapControlsPan(a,s,l));f.handleMapControlsPan(a,s,l)}_fireEvents(e,s,l){const h=ho(this._eventsInProgress),p=ho(e),f={};for(const s in e){const{originalEvent:a}=e[s];this._eventsInProgress[s]||(f[`${s}start`]=a),this._eventsInProgress[s]=e[s]}!h&&p&&this._fireEvent("movestart",p.originalEvent);for(const e in f)this._fireEvent(e,f[e]);p&&this._fireEvent("move",p.originalEvent);for(const s in e){const{originalEvent:a}=e[s];this._fireEvent(s,a)}const _={};let x;for(const e in this._eventsInProgress){const{handlerName:a,originalEvent:l}=this._eventsInProgress[e];this._handlersById[a].isActive()||(delete this._eventsInProgress[e],x=s[a]||l,_[`${e}end`]=x)}for(const e in _)this._fireEvent(e,_[e]);const v=ho(this._eventsInProgress),b=(h||p)&&!v;if(b&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(l&&b){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),s=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Br("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Nr extends a.E{constructor(e,s,a){super(),this._renderFrameCallback=()=>{const e=Math.min((x()-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()){E.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){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const s=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&s!==this._elevationTarget){const 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:h,roll:p,pitch:f,bearing:m,elevation:_}=e(s);l&&s.setCenter(l),void 0!==_&&s.setElevation(_),void 0!==h&&s.setZoom(h),void 0!==p&&s.setRoll(p),void 0!==f&&s.setPitch(f),void 0!==m&&s.setBearing(m),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,h=this._rotating,p=this._pitching,f=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,l&&this.fire(new a.l("zoomend",e)),h&&this.fire(new a.l("rotateend",e)),p&&this.fire(new a.l("pitchend",e)),f&&this.fire(new a.l("rollend",e)),this.fire(new a.l("moveend",e))}flyTo(e,s){if(!e.essential&&m.prefersReducedMotion){const l=a.Q(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);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(),h=l.bearing,p=l.pitch,f=l.roll,_=l.padding,x="bearing"in e?this._normalizeBearing(e.bearing,h):h,v="pitch"in e?+e.pitch:p,b="roll"in e?this._normalizeBearing(e.roll,f):f,w="padding"in e?e.padding:l.padding,T=a.P.convert(e.offset);let P=l.centerPoint.add(T);const M=l.screenPointToLocation(P),E=this.cameraHelper.handleFlyTo(l,{bearing:x,pitch:v,roll:b,padding:w,locationAtOffset:M,offsetAsPoint:T,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let z=e.curve;const k=Math.max(l.width,l.height),L=k/E.scaleOfZoom,F=E.pixelPathLength;"number"==typeof E.scaleOfMinZoom&&(z=Math.sqrt(k/E.scaleOfMinZoom/F*2));const B=z*z;function j(e){const s=(L*L-k*k+(e?-1:1)*B*B*F*F)/(2*(e?L:k)*B*F);return Math.log(Math.sqrt(s*s+1)-s)}function V(e){return(Math.exp(e)-Math.exp(-e))/2}function N(e){return(Math.exp(e)+Math.exp(-e))/2}const U=j(!1);let G=function(e){return N(U)/N(U+z*e)},Z=function(e){return k*((N(U)*(V(s=U+z*e)/N(s))-V(U))/B)/F;var s},nt=(j(!0)-U)/z;if(Math.abs(F)<2e-6||!isFinite(nt)){if(Math.abs(k-L)<1e-6)return this.easeTo(e,s);const a=L0,G=e=>Math.exp(a*z*e)}return e.duration="duration"in e?+e.duration:1e3*nt/("screenSpeed"in e?+e.screenSpeed/z:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=h!==x,this._pitching=v!==p,this._rolling=b!==f,this._padding=!l.isPaddingEqual(w),this._prepareEase(s,!1),this.terrain&&this._prepareElevation(E.targetCenter),this._ease((m=>{const M=m*nt,z=1/G(M),k=Z(M);this._rotating&&l.setBearing(a.C.number(h,x,m)),this._pitching&&l.setPitch(a.C.number(p,v,m)),this._rolling&&l.setRoll(a.C.number(f,b,m)),this._padding&&(l.interpolatePadding(_,w,m),P=l.centerPoint.add(T)),E.easeFunc(m,z,k,P),this.terrain&&!e.freezeElevation&&this._updateElevation(m),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=x(),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 Ur{constructor(e=Qo){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=c.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=c.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=c.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(){c.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=c.sanitize(a),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Gr{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=c.create("div","maplibregl-ctrl");const s=c.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(){c.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Vr{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 ta=a.aJ([{name:"a_pos3d",type:"Int16",components:3}]);class Wr extends a.E{constructor(e){super(),this._lastTilesetChange=x(),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 h of ie(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:s,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))l[h.key]=!0,this._renderableTilesKeys.push(h.key),this._tiles[h.key]||(h.terrainRttPosMatrix32f=new Float64Array(16),a.bZ(h.terrainRttPosMatrix32f,0,a.$,a.$,0,0,1),this._tiles[h.key]=new le(h,this.tileSize),this._lastTilesetChange=x());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 h=this._tiles[l].tileID,p=e.clone(),f=a.ba();if(h.canonical.equals(e.canonical))a.bZ(f,0,a.$,a.$,0,0,1);else if(h.canonical.isChildOf(e.canonical)){const s=h.canonical.z-e.canonical.z,l=h.canonical.x-(h.canonical.x>>s<>s<>s;a.bZ(f,0,m,m,0,0,1),a.M(f,f,[-l*m,-p*m,0])}else{if(!e.canonical.isChildOf(h.canonical))continue;{const s=e.canonical.z-h.canonical.z,l=e.canonical.x-(e.canonical.x>>s<>s<>s;a.bZ(f,0,a.$,a.$,0,0,1),a.M(f,f,[l*m,p*m,0]),a.N(f,f,[1/2**s,1/2**s,0])}}p.terrainRttPosMatrix32f=new Float32Array(f),s[l]=p}return s}_getTerrainCoordsForTileRanges(e,s){const l={};for(const h of this._renderableTilesKeys){const p=this._tiles[h].tileID;if(!this._isWithinTileRanges(p,s))continue;const f=e.clone(),m=a.ba();if(p.canonical.z===e.canonical.z){const s=e.canonical.x-p.canonical.x,l=e.canonical.y-p.canonical.y;a.bZ(m,0,a.$,a.$,0,0,1),a.M(m,m,[s*a.$,l*a.$,0])}else if(p.canonical.z>e.canonical.z){const s=p.canonical.z-e.canonical.z,l=p.canonical.x-(p.canonical.x>>s<>s<>s),_=e.canonical.y-(p.canonical.y>>s),x=a.$>>s;a.bZ(m,0,x,x,0,0,1),a.M(m,m,[-l*x+f*a.$,-h*x+_*a.$,0])}else{const s=e.canonical.z-p.canonical.z,l=e.canonical.x-(e.canonical.x>>s<>s<>s)-p.canonical.x,_=(e.canonical.y>>s)-p.canonical.y,x=a.$<a.maxzoom&&(l=a.maxzoom),l=a.minzoom&&(!h||!h.dem);)h=this.sourceCache.getTileByID(e.scaledTo(l--).key);return h}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 qr{constructor(e,s,a){this._meshCache={},this.painter=e,this.sourceCache=new Wr(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,h=a.$){var p;if(!(s>=0&&s=0&&le.canonical.z&&(e.canonical.z>=l?h=e.canonical.z-l:a.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const p=e.canonical.x-(e.canonical.x>>h<>h<>8<<4|e>>8,s[a+3]=0;const l=new a.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(s.buffer)),h=new a.T(e,l,e.gl.RGBA,{premultiply:!1});return h.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=h,h}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const s=new Uint8Array(4),l=this.painter.context,h=l.gl,p=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),f=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),m=Math.round(this.painter.height/devicePixelRatio);l.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),h.readPixels(p,m-f-1,1,1,h.RGBA,h.UNSIGNED_BYTE,s),l.bindFramebuffer.set(null);const _=s[0]+(s[2]>>4<<8),x=s[1]+((15&s[2])<<8),v=this.coordsIndex[255-s[3]],b=v&&this.sourceCache.getTileByID(v);if(!b)return null;const w=this._coordsTextureSize,T=(1<0,h=l&&0===e.canonical.y,p=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 tl={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class Kr{constructor(e,s){this.painter=e,this.terrain=s,this.pool=new Hr(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(),h=l instanceof Q?l.terrainTileRanges:null;for(const e of a){const a=this.terrain.sourceCache.getTerrainCoords(e,h);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(tl[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}),h=e.type,p=this.painter,f=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(tl[h]&&(this._prevType&&tl[this._prevType]||this._stacks.push([]),this._prevType=h,this._stacks[this._stacks.length-1].push(e.id),!f))return!0;if(tl[this._prevType]||tl[h]&&f){this._prevType=h;const e=this._stacks.length-1,s=this._stacks[e]||[];for(const h of this._renderableTiles){if(this.pool.isFull()&&(vs(this.painter,this.terrain,this._rttTiles,l),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(h),h.rtt[e]){const s=this.pool.getObjectForId(h.rtt[e].id);if(s.stamp===h.rtt[e].stamp){this.pool.useObject(s);continue}}const f=this.pool.getOrCreateFreeObject();this.pool.useObject(f),this.pool.stampObject(f),h.rtt[e]={id:f.id,stamp:f.stamp},p.context.bindFramebuffer.set(f.fbo.framebuffer),p.context.clear({color:a.bf.transparent,stencil:0}),p.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,c.mousePos(this.element,e)),c.addEventListener(window,"mousemove",this.mousemove),c.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,c.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=c.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),c.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),c.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=c.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 h=new dr;this._rotatePitchHandler=new sr({clickTolerance:3,move:(e,h)=>{const p=s.getBoundingClientRect(),f=new a.P((p.bottom-p.top)/2,(p.right-p.left)/2);return{bearingDelta:a.cn(new a.P(e.x,h.y),h,f),pitchDelta:l?-.5*(h.y-e.y):void 0}},moveStateManager:h,enable:!0,assignEvents:()=>{}}),this.map=e,c.addEventListener(s,"mousedown",this.mousedown),c.addEventListener(s,"touchstart",this.touchstart,{passive:!1}),c.addEventListener(s,"touchcancel",this.reset)}startMove(e,s){this._rotatePitchHandler.dragStart(e,s),c.disableDrag()}move(e,s){const a=this.map,{bearingDelta:l,pitchDelta:h}=this._rotatePitchHandler.dragMove(e,s)||{};l&&a.setBearing(a.getBearing()+l),h&&a.setPitch(a.getPitch()+h)}off(){const e=this.element;c.removeEventListener(e,"mousedown",this.mousedown),c.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),c.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),c.removeEventListener(window,"touchend",this.touchend),c.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){c.enableDrag(),c.removeEventListener(window,"mousemove",this.mousemove),c.removeEventListener(window,"mouseup",this.mouseup),c.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),c.removeEventListener(window,"touchend",this.touchend)}}let sl;function ol(e,s,l,h=!1){if(h||!l.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const p=new a.S(e.lng,e.lat);if(e=new a.S(e.lng,e.lat),s){const h=new a.S(e.lng-360,e.lat),p=new a.S(e.lng+360,e.lat),f=l.locationToScreenPoint(e).distSqr(s);l.locationToScreenPoint(h).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!==p.lng&&l.isPointOnMapSurface(l.locationToScreenPoint(e))?e:p}const al={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 ll(e,s,a){const l=e.classList;for(const e in al)l.remove(`maplibregl-${a}-anchor-${e}`);l.add(`maplibregl-${a}-anchor-${s}`)}class ss 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=ol(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()),c.setTransform(this._element,`${al[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${l} ${a}`),m.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=c.create("div");const s=c.createNS("http://www.w3.org/2000/svg","svg"),l=41,h=27;s.setAttributeNS(null,"display","block"),s.setAttributeNS(null,"height",`${l}px`),s.setAttributeNS(null,"width",`${h}px`),s.setAttributeNS(null,"viewBox",`0 0 ${h} ${l}`);const p=c.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"stroke","none"),p.setAttributeNS(null,"stroke-width","1"),p.setAttributeNS(null,"fill","none"),p.setAttributeNS(null,"fill-rule","evenodd");const f=c.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"fill-rule","nonzero");const m=c.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(3.0, 29.0)"),m.setAttributeNS(null,"fill","#000000");const _=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of _){const s=c.createNS("http://www.w3.org/2000/svg","ellipse");s.setAttributeNS(null,"opacity","0.04"),s.setAttributeNS(null,"cx","10.5"),s.setAttributeNS(null,"cy","5.80029008"),s.setAttributeNS(null,"rx",e.rx),s.setAttributeNS(null,"ry",e.ry),m.appendChild(s)}const x=c.createNS("http://www.w3.org/2000/svg","g");x.setAttributeNS(null,"fill",this._color);const v=c.createNS("http://www.w3.org/2000/svg","path");v.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"),x.appendChild(v);const b=c.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"opacity","0.25"),b.setAttributeNS(null,"fill","#000000");const w=c.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"),b.appendChild(w);const T=c.createNS("http://www.w3.org/2000/svg","g");T.setAttributeNS(null,"transform","translate(6.0, 7.0)"),T.setAttributeNS(null,"fill","#FFFFFF");const P=c.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"transform","translate(8.0, 8.0)");const M=c.createNS("http://www.w3.org/2000/svg","circle");M.setAttributeNS(null,"fill","#000000"),M.setAttributeNS(null,"opacity","0.25"),M.setAttributeNS(null,"cx","5.5"),M.setAttributeNS(null,"cy","5.5"),M.setAttributeNS(null,"r","5.4999962");const E=c.createNS("http://www.w3.org/2000/svg","circle");E.setAttributeNS(null,"fill","#FFFFFF"),E.setAttributeNS(null,"cx","5.5"),E.setAttributeNS(null,"cy","5.5"),E.setAttributeNS(null,"r","5.4999962"),P.appendChild(M),P.appendChild(E),f.appendChild(m),f.appendChild(x),f.appendChild(b),f.appendChild(T),f.appendChild(P),s.appendChild(f),s.setAttributeNS(null,"height",l*this._scale+"px"),s.setAttributeNS(null,"width",h*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()})),ll(this._element,this._anchor,"marker"),e&&e.className)for(const s of e.className.split(" "))this._element.classList.add(s);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),c.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 h=null===(s=this._map)||void 0===s?void 0:s.terrain,p=this._map.transform.isLocationOccluded(this._lngLat);if(!h||p){const e=p?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const f=this._map,m=f.terrain.depthAtPoint(this._pos),_=f.terrain.getElevationForLngLatZoom(this._lngLat,f.transform.tileZoom);if(f.transform.lngLatToCameraDepth(this._lngLat,_)-m<.006)return void(this._element.style.opacity=this._opacity);const x=-this._offset.y/f.transform.pixelsPerMeter,v=Math.sin(f.getPitch()*Math.PI/180)*x,b=f.terrain.depthAtPoint(new a.P(this._pos.x,this._pos.y-this._offset.y)),w=f.transform.lngLatToCameraDepth(this._lngLat,_+v)-b>.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,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 ul={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let dl=0,pl=!1;const fl={maxWidth:100,unit:"metric"};function ml(e,s,a){const l=a&&a.maxWidth||100,h=e._container.clientHeight/2,p=e._container.clientWidth/2,f=e.unproject([p-l/2,h]),m=e.unproject([p+l/2,h]),_=Math.round(e.project(m).x-e.project(f).x),x=Math.min(l,_,e._container.clientWidth),v=f.distanceTo(m);if(a&&"imperial"===a.unit){const a=3.2808*v;a>5280?_l(s,x,a/5280,e._getUIString("ScaleControl.Miles")):_l(s,x,a,e._getUIString("ScaleControl.Feet"))}else a&&"nautical"===a.unit?_l(s,x,v/1852,e._getUIString("ScaleControl.NauticalMiles")):v>=1e3?_l(s,x,v/1e3,e._getUIString("ScaleControl.Kilometers")):_l(s,x,v,e._getUIString("ScaleControl.Meters"))}function _l(e,s,a,l){const h=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*(h/a)+"px",e.innerHTML=`${h} ${l}`}const yl={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},vl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function bl(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 bl(new a.P(0,0))}const Tl=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=Ur,s.BoxZoomHandler=tr,s.CanvasSource=J,s.CooperativeGesturesHandler=kr,s.DoubleClickZoomHandler=Er,s.DragPanHandler=zr,s.DragRotateHandler=Ar,s.EdgeInsets=Dt,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=c.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){c.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=c.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);c.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=K,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,h=this._map.getBearing(),p=a.e({bearing:h},this.options.fitBoundsOptions),f=$.fromLngLat(s,l);this._map.fitBounds(f,p,{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._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&pl)return;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=c.create("button","maplibregl-ctrl-geolocate",this._container),c.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=c.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new ss({element:this._dotElement}),this._circleElement=c.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ss({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{const s=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||s||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new a.l("trackuserlocationend")),this.fire(new a.l("userlocationlostfocus")))}))}},this.options=a.e({},ul,e)}onAdd(e){return this._map=e,this._container=c.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return a._(this,arguments,void 0,(function*(e=!1){if(void 0!==sl&&!e)return sl;if(void 0===window.navigator.permissions)return sl=!!window.navigator.geolocation,sl;try{const e=yield window.navigator.permissions.query({name:"geolocation"});sl="denied"!==e.state}catch(e){sl=!!window.navigator.geolocation}return sl}))}().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(),c.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,dl=0,pl=!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":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const s=this._map.project(e),a=this._map.unproject([s.x+100,s.y]),l=e.distanceTo(a)/100,h=2*this._accuracy/l;this._circleElement.style.width=`${h.toFixed(2)}px`,this._circleElement.style.height=`${h.toFixed(2)}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":dl--,pl=!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"),dl++,dl>1?(e={maximumAge:6e5,timeout:0},pl=!0):(e=this.options.positionOptions,pl=!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=c.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=c.create("button","maplibregl-ctrl-globe",this._container),c.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(){c.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},s.Hash=ja,s.ImageSource=Q,s.KeyboardHandler=Pr,s.LngLatBounds=$,s.LogoControl=Gr,s.Map=class extends Nr{constructor(e){var s,l;a.cw.mark(a.cx.create);const h=Object.assign(Object.assign(Object.assign({},rl),e),{canvasContextAttributes:Object.assign(Object.assign({},rl.canvasContextAttributes),e.canvasContextAttributes)});if(null!=h.minZoom&&null!=h.maxZoom&&h.minZoom>h.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=h.minPitch&&null!=h.maxPitch&&h.minPitch>h.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=h.minPitch&&h.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=h.maxPitch&&h.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const p=new Ot,f=new Ut;if(void 0!==h.minZoom&&p.setMinZoom(h.minZoom),void 0!==h.maxZoom&&p.setMaxZoom(h.maxZoom),void 0!==h.minPitch&&p.setMinPitch(h.minPitch),void 0!==h.maxPitch&&p.setMaxPitch(h.maxPitch),void 0!==h.renderWorldCopies&&p.setRenderWorldCopies(h.renderWorldCopies),null!==h.transformConstrain&&p.setConstrain(h.transformConstrain),super(p,f,{bearingSnap:h.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Vr,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=h.interactive,this._maxTileCacheSize=h.maxTileCacheSize,this._maxTileCacheZoomLevels=h.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},h.canvasContextAttributes),this._trackResize=!0===h.trackResize,this._bearingSnap=h.bearingSnap,this._centerClampedToGround=h.centerClampedToGround,this._refreshExpiredTiles=!0===h.refreshExpiredTiles,this._fadeDuration=h.fadeDuration,this._crossSourceCollisions=!0===h.crossSourceCollisions,this._collectResourceTiming=!0===h.collectResourceTiming,this._locale=Object.assign(Object.assign({},el),h.locale),this._clickTolerance=h.clickTolerance,this._overridePixelRatio=h.pixelRatio,this._maxCanvasSize=h.maxCanvasSize,this.transformCameraUpdate=h.transformCameraUpdate,this.transformConstrain=h.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===h.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=E.addThrottleControl((()=>this.isMoving())),this._requestManager=new g(h.transformRequest),"string"==typeof h.container){if(this._container=document.getElementById(h.container),!this._container)throw new Error(`Container '${h.container}' not found.`)}else{if(!(h.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=h.container}if(h.maxBounds&&this.setMaxBounds(h.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=ws((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 jr(this,h),this._hash=h.hash&&new ja("string"==typeof h.hash&&h.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:h.center,elevation:h.elevation,zoom:h.zoom,bearing:h.bearing,pitch:h.pitch,roll:h.roll}),h.bounds&&(this.resize(),this.fitBounds(h.bounds,a.e({},h.fitBoundsOptions,{duration:0}))));const m="string"==typeof h.style||!("globe"===(null===(l=null===(s=h.style)||void 0===s?void 0:s.projection)||void 0===l?void 0:l.type));this.resize(null,m),this._localIdeographFontFamily=h.localIdeographFontFamily,this._validateStyle=h.validateStyle,h.style&&this.setStyle(h.style,{localIdeographFontFamily:h.localIdeographFontFamily}),h.attributionControl&&this.addControl(new Ur("boolean"==typeof h.attributionControl?void 0:h.attributionControl)),h.maplibreLogo&&this.addControl(new Gr,h.logoPosition),this.on("style.load",(()=>{if(m||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 h=this._controlPositions[s];return-1!==s.indexOf("bottom")?h.insertBefore(l,h.firstChild):h.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}coveringTiles(e){return ie(this.transform,e)}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,h]=this._containerDimensions(),p=this._getClampedPixelRatio(l,h);if(this._resizeCanvas(l,h,p),this.painter.resize(l,h,p),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const s=this._getClampedPixelRatio(l,h);this._resizeCanvas(l,h,s),this.painter.resize(l,h,s)}this._resizeTransform(s);const f=!this._moving;return f&&(this.stop(),this.fire(new a.l("movestart",e)).fire(new a.l("move",e))),this.fire(new a.l("resize",e)),f&&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,h=this.getPixelRatio(),p=e*h,f=s*h;return Math.min(p>a?a/p:1,f>l?l/f:1)*h}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds($.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)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()}setTransformConstrain(e){return this.transform.setConstrain(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 h=h=>{const p=s.filter((e=>this.getLayer(e))),f=0!==p.length?this.queryRenderedFeatures(h.point,{layers:p}):[];f.length?l||(l=!0,a.call(this,new Xa(e,this,h.originalEvent,{features:f}))):l=!1};return{layers:s,listener:a,delegates:{mousemove:h,mouseout:()=>{l=!1}}}}if("mouseleave"===e||"mouseout"===e){let l=!1;const h=h=>{const p=s.filter((e=>this.getLayer(e)));(0!==p.length?this.queryRenderedFeatures(h.point,{layers:p}):[]).length?l=!0:l&&(l=!1,a.call(this,new Xa(e,this,h.originalEvent)))},p=s=>{l&&(l=!1,a.call(this,new Xa(e,this,s.originalEvent)))};return{layers:s,listener:a,delegates:{mousemove:h,mouseout:p}}}{const l=e=>{const l=s.filter((e=>this.getLayer(e))),h=0!==l.length?this.queryRenderedFeatures(e.point,{layers:l}):[];h.length&&(e.features=h,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 h.delegates)this.off(e,h.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,h=this._createDelegatedListener(e,l,a);this._saveDelegatedListener(e,h);for(const e in h.delegates)this.on(e,h.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,h=this._createDelegatedListener(e,l,a);for(const s in h.delegates){const p=h.delegates[s];h.delegates[s]=(...s)=>{this._removeDelegatedListener(e,l,a),p(...s)}}this._saveDelegatedListener(e,h);for(const e in h.delegates)this.once(e,h.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 h=e instanceof a.P||Array.isArray(e),p=h?e:[[0,0],[this.transform.width,this.transform.height]];if(s=s||(h?{}:e)||{},p instanceof a.P||"number"==typeof p[0])l=[a.P.convert(p)];else{const e=a.P.convert(p[0]),s=a.P.convert(p[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 h=this.style&&s.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Ii(this,s||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,s,h):this.style.loadJSON(e,s,h),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 Ii(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 qr(this.painter,s,e),this.painter.renderToTexture=new Kr(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=Kt(Math.max(1,e),Math.max(1,s))}else for(const a in this.style.sourceCaches)this.style.sourceCaches[a].getSource().calculateTileZoom=Kt(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:h=1,sdf:p=!1,stretchX:f,stretchY:_,content:x,textFitWidth:v,textFitHeight:b}=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:m,data:w}=s,T=s;return this.style.addImage(e,{data:new a.R({width:l,height:m},new Uint8Array(w)),pixelRatio:h,stretchX:f,stretchY:_,content:x,textFitWidth:v,textFitHeight:b,sdf:p,version:0,userImage:T}),T.onAdd&&T.onAdd(this,e),this}}{const{width:l,height:w,data:T}=m.getImageData(s);this.style.addImage(e,{data:new a.R({width:l,height:w},T),pixelRatio:h,stretchX:f,stretchY:_,content:x,textFitWidth:v,textFitHeight:b,sdf:p,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 h=s instanceof HTMLImageElement||a.b(s)?m.getImageData(s):s,{width:p,height:f,data:_}=h;if(void 0===p||void 0===f)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(p!==l.data.width||f!==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 x=!(s instanceof HTMLImageElement||a.b(s));return l.data.replace(_,x),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 E.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=c.create("div","maplibregl-canvas-container",e);this._interactive&&s.classList.add("maplibregl-interactive"),this._canvas=c.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 h=this._controlContainer=c.create("div","maplibregl-control-container",e),p=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{p[e]=c.create("div",`maplibregl-ctrl-${e} `,h)})),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 Ba(a,this.transform),v.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,h,p,f;const m=this._idleTriggered?this._fadeDuration:0,_=(null===(s=this.style.projection)||void 0===s?void 0:s.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let v=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,s=x();this.style.zoomHistory.update(e,s);const l=new a.F(e,{now:s,fadeDuration:m,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),h=l.crossFadingFactor();1===h&&h===this._crossFadingFactor||(v=!0,this._crossFadingFactor=h),this.style.update(l)}const b=(null===(l=this.style.projection)||void 0===l?void 0:l.transitionState)>0!==_;null===(h=this.style.projection)||void 0===h||h.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(p=this.style.projection)||void 0===p?void 0:p.transitionState,null===(f=this.style.projection)||void 0===f?void 0:f.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||b)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.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,m,this._crossSourceCollisions,b),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:m,showPadding:this.showPadding}),this.fire(new 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()||v)&&(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.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),E.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),c.remove(this._canvasContainer),c.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,m.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===Rn}(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 il}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},s.MapMouseEvent=Xa,s.MapTouchEvent=Ka,s.MapWheelEvent=Qa,s.Marker=ss,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({},nl,e),this._container=c.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}))),c.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}))),c.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=c.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 ts(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){c.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=c.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&&c.remove(this._content),this._container&&(c.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=c.create("div","maplibregl-popup",this._map.getContainer()),this._tip=c.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=ol(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=bl(this.options.offset);if(!a){const e=this._container.offsetWidth,h=this._container.offsetHeight;let p;p=s.y+l.bottom.ythis._map.transform.height-h?["bottom"]:[],s.xthis._map.transform.width-e/2&&p.push("right"),a=0===p.length?"bottom":p.join("-")}let h=s.add(l[a]);this.options.subpixelPositioning||(h=h.round()),c.setTransform(this._container,`${al[a]} translate(${h.x}px,${h.y}px)`),ll(this._container,a,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=a.e(Object.create(yl),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=c.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=c.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(vl);e&&e.focus()}},s.RasterDEMTileSource=X,s.RasterTileSource=H,s.ScaleControl=class{constructor(e){this._onMove=()=>{ml(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,ml(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},fl),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=c.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){c.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},s.ScrollZoomHandler=Sr,s.Style=Ii,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=c.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=c.create("button","maplibregl-ctrl-terrain",this._container),c.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(){c.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},s.TwoFingersTouchPitchHandler=wr,s.TwoFingersTouchRotateHandler=br,s.TwoFingersTouchZoomHandler=vr,s.TwoFingersTouchZoomRotateHandler=Lr,s.VectorTileSource=q,s.VideoSource=Y,s.addSourceType=(e,s)=>a._(void 0,void 0,void 0,(function*(){if(vt(e))throw new Error(`A source type called "${e}" already exists.`);((e,s)=>{_t[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=$i,s.getMaxParallelImageRequests=function(){return a.a.MAX_PARALLEL_IMAGE_REQUESTS},s.getRTLTextPluginStatus=function(){return St().getRTLTextPluginStatus()},s.getVersion=function(){return Tl},s.getWorkerCount=function(){return A.workerCount},s.getWorkerUrl=function(){return a.a.WORKER_URL},s.importScriptInWorkers=function(e){return at().broadcast("IS",e)},s.isTimeFrozen=function(){return _.isFrozen()},s.prewarm=function(){st().acquire(U)},s.restoreNow=function(){_.restoreNow()},s.setMaxParallelImageRequests=function(e){a.a.MAX_PARALLEL_IMAGE_REQUESTS=e},s.setNow=function(e){_.setNow(e)},s.setRTLTextPlugin=function(e,s){return St().setRTLTextPlugin(e,s)},s.setWorkerCount=function(e){A.workerCount=e},s.setWorkerUrl=function(e){a.a.WORKER_URL=e}}));var h=s;return h}));var a=s;export{a as default};