From 44e3d9fe1753aa351df2bbe1c44859a6042f67a6 Mon Sep 17 00:00:00 2001 From: qazsato Date: Tue, 3 Dec 2024 22:35:50 +0900 Subject: [PATCH] remove accuracy option --- README.md | 12 +++++------- docs/{index-Dgo8Clwm.js => index-CarpIPlA.js} | 11 +++++------ docs/index.html | 2 +- src/components/DebugView.ts | 7 +------ src/maplibre-gl-compass.ts | 15 ++------------- tests/DebugView.test.ts | 14 +++----------- tests/maplibre-gl-compass.test.ts | 2 -- 7 files changed, 17 insertions(+), 46 deletions(-) rename docs/{index-Dgo8Clwm.js => index-CarpIPlA.js} (94%) diff --git a/README.md b/README.md index 9b2b338..f1bca6c 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,6 @@ import 'maplibre-gl-compass/style.css' const map = new Map({/* YOUR_MAP_OPTION */}) const compass = new CompassControl({ - accuracy: 10.0, // If the accuracy is lower than this value, the map bearing will not be updated. Default is not set. debug: true, // Show debug view. Default is false. timeout: 10000, // The maximum time to wait for a DeviceOrientationEvent. Default is 3000 [ms]. visible: true, // Show compass button. Default is true. @@ -73,12 +72,11 @@ map.addControl(compass) ## Options -| name | default | description | -| -------- | ------- | ------------------------------------------------------------------------------ | -| accuracy | | If the accuracy is lower than this value, the map bearing will not be updated. | -| debug | false | Show debug view. | -| timeout | 3000 | The maximum time[ms] to wait for a DeviceOrientationEvent. | -| visible | true | Show compass button. | +| name | default | description | +| ------- | ------- | ---------------------------------------------------------- | +| debug | false | Show debug view. | +| timeout | 3000 | The maximum time[ms] to wait for a DeviceOrientationEvent. | +| visible | true | Show compass button. | ## Events diff --git a/docs/index-Dgo8Clwm.js b/docs/index-CarpIPlA.js similarity index 94% rename from docs/index-Dgo8Clwm.js rename to docs/index-CarpIPlA.js index 24a2551..066212d 100644 --- a/docs/index-Dgo8Clwm.js +++ b/docs/index-CarpIPlA.js @@ -1,8 +1,8 @@ -var If=Object.defineProperty;var Pf=(J,j,G)=>j in J?If(J,j,{enumerable:!0,configurable:!0,writable:!0,value:G}):J[j]=G;var Fi=(J,j,G)=>Pf(J,typeof j!="symbol"?j+"":j,G);(function(){const j=document.createElement("link").relList;if(j&&j.supports&&j.supports("modulepreload"))return;for(const he of document.querySelectorAll('link[rel="modulepreload"]'))re(he);new MutationObserver(he=>{for(const ye of he)if(ye.type==="childList")for(const M of ye.addedNodes)M.tagName==="LINK"&&M.rel==="modulepreload"&&re(M)}).observe(document,{childList:!0,subtree:!0});function G(he){const ye={};return he.integrity&&(ye.integrity=he.integrity),he.referrerPolicy&&(ye.referrerPolicy=he.referrerPolicy),he.crossOrigin==="use-credentials"?ye.credentials="include":he.crossOrigin==="anonymous"?ye.credentials="omit":ye.credentials="same-origin",ye}function re(he){if(he.ep)return;he.ep=!0;const ye=G(he);fetch(he.href,ye)}})();var ec={exports:{}};/** +var If=Object.defineProperty;var Pf=(J,j,G)=>j in J?If(J,j,{enumerable:!0,configurable:!0,writable:!0,value:G}):J[j]=G;var Xi=(J,j,G)=>Pf(J,typeof j!="symbol"?j+"":j,G);(function(){const j=document.createElement("link").relList;if(j&&j.supports&&j.supports("modulepreload"))return;for(const de of document.querySelectorAll('link[rel="modulepreload"]'))ne(de);new MutationObserver(de=>{for(const ye of de)if(ye.type==="childList")for(const M of ye.addedNodes)M.tagName==="LINK"&&M.rel==="modulepreload"&&ne(M)}).observe(document,{childList:!0,subtree:!0});function G(de){const ye={};return de.integrity&&(ye.integrity=de.integrity),de.referrerPolicy&&(ye.referrerPolicy=de.referrerPolicy),de.crossOrigin==="use-credentials"?ye.credentials="include":de.crossOrigin==="anonymous"?ye.credentials="omit":ye.credentials="same-origin",ye}function ne(de){if(de.ep)return;de.ep=!0;const ye=G(de);fetch(de.href,ye)}})();var ec={exports:{}};/** * MapLibre GL JS * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.7.1/LICENSE.txt - */var Af=ec.exports,ud;function Cf(){return ud||(ud=1,function(J,j){(function(G,re){J.exports=re()})(Af,function(){var G={},re={};function he(M,p,Je){if(re[M]=Je,M==="index"){var Ge="var sharedModule = {}; ("+re.shared+")(sharedModule); ("+re.worker+")(sharedModule);",He={};return re.shared(He),re.index(G,He),typeof window<"u"&&G.setWorkerUrl(window.URL.createObjectURL(new Blob([Ge],{type:"text/javascript"}))),G}}he("shared",["exports"],function(M){function p(i,t,r,s){return new(r||(r=Promise))(function(l,u){function d(x){try{g(s.next(x))}catch(v){u(v)}}function f(x){try{g(s.throw(x))}catch(v){u(v)}}function g(x){var v;x.done?l(x.value):(v=x.value,v instanceof r?v:new r(function(w){w(v)})).then(d,f)}g((s=s.apply(i,t||[])).next())})}function Je(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var Ge=He;function He(i,t){this.x=i,this.y=t}He.prototype={clone:function(){return new He(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,t){return this.clone()._rotateAround(i,t)},matMult:function(i){return this.clone()._matMult(i)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var t=i.x-this.x,r=i.y-this.y;return t*t+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,t){return Math.atan2(this.x*t-this.y*i,this.x*i+this.y*t)},_matMult:function(i){var t=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=t,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var t=Math.cos(i),r=Math.sin(i),s=r*this.x+t*this.y;return this.x=t*this.x-r*this.y,this.y=s,this},_rotateAround:function(i,t){var r=Math.cos(i),s=Math.sin(i),l=t.y+s*(this.x-t.x)+r*(this.y-t.y);return this.x=t.x+r*(this.x-t.x)-s*(this.y-t.y),this.y=l,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},He.convert=function(i){return i instanceof He?i:Array.isArray(i)?new He(i[0],i[1]):i};var de=Je(Ge),se=Ot;function Ot(i,t,r,s){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(s-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=t,this.p2x=r,this.p2y=s}Ot.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,t){if(t===void 0&&(t=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,s=0;s<8;s++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,t){return this.sampleCurveY(this.solveCurveX(i,t))}};var qt=Je(se);let kt,Ii;function Oi(){return kt==null&&(kt=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),kt}function Fr(){if(Ii==null&&(Ii=!1,Oi())){const t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let s=0;s<5*5;s++){const l=4*s;t.fillStyle=`rgb(${l},${l+1},${l+2})`,t.fillRect(s%5,Math.floor(s/5),1,1)}const r=t.getImageData(0,0,5,5).data;for(let s=0;s<5*5*4;s++)if(s%4!=3&&r[s]!==s){Ii=!0;break}}}return Ii||!1}function Mt(i,t,r,s){const l=new qt(i,t,r,s);return u=>l.solve(u)}const ln=Mt(.25,.1,.25,1);function mi(i,t,r){return Math.min(r,Math.max(t,i))}function Pi(i,t,r){const s=r-t,l=((i-t)%s+s)%s+t;return l===t?r:l}function gi(i,...t){for(const r of t)for(const s in r)i[s]=r[s];return i}let cn=1;function ii(i,t,r){const s={};for(const l in i)s[l]=t.call(this,i[l],l,i);return s}function Or(i,t,r){const s={};for(const l in i)t.call(this,i[l],l,i)&&(s[l]=i[l]);return s}function et(i){return Array.isArray(i)?i.map(et):typeof i=="object"&&i?ii(i,et):i}const hn={};function Gt(i){hn[i]||(typeof console<"u"&&console.warn(i),hn[i]=!0)}function Jt(i,t,r){return(r.y-i.y)*(t.x-i.x)>(t.y-i.y)*(r.x-i.x)}function Wi(i){return typeof WorkerGlobalScope<"u"&&i!==void 0&&i instanceof WorkerGlobalScope}let Vi=null;function _i(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}const un="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function ri(i,t,r,s,l){return p(this,void 0,void 0,function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const u=new VideoFrame(i,{timestamp:0});try{const d=u==null?void 0:u.format;if(!d||!d.startsWith("BGR")&&!d.startsWith("RGB"))throw new Error(`Unrecognized format ${d}`);const f=d.startsWith("BGR"),g=new Uint8ClampedArray(s*l*4);if(yield u.copyTo(g,function(x,v,w,I,C){const E=4*Math.max(-v,0),z=(Math.max(0,w)-w)*I*4+E,O=4*I,$=Math.max(0,v),ne=Math.max(0,w);return{rect:{x:$,y:ne,width:Math.min(x.width,v+I)-$,height:Math.min(x.height,w+C)-ne},layout:[{offset:z,stride:O}]}}(i,t,r,s,l)),f)for(let x=0;xWi(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,Ir=function(i,t){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){const s=si(i.url);if(s)return s(i,t);if(Wi(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,targetMapId:Sr},t)}if(!(/^file:/.test(r=i.url)||/^file:/.test(Ai())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,l){return p(this,void 0,void 0,function*(){const u=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:Ai(),signal:l.signal});s.type!=="json"||u.headers.has("Accept")||u.headers.set("Accept","application/json");const d=yield fetch(u);if(!d.ok){const x=yield d.blob();throw new Yt(d.status,d.statusText,s.url,x)}let f;f=s.type==="arrayBuffer"||s.type==="image"?d.arrayBuffer():s.type==="json"?d.json():d.text();const g=yield f;if(l.signal.aborted)throw Ni();return{data:g,cacheControl:d.headers.get("Cache-Control"),expires:d.headers.get("Expires")}})}(i,t);if(Wi(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,mustQueue:!0,targetMapId:Sr},t)}var r;return function(s,l){return new Promise((u,d)=>{var f;const g=new XMLHttpRequest;g.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(g.responseType="arraybuffer");for(const x in s.headers)g.setRequestHeader(x,s.headers[x]);s.type==="json"&&(g.responseType="text",!((f=s.headers)===null||f===void 0)&&f.Accept||g.setRequestHeader("Accept","application/json")),g.withCredentials=s.credentials==="include",g.onerror=()=>{d(new Error(g.statusText))},g.onload=()=>{if(!l.signal.aborted)if((g.status>=200&&g.status<300||g.status===0)&&g.response!==null){let x=g.response;if(s.type==="json")try{x=JSON.parse(g.response)}catch(v){return void d(v)}u({data:x,cacheControl:g.getResponseHeader("Cache-Control"),expires:g.getResponseHeader("Expires")})}else{const x=new Blob([g.response],{type:g.getResponseHeader("Content-Type")});d(new Yt(g.status,g.statusText,s.url,x))}},l.signal.addEventListener("abort",()=>{g.abort(),d(Ni())}),g.send(s.body)})}(i,t)};function Vr(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;const t=new URL(i),r=window.location;return t.protocol===r.protocol&&t.host===r.host}function Xr(i,t,r){r[i]&&r[i].indexOf(t)!==-1||(r[i]=r[i]||[],r[i].push(t))}function Ki(i,t,r){if(r&&r[i]){const s=r[i].indexOf(t);s!==-1&&r[i].splice(s,1)}}class lr{constructor(t,r={}){gi(this,r),this.type=t}}class Wr extends lr{constructor(t,r={}){super("error",gi({error:t},r))}}class kn{on(t,r){return this._listeners=this._listeners||{},Xr(t,r,this._listeners),this}off(t,r){return Ki(t,r,this._listeners),Ki(t,r,this._oneTimeListeners),this}once(t,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},Xr(t,r,this._oneTimeListeners),this):new Promise(s=>this.once(t,s))}fire(t,r){typeof t=="string"&&(t=new lr(t,r||{}));const s=t.type;if(this.listens(s)){t.target=this;const l=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const f of l)f.call(this,t);const u=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const f of u)Ki(s,f,this._oneTimeListeners),f.call(this,t);const d=this._eventedParent;d&&(gi(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),d.fire(t))}else t instanceof Wr&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,r){return this._eventedParent=t,this._eventedParentData=r,this}}var le={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},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_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"}},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:"enum",default:"mercator",values:{mercator:{},globe:{}}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,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:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",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"}},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 dn=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ps(i,t){const r={};for(const s in i)s!=="ref"&&(r[s]=i[s]);return dn.forEach(s=>{s in t&&(r[s]=t[s])}),r}function ut(i,t){if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(let r=0;r`:i.itemType.kind==="value"?"array":`array<${t}>`}return i.kind}const R=[Jr,Te,Qe,$e,Ci,Ur,cr,A(We),Yr,Mr,U];function V(i,t){if(t.kind==="error")return null;if(i.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!V(i.itemType,t.itemType))&&(typeof i.N!="number"||i.N===t.N))return null}else{if(i.kind===t.kind)return null;if(i.kind==="value"){for(const r of R)if(!V(r,t))return null}}return`Expected ${P(i)} but found ${P(t)} instead.`}function K(i,t){return t.some(r=>r.kind===i.kind)}function Q(i,t){return t.some(r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i)}function ie(i,t){return i.kind==="array"&&t.kind==="array"?i.itemType.kind===t.itemType.kind&&typeof i.N=="number":i.kind===t.kind}const H=.96422,ue=.82521,me=4/29,oe=6/29,ve=3*oe*oe,Ve=oe*oe*oe,Ne=Math.PI/180,ot=180/Math.PI;function Ke(i){return(i%=360)<0&&(i+=360),i}function lt([i,t,r,s]){let l,u;const d=Ut((.2225045*(i=rt(i))+.7168786*(t=rt(t))+.0606169*(r=rt(r)))/1);i===t&&t===r?l=u=d:(l=Ut((.4360747*i+.3850649*t+.1430804*r)/H),u=Ut((.0139322*i+.0971045*t+.7141733*r)/ue));const f=116*d-16;return[f<0?0:f,500*(l-d),200*(d-u),s]}function rt(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function Ut(i){return i>Ve?Math.pow(i,1/3):i/ve+me}function zt([i,t,r,s]){let l=(i+16)/116,u=isNaN(t)?l:l+t/500,d=isNaN(r)?l:l-r/200;return l=1*ft(l),u=H*ft(u),d=ue*ft(d),[tt(3.1338561*u-1.6168667*l-.4906146*d),tt(-.9787684*u+1.9161415*l+.033454*d),tt(.0719453*u-.2289914*l+1.4052427*d),s]}function tt(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function ft(i){return i>oe?i*i*i:ve*(i-me)}function Ct(i){return parseInt(i.padEnd(2,i),16)/255}function Ht(i,t){return Qt(t?i/100:i,0,1)}function Qt(i,t,r){return Math.min(Math.max(t,i),r)}function vi(i){return!i.some(Number.isNaN)}const zn={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]};class mt{constructor(t,r,s,l=1,u=!0){this.r=t,this.g=r,this.b=s,this.a=l,u||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[t,r,s,l]))}static parse(t){if(t instanceof mt)return t;if(typeof t!="string")return;const r=function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const l=zn[s];if(l){const[d,f,g]=l;return[d/255,f/255,g/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const d=s.length<6?1:2;let f=1;return[Ct(s.slice(f,f+=d)),Ct(s.slice(f,f+=d)),Ct(s.slice(f,f+=d)),Ct(s.slice(f,f+d)||"ff")]}if(s.startsWith("rgb")){const d=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){const[f,g,x,v,w,I,C,E,z,O,$,ne]=d,W=[v||" ",C||" ",O].join("");if(W===" "||W===" /"||W===",,"||W===",,,"){const te=[x,I,z].join(""),ce=te==="%%%"?100:te===""?255:0;if(ce){const ge=[Qt(+g/ce,0,1),Qt(+w/ce,0,1),Qt(+E/ce,0,1),$?Ht(+$,ne):1];if(vi(ge))return ge}}return}}const u=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(u){const[d,f,g,x,v,w,I,C,E]=u,z=[g||" ",v||" ",I].join("");if(z===" "||z===" /"||z===",,"||z===",,,"){const O=[+f,Qt(+x,0,100),Qt(+w,0,100),C?Ht(+C,E):1];if(vi(O))return function([$,ne,W,te]){function ce(ge){const Me=(ge+$/30)%12,Ue=ne*Math.min(W,1-W);return W-Ue*Math.max(-1,Math.min(Me-3,9-Me,1))}return $=Ke($),ne/=100,W/=100,[ce(0),ce(8),ce(4),te]}(O)}}}(t);return r?new mt(...r,!1):void 0}get rgb(){const{r:t,g:r,b:s,a:l}=this,u=l||1/0;return this.overwriteGetter("rgb",[t/u,r/u,s/u,l])}get hcl(){return this.overwriteGetter("hcl",function(t){const[r,s,l,u]=lt(t),d=Math.sqrt(s*s+l*l);return[Math.round(1e4*d)?Ke(Math.atan2(l,s)*ot):NaN,d,r,u]}(this.rgb))}get lab(){return this.overwriteGetter("lab",lt(this.rgb))}overwriteGetter(t,r){return Object.defineProperty(this,t,{value:r}),r}toString(){const[t,r,s,l]=this.rgb;return`rgba(${[t,r,s].map(u=>Math.round(255*u)).join(",")},${l})`}}mt.black=new mt(0,0,0,1),mt.white=new mt(1,1,1,1),mt.transparent=new mt(0,0,0,0),mt.red=new mt(1,0,0,1);class Na{constructor(t,r,s){this.sensitivity=t?r?"variant":"case":r?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,r){return this.collator.compare(t,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Ua{constructor(t,r,s,l,u){this.text=t,this.image=r,this.scale=s,this.fontStack=l,this.textColor=u}}class Ui{constructor(t){this.sections=t}static fromString(t){return new Ui([new Ua(t,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof Ui?t:Ui.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}}class ji{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof ji)return t;if(typeof t=="number")return new ji([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const r of t)if(typeof r!="number")return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new ji(t)}}toString(){return JSON.stringify(this.values)}}const rc=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Yi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Yi)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let r=0;r=0&&i<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof r=="number"&&r>=0&&r<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[i,t,r,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[i,t,r,s]:[i,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function pn(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof mt||i instanceof Na||i instanceof Ui||i instanceof ji||i instanceof Yi||i instanceof $i)return!0;if(Array.isArray(i)){for(const t of i)if(!pn(t))return!1;return!0}if(typeof i=="object"){for(const t in i)if(!pn(i[t]))return!1;return!0}return!1}function jt(i){if(i===null)return Jr;if(typeof i=="string")return Qe;if(typeof i=="boolean")return $e;if(typeof i=="number")return Te;if(i instanceof mt)return Ci;if(i instanceof Na)return Cr;if(i instanceof Ui)return Ur;if(i instanceof ji)return Yr;if(i instanceof Yi)return U;if(i instanceof $i)return Mr;if(Array.isArray(i)){const t=i.length;let r;for(const s of i){const l=jt(s);if(r){if(r===l)continue;r=We;break}r=l}return A(r||We,t)}return cr}function _s(i){const t=typeof i;return i===null?"":t==="string"||t==="number"||t==="boolean"?String(i):i instanceof mt||i instanceof Ui||i instanceof ji||i instanceof Yi||i instanceof $i?i.toString():JSON.stringify(i)}class hr{constructor(t,r){this.type=t,this.value=r}static parse(t,r){if(t.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!pn(t[1]))return r.error("invalid value");const s=t[1];let l=jt(s);const u=r.expectedType;return l.kind!=="array"||l.N!==0||!u||u.kind!=="array"||typeof u.N=="number"&&u.N!==0||(l=u),new hr(l,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Vt{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const $s={string:Qe,number:Te,boolean:$e,object:cr};class ur{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s,l=1;const u=t[0];if(u==="array"){let f,g;if(t.length>2){const x=t[1];if(typeof x!="string"||!(x in $s)||x==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);f=$s[x],l++}else f=We;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return r.error('The length argument to "array" must be a positive integer literal',2);g=t[2],l++}s=A(f,g)}else{if(!$s[u])throw new Error(`Types doesn't contain name = ${u}`);s=$s[u]}const d=[];for(;lt.outputDefined())}}const ja={"to-boolean":$e,"to-color":Ci,"to-number":Te,"to-string":Qe};class dr{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");const s=t[0];if(!ja[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&t.length!==2)return r.error("Expected one argument.");const l=ja[s],u=[];for(let d=1;d4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:Dn(r[0],r[1],r[2],r[3]),!s))return new mt(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Vt(s||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const s of this.args){r=s.evaluate(t);const l=ji.parse(r);if(l)return l}throw new Vt(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const s of this.args){r=s.evaluate(t);const l=Yi.parse(r);if(l)return l}throw new Vt(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const s of this.args){if(r=s.evaluate(t),r===null)return 0;const l=Number(r);if(!isNaN(l))return l}throw new Vt(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return Ui.fromString(_s(this.args[0].evaluate(t)));case"resolvedImage":return $i.fromString(_s(this.args[0].evaluate(t)));default:return _s(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const nc=["Unknown","Point","LineString","Polygon"];class qs{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?nc[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(t){let r=this._parseColorCache[t];return r||(r=this._parseColorCache[t]=mt.parse(t)),r}}class fn{constructor(t,r,s=[],l,u=new Ar,d=[]){this.registry=t,this.path=s,this.key=s.map(f=>`[${f}]`).join(""),this.scope=u,this.errors=d,this.expectedType=l,this._isConstant=r}parse(t,r,s,l,u={}){return r?this.concat(r,s,l)._parse(t,u):this._parse(t,u)}_parse(t,r){function s(l,u,d){return d==="assert"?new ur(u,[l]):d==="coerce"?new dr(u,[l]):l}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const l=t[0];if(typeof l!="string")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 u=this.registry[l];if(u){let d=u.parse(t,this);if(!d)return null;if(this.expectedType){const f=this.expectedType,g=d.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||g.kind!=="value")if(f.kind!=="color"&&f.kind!=="formatted"&&f.kind!=="resolvedImage"||g.kind!=="value"&&g.kind!=="string")if(f.kind!=="padding"||g.kind!=="value"&&g.kind!=="number"&&g.kind!=="array")if(f.kind!=="variableAnchorOffsetCollection"||g.kind!=="value"&&g.kind!=="array"){if(this.checkSubtype(f,g))return null}else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"assert")}if(!(d instanceof hr)&&d.type.kind!=="resolvedImage"&&this._isConstant(d)){const f=new qs;try{d=new hr(d.type,d.evaluate(f))}catch(g){return this.error(g.message),null}}return d}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(t===void 0?"'undefined' value invalid. Use null instead.":typeof t=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,r,s){const l=typeof t=="number"?this.path.concat(t):this.path,u=s?this.scope.concat(s):this.scope;return new fn(this.registry,this._isConstant,l,r||null,u,this.errors)}error(t,...r){const s=`${this.key}${r.map(l=>`[${l}]`).join("")}`;this.errors.push(new xi(s,t))}checkSubtype(t,r){const s=V(t,r);return s&&this.error(s),s}}class Qr{constructor(t,r){this.type=r.type,this.bindings=[].concat(t),this.result=r}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const r of this.bindings)t(r[1]);t(this.result)}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const s=[];for(let u=1;u=s.length)throw new Vt(`Array index out of bounds: ${r} > ${s.length-1}.`);if(r!==Math.floor(r))throw new Vt(`Array index must be an integer, but found ${r} instead.`);return s[r]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class qa{constructor(t,r){this.type=$e,this.needle=t,this.haystack=r}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const s=r.parse(t[1],1,We),l=r.parse(t[2],2,We);return s&&l?K(s.type,[$e,Qe,Te,Jr,We])?new qa(s,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`):null}evaluate(t){const r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!s)return!1;if(!Q(r,["boolean","string","number","null"]))throw new Vt(`Expected first argument to be of type boolean, string, number or null, but found ${P(jt(r))} instead.`);if(!Q(s,["string","array"]))throw new Vt(`Expected second argument to be of type array or string, but found ${P(jt(s))} instead.`);return s.indexOf(r)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class Ln{constructor(t,r,s){this.type=Te,this.needle=t,this.haystack=r,this.fromIndex=s}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=r.parse(t[1],1,We),l=r.parse(t[2],2,We);if(!s||!l)return null;if(!K(s.type,[$e,Qe,Te,Jr,We]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`);if(t.length===4){const u=r.parse(t[3],3,Te);return u?new Ln(s,l,u):null}return new Ln(s,l)}evaluate(t){const r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!Q(r,["boolean","string","number","null"]))throw new Vt(`Expected first argument to be of type boolean, string, number or null, but found ${P(jt(r))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(t)),Q(s,["string"])){const u=s.indexOf(r,l);return u===-1?-1:[...s.slice(0,u)].length}if(Q(s,["array"]))return s.indexOf(r,l);throw new Vt(`Expected second argument to be of type array or string, but found ${P(jt(s))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class Za{constructor(t,r,s,l,u,d){this.inputType=t,this.type=r,this.input=s,this.cases=l,this.outputs=u,this.otherwise=d}static parse(t,r){if(t.length<5)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return r.error("Expected an even number of arguments.");let s,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);const u={},d=[];for(let x=2;xNumber.MAX_SAFE_INTEGER)return I.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof E=="number"&&Math.floor(E)!==E)return I.error("Numeric branch labels must be integer values.");if(s){if(I.checkSubtype(s,jt(E)))return null}else s=jt(E);if(u[String(E)]!==void 0)return I.error("Branch labels must be unique.");u[String(E)]=d.length}const C=r.parse(w,x,l);if(!C)return null;l=l||C.type,d.push(C)}const f=r.parse(t[1],1,We);if(!f)return null;const g=r.parse(t[t.length-1],t.length-1,l);return g?f.type.kind!=="value"&&r.concat(1).checkSubtype(s,f.type)?null:new Za(s,l,f,u,d,g):null}evaluate(t){const r=this.input.evaluate(t);return(jt(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}}class Zs{constructor(t,r,s){this.type=t,this.branches=r,this.otherwise=s}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return r.error("Expected an odd number of arguments.");let s;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);const l=[];for(let d=1;dr.outputDefined())&&this.otherwise.outputDefined()}}class ys{constructor(t,r,s,l){this.type=t,this.input=r,this.beginIndex=s,this.endIndex=l}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=r.parse(t[1],1,We),l=r.parse(t[2],2,Te);if(!s||!l)return null;if(!K(s.type,[A(We),Qe,We]))return r.error(`Expected first argument to be of type array or string, but found ${P(s.type)} instead`);if(t.length===4){const u=r.parse(t[3],3,Te);return u?new ys(s.type,s,l,u):null}return new ys(s.type,s,l)}evaluate(t){const r=this.input.evaluate(t),s=this.beginIndex.evaluate(t);let l;if(this.endIndex&&(l=this.endIndex.evaluate(t)),Q(r,["string"]))return[...r].slice(s,l).join("");if(Q(r,["array"]))return r.slice(s,l);throw new Vt(`Expected first argument to be of type array or string, but found ${P(jt(r))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function Gs(i,t){const r=i.length-1;let s,l,u=0,d=r,f=0;for(;u<=d;)if(f=Math.floor((u+d)/2),s=i[f],l=i[f+1],s<=t){if(f===r||tt))throw new Vt("Input is not a number.");d=f-1}return 0}class Rn{constructor(t,r,s){this.type=t,this.input=r,this.labels=[],this.outputs=[];for(const[l,u]of s)this.labels.push(l),this.outputs.push(u)}static parse(t,r){if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");const s=r.parse(t[1],1,Te);if(!s)return null;const l=[];let u=null;r.expectedType&&r.expectedType.kind!=="value"&&(u=r.expectedType);for(let d=1;d=f)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',x);const w=r.parse(g,v,u);if(!w)return null;u=u||w.type,l.push([f,w])}return new Rn(u,s,l)}evaluate(t){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);const l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);const u=r.length;return l>=r[u-1]?s[u-1].evaluate(t):s[Gs(r,l)].evaluate(t)}eachChild(t){t(this.input);for(const r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function Yo(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var sc=Qo;function Qo(i,t,r,s){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(s-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=t,this.p2x=r,this.p2y=s}Qo.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,t){if(t===void 0&&(t=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,s=0;s<8;s++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,t){return this.sampleCurveY(this.solveCurveX(i,t))}};var ac=Yo(sc);function mn(i,t,r){return i+r*(t-i)}function xs(i,t,r){return i.map((s,l)=>mn(s,t[l],r))}const Mi={number:mn,color:function(i,t,r,s="rgb"){switch(s){case"rgb":{const[l,u,d,f]=xs(i.rgb,t.rgb,r);return new mt(l,u,d,f,!1)}case"hcl":{const[l,u,d,f]=i.hcl,[g,x,v,w]=t.hcl;let I,C;if(isNaN(l)||isNaN(g))isNaN(l)?isNaN(g)?I=NaN:(I=g,d!==1&&d!==0||(C=x)):(I=l,v!==1&&v!==0||(C=u));else{let ne=g-l;g>l&&ne>180?ne-=360:g180&&(ne+=360),I=l+r*ne}const[E,z,O,$]=function([ne,W,te,ce]){return ne=isNaN(ne)?0:ne*Ne,zt([te,Math.cos(ne)*W,Math.sin(ne)*W,ce])}([I,C??mn(u,x,r),mn(d,v,r),mn(f,w,r)]);return new mt(E,z,O,$,!1)}case"lab":{const[l,u,d,f]=zt(xs(i.lab,t.lab,r));return new mt(l,u,d,f,!1)}}},array:xs,padding:function(i,t,r){return new ji(xs(i.values,t.values,r))},variableAnchorOffsetCollection:function(i,t,r){const s=i.values,l=t.values;if(s.length!==l.length)throw new Vt(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${t.toString()}`);const u=[];for(let d=0;dtypeof v!="number"||v<0||v>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:x}}}if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(u=r.parse(u,2,Te),!u)return null;const f=[];let g=null;s==="interpolate-hcl"||s==="interpolate-lab"?g=Ci:r.expectedType&&r.expectedType.kind!=="value"&&(g=r.expectedType);for(let x=0;x=v)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',I);const E=r.parse(w,C,g);if(!E)return null;g=g||E.type,f.push([v,E])}return ie(g,Te)||ie(g,Ci)||ie(g,Yr)||ie(g,U)||ie(g,A(Te))?new ki(g,s,l,u,f):r.error(`Type ${P(g)} is not interpolatable.`)}evaluate(t){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);const l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);const u=r.length;if(l>=r[u-1])return s[u-1].evaluate(t);const d=Gs(r,l),f=ki.interpolationFactor(this.interpolation,l,r[d],r[d+1]),g=s[d].evaluate(t),x=s[d+1].evaluate(t);switch(this.operator){case"interpolate":return Mi[this.type.kind](g,x,f);case"interpolate-hcl":return Mi.color(g,x,f,"hcl");case"interpolate-lab":return Mi.color(g,x,f,"lab")}}eachChild(t){t(this.input);for(const r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function Hs(i,t,r,s){const l=s-r,u=i-r;return l===0?0:t===1?u/l:(Math.pow(t,u)-1)/(Math.pow(t,l)-1)}class Xs{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expectected at least one argument.");let s=null;const l=r.expectedType;l&&l.kind!=="value"&&(s=l);const u=[];for(const f of t.slice(1)){const g=r.parse(f,1+u.length,s,void 0,{typeAnnotation:"omit"});if(!g)return null;s=s||g.type,u.push(g)}if(!s)throw new Error("No output type");const d=l&&u.some(f=>V(l,f.type));return new Xs(d?We:s,u)}evaluate(t){let r,s=null,l=0;for(const u of this.args)if(l++,s=u.evaluate(t),s&&s instanceof $i&&!s.available&&(r||(r=s.name),s=null,l===this.args.length&&(s=r)),s!==null)break;return s}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}function Ws(i,t){return i==="=="||i==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function el(i,t,r,s){return s.compare(t,r)===0}function Bn(i,t,r){const s=i!=="=="&&i!=="!=";return class pd{constructor(u,d,f){this.type=$e,this.lhs=u,this.rhs=d,this.collator=f,this.hasUntypedArgument=u.type.kind==="value"||d.type.kind==="value"}static parse(u,d){if(u.length!==3&&u.length!==4)return d.error("Expected two or three arguments.");const f=u[0];let g=d.parse(u[1],1,We);if(!g)return null;if(!Ws(f,g.type))return d.concat(1).error(`"${f}" comparisons are not supported for type '${P(g.type)}'.`);let x=d.parse(u[2],2,We);if(!x)return null;if(!Ws(f,x.type))return d.concat(2).error(`"${f}" comparisons are not supported for type '${P(x.type)}'.`);if(g.type.kind!==x.type.kind&&g.type.kind!=="value"&&x.type.kind!=="value")return d.error(`Cannot compare types '${P(g.type)}' and '${P(x.type)}'.`);s&&(g.type.kind==="value"&&x.type.kind!=="value"?g=new ur(x.type,[g]):g.type.kind!=="value"&&x.type.kind==="value"&&(x=new ur(g.type,[x])));let v=null;if(u.length===4){if(g.type.kind!=="string"&&x.type.kind!=="string"&&g.type.kind!=="value"&&x.type.kind!=="value")return d.error("Cannot use collator to compare non-string types.");if(v=d.parse(u[3],3,Cr),!v)return null}return new pd(g,x,v)}evaluate(u){const d=this.lhs.evaluate(u),f=this.rhs.evaluate(u);if(s&&this.hasUntypedArgument){const g=jt(d),x=jt(f);if(g.kind!==x.kind||g.kind!=="string"&&g.kind!=="number")throw new Vt(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${g.kind}, ${x.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const g=jt(d),x=jt(f);if(g.kind!=="string"||x.kind!=="string")return t(u,d,f)}return this.collator?r(u,d,f,this.collator.evaluate(u)):t(u,d,f)}eachChild(u){u(this.lhs),u(this.rhs),this.collator&&u(this.collator)}outputDefined(){return!0}}}const oc=Bn("==",function(i,t,r){return t===r},el),tl=Bn("!=",function(i,t,r){return t!==r},function(i,t,r,s){return!el(0,t,r,s)}),il=Bn("<",function(i,t,r){return t",function(i,t,r){return t>r},function(i,t,r,s){return s.compare(t,r)>0}),cc=Bn("<=",function(i,t,r){return t<=r},function(i,t,r,s){return s.compare(t,r)<=0}),rl=Bn(">=",function(i,t,r){return t>=r},function(i,t,r,s){return s.compare(t,r)>=0});class vs{constructor(t,r,s){this.type=Cr,this.locale=s,this.caseSensitive=t,this.diacriticSensitive=r}static parse(t,r){if(t.length!==2)return r.error("Expected one argument.");const s=t[1];if(typeof s!="object"||Array.isArray(s))return r.error("Collator options argument must be an object.");const l=r.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,$e);if(!l)return null;const u=r.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,$e);if(!u)return null;let d=null;return s.locale&&(d=r.parse(s.locale,1,Qe),!d)?null:new vs(l,u,d)}evaluate(t){return new Na(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class Ga{constructor(t,r,s,l,u){this.type=Qe,this.number=t,this.locale=r,this.currency=s,this.minFractionDigits=l,this.maxFractionDigits=u}static parse(t,r){if(t.length!==3)return r.error("Expected two arguments.");const s=r.parse(t[1],1,Te);if(!s)return null;const l=t[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let u=null;if(l.locale&&(u=r.parse(l.locale,1,Qe),!u))return null;let d=null;if(l.currency&&(d=r.parse(l.currency,1,Qe),!d))return null;let f=null;if(l["min-fraction-digits"]&&(f=r.parse(l["min-fraction-digits"],1,Te),!f))return null;let g=null;return l["max-fraction-digits"]&&(g=r.parse(l["max-fraction-digits"],1,Te),!g)?null:new Ga(s,u,d,f,g)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class Ks{constructor(t){this.type=Ur,this.sections=t}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");const s=t[1];if(!Array.isArray(s)&&typeof s=="object")return r.error("First argument must be an image or text section.");const l=[];let u=!1;for(let d=1;d<=t.length-1;++d){const f=t[d];if(u&&typeof f=="object"&&!Array.isArray(f)){u=!1;let g=null;if(f["font-scale"]&&(g=r.parse(f["font-scale"],1,Te),!g))return null;let x=null;if(f["text-font"]&&(x=r.parse(f["text-font"],1,A(Qe)),!x))return null;let v=null;if(f["text-color"]&&(v=r.parse(f["text-color"],1,Ci),!v))return null;const w=l[l.length-1];w.scale=g,w.font=x,w.textColor=v}else{const g=r.parse(t[d],1,We);if(!g)return null;const x=g.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");u=!0,l.push({content:g,scale:null,font:null,textColor:null})}}return new Ks(l)}evaluate(t){return new Ui(this.sections.map(r=>{const s=r.content.evaluate(t);return jt(s)===Mr?new Ua("",s,null,null,null):new Ua(_s(s),null,r.scale?r.scale.evaluate(t):null,r.font?r.font.evaluate(t).join(","):null,r.textColor?r.textColor.evaluate(t):null)}))}eachChild(t){for(const r of this.sections)t(r.content),r.scale&&t(r.scale),r.font&&t(r.font),r.textColor&&t(r.textColor)}outputDefined(){return!1}}class Ha{constructor(t){this.type=Mr,this.input=t}static parse(t,r){if(t.length!==2)return r.error("Expected two arguments.");const s=r.parse(t[1],1,Qe);return s?new Ha(s):r.error("No image name provided.")}evaluate(t){const r=this.input.evaluate(t),s=$i.fromString(r);return s&&t.availableImages&&(s.available=t.availableImages.indexOf(r)>-1),s}eachChild(t){t(this.input)}outputDefined(){return!1}}class Xa{constructor(t){this.type=Te,this.input=t}static parse(t,r){if(t.length!==2)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);const s=r.parse(t[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${P(s.type)} instead.`):new Xa(s):null}evaluate(t){const r=this.input.evaluate(t);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new Vt(`Expected value to be of type string or array, but found ${P(jt(r))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const kr=8192;function hc(i,t){const r=(180+i[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,l=Math.pow(2,t.z);return[Math.round(r*l*kr),Math.round(s*l*kr)]}function Wa(i,t){const r=Math.pow(2,t.z);return[(l=(i[0]/kr+t.x)/r,360*l-180),(s=(i[1]/kr+t.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,l}function gn(i,t){i[0]=Math.min(i[0],t[0]),i[1]=Math.min(i[1],t[1]),i[2]=Math.max(i[2],t[0]),i[3]=Math.max(i[3],t[1])}function en(i,t){return!(i[0]<=t[0]||i[2]>=t[2]||i[1]<=t[1]||i[3]>=t[3])}function pt(i,t,r){const s=i[0]-t[0],l=i[1]-t[1],u=i[0]-r[0],d=i[1]-r[1];return s*d-u*l==0&&s*u<=0&&l*d<=0}function Js(i,t,r,s){return(l=[s[0]-r[0],s[1]-r[1]])[0]*(u=[t[0]-i[0],t[1]-i[1]])[1]-l[1]*u[0]!=0&&!(!sl(i,t,r,s)||!sl(r,s,i,t));var l,u}function uc(i,t,r){for(const s of r)for(let l=0;l(l=i)[1]!=(d=f[g+1])[1]>l[1]&&l[0]<(d[0]-u[0])*(l[1]-u[1])/(d[1]-u[1])+u[0]&&(s=!s)}var l,u,d;return s}function dc(i,t){for(const r of t)if(Fn(i,r))return!0;return!1}function nl(i,t){for(const r of i)if(!Fn(r,t))return!1;for(let r=0;r0&&f<0||d<0&&f>0}function Ka(i,t,r){const s=[];for(let l=0;lr[2]){const l=.5*s;let u=i[0]-r[0]>l?-s:r[0]-i[0]>l?s:0;u===0&&(u=i[0]-r[2]>l?-s:r[2]-i[0]>l?s:0),i[0]+=u}gn(t,i)}function ll(i,t,r,s){const l=Math.pow(2,s.z)*kr,u=[s.x*kr,s.y*kr],d=[];for(const f of i)for(const g of f){const x=[g.x+u[0],g.y+u[1]];ol(x,t,r,l),d.push(x)}return d}function cl(i,t,r,s){const l=Math.pow(2,s.z)*kr,u=[s.x*kr,s.y*kr],d=[];for(const g of i){const x=[];for(const v of g){const w=[v.x+u[0],v.y+u[1]];gn(t,w),x.push(w)}d.push(x)}if(t[2]-t[0]<=l/2){(f=t)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const g of d)for(const x of g)ol(x,t,r,l)}var f;return d}class _n{constructor(t,r){this.type=$e,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(pn(t[1])){const s=t[1];if(s.type==="FeatureCollection"){const l=[];for(const u of s.features){const{type:d,coordinates:f}=u.geometry;d==="Polygon"&&l.push(f),d==="MultiPolygon"&&l.push(...f)}if(l.length)return new _n(s,{type:"MultiPolygon",coordinates:l})}else if(s.type==="Feature"){const l=s.geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new _n(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new _n(s,s)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(r,s){const l=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(s.type==="Polygon"){const f=Ka(s.coordinates,u,d),g=ll(r.geometry(),l,u,d);if(!en(l,u))return!1;for(const x of g)if(!Fn(x,f))return!1}if(s.type==="MultiPolygon"){const f=al(s.coordinates,u,d),g=ll(r.geometry(),l,u,d);if(!en(l,u))return!1;for(const x of g)if(!dc(x,f))return!1}return!0}(t,this.geometries);if(t.geometryType()==="LineString")return function(r,s){const l=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(s.type==="Polygon"){const f=Ka(s.coordinates,u,d),g=cl(r.geometry(),l,u,d);if(!en(l,u))return!1;for(const x of g)if(!nl(x,f))return!1}if(s.type==="MultiPolygon"){const f=al(s.coordinates,u,d),g=cl(r.geometry(),l,u,d);if(!en(l,u))return!1;for(const x of g)if(!pc(x,f))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let hl=class{constructor(i=[],t=(r,s)=>rs?1:0){if(this.data=i,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(i){this.data.push(i),this._up(this.length++)}pop(){if(this.length===0)return;const i=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:t,compare:r}=this,s=t[i];for(;i>0;){const l=i-1>>1,u=t[l];if(r(s,u)>=0)break;t[i]=u,i=l}t[i]=s}_down(i){const{data:t,compare:r}=this,s=this.length>>1,l=t[i];for(;i=0)break;t[i]=t[u],i=u}t[i]=l}};function fc(i,t,r,s,l){ul(i,t,r,s||i.length-1,l||mc)}function ul(i,t,r,s,l){for(;s>r;){if(s-r>600){var u=s-r+1,d=t-r+1,f=Math.log(u),g=.5*Math.exp(2*f/3),x=.5*Math.sqrt(f*g*(u-g)/u)*(d-u/2<0?-1:1);ul(i,t,Math.max(r,Math.floor(t-d*g/u+x)),Math.min(s,Math.floor(t+(u-d)*g/u+x)),l)}var v=i[t],w=r,I=s;for(bs(i,r,t),l(i[s],v)>0&&bs(i,r,s);w0;)I--}l(i[r],v)===0?bs(i,r,I):bs(i,++I,s),I<=t&&(r=I+1),t<=I&&(s=I-1)}}function bs(i,t,r){var s=i[t];i[t]=i[r],i[r]=s}function mc(i,t){return it?1:0}function Ys(i,t){if(i.length<=1)return[i];const r=[];let s,l;for(const u of i){const d=_c(u);d!==0&&(u.area=Math.abs(d),l===void 0&&(l=d<0),l===d<0?(s&&r.push(s),s=[u]):s.push(u))}if(s&&r.push(s),t>1)for(let u=0;u1?(x=t[g+1][0],v=t[g+1][1]):C>0&&(x+=w/this.kx*C,v+=I/this.ky*C)),w=this.wrap(r[0]-x)*this.kx,I=(r[1]-v)*this.ky;const E=w*w+I*I;E180;)t-=360;return t}}function ml(i,t){return t[0]-i[0]}function Qs(i){return i[1]-i[0]+1}function jr(i,t){return i[1]>=i[0]&&i[1]i[1])return[null,null];const r=Qs(i);if(t){if(r===2)return[i,null];const l=Math.floor(r/2);return[[i[0],i[0]+l],[i[0]+l,i[1]]]}if(r===1)return[i,null];const s=Math.floor(r/2)-1;return[[i[0],i[0]+s],[i[0]+s+1,i[1]]]}function Qa(i,t){if(!jr(t,i.length))return[1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let s=t[0];s<=t[1];++s)gn(r,i[s]);return r}function eo(i){const t=[1/0,1/0,-1/0,-1/0];for(const r of i)for(const s of r)gn(t,s);return t}function ea(i){return i[0]!==-1/0&&i[1]!==-1/0&&i[2]!==1/0&&i[3]!==1/0}function to(i,t,r){if(!ea(i)||!ea(t))return NaN;let s=0,l=0;return i[2]t[2]&&(s=i[0]-t[2]),i[1]>t[3]&&(l=i[1]-t[3]),i[3]=s)return s;if(en(l,u)){if(ta(i,t))return 0}else if(ta(t,i))return 0;let d=1/0;for(const f of i)for(let g=0,x=f.length,v=x-1;g0;){const g=d.pop();if(g[0]>=u)continue;const x=g[1],v=t?50:100;if(Qs(x)<=v){if(!jr(x,i.length))return NaN;if(t){const w=it(i,x,r,s);if(isNaN(w)||w===0)return w;u=Math.min(u,w)}else for(let w=x[0];w<=x[1];++w){const I=xc(i[w],r,s);if(u=Math.min(u,I),u===0)return 0}}else{const w=Ya(x,t);gt(d,u,s,i,f,w[0]),gt(d,u,s,i,f,w[1])}}return u}function Ts(i,t,r,s,l,u=1/0){let d=Math.min(u,l.distance(i[0],r[0]));if(d===0)return d;const f=new hl([[0,[0,i.length-1],[0,r.length-1]]],ml);for(;f.length>0;){const g=f.pop();if(g[0]>=d)continue;const x=g[1],v=g[2],w=t?50:100,I=s?50:100;if(Qs(x)<=w&&Qs(v)<=I){if(!jr(x,i.length)&&jr(v,r.length))return NaN;let C;if(t&&s)C=yc(i,x,r,v,l),d=Math.min(d,C);else if(t&&!s){const E=i.slice(x[0],x[1]+1);for(let z=v[0];z<=v[1];++z)if(C=yn(r[z],E,l),d=Math.min(d,C),d===0)return d}else if(!t&&s){const E=r.slice(v[0],v[1]+1);for(let z=x[0];z<=x[1];++z)if(C=yn(i[z],E,l),d=Math.min(d,C),d===0)return d}else C=Rt(i,x,r,v,l),d=Math.min(d,C)}else{const C=Ya(x,t),E=Ya(v,s);xn(f,d,l,i,r,C[0],E[0]),xn(f,d,l,i,r,C[0],E[1]),xn(f,d,l,i,r,C[1],E[0]),xn(f,d,l,i,r,C[1],E[1])}}return d}function ro(i){return i.type==="MultiPolygon"?i.coordinates.map(t=>({type:"Polygon",coordinates:t})):i.type==="MultiLineString"?i.coordinates.map(t=>({type:"LineString",coordinates:t})):i.type==="MultiPoint"?i.coordinates.map(t=>({type:"Point",coordinates:t})):[i]}class vn{constructor(t,r){this.type=Te,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(pn(t[1])){const s=t[1];if(s.type==="FeatureCollection")return new vn(s,s.features.map(l=>ro(l.geometry)).flat());if(s.type==="Feature")return new vn(s,ro(s.geometry));if("type"in s&&"coordinates"in s)return new vn(s,ro(s))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(r,s){const l=r.geometry(),u=l.flat().map(g=>Wa([g.x,g.y],r.canonical));if(l.length===0)return NaN;const d=new Ja(u[0][1]);let f=1/0;for(const g of s){switch(g.type){case"Point":f=Math.min(f,Ts(u,!1,[g.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,Ts(u,!1,g.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,ws(u,!1,g.coordinates,d,f))}if(f===0)return f}return f}(t,this.geometries);if(t.geometryType()==="LineString")return function(r,s){const l=r.geometry(),u=l.flat().map(g=>Wa([g.x,g.y],r.canonical));if(l.length===0)return NaN;const d=new Ja(u[0][1]);let f=1/0;for(const g of s){switch(g.type){case"Point":f=Math.min(f,Ts(u,!0,[g.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,Ts(u,!0,g.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,ws(u,!0,g.coordinates,d,f))}if(f===0)return f}return f}(t,this.geometries);if(t.geometryType()==="Polygon")return function(r,s){const l=r.geometry();if(l.length===0||l[0].length===0)return NaN;const u=Ys(l,0).map(g=>g.map(x=>x.map(v=>Wa([v.x,v.y],r.canonical)))),d=new Ja(u[0][0][0][1]);let f=1/0;for(const g of s)for(const x of u){switch(g.type){case"Point":f=Math.min(f,ws([g.coordinates],!1,x,d,f));break;case"LineString":f=Math.min(f,ws(g.coordinates,!0,x,d,f));break;case"Polygon":f=Math.min(f,vt(x,g.coordinates,d,f))}if(f===0)return f}return f}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const On={"==":oc,"!=":tl,">":lc,"<":il,">=":rl,"<=":cc,array:ur,at:$a,boolean:ur,case:Zs,coalesce:Xs,collator:vs,format:Ks,image:Ha,in:qa,"index-of":Ln,interpolate:ki,"interpolate-hcl":ki,"interpolate-lab":ki,length:Xa,let:Qr,literal:hr,match:Za,number:ur,"number-format":Ga,object:ur,slice:ys,step:Rn,string:ur,"to-boolean":dr,"to-color":dr,"to-number":dr,"to-string":dr,var:dt,within:_n,distance:vn};class Qi{constructor(t,r,s,l){this.name=t,this.type=r,this._evaluate=s,this.args=l}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,r){const s=t[0],l=Qi.definitions[s];if(!l)return r.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const u=Array.isArray(l)?l[0]:l.type,d=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,f=d.filter(([x])=>!Array.isArray(x)||x.length===t.length-1);let g=null;for(const[x,v]of f){g=new fn(r.registry,Ss,r.path,null,r.scope);const w=[];let I=!1;for(let C=1;C{return I=w,Array.isArray(I)?`(${I.map(P).join(", ")})`:`(${P(I.type)}...)`;var I}).join(" | "),v=[];for(let w=1;w{r=t?r&&Ss(s):r&&s instanceof hr}),!!r&&Is(i)&&Ps(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Is(i){if(i instanceof Qi&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof _n||i instanceof vn)return!1;let t=!0;return i.eachChild(r=>{t&&!Is(r)&&(t=!1)}),t}function Vn(i){if(i instanceof Qi&&i.name==="feature-state")return!1;let t=!0;return i.eachChild(r=>{t&&!Vn(r)&&(t=!1)}),t}function Ps(i,t){if(i instanceof Qi&&t.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild(s=>{r&&!Ps(s,t)&&(r=!1)}),r}function ia(i){return{result:"success",value:i}}function Nn(i){return{result:"error",value:i}}function Un(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function gl(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function oo(i){return!!i.expression&&i.expression.interpolated}function ct(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function ra(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function vc(i){return i}function _l(i,t){const r=t.type==="color",s=i.stops&&typeof i.stops[0][0]=="object",l=s||!(s||i.property!==void 0),u=i.type||(oo(t)?"exponential":"interval");if(r||t.type==="padding"){const v=r?mt.parse:ji.parse;(i=Pr({},i)).stops&&(i.stops=i.stops.map(w=>[w[0],v(w[1])])),i.default=v(i.default?i.default:t.default)}if(i.colorSpace&&(d=i.colorSpace)!=="rgb"&&d!=="hcl"&&d!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var d;let f,g,x;if(u==="exponential")f=xl;else if(u==="interval")f=na;else if(u==="categorical"){f=yl,g=Object.create(null);for(const v of i.stops)g[v[0]]=v[1];x=typeof i.stops[0][0]}else{if(u!=="identity")throw new Error(`Unknown function type "${u}"`);f=vl}if(s){const v={},w=[];for(let E=0;EE[0]),evaluate:({zoom:E},z)=>xl({stops:I,base:i.base},t,E).evaluate(E,z)}}if(l){const v=u==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:ki.interpolationFactor.bind(void 0,v),zoomStops:i.stops.map(w=>w[0]),evaluate:({zoom:w})=>f(i,t,w,g,x)}}return{kind:"source",evaluate(v,w){const I=w&&w.properties?w.properties[i.property]:void 0;return I===void 0?jn(i.default,t.default):f(i,t,I,g,x)}}}function jn(i,t,r){return i!==void 0?i:t!==void 0?t:r!==void 0?r:void 0}function yl(i,t,r,s,l){return jn(typeof r===l?s[r]:void 0,i.default,t.default)}function na(i,t,r){if(ct(r)!=="number")return jn(i.default,t.default);const s=i.stops.length;if(s===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[s-1][0])return i.stops[s-1][1];const l=Gs(i.stops.map(u=>u[0]),r);return i.stops[l][1]}function xl(i,t,r){const s=i.base!==void 0?i.base:1;if(ct(r)!=="number")return jn(i.default,t.default);const l=i.stops.length;if(l===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[l-1][0])return i.stops[l-1][1];const u=Gs(i.stops.map(v=>v[0]),r),d=function(v,w,I,C){const E=C-I,z=v-I;return E===0?0:w===1?z/E:(Math.pow(w,z)-1)/(Math.pow(w,E)-1)}(r,s,i.stops[u][0],i.stops[u+1][0]),f=i.stops[u][1],g=i.stops[u+1][1],x=Mi[t.type]||vc;return typeof f.evaluate=="function"?{evaluate(...v){const w=f.evaluate.apply(void 0,v),I=g.evaluate.apply(void 0,v);if(w!==void 0&&I!==void 0)return x(w,I,d,i.colorSpace)}}:x(f,g,d,i.colorSpace)}function vl(i,t,r){switch(t.type){case"color":r=mt.parse(r);break;case"formatted":r=Ui.fromString(r.toString());break;case"resolvedImage":r=$i.fromString(r.toString());break;case"padding":r=ji.parse(r);break;default:ct(r)===t.type||t.type==="enum"&&t.values[r]||(r=void 0)}return jn(r,i.default,t.default)}Qi.register(On,{error:[{kind:"error"},[Qe],(i,[t])=>{throw new Vt(t.evaluate(i))}],typeof:[Qe,[We],(i,[t])=>P(jt(t.evaluate(i)))],"to-rgba":[A(Te,4),[Ci],(i,[t])=>{const[r,s,l,u]=t.evaluate(i).rgb;return[255*r,255*s,255*l,u]}],rgb:[Ci,[Te,Te,Te],no],rgba:[Ci,[Te,Te,Te,Te],no],has:{type:$e,overloads:[[[Qe],(i,[t])=>so(t.evaluate(i),i.properties())],[[Qe,cr],(i,[t,r])=>so(t.evaluate(i),r.evaluate(i))]]},get:{type:We,overloads:[[[Qe],(i,[t])=>ao(t.evaluate(i),i.properties())],[[Qe,cr],(i,[t,r])=>ao(t.evaluate(i),r.evaluate(i))]]},"feature-state":[We,[Qe],(i,[t])=>ao(t.evaluate(i),i.featureState||{})],properties:[cr,[],i=>i.properties()],"geometry-type":[Qe,[],i=>i.geometryType()],id:[We,[],i=>i.id()],zoom:[Te,[],i=>i.globals.zoom],"heatmap-density":[Te,[],i=>i.globals.heatmapDensity||0],"line-progress":[Te,[],i=>i.globals.lineProgress||0],accumulated:[We,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[Te,bn(Te),(i,t)=>{let r=0;for(const s of t)r+=s.evaluate(i);return r}],"*":[Te,bn(Te),(i,t)=>{let r=1;for(const s of t)r*=s.evaluate(i);return r}],"-":{type:Te,overloads:[[[Te,Te],(i,[t,r])=>t.evaluate(i)-r.evaluate(i)],[[Te],(i,[t])=>-t.evaluate(i)]]},"/":[Te,[Te,Te],(i,[t,r])=>t.evaluate(i)/r.evaluate(i)],"%":[Te,[Te,Te],(i,[t,r])=>t.evaluate(i)%r.evaluate(i)],ln2:[Te,[],()=>Math.LN2],pi:[Te,[],()=>Math.PI],e:[Te,[],()=>Math.E],"^":[Te,[Te,Te],(i,[t,r])=>Math.pow(t.evaluate(i),r.evaluate(i))],sqrt:[Te,[Te],(i,[t])=>Math.sqrt(t.evaluate(i))],log10:[Te,[Te],(i,[t])=>Math.log(t.evaluate(i))/Math.LN10],ln:[Te,[Te],(i,[t])=>Math.log(t.evaluate(i))],log2:[Te,[Te],(i,[t])=>Math.log(t.evaluate(i))/Math.LN2],sin:[Te,[Te],(i,[t])=>Math.sin(t.evaluate(i))],cos:[Te,[Te],(i,[t])=>Math.cos(t.evaluate(i))],tan:[Te,[Te],(i,[t])=>Math.tan(t.evaluate(i))],asin:[Te,[Te],(i,[t])=>Math.asin(t.evaluate(i))],acos:[Te,[Te],(i,[t])=>Math.acos(t.evaluate(i))],atan:[Te,[Te],(i,[t])=>Math.atan(t.evaluate(i))],min:[Te,bn(Te),(i,t)=>Math.min(...t.map(r=>r.evaluate(i)))],max:[Te,bn(Te),(i,t)=>Math.max(...t.map(r=>r.evaluate(i)))],abs:[Te,[Te],(i,[t])=>Math.abs(t.evaluate(i))],round:[Te,[Te],(i,[t])=>{const r=t.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[Te,[Te],(i,[t])=>Math.floor(t.evaluate(i))],ceil:[Te,[Te],(i,[t])=>Math.ceil(t.evaluate(i))],"filter-==":[$e,[Qe,We],(i,[t,r])=>i.properties()[t.value]===r.value],"filter-id-==":[$e,[We],(i,[t])=>i.id()===t.value],"filter-type-==":[$e,[Qe],(i,[t])=>i.geometryType()===t.value],"filter-<":[$e,[Qe,We],(i,[t,r])=>{const s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s{const r=i.id(),s=t.value;return typeof r==typeof s&&r":[$e,[Qe,We],(i,[t,r])=>{const s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s>l}],"filter-id->":[$e,[We],(i,[t])=>{const r=i.id(),s=t.value;return typeof r==typeof s&&r>s}],"filter-<=":[$e,[Qe,We],(i,[t,r])=>{const s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s<=l}],"filter-id-<=":[$e,[We],(i,[t])=>{const r=i.id(),s=t.value;return typeof r==typeof s&&r<=s}],"filter->=":[$e,[Qe,We],(i,[t,r])=>{const s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s>=l}],"filter-id->=":[$e,[We],(i,[t])=>{const r=i.id(),s=t.value;return typeof r==typeof s&&r>=s}],"filter-has":[$e,[We],(i,[t])=>t.value in i.properties()],"filter-has-id":[$e,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[$e,[A(Qe)],(i,[t])=>t.value.indexOf(i.geometryType())>=0],"filter-id-in":[$e,[A(We)],(i,[t])=>t.value.indexOf(i.id())>=0],"filter-in-small":[$e,[Qe,A(We)],(i,[t,r])=>r.value.indexOf(i.properties()[t.value])>=0],"filter-in-large":[$e,[Qe,A(We)],(i,[t,r])=>function(s,l,u,d){for(;u<=d;){const f=u+d>>1;if(l[f]===s)return!0;l[f]>s?d=f-1:u=f+1}return!1}(i.properties()[t.value],r.value,0,r.value.length-1)],all:{type:$e,overloads:[[[$e,$e],(i,[t,r])=>t.evaluate(i)&&r.evaluate(i)],[bn($e),(i,t)=>{for(const r of t)if(!r.evaluate(i))return!1;return!0}]]},any:{type:$e,overloads:[[[$e,$e],(i,[t,r])=>t.evaluate(i)||r.evaluate(i)],[bn($e),(i,t)=>{for(const r of t)if(r.evaluate(i))return!0;return!1}]]},"!":[$e,[$e],(i,[t])=>!t.evaluate(i)],"is-supported-script":[$e,[Qe],(i,[t])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(t.evaluate(i))}],upcase:[Qe,[Qe],(i,[t])=>t.evaluate(i).toUpperCase()],downcase:[Qe,[Qe],(i,[t])=>t.evaluate(i).toLowerCase()],concat:[Qe,bn(We),(i,t)=>t.map(r=>_s(r.evaluate(i))).join("")],"resolved-locale":[Qe,[Cr],(i,[t])=>t.evaluate(i).resolvedLocale()]});class sa{constructor(t,r){var s;this.expression=t,this._warningHistory={},this._evaluator=new qs,this._defaultValue=r?(s=r).type==="color"&&ra(s.default)?new mt(0,0,0,0):s.type==="color"?mt.parse(s.default)||null:s.type==="padding"?ji.parse(s.default)||null:s.type==="variableAnchorOffsetCollection"?Yi.parse(s.default)||null:s.default===void 0?null:s.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._evaluator.globals=t,this._evaluator.feature=r,this._evaluator.featureState=s,this._evaluator.canonical=l,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=d,this.expression.evaluate(this._evaluator)}evaluate(t,r,s,l,u,d){this._evaluator.globals=t,this._evaluator.feature=r||null,this._evaluator.featureState=s||null,this._evaluator.canonical=l,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=d||null;try{const f=this.expression.evaluate(this._evaluator);if(f==null||typeof f=="number"&&f!=f)return this._defaultValue;if(this._enumValues&&!(f in this._enumValues))throw new Vt(`Expected value to be one of ${Object.keys(this._enumValues).map(g=>JSON.stringify(g)).join(", ")}, but found ${JSON.stringify(f)} instead.`);return f}catch(f){return this._warningHistory[f.message]||(this._warningHistory[f.message]=!0,typeof console<"u"&&console.warn(f.message)),this._defaultValue}}}function aa(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in On}function $n(i,t){const r=new fn(On,Ss,[],t?function(l){const u={color:Ci,string:Qe,number:Te,enum:Qe,boolean:$e,formatted:Ur,padding:Yr,resolvedImage:Mr,variableAnchorOffsetCollection:U};return l.type==="array"?A(u[l.value]||We,l.length):u[l.type]}(t):void 0),s=r.parse(i,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return s?ia(new sa(s,t)):Nn(r.errors)}class qn{constructor(t,r){this.kind=t,this._styleExpression=r,this.isStateDependent=t!=="constant"&&!Vn(r.expression)}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,u,d)}evaluate(t,r,s,l,u,d){return this._styleExpression.evaluate(t,r,s,l,u,d)}}class Zn{constructor(t,r,s,l){this.kind=t,this.zoomStops=s,this._styleExpression=r,this.isStateDependent=t!=="camera"&&!Vn(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,u,d)}evaluate(t,r,s,l,u,d){return this._styleExpression.evaluate(t,r,s,l,u,d)}interpolationFactor(t,r,s){return this.interpolationType?ki.interpolationFactor(this.interpolationType,t,r,s):0}}function lo(i,t){const r=$n(i,t);if(r.result==="error")return r;const s=r.value.expression,l=Is(s);if(!l&&!Un(t))return Nn([new xi("","data expressions not supported")]);const u=Ps(s,["zoom"]);if(!u&&!gl(t))return Nn([new xi("","zoom expressions not supported")]);const d=As(s);return d||u?d instanceof xi?Nn([d]):d instanceof ki&&!oo(t)?Nn([new xi("",'"interpolate" expressions cannot be used with this property')]):ia(d?new Zn(l?"camera":"composite",r.value,d.labels,d instanceof ki?d.interpolation:void 0):new qn(l?"constant":"source",r.value)):Nn([new xi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Gn{constructor(t,r){this._parameters=t,this._specification=r,Pr(this,_l(this._parameters,this._specification))}static deserialize(t){return new Gn(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function As(i){let t=null;if(i instanceof Qr)t=As(i.result);else if(i instanceof Xs){for(const r of i.args)if(t=As(r),t)break}else(i instanceof Rn||i instanceof ki)&&i.input instanceof Qi&&i.input.name==="zoom"&&(t=i);return t instanceof xi||i.eachChild(r=>{const s=As(r);s instanceof xi?t=s:!t&&s?t=new xi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&s&&t!==s&&(t=new xi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function oa(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const t of i.slice(1))if(!oa(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}const la={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function co(i){if(i==null)return{filter:()=>!0,needGeometry:!1};oa(i)||(i=ca(i));const t=$n(i,la);if(t.result==="error")throw new Error(t.value.map(r=>`${r.key}: ${r.message}`).join(", "));return{filter:(r,s,l)=>t.value.evaluate(r,s,{},l),needGeometry:bl(i)}}function bc(i,t){return it?1:0}function bl(i){if(!Array.isArray(i))return!1;if(i[0]==="within"||i[0]==="distance")return!0;for(let t=1;t"||t==="<="||t===">="?ho(i[1],i[2],t):t==="any"?(r=i.slice(1),["any"].concat(r.map(ca))):t==="all"?["all"].concat(i.slice(1).map(ca)):t==="none"?["all"].concat(i.slice(1).map(ca).map(ai)):t==="in"?Cs(i[1],i.slice(2)):t==="!in"?ai(Cs(i[1],i.slice(2))):t==="has"?Ms(i[1]):t!=="!has"||ai(Ms(i[1]));var r}function ho(i,t,r){switch(i){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,i,t]}}function Cs(i,t){if(t.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(r=>typeof r!=typeof t[0])?["filter-in-large",i,["literal",t.sort(bc)]]:["filter-in-small",i,["literal",t]]}}function Ms(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function ai(i){return["!",i]}function wn(i){const t=typeof i;if(t==="number"||t==="boolean"||t==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let l="[";for(const u of i)l+=`${wn(u)},`;return`${l}]`}const r=Object.keys(i).sort();let s="{";for(let l=0;ls.maximum?[new xe(t,r,`${r} is greater than the maximum value ${s.maximum}`)]:[]}function ha(i){const t=i.valueSpec,r=Bt(i.value.type);let s,l,u,d={};const f=r!=="categorical"&&i.value.property===void 0,g=!f,x=ct(i.value.stops)==="array"&&ct(i.value.stops[0])==="array"&&ct(i.value.stops[0][0])==="object",v=qi({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(C){if(r==="identity")return[new xe(C.key,C.value,'identity function may not have a "stops" property')];let E=[];const z=C.value;return E=E.concat(ks({key:C.key,value:z,valueSpec:C.valueSpec,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec,arrayElementValidator:w})),ct(z)==="array"&&z.length===0&&E.push(new xe(C.key,z,"array must have at least one stop")),E},default:function(C){return C.validateSpec({key:C.key,value:C.value,valueSpec:t,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec})}}});return r==="identity"&&f&&v.push(new xe(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||v.push(new xe(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!oo(i.valueSpec)&&v.push(new xe(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(g&&!Un(i.valueSpec)?v.push(new xe(i.key,i.value,"property functions not supported")):f&&!gl(i.valueSpec)&&v.push(new xe(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!x||i.value.property!==void 0||v.push(new xe(i.key,i.value,'"property" property is required')),v;function w(C){let E=[];const z=C.value,O=C.key;if(ct(z)!=="array")return[new xe(O,z,`array expected, ${ct(z)} found`)];if(z.length!==2)return[new xe(O,z,`array length 2 expected, length ${z.length} found`)];if(x){if(ct(z[0])!=="object")return[new xe(O,z,`object expected, ${ct(z[0])} found`)];if(z[0].zoom===void 0)return[new xe(O,z,"object stop key must have zoom")];if(z[0].value===void 0)return[new xe(O,z,"object stop key must have value")];if(u&&u>Bt(z[0].zoom))return[new xe(O,z[0].zoom,"stop zoom values must appear in ascending order")];Bt(z[0].zoom)!==u&&(u=Bt(z[0].zoom),l=void 0,d={}),E=E.concat(qi({key:`${O}[0]`,value:z[0],valueSpec:{zoom:{}},validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec,objectElementValidators:{zoom:uo,value:I}}))}else E=E.concat(I({key:`${O}[0]`,value:z[0],valueSpec:{},validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec},z));return aa(pr(z[1]))?E.concat([new xe(`${O}[1]`,z[1],"expressions are not allowed in function stops.")]):E.concat(C.validateSpec({key:`${O}[1]`,value:z[1],valueSpec:t,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec}))}function I(C,E){const z=ct(C.value),O=Bt(C.value),$=C.value!==null?C.value:E;if(s){if(z!==s)return[new xe(C.key,$,`${z} stop domain type must match previous stop domain type ${s}`)]}else s=z;if(z!=="number"&&z!=="string"&&z!=="boolean")return[new xe(C.key,$,"stop domain value must be a number, string, or boolean")];if(z!=="number"&&r!=="categorical"){let ne=`number expected, ${z} found`;return Un(t)&&r===void 0&&(ne+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new xe(C.key,$,ne)]}return r!=="categorical"||z!=="number"||isFinite(O)&&Math.floor(O)===O?r!=="categorical"&&z==="number"&&l!==void 0&&Onew xe(`${i.key}${s.key}`,i.value,s.message));const r=t.value.expression||t.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new xe(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if(i.expressionContext==="property"&&i.propertyType==="layout"&&!Vn(r))return[new xe(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!Vn(r))return[new xe(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!Ps(r,["zoom","feature-state"]))return[new xe(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!Is(r))return[new xe(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function $r(i){const t=i.key,r=i.value,s=i.valueSpec,l=[];return Array.isArray(s.values)?s.values.indexOf(Bt(r))===-1&&l.push(new xe(t,r,`expected one of [${s.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(s.values).indexOf(Bt(r))===-1&&l.push(new xe(t,r,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function po(i){return oa(pr(i.value))?Hn(Pr({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):ua(i)}function ua(i){const t=i.value,r=i.key;if(ct(t)!=="array")return[new xe(r,t,`array expected, ${ct(t)} found`)];const s=i.styleSpec;let l,u=[];if(t.length<1)return[new xe(r,t,"filter array must have at least 1 element")];switch(u=u.concat($r({key:`${r}[0]`,value:t[0],valueSpec:s.filter_operator,style:i.style,styleSpec:i.styleSpec})),Bt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&Bt(t[1])==="$type"&&u.push(new xe(r,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&u.push(new xe(r,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(l=ct(t[1]),l!=="string"&&u.push(new xe(`${r}[1]`,t[1],`string expected, ${l} found`)));for(let d=2;d{x in r&&t.push(new xe(s,r[x],`"${x}" is prohibited for ref layers`))}),l.layers.forEach(x=>{Bt(x.id)===f&&(g=x)}),g?g.ref?t.push(new xe(s,r.ref,"ref cannot reference another ref layer")):d=Bt(g.type):t.push(new xe(s,r.ref,`ref layer "${f}" not found`))}else if(d!=="background")if(r.source){const g=l.sources&&l.sources[r.source],x=g&&Bt(g.type);g?x==="vector"&&d==="raster"?t.push(new xe(s,r.source,`layer "${r.id}" requires a raster source`)):x!=="raster-dem"&&d==="hillshade"?t.push(new xe(s,r.source,`layer "${r.id}" requires a raster-dem source`)):x==="raster"&&d!=="raster"?t.push(new xe(s,r.source,`layer "${r.id}" requires a vector source`)):x!=="vector"||r["source-layer"]?x==="raster-dem"&&d!=="hillshade"?t.push(new xe(s,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):d!=="line"||!r.paint||!r.paint["line-gradient"]||x==="geojson"&&g.lineMetrics||t.push(new xe(s,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new xe(s,r,`layer "${r.id}" must specify a "source-layer"`)):t.push(new xe(s,r.source,`source "${r.source}" not found`))}else t.push(new xe(s,r,'missing required property "source"'));return t=t.concat(qi({key:s,value:r,valueSpec:u.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${s}.type`,value:r.type,valueSpec:u.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:po,layout:g=>qi({layer:r,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>mo(Pr({layerType:d},x))}}),paint:g=>qi({layer:r,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>da(Pr({layerType:d},x))}})}})),t}function Tn(i){const t=i.value,r=i.key,s=ct(t);return s!=="string"?[new xe(r,t,`string expected, ${s} found`)]:[]}const pa={promoteId:function({key:i,value:t}){if(ct(t)==="string")return Tn({key:i,value:t});{const r=[];for(const s in t)r.push(...Tn({key:`${i}.${s}`,value:t[s]}));return r}}};function Es(i){const t=i.value,r=i.key,s=i.styleSpec,l=i.style,u=i.validateSpec;if(!t.type)return[new xe(r,t,'"type" is required')];const d=Bt(t.type);let f;switch(d){case"vector":case"raster":return f=qi({key:r,value:t,valueSpec:s[`source_${d.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:pa,validateSpec:u}),f;case"raster-dem":return f=function(g){var x;const v=(x=g.sourceName)!==null&&x!==void 0?x:"",w=g.value,I=g.styleSpec,C=I.source_raster_dem,E=g.style;let z=[];const O=ct(w);if(w===void 0)return z;if(O!=="object")return z.push(new xe("source_raster_dem",w,`object expected, ${O} found`)),z;const $=Bt(w.encoding)==="custom",ne=["redFactor","greenFactor","blueFactor","baseShift"],W=g.value.encoding?`"${g.value.encoding}"`:"Default";for(const te in w)!$&&ne.includes(te)?z.push(new xe(te,w[te],`In "${v}": "${te}" is only valid when "encoding" is set to "custom". ${W} encoding found`)):C[te]?z=z.concat(g.validateSpec({key:te,value:w[te],valueSpec:C[te],validateSpec:g.validateSpec,style:E,styleSpec:I})):z.push(new xe(te,w[te],`unknown property "${te}"`));return z}({sourceName:r,value:t,style:i.style,styleSpec:s,validateSpec:u}),f;case"geojson":if(f=qi({key:r,value:t,valueSpec:s.source_geojson,style:l,styleSpec:s,validateSpec:u,objectElementValidators:pa}),t.cluster)for(const g in t.clusterProperties){const[x,v]=t.clusterProperties[g],w=typeof x=="string"?[x,["accumulated"],["get",g]]:x;f.push(...Hn({key:`${r}.${g}.map`,value:v,validateSpec:u,expressionContext:"cluster-map"})),f.push(...Hn({key:`${r}.${g}.reduce`,value:w,validateSpec:u,expressionContext:"cluster-reduce"}))}return f;case"video":return qi({key:r,value:t,valueSpec:s.source_video,style:l,validateSpec:u,styleSpec:s});case"image":return qi({key:r,value:t,valueSpec:s.source_image,style:l,validateSpec:u,styleSpec:s});case"canvas":return[new xe(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return $r({key:`${r}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:l,validateSpec:u,styleSpec:s})}}function _o(i){const t=i.value,r=i.styleSpec,s=r.light,l=i.style;let u=[];const d=ct(t);if(t===void 0)return u;if(d!=="object")return u=u.concat([new xe("light",t,`object expected, ${d} found`)]),u;for(const f in t){const g=f.match(/^(.*)-transition$/);u=u.concat(g&&s[g[1]]&&s[g[1]].transition?i.validateSpec({key:f,value:t[f],valueSpec:r.transition,validateSpec:i.validateSpec,style:l,styleSpec:r}):s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new xe(f,t[f],`unknown property "${f}"`)])}return u}function yo(i){const t=i.value,r=i.styleSpec,s=r.sky,l=i.style,u=ct(t);if(t===void 0)return[];if(u!=="object")return[new xe("sky",t,`object expected, ${u} found`)];let d=[];for(const f in t)d=d.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],style:l,styleSpec:r}):[new xe(f,t[f],`unknown property "${f}"`)]);return d}function xo(i){const t=i.value,r=i.styleSpec,s=r.terrain,l=i.style;let u=[];const d=ct(t);if(t===void 0)return u;if(d!=="object")return u=u.concat([new xe("terrain",t,`object expected, ${d} found`)]),u;for(const f in t)u=u.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new xe(f,t[f],`unknown property "${f}"`)]);return u}function vo(i){let t=[];const r=i.value,s=i.key;if(Array.isArray(r)){const l=[],u=[];for(const d in r)r[d].id&&l.includes(r[d].id)&&t.push(new xe(s,r,`all the sprites' ids must be unique, but ${r[d].id} is duplicated`)),l.push(r[d].id),r[d].url&&u.includes(r[d].url)&&t.push(new xe(s,r,`all the sprites' URLs must be unique, but ${r[d].url} is duplicated`)),u.push(r[d].url),t=t.concat(qi({key:`${s}[${d}]`,value:r[d],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return t}return Tn({key:s,value:r})}const fa={"*":()=>[],array:ks,boolean:function(i){const t=i.value,r=i.key,s=ct(t);return s!=="boolean"?[new xe(r,t,`boolean expected, ${s} found`)]:[]},number:uo,color:function(i){const t=i.key,r=i.value,s=ct(r);return s!=="string"?[new xe(t,r,`color expected, ${s} found`)]:mt.parse(String(r))?[]:[new xe(t,r,`color expected, "${r}" found`)]},constants:Tl,enum:$r,filter:po,function:ha,layer:go,object:qi,source:Es,light:_o,sky:yo,terrain:xo,projection:function(i){const t=i.value,r=i.styleSpec,s=r.projection,l=i.style,u=ct(t);if(t===void 0)return[];if(u!=="object")return[new xe("projection",t,`object expected, ${u} found`)];let d=[];for(const f in t)d=d.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],style:l,styleSpec:r}):[new xe(f,t[f],`unknown property "${f}"`)]);return d},string:Tn,formatted:function(i){return Tn(i).length===0?[]:Hn(i)},resolvedImage:function(i){return Tn(i).length===0?[]:Hn(i)},padding:function(i){const t=i.key,r=i.value;if(ct(r)==="array"){if(r.length<1||r.length>4)return[new xe(t,r,`padding requires 1 to 4 values; ${r.length} values found`)];const s={type:"number"};let l=[];for(let u=0;u[]}})),i.constants&&(r=r.concat(Tl({key:"constants",value:i.constants,style:i,styleSpec:t,validateSpec:Xn}))),bo(r)}function Er(i){return function(t){return i({...t,validateSpec:Xn})}}function bo(i){return[].concat(i).sort((t,r)=>t.line-r.line)}function fr(i){return function(...t){return bo(i.apply(this,t))}}er.source=fr(Er(Es)),er.sprite=fr(Er(vo)),er.glyphs=fr(Er(Sl)),er.light=fr(Er(_o)),er.sky=fr(Er(yo)),er.terrain=fr(Er(xo)),er.layer=fr(Er(go)),er.filter=fr(Er(po)),er.paintProperty=fr(Er(da)),er.layoutProperty=fr(Er(mo));const Sn=er,wc=Sn.light,Tc=Sn.sky,Il=Sn.paintProperty,Pl=Sn.layoutProperty;function wo(i,t){let r=!1;if(t&&t.length)for(const s of t)i.fire(new Wr(new Error(s.message))),r=!0;return r}class Wn{constructor(t,r,s){const l=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const d=new Int32Array(this.arrayBuffer);t=d[0],this.d=(r=d[1])+2*(s=d[2]);for(let g=0;g=w[E+0]&&l>=w[E+1])?(f[C]=!0,d.push(v[C])):f[C]=!1}}}}_forEachCell(t,r,s,l,u,d,f,g){const x=this._convertToCellCoord(t),v=this._convertToCellCoord(r),w=this._convertToCellCoord(s),I=this._convertToCellCoord(l);for(let C=x;C<=w;C++)for(let E=v;E<=I;E++){const z=this.d*E+C;if((!g||g(this._convertFromCellCoord(C),this._convertFromCellCoord(E),this._convertFromCellCoord(C+1),this._convertFromCellCoord(E+1)))&&u.call(this,t,r,s,l,z,d,f,g))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,r=3+this.cells.length+1+1;let s=0;for(let d=0;d=0)continue;const d=i[u];l[u]=tr[r].shallow.indexOf(u)>=0?d:Kn(d,t)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(l.$name=r),l}function Jn(i){if(Al(i))return i;if(Array.isArray(i))return i.map(Jn);if(typeof i!="object")throw new Error("can't deserialize object of type "+typeof i);const t=To(i)||"Object";if(!tr[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:r}=tr[t];if(!r)throw new Error(`can't deserialize unregistered class ${t}`);if(r.deserialize)return r.deserialize(i);const s=Object.create(r.prototype);for(const l of Object.keys(i)){if(l==="$name")continue;const u=i[l];s[l]=tr[t].shallow.indexOf(l)>=0?u:Jn(u)}return s}class So{constructor(){this.first=!0}update(t,r){const s=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=128&&i<=255,"Hangul Jamo":i=>i>=4352&&i<=4607,Khmer:i=>i>=6016&&i<=6143,"General Punctuation":i=>i>=8192&&i<=8303,"Letterlike Symbols":i=>i>=8448&&i<=8527,"Number Forms":i=>i>=8528&&i<=8591,"Miscellaneous Technical":i=>i>=8960&&i<=9215,"Control Pictures":i=>i>=9216&&i<=9279,"Optical Character Recognition":i=>i>=9280&&i<=9311,"Enclosed Alphanumerics":i=>i>=9312&&i<=9471,"Geometric Shapes":i=>i>=9632&&i<=9727,"Miscellaneous Symbols":i=>i>=9728&&i<=9983,"Miscellaneous Symbols and Arrows":i=>i>=11008&&i<=11263,"Ideographic Description Characters":i=>i>=12272&&i<=12287,"CJK Symbols and Punctuation":i=>i>=12288&&i<=12351,Katakana:i=>i>=12448&&i<=12543,Kanbun:i=>i>=12688&&i<=12703,"CJK Strokes":i=>i>=12736&&i<=12783,"Enclosed CJK Letters and Months":i=>i>=12800&&i<=13055,"CJK Compatibility":i=>i>=13056&&i<=13311,"Yijing Hexagram Symbols":i=>i>=19904&&i<=19967,"Private Use Area":i=>i>=57344&&i<=63743,"Vertical Forms":i=>i>=65040&&i<=65055,"CJK Compatibility Forms":i=>i>=65072&&i<=65103,"Small Form Variants":i=>i>=65104&&i<=65135,"Halfwidth and Fullwidth Forms":i=>i>=65280&&i<=65519};function Io(i){for(const t of i)if(Ao(t.charCodeAt(0)))return!0;return!1}function Sc(i){for(const t of i)if(!Yn(t.charCodeAt(0)))return!1;return!0}function Po(i){const t=i.map(r=>{try{return new RegExp(`\\p{sc=${r}}`,"u").source}catch{return null}}).filter(r=>r);return new RegExp(t.join("|"),"u")}const Ic=Po(["Arab","Dupl","Mong","Ougr","Syrc"]);function Yn(i){return!Ic.test(String.fromCodePoint(i))}const Cl=Po(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function Ao(i){return!(i!==746&&i!==747&&(i<4352||!(st["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||st["CJK Compatibility"](i)||st["CJK Strokes"](i)||!(!st["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||st["Enclosed CJK Letters and Months"](i)||st["Ideographic Description Characters"](i)||st.Kanbun(i)||st.Katakana(i)&&i!==12540||!(!st["Halfwidth and Fullwidth Forms"](i)||i===65288||i===65289||i===65293||i>=65306&&i<=65310||i===65339||i===65341||i===65343||i>=65371&&i<=65503||i===65507||i>=65512&&i<=65519)||!(!st["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||st["Vertical Forms"](i)||st["Yijing Hexagram Symbols"](i)||new RegExp("\\p{sc=Cans}","u").test(String.fromCodePoint(i))||new RegExp("\\p{sc=Hang}","u").test(String.fromCodePoint(i))||Cl.test(String.fromCodePoint(i)))))}function Ml(i){return!(Ao(i)||function(t){return!!(st["Latin-1 Supplement"](t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||st["General Punctuation"](t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||st["Letterlike Symbols"](t)||st["Number Forms"](t)||st["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||st["Control Pictures"](t)&&t!==9251||st["Optical Character Recognition"](t)||st["Enclosed Alphanumerics"](t)||st["Geometric Shapes"](t)||st["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||st["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||st["CJK Symbols and Punctuation"](t)||st.Katakana(t)||st["Private Use Area"](t)||st["CJK Compatibility Forms"](t)||st["Small Form Variants"](t)||st["Halfwidth and Fullwidth Forms"](t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)}(i))}const Pc=Po(["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 Co(i){return Pc.test(String.fromCodePoint(i))}function Ac(i,t){return!(!t&&Co(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||st.Khmer(i))}function Cc(i){for(const t of i)if(Co(t.charCodeAt(0)))return!0;return!1}const Zi=new class{constructor(){this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null}setState(i){this.pluginStatus=i.pluginStatus,this.pluginURL=i.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(i){this.applyArabicShaping=i.applyArabicShaping,this.processBidirectionalText=i.processBidirectionalText,this.processStyledBidirectionalText=i.processStyledBidirectionalText}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getPluginURL(){return this.pluginURL}getRTLTextPluginStatus(){return this.pluginStatus}};class wt{constructor(t,r){this.zoom=t,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new So,this.transition={})}isSupportedScript(t){return function(r,s){for(const l of r)if(!Ac(l.charCodeAt(0),s))return!1;return!0}(t,Zi.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,r=t-Math.floor(t),s=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*r}}}class Qn{constructor(t,r){this.property=t,this.value=r,this.expression=function(s,l){if(ra(s))return new Gn(s,l);if(aa(s)){const u=lo(s,l);if(u.result==="error")throw new Error(u.value.map(d=>`${d.key}: ${d.message}`).join(", "));return u.value}{let u=s;return l.type==="color"&&typeof s=="string"?u=mt.parse(s):l.type!=="padding"||typeof s!="number"&&!Array.isArray(s)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(s)&&(u=Yi.parse(s)):u=ji.parse(s),{kind:"constant",evaluate:()=>u}}}(r===void 0?t.specification.default:r,t.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(t,r,s){return this.property.possiblyEvaluate(this,t,r,s)}}class ga{constructor(t){this.property=t,this.value=new Qn(t,void 0)}transitioned(t,r){return new kl(this.property,this.value,r,gi({},t.transition,this.transition),t.now)}untransitioned(){return new kl(this.property,this.value,null,{},0)}}class _a{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return et(this._values[t].value.value)}setValue(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ga(this._values[t].property)),this._values[t].value=new Qn(this._values[t].property,r===null?void 0:et(r))}getTransition(t){return et(this._values[t].transition)}setTransition(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ga(this._values[t].property)),this._values[t].transition=et(r)||void 0}serialize(){const t={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(t[r]=s);const l=this.getTransition(r);l!==void 0&&(t[`${r}-transition`]=l)}return t}transitioned(t,r){const s=new zs(this._properties);for(const l of Object.keys(this._values))s._values[l]=this._values[l].transitioned(t,r._values[l]);return s}untransitioned(){const t=new zs(this._properties);for(const r of Object.keys(this._values))t._values[r]=this._values[r].untransitioned();return t}}class kl{constructor(t,r,s,l,u){this.property=t,this.value=r,this.begin=u+l.delay||0,this.end=this.begin+l.duration||0,t.specification.transition&&(l.delay||l.duration)&&(this.prior=s)}possiblyEvaluate(t,r,s){const l=t.now||0,u=this.value.possiblyEvaluate(t,r,s),d=this.prior;if(d){if(l>this.end)return this.prior=null,u;if(this.value.isDataDriven())return this.prior=null,u;if(l=1)return 1;const x=g*g,v=x*g;return 4*(g<.5?v:3*(g-x)+v-.75)}(f))}}return u}}class zs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,r,s){const l=new Ls(this._properties);for(const u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(t,r,s);return l}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class Ds{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return this._values[t].value!==void 0}getValue(t){return et(this._values[t].value)}setValue(t,r){this._values[t]=new Qn(this._values[t].property,r===null?void 0:et(r))}serialize(){const t={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(t[r]=s)}return t}possiblyEvaluate(t,r,s){const l=new Ls(this._properties);for(const u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(t,r,s);return l}}class zr{constructor(t,r,s){this.property=t,this.value=r,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,r,s,l){return this.property.evaluate(this.value,this.parameters,t,r,s,l)}}class Ls{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Le{constructor(t){this.specification=t}possiblyEvaluate(t,r){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(r)}interpolate(t,r,s){const l=Mi[this.specification.type];return l?l(t,r,s):t}}class je{constructor(t,r){this.specification=t,this.overrides=r}possiblyEvaluate(t,r,s,l){return new zr(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(r,null,{},s,l)}:t.expression,r)}interpolate(t,r,s){if(t.value.kind!=="constant"||r.value.kind!=="constant")return t;if(t.value.value===void 0||r.value.value===void 0)return new zr(this,{kind:"constant",value:void 0},t.parameters);const l=Mi[this.specification.type];if(l){const u=l(t.value.value,r.value.value,s);return new zr(this,{kind:"constant",value:u},t.parameters)}return t}evaluate(t,r,s,l,u,d){return t.kind==="constant"?t.value:t.evaluate(r,s,l,u,d)}}class ya extends je{possiblyEvaluate(t,r,s,l){if(t.value===void 0)return new zr(this,{kind:"constant",value:void 0},r);if(t.expression.kind==="constant"){const u=t.expression.evaluate(r,null,{},s,l),d=t.property.specification.type==="resolvedImage"&&typeof u!="string"?u.name:u,f=this._calculate(d,d,d,r);return new zr(this,{kind:"constant",value:f},r)}if(t.expression.kind==="camera"){const u=this._calculate(t.expression.evaluate({zoom:r.zoom-1}),t.expression.evaluate({zoom:r.zoom}),t.expression.evaluate({zoom:r.zoom+1}),r);return new zr(this,{kind:"constant",value:u},r)}return new zr(this,t.expression,r)}evaluate(t,r,s,l,u,d){if(t.kind==="source"){const f=t.evaluate(r,s,l,u,d);return this._calculate(f,f,f,r)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(r.zoom)-1},s,l),t.evaluate({zoom:Math.floor(r.zoom)},s,l),t.evaluate({zoom:Math.floor(r.zoom)+1},s,l),r):t.value}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class xa{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){if(t.value!==void 0){if(t.expression.kind==="constant"){const u=t.expression.evaluate(r,null,{},s,l);return this._calculate(u,u,u,r)}return this._calculate(t.expression.evaluate(new wt(Math.floor(r.zoom-1),r)),t.expression.evaluate(new wt(Math.floor(r.zoom),r)),t.expression.evaluate(new wt(Math.floor(r.zoom+1),r)),r)}}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class Mo{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){return!!t.expression.evaluate(r,null,{},s,l)}interpolate(){return!1}}class h{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in t){const s=t[r];s.specification.overridable&&this.overridableProperties.push(r);const l=this.defaultPropertyValues[r]=new Qn(s,void 0),u=this.defaultTransitionablePropertyValues[r]=new ga(s);this.defaultTransitioningPropertyValues[r]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}ze("DataDrivenProperty",je),ze("DataConstantProperty",Le),ze("CrossFadedDataDrivenProperty",ya),ze("CrossFadedProperty",xa),ze("ColorRampProperty",Mo);const e="-transition";class n extends kn{constructor(t,r){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),r.layout&&(this._unevaluatedLayout=new Ds(r.layout)),r.paint)){this._transitionablePaint=new _a(r.paint);for(const s in t.paint)this.setPaintProperty(s,t.paint[s],{validate:!1});for(const s in t.layout)this.setLayoutProperty(s,t.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ls(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,r,s={}){r!=null&&this._validate(Pl,`layers.${this.id}.layout.${t}`,t,r,s)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,r):this.visibility=r)}getPaintProperty(t){return t.endsWith(e)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,r,s={}){if(r!=null&&this._validate(Il,`layers.${this.id}.paint.${t}`,t,r,s))return!1;if(t.endsWith(e))return this._transitionablePaint.setTransition(t.slice(0,-11),r||void 0),!1;{const l=this._transitionablePaint._values[t],u=l.property.specification["property-type"]==="cross-faded-data-driven",d=l.value.isDataDriven(),f=l.value;this._transitionablePaint.setValue(t,r),this._handleSpecialPaintPropertyUpdate(t);const g=this._transitionablePaint._values[t].value;return g.isDataDriven()||d||u||this._handleOverridablePaintPropertyUpdate(t,f,g)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,r,s){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||this.visibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,r){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,r)}serialize(){const t={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&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),Or(t,(r,s)=>!(r===void 0||s==="layout"&&!Object.keys(r).length||s==="paint"&&!Object.keys(r).length))}_validate(t,r,s,l,u={}){return(!u||u.validate!==!1)&&wo(this,t.call(Sn,{key:r,layerType:this.type,objectKey:s,value:l,styleSpec:le,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const r=this.paint.get(t);if(r instanceof zr&&Un(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const a={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class o{constructor(t,r){this._structArray=t,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class c{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,r){return t._trim(),r&&(t.isTransferred=!0,r.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const r=Object.create(this.prototype);return r.arrayBuffer=t.arrayBuffer,r.length=t.length,r.capacity=t.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function m(i,t=1){let r=0,s=0;return{members:i.map(l=>{const u=a[l.type].BYTES_PER_ELEMENT,d=r=_(r,Math.max(t,u)),f=l.components||1;return s=Math.max(s,u),r+=u*f,{name:l.name,type:l.type,components:f,offset:d}}),size:_(r,Math.max(s,t)),alignment:t}}function _(i,t){return Math.ceil(i/t)*t}class y extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){const l=2*t;return this.int16[l+0]=r,this.int16[l+1]=s,t}}y.prototype.bytesPerElement=4,ze("StructArrayLayout2i4",y);class b extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const u=3*t;return this.int16[u+0]=r,this.int16[u+1]=s,this.int16[u+2]=l,t}}b.prototype.bytesPerElement=6,ze("StructArrayLayout3i6",b);class T extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,r,s,l)}emplace(t,r,s,l,u){const d=4*t;return this.int16[d+0]=r,this.int16[d+1]=s,this.int16[d+2]=l,this.int16[d+3]=u,t}}T.prototype.bytesPerElement=8,ze("StructArrayLayout4i8",T);class S extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){const f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){const g=6*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.int16[g+2]=l,this.int16[g+3]=u,this.int16[g+4]=d,this.int16[g+5]=f,t}}S.prototype.bytesPerElement=12,ze("StructArrayLayout2i4i12",S);class k extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){const f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){const g=4*t,x=8*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.uint8[x+4]=l,this.uint8[x+5]=u,this.uint8[x+6]=d,this.uint8[x+7]=f,t}}k.prototype.bytesPerElement=8,ze("StructArrayLayout2i4ub8",k);class D extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){const l=2*t;return this.float32[l+0]=r,this.float32[l+1]=s,t}}D.prototype.bytesPerElement=8,ze("StructArrayLayout2f8",D);class B extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d,f,g,x,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,r,s,l,u,d,f,g,x,v)}emplace(t,r,s,l,u,d,f,g,x,v,w){const I=10*t;return this.uint16[I+0]=r,this.uint16[I+1]=s,this.uint16[I+2]=l,this.uint16[I+3]=u,this.uint16[I+4]=d,this.uint16[I+5]=f,this.uint16[I+6]=g,this.uint16[I+7]=x,this.uint16[I+8]=v,this.uint16[I+9]=w,t}}B.prototype.bytesPerElement=20,ze("StructArrayLayout10ui20",B);class N extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d,f,g,x,v,w,I){const C=this.length;return this.resize(C+1),this.emplace(C,t,r,s,l,u,d,f,g,x,v,w,I)}emplace(t,r,s,l,u,d,f,g,x,v,w,I,C){const E=12*t;return this.int16[E+0]=r,this.int16[E+1]=s,this.int16[E+2]=l,this.int16[E+3]=u,this.uint16[E+4]=d,this.uint16[E+5]=f,this.uint16[E+6]=g,this.uint16[E+7]=x,this.int16[E+8]=v,this.int16[E+9]=w,this.int16[E+10]=I,this.int16[E+11]=C,t}}N.prototype.bytesPerElement=24,ze("StructArrayLayout4i4ui4i24",N);class q extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const u=3*t;return this.float32[u+0]=r,this.float32[u+1]=s,this.float32[u+2]=l,t}}q.prototype.bytesPerElement=12,ze("StructArrayLayout3f12",q);class Z extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint32[1*t+0]=r,t}}Z.prototype.bytesPerElement=4,ze("StructArrayLayout1ul4",Z);class X extends c{_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(t,r,s,l,u,d,f,g,x){const v=this.length;return this.resize(v+1),this.emplace(v,t,r,s,l,u,d,f,g,x)}emplace(t,r,s,l,u,d,f,g,x,v){const w=10*t,I=5*t;return this.int16[w+0]=r,this.int16[w+1]=s,this.int16[w+2]=l,this.int16[w+3]=u,this.int16[w+4]=d,this.int16[w+5]=f,this.uint32[I+3]=g,this.uint16[w+8]=x,this.uint16[w+9]=v,t}}X.prototype.bytesPerElement=20,ze("StructArrayLayout6i1ul2ui20",X);class F extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){const f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){const g=6*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.int16[g+2]=l,this.int16[g+3]=u,this.int16[g+4]=d,this.int16[g+5]=f,t}}F.prototype.bytesPerElement=12,ze("StructArrayLayout2i2i2i12",F);class Y extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u){const d=this.length;return this.resize(d+1),this.emplace(d,t,r,s,l,u)}emplace(t,r,s,l,u,d){const f=4*t,g=8*t;return this.float32[f+0]=r,this.float32[f+1]=s,this.float32[f+2]=l,this.int16[g+6]=u,this.int16[g+7]=d,t}}Y.prototype.bytesPerElement=16,ze("StructArrayLayout2f1f2i16",Y);class ee extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){const f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){const g=16*t,x=4*t,v=8*t;return this.uint8[g+0]=r,this.uint8[g+1]=s,this.float32[x+1]=l,this.float32[x+2]=u,this.int16[v+6]=d,this.int16[v+7]=f,t}}ee.prototype.bytesPerElement=16,ze("StructArrayLayout2ub2f2i16",ee);class ae extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const u=3*t;return this.uint16[u+0]=r,this.uint16[u+1]=s,this.uint16[u+2]=l,t}}ae.prototype.bytesPerElement=6,ze("StructArrayLayout3ui6",ae);class fe extends c{_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(t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$){const ne=this.length;return this.resize(ne+1),this.emplace(ne,t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$)}emplace(t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$,ne){const W=24*t,te=12*t,ce=48*t;return this.int16[W+0]=r,this.int16[W+1]=s,this.uint16[W+2]=l,this.uint16[W+3]=u,this.uint32[te+2]=d,this.uint32[te+3]=f,this.uint32[te+4]=g,this.uint16[W+10]=x,this.uint16[W+11]=v,this.uint16[W+12]=w,this.float32[te+7]=I,this.float32[te+8]=C,this.uint8[ce+36]=E,this.uint8[ce+37]=z,this.uint8[ce+38]=O,this.uint32[te+10]=$,this.int16[W+22]=ne,t}}fe.prototype.bytesPerElement=48,ze("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",fe);class _e extends c{_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(t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$,ne,W,te,ce,ge,Me,Ue,Ae,Ie,Fe,De){const Ee=this.length;return this.resize(Ee+1),this.emplace(Ee,t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$,ne,W,te,ce,ge,Me,Ue,Ae,Ie,Fe,De)}emplace(t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$,ne,W,te,ce,ge,Me,Ue,Ae,Ie,Fe,De,Ee){const pe=32*t,Oe=16*t;return this.int16[pe+0]=r,this.int16[pe+1]=s,this.int16[pe+2]=l,this.int16[pe+3]=u,this.int16[pe+4]=d,this.int16[pe+5]=f,this.int16[pe+6]=g,this.int16[pe+7]=x,this.uint16[pe+8]=v,this.uint16[pe+9]=w,this.uint16[pe+10]=I,this.uint16[pe+11]=C,this.uint16[pe+12]=E,this.uint16[pe+13]=z,this.uint16[pe+14]=O,this.uint16[pe+15]=$,this.uint16[pe+16]=ne,this.uint16[pe+17]=W,this.uint16[pe+18]=te,this.uint16[pe+19]=ce,this.uint16[pe+20]=ge,this.uint16[pe+21]=Me,this.uint16[pe+22]=Ue,this.uint32[Oe+12]=Ae,this.float32[Oe+13]=Ie,this.float32[Oe+14]=Fe,this.uint16[pe+30]=De,this.uint16[pe+31]=Ee,t}}_e.prototype.bytesPerElement=64,ze("StructArrayLayout8i15ui1ul2f2ui64",_e);class Pe extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.float32[1*t+0]=r,t}}Pe.prototype.bytesPerElement=4,ze("StructArrayLayout1f4",Pe);class ke extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const u=3*t;return this.uint16[6*t+0]=r,this.float32[u+1]=s,this.float32[u+2]=l,t}}ke.prototype.bytesPerElement=12,ze("StructArrayLayout1ui2f12",ke);class we extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const u=4*t;return this.uint32[2*t+0]=r,this.uint16[u+2]=s,this.uint16[u+3]=l,t}}we.prototype.bytesPerElement=8,ze("StructArrayLayout1ul2ui8",we);class be extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){const l=2*t;return this.uint16[l+0]=r,this.uint16[l+1]=s,t}}be.prototype.bytesPerElement=4,ze("StructArrayLayout2ui4",be);class Re extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint16[1*t+0]=r,t}}Re.prototype.bytesPerElement=2,ze("StructArrayLayout1ui2",Re);class Xe extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,r,s,l)}emplace(t,r,s,l,u){const d=4*t;return this.float32[d+0]=r,this.float32[d+1]=s,this.float32[d+2]=l,this.float32[d+3]=u,t}}Xe.prototype.bytesPerElement=16,ze("StructArrayLayout4f16",Xe);class Se extends o{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 de(this.anchorPointX,this.anchorPointY)}}Se.prototype.size=20;class Ce extends X{get(t){return new Se(this,t)}}ze("CollisionBoxArray",Ce);class qe extends o{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(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}qe.prototype.size=48;class Tt extends fe{get(t){return new qe(this,t)}}ze("PlacedSymbolArray",Tt);class Ye extends o{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(t){this._structArray.uint32[this._pos4+12]=t}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]}}Ye.prototype.size=64;class nt extends _e{get(t){return new Ye(this,t)}}ze("SymbolInstanceArray",nt);class St extends Pe{getoffsetX(t){return this.float32[1*t+0]}}ze("GlyphOffsetArray",St);class oi extends b{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}ze("SymbolLineVertexArray",oi);class mr extends o{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]}}mr.prototype.size=12;class It extends ke{get(t){return new mr(this,t)}}ze("TextAnchorOffsetArray",It);class Ei extends o{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]}}Ei.prototype.size=8;class bi extends we{get(t){return new Ei(this,t)}}ze("FeatureIndexArray",bi);class li extends y{}class wi extends y{}class Dr extends y{}class es extends S{}class va extends k{}class ts extends D{}class ir extends B{}class ba extends N{}class ko extends q{}class rr extends Z{}class nr extends F{}class tn extends ee{}class gr extends ae{}class ei extends be{}const ci=m([{name:"a_pos",components:2,type:"Int16"}],4),{members:Gi}=ci;class at{constructor(t=[]){this.segments=t}prepareSegment(t,r,s,l){let u=this.segments[this.segments.length-1];return t>at.MAX_VERTEX_ARRAY_LENGTH&&Gt(`Max vertices per segment is ${at.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!u||u.vertexLength+t>at.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==l)&&(u={vertexOffset:r.length,primitiveOffset:s.length,vertexLength:0,primitiveLength:0},l!==void 0&&(u.sortKey=l),this.segments.push(u)),u}get(){return this.segments}destroy(){for(const t of this.segments)for(const r in t.vaos)t.vaos[r].destroy()}static simpleSegment(t,r,s,l){return new at([{vertexOffset:t,primitiveOffset:r,vertexLength:s,primitiveLength:l,vaos:{},sortKey:0}])}}function In(i,t){return 256*(i=mi(Math.floor(i),0,255))+mi(Math.floor(t),0,255)}at.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ze("SegmentVector",at);const is=m([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var rs={exports:{}},El={exports:{}};El.exports=function(i,t){var r,s,l,u,d,f,g,x;for(s=i.length-(r=3&i.length),l=t,d=3432918353,f=461845907,x=0;x>>16)*d&65535)<<16)&4294967295)<<15|g>>>17))*f+(((g>>>16)*f&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(g=0,r){case 3:g^=(255&i.charCodeAt(x+2))<<16;case 2:g^=(255&i.charCodeAt(x+1))<<8;case 1:l^=g=(65535&(g=(g=(65535&(g^=255&i.charCodeAt(x)))*d+(((g>>>16)*d&65535)<<16)&4294967295)<<15|g>>>17))*f+(((g>>>16)*f&65535)<<16)&4294967295}return l^=i.length,l=2246822507*(65535&(l^=l>>>16))+((2246822507*(l>>>16)&65535)<<16)&4294967295,l=3266489909*(65535&(l^=l>>>13))+((3266489909*(l>>>16)&65535)<<16)&4294967295,(l^=l>>>16)>>>0};var Mc=El.exports,zl={exports:{}};zl.exports=function(i,t){for(var r,s=i.length,l=t^s,u=0;s>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(u)|(255&i.charCodeAt(++u))<<8|(255&i.charCodeAt(++u))<<16|(255&i.charCodeAt(++u))<<24))+((1540483477*(r>>>16)&65535)<<16),l=1540483477*(65535&l)+((1540483477*(l>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),s-=4,++u;switch(s){case 3:l^=(255&i.charCodeAt(u+2))<<16;case 2:l^=(255&i.charCodeAt(u+1))<<8;case 1:l=1540483477*(65535&(l^=255&i.charCodeAt(u)))+((1540483477*(l>>>16)&65535)<<16)}return l=1540483477*(65535&(l^=l>>>13))+((1540483477*(l>>>16)&65535)<<16),(l^=l>>>15)>>>0};var rn=Mc,Dl=zl.exports;rs.exports=rn,rs.exports.murmur3=rn,rs.exports.murmur2=Dl;var wa=Je(rs.exports);class Rs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,r,s,l){this.ids.push(Ta(t)),this.positions.push(r,s,l)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=Ta(t);let s=0,l=this.ids.length-1;for(;s>1;this.ids[d]>=r?l=d:s=d+1}const u=[];for(;this.ids[s]===r;)u.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return u}static serialize(t,r){const s=new Float64Array(t.ids),l=new Uint32Array(t.positions);return Sa(s,l,0,s.length-1),r&&r.push(s.buffer,l.buffer),{ids:s,positions:l}}static deserialize(t){const r=new Rs;return r.ids=t.ids,r.positions=t.positions,r.indexed=!0,r}}function Ta(i){const t=+i;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:wa(String(i))}function Sa(i,t,r,s){for(;r>1];let u=r-1,d=s+1;for(;;){do u++;while(i[u]l);if(u>=d)break;ns(i,u,d),ns(t,3*u,3*d),ns(t,3*u+1,3*d+1),ns(t,3*u+2,3*d+2)}d-r`u_${l}`),this.type=s}setUniform(t,r,s){t.set(s.constantOr(this.value))}getBinding(t,r,s){return this.type==="color"?new Mh(t,r):new Ll(t,r)}}class Ia{constructor(t,r){this.uniformNames=r.map(s=>`u_${s}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=t.tlbr}setUniform(t,r,s,l){const u=l==="u_pattern_to"?this.patternTo:l==="u_pattern_from"?this.patternFrom:l==="u_pixel_ratio_to"?this.pixelRatioTo:l==="u_pixel_ratio_from"?this.pixelRatioFrom:null;u&&t.set(u)}getBinding(t,r,s){return s.substr(0,9)==="u_pattern"?new Ch(t,r):new Ll(t,r)}}class Pn{constructor(t,r,s,l){this.expression=t,this.type=s,this.maxValue=0,this.paintVertexAttributes=r.map(u=>({name:`a_${u}`,type:"Float32",components:s==="color"?2:1,offset:0})),this.paintVertexArray=new l}populatePaintArray(t,r,s,l,u){const d=this.paintVertexArray.length,f=this.expression.evaluate(new wt(0),r,{},l,[],u);this.paintVertexArray.resize(t),this._setPaintValue(d,t,f)}updatePaintArray(t,r,s,l){const u=this.expression.evaluate({zoom:0},s,l);this._setPaintValue(t,r,u)}_setPaintValue(t,r,s){if(this.type==="color"){const l=kc(s);for(let u=t;u`u_${f}_t`),this.type=s,this.useIntegerZoom=l,this.zoom=u,this.maxValue=0,this.paintVertexAttributes=r.map(f=>({name:`a_${f}`,type:"Float32",components:s==="color"?4:2,offset:0})),this.paintVertexArray=new d}populatePaintArray(t,r,s,l,u){const d=this.expression.evaluate(new wt(this.zoom),r,{},l,[],u),f=this.expression.evaluate(new wt(this.zoom+1),r,{},l,[],u),g=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(g,t,d,f)}updatePaintArray(t,r,s,l){const u=this.expression.evaluate({zoom:this.zoom},s,l),d=this.expression.evaluate({zoom:this.zoom+1},s,l);this._setPaintValue(t,r,u,d)}_setPaintValue(t,r,s,l){if(this.type==="color"){const u=kc(s),d=kc(l);for(let f=t;f`#define HAS_UNIFORM_${l}`))}return t}getBinderAttributes(){const t=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof Pn||s instanceof qr)for(let l=0;l!0){this.programConfigurations={};for(const l of t)this.programConfigurations[l.id]=new kh(l,r,s);this.needsUpload=!1,this._featureMap=new Rs,this._bufferOffset=0}populatePaintArrays(t,r,s,l,u,d){for(const f in this.programConfigurations)this.programConfigurations[f].populatePaintArrays(t,r,l,u,d);r.id!==void 0&&this._featureMap.add(r.id,s,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,r,s,l){for(const u of s)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(t,this._featureMap,r,u,l)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function Dd(i,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[i]||[i.replace(`${t}-`,"").replace(/-/g,"_")]}function Eh(i,t,r){const s={color:{source:D,composite:Xe},number:{source:Pe,composite:D}},l=function(u){return{"line-pattern":{source:ir,composite:ir},"fill-pattern":{source:ir,composite:ir},"fill-extrusion-pattern":{source:ir,composite:ir}}[u]}(i);return l&&l[r]||s[t][r]}ze("ConstantBinder",Eo),ze("CrossFadedConstantBinder",Ia),ze("SourceExpressionBinder",Pn),ze("CrossFadedCompositeBinder",ss),ze("CompositeExpressionBinder",qr),ze("ProgramConfiguration",kh,{omit:["_buffers"]}),ze("ProgramConfigurationSet",Fs);const $t=8192,Ec=Math.pow(2,14)-1,zh=-Ec-1;function Os(i){const t=$t/i.extent,r=i.loadGeometry();for(let s=0;sd.x+1||gd.y+1)&&Gt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function Vs(i,t){return{type:i.type,id:i.id,properties:i.properties,geometry:t?Os(i):[]}}function Rl(i,t,r,s,l){i.emplaceBack(2*t+(s+1)/2,2*r+(l+1)/2)}class zc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new wi,this.indexArray=new gr,this.segments=new at,this.programConfigurations=new Fs(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){const l=this.layers[0],u=[];let d=null,f=!1;l.type==="circle"&&(d=l.layout.get("circle-sort-key"),f=!d.isConstant());for(const{feature:g,id:x,index:v,sourceLayerIndex:w}of t){const I=this.layers[0]._featureFilter.needGeometry,C=Vs(g,I);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom),C,s))continue;const E=f?d.evaluate(C,{},s):void 0,z={id:x,properties:g.properties,type:g.type,sourceLayerIndex:w,index:v,geometry:I?C.geometry:Os(g),patterns:{},sortKey:E};u.push(z)}f&&u.sort((g,x)=>g.sortKey-x.sortKey);for(const g of u){const{geometry:x,index:v,sourceLayerIndex:w}=g,I=t[v].feature;this.addFeature(g,x,v,s),r.featureIndex.insert(I,x,v,w,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Gi),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,r,s,l){for(const u of r)for(const d of u){const f=d.x,g=d.y;if(f<0||f>=$t||g<0||g>=$t)continue;const x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),v=x.vertexLength;Rl(this.layoutVertexArray,f,g,-1,-1),Rl(this.layoutVertexArray,f,g,1,-1),Rl(this.layoutVertexArray,f,g,1,1),Rl(this.layoutVertexArray,f,g,-1,1),this.indexArray.emplaceBack(v,v+1,v+2),this.indexArray.emplaceBack(v,v+3,v+2),x.vertexLength+=4,x.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{},l)}}function Dh(i,t){for(let r=0;r1){if(Dc(i,t))return!0;for(let s=0;s1?r:r.sub(t)._mult(l)._add(t))}function Bh(i,t){let r,s,l,u=!1;for(let d=0;dt.y!=l.y>t.y&&t.x<(l.x-s.x)*(t.y-s.y)/(l.y-s.y)+s.x&&(u=!u)}return u}function Pa(i,t){let r=!1;for(let s=0,l=i.length-1;st.y!=d.y>t.y&&t.x<(d.x-u.x)*(t.y-u.y)/(d.y-u.y)+u.x&&(r=!r)}return r}function Fd(i,t,r){const s=r[0],l=r[2];if(i.xl.x&&t.x>l.x||i.yl.y&&t.y>l.y)return!1;const u=Jt(i,t,r[0]);return u!==Jt(i,t,r[1])||u!==Jt(i,t,r[2])||u!==Jt(i,t,r[3])}function zo(i,t,r){const s=t.paint.get(i).value;return s.kind==="constant"?s.value:r.programConfigurations.get(t.id).getMaxValue(i)}function Bl(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Fl(i,t,r,s,l){if(!t[0]&&!t[1])return i;const u=de.convert(t)._mult(l);r==="viewport"&&u._rotate(-s);const d=[];for(let f=0;fNh(O,z))}(x,g),C=w?v*f:v;for(const E of l)for(const z of E){const O=w?z:Nh(z,g);let $=C;const ne=Ol([],[z.x,z.y,0,1],g);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?$*=ne[3]/d.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&($*=d.cameraToCenterDistance/ne[3]),Ld(I,O,$))return!0}return!1}}function Nh(i,t){const r=Ol([],[i.x,i.y,0,1],t);return new de(r[0]/r[3],r[1]/r[3])}class Uh extends zc{}let jh;ze("HeatmapBucket",Uh,{omit:["layers"]});var Ud={get paint(){return jh=jh||new h({"heatmap-radius":new je(le.paint_heatmap["heatmap-radius"]),"heatmap-weight":new je(le.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Le(le.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Mo(le.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Le(le.paint_heatmap["heatmap-opacity"])})}};function Bc(i,{width:t,height:r},s,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==t*r*s)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${t*r*s}`)}else l=new Uint8Array(t*r*s);return i.width=t,i.height=r,i.data=l,i}function $h(i,{width:t,height:r},s){if(t===i.width&&r===i.height)return;const l=Bc({},{width:t,height:r},s);Fc(i,l,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,t),height:Math.min(i.height,r)},s),i.width=t,i.height=r,i.data=l.data}function Fc(i,t,r,s,l,u){if(l.width===0||l.height===0)return t;if(l.width>i.width||l.height>i.height||r.x>i.width-l.width||r.y>i.height-l.height)throw new RangeError("out of range source coordinates for image copy");if(l.width>t.width||l.height>t.height||s.x>t.width-l.width||s.y>t.height-l.height)throw new RangeError("out of range destination coordinates for image copy");const d=i.data,f=t.data;if(d===f)throw new Error("srcData equals dstData, so image is already copied");for(let g=0;g{t[i.evaluationKey]=g;const x=i.expression.evaluate(t);l.data[d+f+0]=Math.floor(255*x.r/x.a),l.data[d+f+1]=Math.floor(255*x.g/x.a),l.data[d+f+2]=Math.floor(255*x.b/x.a),l.data[d+f+3]=Math.floor(255*x.a)};if(i.clips)for(let d=0,f=0;d80*r){f=1/0,g=1/0;let v=-1/0,w=-1/0;for(let I=r;Iv&&(v=C),E>w&&(w=E)}x=Math.max(v-f,w-g),x=x!==0?32767/x:0}return Ro(u,d,r,f,g,x,0),d}function Hh(i,t,r,s,l){let u;if(l===function(d,f,g,x){let v=0;for(let w=f,I=g-x;w0)for(let d=t;d=t;d-=s)u=Kh(d/s|0,i[d],i[d+1],u);return u&&Vl(u,u.next)&&(Fo(u),u=u.next),u}function Ns(i,t){if(!i)return i;t||(t=i);let r,s=i;do if(r=!1,s.steiner||!Vl(s,s.next)&&Nt(s.prev,s,s.next)!==0)s=s.next;else{if(Fo(s),s=t=s.prev,s===s.next)break;r=!0}while(r||s!==t);return t}function Ro(i,t,r,s,l,u,d){if(!i)return;!d&&u&&function(g,x,v,w){let I=g;do I.z===0&&(I.z=Vc(I.x,I.y,x,v,w)),I.prevZ=I.prev,I.nextZ=I.next,I=I.next;while(I!==g);I.prevZ.nextZ=null,I.prevZ=null,function(C){let E,z=1;do{let O,$=C;C=null;let ne=null;for(E=0;$;){E++;let W=$,te=0;for(let ge=0;ge0||ce>0&&W;)te!==0&&(ce===0||!W||$.z<=W.z)?(O=$,$=$.nextZ,te--):(O=W,W=W.nextZ,ce--),ne?ne.nextZ=O:C=O,O.prevZ=ne,ne=O;$=W}ne.nextZ=null,z*=2}while(E>1)}(I)}(i,s,l,u);let f=i;for(;i.prev!==i.next;){const g=i.prev,x=i.next;if(u?Xd(i,s,l,u):Hd(i))t.push(g.i,i.i,x.i),Fo(i),i=x.next,f=x.next;else if((i=x)===f){d?d===1?Ro(i=Wd(Ns(i),t),t,r,s,l,u,2):d===2&&Kd(i,t,r,s,l,u):Ro(Ns(i),t,r,s,l,u,1);break}}}function Hd(i){const t=i.prev,r=i,s=i.next;if(Nt(t,r,s)>=0)return!1;const l=t.x,u=r.x,d=s.x,f=t.y,g=r.y,x=s.y,v=lu?l>d?l:d:u>d?u:d,C=f>g?f>x?f:x:g>x?g:x;let E=s.next;for(;E!==t;){if(E.x>=v&&E.x<=I&&E.y>=w&&E.y<=C&&Ca(l,f,u,g,d,x,E.x,E.y)&&Nt(E.prev,E,E.next)>=0)return!1;E=E.next}return!0}function Xd(i,t,r,s){const l=i.prev,u=i,d=i.next;if(Nt(l,u,d)>=0)return!1;const f=l.x,g=u.x,x=d.x,v=l.y,w=u.y,I=d.y,C=fg?f>x?f:x:g>x?g:x,O=v>w?v>I?v:I:w>I?w:I,$=Vc(C,E,t,r,s),ne=Vc(z,O,t,r,s);let W=i.prevZ,te=i.nextZ;for(;W&&W.z>=$&&te&&te.z<=ne;){if(W.x>=C&&W.x<=z&&W.y>=E&&W.y<=O&&W!==l&&W!==d&&Ca(f,v,g,w,x,I,W.x,W.y)&&Nt(W.prev,W,W.next)>=0||(W=W.prevZ,te.x>=C&&te.x<=z&&te.y>=E&&te.y<=O&&te!==l&&te!==d&&Ca(f,v,g,w,x,I,te.x,te.y)&&Nt(te.prev,te,te.next)>=0))return!1;te=te.nextZ}for(;W&&W.z>=$;){if(W.x>=C&&W.x<=z&&W.y>=E&&W.y<=O&&W!==l&&W!==d&&Ca(f,v,g,w,x,I,W.x,W.y)&&Nt(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;te&&te.z<=ne;){if(te.x>=C&&te.x<=z&&te.y>=E&&te.y<=O&&te!==l&&te!==d&&Ca(f,v,g,w,x,I,te.x,te.y)&&Nt(te.prev,te,te.next)>=0)return!1;te=te.nextZ}return!0}function Wd(i,t){let r=i;do{const s=r.prev,l=r.next.next;!Vl(s,l)&&Xh(s,r,r.next,l)&&Bo(s,l)&&Bo(l,s)&&(t.push(s.i,r.i,l.i),Fo(r),Fo(r.next),r=i=l),r=r.next}while(r!==i);return Ns(r)}function Kd(i,t,r,s,l,u){let d=i;do{let f=d.next.next;for(;f!==d.prev;){if(d.i!==f.i&&tp(d,f)){let g=Wh(d,f);return d=Ns(d,d.next),g=Ns(g,g.next),Ro(d,t,r,s,l,u,0),void Ro(g,t,r,s,l,u,0)}f=f.next}d=d.next}while(d!==i)}function Jd(i,t){return i.x-t.x}function Yd(i,t){const r=function(l,u){let d=u;const f=l.x,g=l.y;let x,v=-1/0;do{if(g<=d.y&&g>=d.next.y&&d.next.y!==d.y){const z=d.x+(g-d.y)*(d.next.x-d.x)/(d.next.y-d.y);if(z<=f&&z>v&&(v=z,x=d.x=d.x&&d.x>=I&&f!==d.x&&Ca(gx.x||d.x===x.x&&Qd(x,d)))&&(x=d,E=z)}d=d.next}while(d!==w);return x}(i,t);if(!r)return t;const s=Wh(r,i);return Ns(s,s.next),Ns(r,r.next)}function Qd(i,t){return Nt(i.prev,i,t.prev)<0&&Nt(t.next,i,i.next)<0}function Vc(i,t,r,s,l){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*l|0)|i<<8))|i<<4))|i<<2))|i<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*l|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ep(i){let t=i,r=i;do(t.x=(i-d)*(u-f)&&(i-d)*(s-f)>=(r-d)*(t-f)&&(r-d)*(u-f)>=(l-d)*(s-f)}function tp(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!function(r,s){let l=r;do{if(l.i!==r.i&&l.next.i!==r.i&&l.i!==s.i&&l.next.i!==s.i&&Xh(l,l.next,r,s))return!0;l=l.next}while(l!==r);return!1}(i,t)&&(Bo(i,t)&&Bo(t,i)&&function(r,s){let l=r,u=!1;const d=(r.x+s.x)/2,f=(r.y+s.y)/2;do l.y>f!=l.next.y>f&&l.next.y!==l.y&&d<(l.next.x-l.x)*(f-l.y)/(l.next.y-l.y)+l.x&&(u=!u),l=l.next;while(l!==r);return u}(i,t)&&(Nt(i.prev,i,t.prev)||Nt(i,t.prev,t))||Vl(i,t)&&Nt(i.prev,i,i.next)>0&&Nt(t.prev,t,t.next)>0)}function Nt(i,t,r){return(t.y-i.y)*(r.x-t.x)-(t.x-i.x)*(r.y-t.y)}function Vl(i,t){return i.x===t.x&&i.y===t.y}function Xh(i,t,r,s){const l=Ul(Nt(i,t,r)),u=Ul(Nt(i,t,s)),d=Ul(Nt(r,s,i)),f=Ul(Nt(r,s,t));return l!==u&&d!==f||!(l!==0||!Nl(i,r,t))||!(u!==0||!Nl(i,s,t))||!(d!==0||!Nl(r,i,s))||!(f!==0||!Nl(r,t,s))}function Nl(i,t,r){return t.x<=Math.max(i.x,r.x)&&t.x>=Math.min(i.x,r.x)&&t.y<=Math.max(i.y,r.y)&&t.y>=Math.min(i.y,r.y)}function Ul(i){return i>0?1:i<0?-1:0}function Bo(i,t){return Nt(i.prev,i,i.next)<0?Nt(i,t,i.next)>=0&&Nt(i,i.prev,t)>=0:Nt(i,t,i.prev)<0||Nt(i,i.next,t)<0}function Wh(i,t){const r=Nc(i.i,i.x,i.y),s=Nc(t.i,t.x,t.y),l=i.next,u=t.prev;return i.next=t,t.prev=i,r.next=l,l.prev=r,s.next=r,r.prev=s,u.next=s,s.prev=u,s}function Kh(i,t,r,s){const l=Nc(i,t,r);return s?(l.next=s.next,l.prev=s,s.next.prev=l,s.next=l):(l.prev=l,l.next=l),l}function Fo(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Nc(i,t,r){return{i,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Uc(i,t,r){const s=r.patternDependencies;let l=!1;for(const u of t){const d=u.paint.get(`${i}-pattern`);d.isConstant()||(l=!0);const f=d.constantOr(null);f&&(l=!0,s[f.to]=!0,s[f.from]=!0)}return l}function jc(i,t,r,s,l){const u=l.patternDependencies;for(const d of t){const f=d.paint.get(`${i}-pattern`).value;if(f.kind!=="constant"){let g=f.evaluate({zoom:s-1},r,{},l.availableImages),x=f.evaluate({zoom:s},r,{},l.availableImages),v=f.evaluate({zoom:s+1},r,{},l.availableImages);g=g&&g.name?g.name:g,x=x&&x.name?x.name:x,v=v&&v.name?v.name:v,u[g]=!0,u[x]=!0,u[v]=!0,r.patterns[d.id]={min:g,mid:x,max:v}}}return r}class $c{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Dr,this.indexArray=new gr,this.indexArray2=new ei,this.programConfigurations=new Fs(t.layers,t.zoom),this.segments=new at,this.segments2=new at,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.hasPattern=Uc("fill",this.layers,r);const l=this.layers[0].layout.get("fill-sort-key"),u=!l.isConstant(),d=[];for(const{feature:f,id:g,index:x,sourceLayerIndex:v}of t){const w=this.layers[0]._featureFilter.needGeometry,I=Vs(f,w);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom),I,s))continue;const C=u?l.evaluate(I,{},s,r.availableImages):void 0,E={id:g,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?I.geometry:Os(f),patterns:{},sortKey:C};d.push(E)}u&&d.sort((f,g)=>f.sortKey-g.sortKey);for(const f of d){const{geometry:g,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){const w=jc("fill",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,g,x,s,{});r.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Gd),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,r,s,l,u){for(const d of Ys(r,500)){let f=0;for(const C of d)f+=C.length;const g=this.segments.prepareSegment(f,this.layoutVertexArray,this.indexArray),x=g.vertexLength,v=[],w=[];for(const C of d){if(C.length===0)continue;C!==d[0]&&w.push(v.length/2);const E=this.segments2.prepareSegment(C.length,this.layoutVertexArray,this.indexArray2),z=E.vertexLength;this.layoutVertexArray.emplaceBack(C[0].x,C[0].y),this.indexArray2.emplaceBack(z+C.length-1,z),v.push(C[0].x),v.push(C[0].y);for(let O=1;O>3}if(l--,s===1||s===2)u+=i.readSVarint(),d+=i.readSVarint(),s===1&&(t&&f.push(t),t=[]),t.push(new op(u,d));else{if(s!==7)throw new Error("unknown command "+s);t&&t.push(t[0].clone())}}return t&&f.push(t),f},Ma.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var t=i.readVarint()+i.pos,r=1,s=0,l=0,u=0,d=1/0,f=-1/0,g=1/0,x=-1/0;i.pos>3}if(s--,r===1||r===2)(l+=i.readSVarint())f&&(f=l),(u+=i.readSVarint())x&&(x=u);else if(r!==7)throw new Error("unknown command "+r)}return[d,g,f,x]},Ma.prototype.toGeoJSON=function(i,t,r){var s,l,u=this.extent*Math.pow(2,r),d=this.extent*i,f=this.extent*t,g=this.loadGeometry(),x=Ma.types[this.type];function v(C){for(var E=0;E>3;l=d===1?s.readString():d===2?s.readFloat():d===3?s.readDouble():d===4?s.readVarint64():d===5?s.readVarint():d===6?s.readSVarint():d===7?s.readBoolean():null}return l}(r))}tu.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var t=this._pbf.readVarint()+this._pbf.pos;return new hp(this._pbf,t,this.extent,this._keys,this._values)};var dp=eu;function pp(i,t,r){if(i===3){var s=new dp(r,r.readVarint()+r.pos);s.length&&(t[s.name]=s)}}as.VectorTile=function(i,t){this.layers=i.readFields(pp,{},t)},as.VectorTileFeature=Qh,as.VectorTileLayer=eu;const fp=as.VectorTileFeature.types,qc=Math.pow(2,13);function Oo(i,t,r,s,l,u,d,f){i.emplaceBack(t,r,2*Math.floor(s*qc)+d,l*qc*2,u*qc*2,Math.round(f))}class Zc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new es,this.centroidVertexArray=new li,this.indexArray=new gr,this.programConfigurations=new Fs(t.layers,t.zoom),this.segments=new at,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.features=[],this.hasPattern=Uc("fill-extrusion",this.layers,r);for(const{feature:l,id:u,index:d,sourceLayerIndex:f}of t){const g=this.layers[0]._featureFilter.needGeometry,x=Vs(l,g);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom),x,s))continue;const v={id:u,sourceLayerIndex:f,index:d,geometry:g?x.geometry:Os(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(jc("fill-extrusion",this.layers,v,this.zoom,r)):this.addFeature(v,v.geometry,d,s,{}),r.featureIndex.insert(l,v.geometry,d,f,this.index,!0)}}addFeatures(t,r,s){for(const l of this.features){const{geometry:u}=l;this.addFeature(l,u,l.index,r,s)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ap),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,sp.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,r,s,l,u){for(const d of Ys(r,500)){const f={x:0,y:0,vertexCount:0};let g=0;for(const E of d)g+=E.length;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const E of d){if(E.length===0||gp(E))continue;let z=0;for(let O=0;O=1){const ne=E[O-1];if(!mp($,ne)){x.vertexLength+4>at.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const W=$.sub(ne)._perp()._unit(),te=ne.dist($);z+te>32768&&(z=0),Oo(this.layoutVertexArray,$.x,$.y,W.x,W.y,0,0,z),Oo(this.layoutVertexArray,$.x,$.y,W.x,W.y,0,1,z),f.x+=2*$.x,f.y+=2*$.y,f.vertexCount+=2,z+=te,Oo(this.layoutVertexArray,ne.x,ne.y,W.x,W.y,0,0,z),Oo(this.layoutVertexArray,ne.x,ne.y,W.x,W.y,0,1,z),f.x+=2*ne.x,f.y+=2*ne.y,f.vertexCount+=2;const ce=x.vertexLength;this.indexArray.emplaceBack(ce,ce+2,ce+1),this.indexArray.emplaceBack(ce+1,ce+2,ce+3),x.vertexLength+=4,x.primitiveLength+=2}}}}if(x.vertexLength+g>at.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(g,this.layoutVertexArray,this.indexArray)),fp[t.type]!=="Polygon")continue;const v=[],w=[],I=x.vertexLength;for(const E of d)if(E.length!==0){E!==d[0]&&w.push(v.length/2);for(let z=0;z$t)||i.y===t.y&&(i.y<0||i.y>$t)}function gp(i){return i.every(t=>t.x<0)||i.every(t=>t.x>$t)||i.every(t=>t.y<0)||i.every(t=>t.y>$t)}let iu;ze("FillExtrusionBucket",Zc,{omit:["layers","features"]});var _p={get paint(){return iu=iu||new h({"fill-extrusion-opacity":new Le(le["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new je(le["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Le(le["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Le(le["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ya(le["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new je(le["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new je(le["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Le(le["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class yp extends n{constructor(t){super(t,_p)}createBucket(t){return new Zc(t)}queryRadius(){return Bl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,r,s,l,u,d,f,g){const x=Fl(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),d.angle,f),v=this.paint.get("fill-extrusion-height").evaluate(r,s),w=this.paint.get("fill-extrusion-base").evaluate(r,s),I=function(E,z,O,$){const ne=[];for(const W of E){const te=[W.x,W.y,0,1];Ol(te,te,z),ne.push(new de(te[0]/te[3],te[1]/te[3]))}return ne}(x,g),C=function(E,z,O,$){const ne=[],W=[],te=$[8]*z,ce=$[9]*z,ge=$[10]*z,Me=$[11]*z,Ue=$[8]*O,Ae=$[9]*O,Ie=$[10]*O,Fe=$[11]*O;for(const De of E){const Ee=[],pe=[];for(const Oe of De){const Be=Oe.x,Ze=Oe.y,xt=$[0]*Be+$[4]*Ze+$[12],yt=$[1]*Be+$[5]*Ze+$[13],Xt=$[2]*Be+$[6]*Ze+$[14],Lr=$[3]*Be+$[7]*Ze+$[15],ui=Xt+ge,Wt=Lr+Me,Di=xt+Ue,Li=yt+Ae,Ri=Xt+Ie,Ft=Lr+Fe,Kt=new de((xt+te)/Wt,(yt+ce)/Wt);Kt.z=ui/Wt,Ee.push(Kt);const Ti=new de(Di/Ft,Li/Ft);Ti.z=Ri/Ft,pe.push(Ti)}ne.push(Ee),W.push(pe)}return[ne,W]}(l,w,v,g);return function(E,z,O){let $=1/0;Lh(O,z)&&($=ru(O,z[0]));for(let ne=0;ner.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new va,this.layoutVertexArray2=new ts,this.indexArray=new gr,this.programConfigurations=new Fs(t.layers,t.zoom),this.segments=new at,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.hasPattern=Uc("line",this.layers,r);const l=this.layers[0].layout.get("line-sort-key"),u=!l.isConstant(),d=[];for(const{feature:f,id:g,index:x,sourceLayerIndex:v}of t){const w=this.layers[0]._featureFilter.needGeometry,I=Vs(f,w);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom),I,s))continue;const C=u?l.evaluate(I,{},s):void 0,E={id:g,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?I.geometry:Os(f),patterns:{},sortKey:C};d.push(E)}u&&d.sort((f,g)=>f.sortKey-g.sortKey);for(const f of d){const{geometry:g,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){const w=jc("line",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,g,x,s,{});r.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,wp)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,vp),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,r,s,l,u){const d=this.layers[0].layout,f=d.get("line-join").evaluate(t,{}),g=d.get("line-cap"),x=d.get("line-miter-limit"),v=d.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const w of r)this.addLine(w,t,f,g,x,v);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,u,l)}addLine(t,r,s,l,u,d){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let $=0;$=2&&t[g-1].equals(t[g-2]);)g--;let x=0;for(;x0;if(Me&&$>x){const Fe=I.dist(C);if(Fe>2*v){const De=I.sub(I.sub(C)._mult(v/Fe)._round());this.updateDistance(C,De),this.addCurrentVertex(De,z,0,0,w),C=De}}const Ae=C&&E;let Ie=Ae?s:f?"butt":l;if(Ae&&Ie==="round"&&(ceu&&(Ie="bevel"),Ie==="bevel"&&(ce>2&&(Ie="flipbevel"),ce100)ne=O.mult(-1);else{const Fe=ce*z.add(O).mag()/z.sub(O).mag();ne._perp()._mult(Fe*(Ue?-1:1))}this.addCurrentVertex(I,ne,0,0,w),this.addCurrentVertex(I,ne.mult(-1),0,0,w)}else if(Ie==="bevel"||Ie==="fakeround"){const Fe=-Math.sqrt(ce*ce-1),De=Ue?Fe:0,Ee=Ue?0:Fe;if(C&&this.addCurrentVertex(I,z,De,Ee,w),Ie==="fakeround"){const pe=Math.round(180*ge/Math.PI/20);for(let Oe=1;Oe2*v){const De=I.add(E.sub(I)._mult(v/Fe)._round());this.updateDistance(I,De),this.addCurrentVertex(De,O,0,0,w),I=De}}}}addCurrentVertex(t,r,s,l,u,d=!1){const f=r.y*l-r.x,g=-r.y-r.x*l;this.addHalfVertex(t,r.x+r.y*s,r.y-r.x*s,d,!1,s,u),this.addHalfVertex(t,f,g,d,!0,-l,u),this.distance>nu/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,r,s,l,u,d))}addHalfVertex({x:t,y:r},s,l,u,d,f,g){const x=.5*(this.lineClips?this.scaledDistance*(nu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(u?1:0),(r<<1)+(d?1:0),Math.round(63*s)+128,Math.round(63*l)+128,1+(f===0?0:f<0?-1:1)|(63&x)<<2,x>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const v=g.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,v),g.primitiveLength++),d?this.e2=v:this.e1=v}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,r){this.distance+=t.dist(r),this.updateScaledDistance()}}let su,au;ze("LineBucket",Gc,{omit:["layers","patternFeatures"]});var ou={get paint(){return au=au||new h({"line-opacity":new je(le.paint_line["line-opacity"]),"line-color":new je(le.paint_line["line-color"]),"line-translate":new Le(le.paint_line["line-translate"]),"line-translate-anchor":new Le(le.paint_line["line-translate-anchor"]),"line-width":new je(le.paint_line["line-width"]),"line-gap-width":new je(le.paint_line["line-gap-width"]),"line-offset":new je(le.paint_line["line-offset"]),"line-blur":new je(le.paint_line["line-blur"]),"line-dasharray":new xa(le.paint_line["line-dasharray"]),"line-pattern":new ya(le.paint_line["line-pattern"]),"line-gradient":new Mo(le.paint_line["line-gradient"])})},get layout(){return su=su||new h({"line-cap":new Le(le.layout_line["line-cap"]),"line-join":new je(le.layout_line["line-join"]),"line-miter-limit":new Le(le.layout_line["line-miter-limit"]),"line-round-limit":new Le(le.layout_line["line-round-limit"]),"line-sort-key":new je(le.layout_line["line-sort-key"])})}};class Ip extends je{possiblyEvaluate(t,r){return r=new wt(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(t,r)}evaluate(t,r,s,l){return r=gi({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(t,r,s,l)}}let jl;class Pp extends n{constructor(t){super(t,ou),this.gradientVersion=0,jl||(jl=new Ip(ou.paint.properties["line-width"].specification),jl.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){const r=this.gradientExpression();this.stepInterpolant=!!function(s){return s._styleExpression!==void 0}(r)&&r._styleExpression.expression instanceof Rn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,r){super.recalculate(t,r),this.paint._values["line-floorwidth"]=jl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Gc(t)}queryRadius(t){const r=t,s=lu(zo("line-width",this,r),zo("line-gap-width",this,r)),l=zo("line-offset",this,r);return s/2+Math.abs(l)+Bl(this.paint.get("line-translate"))}queryIntersectsFeature(t,r,s,l,u,d,f){const g=Fl(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),d.angle,f),x=f/2*lu(this.paint.get("line-width").evaluate(r,s),this.paint.get("line-gap-width").evaluate(r,s)),v=this.paint.get("line-offset").evaluate(r,s);return v&&(l=function(w,I){const C=[];for(let E=0;E=3){for(let O=0;O0?t+2*i:i}const Ap=m([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Cp=m([{name:"a_projected_pos",components:3,type:"Float32"}],4);m([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Mp=m([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);m([{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 cu=m([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),kp=m([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Ep(i,t,r){return i.sections.forEach(s=>{s.text=function(l,u,d){const f=u.layout.get("text-transform").evaluate(d,{});return f==="uppercase"?l=l.toLocaleUpperCase():f==="lowercase"&&(l=l.toLocaleLowerCase()),Zi.applyArabicShaping&&(l=Zi.applyArabicShaping(l)),l}(s.text,t,r)}),i}m([{name:"triangle",components:3,type:"Uint16"}]),m([{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"}]),m([{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"}]),m([{type:"Float32",name:"offsetX"}]),m([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),m([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const No={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Zt=24,hu=_t,uu=function(i,t,r,s,l){var u,d,f=8*l-s-1,g=(1<>1,v=-7,w=l-1,I=-1,C=i[t+w];for(w+=I,u=C&(1<<-v)-1,C>>=-v,v+=f;v>0;u=256*u+i[t+w],w+=I,v-=8);for(d=u&(1<<-v)-1,u>>=-v,v+=s;v>0;d=256*d+i[t+w],w+=I,v-=8);if(u===0)u=1-x;else{if(u===g)return d?NaN:1/0*(C?-1:1);d+=Math.pow(2,s),u-=x}return(C?-1:1)*d*Math.pow(2,u-s)},du=function(i,t,r,s,l,u){var d,f,g,x=8*u-l-1,v=(1<>1,I=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,C=0,E=1,z=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,d=v):(d=Math.floor(Math.log(t)/Math.LN2),t*(g=Math.pow(2,-d))<1&&(d--,g*=2),(t+=d+w>=1?I/g:I*Math.pow(2,1-w))*g>=2&&(d++,g/=2),d+w>=v?(f=0,d=v):d+w>=1?(f=(t*g-1)*Math.pow(2,l),d+=w):(f=t*Math.pow(2,w-1)*Math.pow(2,l),d=0));l>=8;i[r+C]=255&f,C+=E,f/=256,l-=8);for(d=d<0;i[r+C]=255&d,C+=E,d/=256,x-=8);i[r+C-E]|=128*z};function _t(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}_t.Varint=0,_t.Fixed64=1,_t.Bytes=2,_t.Fixed32=5;var Hc=4294967296,pu=1/Hc,fu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function An(i){return i.type===_t.Bytes?i.readVarint()+i.pos:i.pos+1}function ka(i,t,r){return r?4294967296*t+(i>>>0):4294967296*(t>>>0)+(i>>>0)}function mu(i,t,r){var s=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(s);for(var l=r.pos-1;l>=i;l--)r.buf[l+s]=r.buf[l]}function zp(i,t){for(var r=0;r>>8,i[r+2]=t>>>16,i[r+3]=t>>>24}function gu(i,t){return(i[t]|i[t+1]<<8|i[t+2]<<16)+(i[t+3]<<24)}_t.prototype={destroy:function(){this.buf=null},readFields:function(i,t,r){for(r=r||this.length;this.pos>3,u=this.pos;this.type=7&s,i(l,t,this),this.pos===u&&this.skip(s)}return t},readMessage:function(i,t){return this.readFields(i,t,this.readVarint()+this.pos)},readFixed32:function(){var i=$l(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=gu(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=$l(this.buf,this.pos)+$l(this.buf,this.pos+4)*Hc;return this.pos+=8,i},readSFixed64:function(){var i=$l(this.buf,this.pos)+gu(this.buf,this.pos+4)*Hc;return this.pos+=8,i},readFloat:function(){var i=uu(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=uu(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var t,r,s=this.buf;return t=127&(r=s[this.pos++]),r<128?t:(t|=(127&(r=s[this.pos++]))<<7,r<128?t:(t|=(127&(r=s[this.pos++]))<<14,r<128?t:(t|=(127&(r=s[this.pos++]))<<21,r<128?t:function(l,u,d){var f,g,x=d.buf;if(f=(112&(g=x[d.pos++]))>>4,g<128||(f|=(127&(g=x[d.pos++]))<<3,g<128)||(f|=(127&(g=x[d.pos++]))<<10,g<128)||(f|=(127&(g=x[d.pos++]))<<17,g<128)||(f|=(127&(g=x[d.pos++]))<<24,g<128)||(f|=(1&(g=x[d.pos++]))<<31,g<128))return ka(l,f,u);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(r=s[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?(i+1)/-2:i/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var i=this.readVarint()+this.pos,t=this.pos;return this.pos=i,i-t>=12&&fu?function(r,s,l){return fu.decode(r.subarray(s,l))}(this.buf,t,i):function(r,s,l){for(var u="",d=s;d239?4:v>223?3:v>191?2:1;if(d+I>l)break;I===1?v<128&&(w=v):I===2?(192&(f=r[d+1]))==128&&(w=(31&v)<<6|63&f)<=127&&(w=null):I===3?(g=r[d+2],(192&(f=r[d+1]))==128&&(192&g)==128&&((w=(15&v)<<12|(63&f)<<6|63&g)<=2047||w>=55296&&w<=57343)&&(w=null)):I===4&&(g=r[d+2],x=r[d+3],(192&(f=r[d+1]))==128&&(192&g)==128&&(192&x)==128&&((w=(15&v)<<18|(63&f)<<12|(63&g)<<6|63&x)<=65535||w>=1114112)&&(w=null)),w===null?(w=65533,I=1):w>65535&&(w-=65536,u+=String.fromCharCode(w>>>10&1023|55296),w=56320|1023&w),u+=String.fromCharCode(w),d+=I}return u}(this.buf,t,i)},readBytes:function(){var i=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,i);return this.pos=i,t},readPackedVarint:function(i,t){if(this.type!==_t.Bytes)return i.push(this.readVarint(t));var r=An(this);for(i=i||[];this.pos127;);else if(t===_t.Bytes)this.pos=this.readVarint()+this.pos;else if(t===_t.Fixed32)this.pos+=4;else{if(t!==_t.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(i,t){this.writeVarint(i<<3|t)},realloc:function(i){for(var t=this.length||16;t268435455||i<0?function(t,r){var s,l;if(t>=0?(s=t%4294967296|0,l=t/4294967296|0):(l=~(-t/4294967296),4294967295^(s=~(-t%4294967296))?s=s+1|0:(s=0,l=l+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(u,d,f){f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,f.buf[f.pos]=127&(u>>>=7)}(s,0,r),function(u,d){var f=(7&u)<<4;d.buf[d.pos++]|=f|((u>>>=3)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u)))))}(l,r)}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(!!i)},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var t=this.pos;this.pos=function(s,l,u){for(var d,f,g=0;g55295&&d<57344){if(!f){d>56319||g+1===l.length?(s[u++]=239,s[u++]=191,s[u++]=189):f=d;continue}if(d<56320){s[u++]=239,s[u++]=191,s[u++]=189,f=d;continue}d=f-55296<<10|d-56320|65536,f=null}else f&&(s[u++]=239,s[u++]=191,s[u++]=189,f=null);d<128?s[u++]=d:(d<2048?s[u++]=d>>6|192:(d<65536?s[u++]=d>>12|224:(s[u++]=d>>18|240,s[u++]=d>>12&63|128),s[u++]=d>>6&63|128),s[u++]=63&d|128)}return u}(this.buf,i,this.pos);var r=this.pos-t;r>=128&&mu(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),du(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),du(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var t=i.length;this.writeVarint(t),this.realloc(t);for(var r=0;r=128&&mu(r,s,this),this.pos=r-1,this.writeVarint(s),this.pos+=s},writeMessage:function(i,t,r){this.writeTag(i,_t.Bytes),this.writeRawMessage(t,r)},writePackedVarint:function(i,t){t.length&&this.writeMessage(i,zp,t)},writePackedSVarint:function(i,t){t.length&&this.writeMessage(i,Dp,t)},writePackedBoolean:function(i,t){t.length&&this.writeMessage(i,Bp,t)},writePackedFloat:function(i,t){t.length&&this.writeMessage(i,Lp,t)},writePackedDouble:function(i,t){t.length&&this.writeMessage(i,Rp,t)},writePackedFixed32:function(i,t){t.length&&this.writeMessage(i,Fp,t)},writePackedSFixed32:function(i,t){t.length&&this.writeMessage(i,Op,t)},writePackedFixed64:function(i,t){t.length&&this.writeMessage(i,Vp,t)},writePackedSFixed64:function(i,t){t.length&&this.writeMessage(i,Np,t)},writeBytesField:function(i,t){this.writeTag(i,_t.Bytes),this.writeBytes(t)},writeFixed32Field:function(i,t){this.writeTag(i,_t.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(i,t){this.writeTag(i,_t.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(i,t){this.writeTag(i,_t.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(i,t){this.writeTag(i,_t.Fixed64),this.writeSFixed64(t)},writeVarintField:function(i,t){this.writeTag(i,_t.Varint),this.writeVarint(t)},writeSVarintField:function(i,t){this.writeTag(i,_t.Varint),this.writeSVarint(t)},writeStringField:function(i,t){this.writeTag(i,_t.Bytes),this.writeString(t)},writeFloatField:function(i,t){this.writeTag(i,_t.Fixed32),this.writeFloat(t)},writeDoubleField:function(i,t){this.writeTag(i,_t.Fixed64),this.writeDouble(t)},writeBooleanField:function(i,t){this.writeVarintField(i,!!t)}};var Xc=Je(hu);const Wc=3;function Up(i,t,r){i===1&&r.readMessage(jp,t)}function jp(i,t,r){if(i===3){const{id:s,bitmap:l,width:u,height:d,left:f,top:g,advance:x}=r.readMessage($p,{});t.push({id:s,bitmap:new Lo({width:u+2*Wc,height:d+2*Wc},l),metrics:{width:u,height:d,left:f,top:g,advance:x}})}}function $p(i,t,r){i===1?t.id=r.readVarint():i===2?t.bitmap=r.readBytes():i===3?t.width=r.readVarint():i===4?t.height=r.readVarint():i===5?t.left=r.readSVarint():i===6?t.top=r.readSVarint():i===7&&(t.advance=r.readVarint())}const _u=Wc;function yu(i){let t=0,r=0;for(const d of i)t+=d.w*d.h,r=Math.max(r,d.w);i.sort((d,f)=>f.h-d.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}];let l=0,u=0;for(const d of i)for(let f=s.length-1;f>=0;f--){const g=s[f];if(!(d.w>g.w||d.h>g.h)){if(d.x=g.x,d.y=g.y,u=Math.max(u,d.y+d.h),l=Math.max(l,d.x+d.w),d.w===g.w&&d.h===g.h){const x=s.pop();f=0&&s>=t&&Zl[this.text.charCodeAt(s)];s--)r--;this.text=this.text.substring(t,r),this.sectionIndex=this.sectionIndex.slice(t,r)}substring(t,r){const s=new za;return s.text=this.text.substring(t,r),s.sectionIndex=this.sectionIndex.slice(t,r),s.sections=this.sections,s}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,r)=>Math.max(t,this.sections[r].scale),0)}addTextSection(t,r){this.text+=t.text,this.sections.push(jo.forText(t.scale,t.fontStack||r));const s=this.sections.length-1;for(let l=0;l=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ql(i,t,r,s,l,u,d,f,g,x,v,w,I,C,E){const z=za.fromFeature(i,l);let O;w===M.ah.vertical&&z.verticalizePunctuation();const{processBidirectionalText:$,processStyledBidirectionalText:ne}=Zi;if($&&z.sections.length===1){O=[];const ce=$(z.toString(),Jc(z,x,u,t,s,C));for(const ge of ce){const Me=new za;Me.text=ge,Me.sections=z.sections;for(let Ue=0;Ue0&&Cn>pi&&(pi=Cn)}else{const vr=Me[ht.fontStack],ti=vr&&vr[Pt];if(ti&&ti.rect)Ba=ti.rect,Dt=ti.metrics;else{const Cn=ge[ht.fontStack],Xo=Cn&&Cn[Pt];if(!Xo)continue;Dt=Xo.metrics}sr=(Kt-ht.scale)*Zt}Rr?(ce.verticalizable=!0,Bi.push({glyph:Pt,imageName:sn,x:Ze,y:xt+sr,vertical:Rr,scale:ht.scale,fontStack:ht.fontStack,sectionIndex:bt,metrics:Dt,rect:Ba}),Ze+=an*ht.scale+pe):(Bi.push({glyph:Pt,imageName:sn,x:Ze,y:xt+sr,vertical:Rr,scale:ht.scale,fontStack:ht.fontStack,sectionIndex:bt,metrics:Dt,rect:Ba}),Ze+=Dt.advance*ht.scale+pe)}Bi.length!==0&&(yt=Math.max(Ze-pe,yt),Hp(Bi,0,Bi.length-1,Lr,pi)),Ze=0;const xr=Ie*Kt+pi;di.lineOffset=Math.max(pi,Ti),xt+=xr,Xt=Math.max(xr,Xt),++ui}var Wt;const Di=xt-Uo,{horizontalAlign:Li,verticalAlign:Ri}=Yc(Fe);(function(Ft,Kt,Ti,di,Bi,pi,xr,Xi,ht){const bt=(Kt-Ti)*Bi;let Pt=0;Pt=pi!==xr?-Xi*di-Uo:(-di*ht+.5)*xr;for(const sr of Ft)for(const Dt of sr.positionedGlyphs)Dt.x+=bt,Dt.y+=Pt})(ce.positionedLines,Lr,Li,Ri,yt,Xt,Ie,Di,Ae.length),ce.top+=-Ri*Di,ce.bottom=ce.top+Di,ce.left+=-Li*yt,ce.right=ce.left+yt}(te,t,r,s,O,d,f,g,w,x,I,E),!function(ce){for(const ge of ce)if(ge.positionedGlyphs.length!==0)return!1;return!0}(W)&&te}const Zl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},qp={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Zp={40:!0};function vu(i,t,r,s,l,u){if(t.imageName){const d=s[t.imageName];return d?d.displaySize[0]*t.scale*Zt/u+l:0}{const d=r[t.fontStack],f=d&&d[i];return f?f.metrics.advance*t.scale+l:0}}function bu(i,t,r,s){const l=Math.pow(i-t,2);return s?i=0;let x=0;for(let w=0;wx){const v=Math.ceil(u/x);l*=v/d,d=v}return{x1:s,y1:l,x2:s+u,y2:l+d}}function Iu(i,t,r,s,l,u){const d=i.image;let f;if(d.content){const O=d.content,$=d.pixelRatio||1;f=[O[0]/$,O[1]/$,d.displaySize[0]-O[2]/$,d.displaySize[1]-O[3]/$]}const g=t.left*u,x=t.right*u;let v,w,I,C;r==="width"||r==="both"?(C=l[0]+g-s[3],w=l[0]+x+s[1]):(C=l[0]+(g+x-d.displaySize[0])/2,w=C+d.displaySize[0]);const E=t.top*u,z=t.bottom*u;return r==="height"||r==="both"?(v=l[1]+E-s[0],I=l[1]+z+s[2]):(v=l[1]+(E+z-d.displaySize[1])/2,I=v+d.displaySize[1]),{image:d,top:v,right:w,bottom:I,left:C,collisionPadding:f}}const $o=255,nn=128,ls=$o*nn;function Pu(i,t){const{expression:r}=t;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new wt(i+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:l}=r;let u=0;for(;ud.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Rc([]),this.placementViewportMatrix=Rc([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pu(this.zoom,r["text-size"]),this.iconSizeData=Pu(this.zoom,r["icon-size"]);const s=this.layers[0].layout,l=s.get("symbol-sort-key"),u=s.get("symbol-z-order");this.canOverlap=Qc(s,"text-overlap","text-allow-overlap")!=="never"||Qc(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=u!=="viewport-y"&&!l.isConstant(),this.sortFeaturesByY=(u==="viewport-y"||u==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map(d=>M.ah[d])),this.stateDependentLayerIds=this.layers.filter(d=>d.isStateDependent()).map(d=>d.id),this.sourceID=t.sourceID}createArrays(){this.text=new th(new Fs(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new th(new Fs(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new St,this.lineVertexArray=new oi,this.symbolInstances=new nt,this.textAnchorOffsets=new It}calculateGlyphDependencies(t,r,s,l,u){for(let d=0;d0)&&(d.value.kind!=="constant"||d.value.value.length>0),v=g.value.kind!=="constant"||!!g.value.value||Object.keys(g.parameters).length>0,w=u.get("symbol-sort-key");if(this.features=[],!x&&!v)return;const I=r.iconDependencies,C=r.glyphDependencies,E=r.availableImages,z=new wt(this.zoom);for(const{feature:O,id:$,index:ne,sourceLayerIndex:W}of t){const te=l._featureFilter.needGeometry,ce=Vs(O,te);if(!l._featureFilter.filter(z,ce,s))continue;let ge,Me;if(te||(ce.geometry=Os(O)),x){const Ae=l.getValueAndResolveTokens("text-field",ce,s,E),Ie=Ui.factory(Ae),Fe=this.hasRTLText=this.hasRTLText||Jp(Ie);(!Fe||Zi.getRTLTextPluginStatus()==="unavailable"||Fe&&Zi.isParsed())&&(ge=Ep(Ie,l,ce))}if(v){const Ae=l.getValueAndResolveTokens("icon-image",ce,s,E);Me=Ae instanceof $i?Ae:$i.fromString(Ae)}if(!ge&&!Me)continue;const Ue=this.sortFeaturesByKey?w.evaluate(ce,{},s):void 0;if(this.features.push({id:$,text:ge,icon:Me,index:ne,sourceLayerIndex:W,geometry:ce.geometry,properties:O.properties,type:Wp[O.type],sortKey:Ue}),Me&&(I[Me.name]=!0),ge){const Ae=d.evaluate(ce,{},s).join(","),Ie=u.get("text-rotation-alignment")!=="viewport"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(M.ah.vertical)>=0;for(const Fe of ge.sections)if(Fe.image)I[Fe.image.name]=!0;else{const De=Io(ge.toString()),Ee=Fe.fontStack||Ae,pe=C[Ee]=C[Ee]||{};this.calculateGlyphDependencies(Fe.text,pe,Ie,this.allowVerticalPlacement,De)}}}u.get("symbol-placement")==="line"&&(this.features=function(O){const $={},ne={},W=[];let te=0;function ce(Ae){W.push(O[Ae]),te++}function ge(Ae,Ie,Fe){const De=ne[Ae];return delete ne[Ae],ne[Ie]=De,W[De].geometry[0].pop(),W[De].geometry[0]=W[De].geometry[0].concat(Fe[0]),De}function Me(Ae,Ie,Fe){const De=$[Ie];return delete $[Ie],$[Ae]=De,W[De].geometry[0].shift(),W[De].geometry[0]=Fe[0].concat(W[De].geometry[0]),De}function Ue(Ae,Ie,Fe){const De=Fe?Ie[0][Ie[0].length-1]:Ie[0][0];return`${Ae}:${De.x}:${De.y}`}for(let Ae=0;AeAe.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((O,$)=>O.sortKey-$.sortKey)}update(t,r,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,r,this.layers,s),this.icon.programConfigurations.updatePaintArrays(t,r,this.layers,s))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,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(t,r){const s=this.lineVertexArray.length;if(t.segment!==void 0){let l=t.dist(r[t.segment+1]),u=t.dist(r[t.segment]);const d={};for(let f=t.segment+1;f=0;f--)d[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:u},f>0&&(u+=r[f-1].dist(r[f]));for(let f=0;f0}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(t,r){const s=t.placedSymbolArray.get(r),l=s.vertexStartIndex+4*s.numGlyphs;for(let u=s.vertexStartIndex;ul[f]-l[g]||u[g]-u[f]),d}addToSortKeyRanges(t,r){const s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===r?s.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const r of this.symbolInstanceIndexes){const s=this.symbolInstances.get(r);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach((l,u,d)=>{l>=0&&d.indexOf(l)===u&&this.addIndicesForPlacedSymbol(this.text,l)}),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 Au,Cu;ze("SymbolBucket",Da,{omit:["layers","collisionBoxArray","features","compareText"]}),Da.MAX_GLYPHS=65535,Da.addDynamicAttributes=eh;var rh={get paint(){return Cu=Cu||new h({"icon-opacity":new je(le.paint_symbol["icon-opacity"]),"icon-color":new je(le.paint_symbol["icon-color"]),"icon-halo-color":new je(le.paint_symbol["icon-halo-color"]),"icon-halo-width":new je(le.paint_symbol["icon-halo-width"]),"icon-halo-blur":new je(le.paint_symbol["icon-halo-blur"]),"icon-translate":new Le(le.paint_symbol["icon-translate"]),"icon-translate-anchor":new Le(le.paint_symbol["icon-translate-anchor"]),"text-opacity":new je(le.paint_symbol["text-opacity"]),"text-color":new je(le.paint_symbol["text-color"],{runtimeType:Ci,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new je(le.paint_symbol["text-halo-color"]),"text-halo-width":new je(le.paint_symbol["text-halo-width"]),"text-halo-blur":new je(le.paint_symbol["text-halo-blur"]),"text-translate":new Le(le.paint_symbol["text-translate"]),"text-translate-anchor":new Le(le.paint_symbol["text-translate-anchor"])})},get layout(){return Au=Au||new h({"symbol-placement":new Le(le.layout_symbol["symbol-placement"]),"symbol-spacing":new Le(le.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Le(le.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new je(le.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Le(le.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Le(le.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Le(le.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Le(le.layout_symbol["icon-ignore-placement"]),"icon-optional":new Le(le.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Le(le.layout_symbol["icon-rotation-alignment"]),"icon-size":new je(le.layout_symbol["icon-size"]),"icon-text-fit":new Le(le.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Le(le.layout_symbol["icon-text-fit-padding"]),"icon-image":new je(le.layout_symbol["icon-image"]),"icon-rotate":new je(le.layout_symbol["icon-rotate"]),"icon-padding":new je(le.layout_symbol["icon-padding"]),"icon-keep-upright":new Le(le.layout_symbol["icon-keep-upright"]),"icon-offset":new je(le.layout_symbol["icon-offset"]),"icon-anchor":new je(le.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Le(le.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Le(le.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Le(le.layout_symbol["text-rotation-alignment"]),"text-field":new je(le.layout_symbol["text-field"]),"text-font":new je(le.layout_symbol["text-font"]),"text-size":new je(le.layout_symbol["text-size"]),"text-max-width":new je(le.layout_symbol["text-max-width"]),"text-line-height":new Le(le.layout_symbol["text-line-height"]),"text-letter-spacing":new je(le.layout_symbol["text-letter-spacing"]),"text-justify":new je(le.layout_symbol["text-justify"]),"text-radial-offset":new je(le.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Le(le.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new je(le.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new je(le.layout_symbol["text-anchor"]),"text-max-angle":new Le(le.layout_symbol["text-max-angle"]),"text-writing-mode":new Le(le.layout_symbol["text-writing-mode"]),"text-rotate":new je(le.layout_symbol["text-rotate"]),"text-padding":new Le(le.layout_symbol["text-padding"]),"text-keep-upright":new Le(le.layout_symbol["text-keep-upright"]),"text-transform":new je(le.layout_symbol["text-transform"]),"text-offset":new je(le.layout_symbol["text-offset"]),"text-allow-overlap":new Le(le.layout_symbol["text-allow-overlap"]),"text-overlap":new Le(le.layout_symbol["text-overlap"]),"text-ignore-placement":new Le(le.layout_symbol["text-ignore-placement"]),"text-optional":new Le(le.layout_symbol["text-optional"])})}};class Mu{constructor(t){if(t.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Jr,this.defaultValue=t}evaluate(t){if(t.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(t.formattedSection))return r.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ze("FormatSectionOverride",Mu,{omit:["defaultValue"]});class Hl extends n{constructor(t){super(t,rh)}recalculate(t,r){if(super.recalculate(t,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const s=this.layout.get("text-writing-mode");if(s){const l=[];for(const u of s)l.indexOf(u)<0&&l.push(u);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,r,s,l){const u=this.layout.get(t).evaluate(r,{},s,l),d=this._unevaluatedLayout._values[t];return d.isDataDriven()||aa(d.value)||!u?u:function(f,g){return g.replace(/{([^{}]+)}/g,(x,v)=>f&&v in f?String(f[v]):"")}(r.properties,u)}createBucket(t){return new Da(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of rh.paint.overridableProperties){if(!Hl.hasPaintOverride(this.layout,t))continue;const r=this.paint.get(t),s=new Mu(r),l=new sa(s,r.property.specification);let u=null;u=r.value.kind==="constant"||r.value.kind==="source"?new qn("source",l):new Zn("composite",l,r.value.zoomStops),this.paint._values[t]=new zr(r.property,u,r.parameters)}}_handleOverridablePaintPropertyUpdate(t,r,s){return!(!this.layout||r.isDataDriven()||s.isDataDriven())&&Hl.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,r){const s=t.get("text-field"),l=rh.paint.properties[r];let u=!1;const d=f=>{for(const g of f)if(l.overrides&&l.overrides.hasOverride(g))return void(u=!0)};if(s.value.kind==="constant"&&s.value.value instanceof Ui)d(s.value.value.sections);else if(s.value.kind==="source"){const f=x=>{u||(x instanceof hr&&jt(x.value)===Ur?d(x.value.sections):x instanceof Ks?d(x.sections):x.eachChild(f))},g=s.value;g._styleExpression&&f(g._styleExpression.expression)}return u}}let ku;var Yp={get paint(){return ku=ku||new h({"background-color":new Le(le.paint_background["background-color"]),"background-pattern":new xa(le.paint_background["background-pattern"]),"background-opacity":new Le(le.paint_background["background-opacity"])})}};class Qp extends n{constructor(t){super(t,Yp)}}let Eu;var ef={get paint(){return Eu=Eu||new h({"raster-opacity":new Le(le.paint_raster["raster-opacity"]),"raster-hue-rotate":new Le(le.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Le(le.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Le(le.paint_raster["raster-brightness-max"]),"raster-saturation":new Le(le.paint_raster["raster-saturation"]),"raster-contrast":new Le(le.paint_raster["raster-contrast"]),"raster-resampling":new Le(le.paint_raster["raster-resampling"]),"raster-fade-duration":new Le(le.paint_raster["raster-fade-duration"])})}};class tf extends n{constructor(t){super(t,ef)}}class rf extends n{constructor(t){super(t,{}),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=t}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class nf{constructor(t){this._methodToThrottle=t,this._triggered=!1,typeof MessageChannel<"u"&&(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 nh=63710088e-1;class cs{constructor(t,r){if(isNaN(t)||isNaN(r))throw new Error(`Invalid LngLat object: (${t}, ${r})`);if(this.lng=+t,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new cs(Pi(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const r=Math.PI/180,s=this.lat*r,l=t.lat*r,u=Math.sin(s)*Math.sin(l)+Math.cos(s)*Math.cos(l)*Math.cos((t.lng-this.lng)*r);return nh*Math.acos(Math.min(u,1))}static convert(t){if(t instanceof cs)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new cs(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new cs(Number("lng"in t?t.lng:t.lon),Number(t.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 zu=2*Math.PI*nh;function Du(i){return zu*Math.cos(i*Math.PI/180)}function Lu(i){return(180+i)/360}function Ru(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function Bu(i,t){return i/Du(t)}function sh(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class qo{constructor(t,r,s=0){this.x=+t,this.y=+r,this.z=+s}static fromLngLat(t,r=0){const s=cs.convert(t);return new qo(Lu(s.lng),Ru(s.lat),Bu(r,s.lat))}toLngLat(){return new cs(360*this.x-180,sh(this.y))}toAltitude(){return this.z*Du(sh(this.y))}meterInMercatorCoordinateUnits(){return 1/zu*(t=sh(this.y),1/Math.cos(t*Math.PI/180));var t}}function Fu(i,t,r){var s=2*Math.PI*6378137/256/Math.pow(2,r);return[i*s-2*Math.PI*6378137/2,t*s-2*Math.PI*6378137/2]}class ah{constructor(t,r,s){if(!function(l,u,d){return!(l<0||l>25||d<0||d>=Math.pow(2,l)||u<0||u>=Math.pow(2,l))}(t,r,s))throw new Error(`x=${r}, y=${s}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=r,this.y=s,this.key=Zo(0,t,t,r,s)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,r,s){const l=(d=this.y,f=this.z,g=Fu(256*(u=this.x),256*(d=Math.pow(2,f)-d-1),f),x=Fu(256*(u+1),256*(d+1),f),g[0]+","+g[1]+","+x[0]+","+x[1]);var u,d,f,g,x;const v=function(w,I,C){let E,z="";for(let O=w;O>0;O--)E=1<1?"@2x":"").replace(/{quadkey}/g,v).replace(/{bbox-epsg-3857}/g,l)}isChildOf(t){const r=this.z-t.z;return r>0&&t.x===this.x>>r&&t.y===this.y>>r}getTilePoint(t){const r=Math.pow(2,this.z);return new de((t.x*r-this.x)*$t,(t.y*r-this.y)*$t)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Ou{constructor(t,r){this.wrap=t,this.canonical=r,this.key=Zo(t,r.z,r.z,r.x,r.y)}}class yr{constructor(t,r,s,l,u){if(t= z; overscaledZ = ${t}; z = ${s}`);this.overscaledZ=t,this.wrap=r,this.canonical=new ah(s,+l,+u),this.key=Zo(r,t,s,l,u)}clone(){return new yr(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?new yr(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new yr(t,this.wrap,t,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(t,r){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-t;return t>this.canonical.z?Zo(this.wrap*+r,t,this.canonical.z,this.canonical.x,this.canonical.y):Zo(this.wrap*+r,t,t,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const r=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ>r&&t.canonical.y===this.canonical.y>>r}children(t){if(this.overscaledZ>=t)return[new yr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,s=2*this.canonical.x,l=2*this.canonical.y;return[new yr(r,this.wrap,r,s,l),new yr(r,this.wrap,r,s+1,l),new yr(r,this.wrap,r,s,l+1),new yr(r,this.wrap,r,s+1,l+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=w),w=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(t+1)}unpack(t,r,s){return t*this.redFactor+r*this.greenFactor+s*this.blueFactor-this.baseShift}getPixels(){return new _r({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,r,s){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let l=r*this.dim,u=r*this.dim+this.dim,d=s*this.dim,f=s*this.dim+this.dim;switch(r){case-1:l=u-1;break;case 1:u=l+1}switch(s){case-1:d=f-1;break;case 1:f=d+1}const g=-r*this.dim,x=-s*this.dim;for(let v=d;v=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class Uu{constructor(t,r,s,l,u){this.type="Feature",this._vectorTileFeature=t,t._z=r,t._x=s,t._y=l,this.properties=t.properties,this.id=u}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(t[r]=this[r]);return t}}class ju{constructor(t,r){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Wn($t,16,0),this.grid3D=new Wn($t,16,0),this.featureIndexArray=new bi,this.promoteId=r}insert(t,r,s,l,u,d){const f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,l,u);const g=d?this.grid3D:this.grid;for(let x=0;x=0&&w[3]>=0&&g.insert(f,w[0],w[1],w[2],w[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new as.VectorTile(new Xc(this.rawTileData)).layers,this.sourceLayerCoder=new Nu(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,r,s,l){this.loadVTLayers();const u=t.params||{},d=$t/t.tileSize/t.scale,f=co(u.filter),g=t.queryGeometry,x=t.queryPadding*d,v=qu(g),w=this.grid.query(v.minX-x,v.minY-x,v.maxX+x,v.maxY+x),I=qu(t.cameraQueryGeometry),C=this.grid3D.query(I.minX-x,I.minY-x,I.maxX+x,I.maxY+x,(O,$,ne,W)=>function(te,ce,ge,Me,Ue){for(const Ie of te)if(ce<=Ie.x&&ge<=Ie.y&&Me>=Ie.x&&Ue>=Ie.y)return!0;const Ae=[new de(ce,ge),new de(ce,Ue),new de(Me,Ue),new de(Me,ge)];if(te.length>2){for(const Ie of Ae)if(Pa(te,Ie))return!0}for(let Ie=0;Ie(W||(W=Os(te)),ce.queryIntersectsFeature(g,te,ge,W,this.z,t.transform,d,t.pixelPosMatrix)))}return E}loadMatchingFeature(t,r,s,l,u,d,f,g,x,v,w){const I=this.bucketLayerIDs[r];if(d&&!function(O,$){for(let ne=0;ne=0)return!0;return!1}(d,I))return;const C=this.sourceLayerCoder.decode(s),E=this.vtLayers[C].feature(l);if(u.needGeometry){const O=Vs(E,!0);if(!u.filter(new wt(this.tileID.overscaledZ),O,this.tileID.canonical))return}else if(!u.filter(new wt(this.tileID.overscaledZ),E))return;const z=this.getId(E,C);for(let O=0;O{const f=t instanceof Ls?t.get(d):null;return f&&f.evaluate?f.evaluate(r,s,l):f})}function qu(i){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(const u of i)t=Math.min(t,u.x),r=Math.min(r,u.y),s=Math.max(s,u.x),l=Math.max(l,u.y);return{minX:t,minY:r,maxX:s,maxY:l}}function sf(i,t){return t-i}function Zu(i,t,r,s,l){const u=[];for(let d=0;d=s&&w.x>=s||(v.x>=s?v=new de(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x>=s&&(w=new de(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y>=l&&w.y>=l||(v.y>=l?v=new de(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round():w.y>=l&&(w=new de(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round()),g&&v.equals(g[g.length-1])||(g=[v],u.push(g)),g.push(w)))))}}return u}ze("FeatureIndex",ju,{omit:["rawTileData","sourceLayerCoder"]});class hs extends de{constructor(t,r,s,l){super(t,r),this.angle=s,l!==void 0&&(this.segment=l)}clone(){return new hs(this.x,this.y,this.angle,this.segment)}}function Gu(i,t,r,s,l){if(t.segment===void 0||r===0)return!0;let u=t,d=t.segment+1,f=0;for(;f>-r/2;){if(d--,d<0)return!1;f-=i[d].dist(u),u=i[d]}f+=i[d].dist(i[d+1]),d++;const g=[];let x=0;for(;fs;)x-=g.shift().angleDelta;if(x>l)return!1;d++,f+=v.dist(w)}return!0}function Hu(i){let t=0;for(let r=0;rx){const E=(x-g)/C,z=Mi.number(w.x,I.x,E),O=Mi.number(w.y,I.y,E),$=new hs(z,O,I.angleTo(w),v);return $._round(),!d||Gu(i,$,f,d,t)?$:void 0}g+=C}}function of(i,t,r,s,l,u,d,f,g){const x=Xu(s,u,d),v=Wu(s,l),w=v*d,I=i[0].x===0||i[0].x===g||i[0].y===0||i[0].y===g;return t-w=0&&te=0&&ce=0&&I+x<=v){const ge=new hs(te,ce,ne,E);ge._round(),s&&!Gu(i,ge,u,s,l)||C.push(ge)}}w+=$}return f||C.length||d||(C=Ku(i,w/2,r,s,l,u,d,!0,g)),C}ze("Anchor",hs);const La=Hi;function Ju(i,t,r,s){const l=[],u=i.image,d=u.pixelRatio,f=u.paddedRect.w-2*La,g=u.paddedRect.h-2*La;let x={x1:i.left,y1:i.top,x2:i.right,y2:i.bottom};const v=u.stretchX||[[0,f]],w=u.stretchY||[[0,g]],I=(pe,Oe)=>pe+Oe[1]-Oe[0],C=v.reduce(I,0),E=w.reduce(I,0),z=f-C,O=g-E;let $=0,ne=C,W=0,te=E,ce=0,ge=z,Me=0,Ue=O;if(u.content&&s){const pe=u.content,Oe=pe[2]-pe[0],Be=pe[3]-pe[1];(u.textFitWidth||u.textFitHeight)&&(x=Su(i)),$=Xl(v,0,pe[0]),W=Xl(w,0,pe[1]),ne=Xl(v,pe[0],pe[2]),te=Xl(w,pe[1],pe[3]),ce=pe[0]-$,Me=pe[1]-W,ge=Oe-ne,Ue=Be-te}const Ae=x.x1,Ie=x.y1,Fe=x.x2-Ae,De=x.y2-Ie,Ee=(pe,Oe,Be,Ze)=>{const xt=Wl(pe.stretch-$,ne,Fe,Ae),yt=Kl(pe.fixed-ce,ge,pe.stretch,C),Xt=Wl(Oe.stretch-W,te,De,Ie),Lr=Kl(Oe.fixed-Me,Ue,Oe.stretch,E),ui=Wl(Be.stretch-$,ne,Fe,Ae),Wt=Kl(Be.fixed-ce,ge,Be.stretch,C),Di=Wl(Ze.stretch-W,te,De,Ie),Li=Kl(Ze.fixed-Me,Ue,Ze.stretch,E),Ri=new de(xt,Xt),Ft=new de(ui,Xt),Kt=new de(ui,Di),Ti=new de(xt,Di),di=new de(yt/d,Lr/d),Bi=new de(Wt/d,Li/d),pi=t*Math.PI/180;if(pi){const ht=Math.sin(pi),bt=Math.cos(pi),Pt=[bt,-ht,ht,bt];Ri._matMult(Pt),Ft._matMult(Pt),Ti._matMult(Pt),Kt._matMult(Pt)}const xr=pe.stretch+pe.fixed,Xi=Oe.stretch+Oe.fixed;return{tl:Ri,tr:Ft,bl:Ti,br:Kt,tex:{x:u.paddedRect.x+La+xr,y:u.paddedRect.y+La+Xi,w:Be.stretch+Be.fixed-xr,h:Ze.stretch+Ze.fixed-Xi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:di,pixelOffsetBR:Bi,minFontScaleX:ge/d/Fe,minFontScaleY:Ue/d/De,isSDF:r}};if(s&&(u.stretchX||u.stretchY)){const pe=Yu(v,z,C),Oe=Yu(w,O,E);for(let Be=0;Be0&&(z=Math.max(10,z),this.circleDiameter=z)}else{const I=!((w=d.image)===null||w===void 0)&&w.content&&(d.image.textFitWidth||d.image.textFitHeight)?Su(d):{x1:d.left,y1:d.top,x2:d.right,y2:d.bottom};I.y1=I.y1*f-g[0],I.y2=I.y2*f+g[2],I.x1=I.x1*f-g[3],I.x2=I.x2*f+g[1];const C=d.collisionPadding;if(C&&(I.x1-=C[0]*f,I.y1-=C[1]*f,I.x2+=C[2]*f,I.y2+=C[3]*f),v){const E=new de(I.x1,I.y1),z=new de(I.x2,I.y1),O=new de(I.x1,I.y2),$=new de(I.x2,I.y2),ne=v*Math.PI/180;E._rotate(ne),z._rotate(ne),O._rotate(ne),$._rotate(ne),I.x1=Math.min(E.x,z.x,O.x,$.x),I.x2=Math.max(E.x,z.x,O.x,$.x),I.y1=Math.min(E.y,z.y,O.y,$.y),I.y2=Math.max(E.y,z.y,O.y,$.y)}t.emplaceBack(r.x,r.y,I.x1,I.y1,I.x2,I.y2,s,l,u)}this.boxEndIndex=t.length}}class lf{constructor(t=[],r=(s,l)=>sl?1:0){if(this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:r,compare:s}=this,l=r[t];for(;t>0;){const u=t-1>>1,d=r[u];if(s(l,d)>=0)break;r[t]=d,t=u}r[t]=l}_down(t){const{data:r,compare:s}=this,l=this.length>>1,u=r[t];for(;t=0)break;r[t]=r[d],t=d}r[t]=u}}function cf(i,t=1,r=!1){let s=1/0,l=1/0,u=-1/0,d=-1/0;const f=i[0];for(let C=0;Cu)&&(u=E.x),(!C||E.y>d)&&(d=E.y)}const g=Math.min(u-s,d-l);let x=g/2;const v=new lf([],hf);if(g===0)return new de(s,l);for(let C=s;Cw.d||!w.d)&&(w=C,r&&console.log("found best %d after %d probes",Math.round(1e4*C.d)/1e4,I)),C.max-w.d<=t||(x=C.h/2,v.push(new Ra(C.p.x-x,C.p.y-x,x,i)),v.push(new Ra(C.p.x+x,C.p.y-x,x,i)),v.push(new Ra(C.p.x-x,C.p.y+x,x,i)),v.push(new Ra(C.p.x+x,C.p.y+x,x,i)),I+=4)}return r&&(console.log(`num probes: ${I}`),console.log(`best distance: ${w.d}`)),w.p}function hf(i,t){return t.max-i.max}function Ra(i,t,r,s){this.p=new de(i,t),this.h=r,this.d=function(l,u){let d=!1,f=1/0;for(let g=0;gl.y!=E.y>l.y&&l.x<(E.x-C.x)*(l.y-C.y)/(E.y-C.y)+C.x&&(d=!d),f=Math.min(f,Rh(l,C,E))}}return(d?1:-1)*Math.sqrt(f)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}var hi;M.aq=void 0,(hi=M.aq||(M.aq={}))[hi.center=1]="center",hi[hi.left=2]="left",hi[hi.right=3]="right",hi[hi.top=4]="top",hi[hi.bottom=5]="bottom",hi[hi["top-left"]=6]="top-left",hi[hi["top-right"]=7]="top-right",hi[hi["bottom-left"]=8]="bottom-left",hi[hi["bottom-right"]=9]="bottom-right";const us=7,oh=Number.POSITIVE_INFINITY;function Qu(i,t){return t[1]!==oh?function(r,s,l){let u=0,d=0;switch(s=Math.abs(s),l=Math.abs(l),r){case"top-right":case"top-left":case"top":d=l-us;break;case"bottom-right":case"bottom-left":case"bottom":d=-l+us}switch(r){case"top-right":case"bottom-right":case"right":u=-s;break;case"top-left":case"bottom-left":case"left":u=s}return[u,d]}(i,t[0],t[1]):function(r,s){let l=0,u=0;s<0&&(s=0);const d=s/Math.SQRT2;switch(r){case"top-right":case"top-left":u=d-us;break;case"bottom-right":case"bottom-left":u=-d+us;break;case"bottom":u=-s+us;break;case"top":u=s-us}switch(r){case"top-right":case"bottom-right":l=-d;break;case"top-left":case"bottom-left":l=d;break;case"left":l=s;break;case"right":l=-s}return[l,u]}(i,t[0])}function ed(i,t,r){var s;const l=i.layout,u=(s=l.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(t,{},r);if(u){const f=u.values,g=[];for(let x=0;xI*Zt);v.startsWith("top")?w[1]-=us:v.startsWith("bottom")&&(w[1]+=us),g[x+1]=w}return new Yi(g)}const d=l.get("text-variable-anchor");if(d){let f;f=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[l.get("text-radial-offset").evaluate(t,{},r)*Zt,oh]:l.get("text-offset").evaluate(t,{},r).map(x=>x*Zt);const g=[];for(const x of d)g.push(x,Qu(x,f));return new Yi(g)}return null}function lh(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function uf(i,t,r,s,l,u,d,f,g,x,v){let w=u.textMaxSize.evaluate(t,{});w===void 0&&(w=d);const I=i.layers[0].layout,C=I.get("icon-offset").evaluate(t,{},v),E=id(r.horizontal),z=d/24,O=i.tilePixelRatio*z,$=i.tilePixelRatio*w/24,ne=i.tilePixelRatio*f,W=i.tilePixelRatio*I.get("symbol-spacing"),te=I.get("text-padding")*i.tilePixelRatio,ce=function(pe,Oe,Be,Ze=1){const xt=pe.get("icon-padding").evaluate(Oe,{},Be),yt=xt&&xt.values;return[yt[0]*Ze,yt[1]*Ze,yt[2]*Ze,yt[3]*Ze]}(I,t,v,i.tilePixelRatio),ge=I.get("text-max-angle")/180*Math.PI,Me=I.get("text-rotation-alignment")!=="viewport"&&I.get("symbol-placement")!=="point",Ue=I.get("icon-rotation-alignment")==="map"&&I.get("symbol-placement")!=="point",Ae=I.get("symbol-placement"),Ie=W/2,Fe=I.get("icon-text-fit");let De;s&&Fe!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(De=Iu(s,r.vertical,Fe,I.get("icon-text-fit-padding"),C,z)),E&&(s=Iu(s,E,Fe,I.get("icon-text-fit-padding"),C,z)));const Ee=(pe,Oe)=>{Oe.x<0||Oe.x>=$t||Oe.y<0||Oe.y>=$t||function(Be,Ze,xt,yt,Xt,Lr,ui,Wt,Di,Li,Ri,Ft,Kt,Ti,di,Bi,pi,xr,Xi,ht,bt,Pt,sr,Dt,Ba){const sn=Be.addToLineVertexArray(Ze,xt);let an,Rr,vr,ti,Cn=0,Xo=0,ad=0,od=0,gh=-1,_h=-1;const Mn={};let ld=wa("");if(Be.allowVerticalPlacement&&yt.vertical){const Si=Wt.layout.get("text-rotate").evaluate(bt,{},Dt)+90;vr=new Jl(Di,Ze,Li,Ri,Ft,yt.vertical,Kt,Ti,di,Si),ui&&(ti=new Jl(Di,Ze,Li,Ri,Ft,ui,pi,xr,di,Si))}if(Xt){const Si=Wt.layout.get("icon-rotate").evaluate(bt,{}),br=Wt.layout.get("icon-text-fit")!=="none",Us=Ju(Xt,Si,sr,br),Gr=ui?Ju(ui,Si,sr,br):void 0;Rr=new Jl(Di,Ze,Li,Ri,Ft,Xt,pi,xr,!1,Si),Cn=4*Us.length;const js=Be.iconSizeData;let on=null;js.kind==="source"?(on=[nn*Wt.layout.get("icon-size").evaluate(bt,{})],on[0]>ls&&Gt(`${Be.layerIds[0]}: Value for "icon-size" is >= ${$o}. Reduce your "icon-size".`)):js.kind==="composite"&&(on=[nn*Pt.compositeIconSizes[0].evaluate(bt,{},Dt),nn*Pt.compositeIconSizes[1].evaluate(bt,{},Dt)],(on[0]>ls||on[1]>ls)&&Gt(`${Be.layerIds[0]}: Value for "icon-size" is >= ${$o}. Reduce your "icon-size".`)),Be.addSymbols(Be.icon,Us,on,ht,Xi,bt,M.ah.none,Ze,sn.lineStartIndex,sn.lineLength,-1,Dt),gh=Be.icon.placedSymbolArray.length-1,Gr&&(Xo=4*Gr.length,Be.addSymbols(Be.icon,Gr,on,ht,Xi,bt,M.ah.vertical,Ze,sn.lineStartIndex,sn.lineLength,-1,Dt),_h=Be.icon.placedSymbolArray.length-1)}const cd=Object.keys(yt.horizontal);for(const Si of cd){const br=yt.horizontal[Si];if(!an){ld=wa(br.text);const Gr=Wt.layout.get("text-rotate").evaluate(bt,{},Dt);an=new Jl(Di,Ze,Li,Ri,Ft,br,Kt,Ti,di,Gr)}const Us=br.positionedLines.length===1;if(ad+=td(Be,Ze,br,Lr,Wt,di,bt,Bi,sn,yt.vertical?M.ah.horizontal:M.ah.horizontalOnly,Us?cd:[Si],Mn,gh,Pt,Dt),Us)break}yt.vertical&&(od+=td(Be,Ze,yt.vertical,Lr,Wt,di,bt,Bi,sn,M.ah.vertical,["vertical"],Mn,_h,Pt,Dt));const ff=an?an.boxStartIndex:Be.collisionBoxArray.length,mf=an?an.boxEndIndex:Be.collisionBoxArray.length,gf=vr?vr.boxStartIndex:Be.collisionBoxArray.length,_f=vr?vr.boxEndIndex:Be.collisionBoxArray.length,yf=Rr?Rr.boxStartIndex:Be.collisionBoxArray.length,xf=Rr?Rr.boxEndIndex:Be.collisionBoxArray.length,vf=ti?ti.boxStartIndex:Be.collisionBoxArray.length,bf=ti?ti.boxEndIndex:Be.collisionBoxArray.length;let Zr=-1;const Ql=(Si,br)=>Si&&Si.circleDiameter?Math.max(Si.circleDiameter,br):br;Zr=Ql(an,Zr),Zr=Ql(vr,Zr),Zr=Ql(Rr,Zr),Zr=Ql(ti,Zr);const hd=Zr>-1?1:0;hd&&(Zr*=Ba/Zt),Be.glyphOffsetArray.length>=Da.MAX_GLYPHS&&Gt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),bt.sortKey!==void 0&&Be.addToSortKeyRanges(Be.symbolInstances.length,bt.sortKey);const wf=ed(Wt,bt,Dt),[Tf,Sf]=function(Si,br){const Us=Si.length,Gr=br==null?void 0:br.values;if((Gr==null?void 0:Gr.length)>0)for(let js=0;js=0?Mn.right:-1,Mn.center>=0?Mn.center:-1,Mn.left>=0?Mn.left:-1,Mn.vertical||-1,gh,_h,ld,ff,mf,gf,_f,yf,xf,vf,bf,Li,ad,od,Cn,Xo,hd,0,Kt,Zr,Tf,Sf)}(i,Oe,pe,r,s,l,De,i.layers[0],i.collisionBoxArray,t.index,t.sourceLayerIndex,i.index,O,[te,te,te,te],Me,g,ne,ce,Ue,C,t,u,x,v,d)};if(Ae==="line")for(const pe of Zu(t.geometry,0,0,$t,$t)){const Oe=of(pe,W,ge,r.vertical||E,s,24,$,i.overscaling,$t);for(const Be of Oe)E&&df(i,E.text,Ie,Be)||Ee(pe,Be)}else if(Ae==="line-center"){for(const pe of t.geometry)if(pe.length>1){const Oe=af(pe,ge,r.vertical||E,s,24,$);Oe&&Ee(pe,Oe)}}else if(t.type==="Polygon")for(const pe of Ys(t.geometry,0)){const Oe=cf(pe,16);Ee(pe[0],new hs(Oe.x,Oe.y,0))}else if(t.type==="LineString")for(const pe of t.geometry)Ee(pe,new hs(pe[0].x,pe[0].y,0));else if(t.type==="Point")for(const pe of t.geometry)for(const Oe of pe)Ee([Oe],new hs(Oe.x,Oe.y,0))}function td(i,t,r,s,l,u,d,f,g,x,v,w,I,C,E){const z=function(ne,W,te,ce,ge,Me,Ue,Ae){const Ie=ce.layout.get("text-rotate").evaluate(Me,{})*Math.PI/180,Fe=[];for(const De of W.positionedLines)for(const Ee of De.positionedGlyphs){if(!Ee.rect)continue;const pe=Ee.rect||{};let Oe=_u+1,Be=!0,Ze=1,xt=0;const yt=(ge||Ae)&&Ee.vertical,Xt=Ee.metrics.advance*Ee.scale/2;if(Ae&&W.verticalizable&&(xt=De.lineOffset/2-(Ee.imageName?-(Zt-Ee.metrics.width*Ee.scale)/2:(Ee.scale-1)*Zt)),Ee.imageName){const ht=Ue[Ee.imageName];Be=ht.sdf,Ze=ht.pixelRatio,Oe=Hi/Ze}const Lr=ge?[Ee.x+Xt,Ee.y]:[0,0];let ui=ge?[0,0]:[Ee.x+Xt+te[0],Ee.y+te[1]-xt],Wt=[0,0];yt&&(Wt=ui,ui=[0,0]);const Di=Ee.metrics.isDoubleResolution?2:1,Li=(Ee.metrics.left-Oe)*Ee.scale-Xt+ui[0],Ri=(-Ee.metrics.top-Oe)*Ee.scale+ui[1],Ft=Li+pe.w/Di*Ee.scale/Ze,Kt=Ri+pe.h/Di*Ee.scale/Ze,Ti=new de(Li,Ri),di=new de(Ft,Ri),Bi=new de(Li,Kt),pi=new de(Ft,Kt);if(yt){const ht=new de(-Xt,Xt-Uo),bt=-Math.PI/2,Pt=Zt/2-Xt,sr=new de(5-Uo-Pt,-(Ee.imageName?Pt:0)),Dt=new de(...Wt);Ti._rotateAround(bt,ht)._add(sr)._add(Dt),di._rotateAround(bt,ht)._add(sr)._add(Dt),Bi._rotateAround(bt,ht)._add(sr)._add(Dt),pi._rotateAround(bt,ht)._add(sr)._add(Dt)}if(Ie){const ht=Math.sin(Ie),bt=Math.cos(Ie),Pt=[bt,-ht,ht,bt];Ti._matMult(Pt),di._matMult(Pt),Bi._matMult(Pt),pi._matMult(Pt)}const xr=new de(0,0),Xi=new de(0,0);Fe.push({tl:Ti,tr:di,bl:Bi,br:pi,tex:pe,writingMode:W.writingMode,glyphOffset:Lr,sectionIndex:Ee.sectionIndex,isSDF:Be,pixelOffsetTL:xr,pixelOffsetBR:Xi,minFontScaleX:0,minFontScaleY:0})}return Fe}(0,r,f,l,u,d,s,i.allowVerticalPlacement),O=i.textSizeData;let $=null;O.kind==="source"?($=[nn*l.layout.get("text-size").evaluate(d,{})],$[0]>ls&&Gt(`${i.layerIds[0]}: Value for "text-size" is >= ${$o}. Reduce your "text-size".`)):O.kind==="composite"&&($=[nn*C.compositeTextSizes[0].evaluate(d,{},E),nn*C.compositeTextSizes[1].evaluate(d,{},E)],($[0]>ls||$[1]>ls)&&Gt(`${i.layerIds[0]}: Value for "text-size" is >= ${$o}. Reduce your "text-size".`)),i.addSymbols(i.text,z,$,f,u,d,x,t,g.lineStartIndex,g.lineLength,I,E);for(const ne of v)w[ne]=i.text.placedSymbolArray.length-1;return 4*z.length}function id(i){for(const t in i)return i[t];return null}function df(i,t,r,s){const l=i.compareText;if(t in l){const u=l[t];for(let d=u.length-1;d>=0;d--)if(s.dist(u[d])>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);const u=rd[15&s];if(!u)throw new Error("Unrecognized array type.");const[d]=new Uint16Array(t,2,1),[f]=new Uint32Array(t,4,1);return new ch(f,d,u,t)}constructor(t,r=64,s=Float64Array,l){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=s,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const u=rd.indexOf(this.ArrayType),d=2*t*this.ArrayType.BYTES_PER_ELEMENT,f=t*this.IndexArrayType.BYTES_PER_ELEMENT,g=(8-f%8)%8;if(u<0)throw new Error(`Unexpected typed array class: ${s}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+g,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+d+f+g),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+g,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+u]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=t)}add(t,r){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=t,this.coords[this._pos++]=r,s}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return hh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,r,s,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:u,coords:d,nodeSize:f}=this,g=[0,u.length-1,0],x=[];for(;g.length;){const v=g.pop()||0,w=g.pop()||0,I=g.pop()||0;if(w-I<=f){for(let O=I;O<=w;O++){const $=d[2*O],ne=d[2*O+1];$>=t&&$<=s&&ne>=r&&ne<=l&&x.push(u[O])}continue}const C=I+w>>1,E=d[2*C],z=d[2*C+1];E>=t&&E<=s&&z>=r&&z<=l&&x.push(u[C]),(v===0?t<=E:r<=z)&&(g.push(I),g.push(C-1),g.push(1-v)),(v===0?s>=E:l>=z)&&(g.push(C+1),g.push(w),g.push(1-v))}return x}within(t,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:u,nodeSize:d}=this,f=[0,l.length-1,0],g=[],x=s*s;for(;f.length;){const v=f.pop()||0,w=f.pop()||0,I=f.pop()||0;if(w-I<=d){for(let O=I;O<=w;O++)sd(u[2*O],u[2*O+1],t,r)<=x&&g.push(l[O]);continue}const C=I+w>>1,E=u[2*C],z=u[2*C+1];sd(E,z,t,r)<=x&&g.push(l[C]),(v===0?t-s<=E:r-s<=z)&&(f.push(I),f.push(C-1),f.push(1-v)),(v===0?t+s>=E:r+s>=z)&&(f.push(C+1),f.push(w),f.push(1-v))}return g}}function hh(i,t,r,s,l,u){if(l-s<=r)return;const d=s+l>>1;nd(i,t,d,s,l,u),hh(i,t,r,s,d-1,1-u),hh(i,t,r,d+1,l,1-u)}function nd(i,t,r,s,l,u){for(;l>s;){if(l-s>600){const x=l-s+1,v=r-s+1,w=Math.log(x),I=.5*Math.exp(2*w/3),C=.5*Math.sqrt(w*I*(x-I)/x)*(v-x/2<0?-1:1);nd(i,t,r,Math.max(s,Math.floor(r-v*I/x+C)),Math.min(l,Math.floor(r+(x-v)*I/x+C)),u)}const d=t[2*r+u];let f=s,g=l;for(Go(i,t,s,r),t[2*l+u]>d&&Go(i,t,s,l);fd;)g--}t[2*s+u]===d?Go(i,t,s,g):(g++,Go(i,t,g,l)),g<=r&&(s=g+1),r<=g&&(l=g-1)}}function Go(i,t,r,s){uh(i,r,s),uh(t,2*r,2*s),uh(t,2*r+1,2*s+1)}function uh(i,t,r){const s=i[t];i[t]=i[r],i[r]=s}function sd(i,t,r,s){const l=i-r,u=t-s;return l*l+u*u}var dh;M.bg=void 0,(dh=M.bg||(M.bg={})).create="create",dh.load="load",dh.fullLoad="fullLoad";let Yl=null,Ho=[];const ph=1e3/60,fh="loadTime",mh="fullLoadTime",pf={mark(i){performance.mark(i)},frame(i){const t=i;Yl!=null&&Ho.push(t-Yl),Yl=t},clearMetrics(){Yl=null,Ho=[],performance.clearMeasures(fh),performance.clearMeasures(mh);for(const i in M.bg)performance.clearMarks(M.bg[i])},getPerformanceMetrics(){performance.measure(fh,M.bg.create,M.bg.load),performance.measure(mh,M.bg.create,M.bg.fullLoad);const i=performance.getEntriesByName(fh)[0].duration,t=performance.getEntriesByName(mh)[0].duration,r=Ho.length,s=1/(Ho.reduce((u,d)=>u+d,0)/r/1e3),l=Ho.filter(u=>u>ph).reduce((u,d)=>u+(d-ph)/ph,0);return{loadTime:i,fullLoadTime:t,fps:s,percentDroppedFrames:l/(r+l)*100,totalFrames:r}}};M.$=class extends T{},M.A=Aa,M.B=Tc,M.C=function(i){if(Vi==null){const t=i.navigator?i.navigator.userAgent:null;Vi=!!i.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Vi},M.D=Le,M.E=kn,M.F=class{constructor(i,t){this.target=i,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new nf(()=>this.process()),this.subscription=function(r,s,l,u){return r.addEventListener(s,l,!1),{unsubscribe:()=>{r.removeEventListener(s,l,!1)}}}(this.target,"message",r=>this.receive(r)),this.globalScope=Wi(self)?i:window}registerMessageHandler(i,t){this.messageHandlers[i]=t}sendAsync(i,t){return new Promise((r,s)=>{const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[l]={resolve:r,reject:s},t&&t.signal.addEventListener("abort",()=>{delete this.resolveRejects[l];const f={id:l,type:"",origin:location.origin,targetMapId:i.targetMapId,sourceMapId:this.mapId};this.target.postMessage(f)},{once:!0});const u=[],d=Object.assign(Object.assign({},i),{id:l,sourceMapId:this.mapId,origin:location.origin,data:Kn(i.data,u)});this.target.postMessage(d,{transfer:u})})}receive(i){const t=i.data,r=t.id;if(!(t.origin!=="file://"&&location.origin!=="file://"&&t.origin!=="resource://android"&&location.origin!=="resource://android"&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type===""){delete this.tasks[r];const s=this.abortControllers[r];return delete this.abortControllers[r],void(s&&s.abort())}if(Wi(self)||t.mustQueue)return this.tasks[r]=t,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,t)}}process(){if(this.taskQueue.length===0)return;const i=this.taskQueue.shift(),t=this.tasks[i];delete this.tasks[i],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(i,t)}processTask(i,t){return p(this,void 0,void 0,function*(){if(t.type===""){const l=this.resolveRejects[i];return delete this.resolveRejects[i],l?void(t.error?l.reject(Jn(t.error)):l.resolve(Jn(t.data))):void 0}if(!this.messageHandlers[t.type])return void this.completeTask(i,new Error(`Could not find a registered handler for ${t.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const r=Jn(t.data),s=new AbortController;this.abortControllers[i]=s;try{const l=yield this.messageHandlers[t.type](t.sourceMapId,r,s);this.completeTask(i,null,l)}catch(l){this.completeTask(i,l)}})}completeTask(i,t,r){const s=[];delete this.abortControllers[i];const l={id:i,type:"",sourceMapId:this.mapId,origin:location.origin,error:t?Kn(t):null,data:Kn(r,s)};this.target.postMessage(l,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},M.G=Sr,M.H=function(){var i=new Aa(16);return Aa!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},M.I=Kc,M.J=function(i,t,r){var s,l,u,d,f,g,x,v,w,I,C,E,z=r[0],O=r[1],$=r[2];return t===i?(i[12]=t[0]*z+t[4]*O+t[8]*$+t[12],i[13]=t[1]*z+t[5]*O+t[9]*$+t[13],i[14]=t[2]*z+t[6]*O+t[10]*$+t[14],i[15]=t[3]*z+t[7]*O+t[11]*$+t[15]):(l=t[1],u=t[2],d=t[3],f=t[4],g=t[5],x=t[6],v=t[7],w=t[8],I=t[9],C=t[10],E=t[11],i[0]=s=t[0],i[1]=l,i[2]=u,i[3]=d,i[4]=f,i[5]=g,i[6]=x,i[7]=v,i[8]=w,i[9]=I,i[10]=C,i[11]=E,i[12]=s*z+f*O+w*$+t[12],i[13]=l*z+g*O+I*$+t[13],i[14]=u*z+x*O+C*$+t[14],i[15]=d*z+v*O+E*$+t[15]),i},M.K=function(i,t,r){var s=r[0],l=r[1],u=r[2];return i[0]=t[0]*s,i[1]=t[1]*s,i[2]=t[2]*s,i[3]=t[3]*s,i[4]=t[4]*l,i[5]=t[5]*l,i[6]=t[6]*l,i[7]=t[7]*l,i[8]=t[8]*u,i[9]=t[9]*u,i[10]=t[10]*u,i[11]=t[11]*u,i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],i},M.L=Vh,M.M=function(i,t){const r={};for(let s=0;s{const t=window.document.createElement("video");return t.muted=!0,new Promise(r=>{t.onloadstart=()=>{r(t)};for(const s of i){const l=window.document.createElement("source");Vr(s)||(t.crossOrigin="Anonymous"),l.src=s,t.appendChild(l)}})},M.a4=function(){return cn++},M.a5=Ce,M.a6=Da,M.a7=co,M.a8=Vs,M.a9=Uu,M.aA=function(i){if(i.type==="custom")return new rf(i);switch(i.type){case"background":return new Qp(i);case"circle":return new Nd(i);case"fill":return new rp(i);case"fill-extrusion":return new yp(i);case"heatmap":return new jd(i);case"hillshade":return new qd(i);case"line":return new Pp(i);case"raster":return new tf(i);case"symbol":return new Hl(i)}},M.aB=et,M.aC=function(i,t){if(!i)return[{command:"setStyle",args:[t]}];let r=[];try{if(!ut(i.version,t.version))return[{command:"setStyle",args:[t]}];ut(i.center,t.center)||r.push({command:"setCenter",args:[t.center]}),ut(i.zoom,t.zoom)||r.push({command:"setZoom",args:[t.zoom]}),ut(i.bearing,t.bearing)||r.push({command:"setBearing",args:[t.bearing]}),ut(i.pitch,t.pitch)||r.push({command:"setPitch",args:[t.pitch]}),ut(i.sprite,t.sprite)||r.push({command:"setSprite",args:[t.sprite]}),ut(i.glyphs,t.glyphs)||r.push({command:"setGlyphs",args:[t.glyphs]}),ut(i.transition,t.transition)||r.push({command:"setTransition",args:[t.transition]}),ut(i.light,t.light)||r.push({command:"setLight",args:[t.light]}),ut(i.terrain,t.terrain)||r.push({command:"setTerrain",args:[t.terrain]}),ut(i.sky,t.sky)||r.push({command:"setSky",args:[t.sky]}),ut(i.projection,t.projection)||r.push({command:"setProjection",args:[t.projection]});const s={},l=[];(function(d,f,g,x){let v;for(v in f=f||{},d=d||{})Object.prototype.hasOwnProperty.call(d,v)&&(Object.prototype.hasOwnProperty.call(f,v)||Kr(v,g,x));for(v in f)Object.prototype.hasOwnProperty.call(f,v)&&(Object.prototype.hasOwnProperty.call(d,v)?ut(d[v],f[v])||(d[v].type==="geojson"&&f[v].type==="geojson"&&En(d,f,v)?Et(g,{command:"setGeoJSONSourceData",args:[v,f[v].data]}):Nr(v,f,g,x)):fs(v,f,g))})(i.sources,t.sources,l,s);const u=[];i.layers&&i.layers.forEach(d=>{"source"in d&&s[d.source]?r.push({command:"removeLayer",args:[d.id]}):u.push(d)}),r=r.concat(l),function(d,f,g){f=f||[];const x=(d=d||[]).map(ms),v=f.map(ms),w=d.reduce(gs,{}),I=f.reduce(gs,{}),C=x.slice(),E=Object.create(null);let z,O,$,ne,W;for(let te=0,ce=0;te@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,s,l,u)=>{const d=l||u;return t[s]=!d||d.toLowerCase(),""}),t["max-age"]){const r=parseInt(t["max-age"],10);isNaN(r)?delete t["max-age"]:t["max-age"]=r}return t},M.ab=function(i,t){const r=[];for(const s in i)s in t||r.push(s);return r},M.ac=mi,M.ad=function(i,t,r){var s=Math.sin(r),l=Math.cos(r),u=t[0],d=t[1],f=t[2],g=t[3],x=t[4],v=t[5],w=t[6],I=t[7];return t!==i&&(i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15]),i[0]=u*l+x*s,i[1]=d*l+v*s,i[2]=f*l+w*s,i[3]=g*l+I*s,i[4]=x*l-u*s,i[5]=v*l-d*s,i[6]=w*l-f*s,i[7]=I*l-g*s,i},M.ae=function(i){var t=new Aa(16);return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],t},M.af=Ol,M.ag=function(i,t){let r=0,s=0;if(i.kind==="constant")s=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:l,minZoom:u,maxZoom:d}=i,f=l?mi(ki.interpolationFactor(l,t,u,d),0,1):0;i.kind==="camera"?s=Mi.number(i.minSize,i.maxSize,f):r=f}return{uSizeT:r,uSize:s}},M.ai=function(i,{uSize:t,uSizeT:r},{lowerSize:s,upperSize:l}){return i.kind==="source"?s/nn:i.kind==="composite"?Mi.number(s/nn,l/nn,r):t},M.aj=eh,M.ak=function(i,t,r,s){const l=t.y-i.y,u=t.x-i.x,d=s.y-r.y,f=s.x-r.x,g=d*u-f*l;if(g===0)return null;const x=(f*(i.y-r.y)-d*(i.x-r.x))/g;return new de(i.x+x*u,i.y+x*l)},M.al=Zu,M.am=Dh,M.an=Rc,M.ao=function(i){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(const u of i)t=Math.min(t,u.x),r=Math.min(r,u.y),s=Math.max(s,u.x),l=Math.max(l,u.y);return[t,r,s,l]},M.ap=Zt,M.ar=Qc,M.as=function(i,t){var r=t[0],s=t[1],l=t[2],u=t[3],d=t[4],f=t[5],g=t[6],x=t[7],v=t[8],w=t[9],I=t[10],C=t[11],E=t[12],z=t[13],O=t[14],$=t[15],ne=r*f-s*d,W=r*g-l*d,te=r*x-u*d,ce=s*g-l*f,ge=s*x-u*f,Me=l*x-u*g,Ue=v*z-w*E,Ae=v*O-I*E,Ie=v*$-C*E,Fe=w*O-I*z,De=w*$-C*z,Ee=I*$-C*O,pe=ne*Ee-W*De+te*Fe+ce*Ie-ge*Ae+Me*Ue;return pe?(i[0]=(f*Ee-g*De+x*Fe)*(pe=1/pe),i[1]=(l*De-s*Ee-u*Fe)*pe,i[2]=(z*Me-O*ge+$*ce)*pe,i[3]=(I*ge-w*Me-C*ce)*pe,i[4]=(g*Ie-d*Ee-x*Ae)*pe,i[5]=(r*Ee-l*Ie+u*Ae)*pe,i[6]=(O*te-E*Me-$*W)*pe,i[7]=(v*Me-I*te+C*W)*pe,i[8]=(d*De-f*Ie+x*Ue)*pe,i[9]=(s*Ie-r*De-u*Ue)*pe,i[10]=(E*ge-z*te+$*ne)*pe,i[11]=(w*te-v*ge-C*ne)*pe,i[12]=(f*Ae-d*Fe-g*Ue)*pe,i[13]=(r*Fe-s*Ae+l*Ue)*pe,i[14]=(z*W-E*ce-O*ne)*pe,i[15]=(v*ce-w*W+I*ne)*pe,i):null},M.at=lh,M.au=Yc,M.av=ch,M.aw=function(){const i={},t=le.$version;for(const r in le.$root){const s=le.$root[r];if(s.required){let l=null;l=r==="version"?t:s.type==="array"?[]:{},l!=null&&(i[r]=l)}}return i},M.ax=So,M.ay=Ai,M.az=function(i){i=i.slice();const t=Object.create(null);for(let r=0;r25||s<0||s>=1||r<0||r>=1)},M.bc=function(i,t){return i[0]=t[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=t[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=t[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},M.bd=class extends b{},M.be=nh,M.bf=pf,M.bh=Yt,M.bi=function(i,t){or.REGISTERED_PROTOCOLS[i]=t},M.bj=function(i){delete or.REGISTERED_PROTOCOLS[i]},M.bk=function(i,t){const r={};for(let l=0;lEe*Zt)}let Ae=d?"center":r.get("text-justify").evaluate(x,{},i.canonical);const Ie=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(x,{},i.canonical)*Zt:1/0,Fe=()=>{i.bucket.allowVerticalPlacement&&Io(te)&&(E.vertical=ql(z,i.glyphMap,i.glyphPositions,i.imagePositions,v,Ie,u,Me,"left",ge,$,M.ah.vertical,!0,I,w))};if(!d&&Ue){const De=new Set;if(Ae==="auto")for(let pe=0;pep(void 0,void 0,void 0,function*(){if(i.byteLength===0)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(i)],{type:"image/png"});try{return createImageBitmap(t)}catch(r){throw new Error(`Could not load image because of ${r.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),M.e=gi,M.f=i=>new Promise((t,r)=>{const s=new Image;s.onload=()=>{t(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame(()=>{s.src=un})},s.onerror=()=>r(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 l=new Blob([new Uint8Array(i)],{type:"image/png"});s.src=i.byteLength?URL.createObjectURL(l):un}),M.g=si,M.h=(i,t)=>Ir(gi(i,{type:"json"}),t),M.i=Wi,M.j=Wr,M.k=lr,M.l=(i,t)=>Ir(gi(i,{type:"arrayBuffer"}),t),M.m=Ir,M.n=function(i){return new Xc(i).readFields(Up,[])},M.o=Lo,M.p=yu,M.q=h,M.r=wc,M.s=Vr,M.t=wo,M.u=Sn,M.v=le,M.w=Gt,M.x=function([i,t,r]){return t+=90,t*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(t)*Math.sin(r),y:i*Math.sin(t)*Math.sin(r),z:i*Math.cos(r)}},M.y=Mi,M.z=wt}),he("worker",["./shared"],function(M){class p{constructor(A){this.keyCache={},A&&this.replace(A)}replace(A){this._layerConfigs={},this._layers={},this.update(A,[])}update(A,P){for(const V of A){this._layerConfigs[V.id]=V;const K=this._layers[V.id]=M.aA(V);K._featureFilter=M.a7(K.filter),this.keyCache[V.id]&&delete this.keyCache[V.id]}for(const V of P)delete this.keyCache[V],delete this._layerConfigs[V],delete this._layers[V];this.familiesBySource={};const R=M.bk(Object.values(this._layerConfigs),this.keyCache);for(const V of R){const K=V.map(oe=>this._layers[oe.id]),Q=K[0];if(Q.visibility==="none")continue;const ie=Q.source||"";let H=this.familiesBySource[ie];H||(H=this.familiesBySource[ie]={});const ue=Q.sourceLayer||"_geojsonTileLayer";let me=H[ue];me||(me=H[ue]=[]),me.push(K)}}}class Je{constructor(A){const P={},R=[];for(const ie in A){const H=A[ie],ue=P[ie]={};for(const me in H){const oe=H[+me];if(!oe||oe.bitmap.width===0||oe.bitmap.height===0)continue;const ve={x:0,y:0,w:oe.bitmap.width+2,h:oe.bitmap.height+2};R.push(ve),ue[me]={rect:ve,metrics:oe.metrics}}}const{w:V,h:K}=M.p(R),Q=new M.o({width:V||1,height:K||1});for(const ie in A){const H=A[ie];for(const ue in H){const me=H[+ue];if(!me||me.bitmap.width===0||me.bitmap.height===0)continue;const oe=P[ie][ue].rect;M.o.copy(me.bitmap,Q,{x:0,y:0},{x:oe.x+1,y:oe.y+1},me.bitmap)}}this.image=Q,this.positions=P}}M.bl("GlyphAtlas",Je);class Ge{constructor(A){this.tileID=new M.S(A.tileID.overscaledZ,A.tileID.wrap,A.tileID.canonical.z,A.tileID.canonical.x,A.tileID.canonical.y),this.uid=A.uid,this.zoom=A.zoom,this.pixelRatio=A.pixelRatio,this.tileSize=A.tileSize,this.source=A.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=A.showCollisionBoxes,this.collectResourceTiming=!!A.collectResourceTiming,this.returnDependencies=!!A.returnDependencies,this.promoteId=A.promoteId,this.inFlightDependencies=[]}parse(A,P,R,V){return M._(this,void 0,void 0,function*(){this.status="parsing",this.data=A,this.collisionBoxArray=new M.a5;const K=new M.bm(Object.keys(A.layers).sort()),Q=new M.bn(this.tileID,this.promoteId);Q.bucketLayerIDs=[];const ie={},H={featureIndex:Q,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:R},ue=P.familiesBySource[this.source];for(const tt in ue){const ft=A.layers[tt];if(!ft)continue;ft.version===1&&M.w(`Vector tile source "${this.source}" layer "${tt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Ct=K.encode(tt),Ht=[];for(let Qt=0;Qt=vi.maxzoom||vi.visibility!=="none"&&(He(Qt,this.zoom,R),(ie[vi.id]=vi.createBucket({index:Q.bucketLayerIDs.length,layers:Qt,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ct,sourceID:this.source})).populate(Ht,H,this.tileID.canonical),Q.bucketLayerIDs.push(Qt.map(zn=>zn.id)))}}const me=M.aF(H.glyphDependencies,tt=>Object.keys(tt).map(Number));this.inFlightDependencies.forEach(tt=>tt==null?void 0:tt.abort()),this.inFlightDependencies=[];let oe=Promise.resolve({});if(Object.keys(me).length){const tt=new AbortController;this.inFlightDependencies.push(tt),oe=V.sendAsync({type:"GG",data:{stacks:me,source:this.source,tileID:this.tileID,type:"glyphs"}},tt)}const ve=Object.keys(H.iconDependencies);let Ve=Promise.resolve({});if(ve.length){const tt=new AbortController;this.inFlightDependencies.push(tt),Ve=V.sendAsync({type:"GI",data:{icons:ve,source:this.source,tileID:this.tileID,type:"icons"}},tt)}const Ne=Object.keys(H.patternDependencies);let ot=Promise.resolve({});if(Ne.length){const tt=new AbortController;this.inFlightDependencies.push(tt),ot=V.sendAsync({type:"GI",data:{icons:Ne,source:this.source,tileID:this.tileID,type:"patterns"}},tt)}const[Ke,lt,rt]=yield Promise.all([oe,Ve,ot]),Ut=new Je(Ke),zt=new M.bo(lt,rt);for(const tt in ie){const ft=ie[tt];ft instanceof M.a6?(He(ft.layers,this.zoom,R),M.bp({bucket:ft,glyphMap:Ke,glyphPositions:Ut.positions,imageMap:lt,imagePositions:zt.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):ft.hasPattern&&(ft instanceof M.bq||ft instanceof M.br||ft instanceof M.bs)&&(He(ft.layers,this.zoom,R),ft.addFeatures(H,this.tileID.canonical,zt.patternPositions))}return this.status="done",{buckets:Object.values(ie).filter(tt=>!tt.isEmpty()),featureIndex:Q,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Ut.image,imageAtlas:zt,glyphMap:this.returnDependencies?Ke:null,iconMap:this.returnDependencies?lt:null,glyphPositions:this.returnDependencies?Ut.positions:null}})}}function He(U,A,P){const R=new M.z(A);for(const V of U)V.recalculate(R,P)}class de{constructor(A,P,R){this.actor=A,this.layerIndex=P,this.availableImages=R,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(A,P){return M._(this,void 0,void 0,function*(){const R=yield M.l(A.request,P);try{return{vectorTile:new M.bt.VectorTile(new M.bu(R.data)),rawData:R.data,cacheControl:R.cacheControl,expires:R.expires}}catch(V){const K=new Uint8Array(R.data);let Q=`Unable to parse the tile at ${A.request.url}, `;throw Q+=K[0]===31&&K[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${V.message}`,new Error(Q)}})}loadTile(A){return M._(this,void 0,void 0,function*(){const P=A.uid,R=!!(A&&A.request&&A.request.collectResourceTiming)&&new M.bv(A.request),V=new Ge(A);this.loading[P]=V;const K=new AbortController;V.abort=K;try{const Q=yield this.loadVectorTile(A,K);if(delete this.loading[P],!Q)return null;const ie=Q.rawData,H={};Q.expires&&(H.expires=Q.expires),Q.cacheControl&&(H.cacheControl=Q.cacheControl);const ue={};if(R){const oe=R.finish();oe&&(ue.resourceTiming=JSON.parse(JSON.stringify(oe)))}V.vectorTile=Q.vectorTile;const me=V.parse(Q.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[P]=V,this.fetching[P]={rawTileData:ie,cacheControl:H,resourceTiming:ue};try{const oe=yield me;return M.e({rawTileData:ie.slice(0)},oe,H,ue)}finally{delete this.fetching[P]}}catch(Q){throw delete this.loading[P],V.status="done",this.loaded[P]=V,Q}})}reloadTile(A){return M._(this,void 0,void 0,function*(){const P=A.uid;if(!this.loaded||!this.loaded[P])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const R=this.loaded[P];if(R.showCollisionBoxes=A.showCollisionBoxes,R.status==="parsing"){const V=yield R.parse(R.vectorTile,this.layerIndex,this.availableImages,this.actor);let K;if(this.fetching[P]){const{rawTileData:Q,cacheControl:ie,resourceTiming:H}=this.fetching[P];delete this.fetching[P],K=M.e({rawTileData:Q.slice(0)},V,ie,H)}else K=V;return K}if(R.status==="done"&&R.vectorTile)return R.parse(R.vectorTile,this.layerIndex,this.availableImages,this.actor)})}abortTile(A){return M._(this,void 0,void 0,function*(){const P=this.loading,R=A.uid;P&&P[R]&&P[R].abort&&(P[R].abort.abort(),delete P[R])})}removeTile(A){return M._(this,void 0,void 0,function*(){this.loaded&&this.loaded[A.uid]&&delete this.loaded[A.uid]})}}class se{constructor(){this.loaded={}}loadTile(A){return M._(this,void 0,void 0,function*(){const{uid:P,encoding:R,rawImageData:V,redFactor:K,greenFactor:Q,blueFactor:ie,baseShift:H}=A,ue=V.width+2,me=V.height+2,oe=M.b(V)?new M.R({width:ue,height:me},yield M.bw(V,-1,-1,ue,me)):V,ve=new M.bx(P,oe,R,K,Q,ie,H);return this.loaded=this.loaded||{},this.loaded[P]=ve,ve})}removeTile(A){const P=this.loaded,R=A.uid;P&&P[R]&&delete P[R]}}function Ot(U,A){if(U.length!==0){qt(U[0],A);for(var P=1;P=Math.abs(ie)?P-H+ie:ie-H+P,P=H}P+R>=0!=!!A&&U.reverse()}var kt=M.by(function U(A,P){var R,V=A&&A.type;if(V==="FeatureCollection")for(R=0;R>31}function Wi(U,A){for(var P=U.loadGeometry(),R=U.type,V=0,K=0,Q=P.length,ie=0;ieU},ri=Math.fround||(ar=new Float32Array(1),U=>(ar[0]=+U,ar[0]));var ar;const ni=3,yi=5,Ni=6;class or{constructor(A){this.options=Object.assign(Object.create(un),A),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(A){const{log:P,minZoom:R,maxZoom:V}=this.options;P&&console.time("total time");const K=`prepare ${A.length} points`;P&&console.time(K),this.points=A;const Q=[];for(let H=0;H=R;H--){const ue=+Date.now();ie=this.trees[H]=this._createTree(this._cluster(ie,H)),P&&console.log("z%d: %d clusters in %dms",H,ie.numItems,+Date.now()-ue)}return P&&console.timeEnd("total time"),this}getClusters(A,P){let R=((A[0]+180)%360+360)%360-180;const V=Math.max(-90,Math.min(90,A[1]));let K=A[2]===180?180:((A[2]+180)%360+360)%360-180;const Q=Math.max(-90,Math.min(90,A[3]));if(A[2]-A[0]>=360)R=-180,K=180;else if(R>K){const oe=this.getClusters([R,V,180,Q],P),ve=this.getClusters([-180,V,K,Q],P);return oe.concat(ve)}const ie=this.trees[this._limitZoom(P)],H=ie.range(Yt(R),Ai(Q),Yt(K),Ai(V)),ue=ie.data,me=[];for(const oe of H){const ve=this.stride*oe;me.push(ue[ve+yi]>1?si(ue,ve,this.clusterProps):this.points[ue[ve+ni]])}return me}getChildren(A){const P=this._getOriginId(A),R=this._getOriginZoom(A),V="No cluster with the specified id.",K=this.trees[R];if(!K)throw new Error(V);const Q=K.data;if(P*this.stride>=Q.length)throw new Error(V);const ie=this.options.radius/(this.options.extent*Math.pow(2,R-1)),H=K.within(Q[P*this.stride],Q[P*this.stride+1],ie),ue=[];for(const me of H){const oe=me*this.stride;Q[oe+4]===A&&ue.push(Q[oe+yi]>1?si(Q,oe,this.clusterProps):this.points[Q[oe+ni]])}if(ue.length===0)throw new Error(V);return ue}getLeaves(A,P,R){const V=[];return this._appendLeaves(V,A,P=P||10,R=R||0,0),V}getTile(A,P,R){const V=this.trees[this._limitZoom(A)],K=Math.pow(2,A),{extent:Q,radius:ie}=this.options,H=ie/Q,ue=(R-H)/K,me=(R+1+H)/K,oe={features:[]};return this._addTileFeatures(V.range((P-H)/K,ue,(P+1+H)/K,me),V.data,P,R,K,oe),P===0&&this._addTileFeatures(V.range(1-H/K,ue,1,me),V.data,K,R,K,oe),P===K-1&&this._addTileFeatures(V.range(0,ue,H/K,me),V.data,-1,R,K,oe),oe.features.length?oe:null}getClusterExpansionZoom(A){let P=this._getOriginZoom(A)-1;for(;P<=this.options.maxZoom;){const R=this.getChildren(A);if(P++,R.length!==1)break;A=R[0].properties.cluster_id}return P}_appendLeaves(A,P,R,V,K){const Q=this.getChildren(P);for(const ie of Q){const H=ie.properties;if(H&&H.cluster?K+H.point_count<=V?K+=H.point_count:K=this._appendLeaves(A,H.cluster_id,R,V,K):K1;let me,oe,ve;if(ue)me=Sr(P,H,this.clusterProps),oe=P[H],ve=P[H+1];else{const ot=this.points[P[H+ni]];me=ot.properties;const[Ke,lt]=ot.geometry.coordinates;oe=Yt(Ke),ve=Ai(lt)}const Ve={type:1,geometry:[[Math.round(this.options.extent*(oe*K-R)),Math.round(this.options.extent*(ve*K-V))]],tags:me};let Ne;Ne=ue||this.options.generateId?P[H+ni]:this.points[P[H+ni]].id,Ne!==void 0&&(Ve.id=Ne),Q.features.push(Ve)}}_limitZoom(A){return Math.max(this.options.minZoom,Math.min(Math.floor(+A),this.options.maxZoom+1))}_cluster(A,P){const{radius:R,extent:V,reduce:K,minPoints:Q}=this.options,ie=R/(V*Math.pow(2,P)),H=A.data,ue=[],me=this.stride;for(let oe=0;oeP&&(Ke+=H[rt+yi])}if(Ke>ot&&Ke>=Q){let lt,rt=ve*ot,Ut=Ve*ot,zt=-1;const tt=((oe/me|0)<<5)+(P+1)+this.points.length;for(const ft of Ne){const Ct=ft*me;if(H[Ct+2]<=P)continue;H[Ct+2]=P;const Ht=H[Ct+yi];rt+=H[Ct]*Ht,Ut+=H[Ct+1]*Ht,H[Ct+4]=tt,K&&(lt||(lt=this._map(H,oe,!0),zt=this.clusterProps.length,this.clusterProps.push(lt)),K(lt,this._map(H,Ct)))}H[oe+4]=tt,ue.push(rt/Ke,Ut/Ke,1/0,tt,-1,Ke),K&&ue.push(zt)}else{for(let lt=0;lt1)for(const lt of Ne){const rt=lt*me;if(!(H[rt+2]<=P)){H[rt+2]=P;for(let Ut=0;Ut>5}_getOriginZoom(A){return(A-this.points.length)%32}_map(A,P,R){if(A[P+yi]>1){const Q=this.clusterProps[A[P+Ni]];return R?Object.assign({},Q):Q}const V=this.points[A[P+ni]].properties,K=this.options.map(V);return R&&K===V?Object.assign({},K):K}}function si(U,A,P){return{type:"Feature",id:U[A+ni],properties:Sr(U,A,P),geometry:{type:"Point",coordinates:[(R=U[A],360*(R-.5)),Ir(U[A+1])]}};var R}function Sr(U,A,P){const R=U[A+yi],V=R>=1e4?`${Math.round(R/1e3)}k`:R>=1e3?Math.round(R/100)/10+"k":R,K=U[A+Ni],Q=K===-1?{}:Object.assign({},P[K]);return Object.assign(Q,{cluster:!0,cluster_id:U[A+ni],point_count:R,point_count_abbreviated:V})}function Yt(U){return U/360+.5}function Ai(U){const A=Math.sin(U*Math.PI/180),P=.5-.25*Math.log((1+A)/(1-A))/Math.PI;return P<0?0:P>1?1:P}function Ir(U){const A=(180-360*U)*Math.PI/180;return 360*Math.atan(Math.exp(A))/Math.PI-90}function Vr(U,A,P,R){let V=R;const K=A+(P-A>>1);let Q,ie=P-A;const H=U[A],ue=U[A+1],me=U[P],oe=U[P+1];for(let ve=A+3;veV)Q=ve,V=Ve;else if(Ve===V){const Ne=Math.abs(ve-K);NeR&&(Q-A>3&&Vr(U,A,Q,R),U[Q+2]=V,P-Q>3&&Vr(U,Q,P,R))}function Xr(U,A,P,R,V,K){let Q=V-P,ie=K-R;if(Q!==0||ie!==0){const H=((U-P)*Q+(A-R)*ie)/(Q*Q+ie*ie);H>1?(P=V,R=K):H>0&&(P+=Q*H,R+=ie*H)}return Q=U-P,ie=A-R,Q*Q+ie*ie}function Ki(U,A,P,R){const V={id:U??null,type:A,geometry:P,tags:R,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(A==="Point"||A==="MultiPoint"||A==="LineString")lr(V,P);else if(A==="Polygon")lr(V,P[0]);else if(A==="MultiLineString")for(const K of P)lr(V,K);else if(A==="MultiPolygon")for(const K of P)lr(V,K[0]);return V}function lr(U,A){for(let P=0;P0&&(Q+=R?(V*me-ue*K)/2:Math.sqrt(Math.pow(ue-V,2)+Math.pow(me-K,2))),V=ue,K=me}const ie=A.length-3;A[2]=1,Vr(A,0,ie,P),A[ie+2]=1,A.size=Math.abs(Q),A.start=0,A.end=A.size}function dn(U,A,P,R){for(let V=0;V1?1:P}function Et(U,A,P,R,V,K,Q,ie){if(R/=A,K>=(P/=A)&&Q=R)return null;const H=[];for(const ue of U){const me=ue.geometry;let oe=ue.type;const ve=V===0?ue.minX:ue.minY,Ve=V===0?ue.maxX:ue.maxY;if(ve>=P&&Ve=R)continue;let Ne=[];if(oe==="Point"||oe==="MultiPoint")fs(me,Ne,P,R,V);else if(oe==="LineString")Kr(me,Ne,P,R,V,!1,ie.lineMetrics);else if(oe==="MultiLineString")En(me,Ne,P,R,V,!1);else if(oe==="Polygon")En(me,Ne,P,R,V,!0);else if(oe==="MultiPolygon")for(const ot of me){const Ke=[];En(ot,Ke,P,R,V,!0),Ke.length&&Ne.push(Ke)}if(Ne.length){if(ie.lineMetrics&&oe==="LineString"){for(const ot of Ne)H.push(Ki(ue.id,oe,ot,ue.tags));continue}oe!=="LineString"&&oe!=="MultiLineString"||(Ne.length===1?(oe="LineString",Ne=Ne[0]):oe="MultiLineString"),oe!=="Point"&&oe!=="MultiPoint"||(oe=Ne.length===3?"Point":"MultiPoint"),H.push(Ki(ue.id,oe,Ne,ue.tags))}}return H.length?H:null}function fs(U,A,P,R,V){for(let K=0;K=P&&Q<=R&&Ji(A,U[K],U[K+1],U[K+2])}}function Kr(U,A,P,R,V,K,Q){let ie=Nr(U);const H=V===0?ms:gs;let ue,me,oe=U.start;for(let Ke=0;KeP&&(me=H(ie,lt,rt,zt,tt,P),Q&&(ie.start=oe+ue*me)):ft>R?Ct=P&&(me=H(ie,lt,rt,zt,tt,P),Ht=!0),Ct>R&&ft<=R&&(me=H(ie,lt,rt,zt,tt,R),Ht=!0),!K&&Ht&&(Q&&(ie.end=oe+ue*me),A.push(ie),ie=Nr(U)),Q&&(oe+=ue)}let ve=U.length-3;const Ve=U[ve],Ne=U[ve+1],ot=V===0?Ve:Ne;ot>=P&&ot<=R&&Ji(ie,Ve,Ne,U[ve+2]),ve=ie.length-3,K&&ve>=3&&(ie[ve]!==ie[0]||ie[ve+1]!==ie[1])&&Ji(ie,ie[0],ie[1],ie[2]),ie.length&&A.push(ie)}function Nr(U){const A=[];return A.size=U.size,A.start=U.start,A.end=U.end,A}function En(U,A,P,R,V,K){for(const Q of U)Kr(Q,A,P,R,V,K,!1)}function Ji(U,A,P,R){U.push(A,P,R)}function ms(U,A,P,R,V,K){const Q=(K-A)/(R-A);return Ji(U,K,P+(V-P)*Q,1),Q}function gs(U,A,P,R,V,K){const Q=(K-P)/(V-P);return Ji(U,A+(R-A)*Q,K,1),Q}function xe(U,A){const P=[];for(let R=0;R0&&A.size<(V?Q:R))return void(P.numPoints+=A.length/3);const ie=[];for(let H=0;HQ)&&(P.numSimplified++,ie.push(A[H],A[H+1])),P.numPoints++;V&&function(H,ue){let me=0;for(let oe=0,ve=H.length,Ve=ve-2;oe0===ue)for(let oe=0,ve=H.length;oe24)throw new Error("maxZoom should be in the 0-24 range");if(P.promoteId&&P.generateId)throw new Error("promoteId and generateId cannot be used together.");let V=function(K,Q){const ie=[];if(K.type==="FeatureCollection")for(let H=0;H1&&console.time("creation"),Ve=this.tiles[ve]=Jr(A,P,R,V,ue),this.tileCoords.push({z:P,x:R,y:V}),me)){me>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",P,R,V,Ve.numFeatures,Ve.numPoints,Ve.numSimplified),console.timeEnd("creation"));const Ht=`z${P}`;this.stats[Ht]=(this.stats[Ht]||0)+1,this.total++}if(Ve.source=A,K==null){if(P===ue.indexMaxZoom||Ve.numPoints<=ue.indexMaxPoints)continue}else{if(P===ue.maxZoom||P===K)continue;if(K!=null){const Ht=K-P;if(R!==Q>>Ht||V!==ie>>Ht)continue}}if(Ve.source=null,A.length===0)continue;me>1&&console.time("clipping");const Ne=.5*ue.buffer/ue.extent,ot=.5-Ne,Ke=.5+Ne,lt=1+Ne;let rt=null,Ut=null,zt=null,tt=null,ft=Et(A,oe,R-Ne,R+Ke,0,Ve.minX,Ve.maxX,ue),Ct=Et(A,oe,R+ot,R+lt,0,Ve.minX,Ve.maxX,ue);A=null,ft&&(rt=Et(ft,oe,V-Ne,V+Ke,1,Ve.minY,Ve.maxY,ue),Ut=Et(ft,oe,V+ot,V+lt,1,Ve.minY,Ve.maxY,ue),ft=null),Ct&&(zt=Et(Ct,oe,V-Ne,V+Ke,1,Ve.minY,Ve.maxY,ue),tt=Et(Ct,oe,V+ot,V+lt,1,Ve.minY,Ve.maxY,ue),Ct=null),me>1&&console.timeEnd("clipping"),H.push(rt||[],P+1,2*R,2*V),H.push(Ut||[],P+1,2*R,2*V+1),H.push(zt||[],P+1,2*R+1,2*V),H.push(tt||[],P+1,2*R+1,2*V+1)}}getTile(A,P,R){A=+A,P=+P,R=+R;const V=this.options,{extent:K,debug:Q}=V;if(A<0||A>24)return null;const ie=1<1&&console.log("drilling down to z%d-%d-%d",A,P,R);let ue,me=A,oe=P,ve=R;for(;!ue&&me>0;)me--,oe>>=1,ve>>=1,ue=this.tiles[cr(me,oe,ve)];return ue&&ue.source?(Q>1&&(console.log("found parent tile z%d-%d-%d",me,oe,ve),console.time("drilling down")),this.splitTile(ue.source,me,oe,ve,A,P,R),Q>1&&console.timeEnd("drilling down"),this.tiles[H]?xi(this.tiles[H],K):null):null}}function cr(U,A,P){return 32*((1<{oe.properties=Ve;const Ne={};for(const ot of ve)Ne[ot]=H[ot].evaluate(me,oe);return Ne},Q.reduce=(Ve,Ne)=>{oe.properties=Ne;for(const ot of ve)me.accumulated=Ve[ot],Ve[ot]=ue[ot].evaluate(me,oe)},Q}(A)).load((yield this._pendingData).features):(V=yield this._pendingData,new Ci(V,A.geojsonVtOptions)),this.loaded={};const K={};if(R){const Q=R.finish();Q&&(K.resourceTiming={},K.resourceTiming[A.source]=JSON.parse(JSON.stringify(Q)))}return K}catch(K){if(delete this._pendingRequest,M.bB(K))return{abandoned:!0};throw K}var V})}getData(){return M._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(A){const P=this.loaded;return P&&P[A.uid]?super.reloadTile(A):this.loadTile(A)}loadAndProcessGeoJSON(A,P){return M._(this,void 0,void 0,function*(){let R=yield this.loadGeoJSON(A,P);if(delete this._pendingRequest,typeof R!="object")throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`);if(kt(R,!0),A.filter){const V=M.bC(A.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(V.result==="error")throw new Error(V.value.map(Q=>`${Q.key}: ${Q.message}`).join(", "));R={type:"FeatureCollection",features:R.features.filter(Q=>V.value.evaluate({zoom:0},Q))}}return R})}loadGeoJSON(A,P){return M._(this,void 0,void 0,function*(){const{promoteId:R}=A;if(A.request){const V=yield M.h(A.request,P);return this._dataUpdateable=Cr(V.data,R)?Ur(V.data,R):void 0,V.data}if(typeof A.data=="string")try{const V=JSON.parse(A.data);return this._dataUpdateable=Cr(V,R)?Ur(V,R):void 0,V}catch{throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`)}if(!A.dataDiff)throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${A.source}`);return function(V,K,Q){var ie,H,ue,me;if(K.removeAll&&V.clear(),K.remove)for(const oe of K.remove)V.delete(oe);if(K.add)for(const oe of K.add){const ve=We(oe,Q);ve!=null&&V.set(ve,oe)}if(K.update)for(const oe of K.update){let ve=V.get(oe.id);if(ve==null)continue;const Ve=!oe.removeAllProperties&&(((ie=oe.removeProperties)===null||ie===void 0?void 0:ie.length)>0||((H=oe.addOrUpdateProperties)===null||H===void 0?void 0:H.length)>0);if((oe.newGeometry||oe.removeAllProperties||Ve)&&(ve=Object.assign({},ve),V.set(oe.id,ve),Ve&&(ve.properties=Object.assign({},ve.properties))),oe.newGeometry&&(ve.geometry=oe.newGeometry),oe.removeAllProperties)ve.properties={};else if(((ue=oe.removeProperties)===null||ue===void 0?void 0:ue.length)>0)for(const Ne of oe.removeProperties)Object.prototype.hasOwnProperty.call(ve.properties,Ne)&&delete ve.properties[Ne];if(((me=oe.addOrUpdateProperties)===null||me===void 0?void 0:me.length)>0)for(const{key:Ne,value:ot}of oe.addOrUpdateProperties)ve.properties[Ne]=ot}}(this._dataUpdateable,A.dataDiff,R),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(A){return M._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(A){return this._geoJSONIndex.getClusterExpansionZoom(A.clusterId)}getClusterChildren(A){return this._geoJSONIndex.getChildren(A.clusterId)}getClusterLeaves(A){return this._geoJSONIndex.getLeaves(A.clusterId,A.limit,A.offset)}}class Mr{constructor(A){this.self=A,this.actor=new M.F(A),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(P,R)=>{if(this.externalWorkerSourceTypes[P])throw new Error(`Worker source with name "${P}" already registered.`);this.externalWorkerSourceTypes[P]=R},this.self.addProtocol=M.bi,this.self.removeProtocol=M.bj,this.self.registerRTLTextPlugin=P=>{if(M.bD.isParsed())throw new Error("RTL text plugin already registered.");M.bD.setMethods(P)},this.actor.registerMessageHandler("LDT",(P,R)=>this._getDEMWorkerSource(P,R.source).loadTile(R)),this.actor.registerMessageHandler("RDT",(P,R)=>M._(this,void 0,void 0,function*(){this._getDEMWorkerSource(P,R.source).removeTile(R)})),this.actor.registerMessageHandler("GCEZ",(P,R)=>M._(this,void 0,void 0,function*(){return this._getWorkerSource(P,R.type,R.source).getClusterExpansionZoom(R)})),this.actor.registerMessageHandler("GCC",(P,R)=>M._(this,void 0,void 0,function*(){return this._getWorkerSource(P,R.type,R.source).getClusterChildren(R)})),this.actor.registerMessageHandler("GCL",(P,R)=>M._(this,void 0,void 0,function*(){return this._getWorkerSource(P,R.type,R.source).getClusterLeaves(R)})),this.actor.registerMessageHandler("LD",(P,R)=>this._getWorkerSource(P,R.type,R.source).loadData(R)),this.actor.registerMessageHandler("GD",(P,R)=>this._getWorkerSource(P,R.type,R.source).getData()),this.actor.registerMessageHandler("LT",(P,R)=>this._getWorkerSource(P,R.type,R.source).loadTile(R)),this.actor.registerMessageHandler("RT",(P,R)=>this._getWorkerSource(P,R.type,R.source).reloadTile(R)),this.actor.registerMessageHandler("AT",(P,R)=>this._getWorkerSource(P,R.type,R.source).abortTile(R)),this.actor.registerMessageHandler("RMT",(P,R)=>this._getWorkerSource(P,R.type,R.source).removeTile(R)),this.actor.registerMessageHandler("RS",(P,R)=>M._(this,void 0,void 0,function*(){if(!this.workerSources[P]||!this.workerSources[P][R.type]||!this.workerSources[P][R.type][R.source])return;const V=this.workerSources[P][R.type][R.source];delete this.workerSources[P][R.type][R.source],V.removeSource!==void 0&&V.removeSource(R)})),this.actor.registerMessageHandler("RM",P=>M._(this,void 0,void 0,function*(){delete this.layerIndexes[P],delete this.availableImages[P],delete this.workerSources[P],delete this.demWorkerSources[P]})),this.actor.registerMessageHandler("SR",(P,R)=>M._(this,void 0,void 0,function*(){this.referrer=R})),this.actor.registerMessageHandler("SRPS",(P,R)=>this._syncRTLPluginState(P,R)),this.actor.registerMessageHandler("IS",(P,R)=>M._(this,void 0,void 0,function*(){this.self.importScripts(R)})),this.actor.registerMessageHandler("SI",(P,R)=>this._setImages(P,R)),this.actor.registerMessageHandler("UL",(P,R)=>M._(this,void 0,void 0,function*(){this._getLayerIndex(P).update(R.layers,R.removedIds)})),this.actor.registerMessageHandler("SL",(P,R)=>M._(this,void 0,void 0,function*(){this._getLayerIndex(P).replace(R)}))}_setImages(A,P){return M._(this,void 0,void 0,function*(){this.availableImages[A]=P;for(const R in this.workerSources[A]){const V=this.workerSources[A][R];for(const K in V)V[K].availableImages=P}})}_syncRTLPluginState(A,P){return M._(this,void 0,void 0,function*(){if(M.bD.isParsed())return M.bD.getState();if(P.pluginStatus!=="loading")return M.bD.setState(P),P;const R=P.pluginURL;if(this.self.importScripts(R),M.bD.isParsed()){const V={pluginStatus:"loaded",pluginURL:R};return M.bD.setState(V),V}throw M.bD.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${R}`)})}_getAvailableImages(A){let P=this.availableImages[A];return P||(P=[]),P}_getLayerIndex(A){let P=this.layerIndexes[A];return P||(P=this.layerIndexes[A]=new p),P}_getWorkerSource(A,P,R){if(this.workerSources[A]||(this.workerSources[A]={}),this.workerSources[A][P]||(this.workerSources[A][P]={}),!this.workerSources[A][P][R]){const V={sendAsync:(K,Q)=>(K.targetMapId=A,this.actor.sendAsync(K,Q))};switch(P){case"vector":this.workerSources[A][P][R]=new de(V,this._getLayerIndex(A),this._getAvailableImages(A));break;case"geojson":this.workerSources[A][P][R]=new Yr(V,this._getLayerIndex(A),this._getAvailableImages(A));break;default:this.workerSources[A][P][R]=new this.externalWorkerSourceTypes[P](V,this._getLayerIndex(A),this._getAvailableImages(A))}}return this.workerSources[A][P][R]}_getDEMWorkerSource(A,P){return this.demWorkerSources[A]||(this.demWorkerSources[A]={}),this.demWorkerSources[A][P]||(this.demWorkerSources[A][P]=new se),this.demWorkerSources[A][P]}}return M.i(self)&&(self.worker=new Mr(self)),Mr}),he("index",["exports","./shared"],function(M,p){var Je="4.7.1";let Ge,He;const de={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:h=>new Promise((e,n)=>{const a=requestAnimationFrame(e);h.signal.addEventListener("abort",()=>{cancelAnimationFrame(a),n(p.c())})}),getImageData(h,e=0){return this.getImageCanvasContext(h).getImageData(-e,-e,h.width+2*e,h.height+2*e)},getImageCanvasContext(h){const e=window.document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return e.width=h.width,e.height=h.height,n.drawImage(h,0,0,h.width,h.height),n},resolveURL:h=>(Ge||(Ge=document.createElement("a")),Ge.href=h,Ge.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(He==null&&(He=matchMedia("(prefers-reduced-motion: reduce)")),He.matches)}};class se{static testProp(e){if(!se.docStyle)return e[0];for(let n=0;n{window.removeEventListener("click",se.suppressClickInternal,!0)},0)}static getScale(e){const n=e.getBoundingClientRect();return{x:n.width/e.offsetWidth||1,y:n.height/e.offsetHeight||1,boundingClientRect:n}}static getPoint(e,n,a){const o=n.boundingClientRect;return new p.P((a.clientX-o.left)/n.x-e.clientLeft,(a.clientY-o.top)/n.y-e.clientTop)}static mousePos(e,n){const a=se.getScale(e);return se.getPoint(e,a,n)}static touchPos(e,n){const a=[],o=se.getScale(e);for(let c=0;c{qt&&Fr(qt),qt=null,Oi=!0},kt.onerror=()=>{Ii=!0,qt=null},kt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(h){let e,n,a,o;h.resetRequestQueue=()=>{e=[],n=0,a=0,o={}},h.addThrottleControl=y=>{const b=a++;return o[b]=y,b},h.removeThrottleControl=y=>{delete o[y],m()},h.getImage=(y,b,T=!0)=>new Promise((S,k)=>{Ot.supported&&(y.headers||(y.headers={}),y.headers.accept="image/webp,*/*"),p.e(y,{type:"image"}),e.push({abortController:b,requestParameters:y,supportImageRefresh:T,state:"queued",onError:D=>{k(D)},onSuccess:D=>{S(D)}}),m()});const c=y=>p._(this,void 0,void 0,function*(){y.state="running";const{requestParameters:b,supportImageRefresh:T,onError:S,onSuccess:k,abortController:D}=y,B=T===!1&&!p.i(self)&&!p.g(b.url)&&(!b.headers||Object.keys(b.headers).reduce((Z,X)=>Z&&X==="accept",!0));n++;const N=B?_(b,D):p.m(b,D);try{const Z=yield N;delete y.abortController,y.state="completed",Z.data instanceof HTMLImageElement||p.b(Z.data)?k(Z):Z.data&&k({data:yield(q=Z.data,typeof createImageBitmap=="function"?p.d(q):p.f(q)),cacheControl:Z.cacheControl,expires:Z.expires})}catch(Z){delete y.abortController,S(Z)}finally{n--,m()}var q}),m=()=>{const y=(()=>{for(const b of Object.keys(o))if(o[b]())return!0;return!1})()?p.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:p.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let b=n;b0;b++){const T=e.shift();T.abortController.signal.aborted?b--:c(T)}},_=(y,b)=>new Promise((T,S)=>{const k=new Image,D=y.url,B=y.credentials;B&&B==="include"?k.crossOrigin="use-credentials":(B&&B==="same-origin"||!p.s(D))&&(k.crossOrigin="anonymous"),b.signal.addEventListener("abort",()=>{k.src="",S(p.c())}),k.fetchPriority="high",k.onload=()=>{k.onerror=k.onload=null,T({data:k})},k.onerror=()=>{k.onerror=k.onload=null,b.signal.aborted||S(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."))},k.src=D})}(Mt||(Mt={})),Mt.resetRequestQueue();class ln{constructor(e){this._transformRequestFn=e}transformRequest(e,n){return this._transformRequestFn&&this._transformRequestFn(e,n)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function mi(h){var e=new p.A(3);return e[0]=h[0],e[1]=h[1],e[2]=h[2],e}var Pi,gi=function(h,e,n){return h[0]=e[0]-n[0],h[1]=e[1]-n[1],h[2]=e[2]-n[2],h};Pi=new p.A(3),p.A!=Float32Array&&(Pi[0]=0,Pi[1]=0,Pi[2]=0);var cn=function(h){var e=h[0],n=h[1];return e*e+n*n};function ii(h){const e=[];if(typeof h=="string")e.push({id:"default",url:h});else if(h&&h.length>0){const n=[];for(const{id:a,url:o}of h){const c=`${a}${o}`;n.indexOf(c)===-1&&(n.push(c),e.push({id:a,url:o}))}}return e}function Or(h,e,n){const a=h.split("?");return a[0]+=`${e}${n}`,a.join("?")}(function(){var h=new p.A(2);p.A!=Float32Array&&(h[0]=0,h[1]=0)})();class et{constructor(e,n,a,o){this.context=e,this.format=a,this.texture=e.gl.createTexture(),this.update(n,o)}update(e,n,a){const{width:o,height:c}=e,m=!(this.size&&this.size[0]===o&&this.size[1]===c||a),{context:_}=this,{gl:y}=_;if(this.useMipmap=!!(n&&n.useMipmap),y.bindTexture(y.TEXTURE_2D,this.texture),_.pixelStoreUnpackFlipY.set(!1),_.pixelStoreUnpack.set(1),_.pixelStoreUnpackPremultiplyAlpha.set(this.format===y.RGBA&&(!n||n.premultiply!==!1)),m)this.size=[o,c],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||p.b(e)?y.texImage2D(y.TEXTURE_2D,0,this.format,this.format,y.UNSIGNED_BYTE,e):y.texImage2D(y.TEXTURE_2D,0,this.format,o,c,0,this.format,y.UNSIGNED_BYTE,e.data);else{const{x:b,y:T}=a||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||p.b(e)?y.texSubImage2D(y.TEXTURE_2D,0,b,T,y.RGBA,y.UNSIGNED_BYTE,e):y.texSubImage2D(y.TEXTURE_2D,0,b,T,o,c,y.RGBA,y.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&y.generateMipmap(y.TEXTURE_2D)}bind(e,n,a){const{context:o}=this,{gl:c}=o;c.bindTexture(c.TEXTURE_2D,this.texture),a!==c.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(a=c.LINEAR),e!==this.filter&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,e),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a||e),this.filter=e),n!==this.wrap&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,n),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,n),this.wrap=n)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}function hn(h){const{userImage:e}=h;return!!(e&&e.render&&e.render())&&(h.data.replace(new Uint8Array(e.data.buffer)),!0)}class Gt extends p.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new p.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:n,promiseResolve:a}of this.requestors)a(this._getImagesForIds(n));this.requestors=[]}}getImage(e){const n=this.images[e];if(n&&!n.data&&n.spriteData){const a=n.spriteData;n.data=new p.R({width:a.width,height:a.height},a.context.getImageData(a.x,a.y,a.width,a.height).data),n.spriteData=null}return n}addImage(e,n){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,n)&&(this.images[e]=n)}_validate(e,n){let a=!0;const o=n.data||n.spriteData;return this._validateStretch(n.stretchX,o&&o.width)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "stretchX" value`))),a=!1),this._validateStretch(n.stretchY,o&&o.height)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "stretchY" value`))),a=!1),this._validateContent(n.content,n)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "content" value`))),a=!1),a}_validateStretch(e,n){if(!e)return!0;let a=0;for(const o of e){if(o[0]{let o=!0;if(!this.isLoaded())for(const c of e)this.images[c]||(o=!1);this.isLoaded()||o?n(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:n})})}_getImagesForIds(e){const n={};for(const a of e){let o=this.getImage(a);o||(this.fire(new p.k("styleimagemissing",{id:a})),o=this.getImage(a)),o?n[a]={data:o.data.clone(),pixelRatio:o.pixelRatio,sdf:o.sdf,version:o.version,stretchX:o.stretchX,stretchY:o.stretchY,content:o.content,textFitWidth:o.textFitWidth,textFitHeight:o.textFitHeight,hasRenderCallback:!!(o.userImage&&o.userImage.render)}:p.w(`Image "${a}" 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 n}getPixelSize(){const{width:e,height:n}=this.atlasImage;return{width:e,height:n}}getPattern(e){const n=this.patterns[e],a=this.getImage(e);if(!a)return null;if(n&&n.position.version===a.version)return n.position;if(n)n.position.version=a.version;else{const o={w:a.data.width+2,h:a.data.height+2,x:0,y:0},c=new p.I(o,a);this.patterns[e]={bin:o,position:c}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const n=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new et(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const c in this.patterns)e.push(this.patterns[c].bin);const{w:n,h:a}=p.p(e),o=this.atlasImage;o.resize({width:n||1,height:a||1});for(const c in this.patterns){const{bin:m}=this.patterns[c],_=m.x+1,y=m.y+1,b=this.getImage(c).data,T=b.width,S=b.height;p.R.copy(b,o,{x:0,y:0},{x:_,y},{width:T,height:S}),p.R.copy(b,o,{x:0,y:S-1},{x:_,y:y-1},{width:T,height:1}),p.R.copy(b,o,{x:0,y:0},{x:_,y:y+S},{width:T,height:1}),p.R.copy(b,o,{x:T-1,y:0},{x:_-1,y},{width:1,height:S}),p.R.copy(b,o,{x:0,y:0},{x:_+T,y},{width:1,height:S})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const a=this.getImage(n);a||p.w(`Image with ID: "${n}" was not found`),hn(a)&&this.updateImage(n,a)}}}const Jt=1e20;function Wi(h,e,n,a,o,c,m,_,y){for(let b=e;b-1);y++,c[y]=_,m[y]=b,m[y+1]=Jt}for(let _=0,y=0;_65535)throw new Error("glyphs > 65535 not supported");if(a.ranges[c])return{stack:e,id:n,glyph:o};if(!this.url)throw new Error("glyphsUrl is not set");if(!a.requests[c]){const _=_i.loadGlyphRange(e,c,this.url,this.requestManager);a.requests[c]=_}const m=yield a.requests[c];for(const _ in m)this._doesCharSupportLocalGlyph(+_)||(a.glyphs[+_]=m[+_]);return a.ranges[c]=!0,{stack:e,id:n,glyph:m[n]||null}})}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&new RegExp("\\p{Ideo}|\\p{sc=Hang}|\\p{sc=Hira}|\\p{sc=Kana}","u").test(String.fromCodePoint(e))}_tinySDF(e,n,a){const o=this.localIdeographFontFamily;if(!o||!this._doesCharSupportLocalGlyph(a))return;let c=e.tinySDF;if(!c){let _="400";/bold/i.test(n)?_="900":/medium/i.test(n)?_="500":/light/i.test(n)&&(_="200"),c=e.tinySDF=new _i.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:_})}const m=c.draw(String.fromCharCode(a));return{id:a,bitmap:new p.o({width:m.width||60,height:m.height||60},m.data),metrics:{width:m.glyphWidth/2||24,height:m.glyphHeight/2||24,left:m.glyphLeft/2+.5||0,top:m.glyphTop/2-27.5||-8,advance:m.glyphAdvance/2||24,isDoubleResolution:!0}}}}_i.loadGlyphRange=function(h,e,n,a){return p._(this,void 0,void 0,function*(){const o=256*e,c=o+255,m=a.transformRequest(n.replace("{fontstack}",h).replace("{range}",`${o}-${c}`),"Glyphs"),_=yield p.l(m,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${e}, ${o}-${c}`);const y={};for(const b of p.n(_.data))y[b.id]=b;return y})},_i.TinySDF=class{constructor({fontSize:h=24,buffer:e=3,radius:n=8,cutoff:a=.25,fontFamily:o="sans-serif",fontWeight:c="normal",fontStyle:m="normal"}={}){this.buffer=e,this.cutoff=a,this.radius=n;const _=this.size=h+4*e,y=this._createCanvas(_),b=this.ctx=y.getContext("2d",{willReadFrequently:!0});b.font=`${m} ${c} ${h}px ${o}`,b.textBaseline="alphabetic",b.textAlign="left",b.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(h){const e=document.createElement("canvas");return e.width=e.height=h,e}draw(h){const{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:a,actualBoundingBoxLeft:o,actualBoundingBoxRight:c}=this.ctx.measureText(h),m=Math.ceil(n),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(c-o))),y=Math.min(this.size-this.buffer,m+Math.ceil(a)),b=_+2*this.buffer,T=y+2*this.buffer,S=Math.max(b*T,0),k=new Uint8ClampedArray(S),D={data:k,width:b,height:T,glyphWidth:_,glyphHeight:y,glyphTop:m,glyphLeft:0,glyphAdvance:e};if(_===0||y===0)return D;const{ctx:B,buffer:N,gridInner:q,gridOuter:Z}=this;B.clearRect(N,N,_,y),B.fillText(h,N,N+m);const X=B.getImageData(N,N,_,y);Z.fill(Jt,0,S),q.fill(0,0,S);for(let F=0;F0?fe*fe:0,q[ae]=fe<0?fe*fe:0}}Wi(Z,0,0,b,T,b,this.f,this.v,this.z),Wi(q,N,N,_,y,b,this.f,this.v,this.z);for(let F=0;F1&&(y=e[++_]);const T=Math.abs(b-y.left),S=Math.abs(b-y.right),k=Math.min(T,S);let D;const B=c/a*(o+1);if(y.isDash){const N=o-Math.abs(B);D=Math.sqrt(k*k+N*N)}else D=o-Math.sqrt(k*k+B*B);this.data[m+b]=Math.max(0,Math.min(255,D+128))}}}addRegularDash(e){for(let _=e.length-1;_>=0;--_){const y=e[_],b=e[_+1];y.zeroLength?e.splice(_,1):b&&b.isDash===y.isDash&&(b.left=y.left,e.splice(_,1))}const n=e[0],a=e[e.length-1];n.isDash===a.isDash&&(n.left=a.left-this.width,a.right=n.right+this.width);const o=this.width*this.nextRow;let c=0,m=e[c];for(let _=0;_1&&(m=e[++c]);const y=Math.abs(_-m.left),b=Math.abs(_-m.right),T=Math.min(y,b);this.data[o+_]=Math.max(0,Math.min(255,(m.isDash?T:-T)+128))}}addDash(e,n){const a=n?7:0,o=2*a+1;if(this.nextRow+o>this.height)return p.w("LineAtlas out of space"),null;let c=0;for(let _=0;_{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[or]}numActive(){return Object.keys(this.active).length}}const Sr=Math.floor(de.hardwareConcurrency/2);let Yt,Ai;function Ir(){return Yt||(Yt=new si),Yt}si.workerCount=p.C(globalThis)?Math.max(Math.min(Sr,3),1):1;class Vr{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;const a=this.workerPool.acquire(n);for(let o=0;o{n.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,n){for(const a of this.actors)a.registerMessageHandler(e,n)}}function Xr(){return Ai||(Ai=new Vr(Ir(),p.G),Ai.registerMessageHandler("GR",(h,e,n)=>p.m(e,n))),Ai}function Ki(h,e){const n=p.H();return p.J(n,n,[1,1,0]),p.K(n,n,[.5*h.width,.5*h.height,1]),p.L(n,n,h.calculatePosMatrix(e.toUnwrapped()))}function lr(h,e,n,a,o,c){const m=function(S,k,D){if(S)for(const B of S){const N=k[B];if(N&&N.source===D&&N.type==="fill-extrusion")return!0}else for(const B in k){const N=k[B];if(N.source===D&&N.type==="fill-extrusion")return!0}return!1}(o&&o.layers,e,h.id),_=c.maxPitchScaleFactor(),y=h.tilesIn(a,_,m);y.sort(Wr);const b=[];for(const S of y)b.push({wrappedTileID:S.tileID.wrapped().key,queryResults:S.tile.queryRenderedFeatures(e,n,h._state,S.queryGeometry,S.cameraQueryGeometry,S.scale,o,c,_,Ki(h.transform,S.tileID))});const T=function(S){const k={},D={};for(const B of S){const N=B.queryResults,q=B.wrappedTileID,Z=D[q]=D[q]||{};for(const X in N){const F=N[X],Y=Z[X]=Z[X]||{},ee=k[X]=k[X]||[];for(const ae of F)Y[ae.featureIndex]||(Y[ae.featureIndex]=!0,ee.push(ae))}}return k}(b);for(const S in T)T[S].forEach(k=>{const D=k.feature,B=h.getFeatureState(D.layer["source-layer"],D.id);D.source=D.layer.source,D.layer["source-layer"]&&(D.sourceLayer=D.layer["source-layer"]),D.state=B});return T}function Wr(h,e){const n=h.tileID,a=e.tileID;return n.overscaledZ-a.overscaledZ||n.canonical.y-a.canonical.y||n.wrap-a.wrap||n.canonical.x-a.canonical.x}function kn(h,e,n){return p._(this,void 0,void 0,function*(){let a=h;if(h.url?a=(yield p.h(e.transformRequest(h.url,"Source"),n)).data:yield de.frameAsync(n),!a)return null;const o=p.M(p.e(a,h),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(o.vectorLayerIds=a.vector_layers.map(c=>c.id)),o})}class le{constructor(e,n){e&&(n?this.setSouthWest(e).setNorthEast(n):Array.isArray(e)&&(e.length===4?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 p.N?new p.N(e.lng,e.lat):p.N.convert(e),this}setSouthWest(e){return this._sw=e instanceof p.N?new p.N(e.lng,e.lat):p.N.convert(e),this}extend(e){const n=this._sw,a=this._ne;let o,c;if(e instanceof p.N)o=e,c=e;else{if(!(e instanceof le))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(le.convert(e)):this.extend(p.N.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(p.N.convert(e)):this;if(o=e._sw,c=e._ne,!o||!c)return this}return n||a?(n.lng=Math.min(o.lng,n.lng),n.lat=Math.min(o.lat,n.lat),a.lng=Math.max(c.lng,a.lng),a.lat=Math.max(c.lat,a.lat)):(this._sw=new p.N(o.lng,o.lat),this._ne=new p.N(c.lng,c.lat)),this}getCenter(){return new p.N((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 p.N(this.getWest(),this.getNorth())}getSouthEast(){return new p.N(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:n,lat:a}=p.N.convert(e);let o=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&o}static convert(e){return e instanceof le?e:e&&new le(e)}static fromLngLat(e,n=0){const a=360*n/40075017,o=a/Math.cos(Math.PI/180*e.lat);return new le(new p.N(e.lng-o,e.lat-a),new p.N(e.lng+o,e.lat+a))}adjustAntiMeridian(){const e=new p.N(this._sw.lng,this._sw.lat),n=new p.N(this._ne.lng,this._ne.lat);return new le(e,e.lng>n.lng?new p.N(n.lng+360,n.lat):n)}}class dn{constructor(e,n,a){this.bounds=le.convert(this.validateBounds(e)),this.minzoom=n||0,this.maxzoom=a||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[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 n=Math.pow(2,e.z),a=Math.floor(p.O(this.bounds.getWest())*n),o=Math.floor(p.Q(this.bounds.getNorth())*n),c=Math.ceil(p.O(this.bounds.getEast())*n),m=Math.ceil(p.Q(this.bounds.getSouth())*n);return e.x>=a&&e.x=o&&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 p.e({},this._options)}loadTile(e){return p._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a={request:this.map._requestManager.transformRequest(n,"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};a.request.collectResourceTiming=this._collectResourceTiming;let o="RT";if(e.actor&&e.state!=="expired"){if(e.state==="loading")return new Promise((c,m)=>{e.reloadPromise={resolve:c,reject:m}})}else e.actor=this.dispatcher.getActor(),o="LT";e.abortController=new AbortController;try{const c=yield e.actor.sendAsync({type:o,data:a},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,c)}catch(c){if(delete e.abortController,e.aborted)return;if(c&&c.status!==404)throw c;this._afterTileLoadWorkerResponse(e,null)}})}_afterTileLoadWorkerResponse(e,n){if(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),e.reloadPromise){const a=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(a.resolve).catch(a.reject)}}abortTile(e){return p._(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 p._(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 ut extends p.E{constructor(e,n,a,o){super(),this.id=e,this.dispatcher=a,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=p.e({type:"raster"},n),p.e(this,p.M(n,["url","scheme","tileSize"]))}load(){return p._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new p.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const e=yield kn(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,e&&(p.e(this,e),e.bounds&&(this.tileBounds=new dn(e.bounds,this.minzoom,this.maxzoom)),this.fire(new p.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new p.k("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this.fire(new p.j(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()}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 p.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return p._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const a=yield Mt.getImage(this.map._requestManager.transformRequest(n,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(a&&a.data){this.map._refreshExpiredTiles&&a.cacheControl&&a.expires&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});const o=this.map.painter.context,c=o.gl,m=a.data;e.texture=this.map.painter.getTileTexture(m.width),e.texture?e.texture.update(m,{useMipmap:!0}):(e.texture=new et(o,m,c.RGBA,{useMipmap:!0}),e.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE,c.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(a){if(delete e.abortController,e.aborted)e.state="unloaded";else if(a)throw e.state="errored",a}})}abortTile(e){return p._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return p._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class Et extends ut{constructor(e,n,a,o){super(e,n,a,o),this.type="raster-dem",this.maxzoom=22,this._options=p.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(e){return p._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a=this.map._requestManager.transformRequest(n,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const o=yield Mt.getImage(a,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(o&&o.data){const c=o.data;this.map._refreshExpiredTiles&&o.cacheControl&&o.expires&&e.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});const m=p.b(c)&&p.U()?c:yield this.readImageNow(c),_={type:this.type,uid:e.uid,source:this.id,rawImageData:m,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||e.state==="expired"){e.actor=this.dispatcher.getActor();const y=yield e.actor.sendAsync({type:"LDT",data:_});e.dem=y,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(o){if(delete e.abortController,e.aborted)e.state="unloaded";else if(o)throw e.state="errored",o}})}readImageNow(e){return p._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&p.V()){const n=e.width+2,a=e.height+2;try{return new p.R({width:n,height:a},yield p.W(e,-1,-1,n,a))}catch{}}return de.getImageData(e,1)})}_getNeighboringTiles(e){const n=e.canonical,a=Math.pow(2,n.z),o=(n.x-1+a)%a,c=n.x===0?e.wrap-1:e.wrap,m=(n.x+1+a)%a,_=n.x+1===a?e.wrap+1:e.wrap,y={};return y[new p.S(e.overscaledZ,c,n.z,o,n.y).key]={backfilled:!1},y[new p.S(e.overscaledZ,_,n.z,m,n.y).key]={backfilled:!1},n.y>0&&(y[new p.S(e.overscaledZ,c,n.z,o,n.y-1).key]={backfilled:!1},y[new p.S(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},y[new p.S(e.overscaledZ,_,n.z,m,n.y-1).key]={backfilled:!1}),n.y+10&&p.e(c,{resourceTiming:o}),this.fire(new p.k("data",Object.assign(Object.assign({},c),{sourceDataType:"metadata"}))),this.fire(new p.k("data",Object.assign(Object.assign({},c),{sourceDataType:"content"})))}catch(a){if(this._pendingLoads--,this._removed)return void this.fire(new p.k("dataabort",{dataType:"source"}));this.fire(new p.j(a))}})}loaded(){return this._pendingLoads===0}loadTile(e){return p._(this,void 0,void 0,function*(){const n=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};e.abortController=new AbortController;const o=yield this.actor.sendAsync({type:n,data:a},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(o,this.map.painter,n==="RT")})}abortTile(e){return p._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return p._(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 p.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var Kr=p.Y([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Nr extends p.E{constructor(e,n,a,o){super(),this.id=e,this.dispatcher=a,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=n}load(e){return p._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new p.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield Mt.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,e&&(this.coordinates=e),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,this.fire(new p.j(n))}})}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 p.k("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 n=e.map(p.Z.fromLngLat);this.tileID=function(o){let c=1/0,m=1/0,_=-1/0,y=-1/0;for(const k of o)c=Math.min(c,k.x),m=Math.min(m,k.y),_=Math.max(_,k.x),y=Math.max(y,k.y);const b=Math.max(_-c,y-m),T=Math.max(0,Math.floor(-Math.log(b)/Math.LN2)),S=Math.pow(2,T);return new p.a1(T,Math.floor((c+_)/2*S),Math.floor((m+y)/2*S))}(n),this.minzoom=this.maxzoom=this.tileID.z;const a=n.map(o=>this.tileID.getTilePoint(o)._round());return this._boundsArray=new p.$,this._boundsArray.emplaceBack(a[0].x,a[0].y,0,0),this._boundsArray.emplaceBack(a[1].x,a[1].y,p.X,0),this._boundsArray.emplaceBack(a[3].x,a[3].y,0,p.X),this._boundsArray.emplaceBack(a[2].x,a[2].y,p.X,p.X),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new p.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const e=this.map.painter.context,n=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,Kr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture||(this.texture=new et(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(const o in this.tiles){const c=this.tiles[o];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,a=!0)}a&&this.fire(new p.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return p._(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}}class En extends Nr{constructor(e,n,a,o){super(e,n,a,o),this.roundZoom=!0,this.type="video",this.options=n}load(){return p._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const n of e.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield p.a3(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new p.j(n))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const n=this.video.seekable;en.end(0)?this.fire(new p.j(new p.a2(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.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(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const e=this.map.painter.context,n=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,Kr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new et(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(const o in this.tiles){const c=this.tiles[o];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,a=!0)}a&&this.fire(new p.k("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 Ji extends Nr{constructor(e,n,a,o){super(e,n,a,o),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(c=>!Array.isArray(c)||c.length!==2||c.some(m=>typeof m!="number"))||this.fire(new p.j(new p.a2(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new p.j(new p.a2(`sources.${e}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new p.j(new p.a2(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new p.j(new p.a2(`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 p.j(new p.a2(`sources.${e}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return p._(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 p.j(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()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,a=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,Kr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new et(n,this.canvas,a.RGBA,{premultiply:!0});let o=!1;for(const c in this.tiles){const m=this.tiles[c];m.state!=="loaded"&&(m.state="loaded",m.texture=this.texture,o=!0)}o&&this.fire(new p.k("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 ms={},gs=h=>{switch(h){case"geojson":return fs;case"image":return Nr;case"raster":return ut;case"raster-dem":return Et;case"vector":return ps;case"video":return En;case"canvas":return Ji}return ms[h]},xe="RTLPluginLoaded";class Pr extends p.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Xr()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(n=>{throw this.status="error",n})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return p._(this,arguments,void 0,function*(n,a=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=de.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!a)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return p._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new p.k(xe))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let xi=null;function Ar(){return xi||(xi=new Pr),xi}class Jr{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=p.a4(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){const n=e+this.timeAdded;nc.getLayer(b)).filter(Boolean);if(y.length!==0){_.layers=y,_.stateDependentLayerIds&&(_.stateDependentLayers=_.stateDependentLayerIds.map(b=>y.filter(T=>T.id===b)[0]));for(const b of y)m[b.id]=_}}return m}(e.buckets,n.style),this.hasSymbolBuckets=!1;for(const o in this.buckets){const c=this.buckets[o];if(c instanceof p.a6){if(this.hasSymbolBuckets=!0,!a)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const o in this.buckets){const c=this.buckets[o];if(c instanceof p.a6&&c.hasRTLText){this.hasRTLText=!0,Ar().lazyLoad();break}}this.queryPadding=0;for(const o in this.buckets){const c=this.buckets[o];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(o).queryRadius(c))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new p.a5}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const a in this.buckets){const o=this.buckets[a];o.uploadPending()&&o.upload(e)}const n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new et(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new et(e,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,n,a,o,c,m,_,y,b,T){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:o,cameraQueryGeometry:c,scale:m,tileSize:this.tileSize,pixelPosMatrix:T,transform:y,params:_,queryPadding:this.queryPadding*b},e,n,a):{}}querySourceFeatures(e,n){const a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;const o=a.loadVTLayers(),c=n&&n.sourceLayer?n.sourceLayer:"",m=o._geojsonTileLayer||o[c];if(!m)return;const _=p.a7(n&&n.filter),{z:y,x:b,y:T}=this.tileID.canonical,S={z:y,x:b,y:T};for(let k=0;ka)o=!1;else if(n)if(this.expirationTime{this.remove(e,c)},a)),this.data[o].push(c),this.order.push(o),this.order.length>this.max){const m=this._getAndRemoveByKey(this.order[0]);m&&this.onRemove(m)}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 n=this.data[e].shift();return n.timeout&&clearTimeout(n.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),n.value}getByKey(e){const n=this.data[e];return n?n[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,n){if(!this.has(e))return this;const a=e.wrapped().key,o=n===void 0?0:this.data[a].indexOf(n),c=this.data[a][o];return this.data[a].splice(o,1),c.timeout&&clearTimeout(c.timeout),this.data[a].length===0&&delete this.data[a],this.onRemove(c.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(e){const n=[];for(const a in this.data)for(const o of this.data[a])e(o.value)||n.push(o);for(const a of n)this.remove(a.value.tileID,a)}}class Qe{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,n,a){const o=String(n);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},p.e(this.stateChanges[e][o],a),this.deletedStates[e]===null){this.deletedStates[e]={};for(const c in this.state[e])c!==o&&(this.deletedStates[e][c]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][o]===null){this.deletedStates[e][o]={};for(const c in this.state[e][o])a[c]||(this.deletedStates[e][o][c]=null)}else for(const c in a)this.deletedStates[e]&&this.deletedStates[e][o]&&this.deletedStates[e][o][c]===null&&delete this.deletedStates[e][o][c]}removeFeatureState(e,n,a){if(this.deletedStates[e]===null)return;const o=String(n);if(this.deletedStates[e]=this.deletedStates[e]||{},a&&n!==void 0)this.deletedStates[e][o]!==null&&(this.deletedStates[e][o]=this.deletedStates[e][o]||{},this.deletedStates[e][o][a]=null);else if(n!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][o])for(a in this.deletedStates[e][o]={},this.stateChanges[e][o])this.deletedStates[e][o][a]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null}getState(e,n){const a=String(n),o=p.e({},(this.state[e]||{})[a],(this.stateChanges[e]||{})[a]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const c=this.deletedStates[e][n];if(c===null)return{};for(const m in c)delete o[m]}return o}initializeTileState(e,n){e.setFeatureState(this.state,n)}coalesceChanges(e,n){const a={};for(const o in this.stateChanges){this.state[o]=this.state[o]||{};const c={};for(const m in this.stateChanges[o])this.state[o][m]||(this.state[o][m]={}),p.e(this.state[o][m],this.stateChanges[o][m]),c[m]=this.state[o][m];a[o]=c}for(const o in this.deletedStates){this.state[o]=this.state[o]||{};const c={};if(this.deletedStates[o]===null)for(const m in this.state[o])c[m]={},this.state[o][m]={};else for(const m in this.deletedStates[o]){if(this.deletedStates[o][m]===null)this.state[o][m]={};else for(const _ of Object.keys(this.deletedStates[o][m]))delete this.state[o][m][_];c[m]=this.state[o][m]}a[o]=a[o]||{},p.e(a[o],c)}if(this.stateChanges={},this.deletedStates={},Object.keys(a).length!==0)for(const o in e)e[o].setFeatureState(a,n)}}class $e extends p.E{constructor(e,n,a){super(),this.id=e,this.dispatcher=a,this.on("data",o=>this._dataHandler(o)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((o,c,m,_)=>{const y=new(gs(c.type))(o,c,m,_);if(y.id!==o)throw new Error(`Expected Source id to be ${o} instead of ${y.id}`);return y})(e,n,a,this),this._tiles={},this._cache=new Te(0,o=>this._unloadTile(o)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Qe,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||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const n=this._tiles[e];if(n.state!=="loaded"&&n.state!=="errored")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,n,a){return p._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,n,a)}catch(o){e.state="errored",o.status!==404?this._source.fire(new p.j(o,{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 p.k("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 n in this._tiles){const a=this._tiles[n];a.upload(e),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Ci).map(e=>e.key)}getRenderableIds(e){const n=[];for(const a in this._tiles)this._isIdRenderable(a,e)&&n.push(this._tiles[a]);return e?n.sort((a,o)=>{const c=a.tileID,m=o.tileID,_=new p.P(c.canonical.x,c.canonical.y)._rotate(this.transform.angle),y=new p.P(m.canonical.x,m.canonical.y)._rotate(this.transform.angle);return c.overscaledZ-m.overscaledZ||y.y-_.y||y.x-_.x}).map(a=>a.tileID.key):n.map(a=>a.tileID).sort(Ci).map(a=>a.key)}hasRenderableParent(e){const n=this.findLoadedParent(e,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(e,n){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(n||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(e,"reloading")}}_reloadTile(e,n){return p._(this,void 0,void 0,function*(){const a=this._tiles[e];a&&(a.state!=="loading"&&(a.state=n),yield this._loadTile(a,e,n))})}_tileLoaded(e,n,a){e.timeAdded=de.now(),a==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),this.getSource().type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new p.k("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const n=this.getRenderableIds();for(let o=0;o1||(Math.abs(m)>1&&(Math.abs(m+y)===1?m+=y:Math.abs(m-y)===1&&(m-=y)),c.dem&&o.dem&&(o.dem.backfillBorder(c.dem,m,_),o.neighboringTiles&&o.neighboringTiles[b]&&(o.neighboringTiles[b].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,n,a,o){for(const c in this._tiles){let m=this._tiles[c];if(o[c]||!m.hasData()||m.tileID.overscaledZ<=n||m.tileID.overscaledZ>a)continue;let _=m.tileID;for(;m&&m.tileID.overscaledZ>n+1;){const b=m.tileID.scaledTo(m.tileID.overscaledZ-1);m=this._tiles[b.key],m&&m.hasData()&&(_=b)}let y=_;for(;y.overscaledZ>n;)if(y=y.scaledTo(y.overscaledZ-1),e[y.key]){o[_.key]=_;break}}}findLoadedParent(e,n){if(e.key in this._loadedParentTiles){const a=this._loadedParentTiles[e.key];return a&&a.tileID.overscaledZ>=n?a:null}for(let a=e.overscaledZ-1;a>=n;a--){const o=e.scaledTo(a),c=this._getLoadedTile(o);if(c)return c}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const n=this._tiles[e.key];return n&&n.hasData()?n:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const n=Math.ceil(e.width/this._source.tileSize)+1,a=Math.ceil(e.height/this._source.tileSize)+1,o=Math.floor(n*a*(this._maxTileCacheZoomLevels===null?p.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),c=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(c)}handleWrapJump(e){const n=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,n){const a={};for(const o in this._tiles){const c=this._tiles[o];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+n),a[c.tileID.key]=c}this._tiles=a;for(const o in this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(const o in this._tiles)this._setTileReloadTimer(o,this._tiles[o])}}_updateCoveredAndRetainedTiles(e,n,a,o,c,m){const _={},y={},b=Object.keys(e),T=de.now();for(const S of b){const k=e[S],D=this._tiles[S];if(!D||D.fadeEndTime!==0&&D.fadeEndTime<=T)continue;const B=this.findLoadedParent(k,n),N=this.findLoadedSibling(k),q=B||N||null;q&&(this._addTile(q.tileID),_[q.tileID.key]=q.tileID),y[S]=k}this._retainLoadedChildren(y,o,a,e);for(const S in _)e[S]||(this._coveredTiles[S]=!0,e[S]=_[S]);if(m){const S={},k={};for(const D of c)this._tiles[D.key].hasData()?S[D.key]=D:k[D.key]=D;for(const D in k){const B=k[D].children(this._source.maxzoom);this._tiles[B[0].key]&&this._tiles[B[1].key]&&this._tiles[B[2].key]&&this._tiles[B[3].key]&&(S[B[0].key]=e[B[0].key]=B[0],S[B[1].key]=e[B[1].key]=B[1],S[B[2].key]=e[B[2].key]=B[2],S[B[3].key]=e[B[3].key]=B[3],delete k[D])}for(const D in k){const B=k[D],N=this.findLoadedParent(B,this._source.minzoom),q=this.findLoadedSibling(B),Z=N||q||null;if(Z){S[Z.tileID.key]=e[Z.tileID.key]=Z.tileID;for(const X in S)S[X].isChildOf(Z.tileID)&&delete S[X]}}for(const D in this._tiles)S[D]||(this._coveredTiles[D]=!0)}}update(e,n){if(!this._sourceLoaded||this._paused)return;let a;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(T=>new p.S(T.canonical.z,T.wrap,T.canonical.z,T.canonical.x,T.canonical.y)):(a=e.coveringTiles({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:n}),this._source.hasTile&&(a=a.filter(T=>this._source.hasTile(T)))):a=[];const o=e.coveringZoomLevel(this._source),c=Math.max(o-$e.maxOverzooming,this._source.minzoom),m=Math.max(o+$e.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const T={};for(const S of a)if(S.canonical.z>this._source.minzoom){const k=S.scaledTo(S.canonical.z-1);T[k.key]=k;const D=S.scaledTo(Math.max(this._source.minzoom,Math.min(S.canonical.z,5)));T[D.key]=D}a=a.concat(Object.values(T))}const _=a.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,_&&this.fire(new p.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const y=this._updateRetainedTiles(a,o);cr(this._source.type)&&this._updateCoveredAndRetainedTiles(y,c,m,o,a,n);for(const T in y)this._tiles[T].clearFadeHold();const b=p.ab(this._tiles,y);for(const T of b){const S=this._tiles[T];S.hasSymbolBuckets&&!S.holdingForFade()?S.setHoldDuration(this.map._fadeDuration):S.hasSymbolBuckets&&!S.symbolFadeFinished()||this._removeTile(T)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,n){var a;const o={},c={},m=Math.max(n-$e.maxOverzooming,this._source.minzoom),_=Math.max(n+$e.maxUnderzooming,this._source.minzoom),y={};for(const b of e){const T=this._addTile(b);o[b.key]=b,T.hasData()||nthis._source.maxzoom){const k=b.children(this._source.maxzoom)[0],D=this.getTile(k);if(D&&D.hasData()){o[k.key]=k;continue}}else{const k=b.children(this._source.maxzoom);if(o[k[0].key]&&o[k[1].key]&&o[k[2].key]&&o[k[3].key])continue}let S=T.wasRequested();for(let k=b.overscaledZ-1;k>=m;--k){const D=b.scaledTo(k);if(c[D.key])break;if(c[D.key]=!0,T=this.getTile(D),!T&&S&&(T=this._addTile(D)),T){const B=T.hasData();if((B||!(!((a=this.map)===null||a===void 0)&&a.cancelPendingTileRequestsWhileZooming)||S)&&(o[D.key]=D),S=T.wasRequested(),B)break}}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const n=[];let a,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){a=this._loadedParentTiles[o.key];break}n.push(o.key);const c=o.scaledTo(o.overscaledZ-1);if(a=this._getLoadedTile(c),a)break;o=c}for(const c of n)this._loadedParentTiles[c]=a}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const n=this._tiles[e].tileID,a=this._getLoadedTile(n);this._loadedSiblingTiles[n.key]=a}}_addTile(e){let n=this._tiles[e.key];if(n)return n;n=this._cache.getAndRemove(e),n&&(this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,n)));const a=n;return n||(n=new Jr(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._tiles[e.key]=n,a||this._source.fire(new p.k("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(e,n){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const a=n.getExpiryTimeout();a&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},a))}_removeTile(e){const n=this._tiles[e];n&&(n.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(e){const n=e.sourceDataType;e.dataType==="source"&&n==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&e.dataType==="source"&&n==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,n,a){const o=[],c=this.transform;if(!c)return o;const m=a?c.getCameraQueryGeometry(e):e,_=e.map(B=>c.pointCoordinate(B,this.terrain)),y=m.map(B=>c.pointCoordinate(B,this.terrain)),b=this.getIds();let T=1/0,S=1/0,k=-1/0,D=-1/0;for(const B of y)T=Math.min(T,B.x),S=Math.min(S,B.y),k=Math.max(k,B.x),D=Math.max(D,B.y);for(let B=0;B=0&&F[1].y+X>=0){const Y=_.map(ae=>q.getTilePoint(ae)),ee=y.map(ae=>q.getTilePoint(ae));o.push({tile:N,tileID:q,queryGeometry:Y,cameraQueryGeometry:ee,scale:Z})}}return o}getVisibleCoordinates(e){const n=this.getRenderableIds(e).map(a=>this._tiles[a].tileID);for(const a of n)a.posMatrix=this.transform.calculatePosMatrix(a.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(cr(this._source.type)){const e=de.now();for(const n in this._tiles)if(this._tiles[n].fadeEndTime>=e)return!0}return!1}setFeatureState(e,n,a){this._state.updateState(e=e||"_geojsonTileLayer",n,a)}removeFeatureState(e,n,a){this._state.removeFeatureState(e=e||"_geojsonTileLayer",n,a)}getFeatureState(e,n){return this._state.getState(e=e||"_geojsonTileLayer",n)}setDependencies(e,n,a){const o=this._tiles[e];o&&o.setDependencies(n,a)}reloadTilesForDependencies(e,n){for(const a in this._tiles)this._tiles[a].hasDependency(e,n)&&this._reloadTile(a,"reloading");this._cache.filter(a=>!a.hasDependency(e,n))}}function Ci(h,e){const n=Math.abs(2*h.wrap)-+(h.wrap<0),a=Math.abs(2*e.wrap)-+(e.wrap<0);return h.overscaledZ-e.overscaledZ||a-n||e.canonical.y-h.canonical.y||e.canonical.x-h.canonical.x}function cr(h){return h==="raster"||h==="image"||h==="video"}$e.maxOverzooming=10,$e.maxUnderzooming=3;class We{constructor(e,n){this.reset(e,n)}reset(e,n){this.points=e||[],this._distances=[0];for(let a=1;a0?(o-m)/_:0;return this.points[c].mult(1-y).add(this.points[n].mult(y))}}function Cr(h,e){let n=!0;return h==="always"||h!=="never"&&e!=="never"||(n=!1),n}class Ur{constructor(e,n,a){const o=this.boxCells=[],c=this.circleCells=[];this.xCellCount=Math.ceil(e/a),this.yCellCount=Math.ceil(n/a);for(let m=0;mthis.width||o<0||n>this.height)return[];const y=[];if(e<=0&&n<=0&&this.width<=a&&this.height<=o){if(c)return[{key:null,x1:e,y1:n,x2:a,y2:o}];for(let b=0;b0}hitTestCircle(e,n,a,o,c){const m=e-a,_=e+a,y=n-a,b=n+a;if(_<0||m>this.width||b<0||y>this.height)return!1;const T=[];return this._forEachCell(m,y,_,b,this._queryCellCircle,T,{hitTest:!0,overlapMode:o,circle:{x:e,y:n,radius:a},seenUids:{box:{},circle:{}}},c),T.length>0}_queryCell(e,n,a,o,c,m,_,y){const{seenUids:b,hitTest:T,overlapMode:S}=_,k=this.boxCells[c];if(k!==null){const B=this.bboxes;for(const N of k)if(!b.box[N]){b.box[N]=!0;const q=4*N,Z=this.boxKeys[N];if(e<=B[q+2]&&n<=B[q+3]&&a>=B[q+0]&&o>=B[q+1]&&(!y||y(Z))&&(!T||!Cr(S,Z.overlapMode))&&(m.push({key:Z,x1:B[q],y1:B[q+1],x2:B[q+2],y2:B[q+3]}),T))return!0}}const D=this.circleCells[c];if(D!==null){const B=this.circles;for(const N of D)if(!b.circle[N]){b.circle[N]=!0;const q=3*N,Z=this.circleKeys[N];if(this._circleAndRectCollide(B[q],B[q+1],B[q+2],e,n,a,o)&&(!y||y(Z))&&(!T||!Cr(S,Z.overlapMode))){const X=B[q],F=B[q+1],Y=B[q+2];if(m.push({key:Z,x1:X-Y,y1:F-Y,x2:X+Y,y2:F+Y}),T)return!0}}}return!1}_queryCellCircle(e,n,a,o,c,m,_,y){const{circle:b,seenUids:T,overlapMode:S}=_,k=this.boxCells[c];if(k!==null){const B=this.bboxes;for(const N of k)if(!T.box[N]){T.box[N]=!0;const q=4*N,Z=this.boxKeys[N];if(this._circleAndRectCollide(b.x,b.y,b.radius,B[q+0],B[q+1],B[q+2],B[q+3])&&(!y||y(Z))&&!Cr(S,Z.overlapMode))return m.push(!0),!0}}const D=this.circleCells[c];if(D!==null){const B=this.circles;for(const N of D)if(!T.circle[N]){T.circle[N]=!0;const q=3*N,Z=this.circleKeys[N];if(this._circlesCollide(B[q],B[q+1],B[q+2],b.x,b.y,b.radius)&&(!y||y(Z))&&!Cr(S,Z.overlapMode))return m.push(!0),!0}}}_forEachCell(e,n,a,o,c,m,_,y){const b=this._convertToXCellCoord(e),T=this._convertToYCellCoord(n),S=this._convertToXCellCoord(a),k=this._convertToYCellCoord(o);for(let D=b;D<=S;D++)for(let B=T;B<=k;B++)if(c.call(this,e,n,a,o,this.xCellCount*B+D,m,_,y))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,n,a,o,c,m){const _=o-e,y=c-n,b=a+m;return b*b>_*_+y*y}_circleAndRectCollide(e,n,a,o,c,m,_){const y=(m-o)/2,b=Math.abs(e-(o+y));if(b>y+a)return!1;const T=(_-c)/2,S=Math.abs(n-(c+T));if(S>T+a)return!1;if(b<=y||S<=T)return!0;const k=b-y,D=S-T;return k*k+D*D<=a*a}}function Yr(h,e,n,a,o){const c=p.H();return e?(p.K(c,c,[1/o,1/o,1]),n||p.ad(c,c,a.angle)):p.L(c,a.labelPlaneMatrix,h),c}function Mr(h,e,n,a,o){if(e){const c=p.ae(h);return p.K(c,c,[o,o,1]),n||p.ad(c,c,-a.angle),c}return a.glCoordMatrix}function U(h,e,n,a){let o;a?(o=[h,e,a(h,e),1],p.af(o,o,n)):(o=[h,e,0,1],ot(o,o,n));const c=o[3];return{point:new p.P(o[0]/c,o[1]/c),signedDistanceFromCamera:c,isOccluded:!1}}function A(h,e){return .5+h/e*.5}function P(h,e){return h.x>=-e[0]&&h.x<=e[0]&&h.y>=-e[1]&&h.y<=e[1]}function R(h,e,n,a,o,c,m,_,y,b,T,S,k,D,B){const N=a?h.textSizeData:h.iconSizeData,q=p.ag(N,n.transform.zoom),Z=[256/n.width*2+1,256/n.height*2+1],X=a?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;X.clear();const F=h.lineVertexArray,Y=a?h.text.placedSymbolArray:h.icon.placedSymbolArray,ee=n.transform.width/n.transform.height;let ae=!1;for(let fe=0;feMath.abs(n.x-e.x)*a?{useVertical:!0}:(h===p.ah.vertical?e.yn.x)?{needsFlipping:!0}:null}function Q(h,e,n,a,o,c,m,_,y,b,T){const S=n/24,k=e.lineOffsetX*S,D=e.lineOffsetY*S;let B;if(e.numGlyphs>1){const N=e.glyphStartIndex+e.numGlyphs,q=e.lineStartIndex,Z=e.lineStartIndex+e.lineLength,X=V(S,_,k,D,a,e,T,h);if(!X)return{notEnoughRoom:!0};const F=U(X.first.point.x,X.first.point.y,m,h.getElevation).point,Y=U(X.last.point.x,X.last.point.y,m,h.getElevation).point;if(o&&!a){const ee=K(e.writingMode,F,Y,b);if(ee)return ee}B=[X.first];for(let ee=e.glyphStartIndex+1;ee0?F.point:function(ae,fe,_e,Pe,ke,we){return ie(ae,fe,_e,1,ke,we)}(h.tileAnchorPoint,X,q,0,c,h),ee=K(e.writingMode,q,Y,b);if(ee)return ee}const N=ve(S*_.getoffsetX(e.glyphStartIndex),k,D,a,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,h,T);if(!N||h.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};B=[N]}for(const N of B)p.aj(y,N.point,N.angle);return{}}function ie(h,e,n,a,o,c){const m=h.add(h.sub(e)._unit()),_=o!==void 0?U(m.x,m.y,o,c.getElevation).point:ue(m.x,m.y,c).point,y=n.sub(_);return n.add(y._mult(a/y.mag()))}function H(h,e,n){const a=e.projectionCache;if(a.projections[h])return a.projections[h];const o=new p.P(e.lineVertexArray.getx(h),e.lineVertexArray.gety(h)),c=ue(o.x,o.y,e);if(c.signedDistanceFromCamera>0)return a.projections[h]=c.point,a.anyProjectionOccluded=a.anyProjectionOccluded||c.isOccluded,c.point;const m=h-n.direction;return function(_,y,b,T,S){return ie(_,y,b,T,void 0,S)}(n.distanceFromAnchor===0?e.tileAnchorPoint:new p.P(e.lineVertexArray.getx(m),e.lineVertexArray.gety(m)),o,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,e)}function ue(h,e,n){const a=h+n.translation[0],o=e+n.translation[1];let c;return!n.pitchWithMap&&n.projection.useSpecialProjectionForSymbols?(c=n.projection.projectTileCoordinates(a,o,n.unwrappedTileID,n.getElevation),c.point.x=(.5*c.point.x+.5)*n.width,c.point.y=(.5*-c.point.y+.5)*n.height):(c=U(a,o,n.labelPlaneMatrix,n.getElevation),c.isOccluded=!1),c}function me(h,e,n){return h._unit()._perp()._mult(e*n)}function oe(h,e,n,a,o,c,m,_,y){if(_.projectionCache.offsets[h])return _.projectionCache.offsets[h];const b=n.add(e);if(h+y.direction=o)return _.projectionCache.offsets[h]=b,b;const T=H(h+y.direction,_,y),S=me(T.sub(n),m,y.direction),k=n.add(S),D=T.add(S);return _.projectionCache.offsets[h]=p.ak(c,b,k,D)||b,_.projectionCache.offsets[h]}function ve(h,e,n,a,o,c,m,_,y){const b=a?h-e:h+e;let T=b>0?1:-1,S=0;a&&(T*=-1,S=Math.PI),T<0&&(S+=Math.PI);let k,D=T>0?c+o:c+o+1;_.projectionCache.cachedAnchorPoint?k=_.projectionCache.cachedAnchorPoint:(k=ue(_.tileAnchorPoint.x,_.tileAnchorPoint.y,_).point,_.projectionCache.cachedAnchorPoint=k);let B,N,q=k,Z=k,X=0,F=0;const Y=Math.abs(b),ee=[];let ae;for(;X+F<=Y;){if(D+=T,D=m)return null;X+=F,Z=q,N=B;const Pe={absOffsetX:Y,direction:T,distanceFromAnchor:X,previousVertex:Z};if(q=H(D,_,Pe),n===0)ee.push(Z),ae=q.sub(Z);else{let ke;const we=q.sub(Z);ke=we.mag()===0?me(H(D+T,_,Pe).sub(q),n,T):me(we,n,T),N||(N=Z.add(ke)),B=oe(D,ke,q,c,m,N,n,_,Pe),ee.push(N),ae=B.sub(N)}F=ae.mag()}const fe=ae._mult((Y-X)/F)._add(N||Z),_e=S+Math.atan2(q.y-Z.y,q.x-Z.x);return ee.push(fe),{point:fe,angle:y?_e:0,path:ee}}const Ve=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Ne(h,e){for(let n=0;n=1;Ye--)Ce.push(Xe.path[Ye]);for(let Ye=1;Yent.signedDistanceFromCamera<=0)?[]:Ye.map(nt=>nt.point)}let Tt=[];if(Ce.length>0){const Ye=Ce[0].clone(),nt=Ce[0].clone();for(let St=1;St=we.x&&nt.x<=be.x&&Ye.y>=we.y&&nt.y<=be.y?[Ce]:nt.xbe.x||nt.ybe.y?[]:p.al([Ce],we.x,we.y,be.x,be.y)}for(const Ye of Tt){Re.reset(Ye,.25*ke);let nt=0;nt=Re.length<=.5*ke?1:Math.ceil(Re.paddedLength/qe)+1;for(let St=0;StU(o.x,o.y,a,n.getElevation))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[];let a=1/0,o=1/0,c=-1/0,m=-1/0;for(const T of e){const S=new p.P(T.x+Ke,T.y+Ke);a=Math.min(a,S.x),o=Math.min(o,S.y),c=Math.max(c,S.x),m=Math.max(m,S.y),n.push(S)}const _=this.grid.query(a,o,c,m).concat(this.ignoredGrid.query(a,o,c,m)),y={},b={};for(const T of _){const S=T.key;if(y[S.bucketInstanceId]===void 0&&(y[S.bucketInstanceId]={}),y[S.bucketInstanceId][S.featureIndex])continue;const k=[new p.P(T.x1,T.y1),new p.P(T.x2,T.y1),new p.P(T.x2,T.y2),new p.P(T.x1,T.y2)];p.am(n,k)&&(y[S.bucketInstanceId][S.featureIndex]=!0,b[S.bucketInstanceId]===void 0&&(b[S.bucketInstanceId]=[]),b[S.bucketInstanceId].push(S.featureIndex))}return b}insertCollisionBox(e,n,a,o,c,m){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:o,featureIndex:c,collisionGroupID:m,overlapMode:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,n,a,o,c,m){const _=a?this.ignoredGrid:this.grid,y={bucketInstanceId:o,featureIndex:c,collisionGroupID:m,overlapMode:n};for(let b=0;b=this.screenRightBoundary||othis.screenBottomBoundary}isInsideGrid(e,n,a,o){return a>=0&&e=0&&nthis.projectAndGetPerspectiveRatio(a,ke.x,ke.y,o,b));_e=Pe.some(ke=>!ke.isOccluded),fe=Pe.map(ke=>ke.point)}else _e=!0;return{box:p.ao(fe),allPointsOccluded:!_e}}}function rt(h,e,n){return e*(p.X/(h.tileSize*Math.pow(2,n-h.tileID.overscaledZ)))}class Ut{constructor(e,n,a,o){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?n:-n))):o&&a?1:0,this.placed=a}isHidden(){return this.opacity===0&&!this.placed}}class zt{constructor(e,n,a,o,c){this.text=new Ut(e?e.text:null,n,a,c),this.icon=new Ut(e?e.icon:null,n,o,c)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class tt{constructor(e,n,a){this.text=e,this.icon=n,this.skipFade=a}}class ft{constructor(){this.invProjMatrix=p.H(),this.viewportMatrix=p.H(),this.circles=[]}}class Ct{constructor(e,n,a,o,c){this.bucketInstanceId=e,this.featureIndex=n,this.sourceLayerIndex=a,this.bucketIndex=o,this.tileID=c}}class Ht{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 n=++this.maxGroupID;this.collisionGroups[e]={ID:n,predicate:a=>a.collisionGroupID===n}}return this.collisionGroups[e]}}function Qt(h,e,n,a,o){const{horizontalAlign:c,verticalAlign:m}=p.au(h);return new p.P(-(c-.5)*e+a[0]*o,-(m-.5)*n+a[1]*o)}class vi{constructor(e,n,a,o,c,m){this.transform=e.clone(),this.terrain=a,this.collisionIndex=new lt(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new Ht(c),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=m,m&&(m.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const n=this.terrain;return n?(a,o)=>n.getElevation(e,a,o):null}getBucketParts(e,n,a,o){const c=a.getBucket(n),m=a.latestFeatureIndex;if(!c||!m||n.id!==c.layerIds[0])return;const _=a.collisionBoxArray,y=c.layers[0].layout,b=c.layers[0].paint,T=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),S=a.tileSize/p.X,k=a.tileID.toUnwrapped(),D=this.transform.calculatePosMatrix(k),B=y.get("text-pitch-alignment")==="map",N=y.get("text-rotation-alignment")==="map",q=rt(a,1,this.transform.zoom),Z=this.collisionIndex.mapProjection.translatePosition(this.transform,a,b.get("text-translate"),b.get("text-translate-anchor")),X=this.collisionIndex.mapProjection.translatePosition(this.transform,a,b.get("icon-translate"),b.get("icon-translate-anchor")),F=Yr(D,B,N,this.transform,q);let Y=null;if(B){const ae=Mr(D,B,N,this.transform,q);Y=p.L([],this.transform.labelPlaneMatrix,ae)}this.retainedQueryData[c.bucketInstanceId]=new Ct(c.bucketInstanceId,m,c.sourceLayerIndex,c.index,a.tileID);const ee={bucket:c,layout:y,translationText:Z,translationIcon:X,posMatrix:D,unwrappedTileID:k,textLabelPlaneMatrix:F,labelToScreenMatrix:Y,scale:T,textPixelRatio:S,holdingForFade:a.holdingForFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:p.ag(c.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(c.sourceID)};if(o)for(const ae of c.sortKeyRanges){const{sortKey:fe,symbolInstanceStart:_e,symbolInstanceEnd:Pe}=ae;e.push({sortKey:fe,symbolInstanceStart:_e,symbolInstanceEnd:Pe,parameters:ee})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:c.symbolInstances.length,parameters:ee})}attemptAnchorPlacement(e,n,a,o,c,m,_,y,b,T,S,k,D,B,N,q,Z,X,F){const Y=p.aq[e.textAnchor],ee=[e.textOffset0,e.textOffset1],ae=Qt(Y,a,o,ee,c),fe=this.collisionIndex.placeCollisionBox(n,k,y,b,T,_,m,q,S.predicate,F,ae);if((!X||this.collisionIndex.placeCollisionBox(X,k,y,b,T,_,m,Z,S.predicate,F,ae).placeable)&&fe.placeable){let _e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[D.crossTileID]&&this.prevPlacement.placements[D.crossTileID]&&this.prevPlacement.placements[D.crossTileID].text&&(_e=this.prevPlacement.variableOffsets[D.crossTileID].anchor),D.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[D.crossTileID]={textOffset:ee,width:a,height:o,anchor:Y,textBoxScale:c,prevAnchor:_e},this.markUsedJustification(B,Y,D,N),B.allowVerticalPlacement&&(this.markUsedOrientation(B,N,D),this.placedOrientations[D.crossTileID]=N),{shift:ae,placedGlyphBoxes:fe}}}placeLayerBucketPart(e,n,a){const{bucket:o,layout:c,translationText:m,translationIcon:_,posMatrix:y,unwrappedTileID:b,textLabelPlaneMatrix:T,labelToScreenMatrix:S,textPixelRatio:k,holdingForFade:D,collisionBoxArray:B,partiallyEvaluatedTextSize:N,collisionGroup:q}=e.parameters,Z=c.get("text-optional"),X=c.get("icon-optional"),F=p.ar(c,"text-overlap","text-allow-overlap"),Y=F==="always",ee=p.ar(c,"icon-overlap","icon-allow-overlap"),ae=ee==="always",fe=c.get("text-rotation-alignment")==="map",_e=c.get("text-pitch-alignment")==="map",Pe=c.get("icon-text-fit")!=="none",ke=c.get("symbol-z-order")==="viewport-y",we=Y&&(ae||!o.hasIconData()||X),be=ae&&(Y||!o.hasTextData()||Z);!o.collisionArrays&&B&&o.deserializeCollisionBoxes(B);const Re=this._getTerrainElevationFunc(this.retainedQueryData[o.bucketInstanceId].tileID),Xe=(Se,Ce,qe)=>{var Tt,Ye;if(n[Se.crossTileID])return;if(D)return void(this.placements[Se.crossTileID]=new tt(!1,!1,!1));let nt=!1,St=!1,oi=!0,mr=null,It={box:null,placeable:!1,offscreen:null},Ei={box:null,placeable:!1,offscreen:null},bi=null,li=null,wi=null,Dr=0,es=0,va=0;Ce.textFeatureIndex?Dr=Ce.textFeatureIndex:Se.useRuntimeCollisionCircles&&(Dr=Se.featureIndex),Ce.verticalTextFeatureIndex&&(es=Ce.verticalTextFeatureIndex);const ts=Ce.textBox;if(ts){const rr=ei=>{let ci=p.ah.horizontal;if(o.allowVerticalPlacement&&!ei&&this.prevPlacement){const Gi=this.prevPlacement.placedOrientations[Se.crossTileID];Gi&&(this.placedOrientations[Se.crossTileID]=Gi,ci=Gi,this.markUsedOrientation(o,ci,Se))}return ci},nr=(ei,ci)=>{if(o.allowVerticalPlacement&&Se.numVerticalGlyphVertices>0&&Ce.verticalTextBox){for(const Gi of o.writingModes)if(Gi===p.ah.vertical?(It=ci(),Ei=It):It=ei(),It&&It.placeable)break}else It=ei()},tn=Se.textAnchorOffsetStartIndex,gr=Se.textAnchorOffsetEndIndex;if(gr===tn){const ei=(ci,Gi)=>{const at=this.collisionIndex.placeCollisionBox(ci,F,k,y,b,_e,fe,m,q.predicate,Re);return at&&at.placeable&&(this.markUsedOrientation(o,Gi,Se),this.placedOrientations[Se.crossTileID]=Gi),at};nr(()=>ei(ts,p.ah.horizontal),()=>{const ci=Ce.verticalTextBox;return o.allowVerticalPlacement&&Se.numVerticalGlyphVertices>0&&ci?ei(ci,p.ah.vertical):{box:null,offscreen:null}}),rr(It&&It.placeable)}else{let ei=p.aq[(Ye=(Tt=this.prevPlacement)===null||Tt===void 0?void 0:Tt.variableOffsets[Se.crossTileID])===null||Ye===void 0?void 0:Ye.anchor];const ci=(at,In,is)=>{const rs=at.x2-at.x1,El=at.y2-at.y1,Mc=Se.textBoxScale,zl=Pe&&ee==="never"?In:null;let rn=null,Dl=F==="never"?1:2,wa="never";ei&&Dl++;for(let Rs=0;Rsci(ts,Ce.iconBox,p.ah.horizontal),()=>{const at=Ce.verticalTextBox;return o.allowVerticalPlacement&&(!It||!It.placeable)&&Se.numVerticalGlyphVertices>0&&at?ci(at,Ce.verticalIconBox,p.ah.vertical):{box:null,occluded:!0,offscreen:null}}),It&&(nt=It.placeable,oi=It.offscreen);const Gi=rr(It&&It.placeable);if(!nt&&this.prevPlacement){const at=this.prevPlacement.variableOffsets[Se.crossTileID];at&&(this.variableOffsets[Se.crossTileID]=at,this.markUsedJustification(o,at.anchor,Se,Gi))}}}if(bi=It,nt=bi&&bi.placeable,oi=bi&&bi.offscreen,Se.useRuntimeCollisionCircles){const rr=o.text.placedSymbolArray.get(Se.centerJustifiedTextSymbolIndex),nr=p.ai(o.textSizeData,N,rr),tn=c.get("text-padding");li=this.collisionIndex.placeCollisionCircles(F,rr,o.lineVertexArray,o.glyphOffsetArray,nr,y,b,T,S,a,_e,q.predicate,Se.collisionCircleDiameter,tn,m,Re),li.circles.length&&li.collisionDetected&&!a&&p.w("Collisions detected, but collision boxes are not shown"),nt=Y||li.circles.length>0&&!li.collisionDetected,oi=oi&&li.offscreen}if(Ce.iconFeatureIndex&&(va=Ce.iconFeatureIndex),Ce.iconBox){const rr=nr=>this.collisionIndex.placeCollisionBox(nr,ee,k,y,b,_e,fe,_,q.predicate,Re,Pe&&mr?mr:void 0);Ei&&Ei.placeable&&Ce.verticalIconBox?(wi=rr(Ce.verticalIconBox),St=wi.placeable):(wi=rr(Ce.iconBox),St=wi.placeable),oi=oi&&wi.offscreen}const ir=Z||Se.numHorizontalGlyphVertices===0&&Se.numVerticalGlyphVertices===0,ba=X||Se.numIconVertices===0;ir||ba?ba?ir||(St=St&&nt):nt=St&&nt:St=nt=St&&nt;const ko=St&&wi.placeable;if(nt&&bi.placeable&&this.collisionIndex.insertCollisionBox(bi.box,F,c.get("text-ignore-placement"),o.bucketInstanceId,Ei&&Ei.placeable&&es?es:Dr,q.ID),ko&&this.collisionIndex.insertCollisionBox(wi.box,ee,c.get("icon-ignore-placement"),o.bucketInstanceId,va,q.ID),li&&nt&&this.collisionIndex.insertCollisionCircles(li.circles,F,c.get("text-ignore-placement"),o.bucketInstanceId,Dr,q.ID),a&&this.storeCollisionData(o.bucketInstanceId,qe,Ce,bi,wi,li),Se.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(o.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[Se.crossTileID]=new tt(nt||we,St||be,oi||o.justReloaded),n[Se.crossTileID]=!0};if(ke){if(e.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const Se=o.getSortedSymbolIndexes(this.transform.angle);for(let Ce=Se.length-1;Ce>=0;--Ce){const qe=Se[Ce];Xe(o.symbolInstances.get(qe),o.collisionArrays[qe],qe)}}else for(let Se=e.symbolInstanceStart;Se=0&&(e.text.placedSymbolArray.get(_).crossTileID=c>=0&&_!==c?0:a.crossTileID)}markUsedOrientation(e,n,a){const o=n===p.ah.horizontal||n===p.ah.horizontalOnly?n:0,c=n===p.ah.vertical?n:0,m=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex];for(const _ of m)e.text.placedSymbolArray.get(_).placedOrientation=o;a.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).placedOrientation=c)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let a=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const o=n?n.symbolFadeChange(e):1,c=n?n.opacities:{},m=n?n.variableOffsets:{},_=n?n.placedOrientations:{};for(const y in this.placements){const b=this.placements[y],T=c[y];T?(this.opacities[y]=new zt(T,o,b.text,b.icon),a=a||b.text!==T.text.placed||b.icon!==T.icon.placed):(this.opacities[y]=new zt(null,o,b.text,b.icon,b.skipFade),a=a||b.text||b.icon)}for(const y in c){const b=c[y];if(!this.opacities[y]){const T=new zt(b,o,!1,!1);T.isHidden()||(this.opacities[y]=T,a=a||b.text.placed||b.icon.placed)}}for(const y in m)this.variableOffsets[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.variableOffsets[y]=m[y]);for(const y in _)this.placedOrientations[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.placedOrientations[y]=_[y]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:e)}updateLayerOpacities(e,n){const a={};for(const o of n){const c=o.getBucket(e);c&&o.latestFeatureIndex&&e.id===c.layerIds[0]&&this.updateBucketOpacities(c,o.tileID,a,o.collisionBoxArray)}}updateBucketOpacities(e,n,a,o){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 c=e.layers[0],m=c.layout,_=new zt(null,0,!1,!1,!0),y=m.get("text-allow-overlap"),b=m.get("icon-allow-overlap"),T=c._unevaluatedLayout.hasValue("text-variable-anchor")||c._unevaluatedLayout.hasValue("text-variable-anchor-offset"),S=m.get("text-rotation-alignment")==="map",k=m.get("text-pitch-alignment")==="map",D=m.get("icon-text-fit")!=="none",B=new zt(null,0,y&&(b||!e.hasIconData()||m.get("icon-optional")),b&&(y||!e.hasTextData()||m.get("text-optional")),!0);!e.collisionArrays&&o&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(o);const N=(Z,X,F)=>{for(let Y=0;Y0,_e=this.placedOrientations[X.crossTileID],Pe=_e===p.ah.vertical,ke=_e===p.ah.horizontal||_e===p.ah.horizontalOnly;if(F>0||Y>0){const be=$i(ae.text);N(e.text,F,Pe?Dn:be),N(e.text,Y,ke?Dn:be);const Re=ae.text.isHidden();[X.rightJustifiedTextSymbolIndex,X.centerJustifiedTextSymbolIndex,X.leftJustifiedTextSymbolIndex].forEach(Ce=>{Ce>=0&&(e.text.placedSymbolArray.get(Ce).hidden=Re||Pe?1:0)}),X.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(X.verticalPlacedTextSymbolIndex).hidden=Re||ke?1:0);const Xe=this.variableOffsets[X.crossTileID];Xe&&this.markUsedJustification(e,Xe.anchor,X,_e);const Se=this.placedOrientations[X.crossTileID];Se&&(this.markUsedJustification(e,"left",X,Se),this.markUsedOrientation(e,Se,X))}if(fe){const be=$i(ae.icon),Re=!(D&&X.verticalPlacedIconSymbolIndex&&Pe);X.placedIconSymbolIndex>=0&&(N(e.icon,X.numIconVertices,Re?be:Dn),e.icon.placedSymbolArray.get(X.placedIconSymbolIndex).hidden=ae.icon.isHidden()),X.verticalPlacedIconSymbolIndex>=0&&(N(e.icon,X.numVerticalIconVertices,Re?Dn:be),e.icon.placedSymbolArray.get(X.verticalPlacedIconSymbolIndex).hidden=ae.icon.isHidden())}const we=q&&q.has(Z)?q.get(Z):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const be=e.collisionArrays[Z];if(be){let Re=new p.P(0,0);if(be.textBox||be.verticalTextBox){let Xe=!0;if(T){const Se=this.variableOffsets[ee];Se?(Re=Qt(Se.anchor,Se.width,Se.height,Se.textOffset,Se.textBoxScale),S&&Re._rotate(k?this.transform.angle:-this.transform.angle)):Xe=!1}if(be.textBox||be.verticalTextBox){let Se;be.textBox&&(Se=Pe),be.verticalTextBox&&(Se=ke),zn(e.textCollisionBox.collisionVertexArray,ae.text.placed,!Xe||Se,we.text,Re.x,Re.y)}}if(be.iconBox||be.verticalIconBox){const Xe=!!(!ke&&be.verticalIconBox);let Se;be.iconBox&&(Se=Xe),be.verticalIconBox&&(Se=!Xe),zn(e.iconCollisionBox.collisionVertexArray,ae.icon.placed,Se,we.icon,D?Re.x:0,D?Re.y:0)}}}}if(e.sortFeatures(this.transform.angle),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`);if(e.bucketInstanceId in this.collisionCircleArrays){const Z=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=Z.invProjMatrix,e.placementViewportMatrix=Z.viewportMatrix,e.collisionCircleArray=Z.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(e){return this.fadeDuration===0?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 zn(h,e,n,a,o,c){a&&a.length!==0||(a=[0,0,0,0]);const m=a[0]-Ke,_=a[1]-Ke,y=a[2]-Ke,b=a[3]-Ke;h.emplaceBack(e?1:0,n?1:0,o||0,c||0,m,_),h.emplaceBack(e?1:0,n?1:0,o||0,c||0,y,_),h.emplaceBack(e?1:0,n?1:0,o||0,c||0,y,b),h.emplaceBack(e?1:0,n?1:0,o||0,c||0,m,b)}const mt=Math.pow(2,25),Na=Math.pow(2,24),Ua=Math.pow(2,17),Ui=Math.pow(2,16),ji=Math.pow(2,9),rc=Math.pow(2,8),Yi=Math.pow(2,1);function $i(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;const e=h.placed?1:0,n=Math.floor(127*h.opacity);return n*mt+e*Na+n*Ua+e*Ui+n*ji+e*rc+n*Yi+e}const Dn=0;function pn(){return{isOccluded:(h,e,n)=>!1,getPitchedTextCorrection:(h,e,n)=>1,get useSpecialProjectionForSymbols(){return!1},projectTileCoordinates(h,e,n,a){throw new Error("Not implemented.")},translatePosition:(h,e,n,a)=>function(o,c,m,_,y=!1){if(!m[0]&&!m[1])return[0,0];const b=y?_==="map"?o.angle:0:_==="viewport"?-o.angle:0;if(b){const T=Math.sin(b),S=Math.cos(b);m=[m[0]*S-m[1]*T,m[0]*T+m[1]*S]}return[y?m[0]:rt(c,m[0],o.zoom),y?m[1]:rt(c,m[1],o.zoom)]}(h,e,n,a),getCircleRadiusCorrection:h=>1}}class jt{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,n,a,o,c){const m=this._bucketParts;for(;this._currentTileIndex_.sortKey-y.sortKey));this._currentPartIndex!this._forceFullPlacement&&de.now()-o>2;for(;this._currentPlacementIndex>=0;){const m=n[e[this._currentPlacementIndex]],_=this.placement.collisionIndex.transform.zoom;if(m.type==="symbol"&&(!m.minzoom||m.minzoom<=_)&&(!m.maxzoom||m.maxzoom>_)){if(this._inProgressLayer||(this._inProgressLayer=new jt(m)),this._inProgressLayer.continuePlacement(a[m.source],this.placement,this._showCollisionBoxes,m,c))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const hr=512/p.X/2;class Vt{constructor(e,n,a){this.tileID=e,this.bucketInstanceId=a,this._symbolsByKey={};const o=new Map;for(let c=0;c({x:Math.floor(y.anchorX*hr),y:Math.floor(y.anchorY*hr)})),crossTileIDs:m.map(y=>y.crossTileID)};if(_.positions.length>128){const y=new p.av(_.positions.length,16,Uint16Array);for(const{x:b,y:T}of _.positions)y.add(b,T);y.finish(),delete _.positions,_.index=y}this._symbolsByKey[c]=_}}getScaledCoordinates(e,n){const{x:a,y:o,z:c}=this.tileID.canonical,{x:m,y:_,z:y}=n.canonical,b=hr/Math.pow(2,y-c),T=(_*p.X+e.anchorY)*b,S=o*p.X*hr;return{x:Math.floor((m*p.X+e.anchorX)*b-a*p.X*hr),y:Math.floor(T-S)}}findMatches(e,n,a){const o=this.tileID.canonical.ze)}}class $s{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ur{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const n=Math.round((e-this.lng)/360);if(n!==0)for(const a in this.indexes){const o=this.indexes[a],c={};for(const m in o){const _=o[m];_.tileID=_.tileID.unwrapTo(_.tileID.wrap+n),c[_.tileID.key]=_}this.indexes[a]=c}this.lng=e}addBucket(e,n,a){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let c=0;ce.overscaledZ)for(const _ in m){const y=m[_];y.tileID.isChildOf(e)&&y.findMatches(n.symbolInstances,e,o)}else{const _=m[e.scaledTo(Number(c)).key];_&&_.findMatches(n.symbolInstances,e,o)}}for(let c=0;c{n[a]=!0});for(const a in this.layerIndexes)n[a]||delete this.layerIndexes[a]}}const dr=(h,e)=>p.t(h,e&&e.filter(n=>n.identifier!=="source.canvas")),nc=p.aw();class qs extends p.E{constructor(e,n={}){super(),this._rtlPluginLoaded=()=>{for(const a in this.sourceCaches){const o=this.sourceCaches[a].getSource().type;o!=="vector"&&o!=="geojson"||this.sourceCaches[a].reload()}},this.map=e,this.dispatcher=new Vr(Ir(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(a,o)=>this.getGlyphs(a,o)),this.dispatcher.registerMessageHandler("GI",(a,o)=>this.getImages(a,o)),this.imageManager=new Gt,this.imageManager.setEventedParent(this),this.glyphManager=new _i(e._requestManager,n.localIdeographFontFamily),this.lineAtlas=new Ni(256,512),this.crossTileSymbolIndex=new ja,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new p.ax,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",p.ay()),Ar().on(xe,this._rtlPluginLoaded),this.on("data",a=>{if(a.dataType!=="source"||a.sourceDataType!=="metadata")return;const o=this.sourceCaches[a.sourceId];if(!o)return;const c=o.getSource();if(c&&c.vectorLayerIds)for(const m in this._layers){const _=this._layers[m];_.source===c.id&&this._validateLayer(_)}})}loadURL(e,n={},a){this.fire(new p.k("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const o=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const c=this._loadStyleRequest;p.h(o,this._loadStyleRequest).then(m=>{this._loadStyleRequest=null,this._load(m.data,n,a)}).catch(m=>{this._loadStyleRequest=null,m&&!c.signal.aborted&&this.fire(new p.j(m))})}loadJSON(e,n={},a){this.fire(new p.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,de.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(e,n,a)}).catch(()=>{})}loadEmpty(){this.fire(new p.k("dataloading",{dataType:"style"})),this._load(nc,{validate:!1})}_load(e,n,a){var o;const c=n.transformStyle?n.transformStyle(a,e):e;if(!n.validate||!dr(this,p.u(c))){this._loaded=!0,this.stylesheet=c;for(const m in c.sources)this.addSource(m,c.sources[m],{validate:!1});c.sprite?this._loadSprite(c.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(c.glyphs),this._createLayers(),this.light=new ar(this.stylesheet.light),this.sky=new yi(this.stylesheet.sky),this.map.setTerrain((o=this.stylesheet.terrain)!==null&&o!==void 0?o:null),this.fire(new p.k("data",{dataType:"style"})),this.fire(new p.k("style.load"))}}_createLayers(){const e=p.az(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map(n=>n.id),this._layers={},this._serializedLayers=null;for(const n of e){const a=p.aA(n);a.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=a}}_loadSprite(e,n=!1,a=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(c,m,_,y){return p._(this,void 0,void 0,function*(){const b=ii(c),T=_>1?"@2x":"",S={},k={};for(const{id:D,url:B}of b){const N=m.transformRequest(Or(B,T,".json"),"SpriteJSON");S[D]=p.h(N,y);const q=m.transformRequest(Or(B,T,".png"),"SpriteImage");k[D]=Mt.getImage(q,y)}return yield Promise.all([...Object.values(S),...Object.values(k)]),function(D,B){return p._(this,void 0,void 0,function*(){const N={};for(const q in D){N[q]={};const Z=de.getImageCanvasContext((yield B[q]).data),X=(yield D[q]).data;for(const F in X){const{width:Y,height:ee,x:ae,y:fe,sdf:_e,pixelRatio:Pe,stretchX:ke,stretchY:we,content:be,textFitWidth:Re,textFitHeight:Xe}=X[F];N[q][F]={data:null,pixelRatio:Pe,sdf:_e,stretchX:ke,stretchY:we,content:be,textFitWidth:Re,textFitHeight:Xe,spriteData:{width:Y,height:ee,x:ae,y:fe,context:Z}}}}return N})}(S,k)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(c=>{if(this._spriteRequest=null,c)for(const m in c){this._spritesImagesIds[m]=[];const _=this._spritesImagesIds[m]?this._spritesImagesIds[m].filter(y=>!(y in c)):[];for(const y of _)this.imageManager.removeImage(y),this._changedImages[y]=!0;for(const y in c[m]){const b=m==="default"?y:`${m}:${y}`;this._spritesImagesIds[m].push(b),b in this.imageManager.images?this.imageManager.updateImage(b,c[m][y],!1):this.imageManager.addImage(b,c[m][y]),n&&(this._changedImages[b]=!0)}}}).catch(c=>{this._spriteRequest=null,o=c,this.fire(new p.j(o))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"})),a&&a(o)})}_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 p.k("data",{dataType:"style"}))}_validateLayer(e){const n=this.sourceCaches[e.source];if(!n)return;const a=e.sourceLayer;if(!a)return;const o=n.getSource();(o.type==="geojson"||o.vectorLayerIds&&o.vectorLayerIds.indexOf(a)===-1)&&this.fire(new p.j(new Error(`Source layer "${a}" does not exist on source "${o.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||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,n=!1){const a=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?p.aB(a):a);const o=[];for(const c of e)if(a[c]){const m=n?p.aB(a[c]):a[c];o.push(m)}return o}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const n=Object.keys(this._layers);for(const a of n){const o=this._layers[a];o.type!=="custom"&&(e[a]=o.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition()||this.sky&&this.sky.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 n=this._changed;if(n){const o=Object.keys(this._updatedLayers),c=Object.keys(this._removedLayers);(o.length||c.length)&&this._updateWorkerLayers(o,c);for(const m in this._updatedSources){const _=this._updatedSources[m];if(_==="reload")this._reloadSource(m);else{if(_!=="clear")throw new Error(`Invalid action ${_}`);this._clearSource(m)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const m in this._updatedPaintProps)this._layers[m].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const a={};for(const o in this.sourceCaches){const c=this.sourceCaches[o];a[o]=c.used,c.used=!1}for(const o of this._order){const c=this._layers[o];c.recalculate(e,this._availableImages),!c.isHidden(e.zoom)&&c.source&&(this.sourceCaches[c.source].used=!0)}for(const o in a){const c=this.sourceCaches[o];!!a[o]!=!!c.used&&c.fire(new p.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:o}))}this.light.recalculate(e),this.sky.recalculate(e),this.z=e.zoom,n&&this.fire(new p.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const n in this.sourceCaches)this.sourceCaches[n].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,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var a;this._checkLoaded();const o=this.serialize();if(e=n.transformStyle?n.transformStyle(o,e):e,((a=n.validate)===null||a===void 0||a)&&dr(this,p.u(e)))return!1;(e=p.aB(e)).layers=p.az(e.layers);const c=p.aC(o,e),m=this._getOperationsToPerform(c);if(m.unimplemented.length>0)throw new Error(`Unimplemented: ${m.unimplemented.join(", ")}.`);if(m.operations.length===0)return!1;for(const _ of m.operations)_();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const n=[],a=[];for(const o of e)switch(o.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":n.push(()=>this.addLayer.apply(this,o.args));break;case"removeLayer":n.push(()=>this.removeLayer.apply(this,o.args));break;case"setPaintProperty":n.push(()=>this.setPaintProperty.apply(this,o.args));break;case"setLayoutProperty":n.push(()=>this.setLayoutProperty.apply(this,o.args));break;case"setFilter":n.push(()=>this.setFilter.apply(this,o.args));break;case"addSource":n.push(()=>this.addSource.apply(this,o.args));break;case"removeSource":n.push(()=>this.removeSource.apply(this,o.args));break;case"setLayerZoomRange":n.push(()=>this.setLayerZoomRange.apply(this,o.args));break;case"setLight":n.push(()=>this.setLight.apply(this,o.args));break;case"setGeoJSONSourceData":n.push(()=>this.setGeoJSONSourceData.apply(this,o.args));break;case"setGlyphs":n.push(()=>this.setGlyphs.apply(this,o.args));break;case"setSprite":n.push(()=>this.setSprite.apply(this,o.args));break;case"setSky":n.push(()=>this.setSky.apply(this,o.args));break;case"setTerrain":n.push(()=>this.map.setTerrain.apply(this,o.args));break;case"setTransition":n.push(()=>{});break;default:a.push(o.command)}return{operations:n,unimplemented:a}}addImage(e,n){if(this.getImage(e))return this.fire(new p.j(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,n),this._afterImageUpdated(e)}updateImage(e,n){this.imageManager.updateImage(e,n)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new p.j(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 p.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,a={}){if(this._checkLoaded(),this.sourceCaches[e]!==void 0)throw new Error(`Source "${e}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(p.u.source,`sources.${e}`,n,null,a))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const o=this.sourceCaches[e]=new $e(e,n,this.dispatcher);o.style=this,o.setEventedParent(this,()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e})),o.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error("There is no source with this ID");for(const a in this._layers)if(this._layers[a].source===e)return this.fire(new p.j(new Error(`Source "${e}" cannot be removed while layer "${a}" is using it.`)));const n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new p.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,n){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error(`There is no source with this ID=${e}`);const a=this.sourceCaches[e].getSource();if(a.type!=="geojson")throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(n),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,n,a={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new p.j(new Error(`Layer "${o}" already exists on this map.`)));let c;if(e.type==="custom"){if(dr(this,p.aD(e)))return;c=p.aA(e)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(o,e.source),e=p.aB(e),e=p.e(e,{source:o})),this._validate(p.u.layer,`layers.${o}`,e,{arrayIndex:-1},a))return;c=p.aA(e),this._validateLayer(c),c.setEventedParent(this,{layer:{id:o}})}const m=n?this._order.indexOf(n):this._order.length;if(n&&m===-1)this.fire(new p.j(new Error(`Cannot add layer "${o}" before non-existing layer "${n}".`)));else{if(this._order.splice(m,0,o),this._layerOrderChanged=!0,this._layers[o]=c,this._removedLayers[o]&&c.source&&c.type!=="custom"){const _=this._removedLayers[o];delete this._removedLayers[o],_.type!==c.type?this._updatedSources[c.source]="clear":(this._updatedSources[c.source]="reload",this.sourceCaches[c.source].pause())}this._updateLayer(c),c.onAdd&&c.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new p.j(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;const a=this._order.indexOf(e);this._order.splice(a,1);const o=n?this._order.indexOf(n):this._order.length;n&&o===-1?this.fire(new p.j(new Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const n=this._layers[e];if(!n)return void this.fire(new p.j(new Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);const a=this._order.indexOf(e);this._order.splice(a,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,a){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===n&&o.maxzoom===a||(n!=null&&(o.minzoom=n),a!=null&&(o.maxzoom=a),this._updateLayer(o)):this.fire(new p.j(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,a={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!p.aE(o.filter,n))return n==null?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(p.u.filter,`layers.${o.id}.filter`,n,null,a)||(o.filter=p.aB(n),this._updateLayer(o)))}else this.fire(new p.j(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return p.aB(this.getLayer(e).filter)}setLayoutProperty(e,n,a,o={}){this._checkLoaded();const c=this.getLayer(e);c?p.aE(c.getLayoutProperty(n),a)||(c.setLayoutProperty(n,a,o),this._updateLayer(c)):this.fire(new p.j(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){const a=this.getLayer(e);if(a)return a.getLayoutProperty(n);this.fire(new p.j(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,a,o={}){this._checkLoaded();const c=this.getLayer(e);c?p.aE(c.getPaintProperty(n),a)||(c.setPaintProperty(n,a,o)&&this._updateLayer(c),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new p.j(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(e,n){return this.getLayer(e).getPaintProperty(n)}setFeatureState(e,n){this._checkLoaded();const a=e.source,o=e.sourceLayer,c=this.sourceCaches[a];if(c===void 0)return void this.fire(new p.j(new Error(`The source '${a}' does not exist in the map's style.`)));const m=c.getSource().type;m==="geojson"&&o?this.fire(new p.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):m!=="vector"||o?(e.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),c.setFeatureState(o,e.id,n)):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,n){this._checkLoaded();const a=e.source,o=this.sourceCaches[a];if(o===void 0)return void this.fire(new p.j(new Error(`The source '${a}' does not exist in the map's style.`)));const c=o.getSource().type,m=c==="vector"?e.sourceLayer:void 0;c!=="vector"||m?n&&typeof e.id!="string"&&typeof e.id!="number"?this.fire(new p.j(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(m,e.id,n):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const n=e.source,a=e.sourceLayer,o=this.sourceCaches[n];if(o!==void 0)return o.getSource().type!=="vector"||a?(e.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),o.getFeatureState(a,e.id)):void this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new p.j(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return p.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=p.aF(this.sourceCaches,c=>c.serialize()),n=this._serializeByIds(this._order,!0),a=this.map.getTerrain()||void 0,o=this.stylesheet;return p.aG({version:o.version,name:o.name,metadata:o.metadata,light:o.light,sky:o.sky,center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,sprite:o.sprite,glyphs:o.glyphs,transition:o.transition,sources:e,layers:n,terrain:a},c=>c!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.sourceCaches[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const n=m=>this._layers[m].type==="fill-extrusion",a={},o=[];for(let m=this._order.length-1;m>=0;m--){const _=this._order[m];if(n(_)){a[_]=m;for(const y of e){const b=y[_];if(b)for(const T of b)o.push(T)}}}o.sort((m,_)=>_.intersectionZ-m.intersectionZ);const c=[];for(let m=this._order.length-1;m>=0;m--){const _=this._order[m];if(n(_))for(let y=o.length-1;y>=0;y--){const b=o[y].feature;if(a[b.layer.id]{const _e=Z.featureSortOrder;if(_e){const Pe=_e.indexOf(ae.featureIndex);return _e.indexOf(fe.featureIndex)-Pe}return fe.featureIndex-ae.featureIndex});for(const ae of ee)Y.push(ae)}}for(const Z in B)B[Z].forEach(X=>{const F=X.feature,Y=b[_[Z].source].getFeatureState(F.layer["source-layer"],F.id);F.source=F.layer.source,F.layer["source-layer"]&&(F.sourceLayer=F.layer["source-layer"]),F.state=Y});return B}(this._layers,m,this.sourceCaches,e,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(e,n){n&&n.filter&&this._validate(p.u.filter,"querySourceFeatures.filter",n.filter,null,n);const a=this.sourceCaches[e];return a?function(o,c){const m=o.getRenderableIds().map(b=>o.getTileByID(b)),_=[],y={};for(let b=0;bk.getTileByID(D)).sort((D,B)=>B.tileID.overscaledZ-D.tileID.overscaledZ||(D.tileID.isLessThan(B.tileID)?-1:1))}const S=this.crossTileSymbolIndex.addLayer(T,y[T.source],e.center.lng);m=m||S}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((c=c||this._layerOrderChanged||a===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(de.now(),e.zoom))&&(this.pauseablePlacement=new _s(e,this.map.terrain,this._order,c,n,a,o,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,y),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(de.now()),_=!0),m&&this.pauseablePlacement.placement.setStale()),_||m)for(const b of this._order){const T=this._layers[b];T.type==="symbol"&&this.placement.updateLayerOpacities(T,y[T.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(de.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,n){return p._(this,void 0,void 0,function*(){const a=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const o=this.sourceCaches[n.source];return o&&o.setDependencies(n.tileID.key,n.type,n.icons),a})}getGlyphs(e,n){return p._(this,void 0,void 0,function*(){const a=yield this.glyphManager.getGlyphs(n.stacks),o=this.sourceCaches[n.source];return o&&o.setDependencies(n.tileID.key,n.type,[""]),a})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(p.u.glyphs,"glyphs",e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,n,a={},o){this._checkLoaded();const c=[{id:e,url:n}],m=[...ii(this.stylesheet.sprite),...c];this._validate(p.u.sprite,"sprite",m,null,a)||(this.stylesheet.sprite=m,this._loadSprite(c,!0,o))}removeSprite(e){this._checkLoaded();const n=ii(this.stylesheet.sprite);if(n.find(a=>a.id===e)){if(this._spritesImagesIds[e])for(const a of this._spritesImagesIds[e])this.imageManager.removeImage(a),this._changedImages[a]=!0;n.splice(n.findIndex(a=>a.id===e),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"}))}else this.fire(new p.j(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return ii(this.stylesheet.sprite)}setSprite(e,n={},a){this._checkLoaded(),e&&this._validate(p.u.sprite,"sprite",e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,a):(this._unloadSprite(),a&&a(null)))}}var fn=p.Y([{name:"a_pos",type:"Int16",components:2}]);const Qr={prelude:dt(`#ifdef GL_ES + */var Af=ec.exports,ud;function Cf(){return ud||(ud=1,function(J,j){(function(G,ne){J.exports=ne()})(Af,function(){var G={},ne={};function de(M,p,Je){if(ne[M]=Je,M==="index"){var Ge="var sharedModule = {}; ("+ne.shared+")(sharedModule); ("+ne.worker+")(sharedModule);",He={};return ne.shared(He),ne.index(G,He),typeof window<"u"&&G.setWorkerUrl(window.URL.createObjectURL(new Blob([Ge],{type:"text/javascript"}))),G}}de("shared",["exports"],function(M){function p(i,t,r,s){return new(r||(r=Promise))(function(l,u){function d(x){try{g(s.next(x))}catch(v){u(v)}}function f(x){try{g(s.throw(x))}catch(v){u(v)}}function g(x){var v;x.done?l(x.value):(v=x.value,v instanceof r?v:new r(function(w){w(v)})).then(d,f)}g((s=s.apply(i,t||[])).next())})}function Je(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var Ge=He;function He(i,t){this.x=i,this.y=t}He.prototype={clone:function(){return new He(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,t){return this.clone()._rotateAround(i,t)},matMult:function(i){return this.clone()._matMult(i)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var t=i.x-this.x,r=i.y-this.y;return t*t+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,t){return Math.atan2(this.x*t-this.y*i,this.x*i+this.y*t)},_matMult:function(i){var t=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=t,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var t=Math.cos(i),r=Math.sin(i),s=r*this.x+t*this.y;return this.x=t*this.x-r*this.y,this.y=s,this},_rotateAround:function(i,t){var r=Math.cos(i),s=Math.sin(i),l=t.y+s*(this.x-t.x)+r*(this.y-t.y);return this.x=t.x+r*(this.x-t.x)-s*(this.y-t.y),this.y=l,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},He.convert=function(i){return i instanceof He?i:Array.isArray(i)?new He(i[0],i[1]):i};var ue=Je(Ge),se=Ot;function Ot(i,t,r,s){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(s-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=t,this.p2x=r,this.p2y=s}Ot.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,t){if(t===void 0&&(t=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,s=0;s<8;s++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,t){return this.sampleCurveY(this.solveCurveX(i,t))}};var qt=Je(se);let kt,Ii;function Fi(){return kt==null&&(kt=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),kt}function Fr(){if(Ii==null&&(Ii=!1,Fi())){const t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let s=0;s<5*5;s++){const l=4*s;t.fillStyle=`rgb(${l},${l+1},${l+2})`,t.fillRect(s%5,Math.floor(s/5),1,1)}const r=t.getImageData(0,0,5,5).data;for(let s=0;s<5*5*4;s++)if(s%4!=3&&r[s]!==s){Ii=!0;break}}}return Ii||!1}function Mt(i,t,r,s){const l=new qt(i,t,r,s);return u=>l.solve(u)}const ln=Mt(.25,.1,.25,1);function mi(i,t,r){return Math.min(r,Math.max(t,i))}function Pi(i,t,r){const s=r-t,l=((i-t)%s+s)%s+t;return l===t?r:l}function gi(i,...t){for(const r of t)for(const s in r)i[s]=r[s];return i}let cn=1;function ii(i,t,r){const s={};for(const l in i)s[l]=t.call(this,i[l],l,i);return s}function Or(i,t,r){const s={};for(const l in i)t.call(this,i[l],l,i)&&(s[l]=i[l]);return s}function et(i){return Array.isArray(i)?i.map(et):typeof i=="object"&&i?ii(i,et):i}const hn={};function Gt(i){hn[i]||(typeof console<"u"&&console.warn(i),hn[i]=!0)}function Jt(i,t,r){return(r.y-i.y)*(t.x-i.x)>(t.y-i.y)*(r.x-i.x)}function Wi(i){return typeof WorkerGlobalScope<"u"&&i!==void 0&&i instanceof WorkerGlobalScope}let Oi=null;function _i(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}const un="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function ri(i,t,r,s,l){return p(this,void 0,void 0,function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const u=new VideoFrame(i,{timestamp:0});try{const d=u==null?void 0:u.format;if(!d||!d.startsWith("BGR")&&!d.startsWith("RGB"))throw new Error(`Unrecognized format ${d}`);const f=d.startsWith("BGR"),g=new Uint8ClampedArray(s*l*4);if(yield u.copyTo(g,function(x,v,w,I,C){const E=4*Math.max(-v,0),z=(Math.max(0,w)-w)*I*4+E,O=4*I,$=Math.max(0,v),re=Math.max(0,w);return{rect:{x:$,y:re,width:Math.min(x.width,v+I)-$,height:Math.min(x.height,w+C)-re},layout:[{offset:z,stride:O}]}}(i,t,r,s,l)),f)for(let x=0;xWi(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,Ir=function(i,t){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){const s=si(i.url);if(s)return s(i,t);if(Wi(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,targetMapId:Sr},t)}if(!(/^file:/.test(r=i.url)||/^file:/.test(Ai())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,l){return p(this,void 0,void 0,function*(){const u=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:Ai(),signal:l.signal});s.type!=="json"||u.headers.has("Accept")||u.headers.set("Accept","application/json");const d=yield fetch(u);if(!d.ok){const x=yield d.blob();throw new Yt(d.status,d.statusText,s.url,x)}let f;f=s.type==="arrayBuffer"||s.type==="image"?d.arrayBuffer():s.type==="json"?d.json():d.text();const g=yield f;if(l.signal.aborted)throw Vi();return{data:g,cacheControl:d.headers.get("Cache-Control"),expires:d.headers.get("Expires")}})}(i,t);if(Wi(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,mustQueue:!0,targetMapId:Sr},t)}var r;return function(s,l){return new Promise((u,d)=>{var f;const g=new XMLHttpRequest;g.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(g.responseType="arraybuffer");for(const x in s.headers)g.setRequestHeader(x,s.headers[x]);s.type==="json"&&(g.responseType="text",!((f=s.headers)===null||f===void 0)&&f.Accept||g.setRequestHeader("Accept","application/json")),g.withCredentials=s.credentials==="include",g.onerror=()=>{d(new Error(g.statusText))},g.onload=()=>{if(!l.signal.aborted)if((g.status>=200&&g.status<300||g.status===0)&&g.response!==null){let x=g.response;if(s.type==="json")try{x=JSON.parse(g.response)}catch(v){return void d(v)}u({data:x,cacheControl:g.getResponseHeader("Cache-Control"),expires:g.getResponseHeader("Expires")})}else{const x=new Blob([g.response],{type:g.getResponseHeader("Content-Type")});d(new Yt(g.status,g.statusText,s.url,x))}},l.signal.addEventListener("abort",()=>{g.abort(),d(Vi())}),g.send(s.body)})}(i,t)};function Vr(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;const t=new URL(i),r=window.location;return t.protocol===r.protocol&&t.host===r.host}function Xr(i,t,r){r[i]&&r[i].indexOf(t)!==-1||(r[i]=r[i]||[],r[i].push(t))}function Ki(i,t,r){if(r&&r[i]){const s=r[i].indexOf(t);s!==-1&&r[i].splice(s,1)}}class lr{constructor(t,r={}){gi(this,r),this.type=t}}class Wr extends lr{constructor(t,r={}){super("error",gi({error:t},r))}}class kn{on(t,r){return this._listeners=this._listeners||{},Xr(t,r,this._listeners),this}off(t,r){return Ki(t,r,this._listeners),Ki(t,r,this._oneTimeListeners),this}once(t,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},Xr(t,r,this._oneTimeListeners),this):new Promise(s=>this.once(t,s))}fire(t,r){typeof t=="string"&&(t=new lr(t,r||{}));const s=t.type;if(this.listens(s)){t.target=this;const l=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const f of l)f.call(this,t);const u=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const f of u)Ki(s,f,this._oneTimeListeners),f.call(this,t);const d=this._eventedParent;d&&(gi(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),d.fire(t))}else t instanceof Wr&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,r){return this._eventedParent=t,this._eventedParentData=r,this}}var le={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},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_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"}},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:"enum",default:"mercator",values:{mercator:{},globe:{}}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,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:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",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"}},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 dn=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ps(i,t){const r={};for(const s in i)s!=="ref"&&(r[s]=i[s]);return dn.forEach(s=>{s in t&&(r[s]=t[s])}),r}function ut(i,t){if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(let r=0;r`:i.itemType.kind==="value"?"array":`array<${t}>`}return i.kind}const R=[Jr,Te,Qe,$e,Ci,Ur,cr,A(We),Yr,Mr,U];function V(i,t){if(t.kind==="error")return null;if(i.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!V(i.itemType,t.itemType))&&(typeof i.N!="number"||i.N===t.N))return null}else{if(i.kind===t.kind)return null;if(i.kind==="value"){for(const r of R)if(!V(r,t))return null}}return`Expected ${P(i)} but found ${P(t)} instead.`}function K(i,t){return t.some(r=>r.kind===i.kind)}function Q(i,t){return t.some(r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i)}function ie(i,t){return i.kind==="array"&&t.kind==="array"?i.itemType.kind===t.itemType.kind&&typeof i.N=="number":i.kind===t.kind}const H=.96422,he=.82521,me=4/29,oe=6/29,ve=3*oe*oe,Ve=oe*oe*oe,Ne=Math.PI/180,ot=180/Math.PI;function Ke(i){return(i%=360)<0&&(i+=360),i}function lt([i,t,r,s]){let l,u;const d=Ut((.2225045*(i=rt(i))+.7168786*(t=rt(t))+.0606169*(r=rt(r)))/1);i===t&&t===r?l=u=d:(l=Ut((.4360747*i+.3850649*t+.1430804*r)/H),u=Ut((.0139322*i+.0971045*t+.7141733*r)/he));const f=116*d-16;return[f<0?0:f,500*(l-d),200*(d-u),s]}function rt(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function Ut(i){return i>Ve?Math.pow(i,1/3):i/ve+me}function zt([i,t,r,s]){let l=(i+16)/116,u=isNaN(t)?l:l+t/500,d=isNaN(r)?l:l-r/200;return l=1*ft(l),u=H*ft(u),d=he*ft(d),[tt(3.1338561*u-1.6168667*l-.4906146*d),tt(-.9787684*u+1.9161415*l+.033454*d),tt(.0719453*u-.2289914*l+1.4052427*d),s]}function tt(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function ft(i){return i>oe?i*i*i:ve*(i-me)}function Ct(i){return parseInt(i.padEnd(2,i),16)/255}function Ht(i,t){return Qt(t?i/100:i,0,1)}function Qt(i,t,r){return Math.min(Math.max(t,i),r)}function vi(i){return!i.some(Number.isNaN)}const zn={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]};class mt{constructor(t,r,s,l=1,u=!0){this.r=t,this.g=r,this.b=s,this.a=l,u||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[t,r,s,l]))}static parse(t){if(t instanceof mt)return t;if(typeof t!="string")return;const r=function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const l=zn[s];if(l){const[d,f,g]=l;return[d/255,f/255,g/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const d=s.length<6?1:2;let f=1;return[Ct(s.slice(f,f+=d)),Ct(s.slice(f,f+=d)),Ct(s.slice(f,f+=d)),Ct(s.slice(f,f+d)||"ff")]}if(s.startsWith("rgb")){const d=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){const[f,g,x,v,w,I,C,E,z,O,$,re]=d,W=[v||" ",C||" ",O].join("");if(W===" "||W===" /"||W===",,"||W===",,,"){const te=[x,I,z].join(""),ce=te==="%%%"?100:te===""?255:0;if(ce){const ge=[Qt(+g/ce,0,1),Qt(+w/ce,0,1),Qt(+E/ce,0,1),$?Ht(+$,re):1];if(vi(ge))return ge}}return}}const u=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(u){const[d,f,g,x,v,w,I,C,E]=u,z=[g||" ",v||" ",I].join("");if(z===" "||z===" /"||z===",,"||z===",,,"){const O=[+f,Qt(+x,0,100),Qt(+w,0,100),C?Ht(+C,E):1];if(vi(O))return function([$,re,W,te]){function ce(ge){const Me=(ge+$/30)%12,Ue=re*Math.min(W,1-W);return W-Ue*Math.max(-1,Math.min(Me-3,9-Me,1))}return $=Ke($),re/=100,W/=100,[ce(0),ce(8),ce(4),te]}(O)}}}(t);return r?new mt(...r,!1):void 0}get rgb(){const{r:t,g:r,b:s,a:l}=this,u=l||1/0;return this.overwriteGetter("rgb",[t/u,r/u,s/u,l])}get hcl(){return this.overwriteGetter("hcl",function(t){const[r,s,l,u]=lt(t),d=Math.sqrt(s*s+l*l);return[Math.round(1e4*d)?Ke(Math.atan2(l,s)*ot):NaN,d,r,u]}(this.rgb))}get lab(){return this.overwriteGetter("lab",lt(this.rgb))}overwriteGetter(t,r){return Object.defineProperty(this,t,{value:r}),r}toString(){const[t,r,s,l]=this.rgb;return`rgba(${[t,r,s].map(u=>Math.round(255*u)).join(",")},${l})`}}mt.black=new mt(0,0,0,1),mt.white=new mt(1,1,1,1),mt.transparent=new mt(0,0,0,0),mt.red=new mt(1,0,0,1);class Na{constructor(t,r,s){this.sensitivity=t?r?"variant":"case":r?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,r){return this.collator.compare(t,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Ua{constructor(t,r,s,l,u){this.text=t,this.image=r,this.scale=s,this.fontStack=l,this.textColor=u}}class Ni{constructor(t){this.sections=t}static fromString(t){return new Ni([new Ua(t,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof Ni?t:Ni.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}}class Ui{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Ui)return t;if(typeof t=="number")return new Ui([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const r of t)if(typeof r!="number")return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new Ui(t)}}toString(){return JSON.stringify(this.values)}}const rc=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Yi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Yi)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let r=0;r=0&&i<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof r=="number"&&r>=0&&r<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[i,t,r,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[i,t,r,s]:[i,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function pn(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof mt||i instanceof Na||i instanceof Ni||i instanceof Ui||i instanceof Yi||i instanceof ji)return!0;if(Array.isArray(i)){for(const t of i)if(!pn(t))return!1;return!0}if(typeof i=="object"){for(const t in i)if(!pn(i[t]))return!1;return!0}return!1}function jt(i){if(i===null)return Jr;if(typeof i=="string")return Qe;if(typeof i=="boolean")return $e;if(typeof i=="number")return Te;if(i instanceof mt)return Ci;if(i instanceof Na)return Cr;if(i instanceof Ni)return Ur;if(i instanceof Ui)return Yr;if(i instanceof Yi)return U;if(i instanceof ji)return Mr;if(Array.isArray(i)){const t=i.length;let r;for(const s of i){const l=jt(s);if(r){if(r===l)continue;r=We;break}r=l}return A(r||We,t)}return cr}function _s(i){const t=typeof i;return i===null?"":t==="string"||t==="number"||t==="boolean"?String(i):i instanceof mt||i instanceof Ni||i instanceof Ui||i instanceof Yi||i instanceof ji?i.toString():JSON.stringify(i)}class hr{constructor(t,r){this.type=t,this.value=r}static parse(t,r){if(t.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!pn(t[1]))return r.error("invalid value");const s=t[1];let l=jt(s);const u=r.expectedType;return l.kind!=="array"||l.N!==0||!u||u.kind!=="array"||typeof u.N=="number"&&u.N!==0||(l=u),new hr(l,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Vt{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const $s={string:Qe,number:Te,boolean:$e,object:cr};class ur{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s,l=1;const u=t[0];if(u==="array"){let f,g;if(t.length>2){const x=t[1];if(typeof x!="string"||!(x in $s)||x==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);f=$s[x],l++}else f=We;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return r.error('The length argument to "array" must be a positive integer literal',2);g=t[2],l++}s=A(f,g)}else{if(!$s[u])throw new Error(`Types doesn't contain name = ${u}`);s=$s[u]}const d=[];for(;lt.outputDefined())}}const ja={"to-boolean":$e,"to-color":Ci,"to-number":Te,"to-string":Qe};class dr{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");const s=t[0];if(!ja[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&t.length!==2)return r.error("Expected one argument.");const l=ja[s],u=[];for(let d=1;d4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:Dn(r[0],r[1],r[2],r[3]),!s))return new mt(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Vt(s||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const s of this.args){r=s.evaluate(t);const l=Ui.parse(r);if(l)return l}throw new Vt(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const s of this.args){r=s.evaluate(t);const l=Yi.parse(r);if(l)return l}throw new Vt(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const s of this.args){if(r=s.evaluate(t),r===null)return 0;const l=Number(r);if(!isNaN(l))return l}throw new Vt(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return Ni.fromString(_s(this.args[0].evaluate(t)));case"resolvedImage":return ji.fromString(_s(this.args[0].evaluate(t)));default:return _s(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const nc=["Unknown","Point","LineString","Polygon"];class qs{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?nc[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(t){let r=this._parseColorCache[t];return r||(r=this._parseColorCache[t]=mt.parse(t)),r}}class fn{constructor(t,r,s=[],l,u=new Ar,d=[]){this.registry=t,this.path=s,this.key=s.map(f=>`[${f}]`).join(""),this.scope=u,this.errors=d,this.expectedType=l,this._isConstant=r}parse(t,r,s,l,u={}){return r?this.concat(r,s,l)._parse(t,u):this._parse(t,u)}_parse(t,r){function s(l,u,d){return d==="assert"?new ur(u,[l]):d==="coerce"?new dr(u,[l]):l}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const l=t[0];if(typeof l!="string")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 u=this.registry[l];if(u){let d=u.parse(t,this);if(!d)return null;if(this.expectedType){const f=this.expectedType,g=d.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||g.kind!=="value")if(f.kind!=="color"&&f.kind!=="formatted"&&f.kind!=="resolvedImage"||g.kind!=="value"&&g.kind!=="string")if(f.kind!=="padding"||g.kind!=="value"&&g.kind!=="number"&&g.kind!=="array")if(f.kind!=="variableAnchorOffsetCollection"||g.kind!=="value"&&g.kind!=="array"){if(this.checkSubtype(f,g))return null}else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"assert")}if(!(d instanceof hr)&&d.type.kind!=="resolvedImage"&&this._isConstant(d)){const f=new qs;try{d=new hr(d.type,d.evaluate(f))}catch(g){return this.error(g.message),null}}return d}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(t===void 0?"'undefined' value invalid. Use null instead.":typeof t=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,r,s){const l=typeof t=="number"?this.path.concat(t):this.path,u=s?this.scope.concat(s):this.scope;return new fn(this.registry,this._isConstant,l,r||null,u,this.errors)}error(t,...r){const s=`${this.key}${r.map(l=>`[${l}]`).join("")}`;this.errors.push(new xi(s,t))}checkSubtype(t,r){const s=V(t,r);return s&&this.error(s),s}}class Qr{constructor(t,r){this.type=r.type,this.bindings=[].concat(t),this.result=r}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const r of this.bindings)t(r[1]);t(this.result)}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const s=[];for(let u=1;u=s.length)throw new Vt(`Array index out of bounds: ${r} > ${s.length-1}.`);if(r!==Math.floor(r))throw new Vt(`Array index must be an integer, but found ${r} instead.`);return s[r]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class qa{constructor(t,r){this.type=$e,this.needle=t,this.haystack=r}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const s=r.parse(t[1],1,We),l=r.parse(t[2],2,We);return s&&l?K(s.type,[$e,Qe,Te,Jr,We])?new qa(s,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`):null}evaluate(t){const r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!s)return!1;if(!Q(r,["boolean","string","number","null"]))throw new Vt(`Expected first argument to be of type boolean, string, number or null, but found ${P(jt(r))} instead.`);if(!Q(s,["string","array"]))throw new Vt(`Expected second argument to be of type array or string, but found ${P(jt(s))} instead.`);return s.indexOf(r)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class Ln{constructor(t,r,s){this.type=Te,this.needle=t,this.haystack=r,this.fromIndex=s}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=r.parse(t[1],1,We),l=r.parse(t[2],2,We);if(!s||!l)return null;if(!K(s.type,[$e,Qe,Te,Jr,We]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`);if(t.length===4){const u=r.parse(t[3],3,Te);return u?new Ln(s,l,u):null}return new Ln(s,l)}evaluate(t){const r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!Q(r,["boolean","string","number","null"]))throw new Vt(`Expected first argument to be of type boolean, string, number or null, but found ${P(jt(r))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(t)),Q(s,["string"])){const u=s.indexOf(r,l);return u===-1?-1:[...s.slice(0,u)].length}if(Q(s,["array"]))return s.indexOf(r,l);throw new Vt(`Expected second argument to be of type array or string, but found ${P(jt(s))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class Za{constructor(t,r,s,l,u,d){this.inputType=t,this.type=r,this.input=s,this.cases=l,this.outputs=u,this.otherwise=d}static parse(t,r){if(t.length<5)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return r.error("Expected an even number of arguments.");let s,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);const u={},d=[];for(let x=2;xNumber.MAX_SAFE_INTEGER)return I.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof E=="number"&&Math.floor(E)!==E)return I.error("Numeric branch labels must be integer values.");if(s){if(I.checkSubtype(s,jt(E)))return null}else s=jt(E);if(u[String(E)]!==void 0)return I.error("Branch labels must be unique.");u[String(E)]=d.length}const C=r.parse(w,x,l);if(!C)return null;l=l||C.type,d.push(C)}const f=r.parse(t[1],1,We);if(!f)return null;const g=r.parse(t[t.length-1],t.length-1,l);return g?f.type.kind!=="value"&&r.concat(1).checkSubtype(s,f.type)?null:new Za(s,l,f,u,d,g):null}evaluate(t){const r=this.input.evaluate(t);return(jt(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}}class Zs{constructor(t,r,s){this.type=t,this.branches=r,this.otherwise=s}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return r.error("Expected an odd number of arguments.");let s;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);const l=[];for(let d=1;dr.outputDefined())&&this.otherwise.outputDefined()}}class ys{constructor(t,r,s,l){this.type=t,this.input=r,this.beginIndex=s,this.endIndex=l}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=r.parse(t[1],1,We),l=r.parse(t[2],2,Te);if(!s||!l)return null;if(!K(s.type,[A(We),Qe,We]))return r.error(`Expected first argument to be of type array or string, but found ${P(s.type)} instead`);if(t.length===4){const u=r.parse(t[3],3,Te);return u?new ys(s.type,s,l,u):null}return new ys(s.type,s,l)}evaluate(t){const r=this.input.evaluate(t),s=this.beginIndex.evaluate(t);let l;if(this.endIndex&&(l=this.endIndex.evaluate(t)),Q(r,["string"]))return[...r].slice(s,l).join("");if(Q(r,["array"]))return r.slice(s,l);throw new Vt(`Expected first argument to be of type array or string, but found ${P(jt(r))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function Gs(i,t){const r=i.length-1;let s,l,u=0,d=r,f=0;for(;u<=d;)if(f=Math.floor((u+d)/2),s=i[f],l=i[f+1],s<=t){if(f===r||tt))throw new Vt("Input is not a number.");d=f-1}return 0}class Rn{constructor(t,r,s){this.type=t,this.input=r,this.labels=[],this.outputs=[];for(const[l,u]of s)this.labels.push(l),this.outputs.push(u)}static parse(t,r){if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");const s=r.parse(t[1],1,Te);if(!s)return null;const l=[];let u=null;r.expectedType&&r.expectedType.kind!=="value"&&(u=r.expectedType);for(let d=1;d=f)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',x);const w=r.parse(g,v,u);if(!w)return null;u=u||w.type,l.push([f,w])}return new Rn(u,s,l)}evaluate(t){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);const l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);const u=r.length;return l>=r[u-1]?s[u-1].evaluate(t):s[Gs(r,l)].evaluate(t)}eachChild(t){t(this.input);for(const r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function Yo(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var sc=Qo;function Qo(i,t,r,s){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(s-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=t,this.p2x=r,this.p2y=s}Qo.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,t){if(t===void 0&&(t=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,s=0;s<8;s++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,t){return this.sampleCurveY(this.solveCurveX(i,t))}};var ac=Yo(sc);function mn(i,t,r){return i+r*(t-i)}function xs(i,t,r){return i.map((s,l)=>mn(s,t[l],r))}const Mi={number:mn,color:function(i,t,r,s="rgb"){switch(s){case"rgb":{const[l,u,d,f]=xs(i.rgb,t.rgb,r);return new mt(l,u,d,f,!1)}case"hcl":{const[l,u,d,f]=i.hcl,[g,x,v,w]=t.hcl;let I,C;if(isNaN(l)||isNaN(g))isNaN(l)?isNaN(g)?I=NaN:(I=g,d!==1&&d!==0||(C=x)):(I=l,v!==1&&v!==0||(C=u));else{let re=g-l;g>l&&re>180?re-=360:g180&&(re+=360),I=l+r*re}const[E,z,O,$]=function([re,W,te,ce]){return re=isNaN(re)?0:re*Ne,zt([te,Math.cos(re)*W,Math.sin(re)*W,ce])}([I,C??mn(u,x,r),mn(d,v,r),mn(f,w,r)]);return new mt(E,z,O,$,!1)}case"lab":{const[l,u,d,f]=zt(xs(i.lab,t.lab,r));return new mt(l,u,d,f,!1)}}},array:xs,padding:function(i,t,r){return new Ui(xs(i.values,t.values,r))},variableAnchorOffsetCollection:function(i,t,r){const s=i.values,l=t.values;if(s.length!==l.length)throw new Vt(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${t.toString()}`);const u=[];for(let d=0;dtypeof v!="number"||v<0||v>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:x}}}if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(u=r.parse(u,2,Te),!u)return null;const f=[];let g=null;s==="interpolate-hcl"||s==="interpolate-lab"?g=Ci:r.expectedType&&r.expectedType.kind!=="value"&&(g=r.expectedType);for(let x=0;x=v)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',I);const E=r.parse(w,C,g);if(!E)return null;g=g||E.type,f.push([v,E])}return ie(g,Te)||ie(g,Ci)||ie(g,Yr)||ie(g,U)||ie(g,A(Te))?new ki(g,s,l,u,f):r.error(`Type ${P(g)} is not interpolatable.`)}evaluate(t){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);const l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);const u=r.length;if(l>=r[u-1])return s[u-1].evaluate(t);const d=Gs(r,l),f=ki.interpolationFactor(this.interpolation,l,r[d],r[d+1]),g=s[d].evaluate(t),x=s[d+1].evaluate(t);switch(this.operator){case"interpolate":return Mi[this.type.kind](g,x,f);case"interpolate-hcl":return Mi.color(g,x,f,"hcl");case"interpolate-lab":return Mi.color(g,x,f,"lab")}}eachChild(t){t(this.input);for(const r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function Hs(i,t,r,s){const l=s-r,u=i-r;return l===0?0:t===1?u/l:(Math.pow(t,u)-1)/(Math.pow(t,l)-1)}class Xs{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expectected at least one argument.");let s=null;const l=r.expectedType;l&&l.kind!=="value"&&(s=l);const u=[];for(const f of t.slice(1)){const g=r.parse(f,1+u.length,s,void 0,{typeAnnotation:"omit"});if(!g)return null;s=s||g.type,u.push(g)}if(!s)throw new Error("No output type");const d=l&&u.some(f=>V(l,f.type));return new Xs(d?We:s,u)}evaluate(t){let r,s=null,l=0;for(const u of this.args)if(l++,s=u.evaluate(t),s&&s instanceof ji&&!s.available&&(r||(r=s.name),s=null,l===this.args.length&&(s=r)),s!==null)break;return s}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}function Ws(i,t){return i==="=="||i==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function el(i,t,r,s){return s.compare(t,r)===0}function Bn(i,t,r){const s=i!=="=="&&i!=="!=";return class pd{constructor(u,d,f){this.type=$e,this.lhs=u,this.rhs=d,this.collator=f,this.hasUntypedArgument=u.type.kind==="value"||d.type.kind==="value"}static parse(u,d){if(u.length!==3&&u.length!==4)return d.error("Expected two or three arguments.");const f=u[0];let g=d.parse(u[1],1,We);if(!g)return null;if(!Ws(f,g.type))return d.concat(1).error(`"${f}" comparisons are not supported for type '${P(g.type)}'.`);let x=d.parse(u[2],2,We);if(!x)return null;if(!Ws(f,x.type))return d.concat(2).error(`"${f}" comparisons are not supported for type '${P(x.type)}'.`);if(g.type.kind!==x.type.kind&&g.type.kind!=="value"&&x.type.kind!=="value")return d.error(`Cannot compare types '${P(g.type)}' and '${P(x.type)}'.`);s&&(g.type.kind==="value"&&x.type.kind!=="value"?g=new ur(x.type,[g]):g.type.kind!=="value"&&x.type.kind==="value"&&(x=new ur(g.type,[x])));let v=null;if(u.length===4){if(g.type.kind!=="string"&&x.type.kind!=="string"&&g.type.kind!=="value"&&x.type.kind!=="value")return d.error("Cannot use collator to compare non-string types.");if(v=d.parse(u[3],3,Cr),!v)return null}return new pd(g,x,v)}evaluate(u){const d=this.lhs.evaluate(u),f=this.rhs.evaluate(u);if(s&&this.hasUntypedArgument){const g=jt(d),x=jt(f);if(g.kind!==x.kind||g.kind!=="string"&&g.kind!=="number")throw new Vt(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${g.kind}, ${x.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const g=jt(d),x=jt(f);if(g.kind!=="string"||x.kind!=="string")return t(u,d,f)}return this.collator?r(u,d,f,this.collator.evaluate(u)):t(u,d,f)}eachChild(u){u(this.lhs),u(this.rhs),this.collator&&u(this.collator)}outputDefined(){return!0}}}const oc=Bn("==",function(i,t,r){return t===r},el),tl=Bn("!=",function(i,t,r){return t!==r},function(i,t,r,s){return!el(0,t,r,s)}),il=Bn("<",function(i,t,r){return t",function(i,t,r){return t>r},function(i,t,r,s){return s.compare(t,r)>0}),cc=Bn("<=",function(i,t,r){return t<=r},function(i,t,r,s){return s.compare(t,r)<=0}),rl=Bn(">=",function(i,t,r){return t>=r},function(i,t,r,s){return s.compare(t,r)>=0});class vs{constructor(t,r,s){this.type=Cr,this.locale=s,this.caseSensitive=t,this.diacriticSensitive=r}static parse(t,r){if(t.length!==2)return r.error("Expected one argument.");const s=t[1];if(typeof s!="object"||Array.isArray(s))return r.error("Collator options argument must be an object.");const l=r.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,$e);if(!l)return null;const u=r.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,$e);if(!u)return null;let d=null;return s.locale&&(d=r.parse(s.locale,1,Qe),!d)?null:new vs(l,u,d)}evaluate(t){return new Na(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class Ga{constructor(t,r,s,l,u){this.type=Qe,this.number=t,this.locale=r,this.currency=s,this.minFractionDigits=l,this.maxFractionDigits=u}static parse(t,r){if(t.length!==3)return r.error("Expected two arguments.");const s=r.parse(t[1],1,Te);if(!s)return null;const l=t[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let u=null;if(l.locale&&(u=r.parse(l.locale,1,Qe),!u))return null;let d=null;if(l.currency&&(d=r.parse(l.currency,1,Qe),!d))return null;let f=null;if(l["min-fraction-digits"]&&(f=r.parse(l["min-fraction-digits"],1,Te),!f))return null;let g=null;return l["max-fraction-digits"]&&(g=r.parse(l["max-fraction-digits"],1,Te),!g)?null:new Ga(s,u,d,f,g)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class Ks{constructor(t){this.type=Ur,this.sections=t}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");const s=t[1];if(!Array.isArray(s)&&typeof s=="object")return r.error("First argument must be an image or text section.");const l=[];let u=!1;for(let d=1;d<=t.length-1;++d){const f=t[d];if(u&&typeof f=="object"&&!Array.isArray(f)){u=!1;let g=null;if(f["font-scale"]&&(g=r.parse(f["font-scale"],1,Te),!g))return null;let x=null;if(f["text-font"]&&(x=r.parse(f["text-font"],1,A(Qe)),!x))return null;let v=null;if(f["text-color"]&&(v=r.parse(f["text-color"],1,Ci),!v))return null;const w=l[l.length-1];w.scale=g,w.font=x,w.textColor=v}else{const g=r.parse(t[d],1,We);if(!g)return null;const x=g.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");u=!0,l.push({content:g,scale:null,font:null,textColor:null})}}return new Ks(l)}evaluate(t){return new Ni(this.sections.map(r=>{const s=r.content.evaluate(t);return jt(s)===Mr?new Ua("",s,null,null,null):new Ua(_s(s),null,r.scale?r.scale.evaluate(t):null,r.font?r.font.evaluate(t).join(","):null,r.textColor?r.textColor.evaluate(t):null)}))}eachChild(t){for(const r of this.sections)t(r.content),r.scale&&t(r.scale),r.font&&t(r.font),r.textColor&&t(r.textColor)}outputDefined(){return!1}}class Ha{constructor(t){this.type=Mr,this.input=t}static parse(t,r){if(t.length!==2)return r.error("Expected two arguments.");const s=r.parse(t[1],1,Qe);return s?new Ha(s):r.error("No image name provided.")}evaluate(t){const r=this.input.evaluate(t),s=ji.fromString(r);return s&&t.availableImages&&(s.available=t.availableImages.indexOf(r)>-1),s}eachChild(t){t(this.input)}outputDefined(){return!1}}class Xa{constructor(t){this.type=Te,this.input=t}static parse(t,r){if(t.length!==2)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);const s=r.parse(t[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${P(s.type)} instead.`):new Xa(s):null}evaluate(t){const r=this.input.evaluate(t);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new Vt(`Expected value to be of type string or array, but found ${P(jt(r))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const kr=8192;function hc(i,t){const r=(180+i[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,l=Math.pow(2,t.z);return[Math.round(r*l*kr),Math.round(s*l*kr)]}function Wa(i,t){const r=Math.pow(2,t.z);return[(l=(i[0]/kr+t.x)/r,360*l-180),(s=(i[1]/kr+t.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,l}function gn(i,t){i[0]=Math.min(i[0],t[0]),i[1]=Math.min(i[1],t[1]),i[2]=Math.max(i[2],t[0]),i[3]=Math.max(i[3],t[1])}function en(i,t){return!(i[0]<=t[0]||i[2]>=t[2]||i[1]<=t[1]||i[3]>=t[3])}function pt(i,t,r){const s=i[0]-t[0],l=i[1]-t[1],u=i[0]-r[0],d=i[1]-r[1];return s*d-u*l==0&&s*u<=0&&l*d<=0}function Js(i,t,r,s){return(l=[s[0]-r[0],s[1]-r[1]])[0]*(u=[t[0]-i[0],t[1]-i[1]])[1]-l[1]*u[0]!=0&&!(!sl(i,t,r,s)||!sl(r,s,i,t));var l,u}function uc(i,t,r){for(const s of r)for(let l=0;l(l=i)[1]!=(d=f[g+1])[1]>l[1]&&l[0]<(d[0]-u[0])*(l[1]-u[1])/(d[1]-u[1])+u[0]&&(s=!s)}var l,u,d;return s}function dc(i,t){for(const r of t)if(Fn(i,r))return!0;return!1}function nl(i,t){for(const r of i)if(!Fn(r,t))return!1;for(let r=0;r0&&f<0||d<0&&f>0}function Ka(i,t,r){const s=[];for(let l=0;lr[2]){const l=.5*s;let u=i[0]-r[0]>l?-s:r[0]-i[0]>l?s:0;u===0&&(u=i[0]-r[2]>l?-s:r[2]-i[0]>l?s:0),i[0]+=u}gn(t,i)}function ll(i,t,r,s){const l=Math.pow(2,s.z)*kr,u=[s.x*kr,s.y*kr],d=[];for(const f of i)for(const g of f){const x=[g.x+u[0],g.y+u[1]];ol(x,t,r,l),d.push(x)}return d}function cl(i,t,r,s){const l=Math.pow(2,s.z)*kr,u=[s.x*kr,s.y*kr],d=[];for(const g of i){const x=[];for(const v of g){const w=[v.x+u[0],v.y+u[1]];gn(t,w),x.push(w)}d.push(x)}if(t[2]-t[0]<=l/2){(f=t)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const g of d)for(const x of g)ol(x,t,r,l)}var f;return d}class _n{constructor(t,r){this.type=$e,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(pn(t[1])){const s=t[1];if(s.type==="FeatureCollection"){const l=[];for(const u of s.features){const{type:d,coordinates:f}=u.geometry;d==="Polygon"&&l.push(f),d==="MultiPolygon"&&l.push(...f)}if(l.length)return new _n(s,{type:"MultiPolygon",coordinates:l})}else if(s.type==="Feature"){const l=s.geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new _n(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new _n(s,s)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(r,s){const l=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(s.type==="Polygon"){const f=Ka(s.coordinates,u,d),g=ll(r.geometry(),l,u,d);if(!en(l,u))return!1;for(const x of g)if(!Fn(x,f))return!1}if(s.type==="MultiPolygon"){const f=al(s.coordinates,u,d),g=ll(r.geometry(),l,u,d);if(!en(l,u))return!1;for(const x of g)if(!dc(x,f))return!1}return!0}(t,this.geometries);if(t.geometryType()==="LineString")return function(r,s){const l=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(s.type==="Polygon"){const f=Ka(s.coordinates,u,d),g=cl(r.geometry(),l,u,d);if(!en(l,u))return!1;for(const x of g)if(!nl(x,f))return!1}if(s.type==="MultiPolygon"){const f=al(s.coordinates,u,d),g=cl(r.geometry(),l,u,d);if(!en(l,u))return!1;for(const x of g)if(!pc(x,f))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let hl=class{constructor(i=[],t=(r,s)=>rs?1:0){if(this.data=i,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(i){this.data.push(i),this._up(this.length++)}pop(){if(this.length===0)return;const i=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:t,compare:r}=this,s=t[i];for(;i>0;){const l=i-1>>1,u=t[l];if(r(s,u)>=0)break;t[i]=u,i=l}t[i]=s}_down(i){const{data:t,compare:r}=this,s=this.length>>1,l=t[i];for(;i=0)break;t[i]=t[u],i=u}t[i]=l}};function fc(i,t,r,s,l){ul(i,t,r,s||i.length-1,l||mc)}function ul(i,t,r,s,l){for(;s>r;){if(s-r>600){var u=s-r+1,d=t-r+1,f=Math.log(u),g=.5*Math.exp(2*f/3),x=.5*Math.sqrt(f*g*(u-g)/u)*(d-u/2<0?-1:1);ul(i,t,Math.max(r,Math.floor(t-d*g/u+x)),Math.min(s,Math.floor(t+(u-d)*g/u+x)),l)}var v=i[t],w=r,I=s;for(bs(i,r,t),l(i[s],v)>0&&bs(i,r,s);w0;)I--}l(i[r],v)===0?bs(i,r,I):bs(i,++I,s),I<=t&&(r=I+1),t<=I&&(s=I-1)}}function bs(i,t,r){var s=i[t];i[t]=i[r],i[r]=s}function mc(i,t){return it?1:0}function Ys(i,t){if(i.length<=1)return[i];const r=[];let s,l;for(const u of i){const d=_c(u);d!==0&&(u.area=Math.abs(d),l===void 0&&(l=d<0),l===d<0?(s&&r.push(s),s=[u]):s.push(u))}if(s&&r.push(s),t>1)for(let u=0;u1?(x=t[g+1][0],v=t[g+1][1]):C>0&&(x+=w/this.kx*C,v+=I/this.ky*C)),w=this.wrap(r[0]-x)*this.kx,I=(r[1]-v)*this.ky;const E=w*w+I*I;E180;)t-=360;return t}}function ml(i,t){return t[0]-i[0]}function Qs(i){return i[1]-i[0]+1}function jr(i,t){return i[1]>=i[0]&&i[1]i[1])return[null,null];const r=Qs(i);if(t){if(r===2)return[i,null];const l=Math.floor(r/2);return[[i[0],i[0]+l],[i[0]+l,i[1]]]}if(r===1)return[i,null];const s=Math.floor(r/2)-1;return[[i[0],i[0]+s],[i[0]+s+1,i[1]]]}function Qa(i,t){if(!jr(t,i.length))return[1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let s=t[0];s<=t[1];++s)gn(r,i[s]);return r}function eo(i){const t=[1/0,1/0,-1/0,-1/0];for(const r of i)for(const s of r)gn(t,s);return t}function ea(i){return i[0]!==-1/0&&i[1]!==-1/0&&i[2]!==1/0&&i[3]!==1/0}function to(i,t,r){if(!ea(i)||!ea(t))return NaN;let s=0,l=0;return i[2]t[2]&&(s=i[0]-t[2]),i[1]>t[3]&&(l=i[1]-t[3]),i[3]=s)return s;if(en(l,u)){if(ta(i,t))return 0}else if(ta(t,i))return 0;let d=1/0;for(const f of i)for(let g=0,x=f.length,v=x-1;g0;){const g=d.pop();if(g[0]>=u)continue;const x=g[1],v=t?50:100;if(Qs(x)<=v){if(!jr(x,i.length))return NaN;if(t){const w=it(i,x,r,s);if(isNaN(w)||w===0)return w;u=Math.min(u,w)}else for(let w=x[0];w<=x[1];++w){const I=xc(i[w],r,s);if(u=Math.min(u,I),u===0)return 0}}else{const w=Ya(x,t);gt(d,u,s,i,f,w[0]),gt(d,u,s,i,f,w[1])}}return u}function Ts(i,t,r,s,l,u=1/0){let d=Math.min(u,l.distance(i[0],r[0]));if(d===0)return d;const f=new hl([[0,[0,i.length-1],[0,r.length-1]]],ml);for(;f.length>0;){const g=f.pop();if(g[0]>=d)continue;const x=g[1],v=g[2],w=t?50:100,I=s?50:100;if(Qs(x)<=w&&Qs(v)<=I){if(!jr(x,i.length)&&jr(v,r.length))return NaN;let C;if(t&&s)C=yc(i,x,r,v,l),d=Math.min(d,C);else if(t&&!s){const E=i.slice(x[0],x[1]+1);for(let z=v[0];z<=v[1];++z)if(C=yn(r[z],E,l),d=Math.min(d,C),d===0)return d}else if(!t&&s){const E=r.slice(v[0],v[1]+1);for(let z=x[0];z<=x[1];++z)if(C=yn(i[z],E,l),d=Math.min(d,C),d===0)return d}else C=Rt(i,x,r,v,l),d=Math.min(d,C)}else{const C=Ya(x,t),E=Ya(v,s);xn(f,d,l,i,r,C[0],E[0]),xn(f,d,l,i,r,C[0],E[1]),xn(f,d,l,i,r,C[1],E[0]),xn(f,d,l,i,r,C[1],E[1])}}return d}function ro(i){return i.type==="MultiPolygon"?i.coordinates.map(t=>({type:"Polygon",coordinates:t})):i.type==="MultiLineString"?i.coordinates.map(t=>({type:"LineString",coordinates:t})):i.type==="MultiPoint"?i.coordinates.map(t=>({type:"Point",coordinates:t})):[i]}class vn{constructor(t,r){this.type=Te,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(pn(t[1])){const s=t[1];if(s.type==="FeatureCollection")return new vn(s,s.features.map(l=>ro(l.geometry)).flat());if(s.type==="Feature")return new vn(s,ro(s.geometry));if("type"in s&&"coordinates"in s)return new vn(s,ro(s))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(r,s){const l=r.geometry(),u=l.flat().map(g=>Wa([g.x,g.y],r.canonical));if(l.length===0)return NaN;const d=new Ja(u[0][1]);let f=1/0;for(const g of s){switch(g.type){case"Point":f=Math.min(f,Ts(u,!1,[g.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,Ts(u,!1,g.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,ws(u,!1,g.coordinates,d,f))}if(f===0)return f}return f}(t,this.geometries);if(t.geometryType()==="LineString")return function(r,s){const l=r.geometry(),u=l.flat().map(g=>Wa([g.x,g.y],r.canonical));if(l.length===0)return NaN;const d=new Ja(u[0][1]);let f=1/0;for(const g of s){switch(g.type){case"Point":f=Math.min(f,Ts(u,!0,[g.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,Ts(u,!0,g.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,ws(u,!0,g.coordinates,d,f))}if(f===0)return f}return f}(t,this.geometries);if(t.geometryType()==="Polygon")return function(r,s){const l=r.geometry();if(l.length===0||l[0].length===0)return NaN;const u=Ys(l,0).map(g=>g.map(x=>x.map(v=>Wa([v.x,v.y],r.canonical)))),d=new Ja(u[0][0][0][1]);let f=1/0;for(const g of s)for(const x of u){switch(g.type){case"Point":f=Math.min(f,ws([g.coordinates],!1,x,d,f));break;case"LineString":f=Math.min(f,ws(g.coordinates,!0,x,d,f));break;case"Polygon":f=Math.min(f,vt(x,g.coordinates,d,f))}if(f===0)return f}return f}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const On={"==":oc,"!=":tl,">":lc,"<":il,">=":rl,"<=":cc,array:ur,at:$a,boolean:ur,case:Zs,coalesce:Xs,collator:vs,format:Ks,image:Ha,in:qa,"index-of":Ln,interpolate:ki,"interpolate-hcl":ki,"interpolate-lab":ki,length:Xa,let:Qr,literal:hr,match:Za,number:ur,"number-format":Ga,object:ur,slice:ys,step:Rn,string:ur,"to-boolean":dr,"to-color":dr,"to-number":dr,"to-string":dr,var:dt,within:_n,distance:vn};class Qi{constructor(t,r,s,l){this.name=t,this.type=r,this._evaluate=s,this.args=l}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,r){const s=t[0],l=Qi.definitions[s];if(!l)return r.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const u=Array.isArray(l)?l[0]:l.type,d=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,f=d.filter(([x])=>!Array.isArray(x)||x.length===t.length-1);let g=null;for(const[x,v]of f){g=new fn(r.registry,Ss,r.path,null,r.scope);const w=[];let I=!1;for(let C=1;C{return I=w,Array.isArray(I)?`(${I.map(P).join(", ")})`:`(${P(I.type)}...)`;var I}).join(" | "),v=[];for(let w=1;w{r=t?r&&Ss(s):r&&s instanceof hr}),!!r&&Is(i)&&Ps(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Is(i){if(i instanceof Qi&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof _n||i instanceof vn)return!1;let t=!0;return i.eachChild(r=>{t&&!Is(r)&&(t=!1)}),t}function Vn(i){if(i instanceof Qi&&i.name==="feature-state")return!1;let t=!0;return i.eachChild(r=>{t&&!Vn(r)&&(t=!1)}),t}function Ps(i,t){if(i instanceof Qi&&t.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild(s=>{r&&!Ps(s,t)&&(r=!1)}),r}function ia(i){return{result:"success",value:i}}function Nn(i){return{result:"error",value:i}}function Un(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function gl(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function oo(i){return!!i.expression&&i.expression.interpolated}function ct(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function ra(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function vc(i){return i}function _l(i,t){const r=t.type==="color",s=i.stops&&typeof i.stops[0][0]=="object",l=s||!(s||i.property!==void 0),u=i.type||(oo(t)?"exponential":"interval");if(r||t.type==="padding"){const v=r?mt.parse:Ui.parse;(i=Pr({},i)).stops&&(i.stops=i.stops.map(w=>[w[0],v(w[1])])),i.default=v(i.default?i.default:t.default)}if(i.colorSpace&&(d=i.colorSpace)!=="rgb"&&d!=="hcl"&&d!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var d;let f,g,x;if(u==="exponential")f=xl;else if(u==="interval")f=na;else if(u==="categorical"){f=yl,g=Object.create(null);for(const v of i.stops)g[v[0]]=v[1];x=typeof i.stops[0][0]}else{if(u!=="identity")throw new Error(`Unknown function type "${u}"`);f=vl}if(s){const v={},w=[];for(let E=0;EE[0]),evaluate:({zoom:E},z)=>xl({stops:I,base:i.base},t,E).evaluate(E,z)}}if(l){const v=u==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:ki.interpolationFactor.bind(void 0,v),zoomStops:i.stops.map(w=>w[0]),evaluate:({zoom:w})=>f(i,t,w,g,x)}}return{kind:"source",evaluate(v,w){const I=w&&w.properties?w.properties[i.property]:void 0;return I===void 0?jn(i.default,t.default):f(i,t,I,g,x)}}}function jn(i,t,r){return i!==void 0?i:t!==void 0?t:r!==void 0?r:void 0}function yl(i,t,r,s,l){return jn(typeof r===l?s[r]:void 0,i.default,t.default)}function na(i,t,r){if(ct(r)!=="number")return jn(i.default,t.default);const s=i.stops.length;if(s===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[s-1][0])return i.stops[s-1][1];const l=Gs(i.stops.map(u=>u[0]),r);return i.stops[l][1]}function xl(i,t,r){const s=i.base!==void 0?i.base:1;if(ct(r)!=="number")return jn(i.default,t.default);const l=i.stops.length;if(l===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[l-1][0])return i.stops[l-1][1];const u=Gs(i.stops.map(v=>v[0]),r),d=function(v,w,I,C){const E=C-I,z=v-I;return E===0?0:w===1?z/E:(Math.pow(w,z)-1)/(Math.pow(w,E)-1)}(r,s,i.stops[u][0],i.stops[u+1][0]),f=i.stops[u][1],g=i.stops[u+1][1],x=Mi[t.type]||vc;return typeof f.evaluate=="function"?{evaluate(...v){const w=f.evaluate.apply(void 0,v),I=g.evaluate.apply(void 0,v);if(w!==void 0&&I!==void 0)return x(w,I,d,i.colorSpace)}}:x(f,g,d,i.colorSpace)}function vl(i,t,r){switch(t.type){case"color":r=mt.parse(r);break;case"formatted":r=Ni.fromString(r.toString());break;case"resolvedImage":r=ji.fromString(r.toString());break;case"padding":r=Ui.parse(r);break;default:ct(r)===t.type||t.type==="enum"&&t.values[r]||(r=void 0)}return jn(r,i.default,t.default)}Qi.register(On,{error:[{kind:"error"},[Qe],(i,[t])=>{throw new Vt(t.evaluate(i))}],typeof:[Qe,[We],(i,[t])=>P(jt(t.evaluate(i)))],"to-rgba":[A(Te,4),[Ci],(i,[t])=>{const[r,s,l,u]=t.evaluate(i).rgb;return[255*r,255*s,255*l,u]}],rgb:[Ci,[Te,Te,Te],no],rgba:[Ci,[Te,Te,Te,Te],no],has:{type:$e,overloads:[[[Qe],(i,[t])=>so(t.evaluate(i),i.properties())],[[Qe,cr],(i,[t,r])=>so(t.evaluate(i),r.evaluate(i))]]},get:{type:We,overloads:[[[Qe],(i,[t])=>ao(t.evaluate(i),i.properties())],[[Qe,cr],(i,[t,r])=>ao(t.evaluate(i),r.evaluate(i))]]},"feature-state":[We,[Qe],(i,[t])=>ao(t.evaluate(i),i.featureState||{})],properties:[cr,[],i=>i.properties()],"geometry-type":[Qe,[],i=>i.geometryType()],id:[We,[],i=>i.id()],zoom:[Te,[],i=>i.globals.zoom],"heatmap-density":[Te,[],i=>i.globals.heatmapDensity||0],"line-progress":[Te,[],i=>i.globals.lineProgress||0],accumulated:[We,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[Te,bn(Te),(i,t)=>{let r=0;for(const s of t)r+=s.evaluate(i);return r}],"*":[Te,bn(Te),(i,t)=>{let r=1;for(const s of t)r*=s.evaluate(i);return r}],"-":{type:Te,overloads:[[[Te,Te],(i,[t,r])=>t.evaluate(i)-r.evaluate(i)],[[Te],(i,[t])=>-t.evaluate(i)]]},"/":[Te,[Te,Te],(i,[t,r])=>t.evaluate(i)/r.evaluate(i)],"%":[Te,[Te,Te],(i,[t,r])=>t.evaluate(i)%r.evaluate(i)],ln2:[Te,[],()=>Math.LN2],pi:[Te,[],()=>Math.PI],e:[Te,[],()=>Math.E],"^":[Te,[Te,Te],(i,[t,r])=>Math.pow(t.evaluate(i),r.evaluate(i))],sqrt:[Te,[Te],(i,[t])=>Math.sqrt(t.evaluate(i))],log10:[Te,[Te],(i,[t])=>Math.log(t.evaluate(i))/Math.LN10],ln:[Te,[Te],(i,[t])=>Math.log(t.evaluate(i))],log2:[Te,[Te],(i,[t])=>Math.log(t.evaluate(i))/Math.LN2],sin:[Te,[Te],(i,[t])=>Math.sin(t.evaluate(i))],cos:[Te,[Te],(i,[t])=>Math.cos(t.evaluate(i))],tan:[Te,[Te],(i,[t])=>Math.tan(t.evaluate(i))],asin:[Te,[Te],(i,[t])=>Math.asin(t.evaluate(i))],acos:[Te,[Te],(i,[t])=>Math.acos(t.evaluate(i))],atan:[Te,[Te],(i,[t])=>Math.atan(t.evaluate(i))],min:[Te,bn(Te),(i,t)=>Math.min(...t.map(r=>r.evaluate(i)))],max:[Te,bn(Te),(i,t)=>Math.max(...t.map(r=>r.evaluate(i)))],abs:[Te,[Te],(i,[t])=>Math.abs(t.evaluate(i))],round:[Te,[Te],(i,[t])=>{const r=t.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[Te,[Te],(i,[t])=>Math.floor(t.evaluate(i))],ceil:[Te,[Te],(i,[t])=>Math.ceil(t.evaluate(i))],"filter-==":[$e,[Qe,We],(i,[t,r])=>i.properties()[t.value]===r.value],"filter-id-==":[$e,[We],(i,[t])=>i.id()===t.value],"filter-type-==":[$e,[Qe],(i,[t])=>i.geometryType()===t.value],"filter-<":[$e,[Qe,We],(i,[t,r])=>{const s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s{const r=i.id(),s=t.value;return typeof r==typeof s&&r":[$e,[Qe,We],(i,[t,r])=>{const s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s>l}],"filter-id->":[$e,[We],(i,[t])=>{const r=i.id(),s=t.value;return typeof r==typeof s&&r>s}],"filter-<=":[$e,[Qe,We],(i,[t,r])=>{const s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s<=l}],"filter-id-<=":[$e,[We],(i,[t])=>{const r=i.id(),s=t.value;return typeof r==typeof s&&r<=s}],"filter->=":[$e,[Qe,We],(i,[t,r])=>{const s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s>=l}],"filter-id->=":[$e,[We],(i,[t])=>{const r=i.id(),s=t.value;return typeof r==typeof s&&r>=s}],"filter-has":[$e,[We],(i,[t])=>t.value in i.properties()],"filter-has-id":[$e,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[$e,[A(Qe)],(i,[t])=>t.value.indexOf(i.geometryType())>=0],"filter-id-in":[$e,[A(We)],(i,[t])=>t.value.indexOf(i.id())>=0],"filter-in-small":[$e,[Qe,A(We)],(i,[t,r])=>r.value.indexOf(i.properties()[t.value])>=0],"filter-in-large":[$e,[Qe,A(We)],(i,[t,r])=>function(s,l,u,d){for(;u<=d;){const f=u+d>>1;if(l[f]===s)return!0;l[f]>s?d=f-1:u=f+1}return!1}(i.properties()[t.value],r.value,0,r.value.length-1)],all:{type:$e,overloads:[[[$e,$e],(i,[t,r])=>t.evaluate(i)&&r.evaluate(i)],[bn($e),(i,t)=>{for(const r of t)if(!r.evaluate(i))return!1;return!0}]]},any:{type:$e,overloads:[[[$e,$e],(i,[t,r])=>t.evaluate(i)||r.evaluate(i)],[bn($e),(i,t)=>{for(const r of t)if(r.evaluate(i))return!0;return!1}]]},"!":[$e,[$e],(i,[t])=>!t.evaluate(i)],"is-supported-script":[$e,[Qe],(i,[t])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(t.evaluate(i))}],upcase:[Qe,[Qe],(i,[t])=>t.evaluate(i).toUpperCase()],downcase:[Qe,[Qe],(i,[t])=>t.evaluate(i).toLowerCase()],concat:[Qe,bn(We),(i,t)=>t.map(r=>_s(r.evaluate(i))).join("")],"resolved-locale":[Qe,[Cr],(i,[t])=>t.evaluate(i).resolvedLocale()]});class sa{constructor(t,r){var s;this.expression=t,this._warningHistory={},this._evaluator=new qs,this._defaultValue=r?(s=r).type==="color"&&ra(s.default)?new mt(0,0,0,0):s.type==="color"?mt.parse(s.default)||null:s.type==="padding"?Ui.parse(s.default)||null:s.type==="variableAnchorOffsetCollection"?Yi.parse(s.default)||null:s.default===void 0?null:s.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._evaluator.globals=t,this._evaluator.feature=r,this._evaluator.featureState=s,this._evaluator.canonical=l,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=d,this.expression.evaluate(this._evaluator)}evaluate(t,r,s,l,u,d){this._evaluator.globals=t,this._evaluator.feature=r||null,this._evaluator.featureState=s||null,this._evaluator.canonical=l,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=d||null;try{const f=this.expression.evaluate(this._evaluator);if(f==null||typeof f=="number"&&f!=f)return this._defaultValue;if(this._enumValues&&!(f in this._enumValues))throw new Vt(`Expected value to be one of ${Object.keys(this._enumValues).map(g=>JSON.stringify(g)).join(", ")}, but found ${JSON.stringify(f)} instead.`);return f}catch(f){return this._warningHistory[f.message]||(this._warningHistory[f.message]=!0,typeof console<"u"&&console.warn(f.message)),this._defaultValue}}}function aa(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in On}function $n(i,t){const r=new fn(On,Ss,[],t?function(l){const u={color:Ci,string:Qe,number:Te,enum:Qe,boolean:$e,formatted:Ur,padding:Yr,resolvedImage:Mr,variableAnchorOffsetCollection:U};return l.type==="array"?A(u[l.value]||We,l.length):u[l.type]}(t):void 0),s=r.parse(i,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return s?ia(new sa(s,t)):Nn(r.errors)}class qn{constructor(t,r){this.kind=t,this._styleExpression=r,this.isStateDependent=t!=="constant"&&!Vn(r.expression)}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,u,d)}evaluate(t,r,s,l,u,d){return this._styleExpression.evaluate(t,r,s,l,u,d)}}class Zn{constructor(t,r,s,l){this.kind=t,this.zoomStops=s,this._styleExpression=r,this.isStateDependent=t!=="camera"&&!Vn(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,u,d)}evaluate(t,r,s,l,u,d){return this._styleExpression.evaluate(t,r,s,l,u,d)}interpolationFactor(t,r,s){return this.interpolationType?ki.interpolationFactor(this.interpolationType,t,r,s):0}}function lo(i,t){const r=$n(i,t);if(r.result==="error")return r;const s=r.value.expression,l=Is(s);if(!l&&!Un(t))return Nn([new xi("","data expressions not supported")]);const u=Ps(s,["zoom"]);if(!u&&!gl(t))return Nn([new xi("","zoom expressions not supported")]);const d=As(s);return d||u?d instanceof xi?Nn([d]):d instanceof ki&&!oo(t)?Nn([new xi("",'"interpolate" expressions cannot be used with this property')]):ia(d?new Zn(l?"camera":"composite",r.value,d.labels,d instanceof ki?d.interpolation:void 0):new qn(l?"constant":"source",r.value)):Nn([new xi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Gn{constructor(t,r){this._parameters=t,this._specification=r,Pr(this,_l(this._parameters,this._specification))}static deserialize(t){return new Gn(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function As(i){let t=null;if(i instanceof Qr)t=As(i.result);else if(i instanceof Xs){for(const r of i.args)if(t=As(r),t)break}else(i instanceof Rn||i instanceof ki)&&i.input instanceof Qi&&i.input.name==="zoom"&&(t=i);return t instanceof xi||i.eachChild(r=>{const s=As(r);s instanceof xi?t=s:!t&&s?t=new xi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&s&&t!==s&&(t=new xi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function oa(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const t of i.slice(1))if(!oa(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}const la={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function co(i){if(i==null)return{filter:()=>!0,needGeometry:!1};oa(i)||(i=ca(i));const t=$n(i,la);if(t.result==="error")throw new Error(t.value.map(r=>`${r.key}: ${r.message}`).join(", "));return{filter:(r,s,l)=>t.value.evaluate(r,s,{},l),needGeometry:bl(i)}}function bc(i,t){return it?1:0}function bl(i){if(!Array.isArray(i))return!1;if(i[0]==="within"||i[0]==="distance")return!0;for(let t=1;t"||t==="<="||t===">="?ho(i[1],i[2],t):t==="any"?(r=i.slice(1),["any"].concat(r.map(ca))):t==="all"?["all"].concat(i.slice(1).map(ca)):t==="none"?["all"].concat(i.slice(1).map(ca).map(ai)):t==="in"?Cs(i[1],i.slice(2)):t==="!in"?ai(Cs(i[1],i.slice(2))):t==="has"?Ms(i[1]):t!=="!has"||ai(Ms(i[1]));var r}function ho(i,t,r){switch(i){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,i,t]}}function Cs(i,t){if(t.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(r=>typeof r!=typeof t[0])?["filter-in-large",i,["literal",t.sort(bc)]]:["filter-in-small",i,["literal",t]]}}function Ms(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function ai(i){return["!",i]}function wn(i){const t=typeof i;if(t==="number"||t==="boolean"||t==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let l="[";for(const u of i)l+=`${wn(u)},`;return`${l}]`}const r=Object.keys(i).sort();let s="{";for(let l=0;ls.maximum?[new xe(t,r,`${r} is greater than the maximum value ${s.maximum}`)]:[]}function ha(i){const t=i.valueSpec,r=Bt(i.value.type);let s,l,u,d={};const f=r!=="categorical"&&i.value.property===void 0,g=!f,x=ct(i.value.stops)==="array"&&ct(i.value.stops[0])==="array"&&ct(i.value.stops[0][0])==="object",v=$i({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(C){if(r==="identity")return[new xe(C.key,C.value,'identity function may not have a "stops" property')];let E=[];const z=C.value;return E=E.concat(ks({key:C.key,value:z,valueSpec:C.valueSpec,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec,arrayElementValidator:w})),ct(z)==="array"&&z.length===0&&E.push(new xe(C.key,z,"array must have at least one stop")),E},default:function(C){return C.validateSpec({key:C.key,value:C.value,valueSpec:t,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec})}}});return r==="identity"&&f&&v.push(new xe(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||v.push(new xe(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!oo(i.valueSpec)&&v.push(new xe(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(g&&!Un(i.valueSpec)?v.push(new xe(i.key,i.value,"property functions not supported")):f&&!gl(i.valueSpec)&&v.push(new xe(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!x||i.value.property!==void 0||v.push(new xe(i.key,i.value,'"property" property is required')),v;function w(C){let E=[];const z=C.value,O=C.key;if(ct(z)!=="array")return[new xe(O,z,`array expected, ${ct(z)} found`)];if(z.length!==2)return[new xe(O,z,`array length 2 expected, length ${z.length} found`)];if(x){if(ct(z[0])!=="object")return[new xe(O,z,`object expected, ${ct(z[0])} found`)];if(z[0].zoom===void 0)return[new xe(O,z,"object stop key must have zoom")];if(z[0].value===void 0)return[new xe(O,z,"object stop key must have value")];if(u&&u>Bt(z[0].zoom))return[new xe(O,z[0].zoom,"stop zoom values must appear in ascending order")];Bt(z[0].zoom)!==u&&(u=Bt(z[0].zoom),l=void 0,d={}),E=E.concat($i({key:`${O}[0]`,value:z[0],valueSpec:{zoom:{}},validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec,objectElementValidators:{zoom:uo,value:I}}))}else E=E.concat(I({key:`${O}[0]`,value:z[0],valueSpec:{},validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec},z));return aa(pr(z[1]))?E.concat([new xe(`${O}[1]`,z[1],"expressions are not allowed in function stops.")]):E.concat(C.validateSpec({key:`${O}[1]`,value:z[1],valueSpec:t,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec}))}function I(C,E){const z=ct(C.value),O=Bt(C.value),$=C.value!==null?C.value:E;if(s){if(z!==s)return[new xe(C.key,$,`${z} stop domain type must match previous stop domain type ${s}`)]}else s=z;if(z!=="number"&&z!=="string"&&z!=="boolean")return[new xe(C.key,$,"stop domain value must be a number, string, or boolean")];if(z!=="number"&&r!=="categorical"){let re=`number expected, ${z} found`;return Un(t)&&r===void 0&&(re+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new xe(C.key,$,re)]}return r!=="categorical"||z!=="number"||isFinite(O)&&Math.floor(O)===O?r!=="categorical"&&z==="number"&&l!==void 0&&Onew xe(`${i.key}${s.key}`,i.value,s.message));const r=t.value.expression||t.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new xe(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if(i.expressionContext==="property"&&i.propertyType==="layout"&&!Vn(r))return[new xe(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!Vn(r))return[new xe(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!Ps(r,["zoom","feature-state"]))return[new xe(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!Is(r))return[new xe(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function $r(i){const t=i.key,r=i.value,s=i.valueSpec,l=[];return Array.isArray(s.values)?s.values.indexOf(Bt(r))===-1&&l.push(new xe(t,r,`expected one of [${s.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(s.values).indexOf(Bt(r))===-1&&l.push(new xe(t,r,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function po(i){return oa(pr(i.value))?Hn(Pr({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):ua(i)}function ua(i){const t=i.value,r=i.key;if(ct(t)!=="array")return[new xe(r,t,`array expected, ${ct(t)} found`)];const s=i.styleSpec;let l,u=[];if(t.length<1)return[new xe(r,t,"filter array must have at least 1 element")];switch(u=u.concat($r({key:`${r}[0]`,value:t[0],valueSpec:s.filter_operator,style:i.style,styleSpec:i.styleSpec})),Bt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&Bt(t[1])==="$type"&&u.push(new xe(r,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&u.push(new xe(r,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(l=ct(t[1]),l!=="string"&&u.push(new xe(`${r}[1]`,t[1],`string expected, ${l} found`)));for(let d=2;d{x in r&&t.push(new xe(s,r[x],`"${x}" is prohibited for ref layers`))}),l.layers.forEach(x=>{Bt(x.id)===f&&(g=x)}),g?g.ref?t.push(new xe(s,r.ref,"ref cannot reference another ref layer")):d=Bt(g.type):t.push(new xe(s,r.ref,`ref layer "${f}" not found`))}else if(d!=="background")if(r.source){const g=l.sources&&l.sources[r.source],x=g&&Bt(g.type);g?x==="vector"&&d==="raster"?t.push(new xe(s,r.source,`layer "${r.id}" requires a raster source`)):x!=="raster-dem"&&d==="hillshade"?t.push(new xe(s,r.source,`layer "${r.id}" requires a raster-dem source`)):x==="raster"&&d!=="raster"?t.push(new xe(s,r.source,`layer "${r.id}" requires a vector source`)):x!=="vector"||r["source-layer"]?x==="raster-dem"&&d!=="hillshade"?t.push(new xe(s,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):d!=="line"||!r.paint||!r.paint["line-gradient"]||x==="geojson"&&g.lineMetrics||t.push(new xe(s,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new xe(s,r,`layer "${r.id}" must specify a "source-layer"`)):t.push(new xe(s,r.source,`source "${r.source}" not found`))}else t.push(new xe(s,r,'missing required property "source"'));return t=t.concat($i({key:s,value:r,valueSpec:u.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${s}.type`,value:r.type,valueSpec:u.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:po,layout:g=>$i({layer:r,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>mo(Pr({layerType:d},x))}}),paint:g=>$i({layer:r,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>da(Pr({layerType:d},x))}})}})),t}function Tn(i){const t=i.value,r=i.key,s=ct(t);return s!=="string"?[new xe(r,t,`string expected, ${s} found`)]:[]}const pa={promoteId:function({key:i,value:t}){if(ct(t)==="string")return Tn({key:i,value:t});{const r=[];for(const s in t)r.push(...Tn({key:`${i}.${s}`,value:t[s]}));return r}}};function Es(i){const t=i.value,r=i.key,s=i.styleSpec,l=i.style,u=i.validateSpec;if(!t.type)return[new xe(r,t,'"type" is required')];const d=Bt(t.type);let f;switch(d){case"vector":case"raster":return f=$i({key:r,value:t,valueSpec:s[`source_${d.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:pa,validateSpec:u}),f;case"raster-dem":return f=function(g){var x;const v=(x=g.sourceName)!==null&&x!==void 0?x:"",w=g.value,I=g.styleSpec,C=I.source_raster_dem,E=g.style;let z=[];const O=ct(w);if(w===void 0)return z;if(O!=="object")return z.push(new xe("source_raster_dem",w,`object expected, ${O} found`)),z;const $=Bt(w.encoding)==="custom",re=["redFactor","greenFactor","blueFactor","baseShift"],W=g.value.encoding?`"${g.value.encoding}"`:"Default";for(const te in w)!$&&re.includes(te)?z.push(new xe(te,w[te],`In "${v}": "${te}" is only valid when "encoding" is set to "custom". ${W} encoding found`)):C[te]?z=z.concat(g.validateSpec({key:te,value:w[te],valueSpec:C[te],validateSpec:g.validateSpec,style:E,styleSpec:I})):z.push(new xe(te,w[te],`unknown property "${te}"`));return z}({sourceName:r,value:t,style:i.style,styleSpec:s,validateSpec:u}),f;case"geojson":if(f=$i({key:r,value:t,valueSpec:s.source_geojson,style:l,styleSpec:s,validateSpec:u,objectElementValidators:pa}),t.cluster)for(const g in t.clusterProperties){const[x,v]=t.clusterProperties[g],w=typeof x=="string"?[x,["accumulated"],["get",g]]:x;f.push(...Hn({key:`${r}.${g}.map`,value:v,validateSpec:u,expressionContext:"cluster-map"})),f.push(...Hn({key:`${r}.${g}.reduce`,value:w,validateSpec:u,expressionContext:"cluster-reduce"}))}return f;case"video":return $i({key:r,value:t,valueSpec:s.source_video,style:l,validateSpec:u,styleSpec:s});case"image":return $i({key:r,value:t,valueSpec:s.source_image,style:l,validateSpec:u,styleSpec:s});case"canvas":return[new xe(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return $r({key:`${r}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:l,validateSpec:u,styleSpec:s})}}function _o(i){const t=i.value,r=i.styleSpec,s=r.light,l=i.style;let u=[];const d=ct(t);if(t===void 0)return u;if(d!=="object")return u=u.concat([new xe("light",t,`object expected, ${d} found`)]),u;for(const f in t){const g=f.match(/^(.*)-transition$/);u=u.concat(g&&s[g[1]]&&s[g[1]].transition?i.validateSpec({key:f,value:t[f],valueSpec:r.transition,validateSpec:i.validateSpec,style:l,styleSpec:r}):s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new xe(f,t[f],`unknown property "${f}"`)])}return u}function yo(i){const t=i.value,r=i.styleSpec,s=r.sky,l=i.style,u=ct(t);if(t===void 0)return[];if(u!=="object")return[new xe("sky",t,`object expected, ${u} found`)];let d=[];for(const f in t)d=d.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],style:l,styleSpec:r}):[new xe(f,t[f],`unknown property "${f}"`)]);return d}function xo(i){const t=i.value,r=i.styleSpec,s=r.terrain,l=i.style;let u=[];const d=ct(t);if(t===void 0)return u;if(d!=="object")return u=u.concat([new xe("terrain",t,`object expected, ${d} found`)]),u;for(const f in t)u=u.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new xe(f,t[f],`unknown property "${f}"`)]);return u}function vo(i){let t=[];const r=i.value,s=i.key;if(Array.isArray(r)){const l=[],u=[];for(const d in r)r[d].id&&l.includes(r[d].id)&&t.push(new xe(s,r,`all the sprites' ids must be unique, but ${r[d].id} is duplicated`)),l.push(r[d].id),r[d].url&&u.includes(r[d].url)&&t.push(new xe(s,r,`all the sprites' URLs must be unique, but ${r[d].url} is duplicated`)),u.push(r[d].url),t=t.concat($i({key:`${s}[${d}]`,value:r[d],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return t}return Tn({key:s,value:r})}const fa={"*":()=>[],array:ks,boolean:function(i){const t=i.value,r=i.key,s=ct(t);return s!=="boolean"?[new xe(r,t,`boolean expected, ${s} found`)]:[]},number:uo,color:function(i){const t=i.key,r=i.value,s=ct(r);return s!=="string"?[new xe(t,r,`color expected, ${s} found`)]:mt.parse(String(r))?[]:[new xe(t,r,`color expected, "${r}" found`)]},constants:Tl,enum:$r,filter:po,function:ha,layer:go,object:$i,source:Es,light:_o,sky:yo,terrain:xo,projection:function(i){const t=i.value,r=i.styleSpec,s=r.projection,l=i.style,u=ct(t);if(t===void 0)return[];if(u!=="object")return[new xe("projection",t,`object expected, ${u} found`)];let d=[];for(const f in t)d=d.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],style:l,styleSpec:r}):[new xe(f,t[f],`unknown property "${f}"`)]);return d},string:Tn,formatted:function(i){return Tn(i).length===0?[]:Hn(i)},resolvedImage:function(i){return Tn(i).length===0?[]:Hn(i)},padding:function(i){const t=i.key,r=i.value;if(ct(r)==="array"){if(r.length<1||r.length>4)return[new xe(t,r,`padding requires 1 to 4 values; ${r.length} values found`)];const s={type:"number"};let l=[];for(let u=0;u[]}})),i.constants&&(r=r.concat(Tl({key:"constants",value:i.constants,style:i,styleSpec:t,validateSpec:Xn}))),bo(r)}function Er(i){return function(t){return i({...t,validateSpec:Xn})}}function bo(i){return[].concat(i).sort((t,r)=>t.line-r.line)}function fr(i){return function(...t){return bo(i.apply(this,t))}}er.source=fr(Er(Es)),er.sprite=fr(Er(vo)),er.glyphs=fr(Er(Sl)),er.light=fr(Er(_o)),er.sky=fr(Er(yo)),er.terrain=fr(Er(xo)),er.layer=fr(Er(go)),er.filter=fr(Er(po)),er.paintProperty=fr(Er(da)),er.layoutProperty=fr(Er(mo));const Sn=er,wc=Sn.light,Tc=Sn.sky,Il=Sn.paintProperty,Pl=Sn.layoutProperty;function wo(i,t){let r=!1;if(t&&t.length)for(const s of t)i.fire(new Wr(new Error(s.message))),r=!0;return r}class Wn{constructor(t,r,s){const l=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const d=new Int32Array(this.arrayBuffer);t=d[0],this.d=(r=d[1])+2*(s=d[2]);for(let g=0;g=w[E+0]&&l>=w[E+1])?(f[C]=!0,d.push(v[C])):f[C]=!1}}}}_forEachCell(t,r,s,l,u,d,f,g){const x=this._convertToCellCoord(t),v=this._convertToCellCoord(r),w=this._convertToCellCoord(s),I=this._convertToCellCoord(l);for(let C=x;C<=w;C++)for(let E=v;E<=I;E++){const z=this.d*E+C;if((!g||g(this._convertFromCellCoord(C),this._convertFromCellCoord(E),this._convertFromCellCoord(C+1),this._convertFromCellCoord(E+1)))&&u.call(this,t,r,s,l,z,d,f,g))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,r=3+this.cells.length+1+1;let s=0;for(let d=0;d=0)continue;const d=i[u];l[u]=tr[r].shallow.indexOf(u)>=0?d:Kn(d,t)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(l.$name=r),l}function Jn(i){if(Al(i))return i;if(Array.isArray(i))return i.map(Jn);if(typeof i!="object")throw new Error("can't deserialize object of type "+typeof i);const t=To(i)||"Object";if(!tr[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:r}=tr[t];if(!r)throw new Error(`can't deserialize unregistered class ${t}`);if(r.deserialize)return r.deserialize(i);const s=Object.create(r.prototype);for(const l of Object.keys(i)){if(l==="$name")continue;const u=i[l];s[l]=tr[t].shallow.indexOf(l)>=0?u:Jn(u)}return s}class So{constructor(){this.first=!0}update(t,r){const s=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=128&&i<=255,"Hangul Jamo":i=>i>=4352&&i<=4607,Khmer:i=>i>=6016&&i<=6143,"General Punctuation":i=>i>=8192&&i<=8303,"Letterlike Symbols":i=>i>=8448&&i<=8527,"Number Forms":i=>i>=8528&&i<=8591,"Miscellaneous Technical":i=>i>=8960&&i<=9215,"Control Pictures":i=>i>=9216&&i<=9279,"Optical Character Recognition":i=>i>=9280&&i<=9311,"Enclosed Alphanumerics":i=>i>=9312&&i<=9471,"Geometric Shapes":i=>i>=9632&&i<=9727,"Miscellaneous Symbols":i=>i>=9728&&i<=9983,"Miscellaneous Symbols and Arrows":i=>i>=11008&&i<=11263,"Ideographic Description Characters":i=>i>=12272&&i<=12287,"CJK Symbols and Punctuation":i=>i>=12288&&i<=12351,Katakana:i=>i>=12448&&i<=12543,Kanbun:i=>i>=12688&&i<=12703,"CJK Strokes":i=>i>=12736&&i<=12783,"Enclosed CJK Letters and Months":i=>i>=12800&&i<=13055,"CJK Compatibility":i=>i>=13056&&i<=13311,"Yijing Hexagram Symbols":i=>i>=19904&&i<=19967,"Private Use Area":i=>i>=57344&&i<=63743,"Vertical Forms":i=>i>=65040&&i<=65055,"CJK Compatibility Forms":i=>i>=65072&&i<=65103,"Small Form Variants":i=>i>=65104&&i<=65135,"Halfwidth and Fullwidth Forms":i=>i>=65280&&i<=65519};function Io(i){for(const t of i)if(Ao(t.charCodeAt(0)))return!0;return!1}function Sc(i){for(const t of i)if(!Yn(t.charCodeAt(0)))return!1;return!0}function Po(i){const t=i.map(r=>{try{return new RegExp(`\\p{sc=${r}}`,"u").source}catch{return null}}).filter(r=>r);return new RegExp(t.join("|"),"u")}const Ic=Po(["Arab","Dupl","Mong","Ougr","Syrc"]);function Yn(i){return!Ic.test(String.fromCodePoint(i))}const Cl=Po(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function Ao(i){return!(i!==746&&i!==747&&(i<4352||!(st["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||st["CJK Compatibility"](i)||st["CJK Strokes"](i)||!(!st["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||st["Enclosed CJK Letters and Months"](i)||st["Ideographic Description Characters"](i)||st.Kanbun(i)||st.Katakana(i)&&i!==12540||!(!st["Halfwidth and Fullwidth Forms"](i)||i===65288||i===65289||i===65293||i>=65306&&i<=65310||i===65339||i===65341||i===65343||i>=65371&&i<=65503||i===65507||i>=65512&&i<=65519)||!(!st["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||st["Vertical Forms"](i)||st["Yijing Hexagram Symbols"](i)||new RegExp("\\p{sc=Cans}","u").test(String.fromCodePoint(i))||new RegExp("\\p{sc=Hang}","u").test(String.fromCodePoint(i))||Cl.test(String.fromCodePoint(i)))))}function Ml(i){return!(Ao(i)||function(t){return!!(st["Latin-1 Supplement"](t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||st["General Punctuation"](t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||st["Letterlike Symbols"](t)||st["Number Forms"](t)||st["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||st["Control Pictures"](t)&&t!==9251||st["Optical Character Recognition"](t)||st["Enclosed Alphanumerics"](t)||st["Geometric Shapes"](t)||st["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||st["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||st["CJK Symbols and Punctuation"](t)||st.Katakana(t)||st["Private Use Area"](t)||st["CJK Compatibility Forms"](t)||st["Small Form Variants"](t)||st["Halfwidth and Fullwidth Forms"](t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)}(i))}const Pc=Po(["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 Co(i){return Pc.test(String.fromCodePoint(i))}function Ac(i,t){return!(!t&&Co(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||st.Khmer(i))}function Cc(i){for(const t of i)if(Co(t.charCodeAt(0)))return!0;return!1}const qi=new class{constructor(){this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null}setState(i){this.pluginStatus=i.pluginStatus,this.pluginURL=i.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(i){this.applyArabicShaping=i.applyArabicShaping,this.processBidirectionalText=i.processBidirectionalText,this.processStyledBidirectionalText=i.processStyledBidirectionalText}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getPluginURL(){return this.pluginURL}getRTLTextPluginStatus(){return this.pluginStatus}};class wt{constructor(t,r){this.zoom=t,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new So,this.transition={})}isSupportedScript(t){return function(r,s){for(const l of r)if(!Ac(l.charCodeAt(0),s))return!1;return!0}(t,qi.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,r=t-Math.floor(t),s=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*r}}}class Qn{constructor(t,r){this.property=t,this.value=r,this.expression=function(s,l){if(ra(s))return new Gn(s,l);if(aa(s)){const u=lo(s,l);if(u.result==="error")throw new Error(u.value.map(d=>`${d.key}: ${d.message}`).join(", "));return u.value}{let u=s;return l.type==="color"&&typeof s=="string"?u=mt.parse(s):l.type!=="padding"||typeof s!="number"&&!Array.isArray(s)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(s)&&(u=Yi.parse(s)):u=Ui.parse(s),{kind:"constant",evaluate:()=>u}}}(r===void 0?t.specification.default:r,t.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(t,r,s){return this.property.possiblyEvaluate(this,t,r,s)}}class ga{constructor(t){this.property=t,this.value=new Qn(t,void 0)}transitioned(t,r){return new kl(this.property,this.value,r,gi({},t.transition,this.transition),t.now)}untransitioned(){return new kl(this.property,this.value,null,{},0)}}class _a{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return et(this._values[t].value.value)}setValue(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ga(this._values[t].property)),this._values[t].value=new Qn(this._values[t].property,r===null?void 0:et(r))}getTransition(t){return et(this._values[t].transition)}setTransition(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ga(this._values[t].property)),this._values[t].transition=et(r)||void 0}serialize(){const t={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(t[r]=s);const l=this.getTransition(r);l!==void 0&&(t[`${r}-transition`]=l)}return t}transitioned(t,r){const s=new zs(this._properties);for(const l of Object.keys(this._values))s._values[l]=this._values[l].transitioned(t,r._values[l]);return s}untransitioned(){const t=new zs(this._properties);for(const r of Object.keys(this._values))t._values[r]=this._values[r].untransitioned();return t}}class kl{constructor(t,r,s,l,u){this.property=t,this.value=r,this.begin=u+l.delay||0,this.end=this.begin+l.duration||0,t.specification.transition&&(l.delay||l.duration)&&(this.prior=s)}possiblyEvaluate(t,r,s){const l=t.now||0,u=this.value.possiblyEvaluate(t,r,s),d=this.prior;if(d){if(l>this.end)return this.prior=null,u;if(this.value.isDataDriven())return this.prior=null,u;if(l=1)return 1;const x=g*g,v=x*g;return 4*(g<.5?v:3*(g-x)+v-.75)}(f))}}return u}}class zs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,r,s){const l=new Ls(this._properties);for(const u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(t,r,s);return l}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class Ds{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return this._values[t].value!==void 0}getValue(t){return et(this._values[t].value)}setValue(t,r){this._values[t]=new Qn(this._values[t].property,r===null?void 0:et(r))}serialize(){const t={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(t[r]=s)}return t}possiblyEvaluate(t,r,s){const l=new Ls(this._properties);for(const u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(t,r,s);return l}}class zr{constructor(t,r,s){this.property=t,this.value=r,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,r,s,l){return this.property.evaluate(this.value,this.parameters,t,r,s,l)}}class Ls{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Le{constructor(t){this.specification=t}possiblyEvaluate(t,r){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(r)}interpolate(t,r,s){const l=Mi[this.specification.type];return l?l(t,r,s):t}}class je{constructor(t,r){this.specification=t,this.overrides=r}possiblyEvaluate(t,r,s,l){return new zr(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(r,null,{},s,l)}:t.expression,r)}interpolate(t,r,s){if(t.value.kind!=="constant"||r.value.kind!=="constant")return t;if(t.value.value===void 0||r.value.value===void 0)return new zr(this,{kind:"constant",value:void 0},t.parameters);const l=Mi[this.specification.type];if(l){const u=l(t.value.value,r.value.value,s);return new zr(this,{kind:"constant",value:u},t.parameters)}return t}evaluate(t,r,s,l,u,d){return t.kind==="constant"?t.value:t.evaluate(r,s,l,u,d)}}class ya extends je{possiblyEvaluate(t,r,s,l){if(t.value===void 0)return new zr(this,{kind:"constant",value:void 0},r);if(t.expression.kind==="constant"){const u=t.expression.evaluate(r,null,{},s,l),d=t.property.specification.type==="resolvedImage"&&typeof u!="string"?u.name:u,f=this._calculate(d,d,d,r);return new zr(this,{kind:"constant",value:f},r)}if(t.expression.kind==="camera"){const u=this._calculate(t.expression.evaluate({zoom:r.zoom-1}),t.expression.evaluate({zoom:r.zoom}),t.expression.evaluate({zoom:r.zoom+1}),r);return new zr(this,{kind:"constant",value:u},r)}return new zr(this,t.expression,r)}evaluate(t,r,s,l,u,d){if(t.kind==="source"){const f=t.evaluate(r,s,l,u,d);return this._calculate(f,f,f,r)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(r.zoom)-1},s,l),t.evaluate({zoom:Math.floor(r.zoom)},s,l),t.evaluate({zoom:Math.floor(r.zoom)+1},s,l),r):t.value}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class xa{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){if(t.value!==void 0){if(t.expression.kind==="constant"){const u=t.expression.evaluate(r,null,{},s,l);return this._calculate(u,u,u,r)}return this._calculate(t.expression.evaluate(new wt(Math.floor(r.zoom-1),r)),t.expression.evaluate(new wt(Math.floor(r.zoom),r)),t.expression.evaluate(new wt(Math.floor(r.zoom+1),r)),r)}}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class Mo{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){return!!t.expression.evaluate(r,null,{},s,l)}interpolate(){return!1}}class h{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in t){const s=t[r];s.specification.overridable&&this.overridableProperties.push(r);const l=this.defaultPropertyValues[r]=new Qn(s,void 0),u=this.defaultTransitionablePropertyValues[r]=new ga(s);this.defaultTransitioningPropertyValues[r]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}ze("DataDrivenProperty",je),ze("DataConstantProperty",Le),ze("CrossFadedDataDrivenProperty",ya),ze("CrossFadedProperty",xa),ze("ColorRampProperty",Mo);const e="-transition";class n extends kn{constructor(t,r){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),r.layout&&(this._unevaluatedLayout=new Ds(r.layout)),r.paint)){this._transitionablePaint=new _a(r.paint);for(const s in t.paint)this.setPaintProperty(s,t.paint[s],{validate:!1});for(const s in t.layout)this.setLayoutProperty(s,t.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ls(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,r,s={}){r!=null&&this._validate(Pl,`layers.${this.id}.layout.${t}`,t,r,s)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,r):this.visibility=r)}getPaintProperty(t){return t.endsWith(e)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,r,s={}){if(r!=null&&this._validate(Il,`layers.${this.id}.paint.${t}`,t,r,s))return!1;if(t.endsWith(e))return this._transitionablePaint.setTransition(t.slice(0,-11),r||void 0),!1;{const l=this._transitionablePaint._values[t],u=l.property.specification["property-type"]==="cross-faded-data-driven",d=l.value.isDataDriven(),f=l.value;this._transitionablePaint.setValue(t,r),this._handleSpecialPaintPropertyUpdate(t);const g=this._transitionablePaint._values[t].value;return g.isDataDriven()||d||u||this._handleOverridablePaintPropertyUpdate(t,f,g)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,r,s){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||this.visibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,r){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,r)}serialize(){const t={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&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),Or(t,(r,s)=>!(r===void 0||s==="layout"&&!Object.keys(r).length||s==="paint"&&!Object.keys(r).length))}_validate(t,r,s,l,u={}){return(!u||u.validate!==!1)&&wo(this,t.call(Sn,{key:r,layerType:this.type,objectKey:s,value:l,styleSpec:le,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const r=this.paint.get(t);if(r instanceof zr&&Un(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const a={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class o{constructor(t,r){this._structArray=t,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class c{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,r){return t._trim(),r&&(t.isTransferred=!0,r.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const r=Object.create(this.prototype);return r.arrayBuffer=t.arrayBuffer,r.length=t.length,r.capacity=t.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function m(i,t=1){let r=0,s=0;return{members:i.map(l=>{const u=a[l.type].BYTES_PER_ELEMENT,d=r=_(r,Math.max(t,u)),f=l.components||1;return s=Math.max(s,u),r+=u*f,{name:l.name,type:l.type,components:f,offset:d}}),size:_(r,Math.max(s,t)),alignment:t}}function _(i,t){return Math.ceil(i/t)*t}class y extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){const l=2*t;return this.int16[l+0]=r,this.int16[l+1]=s,t}}y.prototype.bytesPerElement=4,ze("StructArrayLayout2i4",y);class b extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const u=3*t;return this.int16[u+0]=r,this.int16[u+1]=s,this.int16[u+2]=l,t}}b.prototype.bytesPerElement=6,ze("StructArrayLayout3i6",b);class T extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,r,s,l)}emplace(t,r,s,l,u){const d=4*t;return this.int16[d+0]=r,this.int16[d+1]=s,this.int16[d+2]=l,this.int16[d+3]=u,t}}T.prototype.bytesPerElement=8,ze("StructArrayLayout4i8",T);class S extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){const f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){const g=6*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.int16[g+2]=l,this.int16[g+3]=u,this.int16[g+4]=d,this.int16[g+5]=f,t}}S.prototype.bytesPerElement=12,ze("StructArrayLayout2i4i12",S);class k extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){const f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){const g=4*t,x=8*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.uint8[x+4]=l,this.uint8[x+5]=u,this.uint8[x+6]=d,this.uint8[x+7]=f,t}}k.prototype.bytesPerElement=8,ze("StructArrayLayout2i4ub8",k);class D extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){const l=2*t;return this.float32[l+0]=r,this.float32[l+1]=s,t}}D.prototype.bytesPerElement=8,ze("StructArrayLayout2f8",D);class B extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d,f,g,x,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,r,s,l,u,d,f,g,x,v)}emplace(t,r,s,l,u,d,f,g,x,v,w){const I=10*t;return this.uint16[I+0]=r,this.uint16[I+1]=s,this.uint16[I+2]=l,this.uint16[I+3]=u,this.uint16[I+4]=d,this.uint16[I+5]=f,this.uint16[I+6]=g,this.uint16[I+7]=x,this.uint16[I+8]=v,this.uint16[I+9]=w,t}}B.prototype.bytesPerElement=20,ze("StructArrayLayout10ui20",B);class N extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d,f,g,x,v,w,I){const C=this.length;return this.resize(C+1),this.emplace(C,t,r,s,l,u,d,f,g,x,v,w,I)}emplace(t,r,s,l,u,d,f,g,x,v,w,I,C){const E=12*t;return this.int16[E+0]=r,this.int16[E+1]=s,this.int16[E+2]=l,this.int16[E+3]=u,this.uint16[E+4]=d,this.uint16[E+5]=f,this.uint16[E+6]=g,this.uint16[E+7]=x,this.int16[E+8]=v,this.int16[E+9]=w,this.int16[E+10]=I,this.int16[E+11]=C,t}}N.prototype.bytesPerElement=24,ze("StructArrayLayout4i4ui4i24",N);class q extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const u=3*t;return this.float32[u+0]=r,this.float32[u+1]=s,this.float32[u+2]=l,t}}q.prototype.bytesPerElement=12,ze("StructArrayLayout3f12",q);class Z extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint32[1*t+0]=r,t}}Z.prototype.bytesPerElement=4,ze("StructArrayLayout1ul4",Z);class X extends c{_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(t,r,s,l,u,d,f,g,x){const v=this.length;return this.resize(v+1),this.emplace(v,t,r,s,l,u,d,f,g,x)}emplace(t,r,s,l,u,d,f,g,x,v){const w=10*t,I=5*t;return this.int16[w+0]=r,this.int16[w+1]=s,this.int16[w+2]=l,this.int16[w+3]=u,this.int16[w+4]=d,this.int16[w+5]=f,this.uint32[I+3]=g,this.uint16[w+8]=x,this.uint16[w+9]=v,t}}X.prototype.bytesPerElement=20,ze("StructArrayLayout6i1ul2ui20",X);class F extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){const f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){const g=6*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.int16[g+2]=l,this.int16[g+3]=u,this.int16[g+4]=d,this.int16[g+5]=f,t}}F.prototype.bytesPerElement=12,ze("StructArrayLayout2i2i2i12",F);class Y extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u){const d=this.length;return this.resize(d+1),this.emplace(d,t,r,s,l,u)}emplace(t,r,s,l,u,d){const f=4*t,g=8*t;return this.float32[f+0]=r,this.float32[f+1]=s,this.float32[f+2]=l,this.int16[g+6]=u,this.int16[g+7]=d,t}}Y.prototype.bytesPerElement=16,ze("StructArrayLayout2f1f2i16",Y);class ee extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){const f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){const g=16*t,x=4*t,v=8*t;return this.uint8[g+0]=r,this.uint8[g+1]=s,this.float32[x+1]=l,this.float32[x+2]=u,this.int16[v+6]=d,this.int16[v+7]=f,t}}ee.prototype.bytesPerElement=16,ze("StructArrayLayout2ub2f2i16",ee);class ae extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const u=3*t;return this.uint16[u+0]=r,this.uint16[u+1]=s,this.uint16[u+2]=l,t}}ae.prototype.bytesPerElement=6,ze("StructArrayLayout3ui6",ae);class fe extends c{_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(t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$){const re=this.length;return this.resize(re+1),this.emplace(re,t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$)}emplace(t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$,re){const W=24*t,te=12*t,ce=48*t;return this.int16[W+0]=r,this.int16[W+1]=s,this.uint16[W+2]=l,this.uint16[W+3]=u,this.uint32[te+2]=d,this.uint32[te+3]=f,this.uint32[te+4]=g,this.uint16[W+10]=x,this.uint16[W+11]=v,this.uint16[W+12]=w,this.float32[te+7]=I,this.float32[te+8]=C,this.uint8[ce+36]=E,this.uint8[ce+37]=z,this.uint8[ce+38]=O,this.uint32[te+10]=$,this.int16[W+22]=re,t}}fe.prototype.bytesPerElement=48,ze("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",fe);class _e extends c{_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(t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$,re,W,te,ce,ge,Me,Ue,Ae,Ie,Fe,De){const Ee=this.length;return this.resize(Ee+1),this.emplace(Ee,t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$,re,W,te,ce,ge,Me,Ue,Ae,Ie,Fe,De)}emplace(t,r,s,l,u,d,f,g,x,v,w,I,C,E,z,O,$,re,W,te,ce,ge,Me,Ue,Ae,Ie,Fe,De,Ee){const pe=32*t,Oe=16*t;return this.int16[pe+0]=r,this.int16[pe+1]=s,this.int16[pe+2]=l,this.int16[pe+3]=u,this.int16[pe+4]=d,this.int16[pe+5]=f,this.int16[pe+6]=g,this.int16[pe+7]=x,this.uint16[pe+8]=v,this.uint16[pe+9]=w,this.uint16[pe+10]=I,this.uint16[pe+11]=C,this.uint16[pe+12]=E,this.uint16[pe+13]=z,this.uint16[pe+14]=O,this.uint16[pe+15]=$,this.uint16[pe+16]=re,this.uint16[pe+17]=W,this.uint16[pe+18]=te,this.uint16[pe+19]=ce,this.uint16[pe+20]=ge,this.uint16[pe+21]=Me,this.uint16[pe+22]=Ue,this.uint32[Oe+12]=Ae,this.float32[Oe+13]=Ie,this.float32[Oe+14]=Fe,this.uint16[pe+30]=De,this.uint16[pe+31]=Ee,t}}_e.prototype.bytesPerElement=64,ze("StructArrayLayout8i15ui1ul2f2ui64",_e);class Pe extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.float32[1*t+0]=r,t}}Pe.prototype.bytesPerElement=4,ze("StructArrayLayout1f4",Pe);class ke extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const u=3*t;return this.uint16[6*t+0]=r,this.float32[u+1]=s,this.float32[u+2]=l,t}}ke.prototype.bytesPerElement=12,ze("StructArrayLayout1ui2f12",ke);class we extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const u=4*t;return this.uint32[2*t+0]=r,this.uint16[u+2]=s,this.uint16[u+3]=l,t}}we.prototype.bytesPerElement=8,ze("StructArrayLayout1ul2ui8",we);class be extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){const l=2*t;return this.uint16[l+0]=r,this.uint16[l+1]=s,t}}be.prototype.bytesPerElement=4,ze("StructArrayLayout2ui4",be);class Re extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint16[1*t+0]=r,t}}Re.prototype.bytesPerElement=2,ze("StructArrayLayout1ui2",Re);class Xe extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,r,s,l)}emplace(t,r,s,l,u){const d=4*t;return this.float32[d+0]=r,this.float32[d+1]=s,this.float32[d+2]=l,this.float32[d+3]=u,t}}Xe.prototype.bytesPerElement=16,ze("StructArrayLayout4f16",Xe);class Se extends o{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 ue(this.anchorPointX,this.anchorPointY)}}Se.prototype.size=20;class Ce extends X{get(t){return new Se(this,t)}}ze("CollisionBoxArray",Ce);class qe extends o{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(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}qe.prototype.size=48;class Tt extends fe{get(t){return new qe(this,t)}}ze("PlacedSymbolArray",Tt);class Ye extends o{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(t){this._structArray.uint32[this._pos4+12]=t}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]}}Ye.prototype.size=64;class nt extends _e{get(t){return new Ye(this,t)}}ze("SymbolInstanceArray",nt);class St extends Pe{getoffsetX(t){return this.float32[1*t+0]}}ze("GlyphOffsetArray",St);class oi extends b{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}ze("SymbolLineVertexArray",oi);class mr extends o{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]}}mr.prototype.size=12;class It extends ke{get(t){return new mr(this,t)}}ze("TextAnchorOffsetArray",It);class Ei extends o{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]}}Ei.prototype.size=8;class bi extends we{get(t){return new Ei(this,t)}}ze("FeatureIndexArray",bi);class li extends y{}class wi extends y{}class Dr extends y{}class es extends S{}class va extends k{}class ts extends D{}class ir extends B{}class ba extends N{}class ko extends q{}class rr extends Z{}class nr extends F{}class tn extends ee{}class gr extends ae{}class ei extends be{}const ci=m([{name:"a_pos",components:2,type:"Int16"}],4),{members:Zi}=ci;class at{constructor(t=[]){this.segments=t}prepareSegment(t,r,s,l){let u=this.segments[this.segments.length-1];return t>at.MAX_VERTEX_ARRAY_LENGTH&&Gt(`Max vertices per segment is ${at.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!u||u.vertexLength+t>at.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==l)&&(u={vertexOffset:r.length,primitiveOffset:s.length,vertexLength:0,primitiveLength:0},l!==void 0&&(u.sortKey=l),this.segments.push(u)),u}get(){return this.segments}destroy(){for(const t of this.segments)for(const r in t.vaos)t.vaos[r].destroy()}static simpleSegment(t,r,s,l){return new at([{vertexOffset:t,primitiveOffset:r,vertexLength:s,primitiveLength:l,vaos:{},sortKey:0}])}}function In(i,t){return 256*(i=mi(Math.floor(i),0,255))+mi(Math.floor(t),0,255)}at.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ze("SegmentVector",at);const is=m([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var rs={exports:{}},El={exports:{}};El.exports=function(i,t){var r,s,l,u,d,f,g,x;for(s=i.length-(r=3&i.length),l=t,d=3432918353,f=461845907,x=0;x>>16)*d&65535)<<16)&4294967295)<<15|g>>>17))*f+(((g>>>16)*f&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(g=0,r){case 3:g^=(255&i.charCodeAt(x+2))<<16;case 2:g^=(255&i.charCodeAt(x+1))<<8;case 1:l^=g=(65535&(g=(g=(65535&(g^=255&i.charCodeAt(x)))*d+(((g>>>16)*d&65535)<<16)&4294967295)<<15|g>>>17))*f+(((g>>>16)*f&65535)<<16)&4294967295}return l^=i.length,l=2246822507*(65535&(l^=l>>>16))+((2246822507*(l>>>16)&65535)<<16)&4294967295,l=3266489909*(65535&(l^=l>>>13))+((3266489909*(l>>>16)&65535)<<16)&4294967295,(l^=l>>>16)>>>0};var Mc=El.exports,zl={exports:{}};zl.exports=function(i,t){for(var r,s=i.length,l=t^s,u=0;s>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(u)|(255&i.charCodeAt(++u))<<8|(255&i.charCodeAt(++u))<<16|(255&i.charCodeAt(++u))<<24))+((1540483477*(r>>>16)&65535)<<16),l=1540483477*(65535&l)+((1540483477*(l>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),s-=4,++u;switch(s){case 3:l^=(255&i.charCodeAt(u+2))<<16;case 2:l^=(255&i.charCodeAt(u+1))<<8;case 1:l=1540483477*(65535&(l^=255&i.charCodeAt(u)))+((1540483477*(l>>>16)&65535)<<16)}return l=1540483477*(65535&(l^=l>>>13))+((1540483477*(l>>>16)&65535)<<16),(l^=l>>>15)>>>0};var rn=Mc,Dl=zl.exports;rs.exports=rn,rs.exports.murmur3=rn,rs.exports.murmur2=Dl;var wa=Je(rs.exports);class Rs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,r,s,l){this.ids.push(Ta(t)),this.positions.push(r,s,l)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=Ta(t);let s=0,l=this.ids.length-1;for(;s>1;this.ids[d]>=r?l=d:s=d+1}const u=[];for(;this.ids[s]===r;)u.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return u}static serialize(t,r){const s=new Float64Array(t.ids),l=new Uint32Array(t.positions);return Sa(s,l,0,s.length-1),r&&r.push(s.buffer,l.buffer),{ids:s,positions:l}}static deserialize(t){const r=new Rs;return r.ids=t.ids,r.positions=t.positions,r.indexed=!0,r}}function Ta(i){const t=+i;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:wa(String(i))}function Sa(i,t,r,s){for(;r>1];let u=r-1,d=s+1;for(;;){do u++;while(i[u]l);if(u>=d)break;ns(i,u,d),ns(t,3*u,3*d),ns(t,3*u+1,3*d+1),ns(t,3*u+2,3*d+2)}d-r`u_${l}`),this.type=s}setUniform(t,r,s){t.set(s.constantOr(this.value))}getBinding(t,r,s){return this.type==="color"?new Mh(t,r):new Ll(t,r)}}class Ia{constructor(t,r){this.uniformNames=r.map(s=>`u_${s}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=t.tlbr}setUniform(t,r,s,l){const u=l==="u_pattern_to"?this.patternTo:l==="u_pattern_from"?this.patternFrom:l==="u_pixel_ratio_to"?this.pixelRatioTo:l==="u_pixel_ratio_from"?this.pixelRatioFrom:null;u&&t.set(u)}getBinding(t,r,s){return s.substr(0,9)==="u_pattern"?new Ch(t,r):new Ll(t,r)}}class Pn{constructor(t,r,s,l){this.expression=t,this.type=s,this.maxValue=0,this.paintVertexAttributes=r.map(u=>({name:`a_${u}`,type:"Float32",components:s==="color"?2:1,offset:0})),this.paintVertexArray=new l}populatePaintArray(t,r,s,l,u){const d=this.paintVertexArray.length,f=this.expression.evaluate(new wt(0),r,{},l,[],u);this.paintVertexArray.resize(t),this._setPaintValue(d,t,f)}updatePaintArray(t,r,s,l){const u=this.expression.evaluate({zoom:0},s,l);this._setPaintValue(t,r,u)}_setPaintValue(t,r,s){if(this.type==="color"){const l=kc(s);for(let u=t;u`u_${f}_t`),this.type=s,this.useIntegerZoom=l,this.zoom=u,this.maxValue=0,this.paintVertexAttributes=r.map(f=>({name:`a_${f}`,type:"Float32",components:s==="color"?4:2,offset:0})),this.paintVertexArray=new d}populatePaintArray(t,r,s,l,u){const d=this.expression.evaluate(new wt(this.zoom),r,{},l,[],u),f=this.expression.evaluate(new wt(this.zoom+1),r,{},l,[],u),g=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(g,t,d,f)}updatePaintArray(t,r,s,l){const u=this.expression.evaluate({zoom:this.zoom},s,l),d=this.expression.evaluate({zoom:this.zoom+1},s,l);this._setPaintValue(t,r,u,d)}_setPaintValue(t,r,s,l){if(this.type==="color"){const u=kc(s),d=kc(l);for(let f=t;f`#define HAS_UNIFORM_${l}`))}return t}getBinderAttributes(){const t=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof Pn||s instanceof qr)for(let l=0;l!0){this.programConfigurations={};for(const l of t)this.programConfigurations[l.id]=new kh(l,r,s);this.needsUpload=!1,this._featureMap=new Rs,this._bufferOffset=0}populatePaintArrays(t,r,s,l,u,d){for(const f in this.programConfigurations)this.programConfigurations[f].populatePaintArrays(t,r,l,u,d);r.id!==void 0&&this._featureMap.add(r.id,s,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,r,s,l){for(const u of s)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(t,this._featureMap,r,u,l)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function Dd(i,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[i]||[i.replace(`${t}-`,"").replace(/-/g,"_")]}function Eh(i,t,r){const s={color:{source:D,composite:Xe},number:{source:Pe,composite:D}},l=function(u){return{"line-pattern":{source:ir,composite:ir},"fill-pattern":{source:ir,composite:ir},"fill-extrusion-pattern":{source:ir,composite:ir}}[u]}(i);return l&&l[r]||s[t][r]}ze("ConstantBinder",Eo),ze("CrossFadedConstantBinder",Ia),ze("SourceExpressionBinder",Pn),ze("CrossFadedCompositeBinder",ss),ze("CompositeExpressionBinder",qr),ze("ProgramConfiguration",kh,{omit:["_buffers"]}),ze("ProgramConfigurationSet",Fs);const $t=8192,Ec=Math.pow(2,14)-1,zh=-Ec-1;function Os(i){const t=$t/i.extent,r=i.loadGeometry();for(let s=0;sd.x+1||gd.y+1)&&Gt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function Vs(i,t){return{type:i.type,id:i.id,properties:i.properties,geometry:t?Os(i):[]}}function Rl(i,t,r,s,l){i.emplaceBack(2*t+(s+1)/2,2*r+(l+1)/2)}class zc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new wi,this.indexArray=new gr,this.segments=new at,this.programConfigurations=new Fs(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){const l=this.layers[0],u=[];let d=null,f=!1;l.type==="circle"&&(d=l.layout.get("circle-sort-key"),f=!d.isConstant());for(const{feature:g,id:x,index:v,sourceLayerIndex:w}of t){const I=this.layers[0]._featureFilter.needGeometry,C=Vs(g,I);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom),C,s))continue;const E=f?d.evaluate(C,{},s):void 0,z={id:x,properties:g.properties,type:g.type,sourceLayerIndex:w,index:v,geometry:I?C.geometry:Os(g),patterns:{},sortKey:E};u.push(z)}f&&u.sort((g,x)=>g.sortKey-x.sortKey);for(const g of u){const{geometry:x,index:v,sourceLayerIndex:w}=g,I=t[v].feature;this.addFeature(g,x,v,s),r.featureIndex.insert(I,x,v,w,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Zi),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,r,s,l){for(const u of r)for(const d of u){const f=d.x,g=d.y;if(f<0||f>=$t||g<0||g>=$t)continue;const x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),v=x.vertexLength;Rl(this.layoutVertexArray,f,g,-1,-1),Rl(this.layoutVertexArray,f,g,1,-1),Rl(this.layoutVertexArray,f,g,1,1),Rl(this.layoutVertexArray,f,g,-1,1),this.indexArray.emplaceBack(v,v+1,v+2),this.indexArray.emplaceBack(v,v+3,v+2),x.vertexLength+=4,x.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{},l)}}function Dh(i,t){for(let r=0;r1){if(Dc(i,t))return!0;for(let s=0;s1?r:r.sub(t)._mult(l)._add(t))}function Bh(i,t){let r,s,l,u=!1;for(let d=0;dt.y!=l.y>t.y&&t.x<(l.x-s.x)*(t.y-s.y)/(l.y-s.y)+s.x&&(u=!u)}return u}function Pa(i,t){let r=!1;for(let s=0,l=i.length-1;st.y!=d.y>t.y&&t.x<(d.x-u.x)*(t.y-u.y)/(d.y-u.y)+u.x&&(r=!r)}return r}function Fd(i,t,r){const s=r[0],l=r[2];if(i.xl.x&&t.x>l.x||i.yl.y&&t.y>l.y)return!1;const u=Jt(i,t,r[0]);return u!==Jt(i,t,r[1])||u!==Jt(i,t,r[2])||u!==Jt(i,t,r[3])}function zo(i,t,r){const s=t.paint.get(i).value;return s.kind==="constant"?s.value:r.programConfigurations.get(t.id).getMaxValue(i)}function Bl(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Fl(i,t,r,s,l){if(!t[0]&&!t[1])return i;const u=ue.convert(t)._mult(l);r==="viewport"&&u._rotate(-s);const d=[];for(let f=0;fNh(O,z))}(x,g),C=w?v*f:v;for(const E of l)for(const z of E){const O=w?z:Nh(z,g);let $=C;const re=Ol([],[z.x,z.y,0,1],g);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?$*=re[3]/d.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&($*=d.cameraToCenterDistance/re[3]),Ld(I,O,$))return!0}return!1}}function Nh(i,t){const r=Ol([],[i.x,i.y,0,1],t);return new ue(r[0]/r[3],r[1]/r[3])}class Uh extends zc{}let jh;ze("HeatmapBucket",Uh,{omit:["layers"]});var Ud={get paint(){return jh=jh||new h({"heatmap-radius":new je(le.paint_heatmap["heatmap-radius"]),"heatmap-weight":new je(le.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Le(le.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Mo(le.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Le(le.paint_heatmap["heatmap-opacity"])})}};function Bc(i,{width:t,height:r},s,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==t*r*s)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${t*r*s}`)}else l=new Uint8Array(t*r*s);return i.width=t,i.height=r,i.data=l,i}function $h(i,{width:t,height:r},s){if(t===i.width&&r===i.height)return;const l=Bc({},{width:t,height:r},s);Fc(i,l,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,t),height:Math.min(i.height,r)},s),i.width=t,i.height=r,i.data=l.data}function Fc(i,t,r,s,l,u){if(l.width===0||l.height===0)return t;if(l.width>i.width||l.height>i.height||r.x>i.width-l.width||r.y>i.height-l.height)throw new RangeError("out of range source coordinates for image copy");if(l.width>t.width||l.height>t.height||s.x>t.width-l.width||s.y>t.height-l.height)throw new RangeError("out of range destination coordinates for image copy");const d=i.data,f=t.data;if(d===f)throw new Error("srcData equals dstData, so image is already copied");for(let g=0;g{t[i.evaluationKey]=g;const x=i.expression.evaluate(t);l.data[d+f+0]=Math.floor(255*x.r/x.a),l.data[d+f+1]=Math.floor(255*x.g/x.a),l.data[d+f+2]=Math.floor(255*x.b/x.a),l.data[d+f+3]=Math.floor(255*x.a)};if(i.clips)for(let d=0,f=0;d80*r){f=1/0,g=1/0;let v=-1/0,w=-1/0;for(let I=r;Iv&&(v=C),E>w&&(w=E)}x=Math.max(v-f,w-g),x=x!==0?32767/x:0}return Ro(u,d,r,f,g,x,0),d}function Hh(i,t,r,s,l){let u;if(l===function(d,f,g,x){let v=0;for(let w=f,I=g-x;w0)for(let d=t;d=t;d-=s)u=Kh(d/s|0,i[d],i[d+1],u);return u&&Vl(u,u.next)&&(Fo(u),u=u.next),u}function Ns(i,t){if(!i)return i;t||(t=i);let r,s=i;do if(r=!1,s.steiner||!Vl(s,s.next)&&Nt(s.prev,s,s.next)!==0)s=s.next;else{if(Fo(s),s=t=s.prev,s===s.next)break;r=!0}while(r||s!==t);return t}function Ro(i,t,r,s,l,u,d){if(!i)return;!d&&u&&function(g,x,v,w){let I=g;do I.z===0&&(I.z=Vc(I.x,I.y,x,v,w)),I.prevZ=I.prev,I.nextZ=I.next,I=I.next;while(I!==g);I.prevZ.nextZ=null,I.prevZ=null,function(C){let E,z=1;do{let O,$=C;C=null;let re=null;for(E=0;$;){E++;let W=$,te=0;for(let ge=0;ge0||ce>0&&W;)te!==0&&(ce===0||!W||$.z<=W.z)?(O=$,$=$.nextZ,te--):(O=W,W=W.nextZ,ce--),re?re.nextZ=O:C=O,O.prevZ=re,re=O;$=W}re.nextZ=null,z*=2}while(E>1)}(I)}(i,s,l,u);let f=i;for(;i.prev!==i.next;){const g=i.prev,x=i.next;if(u?Xd(i,s,l,u):Hd(i))t.push(g.i,i.i,x.i),Fo(i),i=x.next,f=x.next;else if((i=x)===f){d?d===1?Ro(i=Wd(Ns(i),t),t,r,s,l,u,2):d===2&&Kd(i,t,r,s,l,u):Ro(Ns(i),t,r,s,l,u,1);break}}}function Hd(i){const t=i.prev,r=i,s=i.next;if(Nt(t,r,s)>=0)return!1;const l=t.x,u=r.x,d=s.x,f=t.y,g=r.y,x=s.y,v=lu?l>d?l:d:u>d?u:d,C=f>g?f>x?f:x:g>x?g:x;let E=s.next;for(;E!==t;){if(E.x>=v&&E.x<=I&&E.y>=w&&E.y<=C&&Ca(l,f,u,g,d,x,E.x,E.y)&&Nt(E.prev,E,E.next)>=0)return!1;E=E.next}return!0}function Xd(i,t,r,s){const l=i.prev,u=i,d=i.next;if(Nt(l,u,d)>=0)return!1;const f=l.x,g=u.x,x=d.x,v=l.y,w=u.y,I=d.y,C=fg?f>x?f:x:g>x?g:x,O=v>w?v>I?v:I:w>I?w:I,$=Vc(C,E,t,r,s),re=Vc(z,O,t,r,s);let W=i.prevZ,te=i.nextZ;for(;W&&W.z>=$&&te&&te.z<=re;){if(W.x>=C&&W.x<=z&&W.y>=E&&W.y<=O&&W!==l&&W!==d&&Ca(f,v,g,w,x,I,W.x,W.y)&&Nt(W.prev,W,W.next)>=0||(W=W.prevZ,te.x>=C&&te.x<=z&&te.y>=E&&te.y<=O&&te!==l&&te!==d&&Ca(f,v,g,w,x,I,te.x,te.y)&&Nt(te.prev,te,te.next)>=0))return!1;te=te.nextZ}for(;W&&W.z>=$;){if(W.x>=C&&W.x<=z&&W.y>=E&&W.y<=O&&W!==l&&W!==d&&Ca(f,v,g,w,x,I,W.x,W.y)&&Nt(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;te&&te.z<=re;){if(te.x>=C&&te.x<=z&&te.y>=E&&te.y<=O&&te!==l&&te!==d&&Ca(f,v,g,w,x,I,te.x,te.y)&&Nt(te.prev,te,te.next)>=0)return!1;te=te.nextZ}return!0}function Wd(i,t){let r=i;do{const s=r.prev,l=r.next.next;!Vl(s,l)&&Xh(s,r,r.next,l)&&Bo(s,l)&&Bo(l,s)&&(t.push(s.i,r.i,l.i),Fo(r),Fo(r.next),r=i=l),r=r.next}while(r!==i);return Ns(r)}function Kd(i,t,r,s,l,u){let d=i;do{let f=d.next.next;for(;f!==d.prev;){if(d.i!==f.i&&tp(d,f)){let g=Wh(d,f);return d=Ns(d,d.next),g=Ns(g,g.next),Ro(d,t,r,s,l,u,0),void Ro(g,t,r,s,l,u,0)}f=f.next}d=d.next}while(d!==i)}function Jd(i,t){return i.x-t.x}function Yd(i,t){const r=function(l,u){let d=u;const f=l.x,g=l.y;let x,v=-1/0;do{if(g<=d.y&&g>=d.next.y&&d.next.y!==d.y){const z=d.x+(g-d.y)*(d.next.x-d.x)/(d.next.y-d.y);if(z<=f&&z>v&&(v=z,x=d.x=d.x&&d.x>=I&&f!==d.x&&Ca(gx.x||d.x===x.x&&Qd(x,d)))&&(x=d,E=z)}d=d.next}while(d!==w);return x}(i,t);if(!r)return t;const s=Wh(r,i);return Ns(s,s.next),Ns(r,r.next)}function Qd(i,t){return Nt(i.prev,i,t.prev)<0&&Nt(t.next,i,i.next)<0}function Vc(i,t,r,s,l){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*l|0)|i<<8))|i<<4))|i<<2))|i<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*l|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ep(i){let t=i,r=i;do(t.x=(i-d)*(u-f)&&(i-d)*(s-f)>=(r-d)*(t-f)&&(r-d)*(u-f)>=(l-d)*(s-f)}function tp(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!function(r,s){let l=r;do{if(l.i!==r.i&&l.next.i!==r.i&&l.i!==s.i&&l.next.i!==s.i&&Xh(l,l.next,r,s))return!0;l=l.next}while(l!==r);return!1}(i,t)&&(Bo(i,t)&&Bo(t,i)&&function(r,s){let l=r,u=!1;const d=(r.x+s.x)/2,f=(r.y+s.y)/2;do l.y>f!=l.next.y>f&&l.next.y!==l.y&&d<(l.next.x-l.x)*(f-l.y)/(l.next.y-l.y)+l.x&&(u=!u),l=l.next;while(l!==r);return u}(i,t)&&(Nt(i.prev,i,t.prev)||Nt(i,t.prev,t))||Vl(i,t)&&Nt(i.prev,i,i.next)>0&&Nt(t.prev,t,t.next)>0)}function Nt(i,t,r){return(t.y-i.y)*(r.x-t.x)-(t.x-i.x)*(r.y-t.y)}function Vl(i,t){return i.x===t.x&&i.y===t.y}function Xh(i,t,r,s){const l=Ul(Nt(i,t,r)),u=Ul(Nt(i,t,s)),d=Ul(Nt(r,s,i)),f=Ul(Nt(r,s,t));return l!==u&&d!==f||!(l!==0||!Nl(i,r,t))||!(u!==0||!Nl(i,s,t))||!(d!==0||!Nl(r,i,s))||!(f!==0||!Nl(r,t,s))}function Nl(i,t,r){return t.x<=Math.max(i.x,r.x)&&t.x>=Math.min(i.x,r.x)&&t.y<=Math.max(i.y,r.y)&&t.y>=Math.min(i.y,r.y)}function Ul(i){return i>0?1:i<0?-1:0}function Bo(i,t){return Nt(i.prev,i,i.next)<0?Nt(i,t,i.next)>=0&&Nt(i,i.prev,t)>=0:Nt(i,t,i.prev)<0||Nt(i,i.next,t)<0}function Wh(i,t){const r=Nc(i.i,i.x,i.y),s=Nc(t.i,t.x,t.y),l=i.next,u=t.prev;return i.next=t,t.prev=i,r.next=l,l.prev=r,s.next=r,r.prev=s,u.next=s,s.prev=u,s}function Kh(i,t,r,s){const l=Nc(i,t,r);return s?(l.next=s.next,l.prev=s,s.next.prev=l,s.next=l):(l.prev=l,l.next=l),l}function Fo(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Nc(i,t,r){return{i,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Uc(i,t,r){const s=r.patternDependencies;let l=!1;for(const u of t){const d=u.paint.get(`${i}-pattern`);d.isConstant()||(l=!0);const f=d.constantOr(null);f&&(l=!0,s[f.to]=!0,s[f.from]=!0)}return l}function jc(i,t,r,s,l){const u=l.patternDependencies;for(const d of t){const f=d.paint.get(`${i}-pattern`).value;if(f.kind!=="constant"){let g=f.evaluate({zoom:s-1},r,{},l.availableImages),x=f.evaluate({zoom:s},r,{},l.availableImages),v=f.evaluate({zoom:s+1},r,{},l.availableImages);g=g&&g.name?g.name:g,x=x&&x.name?x.name:x,v=v&&v.name?v.name:v,u[g]=!0,u[x]=!0,u[v]=!0,r.patterns[d.id]={min:g,mid:x,max:v}}}return r}class $c{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Dr,this.indexArray=new gr,this.indexArray2=new ei,this.programConfigurations=new Fs(t.layers,t.zoom),this.segments=new at,this.segments2=new at,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.hasPattern=Uc("fill",this.layers,r);const l=this.layers[0].layout.get("fill-sort-key"),u=!l.isConstant(),d=[];for(const{feature:f,id:g,index:x,sourceLayerIndex:v}of t){const w=this.layers[0]._featureFilter.needGeometry,I=Vs(f,w);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom),I,s))continue;const C=u?l.evaluate(I,{},s,r.availableImages):void 0,E={id:g,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?I.geometry:Os(f),patterns:{},sortKey:C};d.push(E)}u&&d.sort((f,g)=>f.sortKey-g.sortKey);for(const f of d){const{geometry:g,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){const w=jc("fill",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,g,x,s,{});r.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Gd),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,r,s,l,u){for(const d of Ys(r,500)){let f=0;for(const C of d)f+=C.length;const g=this.segments.prepareSegment(f,this.layoutVertexArray,this.indexArray),x=g.vertexLength,v=[],w=[];for(const C of d){if(C.length===0)continue;C!==d[0]&&w.push(v.length/2);const E=this.segments2.prepareSegment(C.length,this.layoutVertexArray,this.indexArray2),z=E.vertexLength;this.layoutVertexArray.emplaceBack(C[0].x,C[0].y),this.indexArray2.emplaceBack(z+C.length-1,z),v.push(C[0].x),v.push(C[0].y);for(let O=1;O>3}if(l--,s===1||s===2)u+=i.readSVarint(),d+=i.readSVarint(),s===1&&(t&&f.push(t),t=[]),t.push(new op(u,d));else{if(s!==7)throw new Error("unknown command "+s);t&&t.push(t[0].clone())}}return t&&f.push(t),f},Ma.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var t=i.readVarint()+i.pos,r=1,s=0,l=0,u=0,d=1/0,f=-1/0,g=1/0,x=-1/0;i.pos>3}if(s--,r===1||r===2)(l+=i.readSVarint())f&&(f=l),(u+=i.readSVarint())x&&(x=u);else if(r!==7)throw new Error("unknown command "+r)}return[d,g,f,x]},Ma.prototype.toGeoJSON=function(i,t,r){var s,l,u=this.extent*Math.pow(2,r),d=this.extent*i,f=this.extent*t,g=this.loadGeometry(),x=Ma.types[this.type];function v(C){for(var E=0;E>3;l=d===1?s.readString():d===2?s.readFloat():d===3?s.readDouble():d===4?s.readVarint64():d===5?s.readVarint():d===6?s.readSVarint():d===7?s.readBoolean():null}return l}(r))}tu.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var t=this._pbf.readVarint()+this._pbf.pos;return new hp(this._pbf,t,this.extent,this._keys,this._values)};var dp=eu;function pp(i,t,r){if(i===3){var s=new dp(r,r.readVarint()+r.pos);s.length&&(t[s.name]=s)}}as.VectorTile=function(i,t){this.layers=i.readFields(pp,{},t)},as.VectorTileFeature=Qh,as.VectorTileLayer=eu;const fp=as.VectorTileFeature.types,qc=Math.pow(2,13);function Oo(i,t,r,s,l,u,d,f){i.emplaceBack(t,r,2*Math.floor(s*qc)+d,l*qc*2,u*qc*2,Math.round(f))}class Zc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new es,this.centroidVertexArray=new li,this.indexArray=new gr,this.programConfigurations=new Fs(t.layers,t.zoom),this.segments=new at,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.features=[],this.hasPattern=Uc("fill-extrusion",this.layers,r);for(const{feature:l,id:u,index:d,sourceLayerIndex:f}of t){const g=this.layers[0]._featureFilter.needGeometry,x=Vs(l,g);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom),x,s))continue;const v={id:u,sourceLayerIndex:f,index:d,geometry:g?x.geometry:Os(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(jc("fill-extrusion",this.layers,v,this.zoom,r)):this.addFeature(v,v.geometry,d,s,{}),r.featureIndex.insert(l,v.geometry,d,f,this.index,!0)}}addFeatures(t,r,s){for(const l of this.features){const{geometry:u}=l;this.addFeature(l,u,l.index,r,s)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ap),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,sp.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,r,s,l,u){for(const d of Ys(r,500)){const f={x:0,y:0,vertexCount:0};let g=0;for(const E of d)g+=E.length;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const E of d){if(E.length===0||gp(E))continue;let z=0;for(let O=0;O=1){const re=E[O-1];if(!mp($,re)){x.vertexLength+4>at.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const W=$.sub(re)._perp()._unit(),te=re.dist($);z+te>32768&&(z=0),Oo(this.layoutVertexArray,$.x,$.y,W.x,W.y,0,0,z),Oo(this.layoutVertexArray,$.x,$.y,W.x,W.y,0,1,z),f.x+=2*$.x,f.y+=2*$.y,f.vertexCount+=2,z+=te,Oo(this.layoutVertexArray,re.x,re.y,W.x,W.y,0,0,z),Oo(this.layoutVertexArray,re.x,re.y,W.x,W.y,0,1,z),f.x+=2*re.x,f.y+=2*re.y,f.vertexCount+=2;const ce=x.vertexLength;this.indexArray.emplaceBack(ce,ce+2,ce+1),this.indexArray.emplaceBack(ce+1,ce+2,ce+3),x.vertexLength+=4,x.primitiveLength+=2}}}}if(x.vertexLength+g>at.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(g,this.layoutVertexArray,this.indexArray)),fp[t.type]!=="Polygon")continue;const v=[],w=[],I=x.vertexLength;for(const E of d)if(E.length!==0){E!==d[0]&&w.push(v.length/2);for(let z=0;z$t)||i.y===t.y&&(i.y<0||i.y>$t)}function gp(i){return i.every(t=>t.x<0)||i.every(t=>t.x>$t)||i.every(t=>t.y<0)||i.every(t=>t.y>$t)}let iu;ze("FillExtrusionBucket",Zc,{omit:["layers","features"]});var _p={get paint(){return iu=iu||new h({"fill-extrusion-opacity":new Le(le["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new je(le["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Le(le["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Le(le["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ya(le["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new je(le["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new je(le["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Le(le["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class yp extends n{constructor(t){super(t,_p)}createBucket(t){return new Zc(t)}queryRadius(){return Bl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,r,s,l,u,d,f,g){const x=Fl(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),d.angle,f),v=this.paint.get("fill-extrusion-height").evaluate(r,s),w=this.paint.get("fill-extrusion-base").evaluate(r,s),I=function(E,z,O,$){const re=[];for(const W of E){const te=[W.x,W.y,0,1];Ol(te,te,z),re.push(new ue(te[0]/te[3],te[1]/te[3]))}return re}(x,g),C=function(E,z,O,$){const re=[],W=[],te=$[8]*z,ce=$[9]*z,ge=$[10]*z,Me=$[11]*z,Ue=$[8]*O,Ae=$[9]*O,Ie=$[10]*O,Fe=$[11]*O;for(const De of E){const Ee=[],pe=[];for(const Oe of De){const Be=Oe.x,Ze=Oe.y,xt=$[0]*Be+$[4]*Ze+$[12],yt=$[1]*Be+$[5]*Ze+$[13],Xt=$[2]*Be+$[6]*Ze+$[14],Lr=$[3]*Be+$[7]*Ze+$[15],ui=Xt+ge,Wt=Lr+Me,Di=xt+Ue,Li=yt+Ae,Ri=Xt+Ie,Ft=Lr+Fe,Kt=new ue((xt+te)/Wt,(yt+ce)/Wt);Kt.z=ui/Wt,Ee.push(Kt);const Ti=new ue(Di/Ft,Li/Ft);Ti.z=Ri/Ft,pe.push(Ti)}re.push(Ee),W.push(pe)}return[re,W]}(l,w,v,g);return function(E,z,O){let $=1/0;Lh(O,z)&&($=ru(O,z[0]));for(let re=0;rer.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new va,this.layoutVertexArray2=new ts,this.indexArray=new gr,this.programConfigurations=new Fs(t.layers,t.zoom),this.segments=new at,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.hasPattern=Uc("line",this.layers,r);const l=this.layers[0].layout.get("line-sort-key"),u=!l.isConstant(),d=[];for(const{feature:f,id:g,index:x,sourceLayerIndex:v}of t){const w=this.layers[0]._featureFilter.needGeometry,I=Vs(f,w);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom),I,s))continue;const C=u?l.evaluate(I,{},s):void 0,E={id:g,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?I.geometry:Os(f),patterns:{},sortKey:C};d.push(E)}u&&d.sort((f,g)=>f.sortKey-g.sortKey);for(const f of d){const{geometry:g,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){const w=jc("line",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,g,x,s,{});r.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,wp)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,vp),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,r,s,l,u){const d=this.layers[0].layout,f=d.get("line-join").evaluate(t,{}),g=d.get("line-cap"),x=d.get("line-miter-limit"),v=d.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const w of r)this.addLine(w,t,f,g,x,v);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,u,l)}addLine(t,r,s,l,u,d){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let $=0;$=2&&t[g-1].equals(t[g-2]);)g--;let x=0;for(;x0;if(Me&&$>x){const Fe=I.dist(C);if(Fe>2*v){const De=I.sub(I.sub(C)._mult(v/Fe)._round());this.updateDistance(C,De),this.addCurrentVertex(De,z,0,0,w),C=De}}const Ae=C&&E;let Ie=Ae?s:f?"butt":l;if(Ae&&Ie==="round"&&(ceu&&(Ie="bevel"),Ie==="bevel"&&(ce>2&&(Ie="flipbevel"),ce100)re=O.mult(-1);else{const Fe=ce*z.add(O).mag()/z.sub(O).mag();re._perp()._mult(Fe*(Ue?-1:1))}this.addCurrentVertex(I,re,0,0,w),this.addCurrentVertex(I,re.mult(-1),0,0,w)}else if(Ie==="bevel"||Ie==="fakeround"){const Fe=-Math.sqrt(ce*ce-1),De=Ue?Fe:0,Ee=Ue?0:Fe;if(C&&this.addCurrentVertex(I,z,De,Ee,w),Ie==="fakeround"){const pe=Math.round(180*ge/Math.PI/20);for(let Oe=1;Oe2*v){const De=I.add(E.sub(I)._mult(v/Fe)._round());this.updateDistance(I,De),this.addCurrentVertex(De,O,0,0,w),I=De}}}}addCurrentVertex(t,r,s,l,u,d=!1){const f=r.y*l-r.x,g=-r.y-r.x*l;this.addHalfVertex(t,r.x+r.y*s,r.y-r.x*s,d,!1,s,u),this.addHalfVertex(t,f,g,d,!0,-l,u),this.distance>nu/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,r,s,l,u,d))}addHalfVertex({x:t,y:r},s,l,u,d,f,g){const x=.5*(this.lineClips?this.scaledDistance*(nu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(u?1:0),(r<<1)+(d?1:0),Math.round(63*s)+128,Math.round(63*l)+128,1+(f===0?0:f<0?-1:1)|(63&x)<<2,x>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const v=g.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,v),g.primitiveLength++),d?this.e2=v:this.e1=v}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,r){this.distance+=t.dist(r),this.updateScaledDistance()}}let su,au;ze("LineBucket",Gc,{omit:["layers","patternFeatures"]});var ou={get paint(){return au=au||new h({"line-opacity":new je(le.paint_line["line-opacity"]),"line-color":new je(le.paint_line["line-color"]),"line-translate":new Le(le.paint_line["line-translate"]),"line-translate-anchor":new Le(le.paint_line["line-translate-anchor"]),"line-width":new je(le.paint_line["line-width"]),"line-gap-width":new je(le.paint_line["line-gap-width"]),"line-offset":new je(le.paint_line["line-offset"]),"line-blur":new je(le.paint_line["line-blur"]),"line-dasharray":new xa(le.paint_line["line-dasharray"]),"line-pattern":new ya(le.paint_line["line-pattern"]),"line-gradient":new Mo(le.paint_line["line-gradient"])})},get layout(){return su=su||new h({"line-cap":new Le(le.layout_line["line-cap"]),"line-join":new je(le.layout_line["line-join"]),"line-miter-limit":new Le(le.layout_line["line-miter-limit"]),"line-round-limit":new Le(le.layout_line["line-round-limit"]),"line-sort-key":new je(le.layout_line["line-sort-key"])})}};class Ip extends je{possiblyEvaluate(t,r){return r=new wt(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(t,r)}evaluate(t,r,s,l){return r=gi({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(t,r,s,l)}}let jl;class Pp extends n{constructor(t){super(t,ou),this.gradientVersion=0,jl||(jl=new Ip(ou.paint.properties["line-width"].specification),jl.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){const r=this.gradientExpression();this.stepInterpolant=!!function(s){return s._styleExpression!==void 0}(r)&&r._styleExpression.expression instanceof Rn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,r){super.recalculate(t,r),this.paint._values["line-floorwidth"]=jl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Gc(t)}queryRadius(t){const r=t,s=lu(zo("line-width",this,r),zo("line-gap-width",this,r)),l=zo("line-offset",this,r);return s/2+Math.abs(l)+Bl(this.paint.get("line-translate"))}queryIntersectsFeature(t,r,s,l,u,d,f){const g=Fl(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),d.angle,f),x=f/2*lu(this.paint.get("line-width").evaluate(r,s),this.paint.get("line-gap-width").evaluate(r,s)),v=this.paint.get("line-offset").evaluate(r,s);return v&&(l=function(w,I){const C=[];for(let E=0;E=3){for(let O=0;O0?t+2*i:i}const Ap=m([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Cp=m([{name:"a_projected_pos",components:3,type:"Float32"}],4);m([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Mp=m([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);m([{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 cu=m([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),kp=m([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Ep(i,t,r){return i.sections.forEach(s=>{s.text=function(l,u,d){const f=u.layout.get("text-transform").evaluate(d,{});return f==="uppercase"?l=l.toLocaleUpperCase():f==="lowercase"&&(l=l.toLocaleLowerCase()),qi.applyArabicShaping&&(l=qi.applyArabicShaping(l)),l}(s.text,t,r)}),i}m([{name:"triangle",components:3,type:"Uint16"}]),m([{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"}]),m([{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"}]),m([{type:"Float32",name:"offsetX"}]),m([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),m([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const No={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Zt=24,hu=_t,uu=function(i,t,r,s,l){var u,d,f=8*l-s-1,g=(1<>1,v=-7,w=l-1,I=-1,C=i[t+w];for(w+=I,u=C&(1<<-v)-1,C>>=-v,v+=f;v>0;u=256*u+i[t+w],w+=I,v-=8);for(d=u&(1<<-v)-1,u>>=-v,v+=s;v>0;d=256*d+i[t+w],w+=I,v-=8);if(u===0)u=1-x;else{if(u===g)return d?NaN:1/0*(C?-1:1);d+=Math.pow(2,s),u-=x}return(C?-1:1)*d*Math.pow(2,u-s)},du=function(i,t,r,s,l,u){var d,f,g,x=8*u-l-1,v=(1<>1,I=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,C=0,E=1,z=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,d=v):(d=Math.floor(Math.log(t)/Math.LN2),t*(g=Math.pow(2,-d))<1&&(d--,g*=2),(t+=d+w>=1?I/g:I*Math.pow(2,1-w))*g>=2&&(d++,g/=2),d+w>=v?(f=0,d=v):d+w>=1?(f=(t*g-1)*Math.pow(2,l),d+=w):(f=t*Math.pow(2,w-1)*Math.pow(2,l),d=0));l>=8;i[r+C]=255&f,C+=E,f/=256,l-=8);for(d=d<0;i[r+C]=255&d,C+=E,d/=256,x-=8);i[r+C-E]|=128*z};function _t(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}_t.Varint=0,_t.Fixed64=1,_t.Bytes=2,_t.Fixed32=5;var Hc=4294967296,pu=1/Hc,fu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function An(i){return i.type===_t.Bytes?i.readVarint()+i.pos:i.pos+1}function ka(i,t,r){return r?4294967296*t+(i>>>0):4294967296*(t>>>0)+(i>>>0)}function mu(i,t,r){var s=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(s);for(var l=r.pos-1;l>=i;l--)r.buf[l+s]=r.buf[l]}function zp(i,t){for(var r=0;r>>8,i[r+2]=t>>>16,i[r+3]=t>>>24}function gu(i,t){return(i[t]|i[t+1]<<8|i[t+2]<<16)+(i[t+3]<<24)}_t.prototype={destroy:function(){this.buf=null},readFields:function(i,t,r){for(r=r||this.length;this.pos>3,u=this.pos;this.type=7&s,i(l,t,this),this.pos===u&&this.skip(s)}return t},readMessage:function(i,t){return this.readFields(i,t,this.readVarint()+this.pos)},readFixed32:function(){var i=$l(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=gu(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=$l(this.buf,this.pos)+$l(this.buf,this.pos+4)*Hc;return this.pos+=8,i},readSFixed64:function(){var i=$l(this.buf,this.pos)+gu(this.buf,this.pos+4)*Hc;return this.pos+=8,i},readFloat:function(){var i=uu(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=uu(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var t,r,s=this.buf;return t=127&(r=s[this.pos++]),r<128?t:(t|=(127&(r=s[this.pos++]))<<7,r<128?t:(t|=(127&(r=s[this.pos++]))<<14,r<128?t:(t|=(127&(r=s[this.pos++]))<<21,r<128?t:function(l,u,d){var f,g,x=d.buf;if(f=(112&(g=x[d.pos++]))>>4,g<128||(f|=(127&(g=x[d.pos++]))<<3,g<128)||(f|=(127&(g=x[d.pos++]))<<10,g<128)||(f|=(127&(g=x[d.pos++]))<<17,g<128)||(f|=(127&(g=x[d.pos++]))<<24,g<128)||(f|=(1&(g=x[d.pos++]))<<31,g<128))return ka(l,f,u);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(r=s[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?(i+1)/-2:i/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var i=this.readVarint()+this.pos,t=this.pos;return this.pos=i,i-t>=12&&fu?function(r,s,l){return fu.decode(r.subarray(s,l))}(this.buf,t,i):function(r,s,l){for(var u="",d=s;d239?4:v>223?3:v>191?2:1;if(d+I>l)break;I===1?v<128&&(w=v):I===2?(192&(f=r[d+1]))==128&&(w=(31&v)<<6|63&f)<=127&&(w=null):I===3?(g=r[d+2],(192&(f=r[d+1]))==128&&(192&g)==128&&((w=(15&v)<<12|(63&f)<<6|63&g)<=2047||w>=55296&&w<=57343)&&(w=null)):I===4&&(g=r[d+2],x=r[d+3],(192&(f=r[d+1]))==128&&(192&g)==128&&(192&x)==128&&((w=(15&v)<<18|(63&f)<<12|(63&g)<<6|63&x)<=65535||w>=1114112)&&(w=null)),w===null?(w=65533,I=1):w>65535&&(w-=65536,u+=String.fromCharCode(w>>>10&1023|55296),w=56320|1023&w),u+=String.fromCharCode(w),d+=I}return u}(this.buf,t,i)},readBytes:function(){var i=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,i);return this.pos=i,t},readPackedVarint:function(i,t){if(this.type!==_t.Bytes)return i.push(this.readVarint(t));var r=An(this);for(i=i||[];this.pos127;);else if(t===_t.Bytes)this.pos=this.readVarint()+this.pos;else if(t===_t.Fixed32)this.pos+=4;else{if(t!==_t.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(i,t){this.writeVarint(i<<3|t)},realloc:function(i){for(var t=this.length||16;t268435455||i<0?function(t,r){var s,l;if(t>=0?(s=t%4294967296|0,l=t/4294967296|0):(l=~(-t/4294967296),4294967295^(s=~(-t%4294967296))?s=s+1|0:(s=0,l=l+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(u,d,f){f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,f.buf[f.pos]=127&(u>>>=7)}(s,0,r),function(u,d){var f=(7&u)<<4;d.buf[d.pos++]|=f|((u>>>=3)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u)))))}(l,r)}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(!!i)},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var t=this.pos;this.pos=function(s,l,u){for(var d,f,g=0;g55295&&d<57344){if(!f){d>56319||g+1===l.length?(s[u++]=239,s[u++]=191,s[u++]=189):f=d;continue}if(d<56320){s[u++]=239,s[u++]=191,s[u++]=189,f=d;continue}d=f-55296<<10|d-56320|65536,f=null}else f&&(s[u++]=239,s[u++]=191,s[u++]=189,f=null);d<128?s[u++]=d:(d<2048?s[u++]=d>>6|192:(d<65536?s[u++]=d>>12|224:(s[u++]=d>>18|240,s[u++]=d>>12&63|128),s[u++]=d>>6&63|128),s[u++]=63&d|128)}return u}(this.buf,i,this.pos);var r=this.pos-t;r>=128&&mu(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),du(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),du(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var t=i.length;this.writeVarint(t),this.realloc(t);for(var r=0;r=128&&mu(r,s,this),this.pos=r-1,this.writeVarint(s),this.pos+=s},writeMessage:function(i,t,r){this.writeTag(i,_t.Bytes),this.writeRawMessage(t,r)},writePackedVarint:function(i,t){t.length&&this.writeMessage(i,zp,t)},writePackedSVarint:function(i,t){t.length&&this.writeMessage(i,Dp,t)},writePackedBoolean:function(i,t){t.length&&this.writeMessage(i,Bp,t)},writePackedFloat:function(i,t){t.length&&this.writeMessage(i,Lp,t)},writePackedDouble:function(i,t){t.length&&this.writeMessage(i,Rp,t)},writePackedFixed32:function(i,t){t.length&&this.writeMessage(i,Fp,t)},writePackedSFixed32:function(i,t){t.length&&this.writeMessage(i,Op,t)},writePackedFixed64:function(i,t){t.length&&this.writeMessage(i,Vp,t)},writePackedSFixed64:function(i,t){t.length&&this.writeMessage(i,Np,t)},writeBytesField:function(i,t){this.writeTag(i,_t.Bytes),this.writeBytes(t)},writeFixed32Field:function(i,t){this.writeTag(i,_t.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(i,t){this.writeTag(i,_t.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(i,t){this.writeTag(i,_t.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(i,t){this.writeTag(i,_t.Fixed64),this.writeSFixed64(t)},writeVarintField:function(i,t){this.writeTag(i,_t.Varint),this.writeVarint(t)},writeSVarintField:function(i,t){this.writeTag(i,_t.Varint),this.writeSVarint(t)},writeStringField:function(i,t){this.writeTag(i,_t.Bytes),this.writeString(t)},writeFloatField:function(i,t){this.writeTag(i,_t.Fixed32),this.writeFloat(t)},writeDoubleField:function(i,t){this.writeTag(i,_t.Fixed64),this.writeDouble(t)},writeBooleanField:function(i,t){this.writeVarintField(i,!!t)}};var Xc=Je(hu);const Wc=3;function Up(i,t,r){i===1&&r.readMessage(jp,t)}function jp(i,t,r){if(i===3){const{id:s,bitmap:l,width:u,height:d,left:f,top:g,advance:x}=r.readMessage($p,{});t.push({id:s,bitmap:new Lo({width:u+2*Wc,height:d+2*Wc},l),metrics:{width:u,height:d,left:f,top:g,advance:x}})}}function $p(i,t,r){i===1?t.id=r.readVarint():i===2?t.bitmap=r.readBytes():i===3?t.width=r.readVarint():i===4?t.height=r.readVarint():i===5?t.left=r.readSVarint():i===6?t.top=r.readSVarint():i===7&&(t.advance=r.readVarint())}const _u=Wc;function yu(i){let t=0,r=0;for(const d of i)t+=d.w*d.h,r=Math.max(r,d.w);i.sort((d,f)=>f.h-d.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}];let l=0,u=0;for(const d of i)for(let f=s.length-1;f>=0;f--){const g=s[f];if(!(d.w>g.w||d.h>g.h)){if(d.x=g.x,d.y=g.y,u=Math.max(u,d.y+d.h),l=Math.max(l,d.x+d.w),d.w===g.w&&d.h===g.h){const x=s.pop();f=0&&s>=t&&Zl[this.text.charCodeAt(s)];s--)r--;this.text=this.text.substring(t,r),this.sectionIndex=this.sectionIndex.slice(t,r)}substring(t,r){const s=new za;return s.text=this.text.substring(t,r),s.sectionIndex=this.sectionIndex.slice(t,r),s.sections=this.sections,s}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,r)=>Math.max(t,this.sections[r].scale),0)}addTextSection(t,r){this.text+=t.text,this.sections.push(jo.forText(t.scale,t.fontStack||r));const s=this.sections.length-1;for(let l=0;l=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ql(i,t,r,s,l,u,d,f,g,x,v,w,I,C,E){const z=za.fromFeature(i,l);let O;w===M.ah.vertical&&z.verticalizePunctuation();const{processBidirectionalText:$,processStyledBidirectionalText:re}=qi;if($&&z.sections.length===1){O=[];const ce=$(z.toString(),Jc(z,x,u,t,s,C));for(const ge of ce){const Me=new za;Me.text=ge,Me.sections=z.sections;for(let Ue=0;Ue0&&Cn>pi&&(pi=Cn)}else{const vr=Me[ht.fontStack],ti=vr&&vr[Pt];if(ti&&ti.rect)Ba=ti.rect,Dt=ti.metrics;else{const Cn=ge[ht.fontStack],Xo=Cn&&Cn[Pt];if(!Xo)continue;Dt=Xo.metrics}sr=(Kt-ht.scale)*Zt}Rr?(ce.verticalizable=!0,Bi.push({glyph:Pt,imageName:sn,x:Ze,y:xt+sr,vertical:Rr,scale:ht.scale,fontStack:ht.fontStack,sectionIndex:bt,metrics:Dt,rect:Ba}),Ze+=an*ht.scale+pe):(Bi.push({glyph:Pt,imageName:sn,x:Ze,y:xt+sr,vertical:Rr,scale:ht.scale,fontStack:ht.fontStack,sectionIndex:bt,metrics:Dt,rect:Ba}),Ze+=Dt.advance*ht.scale+pe)}Bi.length!==0&&(yt=Math.max(Ze-pe,yt),Hp(Bi,0,Bi.length-1,Lr,pi)),Ze=0;const xr=Ie*Kt+pi;di.lineOffset=Math.max(pi,Ti),xt+=xr,Xt=Math.max(xr,Xt),++ui}var Wt;const Di=xt-Uo,{horizontalAlign:Li,verticalAlign:Ri}=Yc(Fe);(function(Ft,Kt,Ti,di,Bi,pi,xr,Hi,ht){const bt=(Kt-Ti)*Bi;let Pt=0;Pt=pi!==xr?-Hi*di-Uo:(-di*ht+.5)*xr;for(const sr of Ft)for(const Dt of sr.positionedGlyphs)Dt.x+=bt,Dt.y+=Pt})(ce.positionedLines,Lr,Li,Ri,yt,Xt,Ie,Di,Ae.length),ce.top+=-Ri*Di,ce.bottom=ce.top+Di,ce.left+=-Li*yt,ce.right=ce.left+yt}(te,t,r,s,O,d,f,g,w,x,I,E),!function(ce){for(const ge of ce)if(ge.positionedGlyphs.length!==0)return!1;return!0}(W)&&te}const Zl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},qp={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Zp={40:!0};function vu(i,t,r,s,l,u){if(t.imageName){const d=s[t.imageName];return d?d.displaySize[0]*t.scale*Zt/u+l:0}{const d=r[t.fontStack],f=d&&d[i];return f?f.metrics.advance*t.scale+l:0}}function bu(i,t,r,s){const l=Math.pow(i-t,2);return s?i=0;let x=0;for(let w=0;wx){const v=Math.ceil(u/x);l*=v/d,d=v}return{x1:s,y1:l,x2:s+u,y2:l+d}}function Iu(i,t,r,s,l,u){const d=i.image;let f;if(d.content){const O=d.content,$=d.pixelRatio||1;f=[O[0]/$,O[1]/$,d.displaySize[0]-O[2]/$,d.displaySize[1]-O[3]/$]}const g=t.left*u,x=t.right*u;let v,w,I,C;r==="width"||r==="both"?(C=l[0]+g-s[3],w=l[0]+x+s[1]):(C=l[0]+(g+x-d.displaySize[0])/2,w=C+d.displaySize[0]);const E=t.top*u,z=t.bottom*u;return r==="height"||r==="both"?(v=l[1]+E-s[0],I=l[1]+z+s[2]):(v=l[1]+(E+z-d.displaySize[1])/2,I=v+d.displaySize[1]),{image:d,top:v,right:w,bottom:I,left:C,collisionPadding:f}}const $o=255,nn=128,ls=$o*nn;function Pu(i,t){const{expression:r}=t;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new wt(i+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:l}=r;let u=0;for(;ud.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Rc([]),this.placementViewportMatrix=Rc([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pu(this.zoom,r["text-size"]),this.iconSizeData=Pu(this.zoom,r["icon-size"]);const s=this.layers[0].layout,l=s.get("symbol-sort-key"),u=s.get("symbol-z-order");this.canOverlap=Qc(s,"text-overlap","text-allow-overlap")!=="never"||Qc(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=u!=="viewport-y"&&!l.isConstant(),this.sortFeaturesByY=(u==="viewport-y"||u==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map(d=>M.ah[d])),this.stateDependentLayerIds=this.layers.filter(d=>d.isStateDependent()).map(d=>d.id),this.sourceID=t.sourceID}createArrays(){this.text=new th(new Fs(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new th(new Fs(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new St,this.lineVertexArray=new oi,this.symbolInstances=new nt,this.textAnchorOffsets=new It}calculateGlyphDependencies(t,r,s,l,u){for(let d=0;d0)&&(d.value.kind!=="constant"||d.value.value.length>0),v=g.value.kind!=="constant"||!!g.value.value||Object.keys(g.parameters).length>0,w=u.get("symbol-sort-key");if(this.features=[],!x&&!v)return;const I=r.iconDependencies,C=r.glyphDependencies,E=r.availableImages,z=new wt(this.zoom);for(const{feature:O,id:$,index:re,sourceLayerIndex:W}of t){const te=l._featureFilter.needGeometry,ce=Vs(O,te);if(!l._featureFilter.filter(z,ce,s))continue;let ge,Me;if(te||(ce.geometry=Os(O)),x){const Ae=l.getValueAndResolveTokens("text-field",ce,s,E),Ie=Ni.factory(Ae),Fe=this.hasRTLText=this.hasRTLText||Jp(Ie);(!Fe||qi.getRTLTextPluginStatus()==="unavailable"||Fe&&qi.isParsed())&&(ge=Ep(Ie,l,ce))}if(v){const Ae=l.getValueAndResolveTokens("icon-image",ce,s,E);Me=Ae instanceof ji?Ae:ji.fromString(Ae)}if(!ge&&!Me)continue;const Ue=this.sortFeaturesByKey?w.evaluate(ce,{},s):void 0;if(this.features.push({id:$,text:ge,icon:Me,index:re,sourceLayerIndex:W,geometry:ce.geometry,properties:O.properties,type:Wp[O.type],sortKey:Ue}),Me&&(I[Me.name]=!0),ge){const Ae=d.evaluate(ce,{},s).join(","),Ie=u.get("text-rotation-alignment")!=="viewport"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(M.ah.vertical)>=0;for(const Fe of ge.sections)if(Fe.image)I[Fe.image.name]=!0;else{const De=Io(ge.toString()),Ee=Fe.fontStack||Ae,pe=C[Ee]=C[Ee]||{};this.calculateGlyphDependencies(Fe.text,pe,Ie,this.allowVerticalPlacement,De)}}}u.get("symbol-placement")==="line"&&(this.features=function(O){const $={},re={},W=[];let te=0;function ce(Ae){W.push(O[Ae]),te++}function ge(Ae,Ie,Fe){const De=re[Ae];return delete re[Ae],re[Ie]=De,W[De].geometry[0].pop(),W[De].geometry[0]=W[De].geometry[0].concat(Fe[0]),De}function Me(Ae,Ie,Fe){const De=$[Ie];return delete $[Ie],$[Ae]=De,W[De].geometry[0].shift(),W[De].geometry[0]=Fe[0].concat(W[De].geometry[0]),De}function Ue(Ae,Ie,Fe){const De=Fe?Ie[0][Ie[0].length-1]:Ie[0][0];return`${Ae}:${De.x}:${De.y}`}for(let Ae=0;AeAe.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((O,$)=>O.sortKey-$.sortKey)}update(t,r,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,r,this.layers,s),this.icon.programConfigurations.updatePaintArrays(t,r,this.layers,s))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,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(t,r){const s=this.lineVertexArray.length;if(t.segment!==void 0){let l=t.dist(r[t.segment+1]),u=t.dist(r[t.segment]);const d={};for(let f=t.segment+1;f=0;f--)d[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:u},f>0&&(u+=r[f-1].dist(r[f]));for(let f=0;f0}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(t,r){const s=t.placedSymbolArray.get(r),l=s.vertexStartIndex+4*s.numGlyphs;for(let u=s.vertexStartIndex;ul[f]-l[g]||u[g]-u[f]),d}addToSortKeyRanges(t,r){const s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===r?s.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const r of this.symbolInstanceIndexes){const s=this.symbolInstances.get(r);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach((l,u,d)=>{l>=0&&d.indexOf(l)===u&&this.addIndicesForPlacedSymbol(this.text,l)}),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 Au,Cu;ze("SymbolBucket",Da,{omit:["layers","collisionBoxArray","features","compareText"]}),Da.MAX_GLYPHS=65535,Da.addDynamicAttributes=eh;var rh={get paint(){return Cu=Cu||new h({"icon-opacity":new je(le.paint_symbol["icon-opacity"]),"icon-color":new je(le.paint_symbol["icon-color"]),"icon-halo-color":new je(le.paint_symbol["icon-halo-color"]),"icon-halo-width":new je(le.paint_symbol["icon-halo-width"]),"icon-halo-blur":new je(le.paint_symbol["icon-halo-blur"]),"icon-translate":new Le(le.paint_symbol["icon-translate"]),"icon-translate-anchor":new Le(le.paint_symbol["icon-translate-anchor"]),"text-opacity":new je(le.paint_symbol["text-opacity"]),"text-color":new je(le.paint_symbol["text-color"],{runtimeType:Ci,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new je(le.paint_symbol["text-halo-color"]),"text-halo-width":new je(le.paint_symbol["text-halo-width"]),"text-halo-blur":new je(le.paint_symbol["text-halo-blur"]),"text-translate":new Le(le.paint_symbol["text-translate"]),"text-translate-anchor":new Le(le.paint_symbol["text-translate-anchor"])})},get layout(){return Au=Au||new h({"symbol-placement":new Le(le.layout_symbol["symbol-placement"]),"symbol-spacing":new Le(le.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Le(le.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new je(le.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Le(le.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Le(le.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Le(le.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Le(le.layout_symbol["icon-ignore-placement"]),"icon-optional":new Le(le.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Le(le.layout_symbol["icon-rotation-alignment"]),"icon-size":new je(le.layout_symbol["icon-size"]),"icon-text-fit":new Le(le.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Le(le.layout_symbol["icon-text-fit-padding"]),"icon-image":new je(le.layout_symbol["icon-image"]),"icon-rotate":new je(le.layout_symbol["icon-rotate"]),"icon-padding":new je(le.layout_symbol["icon-padding"]),"icon-keep-upright":new Le(le.layout_symbol["icon-keep-upright"]),"icon-offset":new je(le.layout_symbol["icon-offset"]),"icon-anchor":new je(le.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Le(le.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Le(le.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Le(le.layout_symbol["text-rotation-alignment"]),"text-field":new je(le.layout_symbol["text-field"]),"text-font":new je(le.layout_symbol["text-font"]),"text-size":new je(le.layout_symbol["text-size"]),"text-max-width":new je(le.layout_symbol["text-max-width"]),"text-line-height":new Le(le.layout_symbol["text-line-height"]),"text-letter-spacing":new je(le.layout_symbol["text-letter-spacing"]),"text-justify":new je(le.layout_symbol["text-justify"]),"text-radial-offset":new je(le.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Le(le.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new je(le.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new je(le.layout_symbol["text-anchor"]),"text-max-angle":new Le(le.layout_symbol["text-max-angle"]),"text-writing-mode":new Le(le.layout_symbol["text-writing-mode"]),"text-rotate":new je(le.layout_symbol["text-rotate"]),"text-padding":new Le(le.layout_symbol["text-padding"]),"text-keep-upright":new Le(le.layout_symbol["text-keep-upright"]),"text-transform":new je(le.layout_symbol["text-transform"]),"text-offset":new je(le.layout_symbol["text-offset"]),"text-allow-overlap":new Le(le.layout_symbol["text-allow-overlap"]),"text-overlap":new Le(le.layout_symbol["text-overlap"]),"text-ignore-placement":new Le(le.layout_symbol["text-ignore-placement"]),"text-optional":new Le(le.layout_symbol["text-optional"])})}};class Mu{constructor(t){if(t.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Jr,this.defaultValue=t}evaluate(t){if(t.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(t.formattedSection))return r.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ze("FormatSectionOverride",Mu,{omit:["defaultValue"]});class Hl extends n{constructor(t){super(t,rh)}recalculate(t,r){if(super.recalculate(t,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const s=this.layout.get("text-writing-mode");if(s){const l=[];for(const u of s)l.indexOf(u)<0&&l.push(u);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,r,s,l){const u=this.layout.get(t).evaluate(r,{},s,l),d=this._unevaluatedLayout._values[t];return d.isDataDriven()||aa(d.value)||!u?u:function(f,g){return g.replace(/{([^{}]+)}/g,(x,v)=>f&&v in f?String(f[v]):"")}(r.properties,u)}createBucket(t){return new Da(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of rh.paint.overridableProperties){if(!Hl.hasPaintOverride(this.layout,t))continue;const r=this.paint.get(t),s=new Mu(r),l=new sa(s,r.property.specification);let u=null;u=r.value.kind==="constant"||r.value.kind==="source"?new qn("source",l):new Zn("composite",l,r.value.zoomStops),this.paint._values[t]=new zr(r.property,u,r.parameters)}}_handleOverridablePaintPropertyUpdate(t,r,s){return!(!this.layout||r.isDataDriven()||s.isDataDriven())&&Hl.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,r){const s=t.get("text-field"),l=rh.paint.properties[r];let u=!1;const d=f=>{for(const g of f)if(l.overrides&&l.overrides.hasOverride(g))return void(u=!0)};if(s.value.kind==="constant"&&s.value.value instanceof Ni)d(s.value.value.sections);else if(s.value.kind==="source"){const f=x=>{u||(x instanceof hr&&jt(x.value)===Ur?d(x.value.sections):x instanceof Ks?d(x.sections):x.eachChild(f))},g=s.value;g._styleExpression&&f(g._styleExpression.expression)}return u}}let ku;var Yp={get paint(){return ku=ku||new h({"background-color":new Le(le.paint_background["background-color"]),"background-pattern":new xa(le.paint_background["background-pattern"]),"background-opacity":new Le(le.paint_background["background-opacity"])})}};class Qp extends n{constructor(t){super(t,Yp)}}let Eu;var ef={get paint(){return Eu=Eu||new h({"raster-opacity":new Le(le.paint_raster["raster-opacity"]),"raster-hue-rotate":new Le(le.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Le(le.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Le(le.paint_raster["raster-brightness-max"]),"raster-saturation":new Le(le.paint_raster["raster-saturation"]),"raster-contrast":new Le(le.paint_raster["raster-contrast"]),"raster-resampling":new Le(le.paint_raster["raster-resampling"]),"raster-fade-duration":new Le(le.paint_raster["raster-fade-duration"])})}};class tf extends n{constructor(t){super(t,ef)}}class rf extends n{constructor(t){super(t,{}),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=t}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class nf{constructor(t){this._methodToThrottle=t,this._triggered=!1,typeof MessageChannel<"u"&&(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 nh=63710088e-1;class cs{constructor(t,r){if(isNaN(t)||isNaN(r))throw new Error(`Invalid LngLat object: (${t}, ${r})`);if(this.lng=+t,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new cs(Pi(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const r=Math.PI/180,s=this.lat*r,l=t.lat*r,u=Math.sin(s)*Math.sin(l)+Math.cos(s)*Math.cos(l)*Math.cos((t.lng-this.lng)*r);return nh*Math.acos(Math.min(u,1))}static convert(t){if(t instanceof cs)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new cs(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new cs(Number("lng"in t?t.lng:t.lon),Number(t.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 zu=2*Math.PI*nh;function Du(i){return zu*Math.cos(i*Math.PI/180)}function Lu(i){return(180+i)/360}function Ru(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function Bu(i,t){return i/Du(t)}function sh(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class qo{constructor(t,r,s=0){this.x=+t,this.y=+r,this.z=+s}static fromLngLat(t,r=0){const s=cs.convert(t);return new qo(Lu(s.lng),Ru(s.lat),Bu(r,s.lat))}toLngLat(){return new cs(360*this.x-180,sh(this.y))}toAltitude(){return this.z*Du(sh(this.y))}meterInMercatorCoordinateUnits(){return 1/zu*(t=sh(this.y),1/Math.cos(t*Math.PI/180));var t}}function Fu(i,t,r){var s=2*Math.PI*6378137/256/Math.pow(2,r);return[i*s-2*Math.PI*6378137/2,t*s-2*Math.PI*6378137/2]}class ah{constructor(t,r,s){if(!function(l,u,d){return!(l<0||l>25||d<0||d>=Math.pow(2,l)||u<0||u>=Math.pow(2,l))}(t,r,s))throw new Error(`x=${r}, y=${s}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=r,this.y=s,this.key=Zo(0,t,t,r,s)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,r,s){const l=(d=this.y,f=this.z,g=Fu(256*(u=this.x),256*(d=Math.pow(2,f)-d-1),f),x=Fu(256*(u+1),256*(d+1),f),g[0]+","+g[1]+","+x[0]+","+x[1]);var u,d,f,g,x;const v=function(w,I,C){let E,z="";for(let O=w;O>0;O--)E=1<1?"@2x":"").replace(/{quadkey}/g,v).replace(/{bbox-epsg-3857}/g,l)}isChildOf(t){const r=this.z-t.z;return r>0&&t.x===this.x>>r&&t.y===this.y>>r}getTilePoint(t){const r=Math.pow(2,this.z);return new ue((t.x*r-this.x)*$t,(t.y*r-this.y)*$t)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Ou{constructor(t,r){this.wrap=t,this.canonical=r,this.key=Zo(t,r.z,r.z,r.x,r.y)}}class yr{constructor(t,r,s,l,u){if(t= z; overscaledZ = ${t}; z = ${s}`);this.overscaledZ=t,this.wrap=r,this.canonical=new ah(s,+l,+u),this.key=Zo(r,t,s,l,u)}clone(){return new yr(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?new yr(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new yr(t,this.wrap,t,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(t,r){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-t;return t>this.canonical.z?Zo(this.wrap*+r,t,this.canonical.z,this.canonical.x,this.canonical.y):Zo(this.wrap*+r,t,t,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const r=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ>r&&t.canonical.y===this.canonical.y>>r}children(t){if(this.overscaledZ>=t)return[new yr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,s=2*this.canonical.x,l=2*this.canonical.y;return[new yr(r,this.wrap,r,s,l),new yr(r,this.wrap,r,s+1,l),new yr(r,this.wrap,r,s,l+1),new yr(r,this.wrap,r,s+1,l+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=w),w=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(t+1)}unpack(t,r,s){return t*this.redFactor+r*this.greenFactor+s*this.blueFactor-this.baseShift}getPixels(){return new _r({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,r,s){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let l=r*this.dim,u=r*this.dim+this.dim,d=s*this.dim,f=s*this.dim+this.dim;switch(r){case-1:l=u-1;break;case 1:u=l+1}switch(s){case-1:d=f-1;break;case 1:f=d+1}const g=-r*this.dim,x=-s*this.dim;for(let v=d;v=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class Uu{constructor(t,r,s,l,u){this.type="Feature",this._vectorTileFeature=t,t._z=r,t._x=s,t._y=l,this.properties=t.properties,this.id=u}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(t[r]=this[r]);return t}}class ju{constructor(t,r){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Wn($t,16,0),this.grid3D=new Wn($t,16,0),this.featureIndexArray=new bi,this.promoteId=r}insert(t,r,s,l,u,d){const f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,l,u);const g=d?this.grid3D:this.grid;for(let x=0;x=0&&w[3]>=0&&g.insert(f,w[0],w[1],w[2],w[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new as.VectorTile(new Xc(this.rawTileData)).layers,this.sourceLayerCoder=new Nu(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,r,s,l){this.loadVTLayers();const u=t.params||{},d=$t/t.tileSize/t.scale,f=co(u.filter),g=t.queryGeometry,x=t.queryPadding*d,v=qu(g),w=this.grid.query(v.minX-x,v.minY-x,v.maxX+x,v.maxY+x),I=qu(t.cameraQueryGeometry),C=this.grid3D.query(I.minX-x,I.minY-x,I.maxX+x,I.maxY+x,(O,$,re,W)=>function(te,ce,ge,Me,Ue){for(const Ie of te)if(ce<=Ie.x&&ge<=Ie.y&&Me>=Ie.x&&Ue>=Ie.y)return!0;const Ae=[new ue(ce,ge),new ue(ce,Ue),new ue(Me,Ue),new ue(Me,ge)];if(te.length>2){for(const Ie of Ae)if(Pa(te,Ie))return!0}for(let Ie=0;Ie(W||(W=Os(te)),ce.queryIntersectsFeature(g,te,ge,W,this.z,t.transform,d,t.pixelPosMatrix)))}return E}loadMatchingFeature(t,r,s,l,u,d,f,g,x,v,w){const I=this.bucketLayerIDs[r];if(d&&!function(O,$){for(let re=0;re=0)return!0;return!1}(d,I))return;const C=this.sourceLayerCoder.decode(s),E=this.vtLayers[C].feature(l);if(u.needGeometry){const O=Vs(E,!0);if(!u.filter(new wt(this.tileID.overscaledZ),O,this.tileID.canonical))return}else if(!u.filter(new wt(this.tileID.overscaledZ),E))return;const z=this.getId(E,C);for(let O=0;O{const f=t instanceof Ls?t.get(d):null;return f&&f.evaluate?f.evaluate(r,s,l):f})}function qu(i){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(const u of i)t=Math.min(t,u.x),r=Math.min(r,u.y),s=Math.max(s,u.x),l=Math.max(l,u.y);return{minX:t,minY:r,maxX:s,maxY:l}}function sf(i,t){return t-i}function Zu(i,t,r,s,l){const u=[];for(let d=0;d=s&&w.x>=s||(v.x>=s?v=new ue(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x>=s&&(w=new ue(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y>=l&&w.y>=l||(v.y>=l?v=new ue(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round():w.y>=l&&(w=new ue(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round()),g&&v.equals(g[g.length-1])||(g=[v],u.push(g)),g.push(w)))))}}return u}ze("FeatureIndex",ju,{omit:["rawTileData","sourceLayerCoder"]});class hs extends ue{constructor(t,r,s,l){super(t,r),this.angle=s,l!==void 0&&(this.segment=l)}clone(){return new hs(this.x,this.y,this.angle,this.segment)}}function Gu(i,t,r,s,l){if(t.segment===void 0||r===0)return!0;let u=t,d=t.segment+1,f=0;for(;f>-r/2;){if(d--,d<0)return!1;f-=i[d].dist(u),u=i[d]}f+=i[d].dist(i[d+1]),d++;const g=[];let x=0;for(;fs;)x-=g.shift().angleDelta;if(x>l)return!1;d++,f+=v.dist(w)}return!0}function Hu(i){let t=0;for(let r=0;rx){const E=(x-g)/C,z=Mi.number(w.x,I.x,E),O=Mi.number(w.y,I.y,E),$=new hs(z,O,I.angleTo(w),v);return $._round(),!d||Gu(i,$,f,d,t)?$:void 0}g+=C}}function of(i,t,r,s,l,u,d,f,g){const x=Xu(s,u,d),v=Wu(s,l),w=v*d,I=i[0].x===0||i[0].x===g||i[0].y===0||i[0].y===g;return t-w=0&&te=0&&ce=0&&I+x<=v){const ge=new hs(te,ce,re,E);ge._round(),s&&!Gu(i,ge,u,s,l)||C.push(ge)}}w+=$}return f||C.length||d||(C=Ku(i,w/2,r,s,l,u,d,!0,g)),C}ze("Anchor",hs);const La=Gi;function Ju(i,t,r,s){const l=[],u=i.image,d=u.pixelRatio,f=u.paddedRect.w-2*La,g=u.paddedRect.h-2*La;let x={x1:i.left,y1:i.top,x2:i.right,y2:i.bottom};const v=u.stretchX||[[0,f]],w=u.stretchY||[[0,g]],I=(pe,Oe)=>pe+Oe[1]-Oe[0],C=v.reduce(I,0),E=w.reduce(I,0),z=f-C,O=g-E;let $=0,re=C,W=0,te=E,ce=0,ge=z,Me=0,Ue=O;if(u.content&&s){const pe=u.content,Oe=pe[2]-pe[0],Be=pe[3]-pe[1];(u.textFitWidth||u.textFitHeight)&&(x=Su(i)),$=Xl(v,0,pe[0]),W=Xl(w,0,pe[1]),re=Xl(v,pe[0],pe[2]),te=Xl(w,pe[1],pe[3]),ce=pe[0]-$,Me=pe[1]-W,ge=Oe-re,Ue=Be-te}const Ae=x.x1,Ie=x.y1,Fe=x.x2-Ae,De=x.y2-Ie,Ee=(pe,Oe,Be,Ze)=>{const xt=Wl(pe.stretch-$,re,Fe,Ae),yt=Kl(pe.fixed-ce,ge,pe.stretch,C),Xt=Wl(Oe.stretch-W,te,De,Ie),Lr=Kl(Oe.fixed-Me,Ue,Oe.stretch,E),ui=Wl(Be.stretch-$,re,Fe,Ae),Wt=Kl(Be.fixed-ce,ge,Be.stretch,C),Di=Wl(Ze.stretch-W,te,De,Ie),Li=Kl(Ze.fixed-Me,Ue,Ze.stretch,E),Ri=new ue(xt,Xt),Ft=new ue(ui,Xt),Kt=new ue(ui,Di),Ti=new ue(xt,Di),di=new ue(yt/d,Lr/d),Bi=new ue(Wt/d,Li/d),pi=t*Math.PI/180;if(pi){const ht=Math.sin(pi),bt=Math.cos(pi),Pt=[bt,-ht,ht,bt];Ri._matMult(Pt),Ft._matMult(Pt),Ti._matMult(Pt),Kt._matMult(Pt)}const xr=pe.stretch+pe.fixed,Hi=Oe.stretch+Oe.fixed;return{tl:Ri,tr:Ft,bl:Ti,br:Kt,tex:{x:u.paddedRect.x+La+xr,y:u.paddedRect.y+La+Hi,w:Be.stretch+Be.fixed-xr,h:Ze.stretch+Ze.fixed-Hi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:di,pixelOffsetBR:Bi,minFontScaleX:ge/d/Fe,minFontScaleY:Ue/d/De,isSDF:r}};if(s&&(u.stretchX||u.stretchY)){const pe=Yu(v,z,C),Oe=Yu(w,O,E);for(let Be=0;Be0&&(z=Math.max(10,z),this.circleDiameter=z)}else{const I=!((w=d.image)===null||w===void 0)&&w.content&&(d.image.textFitWidth||d.image.textFitHeight)?Su(d):{x1:d.left,y1:d.top,x2:d.right,y2:d.bottom};I.y1=I.y1*f-g[0],I.y2=I.y2*f+g[2],I.x1=I.x1*f-g[3],I.x2=I.x2*f+g[1];const C=d.collisionPadding;if(C&&(I.x1-=C[0]*f,I.y1-=C[1]*f,I.x2+=C[2]*f,I.y2+=C[3]*f),v){const E=new ue(I.x1,I.y1),z=new ue(I.x2,I.y1),O=new ue(I.x1,I.y2),$=new ue(I.x2,I.y2),re=v*Math.PI/180;E._rotate(re),z._rotate(re),O._rotate(re),$._rotate(re),I.x1=Math.min(E.x,z.x,O.x,$.x),I.x2=Math.max(E.x,z.x,O.x,$.x),I.y1=Math.min(E.y,z.y,O.y,$.y),I.y2=Math.max(E.y,z.y,O.y,$.y)}t.emplaceBack(r.x,r.y,I.x1,I.y1,I.x2,I.y2,s,l,u)}this.boxEndIndex=t.length}}class lf{constructor(t=[],r=(s,l)=>sl?1:0){if(this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:r,compare:s}=this,l=r[t];for(;t>0;){const u=t-1>>1,d=r[u];if(s(l,d)>=0)break;r[t]=d,t=u}r[t]=l}_down(t){const{data:r,compare:s}=this,l=this.length>>1,u=r[t];for(;t=0)break;r[t]=r[d],t=d}r[t]=u}}function cf(i,t=1,r=!1){let s=1/0,l=1/0,u=-1/0,d=-1/0;const f=i[0];for(let C=0;Cu)&&(u=E.x),(!C||E.y>d)&&(d=E.y)}const g=Math.min(u-s,d-l);let x=g/2;const v=new lf([],hf);if(g===0)return new ue(s,l);for(let C=s;Cw.d||!w.d)&&(w=C,r&&console.log("found best %d after %d probes",Math.round(1e4*C.d)/1e4,I)),C.max-w.d<=t||(x=C.h/2,v.push(new Ra(C.p.x-x,C.p.y-x,x,i)),v.push(new Ra(C.p.x+x,C.p.y-x,x,i)),v.push(new Ra(C.p.x-x,C.p.y+x,x,i)),v.push(new Ra(C.p.x+x,C.p.y+x,x,i)),I+=4)}return r&&(console.log(`num probes: ${I}`),console.log(`best distance: ${w.d}`)),w.p}function hf(i,t){return t.max-i.max}function Ra(i,t,r,s){this.p=new ue(i,t),this.h=r,this.d=function(l,u){let d=!1,f=1/0;for(let g=0;gl.y!=E.y>l.y&&l.x<(E.x-C.x)*(l.y-C.y)/(E.y-C.y)+C.x&&(d=!d),f=Math.min(f,Rh(l,C,E))}}return(d?1:-1)*Math.sqrt(f)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}var hi;M.aq=void 0,(hi=M.aq||(M.aq={}))[hi.center=1]="center",hi[hi.left=2]="left",hi[hi.right=3]="right",hi[hi.top=4]="top",hi[hi.bottom=5]="bottom",hi[hi["top-left"]=6]="top-left",hi[hi["top-right"]=7]="top-right",hi[hi["bottom-left"]=8]="bottom-left",hi[hi["bottom-right"]=9]="bottom-right";const us=7,oh=Number.POSITIVE_INFINITY;function Qu(i,t){return t[1]!==oh?function(r,s,l){let u=0,d=0;switch(s=Math.abs(s),l=Math.abs(l),r){case"top-right":case"top-left":case"top":d=l-us;break;case"bottom-right":case"bottom-left":case"bottom":d=-l+us}switch(r){case"top-right":case"bottom-right":case"right":u=-s;break;case"top-left":case"bottom-left":case"left":u=s}return[u,d]}(i,t[0],t[1]):function(r,s){let l=0,u=0;s<0&&(s=0);const d=s/Math.SQRT2;switch(r){case"top-right":case"top-left":u=d-us;break;case"bottom-right":case"bottom-left":u=-d+us;break;case"bottom":u=-s+us;break;case"top":u=s-us}switch(r){case"top-right":case"bottom-right":l=-d;break;case"top-left":case"bottom-left":l=d;break;case"left":l=s;break;case"right":l=-s}return[l,u]}(i,t[0])}function ed(i,t,r){var s;const l=i.layout,u=(s=l.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(t,{},r);if(u){const f=u.values,g=[];for(let x=0;xI*Zt);v.startsWith("top")?w[1]-=us:v.startsWith("bottom")&&(w[1]+=us),g[x+1]=w}return new Yi(g)}const d=l.get("text-variable-anchor");if(d){let f;f=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[l.get("text-radial-offset").evaluate(t,{},r)*Zt,oh]:l.get("text-offset").evaluate(t,{},r).map(x=>x*Zt);const g=[];for(const x of d)g.push(x,Qu(x,f));return new Yi(g)}return null}function lh(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function uf(i,t,r,s,l,u,d,f,g,x,v){let w=u.textMaxSize.evaluate(t,{});w===void 0&&(w=d);const I=i.layers[0].layout,C=I.get("icon-offset").evaluate(t,{},v),E=id(r.horizontal),z=d/24,O=i.tilePixelRatio*z,$=i.tilePixelRatio*w/24,re=i.tilePixelRatio*f,W=i.tilePixelRatio*I.get("symbol-spacing"),te=I.get("text-padding")*i.tilePixelRatio,ce=function(pe,Oe,Be,Ze=1){const xt=pe.get("icon-padding").evaluate(Oe,{},Be),yt=xt&&xt.values;return[yt[0]*Ze,yt[1]*Ze,yt[2]*Ze,yt[3]*Ze]}(I,t,v,i.tilePixelRatio),ge=I.get("text-max-angle")/180*Math.PI,Me=I.get("text-rotation-alignment")!=="viewport"&&I.get("symbol-placement")!=="point",Ue=I.get("icon-rotation-alignment")==="map"&&I.get("symbol-placement")!=="point",Ae=I.get("symbol-placement"),Ie=W/2,Fe=I.get("icon-text-fit");let De;s&&Fe!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(De=Iu(s,r.vertical,Fe,I.get("icon-text-fit-padding"),C,z)),E&&(s=Iu(s,E,Fe,I.get("icon-text-fit-padding"),C,z)));const Ee=(pe,Oe)=>{Oe.x<0||Oe.x>=$t||Oe.y<0||Oe.y>=$t||function(Be,Ze,xt,yt,Xt,Lr,ui,Wt,Di,Li,Ri,Ft,Kt,Ti,di,Bi,pi,xr,Hi,ht,bt,Pt,sr,Dt,Ba){const sn=Be.addToLineVertexArray(Ze,xt);let an,Rr,vr,ti,Cn=0,Xo=0,ad=0,od=0,gh=-1,_h=-1;const Mn={};let ld=wa("");if(Be.allowVerticalPlacement&&yt.vertical){const Si=Wt.layout.get("text-rotate").evaluate(bt,{},Dt)+90;vr=new Jl(Di,Ze,Li,Ri,Ft,yt.vertical,Kt,Ti,di,Si),ui&&(ti=new Jl(Di,Ze,Li,Ri,Ft,ui,pi,xr,di,Si))}if(Xt){const Si=Wt.layout.get("icon-rotate").evaluate(bt,{}),br=Wt.layout.get("icon-text-fit")!=="none",Us=Ju(Xt,Si,sr,br),Gr=ui?Ju(ui,Si,sr,br):void 0;Rr=new Jl(Di,Ze,Li,Ri,Ft,Xt,pi,xr,!1,Si),Cn=4*Us.length;const js=Be.iconSizeData;let on=null;js.kind==="source"?(on=[nn*Wt.layout.get("icon-size").evaluate(bt,{})],on[0]>ls&&Gt(`${Be.layerIds[0]}: Value for "icon-size" is >= ${$o}. Reduce your "icon-size".`)):js.kind==="composite"&&(on=[nn*Pt.compositeIconSizes[0].evaluate(bt,{},Dt),nn*Pt.compositeIconSizes[1].evaluate(bt,{},Dt)],(on[0]>ls||on[1]>ls)&&Gt(`${Be.layerIds[0]}: Value for "icon-size" is >= ${$o}. Reduce your "icon-size".`)),Be.addSymbols(Be.icon,Us,on,ht,Hi,bt,M.ah.none,Ze,sn.lineStartIndex,sn.lineLength,-1,Dt),gh=Be.icon.placedSymbolArray.length-1,Gr&&(Xo=4*Gr.length,Be.addSymbols(Be.icon,Gr,on,ht,Hi,bt,M.ah.vertical,Ze,sn.lineStartIndex,sn.lineLength,-1,Dt),_h=Be.icon.placedSymbolArray.length-1)}const cd=Object.keys(yt.horizontal);for(const Si of cd){const br=yt.horizontal[Si];if(!an){ld=wa(br.text);const Gr=Wt.layout.get("text-rotate").evaluate(bt,{},Dt);an=new Jl(Di,Ze,Li,Ri,Ft,br,Kt,Ti,di,Gr)}const Us=br.positionedLines.length===1;if(ad+=td(Be,Ze,br,Lr,Wt,di,bt,Bi,sn,yt.vertical?M.ah.horizontal:M.ah.horizontalOnly,Us?cd:[Si],Mn,gh,Pt,Dt),Us)break}yt.vertical&&(od+=td(Be,Ze,yt.vertical,Lr,Wt,di,bt,Bi,sn,M.ah.vertical,["vertical"],Mn,_h,Pt,Dt));const ff=an?an.boxStartIndex:Be.collisionBoxArray.length,mf=an?an.boxEndIndex:Be.collisionBoxArray.length,gf=vr?vr.boxStartIndex:Be.collisionBoxArray.length,_f=vr?vr.boxEndIndex:Be.collisionBoxArray.length,yf=Rr?Rr.boxStartIndex:Be.collisionBoxArray.length,xf=Rr?Rr.boxEndIndex:Be.collisionBoxArray.length,vf=ti?ti.boxStartIndex:Be.collisionBoxArray.length,bf=ti?ti.boxEndIndex:Be.collisionBoxArray.length;let Zr=-1;const Ql=(Si,br)=>Si&&Si.circleDiameter?Math.max(Si.circleDiameter,br):br;Zr=Ql(an,Zr),Zr=Ql(vr,Zr),Zr=Ql(Rr,Zr),Zr=Ql(ti,Zr);const hd=Zr>-1?1:0;hd&&(Zr*=Ba/Zt),Be.glyphOffsetArray.length>=Da.MAX_GLYPHS&&Gt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),bt.sortKey!==void 0&&Be.addToSortKeyRanges(Be.symbolInstances.length,bt.sortKey);const wf=ed(Wt,bt,Dt),[Tf,Sf]=function(Si,br){const Us=Si.length,Gr=br==null?void 0:br.values;if((Gr==null?void 0:Gr.length)>0)for(let js=0;js=0?Mn.right:-1,Mn.center>=0?Mn.center:-1,Mn.left>=0?Mn.left:-1,Mn.vertical||-1,gh,_h,ld,ff,mf,gf,_f,yf,xf,vf,bf,Li,ad,od,Cn,Xo,hd,0,Kt,Zr,Tf,Sf)}(i,Oe,pe,r,s,l,De,i.layers[0],i.collisionBoxArray,t.index,t.sourceLayerIndex,i.index,O,[te,te,te,te],Me,g,re,ce,Ue,C,t,u,x,v,d)};if(Ae==="line")for(const pe of Zu(t.geometry,0,0,$t,$t)){const Oe=of(pe,W,ge,r.vertical||E,s,24,$,i.overscaling,$t);for(const Be of Oe)E&&df(i,E.text,Ie,Be)||Ee(pe,Be)}else if(Ae==="line-center"){for(const pe of t.geometry)if(pe.length>1){const Oe=af(pe,ge,r.vertical||E,s,24,$);Oe&&Ee(pe,Oe)}}else if(t.type==="Polygon")for(const pe of Ys(t.geometry,0)){const Oe=cf(pe,16);Ee(pe[0],new hs(Oe.x,Oe.y,0))}else if(t.type==="LineString")for(const pe of t.geometry)Ee(pe,new hs(pe[0].x,pe[0].y,0));else if(t.type==="Point")for(const pe of t.geometry)for(const Oe of pe)Ee([Oe],new hs(Oe.x,Oe.y,0))}function td(i,t,r,s,l,u,d,f,g,x,v,w,I,C,E){const z=function(re,W,te,ce,ge,Me,Ue,Ae){const Ie=ce.layout.get("text-rotate").evaluate(Me,{})*Math.PI/180,Fe=[];for(const De of W.positionedLines)for(const Ee of De.positionedGlyphs){if(!Ee.rect)continue;const pe=Ee.rect||{};let Oe=_u+1,Be=!0,Ze=1,xt=0;const yt=(ge||Ae)&&Ee.vertical,Xt=Ee.metrics.advance*Ee.scale/2;if(Ae&&W.verticalizable&&(xt=De.lineOffset/2-(Ee.imageName?-(Zt-Ee.metrics.width*Ee.scale)/2:(Ee.scale-1)*Zt)),Ee.imageName){const ht=Ue[Ee.imageName];Be=ht.sdf,Ze=ht.pixelRatio,Oe=Gi/Ze}const Lr=ge?[Ee.x+Xt,Ee.y]:[0,0];let ui=ge?[0,0]:[Ee.x+Xt+te[0],Ee.y+te[1]-xt],Wt=[0,0];yt&&(Wt=ui,ui=[0,0]);const Di=Ee.metrics.isDoubleResolution?2:1,Li=(Ee.metrics.left-Oe)*Ee.scale-Xt+ui[0],Ri=(-Ee.metrics.top-Oe)*Ee.scale+ui[1],Ft=Li+pe.w/Di*Ee.scale/Ze,Kt=Ri+pe.h/Di*Ee.scale/Ze,Ti=new ue(Li,Ri),di=new ue(Ft,Ri),Bi=new ue(Li,Kt),pi=new ue(Ft,Kt);if(yt){const ht=new ue(-Xt,Xt-Uo),bt=-Math.PI/2,Pt=Zt/2-Xt,sr=new ue(5-Uo-Pt,-(Ee.imageName?Pt:0)),Dt=new ue(...Wt);Ti._rotateAround(bt,ht)._add(sr)._add(Dt),di._rotateAround(bt,ht)._add(sr)._add(Dt),Bi._rotateAround(bt,ht)._add(sr)._add(Dt),pi._rotateAround(bt,ht)._add(sr)._add(Dt)}if(Ie){const ht=Math.sin(Ie),bt=Math.cos(Ie),Pt=[bt,-ht,ht,bt];Ti._matMult(Pt),di._matMult(Pt),Bi._matMult(Pt),pi._matMult(Pt)}const xr=new ue(0,0),Hi=new ue(0,0);Fe.push({tl:Ti,tr:di,bl:Bi,br:pi,tex:pe,writingMode:W.writingMode,glyphOffset:Lr,sectionIndex:Ee.sectionIndex,isSDF:Be,pixelOffsetTL:xr,pixelOffsetBR:Hi,minFontScaleX:0,minFontScaleY:0})}return Fe}(0,r,f,l,u,d,s,i.allowVerticalPlacement),O=i.textSizeData;let $=null;O.kind==="source"?($=[nn*l.layout.get("text-size").evaluate(d,{})],$[0]>ls&&Gt(`${i.layerIds[0]}: Value for "text-size" is >= ${$o}. Reduce your "text-size".`)):O.kind==="composite"&&($=[nn*C.compositeTextSizes[0].evaluate(d,{},E),nn*C.compositeTextSizes[1].evaluate(d,{},E)],($[0]>ls||$[1]>ls)&&Gt(`${i.layerIds[0]}: Value for "text-size" is >= ${$o}. Reduce your "text-size".`)),i.addSymbols(i.text,z,$,f,u,d,x,t,g.lineStartIndex,g.lineLength,I,E);for(const re of v)w[re]=i.text.placedSymbolArray.length-1;return 4*z.length}function id(i){for(const t in i)return i[t];return null}function df(i,t,r,s){const l=i.compareText;if(t in l){const u=l[t];for(let d=u.length-1;d>=0;d--)if(s.dist(u[d])>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);const u=rd[15&s];if(!u)throw new Error("Unrecognized array type.");const[d]=new Uint16Array(t,2,1),[f]=new Uint32Array(t,4,1);return new ch(f,d,u,t)}constructor(t,r=64,s=Float64Array,l){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=s,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const u=rd.indexOf(this.ArrayType),d=2*t*this.ArrayType.BYTES_PER_ELEMENT,f=t*this.IndexArrayType.BYTES_PER_ELEMENT,g=(8-f%8)%8;if(u<0)throw new Error(`Unexpected typed array class: ${s}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+g,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+d+f+g),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+g,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+u]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=t)}add(t,r){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=t,this.coords[this._pos++]=r,s}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return hh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,r,s,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:u,coords:d,nodeSize:f}=this,g=[0,u.length-1,0],x=[];for(;g.length;){const v=g.pop()||0,w=g.pop()||0,I=g.pop()||0;if(w-I<=f){for(let O=I;O<=w;O++){const $=d[2*O],re=d[2*O+1];$>=t&&$<=s&&re>=r&&re<=l&&x.push(u[O])}continue}const C=I+w>>1,E=d[2*C],z=d[2*C+1];E>=t&&E<=s&&z>=r&&z<=l&&x.push(u[C]),(v===0?t<=E:r<=z)&&(g.push(I),g.push(C-1),g.push(1-v)),(v===0?s>=E:l>=z)&&(g.push(C+1),g.push(w),g.push(1-v))}return x}within(t,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:u,nodeSize:d}=this,f=[0,l.length-1,0],g=[],x=s*s;for(;f.length;){const v=f.pop()||0,w=f.pop()||0,I=f.pop()||0;if(w-I<=d){for(let O=I;O<=w;O++)sd(u[2*O],u[2*O+1],t,r)<=x&&g.push(l[O]);continue}const C=I+w>>1,E=u[2*C],z=u[2*C+1];sd(E,z,t,r)<=x&&g.push(l[C]),(v===0?t-s<=E:r-s<=z)&&(f.push(I),f.push(C-1),f.push(1-v)),(v===0?t+s>=E:r+s>=z)&&(f.push(C+1),f.push(w),f.push(1-v))}return g}}function hh(i,t,r,s,l,u){if(l-s<=r)return;const d=s+l>>1;nd(i,t,d,s,l,u),hh(i,t,r,s,d-1,1-u),hh(i,t,r,d+1,l,1-u)}function nd(i,t,r,s,l,u){for(;l>s;){if(l-s>600){const x=l-s+1,v=r-s+1,w=Math.log(x),I=.5*Math.exp(2*w/3),C=.5*Math.sqrt(w*I*(x-I)/x)*(v-x/2<0?-1:1);nd(i,t,r,Math.max(s,Math.floor(r-v*I/x+C)),Math.min(l,Math.floor(r+(x-v)*I/x+C)),u)}const d=t[2*r+u];let f=s,g=l;for(Go(i,t,s,r),t[2*l+u]>d&&Go(i,t,s,l);fd;)g--}t[2*s+u]===d?Go(i,t,s,g):(g++,Go(i,t,g,l)),g<=r&&(s=g+1),r<=g&&(l=g-1)}}function Go(i,t,r,s){uh(i,r,s),uh(t,2*r,2*s),uh(t,2*r+1,2*s+1)}function uh(i,t,r){const s=i[t];i[t]=i[r],i[r]=s}function sd(i,t,r,s){const l=i-r,u=t-s;return l*l+u*u}var dh;M.bg=void 0,(dh=M.bg||(M.bg={})).create="create",dh.load="load",dh.fullLoad="fullLoad";let Yl=null,Ho=[];const ph=1e3/60,fh="loadTime",mh="fullLoadTime",pf={mark(i){performance.mark(i)},frame(i){const t=i;Yl!=null&&Ho.push(t-Yl),Yl=t},clearMetrics(){Yl=null,Ho=[],performance.clearMeasures(fh),performance.clearMeasures(mh);for(const i in M.bg)performance.clearMarks(M.bg[i])},getPerformanceMetrics(){performance.measure(fh,M.bg.create,M.bg.load),performance.measure(mh,M.bg.create,M.bg.fullLoad);const i=performance.getEntriesByName(fh)[0].duration,t=performance.getEntriesByName(mh)[0].duration,r=Ho.length,s=1/(Ho.reduce((u,d)=>u+d,0)/r/1e3),l=Ho.filter(u=>u>ph).reduce((u,d)=>u+(d-ph)/ph,0);return{loadTime:i,fullLoadTime:t,fps:s,percentDroppedFrames:l/(r+l)*100,totalFrames:r}}};M.$=class extends T{},M.A=Aa,M.B=Tc,M.C=function(i){if(Oi==null){const t=i.navigator?i.navigator.userAgent:null;Oi=!!i.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Oi},M.D=Le,M.E=kn,M.F=class{constructor(i,t){this.target=i,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new nf(()=>this.process()),this.subscription=function(r,s,l,u){return r.addEventListener(s,l,!1),{unsubscribe:()=>{r.removeEventListener(s,l,!1)}}}(this.target,"message",r=>this.receive(r)),this.globalScope=Wi(self)?i:window}registerMessageHandler(i,t){this.messageHandlers[i]=t}sendAsync(i,t){return new Promise((r,s)=>{const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[l]={resolve:r,reject:s},t&&t.signal.addEventListener("abort",()=>{delete this.resolveRejects[l];const f={id:l,type:"",origin:location.origin,targetMapId:i.targetMapId,sourceMapId:this.mapId};this.target.postMessage(f)},{once:!0});const u=[],d=Object.assign(Object.assign({},i),{id:l,sourceMapId:this.mapId,origin:location.origin,data:Kn(i.data,u)});this.target.postMessage(d,{transfer:u})})}receive(i){const t=i.data,r=t.id;if(!(t.origin!=="file://"&&location.origin!=="file://"&&t.origin!=="resource://android"&&location.origin!=="resource://android"&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type===""){delete this.tasks[r];const s=this.abortControllers[r];return delete this.abortControllers[r],void(s&&s.abort())}if(Wi(self)||t.mustQueue)return this.tasks[r]=t,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,t)}}process(){if(this.taskQueue.length===0)return;const i=this.taskQueue.shift(),t=this.tasks[i];delete this.tasks[i],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(i,t)}processTask(i,t){return p(this,void 0,void 0,function*(){if(t.type===""){const l=this.resolveRejects[i];return delete this.resolveRejects[i],l?void(t.error?l.reject(Jn(t.error)):l.resolve(Jn(t.data))):void 0}if(!this.messageHandlers[t.type])return void this.completeTask(i,new Error(`Could not find a registered handler for ${t.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const r=Jn(t.data),s=new AbortController;this.abortControllers[i]=s;try{const l=yield this.messageHandlers[t.type](t.sourceMapId,r,s);this.completeTask(i,null,l)}catch(l){this.completeTask(i,l)}})}completeTask(i,t,r){const s=[];delete this.abortControllers[i];const l={id:i,type:"",sourceMapId:this.mapId,origin:location.origin,error:t?Kn(t):null,data:Kn(r,s)};this.target.postMessage(l,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},M.G=Sr,M.H=function(){var i=new Aa(16);return Aa!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},M.I=Kc,M.J=function(i,t,r){var s,l,u,d,f,g,x,v,w,I,C,E,z=r[0],O=r[1],$=r[2];return t===i?(i[12]=t[0]*z+t[4]*O+t[8]*$+t[12],i[13]=t[1]*z+t[5]*O+t[9]*$+t[13],i[14]=t[2]*z+t[6]*O+t[10]*$+t[14],i[15]=t[3]*z+t[7]*O+t[11]*$+t[15]):(l=t[1],u=t[2],d=t[3],f=t[4],g=t[5],x=t[6],v=t[7],w=t[8],I=t[9],C=t[10],E=t[11],i[0]=s=t[0],i[1]=l,i[2]=u,i[3]=d,i[4]=f,i[5]=g,i[6]=x,i[7]=v,i[8]=w,i[9]=I,i[10]=C,i[11]=E,i[12]=s*z+f*O+w*$+t[12],i[13]=l*z+g*O+I*$+t[13],i[14]=u*z+x*O+C*$+t[14],i[15]=d*z+v*O+E*$+t[15]),i},M.K=function(i,t,r){var s=r[0],l=r[1],u=r[2];return i[0]=t[0]*s,i[1]=t[1]*s,i[2]=t[2]*s,i[3]=t[3]*s,i[4]=t[4]*l,i[5]=t[5]*l,i[6]=t[6]*l,i[7]=t[7]*l,i[8]=t[8]*u,i[9]=t[9]*u,i[10]=t[10]*u,i[11]=t[11]*u,i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],i},M.L=Vh,M.M=function(i,t){const r={};for(let s=0;s{const t=window.document.createElement("video");return t.muted=!0,new Promise(r=>{t.onloadstart=()=>{r(t)};for(const s of i){const l=window.document.createElement("source");Vr(s)||(t.crossOrigin="Anonymous"),l.src=s,t.appendChild(l)}})},M.a4=function(){return cn++},M.a5=Ce,M.a6=Da,M.a7=co,M.a8=Vs,M.a9=Uu,M.aA=function(i){if(i.type==="custom")return new rf(i);switch(i.type){case"background":return new Qp(i);case"circle":return new Nd(i);case"fill":return new rp(i);case"fill-extrusion":return new yp(i);case"heatmap":return new jd(i);case"hillshade":return new qd(i);case"line":return new Pp(i);case"raster":return new tf(i);case"symbol":return new Hl(i)}},M.aB=et,M.aC=function(i,t){if(!i)return[{command:"setStyle",args:[t]}];let r=[];try{if(!ut(i.version,t.version))return[{command:"setStyle",args:[t]}];ut(i.center,t.center)||r.push({command:"setCenter",args:[t.center]}),ut(i.zoom,t.zoom)||r.push({command:"setZoom",args:[t.zoom]}),ut(i.bearing,t.bearing)||r.push({command:"setBearing",args:[t.bearing]}),ut(i.pitch,t.pitch)||r.push({command:"setPitch",args:[t.pitch]}),ut(i.sprite,t.sprite)||r.push({command:"setSprite",args:[t.sprite]}),ut(i.glyphs,t.glyphs)||r.push({command:"setGlyphs",args:[t.glyphs]}),ut(i.transition,t.transition)||r.push({command:"setTransition",args:[t.transition]}),ut(i.light,t.light)||r.push({command:"setLight",args:[t.light]}),ut(i.terrain,t.terrain)||r.push({command:"setTerrain",args:[t.terrain]}),ut(i.sky,t.sky)||r.push({command:"setSky",args:[t.sky]}),ut(i.projection,t.projection)||r.push({command:"setProjection",args:[t.projection]});const s={},l=[];(function(d,f,g,x){let v;for(v in f=f||{},d=d||{})Object.prototype.hasOwnProperty.call(d,v)&&(Object.prototype.hasOwnProperty.call(f,v)||Kr(v,g,x));for(v in f)Object.prototype.hasOwnProperty.call(f,v)&&(Object.prototype.hasOwnProperty.call(d,v)?ut(d[v],f[v])||(d[v].type==="geojson"&&f[v].type==="geojson"&&En(d,f,v)?Et(g,{command:"setGeoJSONSourceData",args:[v,f[v].data]}):Nr(v,f,g,x)):fs(v,f,g))})(i.sources,t.sources,l,s);const u=[];i.layers&&i.layers.forEach(d=>{"source"in d&&s[d.source]?r.push({command:"removeLayer",args:[d.id]}):u.push(d)}),r=r.concat(l),function(d,f,g){f=f||[];const x=(d=d||[]).map(ms),v=f.map(ms),w=d.reduce(gs,{}),I=f.reduce(gs,{}),C=x.slice(),E=Object.create(null);let z,O,$,re,W;for(let te=0,ce=0;te@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,s,l,u)=>{const d=l||u;return t[s]=!d||d.toLowerCase(),""}),t["max-age"]){const r=parseInt(t["max-age"],10);isNaN(r)?delete t["max-age"]:t["max-age"]=r}return t},M.ab=function(i,t){const r=[];for(const s in i)s in t||r.push(s);return r},M.ac=mi,M.ad=function(i,t,r){var s=Math.sin(r),l=Math.cos(r),u=t[0],d=t[1],f=t[2],g=t[3],x=t[4],v=t[5],w=t[6],I=t[7];return t!==i&&(i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15]),i[0]=u*l+x*s,i[1]=d*l+v*s,i[2]=f*l+w*s,i[3]=g*l+I*s,i[4]=x*l-u*s,i[5]=v*l-d*s,i[6]=w*l-f*s,i[7]=I*l-g*s,i},M.ae=function(i){var t=new Aa(16);return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],t},M.af=Ol,M.ag=function(i,t){let r=0,s=0;if(i.kind==="constant")s=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:l,minZoom:u,maxZoom:d}=i,f=l?mi(ki.interpolationFactor(l,t,u,d),0,1):0;i.kind==="camera"?s=Mi.number(i.minSize,i.maxSize,f):r=f}return{uSizeT:r,uSize:s}},M.ai=function(i,{uSize:t,uSizeT:r},{lowerSize:s,upperSize:l}){return i.kind==="source"?s/nn:i.kind==="composite"?Mi.number(s/nn,l/nn,r):t},M.aj=eh,M.ak=function(i,t,r,s){const l=t.y-i.y,u=t.x-i.x,d=s.y-r.y,f=s.x-r.x,g=d*u-f*l;if(g===0)return null;const x=(f*(i.y-r.y)-d*(i.x-r.x))/g;return new ue(i.x+x*u,i.y+x*l)},M.al=Zu,M.am=Dh,M.an=Rc,M.ao=function(i){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(const u of i)t=Math.min(t,u.x),r=Math.min(r,u.y),s=Math.max(s,u.x),l=Math.max(l,u.y);return[t,r,s,l]},M.ap=Zt,M.ar=Qc,M.as=function(i,t){var r=t[0],s=t[1],l=t[2],u=t[3],d=t[4],f=t[5],g=t[6],x=t[7],v=t[8],w=t[9],I=t[10],C=t[11],E=t[12],z=t[13],O=t[14],$=t[15],re=r*f-s*d,W=r*g-l*d,te=r*x-u*d,ce=s*g-l*f,ge=s*x-u*f,Me=l*x-u*g,Ue=v*z-w*E,Ae=v*O-I*E,Ie=v*$-C*E,Fe=w*O-I*z,De=w*$-C*z,Ee=I*$-C*O,pe=re*Ee-W*De+te*Fe+ce*Ie-ge*Ae+Me*Ue;return pe?(i[0]=(f*Ee-g*De+x*Fe)*(pe=1/pe),i[1]=(l*De-s*Ee-u*Fe)*pe,i[2]=(z*Me-O*ge+$*ce)*pe,i[3]=(I*ge-w*Me-C*ce)*pe,i[4]=(g*Ie-d*Ee-x*Ae)*pe,i[5]=(r*Ee-l*Ie+u*Ae)*pe,i[6]=(O*te-E*Me-$*W)*pe,i[7]=(v*Me-I*te+C*W)*pe,i[8]=(d*De-f*Ie+x*Ue)*pe,i[9]=(s*Ie-r*De-u*Ue)*pe,i[10]=(E*ge-z*te+$*re)*pe,i[11]=(w*te-v*ge-C*re)*pe,i[12]=(f*Ae-d*Fe-g*Ue)*pe,i[13]=(r*Fe-s*Ae+l*Ue)*pe,i[14]=(z*W-E*ce-O*re)*pe,i[15]=(v*ce-w*W+I*re)*pe,i):null},M.at=lh,M.au=Yc,M.av=ch,M.aw=function(){const i={},t=le.$version;for(const r in le.$root){const s=le.$root[r];if(s.required){let l=null;l=r==="version"?t:s.type==="array"?[]:{},l!=null&&(i[r]=l)}}return i},M.ax=So,M.ay=Ai,M.az=function(i){i=i.slice();const t=Object.create(null);for(let r=0;r25||s<0||s>=1||r<0||r>=1)},M.bc=function(i,t){return i[0]=t[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=t[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=t[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},M.bd=class extends b{},M.be=nh,M.bf=pf,M.bh=Yt,M.bi=function(i,t){or.REGISTERED_PROTOCOLS[i]=t},M.bj=function(i){delete or.REGISTERED_PROTOCOLS[i]},M.bk=function(i,t){const r={};for(let l=0;lEe*Zt)}let Ae=d?"center":r.get("text-justify").evaluate(x,{},i.canonical);const Ie=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(x,{},i.canonical)*Zt:1/0,Fe=()=>{i.bucket.allowVerticalPlacement&&Io(te)&&(E.vertical=ql(z,i.glyphMap,i.glyphPositions,i.imagePositions,v,Ie,u,Me,"left",ge,$,M.ah.vertical,!0,I,w))};if(!d&&Ue){const De=new Set;if(Ae==="auto")for(let pe=0;pep(void 0,void 0,void 0,function*(){if(i.byteLength===0)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(i)],{type:"image/png"});try{return createImageBitmap(t)}catch(r){throw new Error(`Could not load image because of ${r.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),M.e=gi,M.f=i=>new Promise((t,r)=>{const s=new Image;s.onload=()=>{t(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame(()=>{s.src=un})},s.onerror=()=>r(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 l=new Blob([new Uint8Array(i)],{type:"image/png"});s.src=i.byteLength?URL.createObjectURL(l):un}),M.g=si,M.h=(i,t)=>Ir(gi(i,{type:"json"}),t),M.i=Wi,M.j=Wr,M.k=lr,M.l=(i,t)=>Ir(gi(i,{type:"arrayBuffer"}),t),M.m=Ir,M.n=function(i){return new Xc(i).readFields(Up,[])},M.o=Lo,M.p=yu,M.q=h,M.r=wc,M.s=Vr,M.t=wo,M.u=Sn,M.v=le,M.w=Gt,M.x=function([i,t,r]){return t+=90,t*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(t)*Math.sin(r),y:i*Math.sin(t)*Math.sin(r),z:i*Math.cos(r)}},M.y=Mi,M.z=wt}),de("worker",["./shared"],function(M){class p{constructor(A){this.keyCache={},A&&this.replace(A)}replace(A){this._layerConfigs={},this._layers={},this.update(A,[])}update(A,P){for(const V of A){this._layerConfigs[V.id]=V;const K=this._layers[V.id]=M.aA(V);K._featureFilter=M.a7(K.filter),this.keyCache[V.id]&&delete this.keyCache[V.id]}for(const V of P)delete this.keyCache[V],delete this._layerConfigs[V],delete this._layers[V];this.familiesBySource={};const R=M.bk(Object.values(this._layerConfigs),this.keyCache);for(const V of R){const K=V.map(oe=>this._layers[oe.id]),Q=K[0];if(Q.visibility==="none")continue;const ie=Q.source||"";let H=this.familiesBySource[ie];H||(H=this.familiesBySource[ie]={});const he=Q.sourceLayer||"_geojsonTileLayer";let me=H[he];me||(me=H[he]=[]),me.push(K)}}}class Je{constructor(A){const P={},R=[];for(const ie in A){const H=A[ie],he=P[ie]={};for(const me in H){const oe=H[+me];if(!oe||oe.bitmap.width===0||oe.bitmap.height===0)continue;const ve={x:0,y:0,w:oe.bitmap.width+2,h:oe.bitmap.height+2};R.push(ve),he[me]={rect:ve,metrics:oe.metrics}}}const{w:V,h:K}=M.p(R),Q=new M.o({width:V||1,height:K||1});for(const ie in A){const H=A[ie];for(const he in H){const me=H[+he];if(!me||me.bitmap.width===0||me.bitmap.height===0)continue;const oe=P[ie][he].rect;M.o.copy(me.bitmap,Q,{x:0,y:0},{x:oe.x+1,y:oe.y+1},me.bitmap)}}this.image=Q,this.positions=P}}M.bl("GlyphAtlas",Je);class Ge{constructor(A){this.tileID=new M.S(A.tileID.overscaledZ,A.tileID.wrap,A.tileID.canonical.z,A.tileID.canonical.x,A.tileID.canonical.y),this.uid=A.uid,this.zoom=A.zoom,this.pixelRatio=A.pixelRatio,this.tileSize=A.tileSize,this.source=A.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=A.showCollisionBoxes,this.collectResourceTiming=!!A.collectResourceTiming,this.returnDependencies=!!A.returnDependencies,this.promoteId=A.promoteId,this.inFlightDependencies=[]}parse(A,P,R,V){return M._(this,void 0,void 0,function*(){this.status="parsing",this.data=A,this.collisionBoxArray=new M.a5;const K=new M.bm(Object.keys(A.layers).sort()),Q=new M.bn(this.tileID,this.promoteId);Q.bucketLayerIDs=[];const ie={},H={featureIndex:Q,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:R},he=P.familiesBySource[this.source];for(const tt in he){const ft=A.layers[tt];if(!ft)continue;ft.version===1&&M.w(`Vector tile source "${this.source}" layer "${tt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Ct=K.encode(tt),Ht=[];for(let Qt=0;Qt=vi.maxzoom||vi.visibility!=="none"&&(He(Qt,this.zoom,R),(ie[vi.id]=vi.createBucket({index:Q.bucketLayerIDs.length,layers:Qt,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ct,sourceID:this.source})).populate(Ht,H,this.tileID.canonical),Q.bucketLayerIDs.push(Qt.map(zn=>zn.id)))}}const me=M.aF(H.glyphDependencies,tt=>Object.keys(tt).map(Number));this.inFlightDependencies.forEach(tt=>tt==null?void 0:tt.abort()),this.inFlightDependencies=[];let oe=Promise.resolve({});if(Object.keys(me).length){const tt=new AbortController;this.inFlightDependencies.push(tt),oe=V.sendAsync({type:"GG",data:{stacks:me,source:this.source,tileID:this.tileID,type:"glyphs"}},tt)}const ve=Object.keys(H.iconDependencies);let Ve=Promise.resolve({});if(ve.length){const tt=new AbortController;this.inFlightDependencies.push(tt),Ve=V.sendAsync({type:"GI",data:{icons:ve,source:this.source,tileID:this.tileID,type:"icons"}},tt)}const Ne=Object.keys(H.patternDependencies);let ot=Promise.resolve({});if(Ne.length){const tt=new AbortController;this.inFlightDependencies.push(tt),ot=V.sendAsync({type:"GI",data:{icons:Ne,source:this.source,tileID:this.tileID,type:"patterns"}},tt)}const[Ke,lt,rt]=yield Promise.all([oe,Ve,ot]),Ut=new Je(Ke),zt=new M.bo(lt,rt);for(const tt in ie){const ft=ie[tt];ft instanceof M.a6?(He(ft.layers,this.zoom,R),M.bp({bucket:ft,glyphMap:Ke,glyphPositions:Ut.positions,imageMap:lt,imagePositions:zt.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):ft.hasPattern&&(ft instanceof M.bq||ft instanceof M.br||ft instanceof M.bs)&&(He(ft.layers,this.zoom,R),ft.addFeatures(H,this.tileID.canonical,zt.patternPositions))}return this.status="done",{buckets:Object.values(ie).filter(tt=>!tt.isEmpty()),featureIndex:Q,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Ut.image,imageAtlas:zt,glyphMap:this.returnDependencies?Ke:null,iconMap:this.returnDependencies?lt:null,glyphPositions:this.returnDependencies?Ut.positions:null}})}}function He(U,A,P){const R=new M.z(A);for(const V of U)V.recalculate(R,P)}class ue{constructor(A,P,R){this.actor=A,this.layerIndex=P,this.availableImages=R,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(A,P){return M._(this,void 0,void 0,function*(){const R=yield M.l(A.request,P);try{return{vectorTile:new M.bt.VectorTile(new M.bu(R.data)),rawData:R.data,cacheControl:R.cacheControl,expires:R.expires}}catch(V){const K=new Uint8Array(R.data);let Q=`Unable to parse the tile at ${A.request.url}, `;throw Q+=K[0]===31&&K[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${V.message}`,new Error(Q)}})}loadTile(A){return M._(this,void 0,void 0,function*(){const P=A.uid,R=!!(A&&A.request&&A.request.collectResourceTiming)&&new M.bv(A.request),V=new Ge(A);this.loading[P]=V;const K=new AbortController;V.abort=K;try{const Q=yield this.loadVectorTile(A,K);if(delete this.loading[P],!Q)return null;const ie=Q.rawData,H={};Q.expires&&(H.expires=Q.expires),Q.cacheControl&&(H.cacheControl=Q.cacheControl);const he={};if(R){const oe=R.finish();oe&&(he.resourceTiming=JSON.parse(JSON.stringify(oe)))}V.vectorTile=Q.vectorTile;const me=V.parse(Q.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[P]=V,this.fetching[P]={rawTileData:ie,cacheControl:H,resourceTiming:he};try{const oe=yield me;return M.e({rawTileData:ie.slice(0)},oe,H,he)}finally{delete this.fetching[P]}}catch(Q){throw delete this.loading[P],V.status="done",this.loaded[P]=V,Q}})}reloadTile(A){return M._(this,void 0,void 0,function*(){const P=A.uid;if(!this.loaded||!this.loaded[P])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const R=this.loaded[P];if(R.showCollisionBoxes=A.showCollisionBoxes,R.status==="parsing"){const V=yield R.parse(R.vectorTile,this.layerIndex,this.availableImages,this.actor);let K;if(this.fetching[P]){const{rawTileData:Q,cacheControl:ie,resourceTiming:H}=this.fetching[P];delete this.fetching[P],K=M.e({rawTileData:Q.slice(0)},V,ie,H)}else K=V;return K}if(R.status==="done"&&R.vectorTile)return R.parse(R.vectorTile,this.layerIndex,this.availableImages,this.actor)})}abortTile(A){return M._(this,void 0,void 0,function*(){const P=this.loading,R=A.uid;P&&P[R]&&P[R].abort&&(P[R].abort.abort(),delete P[R])})}removeTile(A){return M._(this,void 0,void 0,function*(){this.loaded&&this.loaded[A.uid]&&delete this.loaded[A.uid]})}}class se{constructor(){this.loaded={}}loadTile(A){return M._(this,void 0,void 0,function*(){const{uid:P,encoding:R,rawImageData:V,redFactor:K,greenFactor:Q,blueFactor:ie,baseShift:H}=A,he=V.width+2,me=V.height+2,oe=M.b(V)?new M.R({width:he,height:me},yield M.bw(V,-1,-1,he,me)):V,ve=new M.bx(P,oe,R,K,Q,ie,H);return this.loaded=this.loaded||{},this.loaded[P]=ve,ve})}removeTile(A){const P=this.loaded,R=A.uid;P&&P[R]&&delete P[R]}}function Ot(U,A){if(U.length!==0){qt(U[0],A);for(var P=1;P=Math.abs(ie)?P-H+ie:ie-H+P,P=H}P+R>=0!=!!A&&U.reverse()}var kt=M.by(function U(A,P){var R,V=A&&A.type;if(V==="FeatureCollection")for(R=0;R>31}function Wi(U,A){for(var P=U.loadGeometry(),R=U.type,V=0,K=0,Q=P.length,ie=0;ieU},ri=Math.fround||(ar=new Float32Array(1),U=>(ar[0]=+U,ar[0]));var ar;const ni=3,yi=5,Vi=6;class or{constructor(A){this.options=Object.assign(Object.create(un),A),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(A){const{log:P,minZoom:R,maxZoom:V}=this.options;P&&console.time("total time");const K=`prepare ${A.length} points`;P&&console.time(K),this.points=A;const Q=[];for(let H=0;H=R;H--){const he=+Date.now();ie=this.trees[H]=this._createTree(this._cluster(ie,H)),P&&console.log("z%d: %d clusters in %dms",H,ie.numItems,+Date.now()-he)}return P&&console.timeEnd("total time"),this}getClusters(A,P){let R=((A[0]+180)%360+360)%360-180;const V=Math.max(-90,Math.min(90,A[1]));let K=A[2]===180?180:((A[2]+180)%360+360)%360-180;const Q=Math.max(-90,Math.min(90,A[3]));if(A[2]-A[0]>=360)R=-180,K=180;else if(R>K){const oe=this.getClusters([R,V,180,Q],P),ve=this.getClusters([-180,V,K,Q],P);return oe.concat(ve)}const ie=this.trees[this._limitZoom(P)],H=ie.range(Yt(R),Ai(Q),Yt(K),Ai(V)),he=ie.data,me=[];for(const oe of H){const ve=this.stride*oe;me.push(he[ve+yi]>1?si(he,ve,this.clusterProps):this.points[he[ve+ni]])}return me}getChildren(A){const P=this._getOriginId(A),R=this._getOriginZoom(A),V="No cluster with the specified id.",K=this.trees[R];if(!K)throw new Error(V);const Q=K.data;if(P*this.stride>=Q.length)throw new Error(V);const ie=this.options.radius/(this.options.extent*Math.pow(2,R-1)),H=K.within(Q[P*this.stride],Q[P*this.stride+1],ie),he=[];for(const me of H){const oe=me*this.stride;Q[oe+4]===A&&he.push(Q[oe+yi]>1?si(Q,oe,this.clusterProps):this.points[Q[oe+ni]])}if(he.length===0)throw new Error(V);return he}getLeaves(A,P,R){const V=[];return this._appendLeaves(V,A,P=P||10,R=R||0,0),V}getTile(A,P,R){const V=this.trees[this._limitZoom(A)],K=Math.pow(2,A),{extent:Q,radius:ie}=this.options,H=ie/Q,he=(R-H)/K,me=(R+1+H)/K,oe={features:[]};return this._addTileFeatures(V.range((P-H)/K,he,(P+1+H)/K,me),V.data,P,R,K,oe),P===0&&this._addTileFeatures(V.range(1-H/K,he,1,me),V.data,K,R,K,oe),P===K-1&&this._addTileFeatures(V.range(0,he,H/K,me),V.data,-1,R,K,oe),oe.features.length?oe:null}getClusterExpansionZoom(A){let P=this._getOriginZoom(A)-1;for(;P<=this.options.maxZoom;){const R=this.getChildren(A);if(P++,R.length!==1)break;A=R[0].properties.cluster_id}return P}_appendLeaves(A,P,R,V,K){const Q=this.getChildren(P);for(const ie of Q){const H=ie.properties;if(H&&H.cluster?K+H.point_count<=V?K+=H.point_count:K=this._appendLeaves(A,H.cluster_id,R,V,K):K1;let me,oe,ve;if(he)me=Sr(P,H,this.clusterProps),oe=P[H],ve=P[H+1];else{const ot=this.points[P[H+ni]];me=ot.properties;const[Ke,lt]=ot.geometry.coordinates;oe=Yt(Ke),ve=Ai(lt)}const Ve={type:1,geometry:[[Math.round(this.options.extent*(oe*K-R)),Math.round(this.options.extent*(ve*K-V))]],tags:me};let Ne;Ne=he||this.options.generateId?P[H+ni]:this.points[P[H+ni]].id,Ne!==void 0&&(Ve.id=Ne),Q.features.push(Ve)}}_limitZoom(A){return Math.max(this.options.minZoom,Math.min(Math.floor(+A),this.options.maxZoom+1))}_cluster(A,P){const{radius:R,extent:V,reduce:K,minPoints:Q}=this.options,ie=R/(V*Math.pow(2,P)),H=A.data,he=[],me=this.stride;for(let oe=0;oeP&&(Ke+=H[rt+yi])}if(Ke>ot&&Ke>=Q){let lt,rt=ve*ot,Ut=Ve*ot,zt=-1;const tt=((oe/me|0)<<5)+(P+1)+this.points.length;for(const ft of Ne){const Ct=ft*me;if(H[Ct+2]<=P)continue;H[Ct+2]=P;const Ht=H[Ct+yi];rt+=H[Ct]*Ht,Ut+=H[Ct+1]*Ht,H[Ct+4]=tt,K&&(lt||(lt=this._map(H,oe,!0),zt=this.clusterProps.length,this.clusterProps.push(lt)),K(lt,this._map(H,Ct)))}H[oe+4]=tt,he.push(rt/Ke,Ut/Ke,1/0,tt,-1,Ke),K&&he.push(zt)}else{for(let lt=0;lt1)for(const lt of Ne){const rt=lt*me;if(!(H[rt+2]<=P)){H[rt+2]=P;for(let Ut=0;Ut>5}_getOriginZoom(A){return(A-this.points.length)%32}_map(A,P,R){if(A[P+yi]>1){const Q=this.clusterProps[A[P+Vi]];return R?Object.assign({},Q):Q}const V=this.points[A[P+ni]].properties,K=this.options.map(V);return R&&K===V?Object.assign({},K):K}}function si(U,A,P){return{type:"Feature",id:U[A+ni],properties:Sr(U,A,P),geometry:{type:"Point",coordinates:[(R=U[A],360*(R-.5)),Ir(U[A+1])]}};var R}function Sr(U,A,P){const R=U[A+yi],V=R>=1e4?`${Math.round(R/1e3)}k`:R>=1e3?Math.round(R/100)/10+"k":R,K=U[A+Vi],Q=K===-1?{}:Object.assign({},P[K]);return Object.assign(Q,{cluster:!0,cluster_id:U[A+ni],point_count:R,point_count_abbreviated:V})}function Yt(U){return U/360+.5}function Ai(U){const A=Math.sin(U*Math.PI/180),P=.5-.25*Math.log((1+A)/(1-A))/Math.PI;return P<0?0:P>1?1:P}function Ir(U){const A=(180-360*U)*Math.PI/180;return 360*Math.atan(Math.exp(A))/Math.PI-90}function Vr(U,A,P,R){let V=R;const K=A+(P-A>>1);let Q,ie=P-A;const H=U[A],he=U[A+1],me=U[P],oe=U[P+1];for(let ve=A+3;veV)Q=ve,V=Ve;else if(Ve===V){const Ne=Math.abs(ve-K);NeR&&(Q-A>3&&Vr(U,A,Q,R),U[Q+2]=V,P-Q>3&&Vr(U,Q,P,R))}function Xr(U,A,P,R,V,K){let Q=V-P,ie=K-R;if(Q!==0||ie!==0){const H=((U-P)*Q+(A-R)*ie)/(Q*Q+ie*ie);H>1?(P=V,R=K):H>0&&(P+=Q*H,R+=ie*H)}return Q=U-P,ie=A-R,Q*Q+ie*ie}function Ki(U,A,P,R){const V={id:U??null,type:A,geometry:P,tags:R,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(A==="Point"||A==="MultiPoint"||A==="LineString")lr(V,P);else if(A==="Polygon")lr(V,P[0]);else if(A==="MultiLineString")for(const K of P)lr(V,K);else if(A==="MultiPolygon")for(const K of P)lr(V,K[0]);return V}function lr(U,A){for(let P=0;P0&&(Q+=R?(V*me-he*K)/2:Math.sqrt(Math.pow(he-V,2)+Math.pow(me-K,2))),V=he,K=me}const ie=A.length-3;A[2]=1,Vr(A,0,ie,P),A[ie+2]=1,A.size=Math.abs(Q),A.start=0,A.end=A.size}function dn(U,A,P,R){for(let V=0;V1?1:P}function Et(U,A,P,R,V,K,Q,ie){if(R/=A,K>=(P/=A)&&Q=R)return null;const H=[];for(const he of U){const me=he.geometry;let oe=he.type;const ve=V===0?he.minX:he.minY,Ve=V===0?he.maxX:he.maxY;if(ve>=P&&Ve=R)continue;let Ne=[];if(oe==="Point"||oe==="MultiPoint")fs(me,Ne,P,R,V);else if(oe==="LineString")Kr(me,Ne,P,R,V,!1,ie.lineMetrics);else if(oe==="MultiLineString")En(me,Ne,P,R,V,!1);else if(oe==="Polygon")En(me,Ne,P,R,V,!0);else if(oe==="MultiPolygon")for(const ot of me){const Ke=[];En(ot,Ke,P,R,V,!0),Ke.length&&Ne.push(Ke)}if(Ne.length){if(ie.lineMetrics&&oe==="LineString"){for(const ot of Ne)H.push(Ki(he.id,oe,ot,he.tags));continue}oe!=="LineString"&&oe!=="MultiLineString"||(Ne.length===1?(oe="LineString",Ne=Ne[0]):oe="MultiLineString"),oe!=="Point"&&oe!=="MultiPoint"||(oe=Ne.length===3?"Point":"MultiPoint"),H.push(Ki(he.id,oe,Ne,he.tags))}}return H.length?H:null}function fs(U,A,P,R,V){for(let K=0;K=P&&Q<=R&&Ji(A,U[K],U[K+1],U[K+2])}}function Kr(U,A,P,R,V,K,Q){let ie=Nr(U);const H=V===0?ms:gs;let he,me,oe=U.start;for(let Ke=0;KeP&&(me=H(ie,lt,rt,zt,tt,P),Q&&(ie.start=oe+he*me)):ft>R?Ct=P&&(me=H(ie,lt,rt,zt,tt,P),Ht=!0),Ct>R&&ft<=R&&(me=H(ie,lt,rt,zt,tt,R),Ht=!0),!K&&Ht&&(Q&&(ie.end=oe+he*me),A.push(ie),ie=Nr(U)),Q&&(oe+=he)}let ve=U.length-3;const Ve=U[ve],Ne=U[ve+1],ot=V===0?Ve:Ne;ot>=P&&ot<=R&&Ji(ie,Ve,Ne,U[ve+2]),ve=ie.length-3,K&&ve>=3&&(ie[ve]!==ie[0]||ie[ve+1]!==ie[1])&&Ji(ie,ie[0],ie[1],ie[2]),ie.length&&A.push(ie)}function Nr(U){const A=[];return A.size=U.size,A.start=U.start,A.end=U.end,A}function En(U,A,P,R,V,K){for(const Q of U)Kr(Q,A,P,R,V,K,!1)}function Ji(U,A,P,R){U.push(A,P,R)}function ms(U,A,P,R,V,K){const Q=(K-A)/(R-A);return Ji(U,K,P+(V-P)*Q,1),Q}function gs(U,A,P,R,V,K){const Q=(K-P)/(V-P);return Ji(U,A+(R-A)*Q,K,1),Q}function xe(U,A){const P=[];for(let R=0;R0&&A.size<(V?Q:R))return void(P.numPoints+=A.length/3);const ie=[];for(let H=0;HQ)&&(P.numSimplified++,ie.push(A[H],A[H+1])),P.numPoints++;V&&function(H,he){let me=0;for(let oe=0,ve=H.length,Ve=ve-2;oe0===he)for(let oe=0,ve=H.length;oe24)throw new Error("maxZoom should be in the 0-24 range");if(P.promoteId&&P.generateId)throw new Error("promoteId and generateId cannot be used together.");let V=function(K,Q){const ie=[];if(K.type==="FeatureCollection")for(let H=0;H1&&console.time("creation"),Ve=this.tiles[ve]=Jr(A,P,R,V,he),this.tileCoords.push({z:P,x:R,y:V}),me)){me>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",P,R,V,Ve.numFeatures,Ve.numPoints,Ve.numSimplified),console.timeEnd("creation"));const Ht=`z${P}`;this.stats[Ht]=(this.stats[Ht]||0)+1,this.total++}if(Ve.source=A,K==null){if(P===he.indexMaxZoom||Ve.numPoints<=he.indexMaxPoints)continue}else{if(P===he.maxZoom||P===K)continue;if(K!=null){const Ht=K-P;if(R!==Q>>Ht||V!==ie>>Ht)continue}}if(Ve.source=null,A.length===0)continue;me>1&&console.time("clipping");const Ne=.5*he.buffer/he.extent,ot=.5-Ne,Ke=.5+Ne,lt=1+Ne;let rt=null,Ut=null,zt=null,tt=null,ft=Et(A,oe,R-Ne,R+Ke,0,Ve.minX,Ve.maxX,he),Ct=Et(A,oe,R+ot,R+lt,0,Ve.minX,Ve.maxX,he);A=null,ft&&(rt=Et(ft,oe,V-Ne,V+Ke,1,Ve.minY,Ve.maxY,he),Ut=Et(ft,oe,V+ot,V+lt,1,Ve.minY,Ve.maxY,he),ft=null),Ct&&(zt=Et(Ct,oe,V-Ne,V+Ke,1,Ve.minY,Ve.maxY,he),tt=Et(Ct,oe,V+ot,V+lt,1,Ve.minY,Ve.maxY,he),Ct=null),me>1&&console.timeEnd("clipping"),H.push(rt||[],P+1,2*R,2*V),H.push(Ut||[],P+1,2*R,2*V+1),H.push(zt||[],P+1,2*R+1,2*V),H.push(tt||[],P+1,2*R+1,2*V+1)}}getTile(A,P,R){A=+A,P=+P,R=+R;const V=this.options,{extent:K,debug:Q}=V;if(A<0||A>24)return null;const ie=1<1&&console.log("drilling down to z%d-%d-%d",A,P,R);let he,me=A,oe=P,ve=R;for(;!he&&me>0;)me--,oe>>=1,ve>>=1,he=this.tiles[cr(me,oe,ve)];return he&&he.source?(Q>1&&(console.log("found parent tile z%d-%d-%d",me,oe,ve),console.time("drilling down")),this.splitTile(he.source,me,oe,ve,A,P,R),Q>1&&console.timeEnd("drilling down"),this.tiles[H]?xi(this.tiles[H],K):null):null}}function cr(U,A,P){return 32*((1<{oe.properties=Ve;const Ne={};for(const ot of ve)Ne[ot]=H[ot].evaluate(me,oe);return Ne},Q.reduce=(Ve,Ne)=>{oe.properties=Ne;for(const ot of ve)me.accumulated=Ve[ot],Ve[ot]=he[ot].evaluate(me,oe)},Q}(A)).load((yield this._pendingData).features):(V=yield this._pendingData,new Ci(V,A.geojsonVtOptions)),this.loaded={};const K={};if(R){const Q=R.finish();Q&&(K.resourceTiming={},K.resourceTiming[A.source]=JSON.parse(JSON.stringify(Q)))}return K}catch(K){if(delete this._pendingRequest,M.bB(K))return{abandoned:!0};throw K}var V})}getData(){return M._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(A){const P=this.loaded;return P&&P[A.uid]?super.reloadTile(A):this.loadTile(A)}loadAndProcessGeoJSON(A,P){return M._(this,void 0,void 0,function*(){let R=yield this.loadGeoJSON(A,P);if(delete this._pendingRequest,typeof R!="object")throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`);if(kt(R,!0),A.filter){const V=M.bC(A.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(V.result==="error")throw new Error(V.value.map(Q=>`${Q.key}: ${Q.message}`).join(", "));R={type:"FeatureCollection",features:R.features.filter(Q=>V.value.evaluate({zoom:0},Q))}}return R})}loadGeoJSON(A,P){return M._(this,void 0,void 0,function*(){const{promoteId:R}=A;if(A.request){const V=yield M.h(A.request,P);return this._dataUpdateable=Cr(V.data,R)?Ur(V.data,R):void 0,V.data}if(typeof A.data=="string")try{const V=JSON.parse(A.data);return this._dataUpdateable=Cr(V,R)?Ur(V,R):void 0,V}catch{throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`)}if(!A.dataDiff)throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${A.source}`);return function(V,K,Q){var ie,H,he,me;if(K.removeAll&&V.clear(),K.remove)for(const oe of K.remove)V.delete(oe);if(K.add)for(const oe of K.add){const ve=We(oe,Q);ve!=null&&V.set(ve,oe)}if(K.update)for(const oe of K.update){let ve=V.get(oe.id);if(ve==null)continue;const Ve=!oe.removeAllProperties&&(((ie=oe.removeProperties)===null||ie===void 0?void 0:ie.length)>0||((H=oe.addOrUpdateProperties)===null||H===void 0?void 0:H.length)>0);if((oe.newGeometry||oe.removeAllProperties||Ve)&&(ve=Object.assign({},ve),V.set(oe.id,ve),Ve&&(ve.properties=Object.assign({},ve.properties))),oe.newGeometry&&(ve.geometry=oe.newGeometry),oe.removeAllProperties)ve.properties={};else if(((he=oe.removeProperties)===null||he===void 0?void 0:he.length)>0)for(const Ne of oe.removeProperties)Object.prototype.hasOwnProperty.call(ve.properties,Ne)&&delete ve.properties[Ne];if(((me=oe.addOrUpdateProperties)===null||me===void 0?void 0:me.length)>0)for(const{key:Ne,value:ot}of oe.addOrUpdateProperties)ve.properties[Ne]=ot}}(this._dataUpdateable,A.dataDiff,R),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(A){return M._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(A){return this._geoJSONIndex.getClusterExpansionZoom(A.clusterId)}getClusterChildren(A){return this._geoJSONIndex.getChildren(A.clusterId)}getClusterLeaves(A){return this._geoJSONIndex.getLeaves(A.clusterId,A.limit,A.offset)}}class Mr{constructor(A){this.self=A,this.actor=new M.F(A),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(P,R)=>{if(this.externalWorkerSourceTypes[P])throw new Error(`Worker source with name "${P}" already registered.`);this.externalWorkerSourceTypes[P]=R},this.self.addProtocol=M.bi,this.self.removeProtocol=M.bj,this.self.registerRTLTextPlugin=P=>{if(M.bD.isParsed())throw new Error("RTL text plugin already registered.");M.bD.setMethods(P)},this.actor.registerMessageHandler("LDT",(P,R)=>this._getDEMWorkerSource(P,R.source).loadTile(R)),this.actor.registerMessageHandler("RDT",(P,R)=>M._(this,void 0,void 0,function*(){this._getDEMWorkerSource(P,R.source).removeTile(R)})),this.actor.registerMessageHandler("GCEZ",(P,R)=>M._(this,void 0,void 0,function*(){return this._getWorkerSource(P,R.type,R.source).getClusterExpansionZoom(R)})),this.actor.registerMessageHandler("GCC",(P,R)=>M._(this,void 0,void 0,function*(){return this._getWorkerSource(P,R.type,R.source).getClusterChildren(R)})),this.actor.registerMessageHandler("GCL",(P,R)=>M._(this,void 0,void 0,function*(){return this._getWorkerSource(P,R.type,R.source).getClusterLeaves(R)})),this.actor.registerMessageHandler("LD",(P,R)=>this._getWorkerSource(P,R.type,R.source).loadData(R)),this.actor.registerMessageHandler("GD",(P,R)=>this._getWorkerSource(P,R.type,R.source).getData()),this.actor.registerMessageHandler("LT",(P,R)=>this._getWorkerSource(P,R.type,R.source).loadTile(R)),this.actor.registerMessageHandler("RT",(P,R)=>this._getWorkerSource(P,R.type,R.source).reloadTile(R)),this.actor.registerMessageHandler("AT",(P,R)=>this._getWorkerSource(P,R.type,R.source).abortTile(R)),this.actor.registerMessageHandler("RMT",(P,R)=>this._getWorkerSource(P,R.type,R.source).removeTile(R)),this.actor.registerMessageHandler("RS",(P,R)=>M._(this,void 0,void 0,function*(){if(!this.workerSources[P]||!this.workerSources[P][R.type]||!this.workerSources[P][R.type][R.source])return;const V=this.workerSources[P][R.type][R.source];delete this.workerSources[P][R.type][R.source],V.removeSource!==void 0&&V.removeSource(R)})),this.actor.registerMessageHandler("RM",P=>M._(this,void 0,void 0,function*(){delete this.layerIndexes[P],delete this.availableImages[P],delete this.workerSources[P],delete this.demWorkerSources[P]})),this.actor.registerMessageHandler("SR",(P,R)=>M._(this,void 0,void 0,function*(){this.referrer=R})),this.actor.registerMessageHandler("SRPS",(P,R)=>this._syncRTLPluginState(P,R)),this.actor.registerMessageHandler("IS",(P,R)=>M._(this,void 0,void 0,function*(){this.self.importScripts(R)})),this.actor.registerMessageHandler("SI",(P,R)=>this._setImages(P,R)),this.actor.registerMessageHandler("UL",(P,R)=>M._(this,void 0,void 0,function*(){this._getLayerIndex(P).update(R.layers,R.removedIds)})),this.actor.registerMessageHandler("SL",(P,R)=>M._(this,void 0,void 0,function*(){this._getLayerIndex(P).replace(R)}))}_setImages(A,P){return M._(this,void 0,void 0,function*(){this.availableImages[A]=P;for(const R in this.workerSources[A]){const V=this.workerSources[A][R];for(const K in V)V[K].availableImages=P}})}_syncRTLPluginState(A,P){return M._(this,void 0,void 0,function*(){if(M.bD.isParsed())return M.bD.getState();if(P.pluginStatus!=="loading")return M.bD.setState(P),P;const R=P.pluginURL;if(this.self.importScripts(R),M.bD.isParsed()){const V={pluginStatus:"loaded",pluginURL:R};return M.bD.setState(V),V}throw M.bD.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${R}`)})}_getAvailableImages(A){let P=this.availableImages[A];return P||(P=[]),P}_getLayerIndex(A){let P=this.layerIndexes[A];return P||(P=this.layerIndexes[A]=new p),P}_getWorkerSource(A,P,R){if(this.workerSources[A]||(this.workerSources[A]={}),this.workerSources[A][P]||(this.workerSources[A][P]={}),!this.workerSources[A][P][R]){const V={sendAsync:(K,Q)=>(K.targetMapId=A,this.actor.sendAsync(K,Q))};switch(P){case"vector":this.workerSources[A][P][R]=new ue(V,this._getLayerIndex(A),this._getAvailableImages(A));break;case"geojson":this.workerSources[A][P][R]=new Yr(V,this._getLayerIndex(A),this._getAvailableImages(A));break;default:this.workerSources[A][P][R]=new this.externalWorkerSourceTypes[P](V,this._getLayerIndex(A),this._getAvailableImages(A))}}return this.workerSources[A][P][R]}_getDEMWorkerSource(A,P){return this.demWorkerSources[A]||(this.demWorkerSources[A]={}),this.demWorkerSources[A][P]||(this.demWorkerSources[A][P]=new se),this.demWorkerSources[A][P]}}return M.i(self)&&(self.worker=new Mr(self)),Mr}),de("index",["exports","./shared"],function(M,p){var Je="4.7.1";let Ge,He;const ue={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:h=>new Promise((e,n)=>{const a=requestAnimationFrame(e);h.signal.addEventListener("abort",()=>{cancelAnimationFrame(a),n(p.c())})}),getImageData(h,e=0){return this.getImageCanvasContext(h).getImageData(-e,-e,h.width+2*e,h.height+2*e)},getImageCanvasContext(h){const e=window.document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return e.width=h.width,e.height=h.height,n.drawImage(h,0,0,h.width,h.height),n},resolveURL:h=>(Ge||(Ge=document.createElement("a")),Ge.href=h,Ge.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(He==null&&(He=matchMedia("(prefers-reduced-motion: reduce)")),He.matches)}};class se{static testProp(e){if(!se.docStyle)return e[0];for(let n=0;n{window.removeEventListener("click",se.suppressClickInternal,!0)},0)}static getScale(e){const n=e.getBoundingClientRect();return{x:n.width/e.offsetWidth||1,y:n.height/e.offsetHeight||1,boundingClientRect:n}}static getPoint(e,n,a){const o=n.boundingClientRect;return new p.P((a.clientX-o.left)/n.x-e.clientLeft,(a.clientY-o.top)/n.y-e.clientTop)}static mousePos(e,n){const a=se.getScale(e);return se.getPoint(e,a,n)}static touchPos(e,n){const a=[],o=se.getScale(e);for(let c=0;c{qt&&Fr(qt),qt=null,Fi=!0},kt.onerror=()=>{Ii=!0,qt=null},kt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(h){let e,n,a,o;h.resetRequestQueue=()=>{e=[],n=0,a=0,o={}},h.addThrottleControl=y=>{const b=a++;return o[b]=y,b},h.removeThrottleControl=y=>{delete o[y],m()},h.getImage=(y,b,T=!0)=>new Promise((S,k)=>{Ot.supported&&(y.headers||(y.headers={}),y.headers.accept="image/webp,*/*"),p.e(y,{type:"image"}),e.push({abortController:b,requestParameters:y,supportImageRefresh:T,state:"queued",onError:D=>{k(D)},onSuccess:D=>{S(D)}}),m()});const c=y=>p._(this,void 0,void 0,function*(){y.state="running";const{requestParameters:b,supportImageRefresh:T,onError:S,onSuccess:k,abortController:D}=y,B=T===!1&&!p.i(self)&&!p.g(b.url)&&(!b.headers||Object.keys(b.headers).reduce((Z,X)=>Z&&X==="accept",!0));n++;const N=B?_(b,D):p.m(b,D);try{const Z=yield N;delete y.abortController,y.state="completed",Z.data instanceof HTMLImageElement||p.b(Z.data)?k(Z):Z.data&&k({data:yield(q=Z.data,typeof createImageBitmap=="function"?p.d(q):p.f(q)),cacheControl:Z.cacheControl,expires:Z.expires})}catch(Z){delete y.abortController,S(Z)}finally{n--,m()}var q}),m=()=>{const y=(()=>{for(const b of Object.keys(o))if(o[b]())return!0;return!1})()?p.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:p.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let b=n;b0;b++){const T=e.shift();T.abortController.signal.aborted?b--:c(T)}},_=(y,b)=>new Promise((T,S)=>{const k=new Image,D=y.url,B=y.credentials;B&&B==="include"?k.crossOrigin="use-credentials":(B&&B==="same-origin"||!p.s(D))&&(k.crossOrigin="anonymous"),b.signal.addEventListener("abort",()=>{k.src="",S(p.c())}),k.fetchPriority="high",k.onload=()=>{k.onerror=k.onload=null,T({data:k})},k.onerror=()=>{k.onerror=k.onload=null,b.signal.aborted||S(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."))},k.src=D})}(Mt||(Mt={})),Mt.resetRequestQueue();class ln{constructor(e){this._transformRequestFn=e}transformRequest(e,n){return this._transformRequestFn&&this._transformRequestFn(e,n)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function mi(h){var e=new p.A(3);return e[0]=h[0],e[1]=h[1],e[2]=h[2],e}var Pi,gi=function(h,e,n){return h[0]=e[0]-n[0],h[1]=e[1]-n[1],h[2]=e[2]-n[2],h};Pi=new p.A(3),p.A!=Float32Array&&(Pi[0]=0,Pi[1]=0,Pi[2]=0);var cn=function(h){var e=h[0],n=h[1];return e*e+n*n};function ii(h){const e=[];if(typeof h=="string")e.push({id:"default",url:h});else if(h&&h.length>0){const n=[];for(const{id:a,url:o}of h){const c=`${a}${o}`;n.indexOf(c)===-1&&(n.push(c),e.push({id:a,url:o}))}}return e}function Or(h,e,n){const a=h.split("?");return a[0]+=`${e}${n}`,a.join("?")}(function(){var h=new p.A(2);p.A!=Float32Array&&(h[0]=0,h[1]=0)})();class et{constructor(e,n,a,o){this.context=e,this.format=a,this.texture=e.gl.createTexture(),this.update(n,o)}update(e,n,a){const{width:o,height:c}=e,m=!(this.size&&this.size[0]===o&&this.size[1]===c||a),{context:_}=this,{gl:y}=_;if(this.useMipmap=!!(n&&n.useMipmap),y.bindTexture(y.TEXTURE_2D,this.texture),_.pixelStoreUnpackFlipY.set(!1),_.pixelStoreUnpack.set(1),_.pixelStoreUnpackPremultiplyAlpha.set(this.format===y.RGBA&&(!n||n.premultiply!==!1)),m)this.size=[o,c],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||p.b(e)?y.texImage2D(y.TEXTURE_2D,0,this.format,this.format,y.UNSIGNED_BYTE,e):y.texImage2D(y.TEXTURE_2D,0,this.format,o,c,0,this.format,y.UNSIGNED_BYTE,e.data);else{const{x:b,y:T}=a||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||p.b(e)?y.texSubImage2D(y.TEXTURE_2D,0,b,T,y.RGBA,y.UNSIGNED_BYTE,e):y.texSubImage2D(y.TEXTURE_2D,0,b,T,o,c,y.RGBA,y.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&y.generateMipmap(y.TEXTURE_2D)}bind(e,n,a){const{context:o}=this,{gl:c}=o;c.bindTexture(c.TEXTURE_2D,this.texture),a!==c.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(a=c.LINEAR),e!==this.filter&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,e),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a||e),this.filter=e),n!==this.wrap&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,n),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,n),this.wrap=n)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}function hn(h){const{userImage:e}=h;return!!(e&&e.render&&e.render())&&(h.data.replace(new Uint8Array(e.data.buffer)),!0)}class Gt extends p.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new p.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:n,promiseResolve:a}of this.requestors)a(this._getImagesForIds(n));this.requestors=[]}}getImage(e){const n=this.images[e];if(n&&!n.data&&n.spriteData){const a=n.spriteData;n.data=new p.R({width:a.width,height:a.height},a.context.getImageData(a.x,a.y,a.width,a.height).data),n.spriteData=null}return n}addImage(e,n){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,n)&&(this.images[e]=n)}_validate(e,n){let a=!0;const o=n.data||n.spriteData;return this._validateStretch(n.stretchX,o&&o.width)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "stretchX" value`))),a=!1),this._validateStretch(n.stretchY,o&&o.height)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "stretchY" value`))),a=!1),this._validateContent(n.content,n)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "content" value`))),a=!1),a}_validateStretch(e,n){if(!e)return!0;let a=0;for(const o of e){if(o[0]{let o=!0;if(!this.isLoaded())for(const c of e)this.images[c]||(o=!1);this.isLoaded()||o?n(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:n})})}_getImagesForIds(e){const n={};for(const a of e){let o=this.getImage(a);o||(this.fire(new p.k("styleimagemissing",{id:a})),o=this.getImage(a)),o?n[a]={data:o.data.clone(),pixelRatio:o.pixelRatio,sdf:o.sdf,version:o.version,stretchX:o.stretchX,stretchY:o.stretchY,content:o.content,textFitWidth:o.textFitWidth,textFitHeight:o.textFitHeight,hasRenderCallback:!!(o.userImage&&o.userImage.render)}:p.w(`Image "${a}" 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 n}getPixelSize(){const{width:e,height:n}=this.atlasImage;return{width:e,height:n}}getPattern(e){const n=this.patterns[e],a=this.getImage(e);if(!a)return null;if(n&&n.position.version===a.version)return n.position;if(n)n.position.version=a.version;else{const o={w:a.data.width+2,h:a.data.height+2,x:0,y:0},c=new p.I(o,a);this.patterns[e]={bin:o,position:c}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const n=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new et(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const c in this.patterns)e.push(this.patterns[c].bin);const{w:n,h:a}=p.p(e),o=this.atlasImage;o.resize({width:n||1,height:a||1});for(const c in this.patterns){const{bin:m}=this.patterns[c],_=m.x+1,y=m.y+1,b=this.getImage(c).data,T=b.width,S=b.height;p.R.copy(b,o,{x:0,y:0},{x:_,y},{width:T,height:S}),p.R.copy(b,o,{x:0,y:S-1},{x:_,y:y-1},{width:T,height:1}),p.R.copy(b,o,{x:0,y:0},{x:_,y:y+S},{width:T,height:1}),p.R.copy(b,o,{x:T-1,y:0},{x:_-1,y},{width:1,height:S}),p.R.copy(b,o,{x:0,y:0},{x:_+T,y},{width:1,height:S})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const a=this.getImage(n);a||p.w(`Image with ID: "${n}" was not found`),hn(a)&&this.updateImage(n,a)}}}const Jt=1e20;function Wi(h,e,n,a,o,c,m,_,y){for(let b=e;b-1);y++,c[y]=_,m[y]=b,m[y+1]=Jt}for(let _=0,y=0;_65535)throw new Error("glyphs > 65535 not supported");if(a.ranges[c])return{stack:e,id:n,glyph:o};if(!this.url)throw new Error("glyphsUrl is not set");if(!a.requests[c]){const _=_i.loadGlyphRange(e,c,this.url,this.requestManager);a.requests[c]=_}const m=yield a.requests[c];for(const _ in m)this._doesCharSupportLocalGlyph(+_)||(a.glyphs[+_]=m[+_]);return a.ranges[c]=!0,{stack:e,id:n,glyph:m[n]||null}})}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&new RegExp("\\p{Ideo}|\\p{sc=Hang}|\\p{sc=Hira}|\\p{sc=Kana}","u").test(String.fromCodePoint(e))}_tinySDF(e,n,a){const o=this.localIdeographFontFamily;if(!o||!this._doesCharSupportLocalGlyph(a))return;let c=e.tinySDF;if(!c){let _="400";/bold/i.test(n)?_="900":/medium/i.test(n)?_="500":/light/i.test(n)&&(_="200"),c=e.tinySDF=new _i.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:_})}const m=c.draw(String.fromCharCode(a));return{id:a,bitmap:new p.o({width:m.width||60,height:m.height||60},m.data),metrics:{width:m.glyphWidth/2||24,height:m.glyphHeight/2||24,left:m.glyphLeft/2+.5||0,top:m.glyphTop/2-27.5||-8,advance:m.glyphAdvance/2||24,isDoubleResolution:!0}}}}_i.loadGlyphRange=function(h,e,n,a){return p._(this,void 0,void 0,function*(){const o=256*e,c=o+255,m=a.transformRequest(n.replace("{fontstack}",h).replace("{range}",`${o}-${c}`),"Glyphs"),_=yield p.l(m,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${e}, ${o}-${c}`);const y={};for(const b of p.n(_.data))y[b.id]=b;return y})},_i.TinySDF=class{constructor({fontSize:h=24,buffer:e=3,radius:n=8,cutoff:a=.25,fontFamily:o="sans-serif",fontWeight:c="normal",fontStyle:m="normal"}={}){this.buffer=e,this.cutoff=a,this.radius=n;const _=this.size=h+4*e,y=this._createCanvas(_),b=this.ctx=y.getContext("2d",{willReadFrequently:!0});b.font=`${m} ${c} ${h}px ${o}`,b.textBaseline="alphabetic",b.textAlign="left",b.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(h){const e=document.createElement("canvas");return e.width=e.height=h,e}draw(h){const{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:a,actualBoundingBoxLeft:o,actualBoundingBoxRight:c}=this.ctx.measureText(h),m=Math.ceil(n),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(c-o))),y=Math.min(this.size-this.buffer,m+Math.ceil(a)),b=_+2*this.buffer,T=y+2*this.buffer,S=Math.max(b*T,0),k=new Uint8ClampedArray(S),D={data:k,width:b,height:T,glyphWidth:_,glyphHeight:y,glyphTop:m,glyphLeft:0,glyphAdvance:e};if(_===0||y===0)return D;const{ctx:B,buffer:N,gridInner:q,gridOuter:Z}=this;B.clearRect(N,N,_,y),B.fillText(h,N,N+m);const X=B.getImageData(N,N,_,y);Z.fill(Jt,0,S),q.fill(0,0,S);for(let F=0;F0?fe*fe:0,q[ae]=fe<0?fe*fe:0}}Wi(Z,0,0,b,T,b,this.f,this.v,this.z),Wi(q,N,N,_,y,b,this.f,this.v,this.z);for(let F=0;F1&&(y=e[++_]);const T=Math.abs(b-y.left),S=Math.abs(b-y.right),k=Math.min(T,S);let D;const B=c/a*(o+1);if(y.isDash){const N=o-Math.abs(B);D=Math.sqrt(k*k+N*N)}else D=o-Math.sqrt(k*k+B*B);this.data[m+b]=Math.max(0,Math.min(255,D+128))}}}addRegularDash(e){for(let _=e.length-1;_>=0;--_){const y=e[_],b=e[_+1];y.zeroLength?e.splice(_,1):b&&b.isDash===y.isDash&&(b.left=y.left,e.splice(_,1))}const n=e[0],a=e[e.length-1];n.isDash===a.isDash&&(n.left=a.left-this.width,a.right=n.right+this.width);const o=this.width*this.nextRow;let c=0,m=e[c];for(let _=0;_1&&(m=e[++c]);const y=Math.abs(_-m.left),b=Math.abs(_-m.right),T=Math.min(y,b);this.data[o+_]=Math.max(0,Math.min(255,(m.isDash?T:-T)+128))}}addDash(e,n){const a=n?7:0,o=2*a+1;if(this.nextRow+o>this.height)return p.w("LineAtlas out of space"),null;let c=0;for(let _=0;_{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[or]}numActive(){return Object.keys(this.active).length}}const Sr=Math.floor(ue.hardwareConcurrency/2);let Yt,Ai;function Ir(){return Yt||(Yt=new si),Yt}si.workerCount=p.C(globalThis)?Math.max(Math.min(Sr,3),1):1;class Vr{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;const a=this.workerPool.acquire(n);for(let o=0;o{n.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,n){for(const a of this.actors)a.registerMessageHandler(e,n)}}function Xr(){return Ai||(Ai=new Vr(Ir(),p.G),Ai.registerMessageHandler("GR",(h,e,n)=>p.m(e,n))),Ai}function Ki(h,e){const n=p.H();return p.J(n,n,[1,1,0]),p.K(n,n,[.5*h.width,.5*h.height,1]),p.L(n,n,h.calculatePosMatrix(e.toUnwrapped()))}function lr(h,e,n,a,o,c){const m=function(S,k,D){if(S)for(const B of S){const N=k[B];if(N&&N.source===D&&N.type==="fill-extrusion")return!0}else for(const B in k){const N=k[B];if(N.source===D&&N.type==="fill-extrusion")return!0}return!1}(o&&o.layers,e,h.id),_=c.maxPitchScaleFactor(),y=h.tilesIn(a,_,m);y.sort(Wr);const b=[];for(const S of y)b.push({wrappedTileID:S.tileID.wrapped().key,queryResults:S.tile.queryRenderedFeatures(e,n,h._state,S.queryGeometry,S.cameraQueryGeometry,S.scale,o,c,_,Ki(h.transform,S.tileID))});const T=function(S){const k={},D={};for(const B of S){const N=B.queryResults,q=B.wrappedTileID,Z=D[q]=D[q]||{};for(const X in N){const F=N[X],Y=Z[X]=Z[X]||{},ee=k[X]=k[X]||[];for(const ae of F)Y[ae.featureIndex]||(Y[ae.featureIndex]=!0,ee.push(ae))}}return k}(b);for(const S in T)T[S].forEach(k=>{const D=k.feature,B=h.getFeatureState(D.layer["source-layer"],D.id);D.source=D.layer.source,D.layer["source-layer"]&&(D.sourceLayer=D.layer["source-layer"]),D.state=B});return T}function Wr(h,e){const n=h.tileID,a=e.tileID;return n.overscaledZ-a.overscaledZ||n.canonical.y-a.canonical.y||n.wrap-a.wrap||n.canonical.x-a.canonical.x}function kn(h,e,n){return p._(this,void 0,void 0,function*(){let a=h;if(h.url?a=(yield p.h(e.transformRequest(h.url,"Source"),n)).data:yield ue.frameAsync(n),!a)return null;const o=p.M(p.e(a,h),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(o.vectorLayerIds=a.vector_layers.map(c=>c.id)),o})}class le{constructor(e,n){e&&(n?this.setSouthWest(e).setNorthEast(n):Array.isArray(e)&&(e.length===4?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 p.N?new p.N(e.lng,e.lat):p.N.convert(e),this}setSouthWest(e){return this._sw=e instanceof p.N?new p.N(e.lng,e.lat):p.N.convert(e),this}extend(e){const n=this._sw,a=this._ne;let o,c;if(e instanceof p.N)o=e,c=e;else{if(!(e instanceof le))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(le.convert(e)):this.extend(p.N.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(p.N.convert(e)):this;if(o=e._sw,c=e._ne,!o||!c)return this}return n||a?(n.lng=Math.min(o.lng,n.lng),n.lat=Math.min(o.lat,n.lat),a.lng=Math.max(c.lng,a.lng),a.lat=Math.max(c.lat,a.lat)):(this._sw=new p.N(o.lng,o.lat),this._ne=new p.N(c.lng,c.lat)),this}getCenter(){return new p.N((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 p.N(this.getWest(),this.getNorth())}getSouthEast(){return new p.N(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:n,lat:a}=p.N.convert(e);let o=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&o}static convert(e){return e instanceof le?e:e&&new le(e)}static fromLngLat(e,n=0){const a=360*n/40075017,o=a/Math.cos(Math.PI/180*e.lat);return new le(new p.N(e.lng-o,e.lat-a),new p.N(e.lng+o,e.lat+a))}adjustAntiMeridian(){const e=new p.N(this._sw.lng,this._sw.lat),n=new p.N(this._ne.lng,this._ne.lat);return new le(e,e.lng>n.lng?new p.N(n.lng+360,n.lat):n)}}class dn{constructor(e,n,a){this.bounds=le.convert(this.validateBounds(e)),this.minzoom=n||0,this.maxzoom=a||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[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 n=Math.pow(2,e.z),a=Math.floor(p.O(this.bounds.getWest())*n),o=Math.floor(p.Q(this.bounds.getNorth())*n),c=Math.ceil(p.O(this.bounds.getEast())*n),m=Math.ceil(p.Q(this.bounds.getSouth())*n);return e.x>=a&&e.x=o&&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 p.e({},this._options)}loadTile(e){return p._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a={request:this.map._requestManager.transformRequest(n,"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};a.request.collectResourceTiming=this._collectResourceTiming;let o="RT";if(e.actor&&e.state!=="expired"){if(e.state==="loading")return new Promise((c,m)=>{e.reloadPromise={resolve:c,reject:m}})}else e.actor=this.dispatcher.getActor(),o="LT";e.abortController=new AbortController;try{const c=yield e.actor.sendAsync({type:o,data:a},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,c)}catch(c){if(delete e.abortController,e.aborted)return;if(c&&c.status!==404)throw c;this._afterTileLoadWorkerResponse(e,null)}})}_afterTileLoadWorkerResponse(e,n){if(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),e.reloadPromise){const a=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(a.resolve).catch(a.reject)}}abortTile(e){return p._(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 p._(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 ut extends p.E{constructor(e,n,a,o){super(),this.id=e,this.dispatcher=a,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=p.e({type:"raster"},n),p.e(this,p.M(n,["url","scheme","tileSize"]))}load(){return p._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new p.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const e=yield kn(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,e&&(p.e(this,e),e.bounds&&(this.tileBounds=new dn(e.bounds,this.minzoom,this.maxzoom)),this.fire(new p.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new p.k("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this.fire(new p.j(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()}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 p.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return p._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const a=yield Mt.getImage(this.map._requestManager.transformRequest(n,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(a&&a.data){this.map._refreshExpiredTiles&&a.cacheControl&&a.expires&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});const o=this.map.painter.context,c=o.gl,m=a.data;e.texture=this.map.painter.getTileTexture(m.width),e.texture?e.texture.update(m,{useMipmap:!0}):(e.texture=new et(o,m,c.RGBA,{useMipmap:!0}),e.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE,c.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(a){if(delete e.abortController,e.aborted)e.state="unloaded";else if(a)throw e.state="errored",a}})}abortTile(e){return p._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return p._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class Et extends ut{constructor(e,n,a,o){super(e,n,a,o),this.type="raster-dem",this.maxzoom=22,this._options=p.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(e){return p._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a=this.map._requestManager.transformRequest(n,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const o=yield Mt.getImage(a,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(o&&o.data){const c=o.data;this.map._refreshExpiredTiles&&o.cacheControl&&o.expires&&e.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});const m=p.b(c)&&p.U()?c:yield this.readImageNow(c),_={type:this.type,uid:e.uid,source:this.id,rawImageData:m,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||e.state==="expired"){e.actor=this.dispatcher.getActor();const y=yield e.actor.sendAsync({type:"LDT",data:_});e.dem=y,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(o){if(delete e.abortController,e.aborted)e.state="unloaded";else if(o)throw e.state="errored",o}})}readImageNow(e){return p._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&p.V()){const n=e.width+2,a=e.height+2;try{return new p.R({width:n,height:a},yield p.W(e,-1,-1,n,a))}catch{}}return ue.getImageData(e,1)})}_getNeighboringTiles(e){const n=e.canonical,a=Math.pow(2,n.z),o=(n.x-1+a)%a,c=n.x===0?e.wrap-1:e.wrap,m=(n.x+1+a)%a,_=n.x+1===a?e.wrap+1:e.wrap,y={};return y[new p.S(e.overscaledZ,c,n.z,o,n.y).key]={backfilled:!1},y[new p.S(e.overscaledZ,_,n.z,m,n.y).key]={backfilled:!1},n.y>0&&(y[new p.S(e.overscaledZ,c,n.z,o,n.y-1).key]={backfilled:!1},y[new p.S(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},y[new p.S(e.overscaledZ,_,n.z,m,n.y-1).key]={backfilled:!1}),n.y+10&&p.e(c,{resourceTiming:o}),this.fire(new p.k("data",Object.assign(Object.assign({},c),{sourceDataType:"metadata"}))),this.fire(new p.k("data",Object.assign(Object.assign({},c),{sourceDataType:"content"})))}catch(a){if(this._pendingLoads--,this._removed)return void this.fire(new p.k("dataabort",{dataType:"source"}));this.fire(new p.j(a))}})}loaded(){return this._pendingLoads===0}loadTile(e){return p._(this,void 0,void 0,function*(){const n=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};e.abortController=new AbortController;const o=yield this.actor.sendAsync({type:n,data:a},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(o,this.map.painter,n==="RT")})}abortTile(e){return p._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return p._(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 p.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var Kr=p.Y([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Nr extends p.E{constructor(e,n,a,o){super(),this.id=e,this.dispatcher=a,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=n}load(e){return p._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new p.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield Mt.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,e&&(this.coordinates=e),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,this.fire(new p.j(n))}})}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 p.k("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 n=e.map(p.Z.fromLngLat);this.tileID=function(o){let c=1/0,m=1/0,_=-1/0,y=-1/0;for(const k of o)c=Math.min(c,k.x),m=Math.min(m,k.y),_=Math.max(_,k.x),y=Math.max(y,k.y);const b=Math.max(_-c,y-m),T=Math.max(0,Math.floor(-Math.log(b)/Math.LN2)),S=Math.pow(2,T);return new p.a1(T,Math.floor((c+_)/2*S),Math.floor((m+y)/2*S))}(n),this.minzoom=this.maxzoom=this.tileID.z;const a=n.map(o=>this.tileID.getTilePoint(o)._round());return this._boundsArray=new p.$,this._boundsArray.emplaceBack(a[0].x,a[0].y,0,0),this._boundsArray.emplaceBack(a[1].x,a[1].y,p.X,0),this._boundsArray.emplaceBack(a[3].x,a[3].y,0,p.X),this._boundsArray.emplaceBack(a[2].x,a[2].y,p.X,p.X),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new p.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const e=this.map.painter.context,n=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,Kr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture||(this.texture=new et(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(const o in this.tiles){const c=this.tiles[o];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,a=!0)}a&&this.fire(new p.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return p._(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}}class En extends Nr{constructor(e,n,a,o){super(e,n,a,o),this.roundZoom=!0,this.type="video",this.options=n}load(){return p._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const n of e.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield p.a3(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new p.j(n))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const n=this.video.seekable;en.end(0)?this.fire(new p.j(new p.a2(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.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(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const e=this.map.painter.context,n=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,Kr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new et(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(const o in this.tiles){const c=this.tiles[o];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,a=!0)}a&&this.fire(new p.k("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 Ji extends Nr{constructor(e,n,a,o){super(e,n,a,o),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(c=>!Array.isArray(c)||c.length!==2||c.some(m=>typeof m!="number"))||this.fire(new p.j(new p.a2(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new p.j(new p.a2(`sources.${e}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new p.j(new p.a2(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new p.j(new p.a2(`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 p.j(new p.a2(`sources.${e}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return p._(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 p.j(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()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,a=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,Kr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new et(n,this.canvas,a.RGBA,{premultiply:!0});let o=!1;for(const c in this.tiles){const m=this.tiles[c];m.state!=="loaded"&&(m.state="loaded",m.texture=this.texture,o=!0)}o&&this.fire(new p.k("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 ms={},gs=h=>{switch(h){case"geojson":return fs;case"image":return Nr;case"raster":return ut;case"raster-dem":return Et;case"vector":return ps;case"video":return En;case"canvas":return Ji}return ms[h]},xe="RTLPluginLoaded";class Pr extends p.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Xr()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(n=>{throw this.status="error",n})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return p._(this,arguments,void 0,function*(n,a=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=ue.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!a)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return p._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new p.k(xe))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let xi=null;function Ar(){return xi||(xi=new Pr),xi}class Jr{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=p.a4(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){const n=e+this.timeAdded;nc.getLayer(b)).filter(Boolean);if(y.length!==0){_.layers=y,_.stateDependentLayerIds&&(_.stateDependentLayers=_.stateDependentLayerIds.map(b=>y.filter(T=>T.id===b)[0]));for(const b of y)m[b.id]=_}}return m}(e.buckets,n.style),this.hasSymbolBuckets=!1;for(const o in this.buckets){const c=this.buckets[o];if(c instanceof p.a6){if(this.hasSymbolBuckets=!0,!a)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const o in this.buckets){const c=this.buckets[o];if(c instanceof p.a6&&c.hasRTLText){this.hasRTLText=!0,Ar().lazyLoad();break}}this.queryPadding=0;for(const o in this.buckets){const c=this.buckets[o];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(o).queryRadius(c))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new p.a5}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const a in this.buckets){const o=this.buckets[a];o.uploadPending()&&o.upload(e)}const n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new et(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new et(e,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,n,a,o,c,m,_,y,b,T){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:o,cameraQueryGeometry:c,scale:m,tileSize:this.tileSize,pixelPosMatrix:T,transform:y,params:_,queryPadding:this.queryPadding*b},e,n,a):{}}querySourceFeatures(e,n){const a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;const o=a.loadVTLayers(),c=n&&n.sourceLayer?n.sourceLayer:"",m=o._geojsonTileLayer||o[c];if(!m)return;const _=p.a7(n&&n.filter),{z:y,x:b,y:T}=this.tileID.canonical,S={z:y,x:b,y:T};for(let k=0;ka)o=!1;else if(n)if(this.expirationTime{this.remove(e,c)},a)),this.data[o].push(c),this.order.push(o),this.order.length>this.max){const m=this._getAndRemoveByKey(this.order[0]);m&&this.onRemove(m)}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 n=this.data[e].shift();return n.timeout&&clearTimeout(n.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),n.value}getByKey(e){const n=this.data[e];return n?n[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,n){if(!this.has(e))return this;const a=e.wrapped().key,o=n===void 0?0:this.data[a].indexOf(n),c=this.data[a][o];return this.data[a].splice(o,1),c.timeout&&clearTimeout(c.timeout),this.data[a].length===0&&delete this.data[a],this.onRemove(c.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(e){const n=[];for(const a in this.data)for(const o of this.data[a])e(o.value)||n.push(o);for(const a of n)this.remove(a.value.tileID,a)}}class Qe{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,n,a){const o=String(n);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},p.e(this.stateChanges[e][o],a),this.deletedStates[e]===null){this.deletedStates[e]={};for(const c in this.state[e])c!==o&&(this.deletedStates[e][c]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][o]===null){this.deletedStates[e][o]={};for(const c in this.state[e][o])a[c]||(this.deletedStates[e][o][c]=null)}else for(const c in a)this.deletedStates[e]&&this.deletedStates[e][o]&&this.deletedStates[e][o][c]===null&&delete this.deletedStates[e][o][c]}removeFeatureState(e,n,a){if(this.deletedStates[e]===null)return;const o=String(n);if(this.deletedStates[e]=this.deletedStates[e]||{},a&&n!==void 0)this.deletedStates[e][o]!==null&&(this.deletedStates[e][o]=this.deletedStates[e][o]||{},this.deletedStates[e][o][a]=null);else if(n!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][o])for(a in this.deletedStates[e][o]={},this.stateChanges[e][o])this.deletedStates[e][o][a]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null}getState(e,n){const a=String(n),o=p.e({},(this.state[e]||{})[a],(this.stateChanges[e]||{})[a]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const c=this.deletedStates[e][n];if(c===null)return{};for(const m in c)delete o[m]}return o}initializeTileState(e,n){e.setFeatureState(this.state,n)}coalesceChanges(e,n){const a={};for(const o in this.stateChanges){this.state[o]=this.state[o]||{};const c={};for(const m in this.stateChanges[o])this.state[o][m]||(this.state[o][m]={}),p.e(this.state[o][m],this.stateChanges[o][m]),c[m]=this.state[o][m];a[o]=c}for(const o in this.deletedStates){this.state[o]=this.state[o]||{};const c={};if(this.deletedStates[o]===null)for(const m in this.state[o])c[m]={},this.state[o][m]={};else for(const m in this.deletedStates[o]){if(this.deletedStates[o][m]===null)this.state[o][m]={};else for(const _ of Object.keys(this.deletedStates[o][m]))delete this.state[o][m][_];c[m]=this.state[o][m]}a[o]=a[o]||{},p.e(a[o],c)}if(this.stateChanges={},this.deletedStates={},Object.keys(a).length!==0)for(const o in e)e[o].setFeatureState(a,n)}}class $e extends p.E{constructor(e,n,a){super(),this.id=e,this.dispatcher=a,this.on("data",o=>this._dataHandler(o)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((o,c,m,_)=>{const y=new(gs(c.type))(o,c,m,_);if(y.id!==o)throw new Error(`Expected Source id to be ${o} instead of ${y.id}`);return y})(e,n,a,this),this._tiles={},this._cache=new Te(0,o=>this._unloadTile(o)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Qe,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||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const n=this._tiles[e];if(n.state!=="loaded"&&n.state!=="errored")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,n,a){return p._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,n,a)}catch(o){e.state="errored",o.status!==404?this._source.fire(new p.j(o,{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 p.k("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 n in this._tiles){const a=this._tiles[n];a.upload(e),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Ci).map(e=>e.key)}getRenderableIds(e){const n=[];for(const a in this._tiles)this._isIdRenderable(a,e)&&n.push(this._tiles[a]);return e?n.sort((a,o)=>{const c=a.tileID,m=o.tileID,_=new p.P(c.canonical.x,c.canonical.y)._rotate(this.transform.angle),y=new p.P(m.canonical.x,m.canonical.y)._rotate(this.transform.angle);return c.overscaledZ-m.overscaledZ||y.y-_.y||y.x-_.x}).map(a=>a.tileID.key):n.map(a=>a.tileID).sort(Ci).map(a=>a.key)}hasRenderableParent(e){const n=this.findLoadedParent(e,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(e,n){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(n||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(e,"reloading")}}_reloadTile(e,n){return p._(this,void 0,void 0,function*(){const a=this._tiles[e];a&&(a.state!=="loading"&&(a.state=n),yield this._loadTile(a,e,n))})}_tileLoaded(e,n,a){e.timeAdded=ue.now(),a==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),this.getSource().type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new p.k("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const n=this.getRenderableIds();for(let o=0;o1||(Math.abs(m)>1&&(Math.abs(m+y)===1?m+=y:Math.abs(m-y)===1&&(m-=y)),c.dem&&o.dem&&(o.dem.backfillBorder(c.dem,m,_),o.neighboringTiles&&o.neighboringTiles[b]&&(o.neighboringTiles[b].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,n,a,o){for(const c in this._tiles){let m=this._tiles[c];if(o[c]||!m.hasData()||m.tileID.overscaledZ<=n||m.tileID.overscaledZ>a)continue;let _=m.tileID;for(;m&&m.tileID.overscaledZ>n+1;){const b=m.tileID.scaledTo(m.tileID.overscaledZ-1);m=this._tiles[b.key],m&&m.hasData()&&(_=b)}let y=_;for(;y.overscaledZ>n;)if(y=y.scaledTo(y.overscaledZ-1),e[y.key]){o[_.key]=_;break}}}findLoadedParent(e,n){if(e.key in this._loadedParentTiles){const a=this._loadedParentTiles[e.key];return a&&a.tileID.overscaledZ>=n?a:null}for(let a=e.overscaledZ-1;a>=n;a--){const o=e.scaledTo(a),c=this._getLoadedTile(o);if(c)return c}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const n=this._tiles[e.key];return n&&n.hasData()?n:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const n=Math.ceil(e.width/this._source.tileSize)+1,a=Math.ceil(e.height/this._source.tileSize)+1,o=Math.floor(n*a*(this._maxTileCacheZoomLevels===null?p.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),c=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(c)}handleWrapJump(e){const n=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,n){const a={};for(const o in this._tiles){const c=this._tiles[o];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+n),a[c.tileID.key]=c}this._tiles=a;for(const o in this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(const o in this._tiles)this._setTileReloadTimer(o,this._tiles[o])}}_updateCoveredAndRetainedTiles(e,n,a,o,c,m){const _={},y={},b=Object.keys(e),T=ue.now();for(const S of b){const k=e[S],D=this._tiles[S];if(!D||D.fadeEndTime!==0&&D.fadeEndTime<=T)continue;const B=this.findLoadedParent(k,n),N=this.findLoadedSibling(k),q=B||N||null;q&&(this._addTile(q.tileID),_[q.tileID.key]=q.tileID),y[S]=k}this._retainLoadedChildren(y,o,a,e);for(const S in _)e[S]||(this._coveredTiles[S]=!0,e[S]=_[S]);if(m){const S={},k={};for(const D of c)this._tiles[D.key].hasData()?S[D.key]=D:k[D.key]=D;for(const D in k){const B=k[D].children(this._source.maxzoom);this._tiles[B[0].key]&&this._tiles[B[1].key]&&this._tiles[B[2].key]&&this._tiles[B[3].key]&&(S[B[0].key]=e[B[0].key]=B[0],S[B[1].key]=e[B[1].key]=B[1],S[B[2].key]=e[B[2].key]=B[2],S[B[3].key]=e[B[3].key]=B[3],delete k[D])}for(const D in k){const B=k[D],N=this.findLoadedParent(B,this._source.minzoom),q=this.findLoadedSibling(B),Z=N||q||null;if(Z){S[Z.tileID.key]=e[Z.tileID.key]=Z.tileID;for(const X in S)S[X].isChildOf(Z.tileID)&&delete S[X]}}for(const D in this._tiles)S[D]||(this._coveredTiles[D]=!0)}}update(e,n){if(!this._sourceLoaded||this._paused)return;let a;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(T=>new p.S(T.canonical.z,T.wrap,T.canonical.z,T.canonical.x,T.canonical.y)):(a=e.coveringTiles({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:n}),this._source.hasTile&&(a=a.filter(T=>this._source.hasTile(T)))):a=[];const o=e.coveringZoomLevel(this._source),c=Math.max(o-$e.maxOverzooming,this._source.minzoom),m=Math.max(o+$e.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const T={};for(const S of a)if(S.canonical.z>this._source.minzoom){const k=S.scaledTo(S.canonical.z-1);T[k.key]=k;const D=S.scaledTo(Math.max(this._source.minzoom,Math.min(S.canonical.z,5)));T[D.key]=D}a=a.concat(Object.values(T))}const _=a.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,_&&this.fire(new p.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const y=this._updateRetainedTiles(a,o);cr(this._source.type)&&this._updateCoveredAndRetainedTiles(y,c,m,o,a,n);for(const T in y)this._tiles[T].clearFadeHold();const b=p.ab(this._tiles,y);for(const T of b){const S=this._tiles[T];S.hasSymbolBuckets&&!S.holdingForFade()?S.setHoldDuration(this.map._fadeDuration):S.hasSymbolBuckets&&!S.symbolFadeFinished()||this._removeTile(T)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,n){var a;const o={},c={},m=Math.max(n-$e.maxOverzooming,this._source.minzoom),_=Math.max(n+$e.maxUnderzooming,this._source.minzoom),y={};for(const b of e){const T=this._addTile(b);o[b.key]=b,T.hasData()||nthis._source.maxzoom){const k=b.children(this._source.maxzoom)[0],D=this.getTile(k);if(D&&D.hasData()){o[k.key]=k;continue}}else{const k=b.children(this._source.maxzoom);if(o[k[0].key]&&o[k[1].key]&&o[k[2].key]&&o[k[3].key])continue}let S=T.wasRequested();for(let k=b.overscaledZ-1;k>=m;--k){const D=b.scaledTo(k);if(c[D.key])break;if(c[D.key]=!0,T=this.getTile(D),!T&&S&&(T=this._addTile(D)),T){const B=T.hasData();if((B||!(!((a=this.map)===null||a===void 0)&&a.cancelPendingTileRequestsWhileZooming)||S)&&(o[D.key]=D),S=T.wasRequested(),B)break}}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const n=[];let a,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){a=this._loadedParentTiles[o.key];break}n.push(o.key);const c=o.scaledTo(o.overscaledZ-1);if(a=this._getLoadedTile(c),a)break;o=c}for(const c of n)this._loadedParentTiles[c]=a}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const n=this._tiles[e].tileID,a=this._getLoadedTile(n);this._loadedSiblingTiles[n.key]=a}}_addTile(e){let n=this._tiles[e.key];if(n)return n;n=this._cache.getAndRemove(e),n&&(this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,n)));const a=n;return n||(n=new Jr(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._tiles[e.key]=n,a||this._source.fire(new p.k("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(e,n){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const a=n.getExpiryTimeout();a&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},a))}_removeTile(e){const n=this._tiles[e];n&&(n.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(e){const n=e.sourceDataType;e.dataType==="source"&&n==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&e.dataType==="source"&&n==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,n,a){const o=[],c=this.transform;if(!c)return o;const m=a?c.getCameraQueryGeometry(e):e,_=e.map(B=>c.pointCoordinate(B,this.terrain)),y=m.map(B=>c.pointCoordinate(B,this.terrain)),b=this.getIds();let T=1/0,S=1/0,k=-1/0,D=-1/0;for(const B of y)T=Math.min(T,B.x),S=Math.min(S,B.y),k=Math.max(k,B.x),D=Math.max(D,B.y);for(let B=0;B=0&&F[1].y+X>=0){const Y=_.map(ae=>q.getTilePoint(ae)),ee=y.map(ae=>q.getTilePoint(ae));o.push({tile:N,tileID:q,queryGeometry:Y,cameraQueryGeometry:ee,scale:Z})}}return o}getVisibleCoordinates(e){const n=this.getRenderableIds(e).map(a=>this._tiles[a].tileID);for(const a of n)a.posMatrix=this.transform.calculatePosMatrix(a.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(cr(this._source.type)){const e=ue.now();for(const n in this._tiles)if(this._tiles[n].fadeEndTime>=e)return!0}return!1}setFeatureState(e,n,a){this._state.updateState(e=e||"_geojsonTileLayer",n,a)}removeFeatureState(e,n,a){this._state.removeFeatureState(e=e||"_geojsonTileLayer",n,a)}getFeatureState(e,n){return this._state.getState(e=e||"_geojsonTileLayer",n)}setDependencies(e,n,a){const o=this._tiles[e];o&&o.setDependencies(n,a)}reloadTilesForDependencies(e,n){for(const a in this._tiles)this._tiles[a].hasDependency(e,n)&&this._reloadTile(a,"reloading");this._cache.filter(a=>!a.hasDependency(e,n))}}function Ci(h,e){const n=Math.abs(2*h.wrap)-+(h.wrap<0),a=Math.abs(2*e.wrap)-+(e.wrap<0);return h.overscaledZ-e.overscaledZ||a-n||e.canonical.y-h.canonical.y||e.canonical.x-h.canonical.x}function cr(h){return h==="raster"||h==="image"||h==="video"}$e.maxOverzooming=10,$e.maxUnderzooming=3;class We{constructor(e,n){this.reset(e,n)}reset(e,n){this.points=e||[],this._distances=[0];for(let a=1;a0?(o-m)/_:0;return this.points[c].mult(1-y).add(this.points[n].mult(y))}}function Cr(h,e){let n=!0;return h==="always"||h!=="never"&&e!=="never"||(n=!1),n}class Ur{constructor(e,n,a){const o=this.boxCells=[],c=this.circleCells=[];this.xCellCount=Math.ceil(e/a),this.yCellCount=Math.ceil(n/a);for(let m=0;mthis.width||o<0||n>this.height)return[];const y=[];if(e<=0&&n<=0&&this.width<=a&&this.height<=o){if(c)return[{key:null,x1:e,y1:n,x2:a,y2:o}];for(let b=0;b0}hitTestCircle(e,n,a,o,c){const m=e-a,_=e+a,y=n-a,b=n+a;if(_<0||m>this.width||b<0||y>this.height)return!1;const T=[];return this._forEachCell(m,y,_,b,this._queryCellCircle,T,{hitTest:!0,overlapMode:o,circle:{x:e,y:n,radius:a},seenUids:{box:{},circle:{}}},c),T.length>0}_queryCell(e,n,a,o,c,m,_,y){const{seenUids:b,hitTest:T,overlapMode:S}=_,k=this.boxCells[c];if(k!==null){const B=this.bboxes;for(const N of k)if(!b.box[N]){b.box[N]=!0;const q=4*N,Z=this.boxKeys[N];if(e<=B[q+2]&&n<=B[q+3]&&a>=B[q+0]&&o>=B[q+1]&&(!y||y(Z))&&(!T||!Cr(S,Z.overlapMode))&&(m.push({key:Z,x1:B[q],y1:B[q+1],x2:B[q+2],y2:B[q+3]}),T))return!0}}const D=this.circleCells[c];if(D!==null){const B=this.circles;for(const N of D)if(!b.circle[N]){b.circle[N]=!0;const q=3*N,Z=this.circleKeys[N];if(this._circleAndRectCollide(B[q],B[q+1],B[q+2],e,n,a,o)&&(!y||y(Z))&&(!T||!Cr(S,Z.overlapMode))){const X=B[q],F=B[q+1],Y=B[q+2];if(m.push({key:Z,x1:X-Y,y1:F-Y,x2:X+Y,y2:F+Y}),T)return!0}}}return!1}_queryCellCircle(e,n,a,o,c,m,_,y){const{circle:b,seenUids:T,overlapMode:S}=_,k=this.boxCells[c];if(k!==null){const B=this.bboxes;for(const N of k)if(!T.box[N]){T.box[N]=!0;const q=4*N,Z=this.boxKeys[N];if(this._circleAndRectCollide(b.x,b.y,b.radius,B[q+0],B[q+1],B[q+2],B[q+3])&&(!y||y(Z))&&!Cr(S,Z.overlapMode))return m.push(!0),!0}}const D=this.circleCells[c];if(D!==null){const B=this.circles;for(const N of D)if(!T.circle[N]){T.circle[N]=!0;const q=3*N,Z=this.circleKeys[N];if(this._circlesCollide(B[q],B[q+1],B[q+2],b.x,b.y,b.radius)&&(!y||y(Z))&&!Cr(S,Z.overlapMode))return m.push(!0),!0}}}_forEachCell(e,n,a,o,c,m,_,y){const b=this._convertToXCellCoord(e),T=this._convertToYCellCoord(n),S=this._convertToXCellCoord(a),k=this._convertToYCellCoord(o);for(let D=b;D<=S;D++)for(let B=T;B<=k;B++)if(c.call(this,e,n,a,o,this.xCellCount*B+D,m,_,y))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,n,a,o,c,m){const _=o-e,y=c-n,b=a+m;return b*b>_*_+y*y}_circleAndRectCollide(e,n,a,o,c,m,_){const y=(m-o)/2,b=Math.abs(e-(o+y));if(b>y+a)return!1;const T=(_-c)/2,S=Math.abs(n-(c+T));if(S>T+a)return!1;if(b<=y||S<=T)return!0;const k=b-y,D=S-T;return k*k+D*D<=a*a}}function Yr(h,e,n,a,o){const c=p.H();return e?(p.K(c,c,[1/o,1/o,1]),n||p.ad(c,c,a.angle)):p.L(c,a.labelPlaneMatrix,h),c}function Mr(h,e,n,a,o){if(e){const c=p.ae(h);return p.K(c,c,[o,o,1]),n||p.ad(c,c,-a.angle),c}return a.glCoordMatrix}function U(h,e,n,a){let o;a?(o=[h,e,a(h,e),1],p.af(o,o,n)):(o=[h,e,0,1],ot(o,o,n));const c=o[3];return{point:new p.P(o[0]/c,o[1]/c),signedDistanceFromCamera:c,isOccluded:!1}}function A(h,e){return .5+h/e*.5}function P(h,e){return h.x>=-e[0]&&h.x<=e[0]&&h.y>=-e[1]&&h.y<=e[1]}function R(h,e,n,a,o,c,m,_,y,b,T,S,k,D,B){const N=a?h.textSizeData:h.iconSizeData,q=p.ag(N,n.transform.zoom),Z=[256/n.width*2+1,256/n.height*2+1],X=a?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;X.clear();const F=h.lineVertexArray,Y=a?h.text.placedSymbolArray:h.icon.placedSymbolArray,ee=n.transform.width/n.transform.height;let ae=!1;for(let fe=0;feMath.abs(n.x-e.x)*a?{useVertical:!0}:(h===p.ah.vertical?e.yn.x)?{needsFlipping:!0}:null}function Q(h,e,n,a,o,c,m,_,y,b,T){const S=n/24,k=e.lineOffsetX*S,D=e.lineOffsetY*S;let B;if(e.numGlyphs>1){const N=e.glyphStartIndex+e.numGlyphs,q=e.lineStartIndex,Z=e.lineStartIndex+e.lineLength,X=V(S,_,k,D,a,e,T,h);if(!X)return{notEnoughRoom:!0};const F=U(X.first.point.x,X.first.point.y,m,h.getElevation).point,Y=U(X.last.point.x,X.last.point.y,m,h.getElevation).point;if(o&&!a){const ee=K(e.writingMode,F,Y,b);if(ee)return ee}B=[X.first];for(let ee=e.glyphStartIndex+1;ee0?F.point:function(ae,fe,_e,Pe,ke,we){return ie(ae,fe,_e,1,ke,we)}(h.tileAnchorPoint,X,q,0,c,h),ee=K(e.writingMode,q,Y,b);if(ee)return ee}const N=ve(S*_.getoffsetX(e.glyphStartIndex),k,D,a,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,h,T);if(!N||h.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};B=[N]}for(const N of B)p.aj(y,N.point,N.angle);return{}}function ie(h,e,n,a,o,c){const m=h.add(h.sub(e)._unit()),_=o!==void 0?U(m.x,m.y,o,c.getElevation).point:he(m.x,m.y,c).point,y=n.sub(_);return n.add(y._mult(a/y.mag()))}function H(h,e,n){const a=e.projectionCache;if(a.projections[h])return a.projections[h];const o=new p.P(e.lineVertexArray.getx(h),e.lineVertexArray.gety(h)),c=he(o.x,o.y,e);if(c.signedDistanceFromCamera>0)return a.projections[h]=c.point,a.anyProjectionOccluded=a.anyProjectionOccluded||c.isOccluded,c.point;const m=h-n.direction;return function(_,y,b,T,S){return ie(_,y,b,T,void 0,S)}(n.distanceFromAnchor===0?e.tileAnchorPoint:new p.P(e.lineVertexArray.getx(m),e.lineVertexArray.gety(m)),o,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,e)}function he(h,e,n){const a=h+n.translation[0],o=e+n.translation[1];let c;return!n.pitchWithMap&&n.projection.useSpecialProjectionForSymbols?(c=n.projection.projectTileCoordinates(a,o,n.unwrappedTileID,n.getElevation),c.point.x=(.5*c.point.x+.5)*n.width,c.point.y=(.5*-c.point.y+.5)*n.height):(c=U(a,o,n.labelPlaneMatrix,n.getElevation),c.isOccluded=!1),c}function me(h,e,n){return h._unit()._perp()._mult(e*n)}function oe(h,e,n,a,o,c,m,_,y){if(_.projectionCache.offsets[h])return _.projectionCache.offsets[h];const b=n.add(e);if(h+y.direction=o)return _.projectionCache.offsets[h]=b,b;const T=H(h+y.direction,_,y),S=me(T.sub(n),m,y.direction),k=n.add(S),D=T.add(S);return _.projectionCache.offsets[h]=p.ak(c,b,k,D)||b,_.projectionCache.offsets[h]}function ve(h,e,n,a,o,c,m,_,y){const b=a?h-e:h+e;let T=b>0?1:-1,S=0;a&&(T*=-1,S=Math.PI),T<0&&(S+=Math.PI);let k,D=T>0?c+o:c+o+1;_.projectionCache.cachedAnchorPoint?k=_.projectionCache.cachedAnchorPoint:(k=he(_.tileAnchorPoint.x,_.tileAnchorPoint.y,_).point,_.projectionCache.cachedAnchorPoint=k);let B,N,q=k,Z=k,X=0,F=0;const Y=Math.abs(b),ee=[];let ae;for(;X+F<=Y;){if(D+=T,D=m)return null;X+=F,Z=q,N=B;const Pe={absOffsetX:Y,direction:T,distanceFromAnchor:X,previousVertex:Z};if(q=H(D,_,Pe),n===0)ee.push(Z),ae=q.sub(Z);else{let ke;const we=q.sub(Z);ke=we.mag()===0?me(H(D+T,_,Pe).sub(q),n,T):me(we,n,T),N||(N=Z.add(ke)),B=oe(D,ke,q,c,m,N,n,_,Pe),ee.push(N),ae=B.sub(N)}F=ae.mag()}const fe=ae._mult((Y-X)/F)._add(N||Z),_e=S+Math.atan2(q.y-Z.y,q.x-Z.x);return ee.push(fe),{point:fe,angle:y?_e:0,path:ee}}const Ve=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Ne(h,e){for(let n=0;n=1;Ye--)Ce.push(Xe.path[Ye]);for(let Ye=1;Yent.signedDistanceFromCamera<=0)?[]:Ye.map(nt=>nt.point)}let Tt=[];if(Ce.length>0){const Ye=Ce[0].clone(),nt=Ce[0].clone();for(let St=1;St=we.x&&nt.x<=be.x&&Ye.y>=we.y&&nt.y<=be.y?[Ce]:nt.xbe.x||nt.ybe.y?[]:p.al([Ce],we.x,we.y,be.x,be.y)}for(const Ye of Tt){Re.reset(Ye,.25*ke);let nt=0;nt=Re.length<=.5*ke?1:Math.ceil(Re.paddedLength/qe)+1;for(let St=0;StU(o.x,o.y,a,n.getElevation))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[];let a=1/0,o=1/0,c=-1/0,m=-1/0;for(const T of e){const S=new p.P(T.x+Ke,T.y+Ke);a=Math.min(a,S.x),o=Math.min(o,S.y),c=Math.max(c,S.x),m=Math.max(m,S.y),n.push(S)}const _=this.grid.query(a,o,c,m).concat(this.ignoredGrid.query(a,o,c,m)),y={},b={};for(const T of _){const S=T.key;if(y[S.bucketInstanceId]===void 0&&(y[S.bucketInstanceId]={}),y[S.bucketInstanceId][S.featureIndex])continue;const k=[new p.P(T.x1,T.y1),new p.P(T.x2,T.y1),new p.P(T.x2,T.y2),new p.P(T.x1,T.y2)];p.am(n,k)&&(y[S.bucketInstanceId][S.featureIndex]=!0,b[S.bucketInstanceId]===void 0&&(b[S.bucketInstanceId]=[]),b[S.bucketInstanceId].push(S.featureIndex))}return b}insertCollisionBox(e,n,a,o,c,m){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:o,featureIndex:c,collisionGroupID:m,overlapMode:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,n,a,o,c,m){const _=a?this.ignoredGrid:this.grid,y={bucketInstanceId:o,featureIndex:c,collisionGroupID:m,overlapMode:n};for(let b=0;b=this.screenRightBoundary||othis.screenBottomBoundary}isInsideGrid(e,n,a,o){return a>=0&&e=0&&nthis.projectAndGetPerspectiveRatio(a,ke.x,ke.y,o,b));_e=Pe.some(ke=>!ke.isOccluded),fe=Pe.map(ke=>ke.point)}else _e=!0;return{box:p.ao(fe),allPointsOccluded:!_e}}}function rt(h,e,n){return e*(p.X/(h.tileSize*Math.pow(2,n-h.tileID.overscaledZ)))}class Ut{constructor(e,n,a,o){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?n:-n))):o&&a?1:0,this.placed=a}isHidden(){return this.opacity===0&&!this.placed}}class zt{constructor(e,n,a,o,c){this.text=new Ut(e?e.text:null,n,a,c),this.icon=new Ut(e?e.icon:null,n,o,c)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class tt{constructor(e,n,a){this.text=e,this.icon=n,this.skipFade=a}}class ft{constructor(){this.invProjMatrix=p.H(),this.viewportMatrix=p.H(),this.circles=[]}}class Ct{constructor(e,n,a,o,c){this.bucketInstanceId=e,this.featureIndex=n,this.sourceLayerIndex=a,this.bucketIndex=o,this.tileID=c}}class Ht{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 n=++this.maxGroupID;this.collisionGroups[e]={ID:n,predicate:a=>a.collisionGroupID===n}}return this.collisionGroups[e]}}function Qt(h,e,n,a,o){const{horizontalAlign:c,verticalAlign:m}=p.au(h);return new p.P(-(c-.5)*e+a[0]*o,-(m-.5)*n+a[1]*o)}class vi{constructor(e,n,a,o,c,m){this.transform=e.clone(),this.terrain=a,this.collisionIndex=new lt(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new Ht(c),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=m,m&&(m.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const n=this.terrain;return n?(a,o)=>n.getElevation(e,a,o):null}getBucketParts(e,n,a,o){const c=a.getBucket(n),m=a.latestFeatureIndex;if(!c||!m||n.id!==c.layerIds[0])return;const _=a.collisionBoxArray,y=c.layers[0].layout,b=c.layers[0].paint,T=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),S=a.tileSize/p.X,k=a.tileID.toUnwrapped(),D=this.transform.calculatePosMatrix(k),B=y.get("text-pitch-alignment")==="map",N=y.get("text-rotation-alignment")==="map",q=rt(a,1,this.transform.zoom),Z=this.collisionIndex.mapProjection.translatePosition(this.transform,a,b.get("text-translate"),b.get("text-translate-anchor")),X=this.collisionIndex.mapProjection.translatePosition(this.transform,a,b.get("icon-translate"),b.get("icon-translate-anchor")),F=Yr(D,B,N,this.transform,q);let Y=null;if(B){const ae=Mr(D,B,N,this.transform,q);Y=p.L([],this.transform.labelPlaneMatrix,ae)}this.retainedQueryData[c.bucketInstanceId]=new Ct(c.bucketInstanceId,m,c.sourceLayerIndex,c.index,a.tileID);const ee={bucket:c,layout:y,translationText:Z,translationIcon:X,posMatrix:D,unwrappedTileID:k,textLabelPlaneMatrix:F,labelToScreenMatrix:Y,scale:T,textPixelRatio:S,holdingForFade:a.holdingForFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:p.ag(c.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(c.sourceID)};if(o)for(const ae of c.sortKeyRanges){const{sortKey:fe,symbolInstanceStart:_e,symbolInstanceEnd:Pe}=ae;e.push({sortKey:fe,symbolInstanceStart:_e,symbolInstanceEnd:Pe,parameters:ee})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:c.symbolInstances.length,parameters:ee})}attemptAnchorPlacement(e,n,a,o,c,m,_,y,b,T,S,k,D,B,N,q,Z,X,F){const Y=p.aq[e.textAnchor],ee=[e.textOffset0,e.textOffset1],ae=Qt(Y,a,o,ee,c),fe=this.collisionIndex.placeCollisionBox(n,k,y,b,T,_,m,q,S.predicate,F,ae);if((!X||this.collisionIndex.placeCollisionBox(X,k,y,b,T,_,m,Z,S.predicate,F,ae).placeable)&&fe.placeable){let _e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[D.crossTileID]&&this.prevPlacement.placements[D.crossTileID]&&this.prevPlacement.placements[D.crossTileID].text&&(_e=this.prevPlacement.variableOffsets[D.crossTileID].anchor),D.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[D.crossTileID]={textOffset:ee,width:a,height:o,anchor:Y,textBoxScale:c,prevAnchor:_e},this.markUsedJustification(B,Y,D,N),B.allowVerticalPlacement&&(this.markUsedOrientation(B,N,D),this.placedOrientations[D.crossTileID]=N),{shift:ae,placedGlyphBoxes:fe}}}placeLayerBucketPart(e,n,a){const{bucket:o,layout:c,translationText:m,translationIcon:_,posMatrix:y,unwrappedTileID:b,textLabelPlaneMatrix:T,labelToScreenMatrix:S,textPixelRatio:k,holdingForFade:D,collisionBoxArray:B,partiallyEvaluatedTextSize:N,collisionGroup:q}=e.parameters,Z=c.get("text-optional"),X=c.get("icon-optional"),F=p.ar(c,"text-overlap","text-allow-overlap"),Y=F==="always",ee=p.ar(c,"icon-overlap","icon-allow-overlap"),ae=ee==="always",fe=c.get("text-rotation-alignment")==="map",_e=c.get("text-pitch-alignment")==="map",Pe=c.get("icon-text-fit")!=="none",ke=c.get("symbol-z-order")==="viewport-y",we=Y&&(ae||!o.hasIconData()||X),be=ae&&(Y||!o.hasTextData()||Z);!o.collisionArrays&&B&&o.deserializeCollisionBoxes(B);const Re=this._getTerrainElevationFunc(this.retainedQueryData[o.bucketInstanceId].tileID),Xe=(Se,Ce,qe)=>{var Tt,Ye;if(n[Se.crossTileID])return;if(D)return void(this.placements[Se.crossTileID]=new tt(!1,!1,!1));let nt=!1,St=!1,oi=!0,mr=null,It={box:null,placeable:!1,offscreen:null},Ei={box:null,placeable:!1,offscreen:null},bi=null,li=null,wi=null,Dr=0,es=0,va=0;Ce.textFeatureIndex?Dr=Ce.textFeatureIndex:Se.useRuntimeCollisionCircles&&(Dr=Se.featureIndex),Ce.verticalTextFeatureIndex&&(es=Ce.verticalTextFeatureIndex);const ts=Ce.textBox;if(ts){const rr=ei=>{let ci=p.ah.horizontal;if(o.allowVerticalPlacement&&!ei&&this.prevPlacement){const Zi=this.prevPlacement.placedOrientations[Se.crossTileID];Zi&&(this.placedOrientations[Se.crossTileID]=Zi,ci=Zi,this.markUsedOrientation(o,ci,Se))}return ci},nr=(ei,ci)=>{if(o.allowVerticalPlacement&&Se.numVerticalGlyphVertices>0&&Ce.verticalTextBox){for(const Zi of o.writingModes)if(Zi===p.ah.vertical?(It=ci(),Ei=It):It=ei(),It&&It.placeable)break}else It=ei()},tn=Se.textAnchorOffsetStartIndex,gr=Se.textAnchorOffsetEndIndex;if(gr===tn){const ei=(ci,Zi)=>{const at=this.collisionIndex.placeCollisionBox(ci,F,k,y,b,_e,fe,m,q.predicate,Re);return at&&at.placeable&&(this.markUsedOrientation(o,Zi,Se),this.placedOrientations[Se.crossTileID]=Zi),at};nr(()=>ei(ts,p.ah.horizontal),()=>{const ci=Ce.verticalTextBox;return o.allowVerticalPlacement&&Se.numVerticalGlyphVertices>0&&ci?ei(ci,p.ah.vertical):{box:null,offscreen:null}}),rr(It&&It.placeable)}else{let ei=p.aq[(Ye=(Tt=this.prevPlacement)===null||Tt===void 0?void 0:Tt.variableOffsets[Se.crossTileID])===null||Ye===void 0?void 0:Ye.anchor];const ci=(at,In,is)=>{const rs=at.x2-at.x1,El=at.y2-at.y1,Mc=Se.textBoxScale,zl=Pe&&ee==="never"?In:null;let rn=null,Dl=F==="never"?1:2,wa="never";ei&&Dl++;for(let Rs=0;Rsci(ts,Ce.iconBox,p.ah.horizontal),()=>{const at=Ce.verticalTextBox;return o.allowVerticalPlacement&&(!It||!It.placeable)&&Se.numVerticalGlyphVertices>0&&at?ci(at,Ce.verticalIconBox,p.ah.vertical):{box:null,occluded:!0,offscreen:null}}),It&&(nt=It.placeable,oi=It.offscreen);const Zi=rr(It&&It.placeable);if(!nt&&this.prevPlacement){const at=this.prevPlacement.variableOffsets[Se.crossTileID];at&&(this.variableOffsets[Se.crossTileID]=at,this.markUsedJustification(o,at.anchor,Se,Zi))}}}if(bi=It,nt=bi&&bi.placeable,oi=bi&&bi.offscreen,Se.useRuntimeCollisionCircles){const rr=o.text.placedSymbolArray.get(Se.centerJustifiedTextSymbolIndex),nr=p.ai(o.textSizeData,N,rr),tn=c.get("text-padding");li=this.collisionIndex.placeCollisionCircles(F,rr,o.lineVertexArray,o.glyphOffsetArray,nr,y,b,T,S,a,_e,q.predicate,Se.collisionCircleDiameter,tn,m,Re),li.circles.length&&li.collisionDetected&&!a&&p.w("Collisions detected, but collision boxes are not shown"),nt=Y||li.circles.length>0&&!li.collisionDetected,oi=oi&&li.offscreen}if(Ce.iconFeatureIndex&&(va=Ce.iconFeatureIndex),Ce.iconBox){const rr=nr=>this.collisionIndex.placeCollisionBox(nr,ee,k,y,b,_e,fe,_,q.predicate,Re,Pe&&mr?mr:void 0);Ei&&Ei.placeable&&Ce.verticalIconBox?(wi=rr(Ce.verticalIconBox),St=wi.placeable):(wi=rr(Ce.iconBox),St=wi.placeable),oi=oi&&wi.offscreen}const ir=Z||Se.numHorizontalGlyphVertices===0&&Se.numVerticalGlyphVertices===0,ba=X||Se.numIconVertices===0;ir||ba?ba?ir||(St=St&&nt):nt=St&&nt:St=nt=St&&nt;const ko=St&&wi.placeable;if(nt&&bi.placeable&&this.collisionIndex.insertCollisionBox(bi.box,F,c.get("text-ignore-placement"),o.bucketInstanceId,Ei&&Ei.placeable&&es?es:Dr,q.ID),ko&&this.collisionIndex.insertCollisionBox(wi.box,ee,c.get("icon-ignore-placement"),o.bucketInstanceId,va,q.ID),li&&nt&&this.collisionIndex.insertCollisionCircles(li.circles,F,c.get("text-ignore-placement"),o.bucketInstanceId,Dr,q.ID),a&&this.storeCollisionData(o.bucketInstanceId,qe,Ce,bi,wi,li),Se.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(o.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[Se.crossTileID]=new tt(nt||we,St||be,oi||o.justReloaded),n[Se.crossTileID]=!0};if(ke){if(e.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const Se=o.getSortedSymbolIndexes(this.transform.angle);for(let Ce=Se.length-1;Ce>=0;--Ce){const qe=Se[Ce];Xe(o.symbolInstances.get(qe),o.collisionArrays[qe],qe)}}else for(let Se=e.symbolInstanceStart;Se=0&&(e.text.placedSymbolArray.get(_).crossTileID=c>=0&&_!==c?0:a.crossTileID)}markUsedOrientation(e,n,a){const o=n===p.ah.horizontal||n===p.ah.horizontalOnly?n:0,c=n===p.ah.vertical?n:0,m=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex];for(const _ of m)e.text.placedSymbolArray.get(_).placedOrientation=o;a.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).placedOrientation=c)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let a=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const o=n?n.symbolFadeChange(e):1,c=n?n.opacities:{},m=n?n.variableOffsets:{},_=n?n.placedOrientations:{};for(const y in this.placements){const b=this.placements[y],T=c[y];T?(this.opacities[y]=new zt(T,o,b.text,b.icon),a=a||b.text!==T.text.placed||b.icon!==T.icon.placed):(this.opacities[y]=new zt(null,o,b.text,b.icon,b.skipFade),a=a||b.text||b.icon)}for(const y in c){const b=c[y];if(!this.opacities[y]){const T=new zt(b,o,!1,!1);T.isHidden()||(this.opacities[y]=T,a=a||b.text.placed||b.icon.placed)}}for(const y in m)this.variableOffsets[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.variableOffsets[y]=m[y]);for(const y in _)this.placedOrientations[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.placedOrientations[y]=_[y]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:e)}updateLayerOpacities(e,n){const a={};for(const o of n){const c=o.getBucket(e);c&&o.latestFeatureIndex&&e.id===c.layerIds[0]&&this.updateBucketOpacities(c,o.tileID,a,o.collisionBoxArray)}}updateBucketOpacities(e,n,a,o){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 c=e.layers[0],m=c.layout,_=new zt(null,0,!1,!1,!0),y=m.get("text-allow-overlap"),b=m.get("icon-allow-overlap"),T=c._unevaluatedLayout.hasValue("text-variable-anchor")||c._unevaluatedLayout.hasValue("text-variable-anchor-offset"),S=m.get("text-rotation-alignment")==="map",k=m.get("text-pitch-alignment")==="map",D=m.get("icon-text-fit")!=="none",B=new zt(null,0,y&&(b||!e.hasIconData()||m.get("icon-optional")),b&&(y||!e.hasTextData()||m.get("text-optional")),!0);!e.collisionArrays&&o&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(o);const N=(Z,X,F)=>{for(let Y=0;Y0,_e=this.placedOrientations[X.crossTileID],Pe=_e===p.ah.vertical,ke=_e===p.ah.horizontal||_e===p.ah.horizontalOnly;if(F>0||Y>0){const be=ji(ae.text);N(e.text,F,Pe?Dn:be),N(e.text,Y,ke?Dn:be);const Re=ae.text.isHidden();[X.rightJustifiedTextSymbolIndex,X.centerJustifiedTextSymbolIndex,X.leftJustifiedTextSymbolIndex].forEach(Ce=>{Ce>=0&&(e.text.placedSymbolArray.get(Ce).hidden=Re||Pe?1:0)}),X.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(X.verticalPlacedTextSymbolIndex).hidden=Re||ke?1:0);const Xe=this.variableOffsets[X.crossTileID];Xe&&this.markUsedJustification(e,Xe.anchor,X,_e);const Se=this.placedOrientations[X.crossTileID];Se&&(this.markUsedJustification(e,"left",X,Se),this.markUsedOrientation(e,Se,X))}if(fe){const be=ji(ae.icon),Re=!(D&&X.verticalPlacedIconSymbolIndex&&Pe);X.placedIconSymbolIndex>=0&&(N(e.icon,X.numIconVertices,Re?be:Dn),e.icon.placedSymbolArray.get(X.placedIconSymbolIndex).hidden=ae.icon.isHidden()),X.verticalPlacedIconSymbolIndex>=0&&(N(e.icon,X.numVerticalIconVertices,Re?Dn:be),e.icon.placedSymbolArray.get(X.verticalPlacedIconSymbolIndex).hidden=ae.icon.isHidden())}const we=q&&q.has(Z)?q.get(Z):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const be=e.collisionArrays[Z];if(be){let Re=new p.P(0,0);if(be.textBox||be.verticalTextBox){let Xe=!0;if(T){const Se=this.variableOffsets[ee];Se?(Re=Qt(Se.anchor,Se.width,Se.height,Se.textOffset,Se.textBoxScale),S&&Re._rotate(k?this.transform.angle:-this.transform.angle)):Xe=!1}if(be.textBox||be.verticalTextBox){let Se;be.textBox&&(Se=Pe),be.verticalTextBox&&(Se=ke),zn(e.textCollisionBox.collisionVertexArray,ae.text.placed,!Xe||Se,we.text,Re.x,Re.y)}}if(be.iconBox||be.verticalIconBox){const Xe=!!(!ke&&be.verticalIconBox);let Se;be.iconBox&&(Se=Xe),be.verticalIconBox&&(Se=!Xe),zn(e.iconCollisionBox.collisionVertexArray,ae.icon.placed,Se,we.icon,D?Re.x:0,D?Re.y:0)}}}}if(e.sortFeatures(this.transform.angle),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`);if(e.bucketInstanceId in this.collisionCircleArrays){const Z=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=Z.invProjMatrix,e.placementViewportMatrix=Z.viewportMatrix,e.collisionCircleArray=Z.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(e){return this.fadeDuration===0?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 zn(h,e,n,a,o,c){a&&a.length!==0||(a=[0,0,0,0]);const m=a[0]-Ke,_=a[1]-Ke,y=a[2]-Ke,b=a[3]-Ke;h.emplaceBack(e?1:0,n?1:0,o||0,c||0,m,_),h.emplaceBack(e?1:0,n?1:0,o||0,c||0,y,_),h.emplaceBack(e?1:0,n?1:0,o||0,c||0,y,b),h.emplaceBack(e?1:0,n?1:0,o||0,c||0,m,b)}const mt=Math.pow(2,25),Na=Math.pow(2,24),Ua=Math.pow(2,17),Ni=Math.pow(2,16),Ui=Math.pow(2,9),rc=Math.pow(2,8),Yi=Math.pow(2,1);function ji(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;const e=h.placed?1:0,n=Math.floor(127*h.opacity);return n*mt+e*Na+n*Ua+e*Ni+n*Ui+e*rc+n*Yi+e}const Dn=0;function pn(){return{isOccluded:(h,e,n)=>!1,getPitchedTextCorrection:(h,e,n)=>1,get useSpecialProjectionForSymbols(){return!1},projectTileCoordinates(h,e,n,a){throw new Error("Not implemented.")},translatePosition:(h,e,n,a)=>function(o,c,m,_,y=!1){if(!m[0]&&!m[1])return[0,0];const b=y?_==="map"?o.angle:0:_==="viewport"?-o.angle:0;if(b){const T=Math.sin(b),S=Math.cos(b);m=[m[0]*S-m[1]*T,m[0]*T+m[1]*S]}return[y?m[0]:rt(c,m[0],o.zoom),y?m[1]:rt(c,m[1],o.zoom)]}(h,e,n,a),getCircleRadiusCorrection:h=>1}}class jt{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,n,a,o,c){const m=this._bucketParts;for(;this._currentTileIndex_.sortKey-y.sortKey));this._currentPartIndex!this._forceFullPlacement&&ue.now()-o>2;for(;this._currentPlacementIndex>=0;){const m=n[e[this._currentPlacementIndex]],_=this.placement.collisionIndex.transform.zoom;if(m.type==="symbol"&&(!m.minzoom||m.minzoom<=_)&&(!m.maxzoom||m.maxzoom>_)){if(this._inProgressLayer||(this._inProgressLayer=new jt(m)),this._inProgressLayer.continuePlacement(a[m.source],this.placement,this._showCollisionBoxes,m,c))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const hr=512/p.X/2;class Vt{constructor(e,n,a){this.tileID=e,this.bucketInstanceId=a,this._symbolsByKey={};const o=new Map;for(let c=0;c({x:Math.floor(y.anchorX*hr),y:Math.floor(y.anchorY*hr)})),crossTileIDs:m.map(y=>y.crossTileID)};if(_.positions.length>128){const y=new p.av(_.positions.length,16,Uint16Array);for(const{x:b,y:T}of _.positions)y.add(b,T);y.finish(),delete _.positions,_.index=y}this._symbolsByKey[c]=_}}getScaledCoordinates(e,n){const{x:a,y:o,z:c}=this.tileID.canonical,{x:m,y:_,z:y}=n.canonical,b=hr/Math.pow(2,y-c),T=(_*p.X+e.anchorY)*b,S=o*p.X*hr;return{x:Math.floor((m*p.X+e.anchorX)*b-a*p.X*hr),y:Math.floor(T-S)}}findMatches(e,n,a){const o=this.tileID.canonical.ze)}}class $s{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ur{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const n=Math.round((e-this.lng)/360);if(n!==0)for(const a in this.indexes){const o=this.indexes[a],c={};for(const m in o){const _=o[m];_.tileID=_.tileID.unwrapTo(_.tileID.wrap+n),c[_.tileID.key]=_}this.indexes[a]=c}this.lng=e}addBucket(e,n,a){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let c=0;ce.overscaledZ)for(const _ in m){const y=m[_];y.tileID.isChildOf(e)&&y.findMatches(n.symbolInstances,e,o)}else{const _=m[e.scaledTo(Number(c)).key];_&&_.findMatches(n.symbolInstances,e,o)}}for(let c=0;c{n[a]=!0});for(const a in this.layerIndexes)n[a]||delete this.layerIndexes[a]}}const dr=(h,e)=>p.t(h,e&&e.filter(n=>n.identifier!=="source.canvas")),nc=p.aw();class qs extends p.E{constructor(e,n={}){super(),this._rtlPluginLoaded=()=>{for(const a in this.sourceCaches){const o=this.sourceCaches[a].getSource().type;o!=="vector"&&o!=="geojson"||this.sourceCaches[a].reload()}},this.map=e,this.dispatcher=new Vr(Ir(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(a,o)=>this.getGlyphs(a,o)),this.dispatcher.registerMessageHandler("GI",(a,o)=>this.getImages(a,o)),this.imageManager=new Gt,this.imageManager.setEventedParent(this),this.glyphManager=new _i(e._requestManager,n.localIdeographFontFamily),this.lineAtlas=new Vi(256,512),this.crossTileSymbolIndex=new ja,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new p.ax,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",p.ay()),Ar().on(xe,this._rtlPluginLoaded),this.on("data",a=>{if(a.dataType!=="source"||a.sourceDataType!=="metadata")return;const o=this.sourceCaches[a.sourceId];if(!o)return;const c=o.getSource();if(c&&c.vectorLayerIds)for(const m in this._layers){const _=this._layers[m];_.source===c.id&&this._validateLayer(_)}})}loadURL(e,n={},a){this.fire(new p.k("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const o=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const c=this._loadStyleRequest;p.h(o,this._loadStyleRequest).then(m=>{this._loadStyleRequest=null,this._load(m.data,n,a)}).catch(m=>{this._loadStyleRequest=null,m&&!c.signal.aborted&&this.fire(new p.j(m))})}loadJSON(e,n={},a){this.fire(new p.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,ue.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(e,n,a)}).catch(()=>{})}loadEmpty(){this.fire(new p.k("dataloading",{dataType:"style"})),this._load(nc,{validate:!1})}_load(e,n,a){var o;const c=n.transformStyle?n.transformStyle(a,e):e;if(!n.validate||!dr(this,p.u(c))){this._loaded=!0,this.stylesheet=c;for(const m in c.sources)this.addSource(m,c.sources[m],{validate:!1});c.sprite?this._loadSprite(c.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(c.glyphs),this._createLayers(),this.light=new ar(this.stylesheet.light),this.sky=new yi(this.stylesheet.sky),this.map.setTerrain((o=this.stylesheet.terrain)!==null&&o!==void 0?o:null),this.fire(new p.k("data",{dataType:"style"})),this.fire(new p.k("style.load"))}}_createLayers(){const e=p.az(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map(n=>n.id),this._layers={},this._serializedLayers=null;for(const n of e){const a=p.aA(n);a.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=a}}_loadSprite(e,n=!1,a=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(c,m,_,y){return p._(this,void 0,void 0,function*(){const b=ii(c),T=_>1?"@2x":"",S={},k={};for(const{id:D,url:B}of b){const N=m.transformRequest(Or(B,T,".json"),"SpriteJSON");S[D]=p.h(N,y);const q=m.transformRequest(Or(B,T,".png"),"SpriteImage");k[D]=Mt.getImage(q,y)}return yield Promise.all([...Object.values(S),...Object.values(k)]),function(D,B){return p._(this,void 0,void 0,function*(){const N={};for(const q in D){N[q]={};const Z=ue.getImageCanvasContext((yield B[q]).data),X=(yield D[q]).data;for(const F in X){const{width:Y,height:ee,x:ae,y:fe,sdf:_e,pixelRatio:Pe,stretchX:ke,stretchY:we,content:be,textFitWidth:Re,textFitHeight:Xe}=X[F];N[q][F]={data:null,pixelRatio:Pe,sdf:_e,stretchX:ke,stretchY:we,content:be,textFitWidth:Re,textFitHeight:Xe,spriteData:{width:Y,height:ee,x:ae,y:fe,context:Z}}}}return N})}(S,k)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(c=>{if(this._spriteRequest=null,c)for(const m in c){this._spritesImagesIds[m]=[];const _=this._spritesImagesIds[m]?this._spritesImagesIds[m].filter(y=>!(y in c)):[];for(const y of _)this.imageManager.removeImage(y),this._changedImages[y]=!0;for(const y in c[m]){const b=m==="default"?y:`${m}:${y}`;this._spritesImagesIds[m].push(b),b in this.imageManager.images?this.imageManager.updateImage(b,c[m][y],!1):this.imageManager.addImage(b,c[m][y]),n&&(this._changedImages[b]=!0)}}}).catch(c=>{this._spriteRequest=null,o=c,this.fire(new p.j(o))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"})),a&&a(o)})}_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 p.k("data",{dataType:"style"}))}_validateLayer(e){const n=this.sourceCaches[e.source];if(!n)return;const a=e.sourceLayer;if(!a)return;const o=n.getSource();(o.type==="geojson"||o.vectorLayerIds&&o.vectorLayerIds.indexOf(a)===-1)&&this.fire(new p.j(new Error(`Source layer "${a}" does not exist on source "${o.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||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,n=!1){const a=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?p.aB(a):a);const o=[];for(const c of e)if(a[c]){const m=n?p.aB(a[c]):a[c];o.push(m)}return o}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const n=Object.keys(this._layers);for(const a of n){const o=this._layers[a];o.type!=="custom"&&(e[a]=o.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition()||this.sky&&this.sky.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 n=this._changed;if(n){const o=Object.keys(this._updatedLayers),c=Object.keys(this._removedLayers);(o.length||c.length)&&this._updateWorkerLayers(o,c);for(const m in this._updatedSources){const _=this._updatedSources[m];if(_==="reload")this._reloadSource(m);else{if(_!=="clear")throw new Error(`Invalid action ${_}`);this._clearSource(m)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const m in this._updatedPaintProps)this._layers[m].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const a={};for(const o in this.sourceCaches){const c=this.sourceCaches[o];a[o]=c.used,c.used=!1}for(const o of this._order){const c=this._layers[o];c.recalculate(e,this._availableImages),!c.isHidden(e.zoom)&&c.source&&(this.sourceCaches[c.source].used=!0)}for(const o in a){const c=this.sourceCaches[o];!!a[o]!=!!c.used&&c.fire(new p.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:o}))}this.light.recalculate(e),this.sky.recalculate(e),this.z=e.zoom,n&&this.fire(new p.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const n in this.sourceCaches)this.sourceCaches[n].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,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var a;this._checkLoaded();const o=this.serialize();if(e=n.transformStyle?n.transformStyle(o,e):e,((a=n.validate)===null||a===void 0||a)&&dr(this,p.u(e)))return!1;(e=p.aB(e)).layers=p.az(e.layers);const c=p.aC(o,e),m=this._getOperationsToPerform(c);if(m.unimplemented.length>0)throw new Error(`Unimplemented: ${m.unimplemented.join(", ")}.`);if(m.operations.length===0)return!1;for(const _ of m.operations)_();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const n=[],a=[];for(const o of e)switch(o.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":n.push(()=>this.addLayer.apply(this,o.args));break;case"removeLayer":n.push(()=>this.removeLayer.apply(this,o.args));break;case"setPaintProperty":n.push(()=>this.setPaintProperty.apply(this,o.args));break;case"setLayoutProperty":n.push(()=>this.setLayoutProperty.apply(this,o.args));break;case"setFilter":n.push(()=>this.setFilter.apply(this,o.args));break;case"addSource":n.push(()=>this.addSource.apply(this,o.args));break;case"removeSource":n.push(()=>this.removeSource.apply(this,o.args));break;case"setLayerZoomRange":n.push(()=>this.setLayerZoomRange.apply(this,o.args));break;case"setLight":n.push(()=>this.setLight.apply(this,o.args));break;case"setGeoJSONSourceData":n.push(()=>this.setGeoJSONSourceData.apply(this,o.args));break;case"setGlyphs":n.push(()=>this.setGlyphs.apply(this,o.args));break;case"setSprite":n.push(()=>this.setSprite.apply(this,o.args));break;case"setSky":n.push(()=>this.setSky.apply(this,o.args));break;case"setTerrain":n.push(()=>this.map.setTerrain.apply(this,o.args));break;case"setTransition":n.push(()=>{});break;default:a.push(o.command)}return{operations:n,unimplemented:a}}addImage(e,n){if(this.getImage(e))return this.fire(new p.j(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,n),this._afterImageUpdated(e)}updateImage(e,n){this.imageManager.updateImage(e,n)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new p.j(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 p.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,a={}){if(this._checkLoaded(),this.sourceCaches[e]!==void 0)throw new Error(`Source "${e}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(p.u.source,`sources.${e}`,n,null,a))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const o=this.sourceCaches[e]=new $e(e,n,this.dispatcher);o.style=this,o.setEventedParent(this,()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e})),o.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error("There is no source with this ID");for(const a in this._layers)if(this._layers[a].source===e)return this.fire(new p.j(new Error(`Source "${e}" cannot be removed while layer "${a}" is using it.`)));const n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new p.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,n){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error(`There is no source with this ID=${e}`);const a=this.sourceCaches[e].getSource();if(a.type!=="geojson")throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(n),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,n,a={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new p.j(new Error(`Layer "${o}" already exists on this map.`)));let c;if(e.type==="custom"){if(dr(this,p.aD(e)))return;c=p.aA(e)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(o,e.source),e=p.aB(e),e=p.e(e,{source:o})),this._validate(p.u.layer,`layers.${o}`,e,{arrayIndex:-1},a))return;c=p.aA(e),this._validateLayer(c),c.setEventedParent(this,{layer:{id:o}})}const m=n?this._order.indexOf(n):this._order.length;if(n&&m===-1)this.fire(new p.j(new Error(`Cannot add layer "${o}" before non-existing layer "${n}".`)));else{if(this._order.splice(m,0,o),this._layerOrderChanged=!0,this._layers[o]=c,this._removedLayers[o]&&c.source&&c.type!=="custom"){const _=this._removedLayers[o];delete this._removedLayers[o],_.type!==c.type?this._updatedSources[c.source]="clear":(this._updatedSources[c.source]="reload",this.sourceCaches[c.source].pause())}this._updateLayer(c),c.onAdd&&c.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new p.j(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;const a=this._order.indexOf(e);this._order.splice(a,1);const o=n?this._order.indexOf(n):this._order.length;n&&o===-1?this.fire(new p.j(new Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const n=this._layers[e];if(!n)return void this.fire(new p.j(new Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);const a=this._order.indexOf(e);this._order.splice(a,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,a){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===n&&o.maxzoom===a||(n!=null&&(o.minzoom=n),a!=null&&(o.maxzoom=a),this._updateLayer(o)):this.fire(new p.j(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,a={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!p.aE(o.filter,n))return n==null?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(p.u.filter,`layers.${o.id}.filter`,n,null,a)||(o.filter=p.aB(n),this._updateLayer(o)))}else this.fire(new p.j(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return p.aB(this.getLayer(e).filter)}setLayoutProperty(e,n,a,o={}){this._checkLoaded();const c=this.getLayer(e);c?p.aE(c.getLayoutProperty(n),a)||(c.setLayoutProperty(n,a,o),this._updateLayer(c)):this.fire(new p.j(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){const a=this.getLayer(e);if(a)return a.getLayoutProperty(n);this.fire(new p.j(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,a,o={}){this._checkLoaded();const c=this.getLayer(e);c?p.aE(c.getPaintProperty(n),a)||(c.setPaintProperty(n,a,o)&&this._updateLayer(c),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new p.j(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(e,n){return this.getLayer(e).getPaintProperty(n)}setFeatureState(e,n){this._checkLoaded();const a=e.source,o=e.sourceLayer,c=this.sourceCaches[a];if(c===void 0)return void this.fire(new p.j(new Error(`The source '${a}' does not exist in the map's style.`)));const m=c.getSource().type;m==="geojson"&&o?this.fire(new p.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):m!=="vector"||o?(e.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),c.setFeatureState(o,e.id,n)):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,n){this._checkLoaded();const a=e.source,o=this.sourceCaches[a];if(o===void 0)return void this.fire(new p.j(new Error(`The source '${a}' does not exist in the map's style.`)));const c=o.getSource().type,m=c==="vector"?e.sourceLayer:void 0;c!=="vector"||m?n&&typeof e.id!="string"&&typeof e.id!="number"?this.fire(new p.j(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(m,e.id,n):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const n=e.source,a=e.sourceLayer,o=this.sourceCaches[n];if(o!==void 0)return o.getSource().type!=="vector"||a?(e.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),o.getFeatureState(a,e.id)):void this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new p.j(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return p.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=p.aF(this.sourceCaches,c=>c.serialize()),n=this._serializeByIds(this._order,!0),a=this.map.getTerrain()||void 0,o=this.stylesheet;return p.aG({version:o.version,name:o.name,metadata:o.metadata,light:o.light,sky:o.sky,center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,sprite:o.sprite,glyphs:o.glyphs,transition:o.transition,sources:e,layers:n,terrain:a},c=>c!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.sourceCaches[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const n=m=>this._layers[m].type==="fill-extrusion",a={},o=[];for(let m=this._order.length-1;m>=0;m--){const _=this._order[m];if(n(_)){a[_]=m;for(const y of e){const b=y[_];if(b)for(const T of b)o.push(T)}}}o.sort((m,_)=>_.intersectionZ-m.intersectionZ);const c=[];for(let m=this._order.length-1;m>=0;m--){const _=this._order[m];if(n(_))for(let y=o.length-1;y>=0;y--){const b=o[y].feature;if(a[b.layer.id]{const _e=Z.featureSortOrder;if(_e){const Pe=_e.indexOf(ae.featureIndex);return _e.indexOf(fe.featureIndex)-Pe}return fe.featureIndex-ae.featureIndex});for(const ae of ee)Y.push(ae)}}for(const Z in B)B[Z].forEach(X=>{const F=X.feature,Y=b[_[Z].source].getFeatureState(F.layer["source-layer"],F.id);F.source=F.layer.source,F.layer["source-layer"]&&(F.sourceLayer=F.layer["source-layer"]),F.state=Y});return B}(this._layers,m,this.sourceCaches,e,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(e,n){n&&n.filter&&this._validate(p.u.filter,"querySourceFeatures.filter",n.filter,null,n);const a=this.sourceCaches[e];return a?function(o,c){const m=o.getRenderableIds().map(b=>o.getTileByID(b)),_=[],y={};for(let b=0;bk.getTileByID(D)).sort((D,B)=>B.tileID.overscaledZ-D.tileID.overscaledZ||(D.tileID.isLessThan(B.tileID)?-1:1))}const S=this.crossTileSymbolIndex.addLayer(T,y[T.source],e.center.lng);m=m||S}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((c=c||this._layerOrderChanged||a===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(ue.now(),e.zoom))&&(this.pauseablePlacement=new _s(e,this.map.terrain,this._order,c,n,a,o,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,y),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(ue.now()),_=!0),m&&this.pauseablePlacement.placement.setStale()),_||m)for(const b of this._order){const T=this._layers[b];T.type==="symbol"&&this.placement.updateLayerOpacities(T,y[T.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(ue.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,n){return p._(this,void 0,void 0,function*(){const a=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const o=this.sourceCaches[n.source];return o&&o.setDependencies(n.tileID.key,n.type,n.icons),a})}getGlyphs(e,n){return p._(this,void 0,void 0,function*(){const a=yield this.glyphManager.getGlyphs(n.stacks),o=this.sourceCaches[n.source];return o&&o.setDependencies(n.tileID.key,n.type,[""]),a})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(p.u.glyphs,"glyphs",e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,n,a={},o){this._checkLoaded();const c=[{id:e,url:n}],m=[...ii(this.stylesheet.sprite),...c];this._validate(p.u.sprite,"sprite",m,null,a)||(this.stylesheet.sprite=m,this._loadSprite(c,!0,o))}removeSprite(e){this._checkLoaded();const n=ii(this.stylesheet.sprite);if(n.find(a=>a.id===e)){if(this._spritesImagesIds[e])for(const a of this._spritesImagesIds[e])this.imageManager.removeImage(a),this._changedImages[a]=!0;n.splice(n.findIndex(a=>a.id===e),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"}))}else this.fire(new p.j(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return ii(this.stylesheet.sprite)}setSprite(e,n={},a){this._checkLoaded(),e&&this._validate(p.u.sprite,"sprite",e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,a):(this._unloadSprite(),a&&a(null)))}}var fn=p.Y([{name:"a_pos",type:"Int16",components:2}]);const Qr={prelude:dt(`#ifdef GL_ES precision mediump float; #else #if !defined(lowp) @@ -577,9 +577,8 @@ uniform ${T} ${S} u_${k}; #endif `}),staticAttributes:a,staticUniforms:m}}class $a{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,n,a,o,c,m,_,y,b){this.context=e;let T=this.boundPaintVertexBuffers.length!==o.length;for(let S=0;!T&&S({u_matrix:h,u_texture:0,u_ele_delta:e,u_fog_matrix:n,u_fog_color:a?a.properties.get("fog-color"):p.aM.white,u_fog_ground_blend:a?a.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?a.calculateFogBlendOpacity(o):0,u_horizon_color:a?a.properties.get("horizon-color"):p.aM.white,u_horizon_fog_blend:a?a.properties.get("horizon-fog-blend"):1});function Ln(h){const e=[];for(let n=0;n({u_depth:new p.aH(ae,fe.u_depth),u_terrain:new p.aH(ae,fe.u_terrain),u_terrain_dim:new p.aI(ae,fe.u_terrain_dim),u_terrain_matrix:new p.aJ(ae,fe.u_terrain_matrix),u_terrain_unpack:new p.aK(ae,fe.u_terrain_unpack),u_terrain_exaggeration:new p.aI(ae,fe.u_terrain_exaggeration)}))(e,ee),this.binderUniforms=a?a.getUniforms(e,ee):[]}draw(e,n,a,o,c,m,_,y,b,T,S,k,D,B,N,q,Z,X){const F=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(o),e.setColorMode(c),e.setCullFace(m),y){e.activeTexture.set(F.TEXTURE2),F.bindTexture(F.TEXTURE_2D,y.depthTexture),e.activeTexture.set(F.TEXTURE3),F.bindTexture(F.TEXTURE_2D,y.texture);for(const ee in this.terrainUniforms)this.terrainUniforms[ee].set(y[ee])}for(const ee in this.fixedUniforms)this.fixedUniforms[ee].set(_[ee]);N&&N.setUniforms(e,this.binderUniforms,D,{zoom:B});let Y=0;switch(n){case F.LINES:Y=2;break;case F.TRIANGLES:Y=3;break;case F.LINE_STRIP:Y=1}for(const ee of k.get()){const ae=ee.vaos||(ee.vaos={});(ae[b]||(ae[b]=new $a)).bind(e,this,T,N?N.getPaintVertexBuffers():[],S,ee.vertexOffset,q,Z,X),F.drawElements(n,ee.primitiveLength*Y,F.UNSIGNED_SHORT,ee.primitiveOffset*Y*2)}}}function Zs(h,e,n){const a=1/rt(n,1,e.transform.tileZoom),o=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,e.transform.tileZoom)/o,m=c*(n.tileID.canonical.x+n.tileID.wrap*o),_=c*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[a,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_]}}const ys=(h,e,n,a)=>{const o=e.style.light,c=o.properties.get("position"),m=[c.x,c.y,c.z],_=function(){var b=new p.A(9);return p.A!=Float32Array&&(b[1]=0,b[2]=0,b[3]=0,b[5]=0,b[6]=0,b[7]=0),b[0]=1,b[4]=1,b[8]=1,b}();o.properties.get("anchor")==="viewport"&&function(b,T){var S=Math.sin(T),k=Math.cos(T);b[0]=k,b[1]=S,b[2]=0,b[3]=-S,b[4]=k,b[5]=0,b[6]=0,b[7]=0,b[8]=1}(_,-e.transform.angle),function(b,T,S){var k=T[0],D=T[1],B=T[2];b[0]=k*S[0]+D*S[3]+B*S[6],b[1]=k*S[1]+D*S[4]+B*S[7],b[2]=k*S[2]+D*S[5]+B*S[8]}(m,m,_);const y=o.properties.get("color");return{u_matrix:h,u_lightpos:m,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+n,u_opacity:a}},Gs=(h,e,n,a,o,c,m)=>p.e(ys(h,e,n,a),Zs(c,e,m),{u_height_factor:-Math.pow(2,o.overscaledZ)/m.tileSize/8}),Rn=h=>({u_matrix:h}),Yo=(h,e,n,a)=>p.e(Rn(h),Zs(n,e,a)),sc=(h,e)=>({u_matrix:h,u_world:e}),Qo=(h,e,n,a,o)=>p.e(Yo(h,e,n,a),{u_world:o}),ac=(h,e,n,a)=>{const o=h.transform;let c,m;if(a.paint.get("circle-pitch-alignment")==="map"){const _=rt(n,1,o.zoom);c=!0,m=[_,_]}else c=!1,m=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(a.paint.get("circle-pitch-scale")==="map"),u_matrix:h.translatePosMatrix(e.posMatrix,n,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_pitch_with_map:+c,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:m}},mn=(h,e,n)=>({u_matrix:h,u_inv_matrix:e,u_camera_to_center_distance:n.cameraToCenterDistance,u_viewport_size:[n.width,n.height]}),xs=(h,e,n=1)=>({u_matrix:h,u_color:e,u_overlay:0,u_overlay_scale:n}),Mi=h=>({u_matrix:h}),ki=(h,e,n,a)=>({u_matrix:h,u_extrude_scale:rt(e,1,n),u_intensity:a}),Hs=(h,e,n,a)=>{const o=p.H();p.aP(o,0,h.width,h.height,0,0,1);const c=h.context.gl;return{u_matrix:o,u_world:[c.drawingBufferWidth,c.drawingBufferHeight],u_image:n,u_color_ramp:a,u_opacity:e.paint.get("heatmap-opacity")}};function Xs(h,e){const n=Math.pow(2,e.canonical.z),a=e.canonical.y;return[new p.Z(0,a/n).toLngLat().lat,new p.Z(0,(a+1)/n).toLngLat().lat]}const Ws=(h,e,n,a)=>{const o=h.transform;return{u_matrix:il(h,e,n,a),u_ratio:1/rt(e,1,o.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},el=(h,e,n,a,o)=>p.e(Ws(h,e,n,o),{u_image:0,u_image_height:a}),Bn=(h,e,n,a,o)=>{const c=h.transform,m=tl(e,c);return{u_matrix:il(h,e,n,o),u_texsize:e.imageAtlasTexture.size,u_ratio:1/rt(e,1,c.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[m,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},oc=(h,e,n,a,o,c)=>{const m=h.lineAtlas,_=tl(e,h.transform),y=n.layout.get("line-cap")==="round",b=m.getDash(a.from,y),T=m.getDash(a.to,y),S=b.width*o.fromScale,k=T.width*o.toScale;return p.e(Ws(h,e,n,c),{u_patternscale_a:[_/S,-b.height/2],u_patternscale_b:[_/k,-T.height/2],u_sdfgamma:m.width/(256*Math.min(S,k)*h.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:T.y,u_mix:o.t})};function tl(h,e){return 1/rt(h,1,e.tileZoom)}function il(h,e,n,a){return h.translatePosMatrix(a?a.posMatrix:e.tileID.posMatrix,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const lc=(h,e,n,a,o)=>{return{u_matrix:h,u_tl_parent:e,u_scale_parent:n,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(m=o.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(c=o.paint.get("raster-contrast"),c>0?1/(1-c):1+c),u_spin_weights:cc(o.paint.get("raster-hue-rotate"))};var c,m};function cc(h){h*=Math.PI/180;const e=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}const rl=(h,e,n,a,o,c,m,_,y,b,T,S,k,D)=>{const B=m.transform;return{u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:B.cameraToCenterDistance,u_pitch:B.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:B.width/B.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:_,u_label_plane_matrix:y,u_coord_matrix:b,u_is_text:+S,u_pitch_with_map:+a,u_is_along_line:o,u_is_variable_anchor:c,u_texsize:k,u_texture:0,u_translation:T,u_pitched_scale:D}},vs=(h,e,n,a,o,c,m,_,y,b,T,S,k,D,B)=>{const N=m.transform;return p.e(rl(h,e,n,a,o,c,m,_,y,b,T,S,k,B),{u_gamma_scale:a?Math.cos(N._pitch)*N.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:+D})},Ga=(h,e,n,a,o,c,m,_,y,b,T,S,k,D)=>p.e(vs(h,e,n,a,o,c,m,_,y,b,T,!0,S,!0,D),{u_texsize_icon:k,u_texture_icon:1}),Ks=(h,e,n)=>({u_matrix:h,u_opacity:e,u_color:n}),Ha=(h,e,n,a,o,c)=>p.e(function(m,_,y,b){const T=y.imageManager.getPattern(m.from.toString()),S=y.imageManager.getPattern(m.to.toString()),{width:k,height:D}=y.imageManager.getPixelSize(),B=Math.pow(2,b.tileID.overscaledZ),N=b.tileSize*Math.pow(2,y.transform.tileZoom)/B,q=N*(b.tileID.canonical.x+b.tileID.wrap*B),Z=N*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:T.tl,u_pattern_br_a:T.br,u_pattern_tl_b:S.tl,u_pattern_br_b:S.br,u_texsize:[k,D],u_mix:_.t,u_pattern_size_a:T.displaySize,u_pattern_size_b:S.displaySize,u_scale_a:_.fromScale,u_scale_b:_.toScale,u_tile_units_to_pixels:1/rt(b,1,y.transform.tileZoom),u_pixel_coord_upper:[q>>16,Z>>16],u_pixel_coord_lower:[65535&q,65535&Z]}}(a,c,n,o),{u_matrix:h,u_opacity:e}),Xa={fillExtrusion:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_opacity:new p.aI(h,e.u_opacity)}),fillExtrusionPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_height_factor:new p.aI(h,e.u_height_factor),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade),u_opacity:new p.aI(h,e.u_opacity)}),fill:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),fillPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),fillOutline:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world)}),fillOutlinePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),circle:(h,e)=>({u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_scale_with_map:new p.aH(h,e.u_scale_with_map),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_extrude_scale:new p.aO(h,e.u_extrude_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_matrix:new p.aJ(h,e.u_matrix)}),collisionBox:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_pixel_extrude_scale:new p.aO(h,e.u_pixel_extrude_scale)}),collisionCircle:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_inv_matrix:new p.aJ(h,e.u_inv_matrix),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_viewport_size:new p.aO(h,e.u_viewport_size)}),debug:(h,e)=>({u_color:new p.aL(h,e.u_color),u_matrix:new p.aJ(h,e.u_matrix),u_overlay:new p.aH(h,e.u_overlay),u_overlay_scale:new p.aI(h,e.u_overlay_scale)}),clippingMask:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),heatmap:(h,e)=>({u_extrude_scale:new p.aI(h,e.u_extrude_scale),u_intensity:new p.aI(h,e.u_intensity),u_matrix:new p.aJ(h,e.u_matrix)}),heatmapTexture:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_color_ramp:new p.aH(h,e.u_color_ramp),u_opacity:new p.aI(h,e.u_opacity)}),hillshade:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_latrange:new p.aO(h,e.u_latrange),u_light:new p.aO(h,e.u_light),u_shadow:new p.aL(h,e.u_shadow),u_highlight:new p.aL(h,e.u_highlight),u_accent:new p.aL(h,e.u_accent)}),hillshadePrepare:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_dimension:new p.aO(h,e.u_dimension),u_zoom:new p.aI(h,e.u_zoom),u_unpack:new p.aK(h,e.u_unpack)}),line:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels)}),lineGradient:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_image:new p.aH(h,e.u_image),u_image_height:new p.aI(h,e.u_image_height)}),linePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texsize:new p.aO(h,e.u_texsize),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_image:new p.aH(h,e.u_image),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),lineSDF:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_patternscale_a:new p.aO(h,e.u_patternscale_a),u_patternscale_b:new p.aO(h,e.u_patternscale_b),u_sdfgamma:new p.aI(h,e.u_sdfgamma),u_image:new p.aH(h,e.u_image),u_tex_y_a:new p.aI(h,e.u_tex_y_a),u_tex_y_b:new p.aI(h,e.u_tex_y_b),u_mix:new p.aI(h,e.u_mix)}),raster:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_tl_parent:new p.aO(h,e.u_tl_parent),u_scale_parent:new p.aI(h,e.u_scale_parent),u_buffer_scale:new p.aI(h,e.u_buffer_scale),u_fade_t:new p.aI(h,e.u_fade_t),u_opacity:new p.aI(h,e.u_opacity),u_image0:new p.aH(h,e.u_image0),u_image1:new p.aH(h,e.u_image1),u_brightness_low:new p.aI(h,e.u_brightness_low),u_brightness_high:new p.aI(h,e.u_brightness_high),u_saturation_factor:new p.aI(h,e.u_saturation_factor),u_contrast_factor:new p.aI(h,e.u_contrast_factor),u_spin_weights:new p.aN(h,e.u_spin_weights)}),symbolIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolSDF:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolTextAndIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texsize_icon:new p.aO(h,e.u_texsize_icon),u_texture:new p.aH(h,e.u_texture),u_texture_icon:new p.aH(h,e.u_texture_icon),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),background:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_color:new p.aL(h,e.u_color)}),backgroundPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_image:new p.aH(h,e.u_image),u_pattern_tl_a:new p.aO(h,e.u_pattern_tl_a),u_pattern_br_a:new p.aO(h,e.u_pattern_br_a),u_pattern_tl_b:new p.aO(h,e.u_pattern_tl_b),u_pattern_br_b:new p.aO(h,e.u_pattern_br_b),u_texsize:new p.aO(h,e.u_texsize),u_mix:new p.aI(h,e.u_mix),u_pattern_size_a:new p.aO(h,e.u_pattern_size_a),u_pattern_size_b:new p.aO(h,e.u_pattern_size_b),u_scale_a:new p.aI(h,e.u_scale_a),u_scale_b:new p.aI(h,e.u_scale_b),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_tile_units_to_pixels:new p.aI(h,e.u_tile_units_to_pixels)}),terrain:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_ele_delta:new p.aI(h,e.u_ele_delta),u_fog_matrix:new p.aJ(h,e.u_fog_matrix),u_fog_color:new p.aL(h,e.u_fog_color),u_fog_ground_blend:new p.aI(h,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new p.aI(h,e.u_fog_ground_blend_opacity),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon_fog_blend:new p.aI(h,e.u_horizon_fog_blend)}),terrainDepth:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ele_delta:new p.aI(h,e.u_ele_delta)}),terrainCoords:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_terrain_coords_id:new p.aI(h,e.u_terrain_coords_id),u_ele_delta:new p.aI(h,e.u_ele_delta)}),sky:(h,e)=>({u_sky_color:new p.aL(h,e.u_sky_color),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon:new p.aI(h,e.u_horizon),u_sky_horizon_blend:new p.aI(h,e.u_sky_horizon_blend)})};class kr{constructor(e,n,a){this.context=e;const o=e.gl;this.buffer=o.createBuffer(),this.dynamicDraw=!!a,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const hc={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Wa{constructor(e,n,a,o){this.length=n.length,this.attributes=a,this.itemSize=n.bytesPerElement,this.dynamicDraw=o,this.context=e;const c=e.gl;this.buffer=c.createBuffer(),e.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.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 n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,n){for(let a=0;a0){const ae=p.H();p.aQ(ae,F.placementInvProjMatrix,h.transform.glCoordMatrix),p.aQ(ae,ae,F.placementViewportMatrix),y.push({circleArray:ee,circleOffset:T,transform:X.posMatrix,invTransform:ae,coord:X}),b+=ee.length/4,T=b}Y&&_.draw(c,m.LINES,it.disabled,vt.disabled,h.colorModeForRenderPass(),gt.disabled,{u_matrix:X.posMatrix,u_pixel_extrude_scale:[1/(S=h.transform).width,1/S.height]},h.style.map.terrain&&h.style.map.terrain.getTerrainData(X),n.id,Y.layoutVertexBuffer,Y.indexBuffer,Y.segments,null,h.transform.zoom,null,null,Y.collisionVertexBuffer)}var S;if(!o||!y.length)return;const k=h.useProgram("collisionCircle"),D=new p.aR;D.resize(4*b),D._trim();let B=0;for(const Z of y)for(let X=0;X=0&&(Z[F.associatedIconIndex]={shiftedAnchor:qe,angle:Tt})}else Ne(F.numGlyphs,N)}if(b){q.clear();const X=h.icon.placedSymbolArray;for(let F=0;Fh.style.map.terrain.getElevation(we,is,rs):null,In=n.layout.get("text-rotation-alignment")==="map";R(Re,we.posMatrix,h,o,es,ts,Z,b,In,N,we.toUnwrapped(),B.width,B.height,ir,at)}const rr=we.posMatrix,nr=o&&_e||ko,tn=X||nr?Ts:es,gr=va,ei=Ce&&n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let ci;ci=Ce?Re.iconsInText?Ga(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,oi,bi,ke):vs(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,o,oi,!0,ke):rl(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,o,oi,ke);const Gi={program:Ye,buffers:Xe,uniformValues:ci,atlasTexture:mr,atlasTextureIcon:li,atlasInterpolation:It,atlasInterpolationIcon:Ei,isSDF:Ce,hasHalo:ei};if(ee&&Re.canOverlap){ae=!0;const at=Xe.segments.get();for(const In of at)Pe.push({segments:new p.a0([In]),sortKey:In.sortKey,state:Gi,terrainData:St})}else Pe.push({segments:Xe.segments,sortKey:0,state:Gi,terrainData:St})}ae&&Pe.sort((we,be)=>we.sortKey-be.sortKey);for(const we of Pe){const be=we.state;if(k.activeTexture.set(D.TEXTURE0),be.atlasTexture.bind(be.atlasInterpolation,D.CLAMP_TO_EDGE),be.atlasTextureIcon&&(k.activeTexture.set(D.TEXTURE1),be.atlasTextureIcon&&be.atlasTextureIcon.bind(be.atlasInterpolationIcon,D.CLAMP_TO_EDGE)),be.isSDF){const Re=be.uniformValues;be.hasHalo&&(Re.u_is_halo=1,so(be.buffers,we.segments,n,h,be.program,fe,T,S,Re,we.terrainData)),Re.u_is_halo=0}so(be.buffers,we.segments,n,h,be.program,fe,T,S,be.uniformValues,we.terrainData)}}function so(h,e,n,a,o,c,m,_,y,b){const T=a.context;o.draw(T,T.gl.TRIANGLES,c,m,_,gt.disabled,y,b,n.id,h.layoutVertexBuffer,h.indexBuffer,e,n.paint,a.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function ao(h,e,n,a){const o=h.context,c=o.gl,m=vt.disabled,_=new Rt([c.ONE,c.ONE],p.aM.transparent,[!0,!0,!0,!0]),y=e.getBucket(n);if(!y)return;const b=a.key;let T=n.heatmapFbos.get(b);T||(T=Ss(o,e.tileSize,e.tileSize),n.heatmapFbos.set(b,T)),o.bindFramebuffer.set(T.framebuffer),o.viewport.set([0,0,e.tileSize,e.tileSize]),o.clear({color:p.aM.transparent});const S=y.programConfigurations.get(n.id),k=h.useProgram("heatmap",S),D=h.style.map.terrain.getTerrainData(a);k.draw(o,c.TRIANGLES,it.disabled,m,_,gt.disabled,ki(a.posMatrix,e,h.transform.zoom,n.paint.get("heatmap-intensity")),D,n.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,n.paint,h.transform.zoom,S)}function bn(h,e,n){const a=h.context,o=a.gl;a.setColorMode(h.colorModeForRenderPass());const c=Is(a,e),m=n.key,_=e.heatmapFbos.get(m);_&&(a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,_.colorAttachment.get()),a.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE),h.useProgram("heatmapTexture").draw(a,o.TRIANGLES,it.disabled,vt.disabled,h.colorModeForRenderPass(),gt.disabled,Hs(h,e,0,1),null,e.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments,e.paint,h.transform.zoom),_.destroy(),e.heatmapFbos.delete(m))}function Ss(h,e,n){var a,o;const c=h.gl,m=c.createTexture();c.bindTexture(c.TEXTURE_2D,m),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);const _=(a=h.HALF_FLOAT)!==null&&a!==void 0?a:c.UNSIGNED_BYTE,y=(o=h.RGBA16F)!==null&&o!==void 0?o:c.RGBA;c.texImage2D(c.TEXTURE_2D,0,y,e,n,0,c.RGBA,_,null);const b=h.createFramebuffer(e,n,!1,!1);return b.colorAttachment.set(m),b}function Is(h,e){return e.colorRampTexture||(e.colorRampTexture=new et(h,e.colorRamp,h.gl.RGBA)),e.colorRampTexture}function Vn(h,e,n,a,o){if(!n||!a||!a.imageAtlas)return;const c=a.imageAtlas.patternPositions;let m=c[n.to.toString()],_=c[n.from.toString()];if(!m&&_&&(m=_),!_&&m&&(_=m),!m||!_){const y=o.getPaintProperty(e);m=c[y],_=c[y]}m&&_&&h.setConstantPatternPositions(m,_)}function Ps(h,e,n,a,o,c,m){const _=h.context.gl,y="fill-pattern",b=n.paint.get(y),T=b&&b.constantOr(1),S=n.getCrossfadeParameters();let k,D,B,N,q;m?(D=T&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",k=_.LINES):(D=T?"fillPattern":"fill",k=_.TRIANGLES);const Z=b.constantOr(null);for(const X of a){const F=e.getTile(X);if(T&&!F.patternsLoaded())continue;const Y=F.getBucket(n);if(!Y)continue;const ee=Y.programConfigurations.get(n.id),ae=h.useProgram(D,ee),fe=h.style.map.terrain&&h.style.map.terrain.getTerrainData(X);T&&(h.context.activeTexture.set(_.TEXTURE0),F.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),ee.updatePaintBuffers(S)),Vn(ee,y,Z,F,n);const _e=fe?X:null,Pe=h.translatePosMatrix(_e?_e.posMatrix:X.posMatrix,F,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(m){N=Y.indexBuffer2,q=Y.segments2;const ke=[_.drawingBufferWidth,_.drawingBufferHeight];B=D==="fillOutlinePattern"&&T?Qo(Pe,h,S,F,ke):sc(Pe,ke)}else N=Y.indexBuffer,q=Y.segments,B=T?Yo(Pe,h,S,F):Rn(Pe);ae.draw(h.context,k,o,h.stencilModeForClipping(X),c,gt.disabled,B,fe,n.id,Y.layoutVertexBuffer,N,q,n.paint,h.transform.zoom,ee)}}function ia(h,e,n,a,o,c,m){const _=h.context,y=_.gl,b="fill-extrusion-pattern",T=n.paint.get(b),S=T.constantOr(1),k=n.getCrossfadeParameters(),D=n.paint.get("fill-extrusion-opacity"),B=T.constantOr(null);for(const N of a){const q=e.getTile(N),Z=q.getBucket(n);if(!Z)continue;const X=h.style.map.terrain&&h.style.map.terrain.getTerrainData(N),F=Z.programConfigurations.get(n.id),Y=h.useProgram(S?"fillExtrusionPattern":"fillExtrusion",F);S&&(h.context.activeTexture.set(y.TEXTURE0),q.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),F.updatePaintBuffers(k)),Vn(F,b,B,q,n);const ee=h.translatePosMatrix(N.posMatrix,q,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ae=n.paint.get("fill-extrusion-vertical-gradient"),fe=S?Gs(ee,h,ae,D,N,k,q):ys(ee,h,ae,D);Y.draw(_,_.gl.TRIANGLES,o,c,m,gt.backCCW,fe,X,n.id,Z.layoutVertexBuffer,Z.indexBuffer,Z.segments,n.paint,h.transform.zoom,F,h.style.map.terrain&&Z.centroidVertexBuffer)}}function Nn(h,e,n,a,o,c,m){const _=h.context,y=_.gl,b=n.fbo;if(!b)return;const T=h.useProgram("hillshade"),S=h.style.map.terrain&&h.style.map.terrain.getTerrainData(e);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b.colorAttachment.get()),T.draw(_,y.TRIANGLES,o,c,m,gt.disabled,((k,D,B,N)=>{const q=B.paint.get("hillshade-shadow-color"),Z=B.paint.get("hillshade-highlight-color"),X=B.paint.get("hillshade-accent-color");let F=B.paint.get("hillshade-illumination-direction")*(Math.PI/180);B.paint.get("hillshade-illumination-anchor")==="viewport"&&(F-=k.transform.angle);const Y=!k.options.moving;return{u_matrix:N?N.posMatrix:k.transform.calculatePosMatrix(D.tileID.toUnwrapped(),Y),u_image:0,u_latrange:Xs(0,D.tileID),u_light:[B.paint.get("hillshade-exaggeration"),F],u_shadow:q,u_highlight:Z,u_accent:X}})(h,n,a,S?e:null),S,a.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments)}function Un(h,e,n,a,o,c){const m=h.context,_=m.gl,y=e.dem;if(y&&y.data){const b=y.dim,T=y.stride,S=y.getPixels();if(m.activeTexture.set(_.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||h.getTileTexture(T),e.demTexture){const D=e.demTexture;D.update(S,{premultiply:!1}),D.bind(_.NEAREST,_.CLAMP_TO_EDGE)}else e.demTexture=new et(m,S,_.RGBA,{premultiply:!1}),e.demTexture.bind(_.NEAREST,_.CLAMP_TO_EDGE);m.activeTexture.set(_.TEXTURE0);let k=e.fbo;if(!k){const D=new et(m,{width:b,height:b,data:null},_.RGBA);D.bind(_.LINEAR,_.CLAMP_TO_EDGE),k=e.fbo=m.createFramebuffer(b,b,!0,!1),k.colorAttachment.set(D.texture)}m.bindFramebuffer.set(k.framebuffer),m.viewport.set([0,0,b,b]),h.useProgram("hillshadePrepare").draw(m,_.TRIANGLES,a,o,c,gt.disabled,((D,B)=>{const N=B.stride,q=p.H();return p.aP(q,0,p.X,-p.X,0,0,1),p.J(q,q,[0,-p.X,0]),{u_matrix:q,u_image:1,u_dimension:[N,N],u_zoom:D.overscaledZ,u_unpack:B.getUnpackVector()}})(e.tileID,y),null,n.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments),e.needsHillshadePrepare=!1}}function gl(h,e,n,a,o,c){const m=a.paint.get("raster-fade-duration");if(!c&&m>0){const _=de.now(),y=(_-h.timeAdded)/m,b=e?(_-e.timeAdded)/m:-1,T=n.getSource(),S=o.coveringZoomLevel({tileSize:T.tileSize,roundZoom:T.roundZoom}),k=!e||Math.abs(e.tileID.overscaledZ-S)>Math.abs(h.tileID.overscaledZ-S),D=k&&h.refreshedUponExpiration?1:p.ac(k?y:1-b,0,1);return h.refreshedUponExpiration&&y>=1&&(h.refreshedUponExpiration=!1),e?{opacity:1,mix:1-D}:{opacity:D,mix:0}}return{opacity:1,mix:0}}const oo=new p.aM(1,0,0,1),ct=new p.aM(0,1,0,1),ra=new p.aM(0,0,1,1),vc=new p.aM(1,0,1,1),_l=new p.aM(0,1,1,1);function jn(h,e,n,a){na(h,0,e+n/2,h.transform.width,n,a)}function yl(h,e,n,a){na(h,e-n/2,0,n,h.transform.height,a)}function na(h,e,n,a,o,c){const m=h.context,_=m.gl;_.enable(_.SCISSOR_TEST),_.scissor(e*h.pixelRatio,n*h.pixelRatio,a*h.pixelRatio,o*h.pixelRatio),m.clear({color:c}),_.disable(_.SCISSOR_TEST)}function xl(h,e,n){const a=h.context,o=a.gl,c=n.posMatrix,m=h.useProgram("debug"),_=it.disabled,y=vt.disabled,b=h.colorModeForRenderPass(),T="$debug",S=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);a.activeTexture.set(o.TEXTURE0);const k=e.getTileByID(n.key).latestRawTileData,D=Math.floor((k&&k.byteLength||0)/1024),B=e.getTile(n).tileSize,N=512/Math.min(B,512)*(n.overscaledZ/h.transform.zoom)*.5;let q=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(q+=` => ${n.overscaledZ}`),function(Z,X){Z.initDebugOverlayCanvas();const F=Z.debugOverlayCanvas,Y=Z.context.gl,ee=Z.debugOverlayCanvas.getContext("2d");ee.clearRect(0,0,F.width,F.height),ee.shadowColor="white",ee.shadowBlur=2,ee.lineWidth=1.5,ee.strokeStyle="white",ee.textBaseline="top",ee.font="bold 36px Open Sans, sans-serif",ee.fillText(X,5,5),ee.strokeText(X,5,5),Z.debugOverlayTexture.update(F),Z.debugOverlayTexture.bind(Y.LINEAR,Y.CLAMP_TO_EDGE)}(h,`${q} ${D}kB`),m.draw(a,o.TRIANGLES,_,y,Rt.alphaBlended,gt.disabled,xs(c,p.aM.transparent,N),null,T,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),m.draw(a,o.LINE_STRIP,_,y,b,gt.disabled,xs(c,p.aM.red),S,T,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function vl(h,e,n){const a=h.context,o=a.gl,c=h.colorModeForRenderPass(),m=new it(o.LEQUAL,it.ReadWrite,h.depthRangeFor3D),_=h.useProgram("terrain"),y=e.getTerrainMesh();a.bindFramebuffer.set(null),a.viewport.set([0,0,h.width,h.height]);for(const b of n){const T=h.renderToTexture.getTexture(b),S=e.getTerrainData(b.tileID);a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,T.texture);const k=h.transform.calculatePosMatrix(b.tileID.toUnwrapped()),D=e.getMeshFrameDelta(h.transform.zoom),B=h.transform.calculateFogMatrix(b.tileID.toUnwrapped()),N=qa(k,D,B,h.style.sky,h.transform.pitch);_.draw(a,o.TRIANGLES,m,vt.disabled,c,gt.backCCW,N,S,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}class sa{constructor(e,n,a){this.vertexBuffer=e,this.indexBuffer=n,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class aa{constructor(e,n){this.context=new xc(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:p.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=$e.maxUnderzooming+$e.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new ja}resize(e,n,a){if(this.width=Math.floor(e*a),this.height=Math.floor(n*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const o of this.style._order)this.style._layers[o].resize()}setup(){const e=this.context,n=new p.aX;n.emplaceBack(0,0),n.emplaceBack(p.X,0),n.emplaceBack(0,p.X),n.emplaceBack(p.X,p.X),this.tileExtentBuffer=e.createVertexBuffer(n,fn.members),this.tileExtentSegments=p.a0.simpleSegment(0,0,4,2);const a=new p.aX;a.emplaceBack(0,0),a.emplaceBack(p.X,0),a.emplaceBack(0,p.X),a.emplaceBack(p.X,p.X),this.debugBuffer=e.createVertexBuffer(a,fn.members),this.debugSegments=p.a0.simpleSegment(0,0,4,5);const o=new p.$;o.emplaceBack(0,0,0,0),o.emplaceBack(p.X,0,p.X,0),o.emplaceBack(0,p.X,0,p.X),o.emplaceBack(p.X,p.X,p.X,p.X),this.rasterBoundsBuffer=e.createVertexBuffer(o,Kr.members),this.rasterBoundsSegments=p.a0.simpleSegment(0,0,4,2);const c=new p.aX;c.emplaceBack(0,0),c.emplaceBack(1,0),c.emplaceBack(0,1),c.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(c,fn.members),this.viewportSegments=p.a0.simpleSegment(0,0,4,2);const m=new p.aZ;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(m);const _=new p.aY;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(_);const y=this.context.gl;this.stencilClearMode=new vt({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){const e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const a=p.H();p.aP(a,0,this.width,this.height,0,0,1),p.K(a,a,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(e,n.TRIANGLES,it.disabled,this.stencilClearMode,Rt.disabled,gt.disabled,Mi(a),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,n){if(this.currentStencilSource===e.source||!e.isTileClipped()||!n||!n.length)return;this.currentStencilSource=e.source;const a=this.context,o=a.gl;this.nextStencilID+n.length>256&&this.clearStencil(),a.setColorMode(Rt.disabled),a.setDepthMode(it.disabled);const c=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const m of n){const _=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);c.draw(a,o.TRIANGLES,it.disabled,new vt({func:o.ALWAYS,mask:0},_,255,o.KEEP,o.KEEP,o.REPLACE),Rt.disabled,gt.disabled,Mi(m.posMatrix),y,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,n=this.context.gl;return new vt({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){const n=this.context.gl;return new vt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(e){const n=this.context.gl,a=e.sort((m,_)=>_.overscaledZ-m.overscaledZ),o=a[a.length-1].overscaledZ,c=a[0].overscaledZ-o+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();const m={};for(let _=0;_({u_sky_color:Z.properties.get("sky-color"),u_horizon_color:Z.properties.get("horizon-color"),u_horizon:(X.height/2+X.getHorizon())*F,u_sky_horizon_blend:Z.properties.get("sky-horizon-blend")*X.height/2*F}))(b,y.style.map.transform,y.pixelRatio),D=new it(S.LEQUAL,it.ReadWrite,[0,1]),B=vt.disabled,N=y.colorModeForRenderPass(),q=y.useProgram("sky");if(!b.mesh){const Z=new p.aX;Z.emplaceBack(-1,-1),Z.emplaceBack(1,-1),Z.emplaceBack(1,1),Z.emplaceBack(-1,1);const X=new p.aY;X.emplaceBack(0,1,2),X.emplaceBack(0,2,3),b.mesh=new sa(T.createVertexBuffer(Z,fn.members),T.createIndexBuffer(X),p.a0.simpleSegment(0,0,Z.length,X.length))}q.draw(T,S.TRIANGLES,D,B,N,gt.disabled,k,void 0,"sky",b.mesh.vertexBuffer,b.mesh.indexBuffer,b.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const y=this.style._layers[a[this.currentLayer]],b=o[y.source],T=c[y.source];this._renderTileClippingMasks(y,T),this.renderLayer(this,b,y,T)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayerq.source&&!q.isHidden(T)?[b.sourceCaches[q.source]]:[]),D=k.filter(q=>q.getSource().type==="vector"),B=k.filter(q=>q.getSource().type!=="vector"),N=q=>{(!S||S.getSource().maxzoomN(q)),S||B.forEach(q=>N(q)),S}(this.style,this.transform.zoom);y&&function(b,T,S){for(let k=0;k0),o&&(p.b0(n,a),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(c,m){const _=c.context,y=_.gl,b=Rt.unblended,T=new it(y.LEQUAL,it.ReadWrite,[0,1]),S=m.getTerrainMesh(),k=m.sourceCache.getRenderableTiles(),D=c.useProgram("terrainDepth");_.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:p.aM.transparent,depth:1});for(const B of k){const N=m.getTerrainData(B.tileID),q={u_matrix:c.transform.calculatePosMatrix(B.tileID.toUnwrapped()),u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};D.draw(_,y.TRIANGLES,T,vt.disabled,b,gt.backCCW,q,N,"terrain",S.vertexBuffer,S.indexBuffer,S.segments)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])}(this,this.style.map.terrain),function(c,m){const _=c.context,y=_.gl,b=Rt.unblended,T=new it(y.LEQUAL,it.ReadWrite,[0,1]),S=m.getTerrainMesh(),k=m.getCoordsTexture(),D=m.sourceCache.getRenderableTiles(),B=c.useProgram("terrainCoords");_.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:p.aM.transparent,depth:1}),m.coordsIndex=[];for(const N of D){const q=m.getTerrainData(N.tileID);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,k.texture);const Z={u_matrix:c.transform.calculatePosMatrix(N.tileID.toUnwrapped()),u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};B.draw(_,y.TRIANGLES,T,vt.disabled,b,gt.backCCW,Z,q,"terrain",S.vertexBuffer,S.indexBuffer,S.segments),m.coordsIndex.push(N.tileID.key)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])}(this,this.style.map.terrain))}renderLayer(e,n,a,o){if(!a.isHidden(this.transform.zoom)&&(a.type==="background"||a.type==="custom"||(o||[]).length))switch(this.id=a.id,a.type){case"symbol":(function(c,m,_,y,b){if(c.renderPass!=="translucent")return;const T=vt.disabled,S=c.colorModeForRenderPass();(_._unevaluatedLayout.hasValue("text-variable-anchor")||_._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(k,D,B,N,q,Z,X,F,Y){const ee=D.transform,ae=pn(),fe=q==="map",_e=Z==="map";for(const Pe of k){const ke=N.getTile(Pe),we=ke.getBucket(B);if(!we||!we.text||!we.text.segments.get().length)continue;const be=p.ag(we.textSizeData,ee.zoom),Re=rt(ke,1,D.transform.zoom),Xe=Yr(Pe.posMatrix,_e,fe,D.transform,Re),Se=B.layout.get("icon-text-fit")!=="none"&&we.hasIconData();if(be){const Ce=Math.pow(2,ee.zoom-ke.tileID.overscaledZ),qe=D.style.map.terrain?(Ye,nt)=>D.style.map.terrain.getElevation(Pe,Ye,nt):null,Tt=ae.translatePosition(ee,ke,X,F);On(we,fe,_e,Y,ee,Xe,Pe.posMatrix,Ce,be,Se,ae,Tt,Pe.toUnwrapped(),qe)}}}(y,c,_,m,_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),b),_.paint.get("icon-opacity").constantOr(1)!==0&&no(c,m,_,y,!1,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),_.layout.get("icon-rotation-alignment"),_.layout.get("icon-pitch-alignment"),_.layout.get("icon-keep-upright"),T,S),_.paint.get("text-opacity").constantOr(1)!==0&&no(c,m,_,y,!0,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.layout.get("text-keep-upright"),T,S),m.map.showCollisionBoxes&&(ws(c,m,_,y,!0),ws(c,m,_,y,!1))})(e,n,a,o,this.style.placement.variableOffsets);break;case"circle":(function(c,m,_,y){if(c.renderPass!=="translucent")return;const b=_.paint.get("circle-opacity"),T=_.paint.get("circle-stroke-width"),S=_.paint.get("circle-stroke-opacity"),k=!_.layout.get("circle-sort-key").isConstant();if(b.constantOr(1)===0&&(T.constantOr(1)===0||S.constantOr(1)===0))return;const D=c.context,B=D.gl,N=c.depthModeForSublayer(0,it.ReadOnly),q=vt.disabled,Z=c.colorModeForRenderPass(),X=[];for(let F=0;FF.sortKey-Y.sortKey);for(const F of X){const{programConfiguration:Y,program:ee,layoutVertexBuffer:ae,indexBuffer:fe,uniformValues:_e,terrainData:Pe}=F.state;ee.draw(D,B.TRIANGLES,N,q,Z,gt.disabled,_e,Pe,_.id,ae,fe,F.segments,_.paint,c.transform.zoom,Y)}})(e,n,a,o);break;case"heatmap":(function(c,m,_,y){if(_.paint.get("heatmap-opacity")===0)return;const b=c.context;if(c.style.map.terrain){for(const T of y){const S=m.getTile(T);m.hasRenderableParent(T)||(c.renderPass==="offscreen"?ao(c,S,_,T):c.renderPass==="translucent"&&bn(c,_,T))}b.viewport.set([0,0,c.width,c.height])}else c.renderPass==="offscreen"?function(T,S,k,D){const B=T.context,N=B.gl,q=vt.disabled,Z=new Rt([N.ONE,N.ONE],p.aM.transparent,[!0,!0,!0,!0]);(function(X,F,Y){const ee=X.gl;X.activeTexture.set(ee.TEXTURE1),X.viewport.set([0,0,F.width/4,F.height/4]);let ae=Y.heatmapFbos.get(p.aU);ae?(ee.bindTexture(ee.TEXTURE_2D,ae.colorAttachment.get()),X.bindFramebuffer.set(ae.framebuffer)):(ae=Ss(X,F.width/4,F.height/4),Y.heatmapFbos.set(p.aU,ae))})(B,T,k),B.clear({color:p.aM.transparent});for(let X=0;X20&&T.texParameterf(T.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);const we=c.style.map.terrain&&c.style.map.terrain.getTerrainData(X),be=we?X:null,Re=be?be.posMatrix:c.transform.calculatePosMatrix(X.toUnwrapped(),Z),Xe=lc(Re,Pe||[0,0],_e||1,fe,_);S instanceof Nr?k.draw(b,T.TRIANGLES,F,vt.disabled,D,gt.disabled,Xe,we,_.id,S.boundsBuffer,c.quadTriangleIndexBuffer,S.boundsSegments):k.draw(b,T.TRIANGLES,F,B[X.overscaledZ],D,gt.disabled,Xe,we,_.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments)}})(e,n,a,o);break;case"background":(function(c,m,_,y){const b=_.paint.get("background-color"),T=_.paint.get("background-opacity");if(T===0)return;const S=c.context,k=S.gl,D=c.transform,B=D.tileSize,N=_.paint.get("background-pattern");if(c.isPatternMissing(N))return;const q=!N&&b.a===1&&T===1&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==q)return;const Z=vt.disabled,X=c.depthModeForSublayer(0,q==="opaque"?it.ReadWrite:it.ReadOnly),F=c.colorModeForRenderPass(),Y=c.useProgram(N?"backgroundPattern":"background"),ee=y||D.coveringTiles({tileSize:B,terrain:c.style.map.terrain});N&&(S.activeTexture.set(k.TEXTURE0),c.imageManager.bind(c.context));const ae=_.getCrossfadeParameters();for(const fe of ee){const _e=y?fe.posMatrix:c.transform.calculatePosMatrix(fe.toUnwrapped()),Pe=N?Ha(_e,T,c,N,{tileID:fe,tileSize:B},ae):Ks(_e,T,b),ke=c.style.map.terrain&&c.style.map.terrain.getTerrainData(fe);Y.draw(S,k.TRIANGLES,X,Z,F,gt.disabled,Pe,ke,_.id,c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}})(e,0,a,o);break;case"custom":(function(c,m,_){const y=c.context,b=_.implementation;if(c.renderPass==="offscreen"){const T=b.prerender;T&&(c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),T.call(b,y.gl,c.transform.customLayerMatrix()),y.setDirty(),c.setBaseState())}else if(c.renderPass==="translucent"){c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),y.setStencilMode(vt.disabled);const T=b.renderingMode==="3d"?new it(c.context.gl.LEQUAL,it.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,it.ReadOnly);y.setDepthMode(T),b.render(y.gl,c.transform.customLayerMatrix(),{farZ:c.transform.farZ,nearZ:c.transform.nearZ,fov:c.transform._fov,modelViewProjectionMatrix:c.transform.modelViewProjectionMatrix,projectionMatrix:c.transform.projectionMatrix}),y.setDirty(),c.setBaseState(),y.bindFramebuffer.set(null)}})(e,0,a)}}translatePosMatrix(e,n,a,o,c){if(!a[0]&&!a[1])return e;const m=c?o==="map"?this.transform.angle:0:o==="viewport"?-this.transform.angle:0;if(m){const b=Math.sin(m),T=Math.cos(m);a=[a[0]*T-a[1]*b,a[0]*b+a[1]*T]}const _=[c?a[0]:rt(n,a[0],this.transform.zoom),c?a[1]:rt(n,a[1],this.transform.zoom),0],y=new Float32Array(16);return p.J(y,e,_),y}saveTileTexture(e){const n=this._tileTextures[e.size[0]];n?n.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const n=this._tileTextures[e];return n&&n.length>0?n.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const n=this.imageManager.getPattern(e.from.toString()),a=this.imageManager.getPattern(e.to.toString());return!n||!a}useProgram(e,n){this.cache=this.cache||{};const a=e+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[a]||(this.cache[a]=new Za(this.context,Qr[e],n,Xa[e],this._showOverdrawInspector,this.style.map.terrain)),this.cache[a]}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(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new et(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:n}=this.context.gl;return this.width!==e||this.height!==n}}class $n{constructor(e,n){this.points=e,this.planes=n}static fromInvProjectionMatrix(e,n,a){const o=Math.pow(2,a),c=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(_=>{const y=1/(_=p.af([],_,e))[3]/n*o;return p.b1(_,_,[y,y,1/_[3],y])}),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(_=>{const y=function(k,D){var B=D[0],N=D[1],q=D[2],Z=B*B+N*N+q*q;return Z>0&&(Z=1/Math.sqrt(Z)),k[0]=D[0]*Z,k[1]=D[1]*Z,k[2]=D[2]*Z,k}([],function(k,D,B){var N=D[0],q=D[1],Z=D[2],X=B[0],F=B[1],Y=B[2];return k[0]=q*Y-Z*F,k[1]=Z*X-N*Y,k[2]=N*F-q*X,k}([],gi([],c[_[0]],c[_[1]]),gi([],c[_[2]],c[_[1]]))),b=-((T=y)[0]*(S=c[_[1]])[0]+T[1]*S[1]+T[2]*S[2]);var T,S;return y.concat(b)});return new $n(c,m)}}class qn{constructor(e,n){this.min=e,this.max=n,this.center=function(a,o,c){return a[0]=.5*o[0],a[1]=.5*o[1],a[2]=.5*o[2],a}([],function(a,o,c){return a[0]=o[0]+c[0],a[1]=o[1]+c[1],a[2]=o[2]+c[2],a}([],this.min,this.max))}quadrant(e){const n=[e%2==0,e<2],a=mi(this.min),o=mi(this.max);for(let c=0;c=0&&m++;if(m===0)return 0;m!==n.length&&(a=!1)}if(a)return 2;for(let o=0;o<3;o++){let c=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let _=0;_this.max[o]-this.min[o])return 0}return 1}}class Zn{constructor(e=0,n=0,a=0,o=0){if(isNaN(e)||e<0||isNaN(n)||n<0||isNaN(a)||a<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=n,this.left=a,this.right=o}interpolate(e,n,a){return n.top!=null&&e.top!=null&&(this.top=p.y.number(e.top,n.top,a)),n.bottom!=null&&e.bottom!=null&&(this.bottom=p.y.number(e.bottom,n.bottom,a)),n.left!=null&&e.left!=null&&(this.left=p.y.number(e.left,n.left,a)),n.right!=null&&e.right!=null&&(this.right=p.y.number(e.right,n.right,a)),this}getCenter(e,n){const a=p.ac((this.left+e-this.right)/2,0,e),o=p.ac((this.top+n-this.bottom)/2,0,n);return new p.P(a,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Zn(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const lo=85.051129;class Gn{constructor(e,n,a,o,c){this.tileSize=512,this._renderWorldCopies=c===void 0||!!c,this._minZoom=e||0,this._maxZoom=n||22,this._minPitch=a??0,this._maxPitch=o??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new p.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Zn,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const e=new Gn(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return e.apply(this),e}apply(e){this.tileSize=e.tileSize,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.angle=e.angle,this._fov=e._fov,this._pitch=e._pitch,this._unmodified=e._unmodified,this._edgeInsets=e._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new p.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(e){const n=-p.b3(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=function(){var a=new p.A(4);return p.A!=Float32Array&&(a[1]=0,a[2]=0),a[0]=1,a[3]=1,a}(),function(a,o,c){var m=o[0],_=o[1],y=o[2],b=o[3],T=Math.sin(c),S=Math.cos(c);a[0]=m*S+y*T,a[1]=_*S+b*T,a[2]=m*-T+y*S,a[3]=_*-T+b*S}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const n=p.ac(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(e){const n=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(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)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,n,a){this._unmodified=!1,this._edgeInsets.interpolate(e,n,a),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const n=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(e){const n=[new p.b4(0,e)];if(this._renderWorldCopies){const a=this.pointCoordinate(new p.P(0,0)),o=this.pointCoordinate(new p.P(this.width,0)),c=this.pointCoordinate(new p.P(this.width,this.height)),m=this.pointCoordinate(new p.P(0,this.height)),_=Math.floor(Math.min(a.x,o.x,c.x,m.x)),y=Math.floor(Math.max(a.x,o.x,c.x,m.x)),b=1;for(let T=_-b;T<=y+b;T++)T!==0&&n.push(new p.b4(T,e))}return n}coveringTiles(e){var n,a;let o=this.coveringZoomLevel(e);const c=o;if(e.minzoom!==void 0&&oe.maxzoom&&(o=e.maxzoom);const m=this.pointCoordinate(this.getCameraPoint()),_=p.Z.fromLngLat(this.center),y=Math.pow(2,o),b=[y*m.x,y*m.y,0],T=[y*_.x,y*_.y,0],S=$n.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,o);let k=e.minzoom||0;!e.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(k=o);const D=e.terrain?2/Math.min(this.tileSize,e.tileSize)*this.tileSize:3,B=F=>({aabb:new qn([F*y,0,0],[(F+1)*y,y,0]),zoom:0,x:0,y:0,wrap:F,fullyVisible:!1}),N=[],q=[],Z=o,X=e.reparseOverscaled?c:o;if(this._renderWorldCopies)for(let F=1;F<=3;F++)N.push(B(-F)),N.push(B(F));for(N.push(B(0));N.length>0;){const F=N.pop(),Y=F.x,ee=F.y;let ae=F.fullyVisible;if(!ae){const we=F.aabb.intersects(S);if(we===0)continue;ae=we===2}const fe=e.terrain?b:T,_e=F.aabb.distanceX(fe),Pe=F.aabb.distanceY(fe),ke=Math.max(Math.abs(_e),Math.abs(Pe));if(F.zoom===Z||ke>D+(1<=k){const we=Z-F.zoom,be=b[0]-.5-(Y<>1),Xe=F.zoom+1;let Se=F.aabb.quadrant(we);if(e.terrain){const Ce=new p.S(Xe,F.wrap,Xe,be,Re),qe=e.terrain.getMinMaxElevation(Ce),Tt=(n=qe.minElevation)!==null&&n!==void 0?n:this.elevation,Ye=(a=qe.maxElevation)!==null&&a!==void 0?a:this.elevation;Se=new qn([Se.min[0],Se.min[1],Tt],[Se.max[0],Se.max[1],Ye])}N.push({aabb:Se,zoom:Xe,x:be,y:Re,wrap:F.wrap,fullyVisible:ae})}}return q.sort((F,Y)=>F.distanceSq-Y.distanceSq).map(F=>F.tileID)}resize(e,n){this.width=e,this.height=n,this.pixelsToGLUnits=[2/e,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){const n=p.ac(e.lat,-85.051129,lo);return new p.P(p.O(e.lng)*this.worldSize,p.Q(n)*this.worldSize)}unproject(e){return new p.Z(e.x/this.worldSize,e.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(e){const n=this.elevation,a=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,o=this.pointLocation(this.centerPoint,e),c=e.getElevationForLngLatZoom(o,this.tileZoom);if(!(this.elevation-c))return;const m=a+n-c,_=Math.cos(this._pitch)*this.cameraToCenterDistance/m/p.b5(1,o.lat),y=this.scaleZoom(_/this.tileSize);this._elevation=c,this._center=o,this.zoom=y}setLocationAtPoint(e,n){const a=this.pointCoordinate(n),o=this.pointCoordinate(this.centerPoint),c=this.locationCoordinate(e),m=new p.Z(c.x-(a.x-o.x),c.y-(a.y-o.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(e,n){return n?this.coordinatePoint(this.locationCoordinate(e),n.getElevationForLngLatZoom(e,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(e))}pointLocation(e,n){return this.coordinateLocation(this.pointCoordinate(e,n))}locationCoordinate(e){return p.Z.fromLngLat(e)}coordinateLocation(e){return e&&e.toLngLat()}pointCoordinate(e,n){if(n){const k=n.pointCoordinate(e);if(k!=null)return k}const a=[e.x,e.y,0,1],o=[e.x,e.y,1,1];p.af(a,a,this.pixelMatrixInverse),p.af(o,o,this.pixelMatrixInverse);const c=a[3],m=o[3],_=a[1]/c,y=o[1]/m,b=a[2]/c,T=o[2]/m,S=b===T?0:(0-b)/(T-b);return new p.Z(p.y.number(a[0]/c,o[0]/m,S)/this.worldSize,p.y.number(_,y,S)/this.worldSize)}coordinatePoint(e,n=0,a=this.pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,n,1];return p.af(o,o,a),new p.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this.height/2-this.getHorizon());return new le().extend(this.pointLocation(new p.P(0,e))).extend(this.pointLocation(new p.P(this.width,e))).extend(this.pointLocation(new p.P(this.width,this.height))).extend(this.pointLocation(new p.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new le([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(e){e?(this.lngRange=[e.getWest(),e.getEast()],this.latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,lo])}calculateTileMatrix(e){const n=e.canonical,a=this.worldSize/this.zoomScale(n.z),o=n.x+Math.pow(2,n.z)*e.wrap,c=p.an(new Float64Array(16));return p.J(c,c,[o*a,n.y*a,0]),p.K(c,c,[a/p.X,a/p.X,1]),c}calculatePosMatrix(e,n=!1){const a=e.key,o=n?this._alignedPosMatrixCache:this._posMatrixCache;if(o[a])return o[a];const c=this.calculateTileMatrix(e);return p.L(c,n?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,c),o[a]=new Float32Array(c),o[a]}calculateFogMatrix(e){const n=e.key,a=this._fogMatrixCache;if(a[n])return a[n];const o=this.calculateTileMatrix(e);return p.L(o,this.fogMatrix,o),a[n]=new Float32Array(o),a[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(e,n){n=p.ac(+n,this.minZoom,this.maxZoom);const a={center:new p.N(e.lng,e.lat),zoom:n};let o=this.lngRange;if(!this._renderWorldCopies&&o===null){const F=179.9999999999;o=[-F,F]}const c=this.tileSize*this.zoomScale(a.zoom);let m=0,_=c,y=0,b=c,T=0,S=0;const{x:k,y:D}=this.size;if(this.latRange){const F=this.latRange;m=p.Q(F[1])*c,_=p.Q(F[0])*c,_-m_&&(Z=_-F)}if(o){const F=(y+b)/2;let Y=B;this._renderWorldCopies&&(Y=p.b3(B,F-c/2,F+c/2));const ee=k/2;Y-eeb&&(q=b-ee)}if(q!==void 0||Z!==void 0){const F=new p.P(q??B,Z??N);a.center=this.unproject.call({worldSize:c},F).wrap()}return a}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:n,zoom:a}=this.getConstrained(this.center,this.zoom);this.center=n,this.zoom=a,this._unmodified=e,this._constraining=!1}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,n=this.point.x,a=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=p.b5(1,this.center.lat)*this.worldSize;let o=p.an(new Float64Array(16));p.K(o,o,[this.width/2,-this.height/2,1]),p.J(o,o,[1,-1,0]),this.labelPlaneMatrix=o,o=p.an(new Float64Array(16)),p.K(o,o,[1,-1,1]),p.J(o,o,[-1,-1,0]),p.K(o,o,[2/this.width,2/this.height,1]),this.glCoordMatrix=o;const c=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),m=Math.min(this.elevation,this.minElevationForCurrentTile),_=c-m*this._pixelPerMeter/Math.cos(this._pitch),y=m<0?_:c,b=Math.PI/2+this._pitch,T=this._fov*(.5+e.y/this.height),S=Math.sin(T)*y/Math.sin(p.ac(Math.PI-b-T,.01,Math.PI-.01)),k=this.getHorizon(),D=2*Math.atan(k/this.cameraToCenterDistance)*(.5+e.y/(2*k)),B=Math.sin(D)*y/Math.sin(p.ac(Math.PI-b-D,.01,Math.PI-.01)),N=Math.min(S,B);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*N+y),this.nearZ=this.height/50,o=new Float64Array(16),p.b6(o,this._fov,this.width/this.height,this.nearZ,this.farZ),o[8]=2*-e.x/this.width,o[9]=2*e.y/this.height,this.projectionMatrix=p.ae(o),p.K(o,o,[1,-1,1]),p.J(o,o,[0,0,-this.cameraToCenterDistance]),p.b7(o,o,this._pitch),p.ad(o,o,this.angle),p.J(o,o,[-n,-a,0]),this.mercatorMatrix=p.K([],o,[this.worldSize,this.worldSize,this.worldSize]),p.K(o,o,[1,1,this._pixelPerMeter]),this.pixelMatrix=p.L(new Float64Array(16),this.labelPlaneMatrix,o),p.J(o,o,[0,0,-this.elevation]),this.modelViewProjectionMatrix=o,this.invModelViewProjectionMatrix=p.as([],o),this.fogMatrix=new Float64Array(16),p.b6(this.fogMatrix,this._fov,this.width/this.height,c,this.farZ),this.fogMatrix[8]=2*-e.x/this.width,this.fogMatrix[9]=2*e.y/this.height,p.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),p.b7(this.fogMatrix,this.fogMatrix,this._pitch),p.ad(this.fogMatrix,this.fogMatrix,this.angle),p.J(this.fogMatrix,this.fogMatrix,[-n,-a,0]),p.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=p.L(new Float64Array(16),this.labelPlaneMatrix,o);const q=this.width%2/2,Z=this.height%2/2,X=Math.cos(this.angle),F=Math.sin(this.angle),Y=n-Math.round(n)+X*q+F*Z,ee=a-Math.round(a)+X*Z+F*q,ae=new Float64Array(o);if(p.J(ae,ae,[Y>.5?Y-1:Y,ee>.5?ee-1:ee,0]),this.alignedModelViewProjectionMatrix=ae,o=p.as(new Float64Array(16),this.pixelMatrix),!o)throw new Error("failed to invert matrix");this.pixelMatrixInverse=o,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const e=this.pointCoordinate(new p.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return p.af(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new p.P(0,e))}getCameraQueryGeometry(e){const n=this.getCameraPoint();if(e.length===1)return[e[0],n];{let a=n.x,o=n.y,c=n.x,m=n.y;for(const _ of e)a=Math.min(a,_.x),o=Math.min(o,_.y),c=Math.max(c,_.x),m=Math.max(m,_.y);return[new p.P(a,o),new p.P(c,o),new p.P(c,m),new p.P(a,m),new p.P(a,o)]}}lngLatToCameraDepth(e,n){const a=this.locationCoordinate(e),o=[a.x*this.worldSize,a.y*this.worldSize,n,1];return p.af(o,o,this.modelViewProjectionMatrix),o[2]/o[3]}}function As(h,e){let n,a=!1,o=null,c=null;const m=()=>{o=null,a&&(h.apply(c,n),o=setTimeout(m,e),a=!1)};return(..._)=>(a=!0,c=this,n=_,o||m(),o)}class oa{constructor(e){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map(o=>o.split("=")).forEach(o=>{o[0]===this._hashName&&(a=o)}),(a&&a[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(n.length>=3&&!n.some(a=>isNaN(a))){const a=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:a,pitch:+(n[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const a=n.join("/");let o=a;o.split("&").length>0&&(o=o.split("&")[0]),this._hashName&&(o=`${this._hashName}=${a}`);let c=window.location.hash.replace(o,"");c.startsWith("#&")?c=c.slice(0,1)+c.slice(2):c==="#"&&(c="");let m=window.location.href.replace(/(#.+)?$/,c);m=m.replace("&&","&"),window.history.replaceState(window.history.state,null,m)},this._updateHash=As(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 n=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,o=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,o),m=Math.round(n.lng*c)/c,_=Math.round(n.lat*c)/c,y=this._map.getBearing(),b=this._map.getPitch();let T="";if(T+=e?`/${m}/${_}/${a}`:`${a}/${_}/${m}`,(y||b)&&(T+="/"+Math.round(10*y)/10),b&&(T+=`/${Math.round(b)}`),this._hashName){const S=this._hashName;let k=!1;const D=window.location.hash.slice(1).split("&").map(B=>{const N=B.split("=")[0];return N===S?(k=!0,`${N}=${T}`):B}).filter(B=>B);return k||D.push(`${S}=${T}`),`#${D.join("&")}`}return`#${T}`}}const la={linearity:.3,easing:p.b8(0,0,.3,1)},co=p.e({deceleration:2500,maxSpeed:1400},la),bc=p.e({deceleration:20,maxSpeed:1400},la),bl=p.e({deceleration:1e3,maxSpeed:360},la),ca=p.e({deceleration:1e3,maxSpeed:90},la);class ho{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:de.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,n=de.now();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new p.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:c}of this._inertiaBuffer)n.zoom+=c.zoomDelta||0,n.bearing+=c.bearingDelta||0,n.pitch+=c.pitchDelta||0,c.panDelta&&n.pan._add(c.panDelta),c.around&&(n.around=c.around),c.pinchAround&&(n.pinchAround=c.pinchAround);const a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(n.pan.mag()){const c=Ms(n.pan.mag(),a,p.e({},co,e||{}));o.offset=n.pan.mult(c.amount/n.pan.mag()),o.center=this._map.transform.center,Cs(o,c)}if(n.zoom){const c=Ms(n.zoom,a,bc);o.zoom=this._map.transform.zoom+c.amount,Cs(o,c)}if(n.bearing){const c=Ms(n.bearing,a,bl);o.bearing=this._map.transform.bearing+p.ac(c.amount,-179,179),Cs(o,c)}if(n.pitch){const c=Ms(n.pitch,a,ca);o.pitch=this._map.transform.pitch+c.amount,Cs(o,c)}if(o.zoom||o.bearing){const c=n.pinchAround===void 0?n.around:n.pinchAround;o.around=c?this._map.unproject(c):this._map.getCenter()}return this.clear(),p.e(o,{noMoveStart:!0})}}function Cs(h,e){(!h.duration||h.durationn.unproject(y)),_=c.reduce((y,b,T,S)=>y.add(b.div(S.length)),new p.P(0,0));super(e,{points:c,point:_,lngLats:m,lngLat:n.unproject(_),originalEvent:a}),this._defaultPrevented=!1}}class wl extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class Tl{constructor(e,n){this._map=e,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new wl(e.type,this._map,e))}mousedown(e,n){return this._mousedownPos=n,this._firePreventable(new ai(e.type,this._map,e))}mouseup(e){this._map.fire(new ai(e.type,this._map,e))}click(e,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new ai(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ai(e.type,this._map,e))}mouseover(e){this._map.fire(new ai(e.type,this._map,e))}mouseout(e){this._map.fire(new ai(e.type,this._map,e))}touchstart(e){return this._firePreventable(new wn(e.type,this._map,e))}touchmove(e){this._map.fire(new wn(e.type,this._map,e))}touchend(e){this._map.fire(new wn(e.type,this._map,e))}touchcancel(e){this._map.fire(new wn(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Bt{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ai(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ai("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ai(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pr{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.pointLocation(p.P.convert(e),this._map.terrain)}}class qi{constructor(e,n){this._map=e,this._tr=new pr(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,n){this.isEnabled()&&e.shiftKey&&e.button===0&&(se.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(e,n){if(!this._active)return;const a=n;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)c.fitScreenCoordinates(a,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(se.remove(this._box),this._box=null),se.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new p.k(e,{originalEvent:n}))}}function ks(h,e){if(h.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${e.length}`);const n={};for(let a=0;athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),a.length===this.numTouches&&(this.centroid=function(o){const c=new p.P(0,0);for(const m of o)c._add(m);return c.div(o.length)}(n),this.touches=ks(a,n)))}touchmove(e,n,a){if(this.aborted||!this.centroid)return;const o=ks(a,n);for(const c in this.touches){const m=o[c];(!m||m.dist(this.touches[c])>30)&&(this.aborted=!0)}}touchend(e,n,a){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){const o=!this.aborted&&this.centroid;if(this.reset(),o)return o}}}class ha{constructor(e){this.singleTap=new uo(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,n,a){this.singleTap.touchstart(e,n,a)}touchmove(e,n,a){this.singleTap.touchmove(e,n,a)}touchend(e,n,a){const o=this.singleTap.touchend(e,n,a);if(o){const c=e.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(o)<30;if(c&&m||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Hn{constructor(e){this._tr=new pr(e),this._zoomIn=new ha({numTouches:1,numTaps:2}),this._zoomOut=new ha({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,n,a){this._zoomIn.touchstart(e,n,a),this._zoomOut.touchstart(e,n,a)}touchmove(e,n,a){this._zoomIn.touchmove(e,n,a),this._zoomOut.touchmove(e,n,a)}touchend(e,n,a){const o=this._zoomIn.touchend(e,n,a),c=this._zoomOut.touchend(e,n,a),m=this._tr;return o?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(o)},{originalEvent:e})}):c?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(c)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class $r{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 n=this._moveFunction(...e);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(e,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,n){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const o=n.length?n[0]:n;return!this._moved&&o.dist(a){h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=e=>{e.preventDefault()}},mo=({enable:h,clickTolerance:e,bearingDegreesPerPixelMoved:n=.8})=>{const a=new ua({checkCorrectEvent:o=>se.mouseButton(o)===0&&o.ctrlKey||se.mouseButton(o)===2});return new $r({clickTolerance:e,move:(o,c)=>({bearingDelta:(c.x-o.x)*n}),moveStateManager:a,enable:h,assignEvents:da})},go=({enable:h,clickTolerance:e,pitchDegreesPerPixelMoved:n=-.5})=>{const a=new ua({checkCorrectEvent:o=>se.mouseButton(o)===0&&o.ctrlKey||se.mouseButton(o)===2});return new $r({clickTolerance:e,move:(o,c)=>({pitchDelta:(c.y-o.y)*n}),moveStateManager:a,enable:h,assignEvents:da})};class Tn{constructor(e,n){this._clickTolerance=e.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new p.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,n,a){return this._calculateTransform(e,n,a)}touchmove(e,n,a){if(this._active){if(!this._shouldBePrevented(a.length))return e.preventDefault(),this._calculateTransform(e,n,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,n,a){this._calculateTransform(e,n,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,a){a.length>0&&(this._active=!0);const o=ks(a,n),c=new p.P(0,0),m=new p.P(0,0);let _=0;for(const b in o){const T=o[b],S=this._touches[b];S&&(c._add(T),m._add(T.sub(S)),_++,o[b]=T)}if(this._touches=o,this._shouldBePrevented(_)||!m.mag())return;const y=m.div(_);return this._sum._add(y),this._sum.mag()Math.abs(h.x)}class Xn extends pa{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,n,a){super.touchstart(e,n,a),this._currentTouchCount=a.length}_start(e){this._lastPoints=e,fa(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,n,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const o=e[0].sub(this._lastPoints[0]),c=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(o,c,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(o.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(e,n,a){if(this._valid!==void 0)return this._valid;const o=e.mag()>=2,c=n.mag()>=2;if(!o&&!c)return;if(!o||!c)return this._firstMove===void 0&&(this._firstMove=a),a-this._firstMove<100&&void 0;const m=e.y>0==n.y>0;return fa(e)&&fa(n)&&m}}const Sl={panStep:100,bearingStep:15,pitchStep:10};class er{constructor(e){this._tr=new pr(e);const n=Sl;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,a=0,o=0,c=0,m=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),c=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),c=1);break;case 38:e.shiftKey?o=1:(e.preventDefault(),m=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(a=0,o=0),{cameraAnimation:_=>{const y=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:Er,zoom:n?Math.round(y.zoom)+n*(e.shiftKey?2:1):y.zoom,bearing:y.bearing+a*this._bearingStep,pitch:y.pitch+o*this._pitchStep,offset:[-c*this._panStep,-m*this._panStep],center:y.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 Er(h){return h*(2-h)}const bo=4.000244140625;class fr{constructor(e,n){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=e,this._tr=new pr(e),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}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 n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const a=de.now(),o=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,n!==0&&n%bo==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(o*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,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 n=se.mousePos(this._map.getCanvas(),e),a=this._tr;this._around=n.y>a.transform.height/2-a.transform.getHorizon()?p.N.convert(this._aroundCenter?a.center:a.unproject(n)):p.N.convert(a.center),this._aroundPoint=a.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const e=this._tr.transform;if(this._delta!==0){const y=this._type==="wheel"&&Math.abs(this._delta)>bo?this._wheelZoomRate:this._defaultZoomRate;let b=2/(1+Math.exp(-Math.abs(this._delta*y)));this._delta<0&&b!==0&&(b=1/b);const T=typeof this._targetZoom=="number"?e.zoomScale(this._targetZoom):e.scale;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(T*b))),this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom=="number"?this._targetZoom:e.zoom,a=this._startZoom,o=this._easing;let c,m=!1;const _=de.now()-this._lastWheelEventTime;if(this._type==="wheel"&&a&&o&&_){const y=Math.min(_/200,1),b=o(y);c=p.y.number(a,n,b),y<1?this._frameId||(this._frameId=!0):m=!0}else c=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:c-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=p.b9;if(this._prevEase){const a=this._prevEase,o=(de.now()-a.start)/a.duration,c=a.easing(o+.01)-a.easing(o),m=.27/Math.sqrt(c*c+1e-4)*.01,_=Math.sqrt(.0729-m*m);n=p.b8(m,_,.25,1)}return this._prevEase={start:de.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Sn{constructor(e,n){this._clickZoom=e,this._tapZoom=n}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 wc{constructor(e){this._tr=new pr(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Tc{constructor(){this._tap=new ha({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,n,a){if(!this._swipePoint)if(this._tapTime){const o=n[0],c=e.timeStamp-this._tapTime<500,m=this._tapPoint.dist(o)<30;c&&m?a.length>0&&(this._swipePoint=o,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(e,n,a)}touchmove(e,n,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const o=n[0],c=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(e,n,a)}touchend(e,n,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{const o=this._tap.touchend(e,n,a);o&&(this._tapTime=e.timeStamp,this._tapPoint=o)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Il{constructor(e,n,a){this._el=e,this._mousePan=n,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 Pl{constructor(e,n,a){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=n,this._mousePitch=a}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class wo{constructor(e,n,a,o){this._el=e,this._touchZoom=n,this._touchRotate=a,this._tapDragZoom=o,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 Wn{constructor(e,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=n,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=se.create("div","maplibregl-cooperative-gesture-screen",e);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),o=document.createElement("div");o.className="maplibregl-desktop-message",o.textContent=n,this._container.appendChild(o);const c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=a,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(se.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,n){this._enabled&&(this._map.fire(new p.k("cooperativegestureprevented",{gestureType:e,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const tr=h=>h.zoom||h.drag||h.pitch||h.rotate;class ze extends p.k{}function ma(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta}class To{constructor(e,n){this.handleWindowEvent=o=>{this.handleEvent(o,`${o.type}Window`)},this.handleEvent=(o,c)=>{if(o.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const m=o.type==="renderFrame"?void 0:o,_={needsRenderFrame:!1},y={},b={},T=o.touches,S=T?this._getMapTouches(T):void 0,k=S?se.touchPos(this._map.getCanvas(),S):se.mousePos(this._map.getCanvas(),o);for(const{handlerName:N,handler:q,allowed:Z}of this._handlers){if(!q.isEnabled())continue;let X;this._blockedByActive(b,Z,N)?q.reset():q[c||o.type]&&(X=q[c||o.type](o,k,S),this.mergeHandlerResult(_,y,X,N,m),X&&X.needsRenderFrame&&this._triggerRenderFrame()),(X||q.isActive())&&(b[N]=q)}const D={};for(const N in this._previousActiveHandlers)b[N]||(D[N]=m);this._previousActiveHandlers=b,(Object.keys(D).length||ma(_))&&(this._changes.push([_,y,D]),this._triggerRenderFrame()),(Object.keys(b).length||ma(_))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:B}=_;B&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],B(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ho(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const a=this._el;this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]];for(const[o,c,m]of this._listeners)se.addEventListener(o,c,o===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[e,n,a]of this._listeners)se.removeEventListener(e,n,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){const n=this._map,a=n.getCanvasContainer();this._add("mapEvent",new Tl(n,e));const o=n.boxZoom=new qi(n,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const c=n.cooperativeGestures=new Wn(n,e.cooperativeGestures);this._add("cooperativeGestures",c),e.cooperativeGestures&&c.enable();const m=new Hn(n),_=new wc(n);n.doubleClickZoom=new Sn(_,m),this._add("tapZoom",m),this._add("clickZoom",_),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();const y=new Tc;this._add("tapDragZoom",y);const b=n.touchPitch=new Xn(n);this._add("touchPitch",b),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);const T=mo(e),S=go(e);n.dragRotate=new Pl(e,T,S),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",S,["mouseRotate"]),e.interactive&&e.dragRotate&&n.dragRotate.enable();const k=(({enable:X,clickTolerance:F})=>{const Y=new ua({checkCorrectEvent:ee=>se.mouseButton(ee)===0&&!ee.ctrlKey});return new $r({clickTolerance:F,move:(ee,ae)=>({around:ae,panDelta:ae.sub(ee)}),activateOnStart:!0,moveStateManager:Y,enable:X,assignEvents:da})})(e),D=new Tn(e,n);n.dragPan=new Il(a,k,D),this._add("mousePan",k),this._add("touchPan",D,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);const B=new vo,N=new yo;n.touchZoomRotate=new wo(a,N,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",N,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);const q=n.scrollZoom=new fr(n,()=>this._triggerRenderFrame());this._add("scrollZoom",q,["mousePan"]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);const Z=n.keyboard=new er(n);this._add("keyboard",Z),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new Bt(n))}_add(e,n,a){this._handlers.push({handlerName:e,handler:n,allowed:a}),this._handlersById[e]=n}stop(e){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.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!!tr(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,n,a){for(const o in e)if(o!==a&&(!n||n.indexOf(o)<0))return!0;return!1}_getMapTouches(e){const n=[];for(const a of e)this._el.contains(a.target)&&n.push(a);return n}mergeHandlerResult(e,n,a,o,c){if(!a)return;p.e(e,a);const m={handlerName:o,originalEvent:a.originalEvent||c};a.zoomDelta!==void 0&&(n.zoom=m),a.panDelta!==void 0&&(n.drag=m),a.pitchDelta!==void 0&&(n.pitch=m),a.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){const e={},n={},a={};for(const[o,c,m]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new p.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.around!==void 0&&(e.around=o.around),o.pinchAround!==void 0&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),p.e(n,c),p.e(a,m);this._updateMapTransform(e,n,a),this._changes=[]}_updateMapTransform(e,n,a){const o=this._map,c=o._getTransformForUpdate(),m=o.terrain;if(!(ma(e)||m&&this._terrainMovement))return this._fireEvents(n,a,!0);let{panDelta:_,zoomDelta:y,bearingDelta:b,pitchDelta:T,around:S,pinchAround:k}=e;k!==void 0&&(S=k),o._stop(!0),S=S||o.transform.centerPoint;const D=c.pointLocation(_?S.sub(_):S);b&&(c.bearing+=b),T&&(c.pitch+=T),y&&(c.zoom+=y),m?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?c.center=c.pointLocation(c.centerPoint.sub(_)):c.setLocationAtPoint(D,S):(this._terrainMovement=!0,this._map._elevationFreeze=!0,c.setLocationAtPoint(D,S)):c.setLocationAtPoint(D,S),o._applyUpdatedTransform(c),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,a,!0)}_fireEvents(e,n,a){const o=tr(this._eventsInProgress),c=tr(e),m={};for(const S in e){const{originalEvent:k}=e[S];this._eventsInProgress[S]||(m[`${S}start`]=k),this._eventsInProgress[S]=e[S]}!o&&c&&this._fireEvent("movestart",c.originalEvent);for(const S in m)this._fireEvent(S,m[S]);c&&this._fireEvent("move",c.originalEvent);for(const S in e){const{originalEvent:k}=e[S];this._fireEvent(S,k)}const _={};let y;for(const S in this._eventsInProgress){const{handlerName:k,originalEvent:D}=this._eventsInProgress[S];this._handlersById[k].isActive()||(delete this._eventsInProgress[S],y=n[k]||D,_[`${S}end`]=y)}for(const S in _)this._fireEvent(S,_[S]);const b=tr(this._eventsInProgress),T=(o||c)&&!b;if(T&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const S=this._map._getTransformForUpdate();S.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(S)}if(a&&T){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),k=D=>D!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new ze("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Al extends p.E{constructor(e,n){super(),this._renderFrameCallback=()=>{const a=Math.min((de.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(a)),a<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new p.N(this.transform.center.lng,this.transform.center.lat)}setCenter(e,n){return this.jumpTo({center:e},n)}panBy(e,n,a){return e=p.P.convert(e).mult(-1),this.panTo(this.transform.center,p.e({offset:e},n),a)}panTo(e,n,a){return this.easeTo(p.e({center:e},n),a)}getZoom(){return this.transform.zoom}setZoom(e,n){return this.jumpTo({zoom:e},n),this}zoomTo(e,n,a){return this.easeTo(p.e({zoom:e},n),a)}zoomIn(e,n){return this.zoomTo(this.getZoom()+1,e,n),this}zoomOut(e,n){return this.zoomTo(this.getZoom()-1,e,n),this}getBearing(){return this.transform.bearing}setBearing(e,n){return this.jumpTo({bearing:e},n),this}getPadding(){return this.transform.padding}setPadding(e,n){return this.jumpTo({padding:e},n),this}rotateTo(e,n,a){return this.easeTo(p.e({bearing:e},n),a)}resetNorth(e,n){return this.rotateTo(0,p.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(p.e({bearing:0,pitch:0,duration:1e3},e),n),this}snapToNorth(e,n){return Math.abs(this.getBearing()){if(this._zooming&&(o.zoom=p.y.number(c,q,fe)),this._rotating&&(o.bearing=p.y.number(m,b,fe)),this._pitching&&(o.pitch=p.y.number(_,T,fe)),this._padding&&(o.interpolatePadding(y,S,fe),D=o.centerPoint.add(k)),this.terrain&&!e.freezeElevation&&this._updateElevation(fe),Y)o.setLocationAtPoint(Y,ee);else{const _e=o.zoomScale(o.zoom-c),Pe=q>c?Math.min(2,F):Math.max(.5,F),ke=Math.pow(Pe,1-fe),we=o.unproject(Z.add(X.mult(fe*ke)).mult(_e));o.setLocationAtPoint(o.renderWorldCopies?we.wrap():we,D)}this._applyUpdatedTransform(o),this._fireMoveEvents(n)},fe=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,fe)},e),this}_prepareEase(e,n,a={}){this._moving=!0,n||a.moving||this.fire(new p.k("movestart",e)),this._zooming&&!a.zooming&&this.fire(new p.k("zoomstart",e)),this._rotating&&!a.rotating&&this.fire(new p.k("rotatestart",e)),this._pitching&&!a.pitching&&this.fire(new p.k("pitchstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(a-(n-(a*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.elevation=p.y.number(this._elevationStart,this._elevationTarget,e)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){const n=e.getCameraPosition(),a=this.terrain.getElevationForLngLatZoom(n.lngLat,e.zoom);if(n.altitudethis._elevateCameraIfInsideTerrain(o)),this.transformCameraUpdate&&n.push(o=>this.transformCameraUpdate(o)),!n.length)return;const a=e.clone();for(const o of n){const c=a.clone(),{center:m,zoom:_,pitch:y,bearing:b,elevation:T}=o(c);m&&(c.center=m),_!==void 0&&(c.zoom=_),y!==void 0&&(c.pitch=y),b!==void 0&&(c.bearing=b),T!==void 0&&(c.elevation=T),a.apply(c)}this.transform.apply(a)}_fireMoveEvents(e){this.fire(new p.k("move",e)),this._zooming&&this.fire(new p.k("zoom",e)),this._rotating&&this.fire(new p.k("rotate",e)),this._pitching&&this.fire(new p.k("pitch",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const a=this._zooming,o=this._rotating,c=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,a&&this.fire(new p.k("zoomend",e)),o&&this.fire(new p.k("rotateend",e)),c&&this.fire(new p.k("pitchend",e)),this.fire(new p.k("moveend",e))}flyTo(e,n){var a;if(!e.essential&&de.prefersReducedMotion){const Ce=p.M(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Ce,n)}this.stop(),e=p.e({offset:[0,0],speed:1.2,curve:1.42,easing:p.b9},e);const o=this._getTransformForUpdate(),c=o.zoom,m=o.bearing,_=o.pitch,y=o.padding,b="bearing"in e?this._normalizeBearing(e.bearing,m):m,T="pitch"in e?+e.pitch:_,S="padding"in e?e.padding:o.padding,k=p.P.convert(e.offset);let D=o.centerPoint.add(k);const B=o.pointLocation(D),{center:N,zoom:q}=o.getConstrained(p.N.convert(e.center||B),(a=e.zoom)!==null&&a!==void 0?a:c);this._normalizeCenter(N,o);const Z=o.zoomScale(q-c),X=o.project(B),F=o.project(N).sub(X);let Y=e.curve;const ee=Math.max(o.width,o.height),ae=ee/Z,fe=F.mag();if("minZoom"in e){const Ce=p.ac(Math.min(e.minZoom,c,q),o.minZoom,o.maxZoom),qe=ee/o.zoomScale(Ce-c);Y=Math.sqrt(qe/fe*2)}const _e=Y*Y;function Pe(Ce){const qe=(ae*ae-ee*ee+(Ce?-1:1)*_e*_e*fe*fe)/(2*(Ce?ae:ee)*_e*fe);return Math.log(Math.sqrt(qe*qe+1)-qe)}function ke(Ce){return(Math.exp(Ce)-Math.exp(-Ce))/2}function we(Ce){return(Math.exp(Ce)+Math.exp(-Ce))/2}const be=Pe(!1);let Re=function(Ce){return we(be)/we(be+Y*Ce)},Xe=function(Ce){return ee*((we(be)*(ke(qe=be+Y*Ce)/we(qe))-ke(be))/_e)/fe;var qe},Se=(Pe(!0)-be)/Y;if(Math.abs(fe)<1e-6||!isFinite(Se)){if(Math.abs(ee-ae)<1e-6)return this.easeTo(e,n);const Ce=ae0,Re=qe=>Math.exp(Ce*Y*qe)}return e.duration="duration"in e?+e.duration:1e3*Se/("screenSpeed"in e?+e.screenSpeed/Y:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=m!==b,this._pitching=T!==_,this._padding=!o.isPaddingEqual(S),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(N),this._ease(Ce=>{const qe=Ce*Se,Tt=1/Re(qe);o.zoom=Ce===1?q:c+o.scaleZoom(Tt),this._rotating&&(o.bearing=p.y.number(m,b,Ce)),this._pitching&&(o.pitch=p.y.number(_,T,Ce)),this._padding&&(o.interpolatePadding(y,S,Ce),D=o.centerPoint.add(k)),this.terrain&&!e.freezeElevation&&this._updateElevation(Ce);const Ye=Ce===1?N:o.unproject(X.add(F.mult(Xe(qe))).mult(Tt));o.setLocationAtPoint(o.renderWorldCopies?Ye.wrap():Ye,D),this._applyUpdatedTransform(o),this._fireMoveEvents(n)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,n){var a;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const o=this._onEaseEnd;delete this._onEaseEnd,o.call(this,n)}return e||(a=this.handlers)===null||a===void 0||a.stop(!1),this}_ease(e,n,a){a.animate===!1||a.duration===0?(e(1),n()):(this._easeStart=de.now(),this._easeOptions=a,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=p.b3(e,-180,180);const a=Math.abs(e-n);return Math.abs(e-360-n)180?-360:a<-180?360:0}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(p.N.convert(e),this.transform.tileZoom)-this.transform.elevation:null}}const Kn={compact:!0,customAttribution:'MapLibre'};class Jn{constructor(e=Kn){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=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?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=se.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=se.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=se.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(){se.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,n){const a=this._map._getUIString(`AttributionControl.${n}`);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(o=>typeof o!="string"?"":o)):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const o=this._map.style.stylesheet;this.styleOwner=o.owner,this.styleId=o.id}const n=this._map.style.sourceCaches;for(const o in n){const c=n[o];if(c.used||c.usedForTerrain){const m=c.getSource();m.attribution&&e.indexOf(m.attribution)<0&&e.push(m.attribution)}}e=e.filter(o=>String(o).trim()),e.sort((o,c)=>o.length-c.length),e=e.filter((o,c)=>{for(let m=c+1;m=0)return!1;return!0});const a=e.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,e.length?(this._innerContainer.innerHTML=a,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class So{constructor(e={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const a=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&a.classList.add("maplibregl-compact"):a.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=se.create("div","maplibregl-ctrl");const n=se.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){se.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class st{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const n=++this._id;return this._queue.push({callback:e,id:n,cancelled:!1}),n}remove(e){const n=this._currentlyRunning,a=n?this._queue.concat(n):this._queue;for(const o of a)if(o.id===e)return void(o.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const a of n)if(!a.cancelled&&(a.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Io=p.Y([{name:"a_pos3d",type:"Int16",components:3}]);class Sc extends p.E{constructor(e){super(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,e.usedForTerrain=!0,e.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];const a={};for(const o of e.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))a[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.posMatrix=new Float64Array(16),p.aP(o.posMatrix,0,p.X,0,p.X,0,1),this._tiles[o.key]=new Jr(o,this.tileSize));for(const o in this._tiles)a[o]||delete this._tiles[o]}freeRtt(e){for(const n in this._tiles){const a=this._tiles[n];(!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){const n={};for(const a of this._renderableTilesKeys){const o=this._tiles[a].tileID;if(o.canonical.equals(e.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16),p.aP(c.posMatrix,0,p.X,0,p.X,0,1),n[a]=c}else if(o.canonical.isChildOf(e.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16);const m=o.canonical.z-e.canonical.z,_=o.canonical.x-(o.canonical.x>>m<>m<>m;p.aP(c.posMatrix,0,b,0,b,0,1),p.J(c.posMatrix,c.posMatrix,[-_*b,-y*b,0]),n[a]=c}else if(e.canonical.isChildOf(o.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16);const m=e.canonical.z-o.canonical.z,_=e.canonical.x-(e.canonical.x>>m<>m<>m;p.aP(c.posMatrix,0,p.X,0,p.X,0,1),p.J(c.posMatrix,c.posMatrix,[_*b,y*b,0]),p.K(c.posMatrix,c.posMatrix,[1/2**m,1/2**m,0]),n[a]=c}}return n}getSourceTile(e,n){const a=this.sourceCache._source;let o=e.overscaledZ-this.deltaZoom;if(o>a.maxzoom&&(o=a.maxzoom),o=a.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(e.scaledTo(o--).key);return c}tilesAfterTime(e=Date.now()){return Object.values(this._tiles).filter(n=>n.timeAdded>=e)}}class Po{constructor(e,n,a){this.painter=e,this.sourceCache=new Sc(n),this.options=a,this.exaggeration=typeof a.exaggeration=="number"?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,a,o=p.X){var c;if(!(n>=0&&n=0&&ae.canonical.z&&(e.canonical.z>=o?c=e.canonical.z-o:p.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=e.canonical.x-(e.canonical.x>>c<>c<>8<<4|c>>8,n[m+3]=0;const a=new p.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),o=new et(e,a,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),a=this.painter.context,o=a.gl,c=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),_=Math.round(this.painter.height/devicePixelRatio);a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(c,_-m-1,1,1,o.RGBA,o.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null);const y=n[0]+(n[2]>>4<<8),b=n[1]+((15&n[2])<<8),T=this.coordsIndex[255-n[3]],S=T&&this.sourceCache.getTileByID(T);if(!S)return null;const k=this._coordsTextureSize,D=(1<e.id!==n),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];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)===!1}}const Yn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Cl{constructor(e,n){this.painter=e,this.terrain=n,this.pool=new Ic(e.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter(a=>!e._layers[a].isHidden(n)),this._coordsDescendingInv={};for(const a in e.sourceCaches){this._coordsDescendingInv[a]={};const o=e.sourceCaches[a].getVisibleCoordinates();for(const c of o){const m=this.terrain.sourceCache.getTerrainCoords(c);for(const _ in m)this._coordsDescendingInv[a][_]||(this._coordsDescendingInv[a][_]=[]),this._coordsDescendingInv[a][_].push(m[_])}}this._coordsDescendingInvStr={};for(const a of e._order){const o=e._layers[a],c=o.source;if(Yn[o.type]&&!this._coordsDescendingInvStr[c]){this._coordsDescendingInvStr[c]={};for(const m in this._coordsDescendingInv[c])this._coordsDescendingInvStr[c][m]=this._coordsDescendingInv[c][m].map(_=>_.key).sort().join()}}for(const a of this._renderableTiles)for(const o in this._coordsDescendingInvStr){const c=this._coordsDescendingInvStr[o][a.tileID.key];c&&c!==a.rttCoords[o]&&(a.rtt=[])}}renderLayer(e){if(e.isHidden(this.painter.transform.zoom))return!1;const n=e.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Yn[n]&&(this._prevType&&Yn[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(e.id),!o))return!0;if(Yn[this._prevType]||Yn[n]&&o){this._prevType=n;const c=this._stacks.length-1,m=this._stacks[c]||[];for(const _ of this._renderableTiles){if(this.pool.isFull()&&(vl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(_),_.rtt[c]){const b=this.pool.getObjectForId(_.rtt[c].id);if(b.stamp===_.rtt[c].stamp){this.pool.useObject(b);continue}}const y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),_.rtt[c]={id:y.id,stamp:y.stamp},a.context.bindFramebuffer.set(y.fbo.framebuffer),a.context.clear({color:p.aM.transparent,stencil:0}),a.currentStencilSource=void 0;for(let b=0;b{h.touchstart=h.dragStart,h.touchmoveWindow=h.dragMove,h.touchend=h.dragEnd},Ac={showCompass:!0,showZoom:!0,visualizePitch:!1};class Cc{constructor(e,n,a=!1){this.mousedown=m=>{this.startMouse(p.e({},m,{ctrlKey:!0,preventDefault:()=>m.preventDefault()}),se.mousePos(this.element,m)),se.addEventListener(window,"mousemove",this.mousemove),se.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=m=>{this.moveMouse(m,se.mousePos(this.element,m))},this.mouseup=m=>{this.mouseRotate.dragEnd(m),this.mousePitch&&this.mousePitch.dragEnd(m),this.offTemp()},this.touchstart=m=>{m.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.startTouch(m,this._startPos),se.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.addEventListener(window,"touchend",this.touchend))},this.touchmove=m=>{m.targetTouches.length!==1?this.reset():(this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.moveTouch(m,this._lastPos))},this.touchend=m=>{m.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const o=e.dragRotate._mouseRotate.getClickTolerance(),c=e.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=mo({clickTolerance:o,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:_,bearingDegreesPerPixelMoved:y=.8})=>{const b=new fo;return new $r({clickTolerance:_,move:(T,S)=>({bearingDelta:(S.x-T.x)*y}),moveStateManager:b,enable:m,assignEvents:Co})})({clickTolerance:o,enable:!0}),this.map=e,a&&(this.mousePitch=go({clickTolerance:c,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:_,pitchDegreesPerPixelMoved:y=-.5})=>{const b=new fo;return new $r({clickTolerance:_,move:(T,S)=>({pitchDelta:(S.y-T.y)*y}),moveStateManager:b,enable:m,assignEvents:Co})})({clickTolerance:c,enable:!0})),se.addEventListener(n,"mousedown",this.mousedown),se.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),se.addEventListener(n,"touchcancel",this.reset)}startMouse(e,n){this.mouseRotate.dragStart(e,n),this.mousePitch&&this.mousePitch.dragStart(e,n),se.disableDrag()}startTouch(e,n){this.touchRotate.dragStart(e,n),this.touchPitch&&this.touchPitch.dragStart(e,n),se.disableDrag()}moveMouse(e,n){const a=this.map,{bearingDelta:o}=this.mouseRotate.dragMove(e,n)||{};if(o&&a.setBearing(a.getBearing()+o),this.mousePitch){const{pitchDelta:c}=this.mousePitch.dragMove(e,n)||{};c&&a.setPitch(a.getPitch()+c)}}moveTouch(e,n){const a=this.map,{bearingDelta:o}=this.touchRotate.dragMove(e,n)||{};if(o&&a.setBearing(a.getBearing()+o),this.touchPitch){const{pitchDelta:c}=this.touchPitch.dragMove(e,n)||{};c&&a.setPitch(a.getPitch()+c)}}off(){const e=this.element;se.removeEventListener(e,"mousedown",this.mousedown),se.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend),se.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){se.enableDrag(),se.removeEventListener(window,"mousemove",this.mousemove),se.removeEventListener(window,"mouseup",this.mouseup),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend)}}let Zi;function wt(h,e,n){const a=new p.N(h.lng,h.lat);if(h=new p.N(h.lng,h.lat),e){const o=new p.N(h.lng-360,h.lat),c=new p.N(h.lng+360,h.lat),m=n.locationPoint(h).distSqr(e);n.locationPoint(o).distSqr(e)180;){const o=n.locationPoint(h);if(o.x>=0&&o.y>=0&&o.x<=n.width&&o.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h.lng!==a.lng&&n.locationPoint(h).y>n.height/2-n.getHorizon()?h:a}const Qn={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 ga(h,e,n){const a=h.classList;for(const o in Qn)a.remove(`maplibregl-${n}-anchor-${o}`);a.add(`maplibregl-${n}-anchor-${e}`)}class _a extends p.E{constructor(e){if(super(),this._onKeyPress=n=>{const a=n.code,o=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&o!==32&&o!==13||this.togglePopup()},this._onMapClick=n=>{const a=n.originalEvent.target,o=this._element;this._popup&&(a===o||o.contains(a))&&this.togglePopup()},this._update=n=>{var a;if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?wt(this._lngLat,this._flatPos,this._map.transform):(a=this._lngLat)===null||a===void 0?void 0:a.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let m="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?m="rotateX(0deg)":this._pitchAlignment==="map"&&(m=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),se.setTransform(this._element,`${Qn[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${m} ${c}`),de.frameAsync(new AbortController).then(()=>{this._updateOpacity(n&&n.type==="moveend")}).catch(()=>{})},this._onMove=n=>{if(!this._isDragging){const a=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=a}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new p.k("dragstart"))),this.fire(new p.k("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),this._state==="active"&&this.fire(new p.k("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.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&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(e==null?void 0:e.opacity,e==null?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=p.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=se.create("div");const n=se.createNS("http://www.w3.org/2000/svg","svg"),a=41,o=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${a}px`),n.setAttributeNS(null,"width",`${o}px`),n.setAttributeNS(null,"viewBox",`0 0 ${o} ${a}`);const c=se.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"stroke","none"),c.setAttributeNS(null,"stroke-width","1"),c.setAttributeNS(null,"fill","none"),c.setAttributeNS(null,"fill-rule","evenodd");const m=se.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const _=se.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const y=[{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 Z of y){const X=se.createNS("http://www.w3.org/2000/svg","ellipse");X.setAttributeNS(null,"opacity","0.04"),X.setAttributeNS(null,"cx","10.5"),X.setAttributeNS(null,"cy","5.80029008"),X.setAttributeNS(null,"rx",Z.rx),X.setAttributeNS(null,"ry",Z.ry),_.appendChild(X)}const b=se.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=se.createNS("http://www.w3.org/2000/svg","path");T.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),b.appendChild(T);const S=se.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const k=se.createNS("http://www.w3.org/2000/svg","path");k.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),S.appendChild(k);const D=se.createNS("http://www.w3.org/2000/svg","g");D.setAttributeNS(null,"transform","translate(6.0, 7.0)"),D.setAttributeNS(null,"fill","#FFFFFF");const B=se.createNS("http://www.w3.org/2000/svg","g");B.setAttributeNS(null,"transform","translate(8.0, 8.0)");const N=se.createNS("http://www.w3.org/2000/svg","circle");N.setAttributeNS(null,"fill","#000000"),N.setAttributeNS(null,"opacity","0.25"),N.setAttributeNS(null,"cx","5.5"),N.setAttributeNS(null,"cy","5.5"),N.setAttributeNS(null,"r","5.4999962");const q=se.createNS("http://www.w3.org/2000/svg","circle");q.setAttributeNS(null,"fill","#FFFFFF"),q.setAttributeNS(null,"cx","5.5"),q.setAttributeNS(null,"cy","5.5"),q.setAttributeNS(null,"r","5.4999962"),B.appendChild(N),B.appendChild(q),m.appendChild(_),m.appendChild(b),m.appendChild(S),m.appendChild(D),m.appendChild(B),n.appendChild(m),n.setAttributeNS(null,"height",a*this._scale+"px"),n.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(n),this._offset=p.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",n=>{n.preventDefault()}),this._element.addEventListener("mousedown",n=>{n.preventDefault()}),ga(this._element,this._anchor,"marker"),e&&e.className)for(const n of e.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),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("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),se.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=p.N.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 o=Math.abs(13.5)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[o,-1*(38.1-13.5+o)],"bottom-right":[-o,-1*(38.1-13.5+o)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}: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 n,a;if(!(!((n=this._map)===null||n===void 0)&&n.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const o=this._map,c=o.terrain.depthAtPoint(this._pos),m=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,m)-c<.006)return void(this._element.style.opacity=this._opacity);const _=-this._offset.y/o.transform._pixelPerMeter,y=Math.sin(o.getPitch()*Math.PI/180)*_,b=o.terrain.depthAtPoint(new p.P(this._pos.x,this._pos.y-this._offset.y)),T=o.transform.lngLatToCameraDepth(this._lngLat,m+y)-b>.006;!((a=this._popup)===null||a===void 0)&&a.isOpen()&&T&&this._popup.remove(),this._element.style.opacity=T?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=p.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&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,n){return e===void 0&&n===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const kl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let zs=0,Ds=!1;const zr={maxWidth:100,unit:"metric"};function Ls(h,e,n){const a=n&&n.maxWidth||100,o=h._container.clientHeight/2,c=h.unproject([0,o]),m=h.unproject([a,o]),_=c.distanceTo(m);if(n&&n.unit==="imperial"){const y=3.2808*_;y>5280?Le(e,a,y/5280,h._getUIString("ScaleControl.Miles")):Le(e,a,y,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Le(e,a,_/1852,h._getUIString("ScaleControl.NauticalMiles")):_>=1e3?Le(e,a,_/1e3,h._getUIString("ScaleControl.Kilometers")):Le(e,a,_,h._getUIString("ScaleControl.Meters"))}function Le(h,e,n,a){const o=function(c){const m=Math.pow(10,`${Math.floor(c)}`.length-1);let _=c/m;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:function(y){const b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b}(_),m*_}(n);h.style.width=e*(o/n)+"px",h.innerHTML=`${o} ${a}`}const je={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},ya=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function xa(h){if(h){if(typeof h=="number"){const e=Math.round(Math.abs(h)/Math.SQRT2);return{center:new p.P(0,0),top:new p.P(0,h),"top-left":new p.P(e,e),"top-right":new p.P(-e,e),bottom:new p.P(0,-h),"bottom-left":new p.P(e,-e),"bottom-right":new p.P(-e,-e),left:new p.P(h,0),right:new p.P(-h,0)}}if(h instanceof p.P||Array.isArray(h)){const e=p.P.convert(h);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:p.P.convert(h.center||[0,0]),top:p.P.convert(h.top||[0,0]),"top-left":p.P.convert(h["top-left"]||[0,0]),"top-right":p.P.convert(h["top-right"]||[0,0]),bottom:p.P.convert(h.bottom||[0,0]),"bottom-left":p.P.convert(h["bottom-left"]||[0,0]),"bottom-right":p.P.convert(h["bottom-right"]||[0,0]),left:p.P.convert(h.left||[0,0]),right:p.P.convert(h.right||[0,0])}}return xa(new p.P(0,0))}const Mo=Je;M.AJAXError=p.bh,M.Evented=p.E,M.LngLat=p.N,M.MercatorCoordinate=p.Z,M.Point=p.P,M.addProtocol=p.bi,M.config=p.a,M.removeProtocol=p.bj,M.AttributionControl=Jn,M.BoxZoomHandler=qi,M.CanvasSource=Ji,M.CooperativeGesturesHandler=Wn,M.DoubleClickZoomHandler=Sn,M.DragPanHandler=Il,M.DragRotateHandler=Pl,M.EdgeInsets=Zn,M.FullscreenControl=class extends p.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var e;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=n==null?void 0:n.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:p.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(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){se.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const h=this._fullscreenButton=se.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);se.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_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 p.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new p.k("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()}},M.GeoJSONSource=fs,M.GeolocateControl=class extends p.E{constructor(h){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new p.k("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&&this._watchState!=="OFF"&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new p.k("geolocate",e)),this._finish()}},this._updateCamera=e=>{const n=new p.N(e.coords.longitude,e.coords.latitude),a=e.coords.accuracy,o=this._map.getBearing(),c=p.e({bearing:o},this.options.fitBoundsOptions),m=le.fromLngLat(n,a);this._map.fitBounds(m,c,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const n=new p.N(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(e.code===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._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&Ds)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new p.k("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=se.create("button","maplibregl-ctrl-geolocate",this._container),se.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(e===!1){p.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=se.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new _a({element:this._dotElement}),this._circleElement=se.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new _a({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new p.k("trackuserlocationend")),this.fire(new p.k("userlocationlostfocus")))})}},this.options=p.e({},kl,h)}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return p._(this,arguments,void 0,function*(e=!1){if(Zi!==void 0&&!e)return Zi;if(window.navigator.permissions===void 0)return Zi=!!window.navigator.geolocation,Zi;try{Zi=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Zi=!!window.navigator.geolocation}return Zi})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(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(),se.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,zs=0,Ds=!1}_isOutOfMapMaxBounds(h){const e=this._map.getMaxBounds(),n=h.coords;return e&&(n.longitudee.getEast()||n.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const h=this._map.getBounds(),e=h.getSouthEast(),n=h.getNorthEast(),a=e.distanceTo(n),o=Math.ceil(this._accuracy/(a/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}trigger(){if(!this._setup)return p.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 p.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":zs--,Ds=!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 p.k("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 p.k("trackuserlocationstart")),this.fire(new p.k("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(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let h;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),zs++,zs>1?(h={maximumAge:6e5,timeout:0},Ds=!0):(h=this.options.positionOptions,Ds=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,h)}}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)}},M.Hash=oa,M.ImageSource=Nr,M.KeyboardHandler=er,M.LngLatBounds=le,M.LogoControl=So,M.Map=class extends Al{constructor(h){p.bf.mark(p.bg.create);const e=Object.assign(Object.assign({},Pc),h);if(e.minZoom!=null&&e.maxZoom!=null&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(e.minPitch!=null&&e.maxPitch!=null&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(e.minPitch!=null&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(e.maxPitch!=null&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Gn(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),{bearingSnap:e.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new st,this._controls=[],this._mapId=p.a4(),this._contextLost=n=>{n.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new p.k("webglcontextlost",{originalEvent:n}))},this._contextRestored=n=>{this._setupPainter(),this.resize(),this._update(),this.fire(new p.k("webglcontextrestored",{originalEvent:n}))},this._onMapScroll=n=>{if(n.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._maxTileCacheZoomLevels=e.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=e.preserveDrawingBuffer===!0,this._antialias=e.antialias===!0,this._trackResize=e.trackResize===!0,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles===!0,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions===!0,this._collectResourceTiming=e.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Ao),e.locale),this._clickTolerance=e.clickTolerance,this._overridePixelRatio=e.pixelRatio,this._maxCanvasSize=e.maxCanvasSize,this.transformCameraUpdate=e.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=e.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Mt.addThrottleControl(()=>this.isMoving()),this._requestManager=new ln(e.transformRequest),typeof e.container=="string"){if(this._container=document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)).on("moveend",()=>this._update(!1)).on("zoom",()=>this._update(!0)).on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}).once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let n=!1;const a=As(o=>{this._trackResize&&!this._removed&&(this.resize(o),this.redraw())},50);this._resizeObserver=new ResizeObserver(o=>{n?a(o):n=!0}),this._resizeObserver.observe(this._container)}this.handlers=new To(this,e),this._hash=e.hash&&new oa(typeof e.hash=="string"&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,p.e({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,this._validateStyle=e.validateStyle,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new Jn(typeof e.attributionControl=="boolean"?void 0:e.attributionControl)),e.maplibreLogo&&this.addControl(new So,e.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",n=>{this._update(n.dataType==="style"),this.fire(new p.k(`${n.dataType}data`,n))}),this.on("dataloading",n=>{this.fire(new p.k(`${n.dataType}dataloading`,n))}),this.on("dataabort",n=>{this.fire(new p.k("sourcedataabort",n))})}_getMapId(){return this._mapId}addControl(h,e){if(e===void 0&&(e=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new p.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=h.onAdd(this);this._controls.push(h);const a=this._controlPositions[e];return e.indexOf("bottom")!==-1?a.insertBefore(n,a.firstChild):a.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new p.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(h);return e>-1&&this._controls.splice(e,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}calculateCameraOptionsFromTo(h,e,n,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,e,n,a)}resize(h){var e;const n=this._containerDimensions(),a=n[0],o=n[1],c=this._getClampedPixelRatio(a,o);if(this._resizeCanvas(a,o,c),this.painter.resize(a,o,c),this.painter.overLimit()){const _=this.painter.context.gl;this._maxCanvasSize=[_.drawingBufferWidth,_.drawingBufferHeight];const y=this._getClampedPixelRatio(a,o);this._resizeCanvas(a,o,y),this.painter.resize(a,o,y)}this.transform.resize(a,o),(e=this._requestedCameraState)===null||e===void 0||e.resize(a,o);const m=!this._moving;return m&&(this.stop(),this.fire(new p.k("movestart",h)).fire(new p.k("move",h))),this.fire(new p.k("resize",h)),m&&this.fire(new p.k("moveend",h)),this}_getClampedPixelRatio(h,e){const{0:n,1:a}=this._maxCanvasSize,o=this.getPixelRatio(),c=h*o,m=e*o;return Math.min(c>n?n/c:1,m>a?a/m:1)*o}getPixelRatio(){var h;return(h=this._overridePixelRatio)!==null&&h!==void 0?h:devicePixelRatio}setPixelRatio(h){this._overridePixelRatio=h,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(h){return this.transform.setMaxBounds(le.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.minZoom=h,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=h,this._update(),this.getZoom()>h&&this.setZoom(h),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.minPitch=h,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(h>=this.transform.minPitch)return this.transform.maxPitch=h,this._update(),this.getPitch()>h&&this.setPitch(h),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.renderWorldCopies=h,this._update()}project(h){return this.transform.locationPoint(p.N.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.pointLocation(p.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,e,n){if(h==="mouseenter"||h==="mouseover"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:c=>{const m=e.filter(y=>this.getLayer(y)),_=m.length!==0?this.queryRenderedFeatures(c.point,{layers:m}):[];_.length?a||(a=!0,n.call(this,new ai(h,this,c.originalEvent,{features:_}))):a=!1},mouseout:()=>{a=!1}}}}if(h==="mouseleave"||h==="mouseout"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:m=>{const _=e.filter(y=>this.getLayer(y));(_.length!==0?this.queryRenderedFeatures(m.point,{layers:_}):[]).length?a=!0:a&&(a=!1,n.call(this,new ai(h,this,m.originalEvent)))},mouseout:m=>{a&&(a=!1,n.call(this,new ai(h,this,m.originalEvent)))}}}}{const a=o=>{const c=e.filter(_=>this.getLayer(_)),m=c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[];m.length&&(o.features=m,n.call(this,o),delete o.features)};return{layers:e,listener:n,delegates:{[h]:a}}}}_saveDelegatedListener(h,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(e)}_removeDelegatedListener(h,e,n){if(!this._delegatedListeners||!this._delegatedListeners[h])return;const a=this._delegatedListeners[h];for(let o=0;oe.includes(m))){for(const m in c.delegates)this.off(m,c.delegates[m]);return void a.splice(o,1)}}}on(h,e,n){if(n===void 0)return super.on(h,e);const a=this._createDelegatedListener(h,typeof e=="string"?[e]:e,n);this._saveDelegatedListener(h,a);for(const o in a.delegates)this.on(o,a.delegates[o]);return this}once(h,e,n){if(n===void 0)return super.once(h,e);const a=typeof e=="string"?[e]:e,o=this._createDelegatedListener(h,a,n);for(const c in o.delegates){const m=o.delegates[c];o.delegates[c]=(..._)=>{this._removeDelegatedListener(h,a,n),m(..._)}}this._saveDelegatedListener(h,o);for(const c in o.delegates)this.once(c,o.delegates[c]);return this}off(h,e,n){return n===void 0?super.off(h,e):(this._removeDelegatedListener(h,typeof e=="string"?[e]:e,n),this)}queryRenderedFeatures(h,e){if(!this.style)return[];let n;const a=h instanceof p.P||Array.isArray(h),o=a?h:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(a?{}:h)||{},o instanceof p.P||typeof o[0]=="number")n=[p.P.convert(o)];else{const c=p.P.convert(o[0]),m=p.P.convert(o[1]);n=[c,new p.P(m.x,c.y),m,new p.P(c.x,m.y),c]}return this.style.queryRenderedFeatures(n,e,this.transform)}querySourceFeatures(h,e){return this.style.querySourceFeatures(h,e)}setStyle(h,e){return(e=p.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(h,e))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){const e=this._locale[h];if(e==null)throw new Error(`Missing UI string '${h}'`);return e}_updateStyle(h,e){if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(h,e));const n=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new qs(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,e,n):this.style.loadJSON(h,e,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new qs(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,e){if(typeof h=="string"){const n=this._requestManager.transformRequest(h,"Style");p.h(n,new AbortController).then(a=>{this._updateDiff(a.data,e)}).catch(a=>{a&&this.fire(new p.j(a))})}else typeof h=="object"&&this._updateDiff(h,e)}_updateDiff(h,e){try{this.style.setState(h,e)&&this._update(!0)}catch(n){p.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(h,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():p.w("There is no style added to the map.")}addSource(h,e){return this._lazyInitEmptyStyle(),this.style.addSource(h,e),this._update(!0)}isSourceLoaded(h){const e=this.style&&this.style.sourceCaches[h];if(e!==void 0)return e.loaded();this.fire(new p.j(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){const e=this.style.sourceCaches[h.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&e.reload();for(const n in this.style._layers){const a=this.style._layers[n];a.type==="hillshade"&&a.source===h.source&&p.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.")}this.terrain=new Po(this.painter,e,h),this.painter.renderToTexture=new Cl(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==h.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.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.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new p.k("terrain",{terrain:h})),this}getTerrain(){var h,e;return(e=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&e!==void 0?e:null}areTilesLoaded(){const h=this.style&&this.style.sourceCaches;for(const e in h){const n=h[e]._tiles;for(const a in n){const o=n[a];if(o.state!=="loaded"&&o.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}addImage(h,e,n={}){const{pixelRatio:a=1,sdf:o=!1,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b}=n;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||p.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new p.j(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:T,height:S,data:k}=e,D=e;return this.style.addImage(h,{data:new p.R({width:T,height:S},new Uint8Array(k)),pixelRatio:a,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:o,version:0,userImage:D}),D.onAdd&&D.onAdd(this,h),this}}{const{width:T,height:S,data:k}=de.getImageData(e);this.style.addImage(h,{data:new p.R({width:T,height:S},k),pixelRatio:a,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:o,version:0})}}updateImage(h,e){const n=this.style.getImage(h);if(!n)return this.fire(new p.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=e instanceof HTMLImageElement||p.b(e)?de.getImageData(e):e,{width:o,height:c,data:m}=a;if(o===void 0||c===void 0)return this.fire(new p.j(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(o!==n.data.width||c!==n.data.height)return this.fire(new p.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const _=!(e instanceof HTMLImageElement||p.b(e));return n.data.replace(m,_),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new p.j(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return Mt.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,e){return this._lazyInitEmptyStyle(),this.style.addLayer(h,e),this._update(!0)}moveLayer(h,e){return this.style.moveLayer(h,e),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,e,n){return this.style.setLayerZoomRange(h,e,n),this._update(!0)}setFilter(h,e,n={}){return this.style.setFilter(h,e,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,e,n,a={}){return this.style.setPaintProperty(h,e,n,a),this._update(!0)}getPaintProperty(h,e){return this.style.getPaintProperty(h,e)}setLayoutProperty(h,e,n,a={}){return this.style.setLayoutProperty(h,e,n,a),this._update(!0)}getLayoutProperty(h,e){return this.style.getLayoutProperty(h,e)}setGlyphs(h,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,e,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,e,n,a=>{a||this._update(!0)}),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,e,n=>{n||this._update(!0)}),this}setLight(h,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(h){return this._lazyInitEmptyStyle(),this.style.setSky(h),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,e){return this.style.setFeatureState(h,e),this._update()}removeFeatureState(h,e){return this.style.removeFeatureState(h,e),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,e=0;return this._container&&(h=this._container.clientWidth||400,e=this._container.clientHeight||300),[h,e]}_setupContainer(){const h=this._container;h.classList.add("maplibregl-map");const e=this._canvasContainer=se.create("div","maplibregl-canvas-container",h);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=se.create("canvas","maplibregl-canvas",e),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 n=this._containerDimensions(),a=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],a);const o=this._controlContainer=se.create("div","maplibregl-control-container",h),c=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(m=>{c[m]=se.create("div",`maplibregl-ctrl-${m} `,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,e,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*e),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const h={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let e=null;this._canvas.addEventListener("webglcontextcreationerror",a=>{e={requestedAttributes:h},a&&(e.statusMessage=a.statusMessage,e.type=a.type)},{once:!0});const n=this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h);if(!n){const a="Failed to initialize WebGL";throw e?(e.message=a,new Error(JSON.stringify(e))):new Error(a)}this.painter=new aa(n,this.transform),Ot.testSupport(n)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(h){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_render(h){const e=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const o=this.transform.zoom,c=de.now();this.style.zoomHistory.update(o,c);const m=new p.z(o,{now:c,fadeDuration:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),_=m.crossFadingFactor();_===1&&_===this._crossFadingFactor||(n=!0,this._crossFadingFactor=_),this.style.update(m)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,e,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:e,showPadding:this.showPadding}),this.fire(new p.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.bf.mark(p.bg.load),this.fire(new p.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const a=this._sourcesDirty||this._styleDirty||this._placementDirty;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new p.k("idle")),!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,p.bf.mark(p.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(const n of this._controls)n.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),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Mt.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e!=null&&e.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),se.remove(this._canvasContainer),se.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),p.bf.clearMetrics(),this._removed=!0,this.fire(new p.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,de.frameAsync(this._frameRequest).then(h=>{p.bf.frame(h),this._frameRequest=null,this._render(h)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get version(){return Ml}getCameraTargetElevation(){return this.transform.elevation}},M.MapMouseEvent=ai,M.MapTouchEvent=wn,M.MapWheelEvent=wl,M.Marker=_a,M.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{const e=this._map.getZoom(),n=e===this._map.getMaxZoom(),a=e===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=e},this._setButtonTitle=(e,n)=>{const a=this._map._getUIString(`NavigationControl.${n}`);e.title=a,e.setAttribute("aria-label",a)},this.options=p.e({},Ac,h),this._container=se.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})),se.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})),se.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=se.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,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._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Cc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){se.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._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,e){const n=se.create("button",h,this._container);return n.type="button",n.addEventListener("click",e),n}},M.Popup=class extends p.E{constructor(h){super(),this.remove=()=>(this._content&&se.remove(this._content),this._container&&(se.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 p.k("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=>{var n;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=se.create("div","maplibregl-popup",this._map.getContainer()),this._tip=se.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const _ of this.options.className.split(" "))this._container.classList.add(_);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=this._map.transform.renderWorldCopies&&!this._trackPointer?wt(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.wrap(),this._trackPointer&&!e)return;const a=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.locationPoint(this._lngLat));let o=this.options.anchor;const c=xa(this.options.offset);if(!o){const _=this._container.offsetWidth,y=this._container.offsetHeight;let b;b=a.y+c.bottom.ythis._map.transform.height-y?["bottom"]:[],a.x<_/2?b.push("left"):a.x>this._map.transform.width-_/2&&b.push("right"),o=b.length===0?"bottom":b.join("-")}let m=a.add(c[o]);this.options.subpixelPositioning||(m=m.round()),se.setTransform(this._container,`${Qn[o]} translate(${m.x}px,${m.y}px)`),ga(this._container,o,"popup")},this._onClose=()=>{this.remove()},this.options=p.e(Object.create(je),h)}addTo(h){return this._map&&this.remove(),this._map=h,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 p.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=p.N.convert(h),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(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){const e=document.createDocumentFragment(),n=document.createElement("body");let a;for(n.innerHTML=h;a=n.firstChild,a;)e.appendChild(a);return this.setDOMContent(e)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=se.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=se.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 h=this._container.querySelector(ya);h&&h.focus()}},M.RasterDEMTileSource=Et,M.RasterTileSource=ut,M.ScaleControl=class{constructor(h){this._onMove=()=>{Ls(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Ls(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},zr),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){se.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},M.ScrollZoomHandler=fr,M.Style=qs,M.TerrainControl=class{constructor(h){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=h}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=se.create("button","maplibregl-ctrl-terrain",this._container),se.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(){se.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},M.TwoFingersTouchPitchHandler=Xn,M.TwoFingersTouchRotateHandler=vo,M.TwoFingersTouchZoomHandler=yo,M.TwoFingersTouchZoomRotateHandler=wo,M.VectorTileSource=ps,M.VideoSource=En,M.addSourceType=(h,e)=>p._(void 0,void 0,void 0,function*(){if(gs(h))throw new Error(`A source type called "${h}" already exists.`);((n,a)=>{ms[n]=a})(h,e)}),M.clearPrewarmedResources=function(){const h=Yt;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(or),Yt=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()"))},M.getMaxParallelImageRequests=function(){return p.a.MAX_PARALLEL_IMAGE_REQUESTS},M.getRTLTextPluginStatus=function(){return Ar().getRTLTextPluginStatus()},M.getVersion=function(){return Mo},M.getWorkerCount=function(){return si.workerCount},M.getWorkerUrl=function(){return p.a.WORKER_URL},M.importScriptInWorkers=function(h){return Xr().broadcast("IS",h)},M.prewarm=function(){Ir().acquire(or)},M.setMaxParallelImageRequests=function(h){p.a.MAX_PARALLEL_IMAGE_REQUESTS=h},M.setRTLTextPlugin=function(h,e){return Ar().setRTLTextPlugin(h,e)},M.setWorkerCount=function(h){si.workerCount=h},M.setWorkerUrl=function(h){p.a.WORKER_URL=h}});var ye=G;return ye})}(ec)),ec.exports}var tc=Cf(),Tr=Uint8Array,Oa=Uint16Array,Mf=Int32Array,fd=new Tr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),md=new Tr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),kf=new Tr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gd=function(J,j){for(var G=new Oa(31),re=0;re<31;++re)G[re]=j+=1<>1|(Lt&21845)<<1;ds=(ds&52428)>>2|(ds&13107)<<2,ds=(ds&61680)>>4|(ds&3855)<<4,vh[Lt]=((ds&65280)>>8|(ds&255)<<8)>>1}var Wo=function(J,j,G){for(var re=J.length,he=0,ye=new Oa(j);he>Je]=Ge}else for(p=new Oa(re),he=0;he>15-J[he]);return p},Jo=new Tr(288);for(var Lt=0;Lt<144;++Lt)Jo[Lt]=8;for(var Lt=144;Lt<256;++Lt)Jo[Lt]=9;for(var Lt=256;Lt<280;++Lt)Jo[Lt]=7;for(var Lt=280;Lt<288;++Lt)Jo[Lt]=8;var xd=new Tr(32);for(var Lt=0;Lt<32;++Lt)xd[Lt]=5;var Lf=Wo(Jo,9,1),Rf=Wo(xd,5,1),yh=function(J){for(var j=J[0],G=1;Gj&&(j=J[G]);return j},Hr=function(J,j,G){var re=j/8|0;return(J[re]|J[re+1]<<8)>>(j&7)&G},xh=function(J,j){var G=j/8|0;return(J[G]|J[G+1]<<8|J[G+2]<<16)>>(j&7)},Bf=function(J){return(J+7)/8|0},Ff=function(J,j,G){return(G==null||G>J.length)&&(G=J.length),new Tr(J.subarray(j,G))},Of=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],wr=function(J,j,G){var re=new Error(j||Of[J]);if(re.code=J,Error.captureStackTrace&&Error.captureStackTrace(re,wr),!G)throw re;return re},wh=function(J,j,G,re){var he=J.length,ye=0;if(!he||j.f&&!j.l)return G||new Tr(0);var M=!G,p=M||j.i!=2,Je=j.i;M&&(G=new Tr(he*3));var Ge=function(Xr){var Ki=G.length;if(Xr>Ki){var lr=new Tr(Math.max(Ki*2,Xr));lr.set(G),G=lr}},He=j.f||0,de=j.p||0,se=j.b||0,Ot=j.l,qt=j.d,kt=j.m,Ii=j.n,Oi=he*8;do{if(!Ot){He=Hr(J,de,1);var Fr=Hr(J,de+1,3);if(de+=3,Fr)if(Fr==1)Ot=Lf,qt=Rf,kt=9,Ii=5;else if(Fr==2){var Pi=Hr(J,de,31)+257,gi=Hr(J,de+10,15)+4,cn=Pi+Hr(J,de+5,31)+1;de+=14;for(var ii=new Tr(cn),Or=new Tr(19),et=0;et>4;if(Mt<16)ii[et++]=Mt;else{var Vi=0,_i=0;for(Mt==16?(_i=3+Hr(J,de,3),de+=2,Vi=ii[et-1]):Mt==17?(_i=3+Hr(J,de,7),de+=3):Mt==18&&(_i=11+Hr(J,de,127),de+=7);_i--;)ii[et++]=Vi}}var un=ii.subarray(0,Pi),ri=ii.subarray(Pi);kt=yh(un),Ii=yh(ri),Ot=Wo(un,kt,1),qt=Wo(ri,Ii,1)}else wr(1);else{var Mt=Bf(de)+4,ln=J[Mt-4]|J[Mt-3]<<8,mi=Mt+ln;if(mi>he){Je&&wr(0);break}p&&Ge(se+ln),G.set(J.subarray(Mt,mi),se),j.b=se+=ln,j.p=de=mi*8,j.f=He;continue}if(de>Oi){Je&&wr(0);break}}p&&Ge(se+131072);for(var ar=(1<>4;if(de+=Vi&15,de>Oi){Je&&wr(0);break}if(Vi||wr(2),Ni<256)G[se++]=Ni;else if(Ni==256){yi=de,Ot=null;break}else{var or=Ni-254;if(Ni>264){var et=Ni-257,si=fd[et];or=Hr(J,de,(1<>4;Sr||wr(3),de+=Sr&15;var ri=Df[Yt];if(Yt>3){var si=md[Yt];ri+=xh(J,de)&(1<Oi){Je&&wr(0);break}p&&Ge(se+131072);var Ai=se+or;if(se>3&1)+(j>>4&1);re>0;re-=!J[G++]);return G+(j&2)},Uf=function(J){var j=J.length;return(J[j-4]|J[j-3]<<8|J[j-2]<<16|J[j-1]<<24)>>>0},jf=function(J,j){return((J[0]&15)!=8||J[0]>>4>7||(J[0]<<8|J[1])%31)&&wr(6,"invalid zlib data"),(J[1]>>5&1)==+!j&&wr(6,"invalid zlib data: "+(J[1]&32?"need":"unexpected")+" dictionary"),(J[1]>>3&4)+2};function $f(J,j){return wh(J,{i:2},j,j)}function qf(J,j){var G=Nf(J);return G+8>J.length&&wr(6,"invalid gzip data"),wh(J.subarray(G,-8),{i:2},new Tr(Uf(J)),j)}function Zf(J,j){return wh(J.subarray(jf(J,j),-4),{i:2},j,j)}function Gf(J,j){return J[0]==31&&J[1]==139&&J[2]==8?qf(J,j):(J[0]&15)!=8||J[0]>>4>7||(J[0]<<8|J[1])%31?$f(J,j):Zf(J,j)}var Hf=typeof TextDecoder<"u"&&new TextDecoder,Xf=0;try{Hf.decode(Vf,{stream:!0}),Xf=1}catch{}var Wf=Object.defineProperty,Ko=Math.pow,At=(J,j)=>Wf(J,"name",{value:j,configurable:!0}),fi=(J,j,G)=>new Promise((re,he)=>{var ye=Je=>{try{p(G.next(Je))}catch(Ge){he(Ge)}},M=Je=>{try{p(G.throw(Je))}catch(Ge){he(Ge)}},p=Je=>Je.done?re(Je.value):Promise.resolve(Je.value).then(ye,M);p((G=G.apply(J,j)).next())});At((J,j)=>{let G=!1,re="",he=L.GridLayer.extend({createTile:At((ye,M)=>{let p=document.createElement("img"),Je=new AbortController,Ge=Je.signal;return p.cancel=()=>{Je.abort()},G||(J.getHeader().then(He=>{He.tileType===1?console.error("Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details."):He.tileType===2?re="image/png":He.tileType===3?re="image/jpeg":He.tileType===4?re="image/webp":He.tileType===5&&(re="image/avif")}),G=!0),J.getZxy(ye.z,ye.x,ye.y,Ge).then(He=>{if(He){let de=new Blob([He.data],{type:re}),se=window.URL.createObjectURL(de);p.src=se,p.cancel=void 0,M(void 0,p)}}).catch(He=>{if(He.name!=="AbortError")throw He}),p},"createTile"),_removeTile:At(function(ye){let M=this._tiles[ye];M&&(M.el.cancel&&M.el.cancel(),M.el.width=0,M.el.height=0,M.el.deleted=!0,L.DomUtil.remove(M.el),delete this._tiles[ye],this.fire("tileunload",{tile:M.el,coords:this._keyToTileCoords(ye)}))},"_removeTile")});return new he(j)},"leafletRasterLayer");var Kf=At(J=>(j,G)=>{if(G instanceof AbortController)return J(j,G);let re=new AbortController;return J(j,re).then(he=>G(void 0,he.data,he.cacheControl||"",he.expires||""),he=>G(he)).catch(he=>G(he)),{cancel:At(()=>re.abort(),"cancel")}},"v3compat"),vd=class{constructor(j){this.tilev4=At((G,re)=>fi(this,null,function*(){if(G.type==="json"){let Ot=G.url.substr(10),qt=this.tiles.get(Ot);if(qt||(qt=new dd(Ot),this.tiles.set(Ot,qt)),this.metadata)return{data:yield qt.getTileJson(G.url)};let kt=yield qt.getHeader();return{data:{tiles:[`${G.url}/{z}/{x}/{y}`],minzoom:kt.minZoom,maxzoom:kt.maxZoom,bounds:[kt.minLon,kt.minLat,kt.maxLon,kt.maxLat]}}}let he=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),ye=G.url.match(he);if(!ye)throw new Error("Invalid PMTiles protocol URL");let M=ye[1],p=this.tiles.get(M);p||(p=new dd(M),this.tiles.set(M,p));let Je=ye[2],Ge=ye[3],He=ye[4],de=yield p.getHeader(),se=yield p==null?void 0:p.getZxy(+Je,+Ge,+He,re.signal);return se?{data:new Uint8Array(se.data),cacheControl:se.cacheControl,expires:se.expires}:de.tileType===1?{data:new Uint8Array}:{data:null}}),"tilev4"),this.tile=Kf(this.tilev4),this.tiles=new Map,this.metadata=(j==null?void 0:j.metadata)||!1}add(j){this.tiles.set(j.source.getKey(),j)}get(j){return this.tiles.get(j)}};At(vd,"Protocol");var Jf=vd;function bd(J,j){return(j>>>0)*4294967296+(J>>>0)}At(bd,"toNum");function wd(J,j){let G=j.buf,re=G[j.pos++],he=(re&112)>>4;if(re<128||(re=G[j.pos++],he|=(re&127)<<3,re<128)||(re=G[j.pos++],he|=(re&127)<<10,re<128)||(re=G[j.pos++],he|=(re&127)<<17,re<128)||(re=G[j.pos++],he|=(re&127)<<24,re<128)||(re=G[j.pos++],he|=(re&1)<<31,re<128))return bd(J,he);throw new Error("Expected varint not more than 10 bytes")}At(wd,"readVarintRemainder");function Fa(J){let j=J.buf,G=j[J.pos++],re=G&127;return G<128||(G=j[J.pos++],re|=(G&127)<<7,G<128)||(G=j[J.pos++],re|=(G&127)<<14,G<128)||(G=j[J.pos++],re|=(G&127)<<21,G<128)?re:(G=j[J.pos],re|=(G&15)<<28,wd(re,J))}At(Fa,"readVarint");function Th(J,j,G,re){if(re===0){G===1&&(j[0]=J-1-j[0],j[1]=J-1-j[1]);let he=j[0];j[0]=j[1],j[1]=he}}At(Th,"rotate");function Td(J,j){let G=Ko(2,J),re=j,he=j,ye=j,M=[0,0],p=1;for(;p26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(j>Ko(2,J)-1||G>Ko(2,J)-1)throw Error("tile x/y outside zoom level bounds");let re=Yf[J],he=Ko(2,J),ye=0,M=0,p=0,Je=[j,G],Ge=he/2;for(;Ge>0;)ye=(Je[0]&Ge)>0?1:0,M=(Je[1]&Ge)>0?1:0,p+=Ge*Ge*(3*ye^M),Th(Ge,Je,ye,M),Ge=Ge/2;return re+p}At(Sd,"zxyToTileId");function Qf(J){let j=0;for(let G=0;G<27;G++){let re=(1<J)return Td(G,J-j);j+=re}throw Error("Tile zoom level exceeds max safe number limit (26)")}At(Qf,"tileIdToZxy");var em=(J=>(J[J.Unknown=0]="Unknown",J[J.None=1]="None",J[J.Gzip=2]="Gzip",J[J.Brotli=3]="Brotli",J[J.Zstd=4]="Zstd",J))(em||{});function ic(J,j){return fi(this,null,function*(){if(j===1||j===0)return J;if(j===2){if(typeof globalThis.DecompressionStream>"u")return Gf(new Uint8Array(J));let G=new Response(J).body;if(!G)throw Error("Failed to read response stream");let re=G.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(re).arrayBuffer()}throw Error("Compression method not supported")})}At(ic,"defaultDecompress");var tm=(J=>(J[J.Unknown=0]="Unknown",J[J.Mvt=1]="Mvt",J[J.Png=2]="Png",J[J.Jpeg=3]="Jpeg",J[J.Webp=4]="Webp",J[J.Avif=5]="Avif",J))(tm||{});function Id(J){return J===1?".mvt":J===2?".png":J===3?".jpg":J===4?".webp":J===5?".avif":""}At(Id,"tileTypeExt");var im=127;function Pd(J,j){let G=0,re=J.length-1;for(;G<=re;){let he=re+G>>1,ye=j-J[he].tileId;if(ye>0)G=he+1;else if(ye<0)re=he-1;else return J[he]}return re>=0&&(J[re].runLength===0||j-J[re].tileId-1,ye=/Chrome|Chromium|Edg|OPR|Brave/.test(re);this.chromeWindowsNoCache=!1,he&&ye&&(this.chromeWindowsNoCache=!0)}getKey(){return this.url}setHeaders(j){this.customHeaders=j}getBytes(j,G,re,he){return fi(this,null,function*(){let ye,M;re?M=re:(ye=new AbortController,M=ye.signal);let p=new Headers(this.customHeaders);p.set("range",`bytes=${j}-${j+G-1}`);let Je;this.mustReload?Je="reload":this.chromeWindowsNoCache&&(Je="no-store");let Ge=yield fetch(this.url,{signal:M,cache:Je,headers:p});if(j===0&&Ge.status===416){let se=Ge.headers.get("Content-Range");if(!se||!se.startsWith("bytes */"))throw Error("Missing content-length on 416 response");let Ot=+se.substr(8);Ge=yield fetch(this.url,{signal:M,cache:"reload",headers:{range:`bytes=0-${Ot-1}`}})}let He=Ge.headers.get("Etag");if(He!=null&&He.startsWith("W/")&&(He=null),Ge.status===416||he&&He&&He!==he)throw this.mustReload=!0,new bh(`Server returned non-matching ETag ${he} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);if(Ge.status>=300)throw Error(`Bad response code: ${Ge.status}`);let de=Ge.headers.get("Content-Length");if(Ge.status===200&&(!de||+de>G))throw ye&&ye.abort(),Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield Ge.arrayBuffer(),etag:He||void 0,cacheControl:Ge.headers.get("Cache-Control")||void 0,expires:Ge.headers.get("Expires")||void 0}})}};At(Ad,"FetchSource");var nm=Ad;function Br(J,j){let G=J.getUint32(j+4,!0),re=J.getUint32(j+0,!0);return G*Ko(2,32)+re}At(Br,"getUint64");function Cd(J,j){let G=new DataView(J),re=G.getUint8(7);if(re>3)throw Error(`Archive is spec version ${re} but this library supports up to spec version 3`);return{specVersion:re,rootDirectoryOffset:Br(G,8),rootDirectoryLength:Br(G,16),jsonMetadataOffset:Br(G,24),jsonMetadataLength:Br(G,32),leafDirectoryOffset:Br(G,40),leafDirectoryLength:Br(G,48),tileDataOffset:Br(G,56),tileDataLength:Br(G,64),numAddressedTiles:Br(G,72),numTileEntries:Br(G,80),numTileContents:Br(G,88),clustered:G.getUint8(96)===1,internalCompression:G.getUint8(97),tileCompression:G.getUint8(98),tileType:G.getUint8(99),minZoom:G.getUint8(100),maxZoom:G.getUint8(101),minLon:G.getInt32(102,!0)/1e7,minLat:G.getInt32(106,!0)/1e7,maxLon:G.getInt32(110,!0)/1e7,maxLat:G.getInt32(114,!0)/1e7,centerZoom:G.getUint8(118),centerLon:G.getInt32(119,!0)/1e7,centerLat:G.getInt32(123,!0)/1e7,etag:j}}At(Cd,"bytesToHeader");function Sh(J){let j={buf:new Uint8Array(J),pos:0},G=Fa(j),re=[],he=0;for(let ye=0;ye0?re[ye].offset=re[ye-1].offset+re[ye-1].length:re[ye].offset=M-1}return re}At(Sh,"deserializeIndex");var Md=class extends Error{};At(Md,"EtagMismatch");var bh=Md;function Ih(J,j){return fi(this,null,function*(){let G=yield J.getBytes(0,16384);if(new DataView(G.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");let re=G.data.slice(0,im),he=Cd(re,G.etag),ye=G.data.slice(he.rootDirectoryOffset,he.rootDirectoryOffset+he.rootDirectoryLength),M=`${J.getKey()}|${he.etag||""}|${he.rootDirectoryOffset}|${he.rootDirectoryLength}`,p=Sh(yield j(ye,he.internalCompression));return[he,[M,p.length,p]]})}At(Ih,"getHeaderAndRoot");function Ph(J,j,G,re,he){return fi(this,null,function*(){let ye=yield J.getBytes(G,re,void 0,he.etag),M=yield j(ye.data,he.internalCompression),p=Sh(M);if(p.length===0)throw new Error("Empty directory is invalid");return p})}At(Ph,"getDirectory");var sm=class{constructor(j=100,G=!0,re=ic){this.cache=new Map,this.maxCacheEntries=j,this.counter=1,this.decompress=re}getHeader(j){return fi(this,null,function*(){let G=j.getKey(),re=this.cache.get(G);if(re)return re.lastUsed=this.counter++,re.data;let he=yield Ih(j,this.decompress);return he[1]&&this.cache.set(he[1][0],{lastUsed:this.counter++,data:he[1][2]}),this.cache.set(G,{lastUsed:this.counter++,data:he[0]}),this.prune(),he[0]})}getDirectory(j,G,re,he){return fi(this,null,function*(){let ye=`${j.getKey()}|${he.etag||""}|${G}|${re}`,M=this.cache.get(ye);if(M)return M.lastUsed=this.counter++,M.data;let p=yield Ph(j,this.decompress,G,re,he);return this.cache.set(ye,{lastUsed:this.counter++,data:p}),this.prune(),p})}prune(){if(this.cache.size>this.maxCacheEntries){let j=1/0,G;this.cache.forEach((re,he)=>{re.lastUsed{Ih(j,this.decompress).then(p=>{p[1]&&this.cache.set(p[1][0],{lastUsed:this.counter++,data:Promise.resolve(p[1][2])}),ye(p[0]),this.prune()}).catch(p=>{M(p)})});return this.cache.set(G,{lastUsed:this.counter++,data:he}),he})}getDirectory(j,G,re,he){return fi(this,null,function*(){let ye=`${j.getKey()}|${he.etag||""}|${G}|${re}`,M=this.cache.get(ye);if(M)return M.lastUsed=this.counter++,yield M.data;let p=new Promise((Je,Ge)=>{Ph(j,this.decompress,G,re,he).then(He=>{Je(He),this.prune()}).catch(He=>{Ge(He)})});return this.cache.set(ye,{lastUsed:this.counter++,data:p}),p})}prune(){if(this.cache.size>=this.maxCacheEntries){let j=1/0,G;this.cache.forEach((re,he)=>{re.lastUsed{this.getHeader(j).then(M=>{he(),this.invalidations.delete(G)}).catch(M=>{ye(M)})});this.invalidations.set(G,re)})}};At(kd,"SharedPromiseCache");var am=kd,Ed=class{constructor(j,G,re){typeof j=="string"?this.source=new nm(j):this.source=j,re?this.decompress=re:this.decompress=ic,G?this.cache=G:this.cache=new am}getHeader(){return fi(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(j,G,re,he){return fi(this,null,function*(){let ye=Sd(j,G,re),M=yield this.cache.getHeader(this.source);if(jM.maxZoom)return;let p=M.rootDirectoryOffset,Je=M.rootDirectoryLength;for(let Ge=0;Ge<=3;Ge++){let He=yield this.cache.getDirectory(this.source,p,Je,M),de=Pd(He,ye);if(de){if(de.runLength>0){let se=yield this.source.getBytes(M.tileDataOffset+de.offset,de.length,he,M.etag);return{data:yield this.decompress(se.data,M.tileCompression),cacheControl:se.cacheControl,expires:se.expires}}p=M.leafDirectoryOffset+de.offset,Je=de.length}else return}throw Error("Maximum directory depth exceeded")})}getZxy(j,G,re,he){return fi(this,null,function*(){try{return yield this.getZxyAttempt(j,G,re,he)}catch(ye){if(ye instanceof bh)return this.cache.invalidate(this.source),yield this.getZxyAttempt(j,G,re,he);throw ye}})}getMetadataAttempt(){return fi(this,null,function*(){let j=yield this.cache.getHeader(this.source),G=yield this.source.getBytes(j.jsonMetadataOffset,j.jsonMetadataLength,void 0,j.etag),re=yield this.decompress(G.data,j.internalCompression),he=new TextDecoder("utf-8");return JSON.parse(he.decode(re))})}getMetadata(){return fi(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(j){if(j instanceof bh)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw j}})}getTileJson(j){return fi(this,null,function*(){let G=yield this.getHeader(),re=yield this.getMetadata(),he=Id(G.tileType);return{tilejson:"3.0.0",scheme:"xyz",tiles:[`${j}/{z}/{x}/{y}${he}`],vector_layers:re.vector_layers,attribution:re.attribution,description:re.description,name:re.name,version:re.version,bounds:[G.minLon,G.minLat,G.maxLon,G.maxLat],center:[G.centerLon,G.centerLat,G.centerZoom],minzoom:G.minZoom,maxzoom:G.maxZoom}})}};At(Ed,"PMTiles");var dd=Ed;const om=["click"];class lm{constructor(j,G=!0){Fi(this,"button");Fi(this,"clickCallback");this.button=this.createButton();const re=document.createElement("div");re.classList.add("maplibregl-ctrl","maplibregl-ctrl-group"),re.appendChild(this.button),G||(re.style.display="none"),j.appendChild(re)}on(j,G){if(!om.includes(j))throw new Error(`Event type ${j} is not supported.`);switch(j){case"click":this.clickCallback=G;break}}turnOn(){this.button.classList.add("maplibregl-ctrl-compass-heading-active"),this.button.setAttribute("aria-pressed","true"),this.startLoading()}turnOff(){this.button.classList.remove("maplibregl-ctrl-compass-heading-active"),this.button.setAttribute("aria-pressed","false"),this.stopLoading()}disable(){this.button.setAttribute("title","Compass not available"),this.button.setAttribute("aria-label","Compass not available"),this.button.setAttribute("disabled","disabled")}startLoading(){this.button.classList.add("maplibregl-ctrl-compass-heading-waiting")}stopLoading(){this.button.classList.remove("maplibregl-ctrl-compass-heading-waiting")}createButton(){const j=document.createElement("button");j.classList.add("maplibregl-ctrl-compass-heading"),j.setAttribute("title","Rotate map to heading-up"),j.setAttribute("aria-label","Rotate map to heading-up"),j.addEventListener("click",()=>{this.clickCallback&&this.clickCallback()});const G=document.createElement("span");return G.classList.add("maplibregl-ctrl-icon"),j.appendChild(G),j}}class cm{constructor(j){Fi(this,"element");this.element=document.createElement("div"),this.element.classList.add("maplibregl-ctrl"),this.element.innerHTML=` +`),F=_.createShader(_.FRAGMENT_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(F,Z),_.compileShader(F),!_.getShaderParameter(F,_.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${_.getShaderInfoLog(F)}`);_.attachShader(this.program,F);const Y=_.createShader(_.VERTEX_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(Y,X),_.compileShader(Y),!_.getShaderParameter(Y,_.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${_.getShaderInfoLog(Y)}`);_.attachShader(this.program,Y),this.attributes={};const ee={};this.numAttributes=T.length;for(let ae=0;ae({u_depth:new p.aH(ae,fe.u_depth),u_terrain:new p.aH(ae,fe.u_terrain),u_terrain_dim:new p.aI(ae,fe.u_terrain_dim),u_terrain_matrix:new p.aJ(ae,fe.u_terrain_matrix),u_terrain_unpack:new p.aK(ae,fe.u_terrain_unpack),u_terrain_exaggeration:new p.aI(ae,fe.u_terrain_exaggeration)}))(e,ee),this.binderUniforms=a?a.getUniforms(e,ee):[]}draw(e,n,a,o,c,m,_,y,b,T,S,k,D,B,N,q,Z,X){const F=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(o),e.setColorMode(c),e.setCullFace(m),y){e.activeTexture.set(F.TEXTURE2),F.bindTexture(F.TEXTURE_2D,y.depthTexture),e.activeTexture.set(F.TEXTURE3),F.bindTexture(F.TEXTURE_2D,y.texture);for(const ee in this.terrainUniforms)this.terrainUniforms[ee].set(y[ee])}for(const ee in this.fixedUniforms)this.fixedUniforms[ee].set(_[ee]);N&&N.setUniforms(e,this.binderUniforms,D,{zoom:B});let Y=0;switch(n){case F.LINES:Y=2;break;case F.TRIANGLES:Y=3;break;case F.LINE_STRIP:Y=1}for(const ee of k.get()){const ae=ee.vaos||(ee.vaos={});(ae[b]||(ae[b]=new $a)).bind(e,this,T,N?N.getPaintVertexBuffers():[],S,ee.vertexOffset,q,Z,X),F.drawElements(n,ee.primitiveLength*Y,F.UNSIGNED_SHORT,ee.primitiveOffset*Y*2)}}}function Zs(h,e,n){const a=1/rt(n,1,e.transform.tileZoom),o=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,e.transform.tileZoom)/o,m=c*(n.tileID.canonical.x+n.tileID.wrap*o),_=c*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[a,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_]}}const ys=(h,e,n,a)=>{const o=e.style.light,c=o.properties.get("position"),m=[c.x,c.y,c.z],_=function(){var b=new p.A(9);return p.A!=Float32Array&&(b[1]=0,b[2]=0,b[3]=0,b[5]=0,b[6]=0,b[7]=0),b[0]=1,b[4]=1,b[8]=1,b}();o.properties.get("anchor")==="viewport"&&function(b,T){var S=Math.sin(T),k=Math.cos(T);b[0]=k,b[1]=S,b[2]=0,b[3]=-S,b[4]=k,b[5]=0,b[6]=0,b[7]=0,b[8]=1}(_,-e.transform.angle),function(b,T,S){var k=T[0],D=T[1],B=T[2];b[0]=k*S[0]+D*S[3]+B*S[6],b[1]=k*S[1]+D*S[4]+B*S[7],b[2]=k*S[2]+D*S[5]+B*S[8]}(m,m,_);const y=o.properties.get("color");return{u_matrix:h,u_lightpos:m,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+n,u_opacity:a}},Gs=(h,e,n,a,o,c,m)=>p.e(ys(h,e,n,a),Zs(c,e,m),{u_height_factor:-Math.pow(2,o.overscaledZ)/m.tileSize/8}),Rn=h=>({u_matrix:h}),Yo=(h,e,n,a)=>p.e(Rn(h),Zs(n,e,a)),sc=(h,e)=>({u_matrix:h,u_world:e}),Qo=(h,e,n,a,o)=>p.e(Yo(h,e,n,a),{u_world:o}),ac=(h,e,n,a)=>{const o=h.transform;let c,m;if(a.paint.get("circle-pitch-alignment")==="map"){const _=rt(n,1,o.zoom);c=!0,m=[_,_]}else c=!1,m=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(a.paint.get("circle-pitch-scale")==="map"),u_matrix:h.translatePosMatrix(e.posMatrix,n,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_pitch_with_map:+c,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:m}},mn=(h,e,n)=>({u_matrix:h,u_inv_matrix:e,u_camera_to_center_distance:n.cameraToCenterDistance,u_viewport_size:[n.width,n.height]}),xs=(h,e,n=1)=>({u_matrix:h,u_color:e,u_overlay:0,u_overlay_scale:n}),Mi=h=>({u_matrix:h}),ki=(h,e,n,a)=>({u_matrix:h,u_extrude_scale:rt(e,1,n),u_intensity:a}),Hs=(h,e,n,a)=>{const o=p.H();p.aP(o,0,h.width,h.height,0,0,1);const c=h.context.gl;return{u_matrix:o,u_world:[c.drawingBufferWidth,c.drawingBufferHeight],u_image:n,u_color_ramp:a,u_opacity:e.paint.get("heatmap-opacity")}};function Xs(h,e){const n=Math.pow(2,e.canonical.z),a=e.canonical.y;return[new p.Z(0,a/n).toLngLat().lat,new p.Z(0,(a+1)/n).toLngLat().lat]}const Ws=(h,e,n,a)=>{const o=h.transform;return{u_matrix:il(h,e,n,a),u_ratio:1/rt(e,1,o.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},el=(h,e,n,a,o)=>p.e(Ws(h,e,n,o),{u_image:0,u_image_height:a}),Bn=(h,e,n,a,o)=>{const c=h.transform,m=tl(e,c);return{u_matrix:il(h,e,n,o),u_texsize:e.imageAtlasTexture.size,u_ratio:1/rt(e,1,c.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[m,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},oc=(h,e,n,a,o,c)=>{const m=h.lineAtlas,_=tl(e,h.transform),y=n.layout.get("line-cap")==="round",b=m.getDash(a.from,y),T=m.getDash(a.to,y),S=b.width*o.fromScale,k=T.width*o.toScale;return p.e(Ws(h,e,n,c),{u_patternscale_a:[_/S,-b.height/2],u_patternscale_b:[_/k,-T.height/2],u_sdfgamma:m.width/(256*Math.min(S,k)*h.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:T.y,u_mix:o.t})};function tl(h,e){return 1/rt(h,1,e.tileZoom)}function il(h,e,n,a){return h.translatePosMatrix(a?a.posMatrix:e.tileID.posMatrix,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const lc=(h,e,n,a,o)=>{return{u_matrix:h,u_tl_parent:e,u_scale_parent:n,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(m=o.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(c=o.paint.get("raster-contrast"),c>0?1/(1-c):1+c),u_spin_weights:cc(o.paint.get("raster-hue-rotate"))};var c,m};function cc(h){h*=Math.PI/180;const e=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}const rl=(h,e,n,a,o,c,m,_,y,b,T,S,k,D)=>{const B=m.transform;return{u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:B.cameraToCenterDistance,u_pitch:B.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:B.width/B.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:_,u_label_plane_matrix:y,u_coord_matrix:b,u_is_text:+S,u_pitch_with_map:+a,u_is_along_line:o,u_is_variable_anchor:c,u_texsize:k,u_texture:0,u_translation:T,u_pitched_scale:D}},vs=(h,e,n,a,o,c,m,_,y,b,T,S,k,D,B)=>{const N=m.transform;return p.e(rl(h,e,n,a,o,c,m,_,y,b,T,S,k,B),{u_gamma_scale:a?Math.cos(N._pitch)*N.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:+D})},Ga=(h,e,n,a,o,c,m,_,y,b,T,S,k,D)=>p.e(vs(h,e,n,a,o,c,m,_,y,b,T,!0,S,!0,D),{u_texsize_icon:k,u_texture_icon:1}),Ks=(h,e,n)=>({u_matrix:h,u_opacity:e,u_color:n}),Ha=(h,e,n,a,o,c)=>p.e(function(m,_,y,b){const T=y.imageManager.getPattern(m.from.toString()),S=y.imageManager.getPattern(m.to.toString()),{width:k,height:D}=y.imageManager.getPixelSize(),B=Math.pow(2,b.tileID.overscaledZ),N=b.tileSize*Math.pow(2,y.transform.tileZoom)/B,q=N*(b.tileID.canonical.x+b.tileID.wrap*B),Z=N*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:T.tl,u_pattern_br_a:T.br,u_pattern_tl_b:S.tl,u_pattern_br_b:S.br,u_texsize:[k,D],u_mix:_.t,u_pattern_size_a:T.displaySize,u_pattern_size_b:S.displaySize,u_scale_a:_.fromScale,u_scale_b:_.toScale,u_tile_units_to_pixels:1/rt(b,1,y.transform.tileZoom),u_pixel_coord_upper:[q>>16,Z>>16],u_pixel_coord_lower:[65535&q,65535&Z]}}(a,c,n,o),{u_matrix:h,u_opacity:e}),Xa={fillExtrusion:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_opacity:new p.aI(h,e.u_opacity)}),fillExtrusionPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_height_factor:new p.aI(h,e.u_height_factor),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade),u_opacity:new p.aI(h,e.u_opacity)}),fill:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),fillPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),fillOutline:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world)}),fillOutlinePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),circle:(h,e)=>({u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_scale_with_map:new p.aH(h,e.u_scale_with_map),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_extrude_scale:new p.aO(h,e.u_extrude_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_matrix:new p.aJ(h,e.u_matrix)}),collisionBox:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_pixel_extrude_scale:new p.aO(h,e.u_pixel_extrude_scale)}),collisionCircle:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_inv_matrix:new p.aJ(h,e.u_inv_matrix),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_viewport_size:new p.aO(h,e.u_viewport_size)}),debug:(h,e)=>({u_color:new p.aL(h,e.u_color),u_matrix:new p.aJ(h,e.u_matrix),u_overlay:new p.aH(h,e.u_overlay),u_overlay_scale:new p.aI(h,e.u_overlay_scale)}),clippingMask:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),heatmap:(h,e)=>({u_extrude_scale:new p.aI(h,e.u_extrude_scale),u_intensity:new p.aI(h,e.u_intensity),u_matrix:new p.aJ(h,e.u_matrix)}),heatmapTexture:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_color_ramp:new p.aH(h,e.u_color_ramp),u_opacity:new p.aI(h,e.u_opacity)}),hillshade:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_latrange:new p.aO(h,e.u_latrange),u_light:new p.aO(h,e.u_light),u_shadow:new p.aL(h,e.u_shadow),u_highlight:new p.aL(h,e.u_highlight),u_accent:new p.aL(h,e.u_accent)}),hillshadePrepare:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_dimension:new p.aO(h,e.u_dimension),u_zoom:new p.aI(h,e.u_zoom),u_unpack:new p.aK(h,e.u_unpack)}),line:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels)}),lineGradient:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_image:new p.aH(h,e.u_image),u_image_height:new p.aI(h,e.u_image_height)}),linePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texsize:new p.aO(h,e.u_texsize),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_image:new p.aH(h,e.u_image),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),lineSDF:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_patternscale_a:new p.aO(h,e.u_patternscale_a),u_patternscale_b:new p.aO(h,e.u_patternscale_b),u_sdfgamma:new p.aI(h,e.u_sdfgamma),u_image:new p.aH(h,e.u_image),u_tex_y_a:new p.aI(h,e.u_tex_y_a),u_tex_y_b:new p.aI(h,e.u_tex_y_b),u_mix:new p.aI(h,e.u_mix)}),raster:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_tl_parent:new p.aO(h,e.u_tl_parent),u_scale_parent:new p.aI(h,e.u_scale_parent),u_buffer_scale:new p.aI(h,e.u_buffer_scale),u_fade_t:new p.aI(h,e.u_fade_t),u_opacity:new p.aI(h,e.u_opacity),u_image0:new p.aH(h,e.u_image0),u_image1:new p.aH(h,e.u_image1),u_brightness_low:new p.aI(h,e.u_brightness_low),u_brightness_high:new p.aI(h,e.u_brightness_high),u_saturation_factor:new p.aI(h,e.u_saturation_factor),u_contrast_factor:new p.aI(h,e.u_contrast_factor),u_spin_weights:new p.aN(h,e.u_spin_weights)}),symbolIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolSDF:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolTextAndIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texsize_icon:new p.aO(h,e.u_texsize_icon),u_texture:new p.aH(h,e.u_texture),u_texture_icon:new p.aH(h,e.u_texture_icon),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),background:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_color:new p.aL(h,e.u_color)}),backgroundPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_image:new p.aH(h,e.u_image),u_pattern_tl_a:new p.aO(h,e.u_pattern_tl_a),u_pattern_br_a:new p.aO(h,e.u_pattern_br_a),u_pattern_tl_b:new p.aO(h,e.u_pattern_tl_b),u_pattern_br_b:new p.aO(h,e.u_pattern_br_b),u_texsize:new p.aO(h,e.u_texsize),u_mix:new p.aI(h,e.u_mix),u_pattern_size_a:new p.aO(h,e.u_pattern_size_a),u_pattern_size_b:new p.aO(h,e.u_pattern_size_b),u_scale_a:new p.aI(h,e.u_scale_a),u_scale_b:new p.aI(h,e.u_scale_b),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_tile_units_to_pixels:new p.aI(h,e.u_tile_units_to_pixels)}),terrain:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_ele_delta:new p.aI(h,e.u_ele_delta),u_fog_matrix:new p.aJ(h,e.u_fog_matrix),u_fog_color:new p.aL(h,e.u_fog_color),u_fog_ground_blend:new p.aI(h,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new p.aI(h,e.u_fog_ground_blend_opacity),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon_fog_blend:new p.aI(h,e.u_horizon_fog_blend)}),terrainDepth:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ele_delta:new p.aI(h,e.u_ele_delta)}),terrainCoords:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_terrain_coords_id:new p.aI(h,e.u_terrain_coords_id),u_ele_delta:new p.aI(h,e.u_ele_delta)}),sky:(h,e)=>({u_sky_color:new p.aL(h,e.u_sky_color),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon:new p.aI(h,e.u_horizon),u_sky_horizon_blend:new p.aI(h,e.u_sky_horizon_blend)})};class kr{constructor(e,n,a){this.context=e;const o=e.gl;this.buffer=o.createBuffer(),this.dynamicDraw=!!a,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const hc={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Wa{constructor(e,n,a,o){this.length=n.length,this.attributes=a,this.itemSize=n.bytesPerElement,this.dynamicDraw=o,this.context=e;const c=e.gl;this.buffer=c.createBuffer(),e.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.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 n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,n){for(let a=0;a0){const ae=p.H();p.aQ(ae,F.placementInvProjMatrix,h.transform.glCoordMatrix),p.aQ(ae,ae,F.placementViewportMatrix),y.push({circleArray:ee,circleOffset:T,transform:X.posMatrix,invTransform:ae,coord:X}),b+=ee.length/4,T=b}Y&&_.draw(c,m.LINES,it.disabled,vt.disabled,h.colorModeForRenderPass(),gt.disabled,{u_matrix:X.posMatrix,u_pixel_extrude_scale:[1/(S=h.transform).width,1/S.height]},h.style.map.terrain&&h.style.map.terrain.getTerrainData(X),n.id,Y.layoutVertexBuffer,Y.indexBuffer,Y.segments,null,h.transform.zoom,null,null,Y.collisionVertexBuffer)}var S;if(!o||!y.length)return;const k=h.useProgram("collisionCircle"),D=new p.aR;D.resize(4*b),D._trim();let B=0;for(const Z of y)for(let X=0;X=0&&(Z[F.associatedIconIndex]={shiftedAnchor:qe,angle:Tt})}else Ne(F.numGlyphs,N)}if(b){q.clear();const X=h.icon.placedSymbolArray;for(let F=0;Fh.style.map.terrain.getElevation(we,is,rs):null,In=n.layout.get("text-rotation-alignment")==="map";R(Re,we.posMatrix,h,o,es,ts,Z,b,In,N,we.toUnwrapped(),B.width,B.height,ir,at)}const rr=we.posMatrix,nr=o&&_e||ko,tn=X||nr?Ts:es,gr=va,ei=Ce&&n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let ci;ci=Ce?Re.iconsInText?Ga(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,oi,bi,ke):vs(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,o,oi,!0,ke):rl(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,o,oi,ke);const Zi={program:Ye,buffers:Xe,uniformValues:ci,atlasTexture:mr,atlasTextureIcon:li,atlasInterpolation:It,atlasInterpolationIcon:Ei,isSDF:Ce,hasHalo:ei};if(ee&&Re.canOverlap){ae=!0;const at=Xe.segments.get();for(const In of at)Pe.push({segments:new p.a0([In]),sortKey:In.sortKey,state:Zi,terrainData:St})}else Pe.push({segments:Xe.segments,sortKey:0,state:Zi,terrainData:St})}ae&&Pe.sort((we,be)=>we.sortKey-be.sortKey);for(const we of Pe){const be=we.state;if(k.activeTexture.set(D.TEXTURE0),be.atlasTexture.bind(be.atlasInterpolation,D.CLAMP_TO_EDGE),be.atlasTextureIcon&&(k.activeTexture.set(D.TEXTURE1),be.atlasTextureIcon&&be.atlasTextureIcon.bind(be.atlasInterpolationIcon,D.CLAMP_TO_EDGE)),be.isSDF){const Re=be.uniformValues;be.hasHalo&&(Re.u_is_halo=1,so(be.buffers,we.segments,n,h,be.program,fe,T,S,Re,we.terrainData)),Re.u_is_halo=0}so(be.buffers,we.segments,n,h,be.program,fe,T,S,be.uniformValues,we.terrainData)}}function so(h,e,n,a,o,c,m,_,y,b){const T=a.context;o.draw(T,T.gl.TRIANGLES,c,m,_,gt.disabled,y,b,n.id,h.layoutVertexBuffer,h.indexBuffer,e,n.paint,a.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function ao(h,e,n,a){const o=h.context,c=o.gl,m=vt.disabled,_=new Rt([c.ONE,c.ONE],p.aM.transparent,[!0,!0,!0,!0]),y=e.getBucket(n);if(!y)return;const b=a.key;let T=n.heatmapFbos.get(b);T||(T=Ss(o,e.tileSize,e.tileSize),n.heatmapFbos.set(b,T)),o.bindFramebuffer.set(T.framebuffer),o.viewport.set([0,0,e.tileSize,e.tileSize]),o.clear({color:p.aM.transparent});const S=y.programConfigurations.get(n.id),k=h.useProgram("heatmap",S),D=h.style.map.terrain.getTerrainData(a);k.draw(o,c.TRIANGLES,it.disabled,m,_,gt.disabled,ki(a.posMatrix,e,h.transform.zoom,n.paint.get("heatmap-intensity")),D,n.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,n.paint,h.transform.zoom,S)}function bn(h,e,n){const a=h.context,o=a.gl;a.setColorMode(h.colorModeForRenderPass());const c=Is(a,e),m=n.key,_=e.heatmapFbos.get(m);_&&(a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,_.colorAttachment.get()),a.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE),h.useProgram("heatmapTexture").draw(a,o.TRIANGLES,it.disabled,vt.disabled,h.colorModeForRenderPass(),gt.disabled,Hs(h,e,0,1),null,e.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments,e.paint,h.transform.zoom),_.destroy(),e.heatmapFbos.delete(m))}function Ss(h,e,n){var a,o;const c=h.gl,m=c.createTexture();c.bindTexture(c.TEXTURE_2D,m),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);const _=(a=h.HALF_FLOAT)!==null&&a!==void 0?a:c.UNSIGNED_BYTE,y=(o=h.RGBA16F)!==null&&o!==void 0?o:c.RGBA;c.texImage2D(c.TEXTURE_2D,0,y,e,n,0,c.RGBA,_,null);const b=h.createFramebuffer(e,n,!1,!1);return b.colorAttachment.set(m),b}function Is(h,e){return e.colorRampTexture||(e.colorRampTexture=new et(h,e.colorRamp,h.gl.RGBA)),e.colorRampTexture}function Vn(h,e,n,a,o){if(!n||!a||!a.imageAtlas)return;const c=a.imageAtlas.patternPositions;let m=c[n.to.toString()],_=c[n.from.toString()];if(!m&&_&&(m=_),!_&&m&&(_=m),!m||!_){const y=o.getPaintProperty(e);m=c[y],_=c[y]}m&&_&&h.setConstantPatternPositions(m,_)}function Ps(h,e,n,a,o,c,m){const _=h.context.gl,y="fill-pattern",b=n.paint.get(y),T=b&&b.constantOr(1),S=n.getCrossfadeParameters();let k,D,B,N,q;m?(D=T&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",k=_.LINES):(D=T?"fillPattern":"fill",k=_.TRIANGLES);const Z=b.constantOr(null);for(const X of a){const F=e.getTile(X);if(T&&!F.patternsLoaded())continue;const Y=F.getBucket(n);if(!Y)continue;const ee=Y.programConfigurations.get(n.id),ae=h.useProgram(D,ee),fe=h.style.map.terrain&&h.style.map.terrain.getTerrainData(X);T&&(h.context.activeTexture.set(_.TEXTURE0),F.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),ee.updatePaintBuffers(S)),Vn(ee,y,Z,F,n);const _e=fe?X:null,Pe=h.translatePosMatrix(_e?_e.posMatrix:X.posMatrix,F,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(m){N=Y.indexBuffer2,q=Y.segments2;const ke=[_.drawingBufferWidth,_.drawingBufferHeight];B=D==="fillOutlinePattern"&&T?Qo(Pe,h,S,F,ke):sc(Pe,ke)}else N=Y.indexBuffer,q=Y.segments,B=T?Yo(Pe,h,S,F):Rn(Pe);ae.draw(h.context,k,o,h.stencilModeForClipping(X),c,gt.disabled,B,fe,n.id,Y.layoutVertexBuffer,N,q,n.paint,h.transform.zoom,ee)}}function ia(h,e,n,a,o,c,m){const _=h.context,y=_.gl,b="fill-extrusion-pattern",T=n.paint.get(b),S=T.constantOr(1),k=n.getCrossfadeParameters(),D=n.paint.get("fill-extrusion-opacity"),B=T.constantOr(null);for(const N of a){const q=e.getTile(N),Z=q.getBucket(n);if(!Z)continue;const X=h.style.map.terrain&&h.style.map.terrain.getTerrainData(N),F=Z.programConfigurations.get(n.id),Y=h.useProgram(S?"fillExtrusionPattern":"fillExtrusion",F);S&&(h.context.activeTexture.set(y.TEXTURE0),q.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),F.updatePaintBuffers(k)),Vn(F,b,B,q,n);const ee=h.translatePosMatrix(N.posMatrix,q,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ae=n.paint.get("fill-extrusion-vertical-gradient"),fe=S?Gs(ee,h,ae,D,N,k,q):ys(ee,h,ae,D);Y.draw(_,_.gl.TRIANGLES,o,c,m,gt.backCCW,fe,X,n.id,Z.layoutVertexBuffer,Z.indexBuffer,Z.segments,n.paint,h.transform.zoom,F,h.style.map.terrain&&Z.centroidVertexBuffer)}}function Nn(h,e,n,a,o,c,m){const _=h.context,y=_.gl,b=n.fbo;if(!b)return;const T=h.useProgram("hillshade"),S=h.style.map.terrain&&h.style.map.terrain.getTerrainData(e);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b.colorAttachment.get()),T.draw(_,y.TRIANGLES,o,c,m,gt.disabled,((k,D,B,N)=>{const q=B.paint.get("hillshade-shadow-color"),Z=B.paint.get("hillshade-highlight-color"),X=B.paint.get("hillshade-accent-color");let F=B.paint.get("hillshade-illumination-direction")*(Math.PI/180);B.paint.get("hillshade-illumination-anchor")==="viewport"&&(F-=k.transform.angle);const Y=!k.options.moving;return{u_matrix:N?N.posMatrix:k.transform.calculatePosMatrix(D.tileID.toUnwrapped(),Y),u_image:0,u_latrange:Xs(0,D.tileID),u_light:[B.paint.get("hillshade-exaggeration"),F],u_shadow:q,u_highlight:Z,u_accent:X}})(h,n,a,S?e:null),S,a.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments)}function Un(h,e,n,a,o,c){const m=h.context,_=m.gl,y=e.dem;if(y&&y.data){const b=y.dim,T=y.stride,S=y.getPixels();if(m.activeTexture.set(_.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||h.getTileTexture(T),e.demTexture){const D=e.demTexture;D.update(S,{premultiply:!1}),D.bind(_.NEAREST,_.CLAMP_TO_EDGE)}else e.demTexture=new et(m,S,_.RGBA,{premultiply:!1}),e.demTexture.bind(_.NEAREST,_.CLAMP_TO_EDGE);m.activeTexture.set(_.TEXTURE0);let k=e.fbo;if(!k){const D=new et(m,{width:b,height:b,data:null},_.RGBA);D.bind(_.LINEAR,_.CLAMP_TO_EDGE),k=e.fbo=m.createFramebuffer(b,b,!0,!1),k.colorAttachment.set(D.texture)}m.bindFramebuffer.set(k.framebuffer),m.viewport.set([0,0,b,b]),h.useProgram("hillshadePrepare").draw(m,_.TRIANGLES,a,o,c,gt.disabled,((D,B)=>{const N=B.stride,q=p.H();return p.aP(q,0,p.X,-p.X,0,0,1),p.J(q,q,[0,-p.X,0]),{u_matrix:q,u_image:1,u_dimension:[N,N],u_zoom:D.overscaledZ,u_unpack:B.getUnpackVector()}})(e.tileID,y),null,n.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments),e.needsHillshadePrepare=!1}}function gl(h,e,n,a,o,c){const m=a.paint.get("raster-fade-duration");if(!c&&m>0){const _=ue.now(),y=(_-h.timeAdded)/m,b=e?(_-e.timeAdded)/m:-1,T=n.getSource(),S=o.coveringZoomLevel({tileSize:T.tileSize,roundZoom:T.roundZoom}),k=!e||Math.abs(e.tileID.overscaledZ-S)>Math.abs(h.tileID.overscaledZ-S),D=k&&h.refreshedUponExpiration?1:p.ac(k?y:1-b,0,1);return h.refreshedUponExpiration&&y>=1&&(h.refreshedUponExpiration=!1),e?{opacity:1,mix:1-D}:{opacity:D,mix:0}}return{opacity:1,mix:0}}const oo=new p.aM(1,0,0,1),ct=new p.aM(0,1,0,1),ra=new p.aM(0,0,1,1),vc=new p.aM(1,0,1,1),_l=new p.aM(0,1,1,1);function jn(h,e,n,a){na(h,0,e+n/2,h.transform.width,n,a)}function yl(h,e,n,a){na(h,e-n/2,0,n,h.transform.height,a)}function na(h,e,n,a,o,c){const m=h.context,_=m.gl;_.enable(_.SCISSOR_TEST),_.scissor(e*h.pixelRatio,n*h.pixelRatio,a*h.pixelRatio,o*h.pixelRatio),m.clear({color:c}),_.disable(_.SCISSOR_TEST)}function xl(h,e,n){const a=h.context,o=a.gl,c=n.posMatrix,m=h.useProgram("debug"),_=it.disabled,y=vt.disabled,b=h.colorModeForRenderPass(),T="$debug",S=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);a.activeTexture.set(o.TEXTURE0);const k=e.getTileByID(n.key).latestRawTileData,D=Math.floor((k&&k.byteLength||0)/1024),B=e.getTile(n).tileSize,N=512/Math.min(B,512)*(n.overscaledZ/h.transform.zoom)*.5;let q=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(q+=` => ${n.overscaledZ}`),function(Z,X){Z.initDebugOverlayCanvas();const F=Z.debugOverlayCanvas,Y=Z.context.gl,ee=Z.debugOverlayCanvas.getContext("2d");ee.clearRect(0,0,F.width,F.height),ee.shadowColor="white",ee.shadowBlur=2,ee.lineWidth=1.5,ee.strokeStyle="white",ee.textBaseline="top",ee.font="bold 36px Open Sans, sans-serif",ee.fillText(X,5,5),ee.strokeText(X,5,5),Z.debugOverlayTexture.update(F),Z.debugOverlayTexture.bind(Y.LINEAR,Y.CLAMP_TO_EDGE)}(h,`${q} ${D}kB`),m.draw(a,o.TRIANGLES,_,y,Rt.alphaBlended,gt.disabled,xs(c,p.aM.transparent,N),null,T,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),m.draw(a,o.LINE_STRIP,_,y,b,gt.disabled,xs(c,p.aM.red),S,T,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function vl(h,e,n){const a=h.context,o=a.gl,c=h.colorModeForRenderPass(),m=new it(o.LEQUAL,it.ReadWrite,h.depthRangeFor3D),_=h.useProgram("terrain"),y=e.getTerrainMesh();a.bindFramebuffer.set(null),a.viewport.set([0,0,h.width,h.height]);for(const b of n){const T=h.renderToTexture.getTexture(b),S=e.getTerrainData(b.tileID);a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,T.texture);const k=h.transform.calculatePosMatrix(b.tileID.toUnwrapped()),D=e.getMeshFrameDelta(h.transform.zoom),B=h.transform.calculateFogMatrix(b.tileID.toUnwrapped()),N=qa(k,D,B,h.style.sky,h.transform.pitch);_.draw(a,o.TRIANGLES,m,vt.disabled,c,gt.backCCW,N,S,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}class sa{constructor(e,n,a){this.vertexBuffer=e,this.indexBuffer=n,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class aa{constructor(e,n){this.context=new xc(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:p.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=$e.maxUnderzooming+$e.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new ja}resize(e,n,a){if(this.width=Math.floor(e*a),this.height=Math.floor(n*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const o of this.style._order)this.style._layers[o].resize()}setup(){const e=this.context,n=new p.aX;n.emplaceBack(0,0),n.emplaceBack(p.X,0),n.emplaceBack(0,p.X),n.emplaceBack(p.X,p.X),this.tileExtentBuffer=e.createVertexBuffer(n,fn.members),this.tileExtentSegments=p.a0.simpleSegment(0,0,4,2);const a=new p.aX;a.emplaceBack(0,0),a.emplaceBack(p.X,0),a.emplaceBack(0,p.X),a.emplaceBack(p.X,p.X),this.debugBuffer=e.createVertexBuffer(a,fn.members),this.debugSegments=p.a0.simpleSegment(0,0,4,5);const o=new p.$;o.emplaceBack(0,0,0,0),o.emplaceBack(p.X,0,p.X,0),o.emplaceBack(0,p.X,0,p.X),o.emplaceBack(p.X,p.X,p.X,p.X),this.rasterBoundsBuffer=e.createVertexBuffer(o,Kr.members),this.rasterBoundsSegments=p.a0.simpleSegment(0,0,4,2);const c=new p.aX;c.emplaceBack(0,0),c.emplaceBack(1,0),c.emplaceBack(0,1),c.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(c,fn.members),this.viewportSegments=p.a0.simpleSegment(0,0,4,2);const m=new p.aZ;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(m);const _=new p.aY;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(_);const y=this.context.gl;this.stencilClearMode=new vt({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){const e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const a=p.H();p.aP(a,0,this.width,this.height,0,0,1),p.K(a,a,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(e,n.TRIANGLES,it.disabled,this.stencilClearMode,Rt.disabled,gt.disabled,Mi(a),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,n){if(this.currentStencilSource===e.source||!e.isTileClipped()||!n||!n.length)return;this.currentStencilSource=e.source;const a=this.context,o=a.gl;this.nextStencilID+n.length>256&&this.clearStencil(),a.setColorMode(Rt.disabled),a.setDepthMode(it.disabled);const c=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const m of n){const _=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);c.draw(a,o.TRIANGLES,it.disabled,new vt({func:o.ALWAYS,mask:0},_,255,o.KEEP,o.KEEP,o.REPLACE),Rt.disabled,gt.disabled,Mi(m.posMatrix),y,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,n=this.context.gl;return new vt({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){const n=this.context.gl;return new vt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(e){const n=this.context.gl,a=e.sort((m,_)=>_.overscaledZ-m.overscaledZ),o=a[a.length-1].overscaledZ,c=a[0].overscaledZ-o+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();const m={};for(let _=0;_({u_sky_color:Z.properties.get("sky-color"),u_horizon_color:Z.properties.get("horizon-color"),u_horizon:(X.height/2+X.getHorizon())*F,u_sky_horizon_blend:Z.properties.get("sky-horizon-blend")*X.height/2*F}))(b,y.style.map.transform,y.pixelRatio),D=new it(S.LEQUAL,it.ReadWrite,[0,1]),B=vt.disabled,N=y.colorModeForRenderPass(),q=y.useProgram("sky");if(!b.mesh){const Z=new p.aX;Z.emplaceBack(-1,-1),Z.emplaceBack(1,-1),Z.emplaceBack(1,1),Z.emplaceBack(-1,1);const X=new p.aY;X.emplaceBack(0,1,2),X.emplaceBack(0,2,3),b.mesh=new sa(T.createVertexBuffer(Z,fn.members),T.createIndexBuffer(X),p.a0.simpleSegment(0,0,Z.length,X.length))}q.draw(T,S.TRIANGLES,D,B,N,gt.disabled,k,void 0,"sky",b.mesh.vertexBuffer,b.mesh.indexBuffer,b.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const y=this.style._layers[a[this.currentLayer]],b=o[y.source],T=c[y.source];this._renderTileClippingMasks(y,T),this.renderLayer(this,b,y,T)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayerq.source&&!q.isHidden(T)?[b.sourceCaches[q.source]]:[]),D=k.filter(q=>q.getSource().type==="vector"),B=k.filter(q=>q.getSource().type!=="vector"),N=q=>{(!S||S.getSource().maxzoomN(q)),S||B.forEach(q=>N(q)),S}(this.style,this.transform.zoom);y&&function(b,T,S){for(let k=0;k0),o&&(p.b0(n,a),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(c,m){const _=c.context,y=_.gl,b=Rt.unblended,T=new it(y.LEQUAL,it.ReadWrite,[0,1]),S=m.getTerrainMesh(),k=m.sourceCache.getRenderableTiles(),D=c.useProgram("terrainDepth");_.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:p.aM.transparent,depth:1});for(const B of k){const N=m.getTerrainData(B.tileID),q={u_matrix:c.transform.calculatePosMatrix(B.tileID.toUnwrapped()),u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};D.draw(_,y.TRIANGLES,T,vt.disabled,b,gt.backCCW,q,N,"terrain",S.vertexBuffer,S.indexBuffer,S.segments)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])}(this,this.style.map.terrain),function(c,m){const _=c.context,y=_.gl,b=Rt.unblended,T=new it(y.LEQUAL,it.ReadWrite,[0,1]),S=m.getTerrainMesh(),k=m.getCoordsTexture(),D=m.sourceCache.getRenderableTiles(),B=c.useProgram("terrainCoords");_.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:p.aM.transparent,depth:1}),m.coordsIndex=[];for(const N of D){const q=m.getTerrainData(N.tileID);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,k.texture);const Z={u_matrix:c.transform.calculatePosMatrix(N.tileID.toUnwrapped()),u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};B.draw(_,y.TRIANGLES,T,vt.disabled,b,gt.backCCW,Z,q,"terrain",S.vertexBuffer,S.indexBuffer,S.segments),m.coordsIndex.push(N.tileID.key)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])}(this,this.style.map.terrain))}renderLayer(e,n,a,o){if(!a.isHidden(this.transform.zoom)&&(a.type==="background"||a.type==="custom"||(o||[]).length))switch(this.id=a.id,a.type){case"symbol":(function(c,m,_,y,b){if(c.renderPass!=="translucent")return;const T=vt.disabled,S=c.colorModeForRenderPass();(_._unevaluatedLayout.hasValue("text-variable-anchor")||_._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(k,D,B,N,q,Z,X,F,Y){const ee=D.transform,ae=pn(),fe=q==="map",_e=Z==="map";for(const Pe of k){const ke=N.getTile(Pe),we=ke.getBucket(B);if(!we||!we.text||!we.text.segments.get().length)continue;const be=p.ag(we.textSizeData,ee.zoom),Re=rt(ke,1,D.transform.zoom),Xe=Yr(Pe.posMatrix,_e,fe,D.transform,Re),Se=B.layout.get("icon-text-fit")!=="none"&&we.hasIconData();if(be){const Ce=Math.pow(2,ee.zoom-ke.tileID.overscaledZ),qe=D.style.map.terrain?(Ye,nt)=>D.style.map.terrain.getElevation(Pe,Ye,nt):null,Tt=ae.translatePosition(ee,ke,X,F);On(we,fe,_e,Y,ee,Xe,Pe.posMatrix,Ce,be,Se,ae,Tt,Pe.toUnwrapped(),qe)}}}(y,c,_,m,_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),b),_.paint.get("icon-opacity").constantOr(1)!==0&&no(c,m,_,y,!1,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),_.layout.get("icon-rotation-alignment"),_.layout.get("icon-pitch-alignment"),_.layout.get("icon-keep-upright"),T,S),_.paint.get("text-opacity").constantOr(1)!==0&&no(c,m,_,y,!0,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.layout.get("text-keep-upright"),T,S),m.map.showCollisionBoxes&&(ws(c,m,_,y,!0),ws(c,m,_,y,!1))})(e,n,a,o,this.style.placement.variableOffsets);break;case"circle":(function(c,m,_,y){if(c.renderPass!=="translucent")return;const b=_.paint.get("circle-opacity"),T=_.paint.get("circle-stroke-width"),S=_.paint.get("circle-stroke-opacity"),k=!_.layout.get("circle-sort-key").isConstant();if(b.constantOr(1)===0&&(T.constantOr(1)===0||S.constantOr(1)===0))return;const D=c.context,B=D.gl,N=c.depthModeForSublayer(0,it.ReadOnly),q=vt.disabled,Z=c.colorModeForRenderPass(),X=[];for(let F=0;FF.sortKey-Y.sortKey);for(const F of X){const{programConfiguration:Y,program:ee,layoutVertexBuffer:ae,indexBuffer:fe,uniformValues:_e,terrainData:Pe}=F.state;ee.draw(D,B.TRIANGLES,N,q,Z,gt.disabled,_e,Pe,_.id,ae,fe,F.segments,_.paint,c.transform.zoom,Y)}})(e,n,a,o);break;case"heatmap":(function(c,m,_,y){if(_.paint.get("heatmap-opacity")===0)return;const b=c.context;if(c.style.map.terrain){for(const T of y){const S=m.getTile(T);m.hasRenderableParent(T)||(c.renderPass==="offscreen"?ao(c,S,_,T):c.renderPass==="translucent"&&bn(c,_,T))}b.viewport.set([0,0,c.width,c.height])}else c.renderPass==="offscreen"?function(T,S,k,D){const B=T.context,N=B.gl,q=vt.disabled,Z=new Rt([N.ONE,N.ONE],p.aM.transparent,[!0,!0,!0,!0]);(function(X,F,Y){const ee=X.gl;X.activeTexture.set(ee.TEXTURE1),X.viewport.set([0,0,F.width/4,F.height/4]);let ae=Y.heatmapFbos.get(p.aU);ae?(ee.bindTexture(ee.TEXTURE_2D,ae.colorAttachment.get()),X.bindFramebuffer.set(ae.framebuffer)):(ae=Ss(X,F.width/4,F.height/4),Y.heatmapFbos.set(p.aU,ae))})(B,T,k),B.clear({color:p.aM.transparent});for(let X=0;X20&&T.texParameterf(T.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);const we=c.style.map.terrain&&c.style.map.terrain.getTerrainData(X),be=we?X:null,Re=be?be.posMatrix:c.transform.calculatePosMatrix(X.toUnwrapped(),Z),Xe=lc(Re,Pe||[0,0],_e||1,fe,_);S instanceof Nr?k.draw(b,T.TRIANGLES,F,vt.disabled,D,gt.disabled,Xe,we,_.id,S.boundsBuffer,c.quadTriangleIndexBuffer,S.boundsSegments):k.draw(b,T.TRIANGLES,F,B[X.overscaledZ],D,gt.disabled,Xe,we,_.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments)}})(e,n,a,o);break;case"background":(function(c,m,_,y){const b=_.paint.get("background-color"),T=_.paint.get("background-opacity");if(T===0)return;const S=c.context,k=S.gl,D=c.transform,B=D.tileSize,N=_.paint.get("background-pattern");if(c.isPatternMissing(N))return;const q=!N&&b.a===1&&T===1&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==q)return;const Z=vt.disabled,X=c.depthModeForSublayer(0,q==="opaque"?it.ReadWrite:it.ReadOnly),F=c.colorModeForRenderPass(),Y=c.useProgram(N?"backgroundPattern":"background"),ee=y||D.coveringTiles({tileSize:B,terrain:c.style.map.terrain});N&&(S.activeTexture.set(k.TEXTURE0),c.imageManager.bind(c.context));const ae=_.getCrossfadeParameters();for(const fe of ee){const _e=y?fe.posMatrix:c.transform.calculatePosMatrix(fe.toUnwrapped()),Pe=N?Ha(_e,T,c,N,{tileID:fe,tileSize:B},ae):Ks(_e,T,b),ke=c.style.map.terrain&&c.style.map.terrain.getTerrainData(fe);Y.draw(S,k.TRIANGLES,X,Z,F,gt.disabled,Pe,ke,_.id,c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}})(e,0,a,o);break;case"custom":(function(c,m,_){const y=c.context,b=_.implementation;if(c.renderPass==="offscreen"){const T=b.prerender;T&&(c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),T.call(b,y.gl,c.transform.customLayerMatrix()),y.setDirty(),c.setBaseState())}else if(c.renderPass==="translucent"){c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),y.setStencilMode(vt.disabled);const T=b.renderingMode==="3d"?new it(c.context.gl.LEQUAL,it.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,it.ReadOnly);y.setDepthMode(T),b.render(y.gl,c.transform.customLayerMatrix(),{farZ:c.transform.farZ,nearZ:c.transform.nearZ,fov:c.transform._fov,modelViewProjectionMatrix:c.transform.modelViewProjectionMatrix,projectionMatrix:c.transform.projectionMatrix}),y.setDirty(),c.setBaseState(),y.bindFramebuffer.set(null)}})(e,0,a)}}translatePosMatrix(e,n,a,o,c){if(!a[0]&&!a[1])return e;const m=c?o==="map"?this.transform.angle:0:o==="viewport"?-this.transform.angle:0;if(m){const b=Math.sin(m),T=Math.cos(m);a=[a[0]*T-a[1]*b,a[0]*b+a[1]*T]}const _=[c?a[0]:rt(n,a[0],this.transform.zoom),c?a[1]:rt(n,a[1],this.transform.zoom),0],y=new Float32Array(16);return p.J(y,e,_),y}saveTileTexture(e){const n=this._tileTextures[e.size[0]];n?n.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const n=this._tileTextures[e];return n&&n.length>0?n.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const n=this.imageManager.getPattern(e.from.toString()),a=this.imageManager.getPattern(e.to.toString());return!n||!a}useProgram(e,n){this.cache=this.cache||{};const a=e+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[a]||(this.cache[a]=new Za(this.context,Qr[e],n,Xa[e],this._showOverdrawInspector,this.style.map.terrain)),this.cache[a]}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(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new et(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:n}=this.context.gl;return this.width!==e||this.height!==n}}class $n{constructor(e,n){this.points=e,this.planes=n}static fromInvProjectionMatrix(e,n,a){const o=Math.pow(2,a),c=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(_=>{const y=1/(_=p.af([],_,e))[3]/n*o;return p.b1(_,_,[y,y,1/_[3],y])}),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(_=>{const y=function(k,D){var B=D[0],N=D[1],q=D[2],Z=B*B+N*N+q*q;return Z>0&&(Z=1/Math.sqrt(Z)),k[0]=D[0]*Z,k[1]=D[1]*Z,k[2]=D[2]*Z,k}([],function(k,D,B){var N=D[0],q=D[1],Z=D[2],X=B[0],F=B[1],Y=B[2];return k[0]=q*Y-Z*F,k[1]=Z*X-N*Y,k[2]=N*F-q*X,k}([],gi([],c[_[0]],c[_[1]]),gi([],c[_[2]],c[_[1]]))),b=-((T=y)[0]*(S=c[_[1]])[0]+T[1]*S[1]+T[2]*S[2]);var T,S;return y.concat(b)});return new $n(c,m)}}class qn{constructor(e,n){this.min=e,this.max=n,this.center=function(a,o,c){return a[0]=.5*o[0],a[1]=.5*o[1],a[2]=.5*o[2],a}([],function(a,o,c){return a[0]=o[0]+c[0],a[1]=o[1]+c[1],a[2]=o[2]+c[2],a}([],this.min,this.max))}quadrant(e){const n=[e%2==0,e<2],a=mi(this.min),o=mi(this.max);for(let c=0;c=0&&m++;if(m===0)return 0;m!==n.length&&(a=!1)}if(a)return 2;for(let o=0;o<3;o++){let c=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let _=0;_this.max[o]-this.min[o])return 0}return 1}}class Zn{constructor(e=0,n=0,a=0,o=0){if(isNaN(e)||e<0||isNaN(n)||n<0||isNaN(a)||a<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=n,this.left=a,this.right=o}interpolate(e,n,a){return n.top!=null&&e.top!=null&&(this.top=p.y.number(e.top,n.top,a)),n.bottom!=null&&e.bottom!=null&&(this.bottom=p.y.number(e.bottom,n.bottom,a)),n.left!=null&&e.left!=null&&(this.left=p.y.number(e.left,n.left,a)),n.right!=null&&e.right!=null&&(this.right=p.y.number(e.right,n.right,a)),this}getCenter(e,n){const a=p.ac((this.left+e-this.right)/2,0,e),o=p.ac((this.top+n-this.bottom)/2,0,n);return new p.P(a,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Zn(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const lo=85.051129;class Gn{constructor(e,n,a,o,c){this.tileSize=512,this._renderWorldCopies=c===void 0||!!c,this._minZoom=e||0,this._maxZoom=n||22,this._minPitch=a??0,this._maxPitch=o??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new p.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Zn,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const e=new Gn(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return e.apply(this),e}apply(e){this.tileSize=e.tileSize,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.angle=e.angle,this._fov=e._fov,this._pitch=e._pitch,this._unmodified=e._unmodified,this._edgeInsets=e._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new p.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(e){const n=-p.b3(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=function(){var a=new p.A(4);return p.A!=Float32Array&&(a[1]=0,a[2]=0),a[0]=1,a[3]=1,a}(),function(a,o,c){var m=o[0],_=o[1],y=o[2],b=o[3],T=Math.sin(c),S=Math.cos(c);a[0]=m*S+y*T,a[1]=_*S+b*T,a[2]=m*-T+y*S,a[3]=_*-T+b*S}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const n=p.ac(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(e){const n=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(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)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,n,a){this._unmodified=!1,this._edgeInsets.interpolate(e,n,a),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const n=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(e){const n=[new p.b4(0,e)];if(this._renderWorldCopies){const a=this.pointCoordinate(new p.P(0,0)),o=this.pointCoordinate(new p.P(this.width,0)),c=this.pointCoordinate(new p.P(this.width,this.height)),m=this.pointCoordinate(new p.P(0,this.height)),_=Math.floor(Math.min(a.x,o.x,c.x,m.x)),y=Math.floor(Math.max(a.x,o.x,c.x,m.x)),b=1;for(let T=_-b;T<=y+b;T++)T!==0&&n.push(new p.b4(T,e))}return n}coveringTiles(e){var n,a;let o=this.coveringZoomLevel(e);const c=o;if(e.minzoom!==void 0&&oe.maxzoom&&(o=e.maxzoom);const m=this.pointCoordinate(this.getCameraPoint()),_=p.Z.fromLngLat(this.center),y=Math.pow(2,o),b=[y*m.x,y*m.y,0],T=[y*_.x,y*_.y,0],S=$n.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,o);let k=e.minzoom||0;!e.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(k=o);const D=e.terrain?2/Math.min(this.tileSize,e.tileSize)*this.tileSize:3,B=F=>({aabb:new qn([F*y,0,0],[(F+1)*y,y,0]),zoom:0,x:0,y:0,wrap:F,fullyVisible:!1}),N=[],q=[],Z=o,X=e.reparseOverscaled?c:o;if(this._renderWorldCopies)for(let F=1;F<=3;F++)N.push(B(-F)),N.push(B(F));for(N.push(B(0));N.length>0;){const F=N.pop(),Y=F.x,ee=F.y;let ae=F.fullyVisible;if(!ae){const we=F.aabb.intersects(S);if(we===0)continue;ae=we===2}const fe=e.terrain?b:T,_e=F.aabb.distanceX(fe),Pe=F.aabb.distanceY(fe),ke=Math.max(Math.abs(_e),Math.abs(Pe));if(F.zoom===Z||ke>D+(1<=k){const we=Z-F.zoom,be=b[0]-.5-(Y<>1),Xe=F.zoom+1;let Se=F.aabb.quadrant(we);if(e.terrain){const Ce=new p.S(Xe,F.wrap,Xe,be,Re),qe=e.terrain.getMinMaxElevation(Ce),Tt=(n=qe.minElevation)!==null&&n!==void 0?n:this.elevation,Ye=(a=qe.maxElevation)!==null&&a!==void 0?a:this.elevation;Se=new qn([Se.min[0],Se.min[1],Tt],[Se.max[0],Se.max[1],Ye])}N.push({aabb:Se,zoom:Xe,x:be,y:Re,wrap:F.wrap,fullyVisible:ae})}}return q.sort((F,Y)=>F.distanceSq-Y.distanceSq).map(F=>F.tileID)}resize(e,n){this.width=e,this.height=n,this.pixelsToGLUnits=[2/e,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){const n=p.ac(e.lat,-85.051129,lo);return new p.P(p.O(e.lng)*this.worldSize,p.Q(n)*this.worldSize)}unproject(e){return new p.Z(e.x/this.worldSize,e.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(e){const n=this.elevation,a=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,o=this.pointLocation(this.centerPoint,e),c=e.getElevationForLngLatZoom(o,this.tileZoom);if(!(this.elevation-c))return;const m=a+n-c,_=Math.cos(this._pitch)*this.cameraToCenterDistance/m/p.b5(1,o.lat),y=this.scaleZoom(_/this.tileSize);this._elevation=c,this._center=o,this.zoom=y}setLocationAtPoint(e,n){const a=this.pointCoordinate(n),o=this.pointCoordinate(this.centerPoint),c=this.locationCoordinate(e),m=new p.Z(c.x-(a.x-o.x),c.y-(a.y-o.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(e,n){return n?this.coordinatePoint(this.locationCoordinate(e),n.getElevationForLngLatZoom(e,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(e))}pointLocation(e,n){return this.coordinateLocation(this.pointCoordinate(e,n))}locationCoordinate(e){return p.Z.fromLngLat(e)}coordinateLocation(e){return e&&e.toLngLat()}pointCoordinate(e,n){if(n){const k=n.pointCoordinate(e);if(k!=null)return k}const a=[e.x,e.y,0,1],o=[e.x,e.y,1,1];p.af(a,a,this.pixelMatrixInverse),p.af(o,o,this.pixelMatrixInverse);const c=a[3],m=o[3],_=a[1]/c,y=o[1]/m,b=a[2]/c,T=o[2]/m,S=b===T?0:(0-b)/(T-b);return new p.Z(p.y.number(a[0]/c,o[0]/m,S)/this.worldSize,p.y.number(_,y,S)/this.worldSize)}coordinatePoint(e,n=0,a=this.pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,n,1];return p.af(o,o,a),new p.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this.height/2-this.getHorizon());return new le().extend(this.pointLocation(new p.P(0,e))).extend(this.pointLocation(new p.P(this.width,e))).extend(this.pointLocation(new p.P(this.width,this.height))).extend(this.pointLocation(new p.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new le([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(e){e?(this.lngRange=[e.getWest(),e.getEast()],this.latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,lo])}calculateTileMatrix(e){const n=e.canonical,a=this.worldSize/this.zoomScale(n.z),o=n.x+Math.pow(2,n.z)*e.wrap,c=p.an(new Float64Array(16));return p.J(c,c,[o*a,n.y*a,0]),p.K(c,c,[a/p.X,a/p.X,1]),c}calculatePosMatrix(e,n=!1){const a=e.key,o=n?this._alignedPosMatrixCache:this._posMatrixCache;if(o[a])return o[a];const c=this.calculateTileMatrix(e);return p.L(c,n?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,c),o[a]=new Float32Array(c),o[a]}calculateFogMatrix(e){const n=e.key,a=this._fogMatrixCache;if(a[n])return a[n];const o=this.calculateTileMatrix(e);return p.L(o,this.fogMatrix,o),a[n]=new Float32Array(o),a[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(e,n){n=p.ac(+n,this.minZoom,this.maxZoom);const a={center:new p.N(e.lng,e.lat),zoom:n};let o=this.lngRange;if(!this._renderWorldCopies&&o===null){const F=179.9999999999;o=[-F,F]}const c=this.tileSize*this.zoomScale(a.zoom);let m=0,_=c,y=0,b=c,T=0,S=0;const{x:k,y:D}=this.size;if(this.latRange){const F=this.latRange;m=p.Q(F[1])*c,_=p.Q(F[0])*c,_-m_&&(Z=_-F)}if(o){const F=(y+b)/2;let Y=B;this._renderWorldCopies&&(Y=p.b3(B,F-c/2,F+c/2));const ee=k/2;Y-eeb&&(q=b-ee)}if(q!==void 0||Z!==void 0){const F=new p.P(q??B,Z??N);a.center=this.unproject.call({worldSize:c},F).wrap()}return a}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:n,zoom:a}=this.getConstrained(this.center,this.zoom);this.center=n,this.zoom=a,this._unmodified=e,this._constraining=!1}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,n=this.point.x,a=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=p.b5(1,this.center.lat)*this.worldSize;let o=p.an(new Float64Array(16));p.K(o,o,[this.width/2,-this.height/2,1]),p.J(o,o,[1,-1,0]),this.labelPlaneMatrix=o,o=p.an(new Float64Array(16)),p.K(o,o,[1,-1,1]),p.J(o,o,[-1,-1,0]),p.K(o,o,[2/this.width,2/this.height,1]),this.glCoordMatrix=o;const c=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),m=Math.min(this.elevation,this.minElevationForCurrentTile),_=c-m*this._pixelPerMeter/Math.cos(this._pitch),y=m<0?_:c,b=Math.PI/2+this._pitch,T=this._fov*(.5+e.y/this.height),S=Math.sin(T)*y/Math.sin(p.ac(Math.PI-b-T,.01,Math.PI-.01)),k=this.getHorizon(),D=2*Math.atan(k/this.cameraToCenterDistance)*(.5+e.y/(2*k)),B=Math.sin(D)*y/Math.sin(p.ac(Math.PI-b-D,.01,Math.PI-.01)),N=Math.min(S,B);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*N+y),this.nearZ=this.height/50,o=new Float64Array(16),p.b6(o,this._fov,this.width/this.height,this.nearZ,this.farZ),o[8]=2*-e.x/this.width,o[9]=2*e.y/this.height,this.projectionMatrix=p.ae(o),p.K(o,o,[1,-1,1]),p.J(o,o,[0,0,-this.cameraToCenterDistance]),p.b7(o,o,this._pitch),p.ad(o,o,this.angle),p.J(o,o,[-n,-a,0]),this.mercatorMatrix=p.K([],o,[this.worldSize,this.worldSize,this.worldSize]),p.K(o,o,[1,1,this._pixelPerMeter]),this.pixelMatrix=p.L(new Float64Array(16),this.labelPlaneMatrix,o),p.J(o,o,[0,0,-this.elevation]),this.modelViewProjectionMatrix=o,this.invModelViewProjectionMatrix=p.as([],o),this.fogMatrix=new Float64Array(16),p.b6(this.fogMatrix,this._fov,this.width/this.height,c,this.farZ),this.fogMatrix[8]=2*-e.x/this.width,this.fogMatrix[9]=2*e.y/this.height,p.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),p.b7(this.fogMatrix,this.fogMatrix,this._pitch),p.ad(this.fogMatrix,this.fogMatrix,this.angle),p.J(this.fogMatrix,this.fogMatrix,[-n,-a,0]),p.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=p.L(new Float64Array(16),this.labelPlaneMatrix,o);const q=this.width%2/2,Z=this.height%2/2,X=Math.cos(this.angle),F=Math.sin(this.angle),Y=n-Math.round(n)+X*q+F*Z,ee=a-Math.round(a)+X*Z+F*q,ae=new Float64Array(o);if(p.J(ae,ae,[Y>.5?Y-1:Y,ee>.5?ee-1:ee,0]),this.alignedModelViewProjectionMatrix=ae,o=p.as(new Float64Array(16),this.pixelMatrix),!o)throw new Error("failed to invert matrix");this.pixelMatrixInverse=o,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const e=this.pointCoordinate(new p.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return p.af(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new p.P(0,e))}getCameraQueryGeometry(e){const n=this.getCameraPoint();if(e.length===1)return[e[0],n];{let a=n.x,o=n.y,c=n.x,m=n.y;for(const _ of e)a=Math.min(a,_.x),o=Math.min(o,_.y),c=Math.max(c,_.x),m=Math.max(m,_.y);return[new p.P(a,o),new p.P(c,o),new p.P(c,m),new p.P(a,m),new p.P(a,o)]}}lngLatToCameraDepth(e,n){const a=this.locationCoordinate(e),o=[a.x*this.worldSize,a.y*this.worldSize,n,1];return p.af(o,o,this.modelViewProjectionMatrix),o[2]/o[3]}}function As(h,e){let n,a=!1,o=null,c=null;const m=()=>{o=null,a&&(h.apply(c,n),o=setTimeout(m,e),a=!1)};return(..._)=>(a=!0,c=this,n=_,o||m(),o)}class oa{constructor(e){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map(o=>o.split("=")).forEach(o=>{o[0]===this._hashName&&(a=o)}),(a&&a[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(n.length>=3&&!n.some(a=>isNaN(a))){const a=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:a,pitch:+(n[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const a=n.join("/");let o=a;o.split("&").length>0&&(o=o.split("&")[0]),this._hashName&&(o=`${this._hashName}=${a}`);let c=window.location.hash.replace(o,"");c.startsWith("#&")?c=c.slice(0,1)+c.slice(2):c==="#"&&(c="");let m=window.location.href.replace(/(#.+)?$/,c);m=m.replace("&&","&"),window.history.replaceState(window.history.state,null,m)},this._updateHash=As(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 n=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,o=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,o),m=Math.round(n.lng*c)/c,_=Math.round(n.lat*c)/c,y=this._map.getBearing(),b=this._map.getPitch();let T="";if(T+=e?`/${m}/${_}/${a}`:`${a}/${_}/${m}`,(y||b)&&(T+="/"+Math.round(10*y)/10),b&&(T+=`/${Math.round(b)}`),this._hashName){const S=this._hashName;let k=!1;const D=window.location.hash.slice(1).split("&").map(B=>{const N=B.split("=")[0];return N===S?(k=!0,`${N}=${T}`):B}).filter(B=>B);return k||D.push(`${S}=${T}`),`#${D.join("&")}`}return`#${T}`}}const la={linearity:.3,easing:p.b8(0,0,.3,1)},co=p.e({deceleration:2500,maxSpeed:1400},la),bc=p.e({deceleration:20,maxSpeed:1400},la),bl=p.e({deceleration:1e3,maxSpeed:360},la),ca=p.e({deceleration:1e3,maxSpeed:90},la);class ho{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:ue.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,n=ue.now();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new p.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:c}of this._inertiaBuffer)n.zoom+=c.zoomDelta||0,n.bearing+=c.bearingDelta||0,n.pitch+=c.pitchDelta||0,c.panDelta&&n.pan._add(c.panDelta),c.around&&(n.around=c.around),c.pinchAround&&(n.pinchAround=c.pinchAround);const a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(n.pan.mag()){const c=Ms(n.pan.mag(),a,p.e({},co,e||{}));o.offset=n.pan.mult(c.amount/n.pan.mag()),o.center=this._map.transform.center,Cs(o,c)}if(n.zoom){const c=Ms(n.zoom,a,bc);o.zoom=this._map.transform.zoom+c.amount,Cs(o,c)}if(n.bearing){const c=Ms(n.bearing,a,bl);o.bearing=this._map.transform.bearing+p.ac(c.amount,-179,179),Cs(o,c)}if(n.pitch){const c=Ms(n.pitch,a,ca);o.pitch=this._map.transform.pitch+c.amount,Cs(o,c)}if(o.zoom||o.bearing){const c=n.pinchAround===void 0?n.around:n.pinchAround;o.around=c?this._map.unproject(c):this._map.getCenter()}return this.clear(),p.e(o,{noMoveStart:!0})}}function Cs(h,e){(!h.duration||h.durationn.unproject(y)),_=c.reduce((y,b,T,S)=>y.add(b.div(S.length)),new p.P(0,0));super(e,{points:c,point:_,lngLats:m,lngLat:n.unproject(_),originalEvent:a}),this._defaultPrevented=!1}}class wl extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class Tl{constructor(e,n){this._map=e,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new wl(e.type,this._map,e))}mousedown(e,n){return this._mousedownPos=n,this._firePreventable(new ai(e.type,this._map,e))}mouseup(e){this._map.fire(new ai(e.type,this._map,e))}click(e,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new ai(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ai(e.type,this._map,e))}mouseover(e){this._map.fire(new ai(e.type,this._map,e))}mouseout(e){this._map.fire(new ai(e.type,this._map,e))}touchstart(e){return this._firePreventable(new wn(e.type,this._map,e))}touchmove(e){this._map.fire(new wn(e.type,this._map,e))}touchend(e){this._map.fire(new wn(e.type,this._map,e))}touchcancel(e){this._map.fire(new wn(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Bt{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ai(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ai("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ai(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pr{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.pointLocation(p.P.convert(e),this._map.terrain)}}class $i{constructor(e,n){this._map=e,this._tr=new pr(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,n){this.isEnabled()&&e.shiftKey&&e.button===0&&(se.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(e,n){if(!this._active)return;const a=n;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)c.fitScreenCoordinates(a,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(se.remove(this._box),this._box=null),se.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new p.k(e,{originalEvent:n}))}}function ks(h,e){if(h.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${e.length}`);const n={};for(let a=0;athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),a.length===this.numTouches&&(this.centroid=function(o){const c=new p.P(0,0);for(const m of o)c._add(m);return c.div(o.length)}(n),this.touches=ks(a,n)))}touchmove(e,n,a){if(this.aborted||!this.centroid)return;const o=ks(a,n);for(const c in this.touches){const m=o[c];(!m||m.dist(this.touches[c])>30)&&(this.aborted=!0)}}touchend(e,n,a){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){const o=!this.aborted&&this.centroid;if(this.reset(),o)return o}}}class ha{constructor(e){this.singleTap=new uo(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,n,a){this.singleTap.touchstart(e,n,a)}touchmove(e,n,a){this.singleTap.touchmove(e,n,a)}touchend(e,n,a){const o=this.singleTap.touchend(e,n,a);if(o){const c=e.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(o)<30;if(c&&m||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Hn{constructor(e){this._tr=new pr(e),this._zoomIn=new ha({numTouches:1,numTaps:2}),this._zoomOut=new ha({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,n,a){this._zoomIn.touchstart(e,n,a),this._zoomOut.touchstart(e,n,a)}touchmove(e,n,a){this._zoomIn.touchmove(e,n,a),this._zoomOut.touchmove(e,n,a)}touchend(e,n,a){const o=this._zoomIn.touchend(e,n,a),c=this._zoomOut.touchend(e,n,a),m=this._tr;return o?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(o)},{originalEvent:e})}):c?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(c)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class $r{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 n=this._moveFunction(...e);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(e,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,n){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const o=n.length?n[0]:n;return!this._moved&&o.dist(a){h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=e=>{e.preventDefault()}},mo=({enable:h,clickTolerance:e,bearingDegreesPerPixelMoved:n=.8})=>{const a=new ua({checkCorrectEvent:o=>se.mouseButton(o)===0&&o.ctrlKey||se.mouseButton(o)===2});return new $r({clickTolerance:e,move:(o,c)=>({bearingDelta:(c.x-o.x)*n}),moveStateManager:a,enable:h,assignEvents:da})},go=({enable:h,clickTolerance:e,pitchDegreesPerPixelMoved:n=-.5})=>{const a=new ua({checkCorrectEvent:o=>se.mouseButton(o)===0&&o.ctrlKey||se.mouseButton(o)===2});return new $r({clickTolerance:e,move:(o,c)=>({pitchDelta:(c.y-o.y)*n}),moveStateManager:a,enable:h,assignEvents:da})};class Tn{constructor(e,n){this._clickTolerance=e.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new p.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,n,a){return this._calculateTransform(e,n,a)}touchmove(e,n,a){if(this._active){if(!this._shouldBePrevented(a.length))return e.preventDefault(),this._calculateTransform(e,n,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,n,a){this._calculateTransform(e,n,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,a){a.length>0&&(this._active=!0);const o=ks(a,n),c=new p.P(0,0),m=new p.P(0,0);let _=0;for(const b in o){const T=o[b],S=this._touches[b];S&&(c._add(T),m._add(T.sub(S)),_++,o[b]=T)}if(this._touches=o,this._shouldBePrevented(_)||!m.mag())return;const y=m.div(_);return this._sum._add(y),this._sum.mag()Math.abs(h.x)}class Xn extends pa{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,n,a){super.touchstart(e,n,a),this._currentTouchCount=a.length}_start(e){this._lastPoints=e,fa(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,n,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const o=e[0].sub(this._lastPoints[0]),c=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(o,c,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(o.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(e,n,a){if(this._valid!==void 0)return this._valid;const o=e.mag()>=2,c=n.mag()>=2;if(!o&&!c)return;if(!o||!c)return this._firstMove===void 0&&(this._firstMove=a),a-this._firstMove<100&&void 0;const m=e.y>0==n.y>0;return fa(e)&&fa(n)&&m}}const Sl={panStep:100,bearingStep:15,pitchStep:10};class er{constructor(e){this._tr=new pr(e);const n=Sl;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,a=0,o=0,c=0,m=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),c=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),c=1);break;case 38:e.shiftKey?o=1:(e.preventDefault(),m=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(a=0,o=0),{cameraAnimation:_=>{const y=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:Er,zoom:n?Math.round(y.zoom)+n*(e.shiftKey?2:1):y.zoom,bearing:y.bearing+a*this._bearingStep,pitch:y.pitch+o*this._pitchStep,offset:[-c*this._panStep,-m*this._panStep],center:y.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 Er(h){return h*(2-h)}const bo=4.000244140625;class fr{constructor(e,n){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=e,this._tr=new pr(e),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}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 n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const a=ue.now(),o=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,n!==0&&n%bo==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(o*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,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 n=se.mousePos(this._map.getCanvas(),e),a=this._tr;this._around=n.y>a.transform.height/2-a.transform.getHorizon()?p.N.convert(this._aroundCenter?a.center:a.unproject(n)):p.N.convert(a.center),this._aroundPoint=a.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const e=this._tr.transform;if(this._delta!==0){const y=this._type==="wheel"&&Math.abs(this._delta)>bo?this._wheelZoomRate:this._defaultZoomRate;let b=2/(1+Math.exp(-Math.abs(this._delta*y)));this._delta<0&&b!==0&&(b=1/b);const T=typeof this._targetZoom=="number"?e.zoomScale(this._targetZoom):e.scale;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(T*b))),this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom=="number"?this._targetZoom:e.zoom,a=this._startZoom,o=this._easing;let c,m=!1;const _=ue.now()-this._lastWheelEventTime;if(this._type==="wheel"&&a&&o&&_){const y=Math.min(_/200,1),b=o(y);c=p.y.number(a,n,b),y<1?this._frameId||(this._frameId=!0):m=!0}else c=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:c-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=p.b9;if(this._prevEase){const a=this._prevEase,o=(ue.now()-a.start)/a.duration,c=a.easing(o+.01)-a.easing(o),m=.27/Math.sqrt(c*c+1e-4)*.01,_=Math.sqrt(.0729-m*m);n=p.b8(m,_,.25,1)}return this._prevEase={start:ue.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Sn{constructor(e,n){this._clickZoom=e,this._tapZoom=n}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 wc{constructor(e){this._tr=new pr(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Tc{constructor(){this._tap=new ha({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,n,a){if(!this._swipePoint)if(this._tapTime){const o=n[0],c=e.timeStamp-this._tapTime<500,m=this._tapPoint.dist(o)<30;c&&m?a.length>0&&(this._swipePoint=o,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(e,n,a)}touchmove(e,n,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const o=n[0],c=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(e,n,a)}touchend(e,n,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{const o=this._tap.touchend(e,n,a);o&&(this._tapTime=e.timeStamp,this._tapPoint=o)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Il{constructor(e,n,a){this._el=e,this._mousePan=n,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 Pl{constructor(e,n,a){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=n,this._mousePitch=a}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class wo{constructor(e,n,a,o){this._el=e,this._touchZoom=n,this._touchRotate=a,this._tapDragZoom=o,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 Wn{constructor(e,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=n,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=se.create("div","maplibregl-cooperative-gesture-screen",e);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),o=document.createElement("div");o.className="maplibregl-desktop-message",o.textContent=n,this._container.appendChild(o);const c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=a,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(se.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,n){this._enabled&&(this._map.fire(new p.k("cooperativegestureprevented",{gestureType:e,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const tr=h=>h.zoom||h.drag||h.pitch||h.rotate;class ze extends p.k{}function ma(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta}class To{constructor(e,n){this.handleWindowEvent=o=>{this.handleEvent(o,`${o.type}Window`)},this.handleEvent=(o,c)=>{if(o.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const m=o.type==="renderFrame"?void 0:o,_={needsRenderFrame:!1},y={},b={},T=o.touches,S=T?this._getMapTouches(T):void 0,k=S?se.touchPos(this._map.getCanvas(),S):se.mousePos(this._map.getCanvas(),o);for(const{handlerName:N,handler:q,allowed:Z}of this._handlers){if(!q.isEnabled())continue;let X;this._blockedByActive(b,Z,N)?q.reset():q[c||o.type]&&(X=q[c||o.type](o,k,S),this.mergeHandlerResult(_,y,X,N,m),X&&X.needsRenderFrame&&this._triggerRenderFrame()),(X||q.isActive())&&(b[N]=q)}const D={};for(const N in this._previousActiveHandlers)b[N]||(D[N]=m);this._previousActiveHandlers=b,(Object.keys(D).length||ma(_))&&(this._changes.push([_,y,D]),this._triggerRenderFrame()),(Object.keys(b).length||ma(_))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:B}=_;B&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],B(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ho(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const a=this._el;this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]];for(const[o,c,m]of this._listeners)se.addEventListener(o,c,o===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[e,n,a]of this._listeners)se.removeEventListener(e,n,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){const n=this._map,a=n.getCanvasContainer();this._add("mapEvent",new Tl(n,e));const o=n.boxZoom=new $i(n,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const c=n.cooperativeGestures=new Wn(n,e.cooperativeGestures);this._add("cooperativeGestures",c),e.cooperativeGestures&&c.enable();const m=new Hn(n),_=new wc(n);n.doubleClickZoom=new Sn(_,m),this._add("tapZoom",m),this._add("clickZoom",_),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();const y=new Tc;this._add("tapDragZoom",y);const b=n.touchPitch=new Xn(n);this._add("touchPitch",b),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);const T=mo(e),S=go(e);n.dragRotate=new Pl(e,T,S),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",S,["mouseRotate"]),e.interactive&&e.dragRotate&&n.dragRotate.enable();const k=(({enable:X,clickTolerance:F})=>{const Y=new ua({checkCorrectEvent:ee=>se.mouseButton(ee)===0&&!ee.ctrlKey});return new $r({clickTolerance:F,move:(ee,ae)=>({around:ae,panDelta:ae.sub(ee)}),activateOnStart:!0,moveStateManager:Y,enable:X,assignEvents:da})})(e),D=new Tn(e,n);n.dragPan=new Il(a,k,D),this._add("mousePan",k),this._add("touchPan",D,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);const B=new vo,N=new yo;n.touchZoomRotate=new wo(a,N,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",N,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);const q=n.scrollZoom=new fr(n,()=>this._triggerRenderFrame());this._add("scrollZoom",q,["mousePan"]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);const Z=n.keyboard=new er(n);this._add("keyboard",Z),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new Bt(n))}_add(e,n,a){this._handlers.push({handlerName:e,handler:n,allowed:a}),this._handlersById[e]=n}stop(e){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.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!!tr(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,n,a){for(const o in e)if(o!==a&&(!n||n.indexOf(o)<0))return!0;return!1}_getMapTouches(e){const n=[];for(const a of e)this._el.contains(a.target)&&n.push(a);return n}mergeHandlerResult(e,n,a,o,c){if(!a)return;p.e(e,a);const m={handlerName:o,originalEvent:a.originalEvent||c};a.zoomDelta!==void 0&&(n.zoom=m),a.panDelta!==void 0&&(n.drag=m),a.pitchDelta!==void 0&&(n.pitch=m),a.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){const e={},n={},a={};for(const[o,c,m]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new p.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.around!==void 0&&(e.around=o.around),o.pinchAround!==void 0&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),p.e(n,c),p.e(a,m);this._updateMapTransform(e,n,a),this._changes=[]}_updateMapTransform(e,n,a){const o=this._map,c=o._getTransformForUpdate(),m=o.terrain;if(!(ma(e)||m&&this._terrainMovement))return this._fireEvents(n,a,!0);let{panDelta:_,zoomDelta:y,bearingDelta:b,pitchDelta:T,around:S,pinchAround:k}=e;k!==void 0&&(S=k),o._stop(!0),S=S||o.transform.centerPoint;const D=c.pointLocation(_?S.sub(_):S);b&&(c.bearing+=b),T&&(c.pitch+=T),y&&(c.zoom+=y),m?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?c.center=c.pointLocation(c.centerPoint.sub(_)):c.setLocationAtPoint(D,S):(this._terrainMovement=!0,this._map._elevationFreeze=!0,c.setLocationAtPoint(D,S)):c.setLocationAtPoint(D,S),o._applyUpdatedTransform(c),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,a,!0)}_fireEvents(e,n,a){const o=tr(this._eventsInProgress),c=tr(e),m={};for(const S in e){const{originalEvent:k}=e[S];this._eventsInProgress[S]||(m[`${S}start`]=k),this._eventsInProgress[S]=e[S]}!o&&c&&this._fireEvent("movestart",c.originalEvent);for(const S in m)this._fireEvent(S,m[S]);c&&this._fireEvent("move",c.originalEvent);for(const S in e){const{originalEvent:k}=e[S];this._fireEvent(S,k)}const _={};let y;for(const S in this._eventsInProgress){const{handlerName:k,originalEvent:D}=this._eventsInProgress[S];this._handlersById[k].isActive()||(delete this._eventsInProgress[S],y=n[k]||D,_[`${S}end`]=y)}for(const S in _)this._fireEvent(S,_[S]);const b=tr(this._eventsInProgress),T=(o||c)&&!b;if(T&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const S=this._map._getTransformForUpdate();S.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(S)}if(a&&T){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),k=D=>D!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new ze("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Al extends p.E{constructor(e,n){super(),this._renderFrameCallback=()=>{const a=Math.min((ue.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(a)),a<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new p.N(this.transform.center.lng,this.transform.center.lat)}setCenter(e,n){return this.jumpTo({center:e},n)}panBy(e,n,a){return e=p.P.convert(e).mult(-1),this.panTo(this.transform.center,p.e({offset:e},n),a)}panTo(e,n,a){return this.easeTo(p.e({center:e},n),a)}getZoom(){return this.transform.zoom}setZoom(e,n){return this.jumpTo({zoom:e},n),this}zoomTo(e,n,a){return this.easeTo(p.e({zoom:e},n),a)}zoomIn(e,n){return this.zoomTo(this.getZoom()+1,e,n),this}zoomOut(e,n){return this.zoomTo(this.getZoom()-1,e,n),this}getBearing(){return this.transform.bearing}setBearing(e,n){return this.jumpTo({bearing:e},n),this}getPadding(){return this.transform.padding}setPadding(e,n){return this.jumpTo({padding:e},n),this}rotateTo(e,n,a){return this.easeTo(p.e({bearing:e},n),a)}resetNorth(e,n){return this.rotateTo(0,p.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(p.e({bearing:0,pitch:0,duration:1e3},e),n),this}snapToNorth(e,n){return Math.abs(this.getBearing()){if(this._zooming&&(o.zoom=p.y.number(c,q,fe)),this._rotating&&(o.bearing=p.y.number(m,b,fe)),this._pitching&&(o.pitch=p.y.number(_,T,fe)),this._padding&&(o.interpolatePadding(y,S,fe),D=o.centerPoint.add(k)),this.terrain&&!e.freezeElevation&&this._updateElevation(fe),Y)o.setLocationAtPoint(Y,ee);else{const _e=o.zoomScale(o.zoom-c),Pe=q>c?Math.min(2,F):Math.max(.5,F),ke=Math.pow(Pe,1-fe),we=o.unproject(Z.add(X.mult(fe*ke)).mult(_e));o.setLocationAtPoint(o.renderWorldCopies?we.wrap():we,D)}this._applyUpdatedTransform(o),this._fireMoveEvents(n)},fe=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,fe)},e),this}_prepareEase(e,n,a={}){this._moving=!0,n||a.moving||this.fire(new p.k("movestart",e)),this._zooming&&!a.zooming&&this.fire(new p.k("zoomstart",e)),this._rotating&&!a.rotating&&this.fire(new p.k("rotatestart",e)),this._pitching&&!a.pitching&&this.fire(new p.k("pitchstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(a-(n-(a*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.elevation=p.y.number(this._elevationStart,this._elevationTarget,e)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){const n=e.getCameraPosition(),a=this.terrain.getElevationForLngLatZoom(n.lngLat,e.zoom);if(n.altitudethis._elevateCameraIfInsideTerrain(o)),this.transformCameraUpdate&&n.push(o=>this.transformCameraUpdate(o)),!n.length)return;const a=e.clone();for(const o of n){const c=a.clone(),{center:m,zoom:_,pitch:y,bearing:b,elevation:T}=o(c);m&&(c.center=m),_!==void 0&&(c.zoom=_),y!==void 0&&(c.pitch=y),b!==void 0&&(c.bearing=b),T!==void 0&&(c.elevation=T),a.apply(c)}this.transform.apply(a)}_fireMoveEvents(e){this.fire(new p.k("move",e)),this._zooming&&this.fire(new p.k("zoom",e)),this._rotating&&this.fire(new p.k("rotate",e)),this._pitching&&this.fire(new p.k("pitch",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const a=this._zooming,o=this._rotating,c=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,a&&this.fire(new p.k("zoomend",e)),o&&this.fire(new p.k("rotateend",e)),c&&this.fire(new p.k("pitchend",e)),this.fire(new p.k("moveend",e))}flyTo(e,n){var a;if(!e.essential&&ue.prefersReducedMotion){const Ce=p.M(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Ce,n)}this.stop(),e=p.e({offset:[0,0],speed:1.2,curve:1.42,easing:p.b9},e);const o=this._getTransformForUpdate(),c=o.zoom,m=o.bearing,_=o.pitch,y=o.padding,b="bearing"in e?this._normalizeBearing(e.bearing,m):m,T="pitch"in e?+e.pitch:_,S="padding"in e?e.padding:o.padding,k=p.P.convert(e.offset);let D=o.centerPoint.add(k);const B=o.pointLocation(D),{center:N,zoom:q}=o.getConstrained(p.N.convert(e.center||B),(a=e.zoom)!==null&&a!==void 0?a:c);this._normalizeCenter(N,o);const Z=o.zoomScale(q-c),X=o.project(B),F=o.project(N).sub(X);let Y=e.curve;const ee=Math.max(o.width,o.height),ae=ee/Z,fe=F.mag();if("minZoom"in e){const Ce=p.ac(Math.min(e.minZoom,c,q),o.minZoom,o.maxZoom),qe=ee/o.zoomScale(Ce-c);Y=Math.sqrt(qe/fe*2)}const _e=Y*Y;function Pe(Ce){const qe=(ae*ae-ee*ee+(Ce?-1:1)*_e*_e*fe*fe)/(2*(Ce?ae:ee)*_e*fe);return Math.log(Math.sqrt(qe*qe+1)-qe)}function ke(Ce){return(Math.exp(Ce)-Math.exp(-Ce))/2}function we(Ce){return(Math.exp(Ce)+Math.exp(-Ce))/2}const be=Pe(!1);let Re=function(Ce){return we(be)/we(be+Y*Ce)},Xe=function(Ce){return ee*((we(be)*(ke(qe=be+Y*Ce)/we(qe))-ke(be))/_e)/fe;var qe},Se=(Pe(!0)-be)/Y;if(Math.abs(fe)<1e-6||!isFinite(Se)){if(Math.abs(ee-ae)<1e-6)return this.easeTo(e,n);const Ce=ae0,Re=qe=>Math.exp(Ce*Y*qe)}return e.duration="duration"in e?+e.duration:1e3*Se/("screenSpeed"in e?+e.screenSpeed/Y:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=m!==b,this._pitching=T!==_,this._padding=!o.isPaddingEqual(S),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(N),this._ease(Ce=>{const qe=Ce*Se,Tt=1/Re(qe);o.zoom=Ce===1?q:c+o.scaleZoom(Tt),this._rotating&&(o.bearing=p.y.number(m,b,Ce)),this._pitching&&(o.pitch=p.y.number(_,T,Ce)),this._padding&&(o.interpolatePadding(y,S,Ce),D=o.centerPoint.add(k)),this.terrain&&!e.freezeElevation&&this._updateElevation(Ce);const Ye=Ce===1?N:o.unproject(X.add(F.mult(Xe(qe))).mult(Tt));o.setLocationAtPoint(o.renderWorldCopies?Ye.wrap():Ye,D),this._applyUpdatedTransform(o),this._fireMoveEvents(n)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,n){var a;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const o=this._onEaseEnd;delete this._onEaseEnd,o.call(this,n)}return e||(a=this.handlers)===null||a===void 0||a.stop(!1),this}_ease(e,n,a){a.animate===!1||a.duration===0?(e(1),n()):(this._easeStart=ue.now(),this._easeOptions=a,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=p.b3(e,-180,180);const a=Math.abs(e-n);return Math.abs(e-360-n)180?-360:a<-180?360:0}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(p.N.convert(e),this.transform.tileZoom)-this.transform.elevation:null}}const Kn={compact:!0,customAttribution:'MapLibre'};class Jn{constructor(e=Kn){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=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?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=se.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=se.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=se.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(){se.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,n){const a=this._map._getUIString(`AttributionControl.${n}`);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(o=>typeof o!="string"?"":o)):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const o=this._map.style.stylesheet;this.styleOwner=o.owner,this.styleId=o.id}const n=this._map.style.sourceCaches;for(const o in n){const c=n[o];if(c.used||c.usedForTerrain){const m=c.getSource();m.attribution&&e.indexOf(m.attribution)<0&&e.push(m.attribution)}}e=e.filter(o=>String(o).trim()),e.sort((o,c)=>o.length-c.length),e=e.filter((o,c)=>{for(let m=c+1;m=0)return!1;return!0});const a=e.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,e.length?(this._innerContainer.innerHTML=a,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class So{constructor(e={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const a=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&a.classList.add("maplibregl-compact"):a.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=se.create("div","maplibregl-ctrl");const n=se.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){se.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class st{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const n=++this._id;return this._queue.push({callback:e,id:n,cancelled:!1}),n}remove(e){const n=this._currentlyRunning,a=n?this._queue.concat(n):this._queue;for(const o of a)if(o.id===e)return void(o.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const a of n)if(!a.cancelled&&(a.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Io=p.Y([{name:"a_pos3d",type:"Int16",components:3}]);class Sc extends p.E{constructor(e){super(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,e.usedForTerrain=!0,e.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];const a={};for(const o of e.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))a[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.posMatrix=new Float64Array(16),p.aP(o.posMatrix,0,p.X,0,p.X,0,1),this._tiles[o.key]=new Jr(o,this.tileSize));for(const o in this._tiles)a[o]||delete this._tiles[o]}freeRtt(e){for(const n in this._tiles){const a=this._tiles[n];(!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){const n={};for(const a of this._renderableTilesKeys){const o=this._tiles[a].tileID;if(o.canonical.equals(e.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16),p.aP(c.posMatrix,0,p.X,0,p.X,0,1),n[a]=c}else if(o.canonical.isChildOf(e.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16);const m=o.canonical.z-e.canonical.z,_=o.canonical.x-(o.canonical.x>>m<>m<>m;p.aP(c.posMatrix,0,b,0,b,0,1),p.J(c.posMatrix,c.posMatrix,[-_*b,-y*b,0]),n[a]=c}else if(e.canonical.isChildOf(o.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16);const m=e.canonical.z-o.canonical.z,_=e.canonical.x-(e.canonical.x>>m<>m<>m;p.aP(c.posMatrix,0,p.X,0,p.X,0,1),p.J(c.posMatrix,c.posMatrix,[_*b,y*b,0]),p.K(c.posMatrix,c.posMatrix,[1/2**m,1/2**m,0]),n[a]=c}}return n}getSourceTile(e,n){const a=this.sourceCache._source;let o=e.overscaledZ-this.deltaZoom;if(o>a.maxzoom&&(o=a.maxzoom),o=a.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(e.scaledTo(o--).key);return c}tilesAfterTime(e=Date.now()){return Object.values(this._tiles).filter(n=>n.timeAdded>=e)}}class Po{constructor(e,n,a){this.painter=e,this.sourceCache=new Sc(n),this.options=a,this.exaggeration=typeof a.exaggeration=="number"?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,a,o=p.X){var c;if(!(n>=0&&n=0&&ae.canonical.z&&(e.canonical.z>=o?c=e.canonical.z-o:p.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=e.canonical.x-(e.canonical.x>>c<>c<>8<<4|c>>8,n[m+3]=0;const a=new p.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),o=new et(e,a,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),a=this.painter.context,o=a.gl,c=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),_=Math.round(this.painter.height/devicePixelRatio);a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(c,_-m-1,1,1,o.RGBA,o.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null);const y=n[0]+(n[2]>>4<<8),b=n[1]+((15&n[2])<<8),T=this.coordsIndex[255-n[3]],S=T&&this.sourceCache.getTileByID(T);if(!S)return null;const k=this._coordsTextureSize,D=(1<e.id!==n),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];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)===!1}}const Yn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Cl{constructor(e,n){this.painter=e,this.terrain=n,this.pool=new Ic(e.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter(a=>!e._layers[a].isHidden(n)),this._coordsDescendingInv={};for(const a in e.sourceCaches){this._coordsDescendingInv[a]={};const o=e.sourceCaches[a].getVisibleCoordinates();for(const c of o){const m=this.terrain.sourceCache.getTerrainCoords(c);for(const _ in m)this._coordsDescendingInv[a][_]||(this._coordsDescendingInv[a][_]=[]),this._coordsDescendingInv[a][_].push(m[_])}}this._coordsDescendingInvStr={};for(const a of e._order){const o=e._layers[a],c=o.source;if(Yn[o.type]&&!this._coordsDescendingInvStr[c]){this._coordsDescendingInvStr[c]={};for(const m in this._coordsDescendingInv[c])this._coordsDescendingInvStr[c][m]=this._coordsDescendingInv[c][m].map(_=>_.key).sort().join()}}for(const a of this._renderableTiles)for(const o in this._coordsDescendingInvStr){const c=this._coordsDescendingInvStr[o][a.tileID.key];c&&c!==a.rttCoords[o]&&(a.rtt=[])}}renderLayer(e){if(e.isHidden(this.painter.transform.zoom))return!1;const n=e.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Yn[n]&&(this._prevType&&Yn[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(e.id),!o))return!0;if(Yn[this._prevType]||Yn[n]&&o){this._prevType=n;const c=this._stacks.length-1,m=this._stacks[c]||[];for(const _ of this._renderableTiles){if(this.pool.isFull()&&(vl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(_),_.rtt[c]){const b=this.pool.getObjectForId(_.rtt[c].id);if(b.stamp===_.rtt[c].stamp){this.pool.useObject(b);continue}}const y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),_.rtt[c]={id:y.id,stamp:y.stamp},a.context.bindFramebuffer.set(y.fbo.framebuffer),a.context.clear({color:p.aM.transparent,stencil:0}),a.currentStencilSource=void 0;for(let b=0;b{h.touchstart=h.dragStart,h.touchmoveWindow=h.dragMove,h.touchend=h.dragEnd},Ac={showCompass:!0,showZoom:!0,visualizePitch:!1};class Cc{constructor(e,n,a=!1){this.mousedown=m=>{this.startMouse(p.e({},m,{ctrlKey:!0,preventDefault:()=>m.preventDefault()}),se.mousePos(this.element,m)),se.addEventListener(window,"mousemove",this.mousemove),se.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=m=>{this.moveMouse(m,se.mousePos(this.element,m))},this.mouseup=m=>{this.mouseRotate.dragEnd(m),this.mousePitch&&this.mousePitch.dragEnd(m),this.offTemp()},this.touchstart=m=>{m.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.startTouch(m,this._startPos),se.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.addEventListener(window,"touchend",this.touchend))},this.touchmove=m=>{m.targetTouches.length!==1?this.reset():(this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.moveTouch(m,this._lastPos))},this.touchend=m=>{m.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const o=e.dragRotate._mouseRotate.getClickTolerance(),c=e.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=mo({clickTolerance:o,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:_,bearingDegreesPerPixelMoved:y=.8})=>{const b=new fo;return new $r({clickTolerance:_,move:(T,S)=>({bearingDelta:(S.x-T.x)*y}),moveStateManager:b,enable:m,assignEvents:Co})})({clickTolerance:o,enable:!0}),this.map=e,a&&(this.mousePitch=go({clickTolerance:c,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:_,pitchDegreesPerPixelMoved:y=-.5})=>{const b=new fo;return new $r({clickTolerance:_,move:(T,S)=>({pitchDelta:(S.y-T.y)*y}),moveStateManager:b,enable:m,assignEvents:Co})})({clickTolerance:c,enable:!0})),se.addEventListener(n,"mousedown",this.mousedown),se.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),se.addEventListener(n,"touchcancel",this.reset)}startMouse(e,n){this.mouseRotate.dragStart(e,n),this.mousePitch&&this.mousePitch.dragStart(e,n),se.disableDrag()}startTouch(e,n){this.touchRotate.dragStart(e,n),this.touchPitch&&this.touchPitch.dragStart(e,n),se.disableDrag()}moveMouse(e,n){const a=this.map,{bearingDelta:o}=this.mouseRotate.dragMove(e,n)||{};if(o&&a.setBearing(a.getBearing()+o),this.mousePitch){const{pitchDelta:c}=this.mousePitch.dragMove(e,n)||{};c&&a.setPitch(a.getPitch()+c)}}moveTouch(e,n){const a=this.map,{bearingDelta:o}=this.touchRotate.dragMove(e,n)||{};if(o&&a.setBearing(a.getBearing()+o),this.touchPitch){const{pitchDelta:c}=this.touchPitch.dragMove(e,n)||{};c&&a.setPitch(a.getPitch()+c)}}off(){const e=this.element;se.removeEventListener(e,"mousedown",this.mousedown),se.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend),se.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){se.enableDrag(),se.removeEventListener(window,"mousemove",this.mousemove),se.removeEventListener(window,"mouseup",this.mouseup),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend)}}let qi;function wt(h,e,n){const a=new p.N(h.lng,h.lat);if(h=new p.N(h.lng,h.lat),e){const o=new p.N(h.lng-360,h.lat),c=new p.N(h.lng+360,h.lat),m=n.locationPoint(h).distSqr(e);n.locationPoint(o).distSqr(e)180;){const o=n.locationPoint(h);if(o.x>=0&&o.y>=0&&o.x<=n.width&&o.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h.lng!==a.lng&&n.locationPoint(h).y>n.height/2-n.getHorizon()?h:a}const Qn={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 ga(h,e,n){const a=h.classList;for(const o in Qn)a.remove(`maplibregl-${n}-anchor-${o}`);a.add(`maplibregl-${n}-anchor-${e}`)}class _a extends p.E{constructor(e){if(super(),this._onKeyPress=n=>{const a=n.code,o=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&o!==32&&o!==13||this.togglePopup()},this._onMapClick=n=>{const a=n.originalEvent.target,o=this._element;this._popup&&(a===o||o.contains(a))&&this.togglePopup()},this._update=n=>{var a;if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?wt(this._lngLat,this._flatPos,this._map.transform):(a=this._lngLat)===null||a===void 0?void 0:a.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let m="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?m="rotateX(0deg)":this._pitchAlignment==="map"&&(m=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),se.setTransform(this._element,`${Qn[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${m} ${c}`),ue.frameAsync(new AbortController).then(()=>{this._updateOpacity(n&&n.type==="moveend")}).catch(()=>{})},this._onMove=n=>{if(!this._isDragging){const a=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=a}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new p.k("dragstart"))),this.fire(new p.k("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),this._state==="active"&&this.fire(new p.k("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.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&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(e==null?void 0:e.opacity,e==null?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=p.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=se.create("div");const n=se.createNS("http://www.w3.org/2000/svg","svg"),a=41,o=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${a}px`),n.setAttributeNS(null,"width",`${o}px`),n.setAttributeNS(null,"viewBox",`0 0 ${o} ${a}`);const c=se.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"stroke","none"),c.setAttributeNS(null,"stroke-width","1"),c.setAttributeNS(null,"fill","none"),c.setAttributeNS(null,"fill-rule","evenodd");const m=se.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const _=se.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const y=[{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 Z of y){const X=se.createNS("http://www.w3.org/2000/svg","ellipse");X.setAttributeNS(null,"opacity","0.04"),X.setAttributeNS(null,"cx","10.5"),X.setAttributeNS(null,"cy","5.80029008"),X.setAttributeNS(null,"rx",Z.rx),X.setAttributeNS(null,"ry",Z.ry),_.appendChild(X)}const b=se.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=se.createNS("http://www.w3.org/2000/svg","path");T.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),b.appendChild(T);const S=se.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const k=se.createNS("http://www.w3.org/2000/svg","path");k.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),S.appendChild(k);const D=se.createNS("http://www.w3.org/2000/svg","g");D.setAttributeNS(null,"transform","translate(6.0, 7.0)"),D.setAttributeNS(null,"fill","#FFFFFF");const B=se.createNS("http://www.w3.org/2000/svg","g");B.setAttributeNS(null,"transform","translate(8.0, 8.0)");const N=se.createNS("http://www.w3.org/2000/svg","circle");N.setAttributeNS(null,"fill","#000000"),N.setAttributeNS(null,"opacity","0.25"),N.setAttributeNS(null,"cx","5.5"),N.setAttributeNS(null,"cy","5.5"),N.setAttributeNS(null,"r","5.4999962");const q=se.createNS("http://www.w3.org/2000/svg","circle");q.setAttributeNS(null,"fill","#FFFFFF"),q.setAttributeNS(null,"cx","5.5"),q.setAttributeNS(null,"cy","5.5"),q.setAttributeNS(null,"r","5.4999962"),B.appendChild(N),B.appendChild(q),m.appendChild(_),m.appendChild(b),m.appendChild(S),m.appendChild(D),m.appendChild(B),n.appendChild(m),n.setAttributeNS(null,"height",a*this._scale+"px"),n.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(n),this._offset=p.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",n=>{n.preventDefault()}),this._element.addEventListener("mousedown",n=>{n.preventDefault()}),ga(this._element,this._anchor,"marker"),e&&e.className)for(const n of e.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),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("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),se.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=p.N.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 o=Math.abs(13.5)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[o,-1*(38.1-13.5+o)],"bottom-right":[-o,-1*(38.1-13.5+o)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}: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 n,a;if(!(!((n=this._map)===null||n===void 0)&&n.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const o=this._map,c=o.terrain.depthAtPoint(this._pos),m=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,m)-c<.006)return void(this._element.style.opacity=this._opacity);const _=-this._offset.y/o.transform._pixelPerMeter,y=Math.sin(o.getPitch()*Math.PI/180)*_,b=o.terrain.depthAtPoint(new p.P(this._pos.x,this._pos.y-this._offset.y)),T=o.transform.lngLatToCameraDepth(this._lngLat,m+y)-b>.006;!((a=this._popup)===null||a===void 0)&&a.isOpen()&&T&&this._popup.remove(),this._element.style.opacity=T?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=p.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&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,n){return e===void 0&&n===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const kl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let zs=0,Ds=!1;const zr={maxWidth:100,unit:"metric"};function Ls(h,e,n){const a=n&&n.maxWidth||100,o=h._container.clientHeight/2,c=h.unproject([0,o]),m=h.unproject([a,o]),_=c.distanceTo(m);if(n&&n.unit==="imperial"){const y=3.2808*_;y>5280?Le(e,a,y/5280,h._getUIString("ScaleControl.Miles")):Le(e,a,y,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Le(e,a,_/1852,h._getUIString("ScaleControl.NauticalMiles")):_>=1e3?Le(e,a,_/1e3,h._getUIString("ScaleControl.Kilometers")):Le(e,a,_,h._getUIString("ScaleControl.Meters"))}function Le(h,e,n,a){const o=function(c){const m=Math.pow(10,`${Math.floor(c)}`.length-1);let _=c/m;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:function(y){const b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b}(_),m*_}(n);h.style.width=e*(o/n)+"px",h.innerHTML=`${o} ${a}`}const je={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},ya=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function xa(h){if(h){if(typeof h=="number"){const e=Math.round(Math.abs(h)/Math.SQRT2);return{center:new p.P(0,0),top:new p.P(0,h),"top-left":new p.P(e,e),"top-right":new p.P(-e,e),bottom:new p.P(0,-h),"bottom-left":new p.P(e,-e),"bottom-right":new p.P(-e,-e),left:new p.P(h,0),right:new p.P(-h,0)}}if(h instanceof p.P||Array.isArray(h)){const e=p.P.convert(h);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:p.P.convert(h.center||[0,0]),top:p.P.convert(h.top||[0,0]),"top-left":p.P.convert(h["top-left"]||[0,0]),"top-right":p.P.convert(h["top-right"]||[0,0]),bottom:p.P.convert(h.bottom||[0,0]),"bottom-left":p.P.convert(h["bottom-left"]||[0,0]),"bottom-right":p.P.convert(h["bottom-right"]||[0,0]),left:p.P.convert(h.left||[0,0]),right:p.P.convert(h.right||[0,0])}}return xa(new p.P(0,0))}const Mo=Je;M.AJAXError=p.bh,M.Evented=p.E,M.LngLat=p.N,M.MercatorCoordinate=p.Z,M.Point=p.P,M.addProtocol=p.bi,M.config=p.a,M.removeProtocol=p.bj,M.AttributionControl=Jn,M.BoxZoomHandler=$i,M.CanvasSource=Ji,M.CooperativeGesturesHandler=Wn,M.DoubleClickZoomHandler=Sn,M.DragPanHandler=Il,M.DragRotateHandler=Pl,M.EdgeInsets=Zn,M.FullscreenControl=class extends p.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var e;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=n==null?void 0:n.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:p.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(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){se.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const h=this._fullscreenButton=se.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);se.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_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 p.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new p.k("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()}},M.GeoJSONSource=fs,M.GeolocateControl=class extends p.E{constructor(h){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new p.k("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&&this._watchState!=="OFF"&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new p.k("geolocate",e)),this._finish()}},this._updateCamera=e=>{const n=new p.N(e.coords.longitude,e.coords.latitude),a=e.coords.accuracy,o=this._map.getBearing(),c=p.e({bearing:o},this.options.fitBoundsOptions),m=le.fromLngLat(n,a);this._map.fitBounds(m,c,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const n=new p.N(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(e.code===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._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&Ds)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new p.k("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=se.create("button","maplibregl-ctrl-geolocate",this._container),se.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(e===!1){p.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=se.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new _a({element:this._dotElement}),this._circleElement=se.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new _a({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new p.k("trackuserlocationend")),this.fire(new p.k("userlocationlostfocus")))})}},this.options=p.e({},kl,h)}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return p._(this,arguments,void 0,function*(e=!1){if(qi!==void 0&&!e)return qi;if(window.navigator.permissions===void 0)return qi=!!window.navigator.geolocation,qi;try{qi=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{qi=!!window.navigator.geolocation}return qi})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(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(),se.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,zs=0,Ds=!1}_isOutOfMapMaxBounds(h){const e=this._map.getMaxBounds(),n=h.coords;return e&&(n.longitudee.getEast()||n.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const h=this._map.getBounds(),e=h.getSouthEast(),n=h.getNorthEast(),a=e.distanceTo(n),o=Math.ceil(this._accuracy/(a/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}trigger(){if(!this._setup)return p.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 p.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":zs--,Ds=!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 p.k("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 p.k("trackuserlocationstart")),this.fire(new p.k("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(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let h;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),zs++,zs>1?(h={maximumAge:6e5,timeout:0},Ds=!0):(h=this.options.positionOptions,Ds=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,h)}}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)}},M.Hash=oa,M.ImageSource=Nr,M.KeyboardHandler=er,M.LngLatBounds=le,M.LogoControl=So,M.Map=class extends Al{constructor(h){p.bf.mark(p.bg.create);const e=Object.assign(Object.assign({},Pc),h);if(e.minZoom!=null&&e.maxZoom!=null&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(e.minPitch!=null&&e.maxPitch!=null&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(e.minPitch!=null&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(e.maxPitch!=null&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Gn(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),{bearingSnap:e.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new st,this._controls=[],this._mapId=p.a4(),this._contextLost=n=>{n.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new p.k("webglcontextlost",{originalEvent:n}))},this._contextRestored=n=>{this._setupPainter(),this.resize(),this._update(),this.fire(new p.k("webglcontextrestored",{originalEvent:n}))},this._onMapScroll=n=>{if(n.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._maxTileCacheZoomLevels=e.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=e.preserveDrawingBuffer===!0,this._antialias=e.antialias===!0,this._trackResize=e.trackResize===!0,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles===!0,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions===!0,this._collectResourceTiming=e.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Ao),e.locale),this._clickTolerance=e.clickTolerance,this._overridePixelRatio=e.pixelRatio,this._maxCanvasSize=e.maxCanvasSize,this.transformCameraUpdate=e.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=e.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Mt.addThrottleControl(()=>this.isMoving()),this._requestManager=new ln(e.transformRequest),typeof e.container=="string"){if(this._container=document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)).on("moveend",()=>this._update(!1)).on("zoom",()=>this._update(!0)).on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}).once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let n=!1;const a=As(o=>{this._trackResize&&!this._removed&&(this.resize(o),this.redraw())},50);this._resizeObserver=new ResizeObserver(o=>{n?a(o):n=!0}),this._resizeObserver.observe(this._container)}this.handlers=new To(this,e),this._hash=e.hash&&new oa(typeof e.hash=="string"&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,p.e({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,this._validateStyle=e.validateStyle,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new Jn(typeof e.attributionControl=="boolean"?void 0:e.attributionControl)),e.maplibreLogo&&this.addControl(new So,e.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",n=>{this._update(n.dataType==="style"),this.fire(new p.k(`${n.dataType}data`,n))}),this.on("dataloading",n=>{this.fire(new p.k(`${n.dataType}dataloading`,n))}),this.on("dataabort",n=>{this.fire(new p.k("sourcedataabort",n))})}_getMapId(){return this._mapId}addControl(h,e){if(e===void 0&&(e=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new p.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=h.onAdd(this);this._controls.push(h);const a=this._controlPositions[e];return e.indexOf("bottom")!==-1?a.insertBefore(n,a.firstChild):a.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new p.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(h);return e>-1&&this._controls.splice(e,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}calculateCameraOptionsFromTo(h,e,n,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,e,n,a)}resize(h){var e;const n=this._containerDimensions(),a=n[0],o=n[1],c=this._getClampedPixelRatio(a,o);if(this._resizeCanvas(a,o,c),this.painter.resize(a,o,c),this.painter.overLimit()){const _=this.painter.context.gl;this._maxCanvasSize=[_.drawingBufferWidth,_.drawingBufferHeight];const y=this._getClampedPixelRatio(a,o);this._resizeCanvas(a,o,y),this.painter.resize(a,o,y)}this.transform.resize(a,o),(e=this._requestedCameraState)===null||e===void 0||e.resize(a,o);const m=!this._moving;return m&&(this.stop(),this.fire(new p.k("movestart",h)).fire(new p.k("move",h))),this.fire(new p.k("resize",h)),m&&this.fire(new p.k("moveend",h)),this}_getClampedPixelRatio(h,e){const{0:n,1:a}=this._maxCanvasSize,o=this.getPixelRatio(),c=h*o,m=e*o;return Math.min(c>n?n/c:1,m>a?a/m:1)*o}getPixelRatio(){var h;return(h=this._overridePixelRatio)!==null&&h!==void 0?h:devicePixelRatio}setPixelRatio(h){this._overridePixelRatio=h,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(h){return this.transform.setMaxBounds(le.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.minZoom=h,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=h,this._update(),this.getZoom()>h&&this.setZoom(h),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.minPitch=h,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(h>=this.transform.minPitch)return this.transform.maxPitch=h,this._update(),this.getPitch()>h&&this.setPitch(h),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.renderWorldCopies=h,this._update()}project(h){return this.transform.locationPoint(p.N.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.pointLocation(p.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,e,n){if(h==="mouseenter"||h==="mouseover"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:c=>{const m=e.filter(y=>this.getLayer(y)),_=m.length!==0?this.queryRenderedFeatures(c.point,{layers:m}):[];_.length?a||(a=!0,n.call(this,new ai(h,this,c.originalEvent,{features:_}))):a=!1},mouseout:()=>{a=!1}}}}if(h==="mouseleave"||h==="mouseout"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:m=>{const _=e.filter(y=>this.getLayer(y));(_.length!==0?this.queryRenderedFeatures(m.point,{layers:_}):[]).length?a=!0:a&&(a=!1,n.call(this,new ai(h,this,m.originalEvent)))},mouseout:m=>{a&&(a=!1,n.call(this,new ai(h,this,m.originalEvent)))}}}}{const a=o=>{const c=e.filter(_=>this.getLayer(_)),m=c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[];m.length&&(o.features=m,n.call(this,o),delete o.features)};return{layers:e,listener:n,delegates:{[h]:a}}}}_saveDelegatedListener(h,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(e)}_removeDelegatedListener(h,e,n){if(!this._delegatedListeners||!this._delegatedListeners[h])return;const a=this._delegatedListeners[h];for(let o=0;oe.includes(m))){for(const m in c.delegates)this.off(m,c.delegates[m]);return void a.splice(o,1)}}}on(h,e,n){if(n===void 0)return super.on(h,e);const a=this._createDelegatedListener(h,typeof e=="string"?[e]:e,n);this._saveDelegatedListener(h,a);for(const o in a.delegates)this.on(o,a.delegates[o]);return this}once(h,e,n){if(n===void 0)return super.once(h,e);const a=typeof e=="string"?[e]:e,o=this._createDelegatedListener(h,a,n);for(const c in o.delegates){const m=o.delegates[c];o.delegates[c]=(..._)=>{this._removeDelegatedListener(h,a,n),m(..._)}}this._saveDelegatedListener(h,o);for(const c in o.delegates)this.once(c,o.delegates[c]);return this}off(h,e,n){return n===void 0?super.off(h,e):(this._removeDelegatedListener(h,typeof e=="string"?[e]:e,n),this)}queryRenderedFeatures(h,e){if(!this.style)return[];let n;const a=h instanceof p.P||Array.isArray(h),o=a?h:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(a?{}:h)||{},o instanceof p.P||typeof o[0]=="number")n=[p.P.convert(o)];else{const c=p.P.convert(o[0]),m=p.P.convert(o[1]);n=[c,new p.P(m.x,c.y),m,new p.P(c.x,m.y),c]}return this.style.queryRenderedFeatures(n,e,this.transform)}querySourceFeatures(h,e){return this.style.querySourceFeatures(h,e)}setStyle(h,e){return(e=p.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(h,e))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){const e=this._locale[h];if(e==null)throw new Error(`Missing UI string '${h}'`);return e}_updateStyle(h,e){if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(h,e));const n=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new qs(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,e,n):this.style.loadJSON(h,e,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new qs(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,e){if(typeof h=="string"){const n=this._requestManager.transformRequest(h,"Style");p.h(n,new AbortController).then(a=>{this._updateDiff(a.data,e)}).catch(a=>{a&&this.fire(new p.j(a))})}else typeof h=="object"&&this._updateDiff(h,e)}_updateDiff(h,e){try{this.style.setState(h,e)&&this._update(!0)}catch(n){p.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(h,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():p.w("There is no style added to the map.")}addSource(h,e){return this._lazyInitEmptyStyle(),this.style.addSource(h,e),this._update(!0)}isSourceLoaded(h){const e=this.style&&this.style.sourceCaches[h];if(e!==void 0)return e.loaded();this.fire(new p.j(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){const e=this.style.sourceCaches[h.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&e.reload();for(const n in this.style._layers){const a=this.style._layers[n];a.type==="hillshade"&&a.source===h.source&&p.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.")}this.terrain=new Po(this.painter,e,h),this.painter.renderToTexture=new Cl(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==h.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.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.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new p.k("terrain",{terrain:h})),this}getTerrain(){var h,e;return(e=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&e!==void 0?e:null}areTilesLoaded(){const h=this.style&&this.style.sourceCaches;for(const e in h){const n=h[e]._tiles;for(const a in n){const o=n[a];if(o.state!=="loaded"&&o.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}addImage(h,e,n={}){const{pixelRatio:a=1,sdf:o=!1,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b}=n;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||p.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new p.j(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:T,height:S,data:k}=e,D=e;return this.style.addImage(h,{data:new p.R({width:T,height:S},new Uint8Array(k)),pixelRatio:a,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:o,version:0,userImage:D}),D.onAdd&&D.onAdd(this,h),this}}{const{width:T,height:S,data:k}=ue.getImageData(e);this.style.addImage(h,{data:new p.R({width:T,height:S},k),pixelRatio:a,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:o,version:0})}}updateImage(h,e){const n=this.style.getImage(h);if(!n)return this.fire(new p.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=e instanceof HTMLImageElement||p.b(e)?ue.getImageData(e):e,{width:o,height:c,data:m}=a;if(o===void 0||c===void 0)return this.fire(new p.j(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(o!==n.data.width||c!==n.data.height)return this.fire(new p.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const _=!(e instanceof HTMLImageElement||p.b(e));return n.data.replace(m,_),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new p.j(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return Mt.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,e){return this._lazyInitEmptyStyle(),this.style.addLayer(h,e),this._update(!0)}moveLayer(h,e){return this.style.moveLayer(h,e),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,e,n){return this.style.setLayerZoomRange(h,e,n),this._update(!0)}setFilter(h,e,n={}){return this.style.setFilter(h,e,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,e,n,a={}){return this.style.setPaintProperty(h,e,n,a),this._update(!0)}getPaintProperty(h,e){return this.style.getPaintProperty(h,e)}setLayoutProperty(h,e,n,a={}){return this.style.setLayoutProperty(h,e,n,a),this._update(!0)}getLayoutProperty(h,e){return this.style.getLayoutProperty(h,e)}setGlyphs(h,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,e,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,e,n,a=>{a||this._update(!0)}),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,e,n=>{n||this._update(!0)}),this}setLight(h,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(h){return this._lazyInitEmptyStyle(),this.style.setSky(h),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,e){return this.style.setFeatureState(h,e),this._update()}removeFeatureState(h,e){return this.style.removeFeatureState(h,e),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,e=0;return this._container&&(h=this._container.clientWidth||400,e=this._container.clientHeight||300),[h,e]}_setupContainer(){const h=this._container;h.classList.add("maplibregl-map");const e=this._canvasContainer=se.create("div","maplibregl-canvas-container",h);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=se.create("canvas","maplibregl-canvas",e),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 n=this._containerDimensions(),a=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],a);const o=this._controlContainer=se.create("div","maplibregl-control-container",h),c=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(m=>{c[m]=se.create("div",`maplibregl-ctrl-${m} `,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,e,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*e),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const h={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let e=null;this._canvas.addEventListener("webglcontextcreationerror",a=>{e={requestedAttributes:h},a&&(e.statusMessage=a.statusMessage,e.type=a.type)},{once:!0});const n=this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h);if(!n){const a="Failed to initialize WebGL";throw e?(e.message=a,new Error(JSON.stringify(e))):new Error(a)}this.painter=new aa(n,this.transform),Ot.testSupport(n)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(h){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_render(h){const e=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const o=this.transform.zoom,c=ue.now();this.style.zoomHistory.update(o,c);const m=new p.z(o,{now:c,fadeDuration:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),_=m.crossFadingFactor();_===1&&_===this._crossFadingFactor||(n=!0,this._crossFadingFactor=_),this.style.update(m)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,e,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:e,showPadding:this.showPadding}),this.fire(new p.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.bf.mark(p.bg.load),this.fire(new p.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const a=this._sourcesDirty||this._styleDirty||this._placementDirty;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new p.k("idle")),!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,p.bf.mark(p.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(const n of this._controls)n.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),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Mt.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e!=null&&e.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),se.remove(this._canvasContainer),se.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),p.bf.clearMetrics(),this._removed=!0,this.fire(new p.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,ue.frameAsync(this._frameRequest).then(h=>{p.bf.frame(h),this._frameRequest=null,this._render(h)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get version(){return Ml}getCameraTargetElevation(){return this.transform.elevation}},M.MapMouseEvent=ai,M.MapTouchEvent=wn,M.MapWheelEvent=wl,M.Marker=_a,M.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{const e=this._map.getZoom(),n=e===this._map.getMaxZoom(),a=e===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=e},this._setButtonTitle=(e,n)=>{const a=this._map._getUIString(`NavigationControl.${n}`);e.title=a,e.setAttribute("aria-label",a)},this.options=p.e({},Ac,h),this._container=se.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})),se.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})),se.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=se.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,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._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Cc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){se.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._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,e){const n=se.create("button",h,this._container);return n.type="button",n.addEventListener("click",e),n}},M.Popup=class extends p.E{constructor(h){super(),this.remove=()=>(this._content&&se.remove(this._content),this._container&&(se.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 p.k("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=>{var n;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=se.create("div","maplibregl-popup",this._map.getContainer()),this._tip=se.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const _ of this.options.className.split(" "))this._container.classList.add(_);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=this._map.transform.renderWorldCopies&&!this._trackPointer?wt(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.wrap(),this._trackPointer&&!e)return;const a=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.locationPoint(this._lngLat));let o=this.options.anchor;const c=xa(this.options.offset);if(!o){const _=this._container.offsetWidth,y=this._container.offsetHeight;let b;b=a.y+c.bottom.ythis._map.transform.height-y?["bottom"]:[],a.x<_/2?b.push("left"):a.x>this._map.transform.width-_/2&&b.push("right"),o=b.length===0?"bottom":b.join("-")}let m=a.add(c[o]);this.options.subpixelPositioning||(m=m.round()),se.setTransform(this._container,`${Qn[o]} translate(${m.x}px,${m.y}px)`),ga(this._container,o,"popup")},this._onClose=()=>{this.remove()},this.options=p.e(Object.create(je),h)}addTo(h){return this._map&&this.remove(),this._map=h,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 p.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=p.N.convert(h),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(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){const e=document.createDocumentFragment(),n=document.createElement("body");let a;for(n.innerHTML=h;a=n.firstChild,a;)e.appendChild(a);return this.setDOMContent(e)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=se.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=se.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 h=this._container.querySelector(ya);h&&h.focus()}},M.RasterDEMTileSource=Et,M.RasterTileSource=ut,M.ScaleControl=class{constructor(h){this._onMove=()=>{Ls(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Ls(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},zr),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){se.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},M.ScrollZoomHandler=fr,M.Style=qs,M.TerrainControl=class{constructor(h){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=h}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=se.create("button","maplibregl-ctrl-terrain",this._container),se.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(){se.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},M.TwoFingersTouchPitchHandler=Xn,M.TwoFingersTouchRotateHandler=vo,M.TwoFingersTouchZoomHandler=yo,M.TwoFingersTouchZoomRotateHandler=wo,M.VectorTileSource=ps,M.VideoSource=En,M.addSourceType=(h,e)=>p._(void 0,void 0,void 0,function*(){if(gs(h))throw new Error(`A source type called "${h}" already exists.`);((n,a)=>{ms[n]=a})(h,e)}),M.clearPrewarmedResources=function(){const h=Yt;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(or),Yt=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()"))},M.getMaxParallelImageRequests=function(){return p.a.MAX_PARALLEL_IMAGE_REQUESTS},M.getRTLTextPluginStatus=function(){return Ar().getRTLTextPluginStatus()},M.getVersion=function(){return Mo},M.getWorkerCount=function(){return si.workerCount},M.getWorkerUrl=function(){return p.a.WORKER_URL},M.importScriptInWorkers=function(h){return Xr().broadcast("IS",h)},M.prewarm=function(){Ir().acquire(or)},M.setMaxParallelImageRequests=function(h){p.a.MAX_PARALLEL_IMAGE_REQUESTS=h},M.setRTLTextPlugin=function(h,e){return Ar().setRTLTextPlugin(h,e)},M.setWorkerCount=function(h){si.workerCount=h},M.setWorkerUrl=function(h){p.a.WORKER_URL=h}});var ye=G;return ye})}(ec)),ec.exports}var tc=Cf(),Tr=Uint8Array,Oa=Uint16Array,Mf=Int32Array,fd=new Tr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),md=new Tr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),kf=new Tr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gd=function(J,j){for(var G=new Oa(31),ne=0;ne<31;++ne)G[ne]=j+=1<>1|(Lt&21845)<<1;ds=(ds&52428)>>2|(ds&13107)<<2,ds=(ds&61680)>>4|(ds&3855)<<4,vh[Lt]=((ds&65280)>>8|(ds&255)<<8)>>1}var Wo=function(J,j,G){for(var ne=J.length,de=0,ye=new Oa(j);de>Je]=Ge}else for(p=new Oa(ne),de=0;de>15-J[de]);return p},Jo=new Tr(288);for(var Lt=0;Lt<144;++Lt)Jo[Lt]=8;for(var Lt=144;Lt<256;++Lt)Jo[Lt]=9;for(var Lt=256;Lt<280;++Lt)Jo[Lt]=7;for(var Lt=280;Lt<288;++Lt)Jo[Lt]=8;var xd=new Tr(32);for(var Lt=0;Lt<32;++Lt)xd[Lt]=5;var Lf=Wo(Jo,9,1),Rf=Wo(xd,5,1),yh=function(J){for(var j=J[0],G=1;Gj&&(j=J[G]);return j},Hr=function(J,j,G){var ne=j/8|0;return(J[ne]|J[ne+1]<<8)>>(j&7)&G},xh=function(J,j){var G=j/8|0;return(J[G]|J[G+1]<<8|J[G+2]<<16)>>(j&7)},Bf=function(J){return(J+7)/8|0},Ff=function(J,j,G){return(G==null||G>J.length)&&(G=J.length),new Tr(J.subarray(j,G))},Of=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],wr=function(J,j,G){var ne=new Error(j||Of[J]);if(ne.code=J,Error.captureStackTrace&&Error.captureStackTrace(ne,wr),!G)throw ne;return ne},wh=function(J,j,G,ne){var de=J.length,ye=0;if(!de||j.f&&!j.l)return G||new Tr(0);var M=!G,p=M||j.i!=2,Je=j.i;M&&(G=new Tr(de*3));var Ge=function(Xr){var Ki=G.length;if(Xr>Ki){var lr=new Tr(Math.max(Ki*2,Xr));lr.set(G),G=lr}},He=j.f||0,ue=j.p||0,se=j.b||0,Ot=j.l,qt=j.d,kt=j.m,Ii=j.n,Fi=de*8;do{if(!Ot){He=Hr(J,ue,1);var Fr=Hr(J,ue+1,3);if(ue+=3,Fr)if(Fr==1)Ot=Lf,qt=Rf,kt=9,Ii=5;else if(Fr==2){var Pi=Hr(J,ue,31)+257,gi=Hr(J,ue+10,15)+4,cn=Pi+Hr(J,ue+5,31)+1;ue+=14;for(var ii=new Tr(cn),Or=new Tr(19),et=0;et>4;if(Mt<16)ii[et++]=Mt;else{var Oi=0,_i=0;for(Mt==16?(_i=3+Hr(J,ue,3),ue+=2,Oi=ii[et-1]):Mt==17?(_i=3+Hr(J,ue,7),ue+=3):Mt==18&&(_i=11+Hr(J,ue,127),ue+=7);_i--;)ii[et++]=Oi}}var un=ii.subarray(0,Pi),ri=ii.subarray(Pi);kt=yh(un),Ii=yh(ri),Ot=Wo(un,kt,1),qt=Wo(ri,Ii,1)}else wr(1);else{var Mt=Bf(ue)+4,ln=J[Mt-4]|J[Mt-3]<<8,mi=Mt+ln;if(mi>de){Je&&wr(0);break}p&&Ge(se+ln),G.set(J.subarray(Mt,mi),se),j.b=se+=ln,j.p=ue=mi*8,j.f=He;continue}if(ue>Fi){Je&&wr(0);break}}p&&Ge(se+131072);for(var ar=(1<>4;if(ue+=Oi&15,ue>Fi){Je&&wr(0);break}if(Oi||wr(2),Vi<256)G[se++]=Vi;else if(Vi==256){yi=ue,Ot=null;break}else{var or=Vi-254;if(Vi>264){var et=Vi-257,si=fd[et];or=Hr(J,ue,(1<>4;Sr||wr(3),ue+=Sr&15;var ri=Df[Yt];if(Yt>3){var si=md[Yt];ri+=xh(J,ue)&(1<Fi){Je&&wr(0);break}p&&Ge(se+131072);var Ai=se+or;if(se>3&1)+(j>>4&1);ne>0;ne-=!J[G++]);return G+(j&2)},Uf=function(J){var j=J.length;return(J[j-4]|J[j-3]<<8|J[j-2]<<16|J[j-1]<<24)>>>0},jf=function(J,j){return((J[0]&15)!=8||J[0]>>4>7||(J[0]<<8|J[1])%31)&&wr(6,"invalid zlib data"),(J[1]>>5&1)==+!j&&wr(6,"invalid zlib data: "+(J[1]&32?"need":"unexpected")+" dictionary"),(J[1]>>3&4)+2};function $f(J,j){return wh(J,{i:2},j,j)}function qf(J,j){var G=Nf(J);return G+8>J.length&&wr(6,"invalid gzip data"),wh(J.subarray(G,-8),{i:2},new Tr(Uf(J)),j)}function Zf(J,j){return wh(J.subarray(jf(J,j),-4),{i:2},j,j)}function Gf(J,j){return J[0]==31&&J[1]==139&&J[2]==8?qf(J,j):(J[0]&15)!=8||J[0]>>4>7||(J[0]<<8|J[1])%31?$f(J,j):Zf(J,j)}var Hf=typeof TextDecoder<"u"&&new TextDecoder,Xf=0;try{Hf.decode(Vf,{stream:!0}),Xf=1}catch{}var Wf=Object.defineProperty,Ko=Math.pow,At=(J,j)=>Wf(J,"name",{value:j,configurable:!0}),fi=(J,j,G)=>new Promise((ne,de)=>{var ye=Je=>{try{p(G.next(Je))}catch(Ge){de(Ge)}},M=Je=>{try{p(G.throw(Je))}catch(Ge){de(Ge)}},p=Je=>Je.done?ne(Je.value):Promise.resolve(Je.value).then(ye,M);p((G=G.apply(J,j)).next())});At((J,j)=>{let G=!1,ne="",de=L.GridLayer.extend({createTile:At((ye,M)=>{let p=document.createElement("img"),Je=new AbortController,Ge=Je.signal;return p.cancel=()=>{Je.abort()},G||(J.getHeader().then(He=>{He.tileType===1?console.error("Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details."):He.tileType===2?ne="image/png":He.tileType===3?ne="image/jpeg":He.tileType===4?ne="image/webp":He.tileType===5&&(ne="image/avif")}),G=!0),J.getZxy(ye.z,ye.x,ye.y,Ge).then(He=>{if(He){let ue=new Blob([He.data],{type:ne}),se=window.URL.createObjectURL(ue);p.src=se,p.cancel=void 0,M(void 0,p)}}).catch(He=>{if(He.name!=="AbortError")throw He}),p},"createTile"),_removeTile:At(function(ye){let M=this._tiles[ye];M&&(M.el.cancel&&M.el.cancel(),M.el.width=0,M.el.height=0,M.el.deleted=!0,L.DomUtil.remove(M.el),delete this._tiles[ye],this.fire("tileunload",{tile:M.el,coords:this._keyToTileCoords(ye)}))},"_removeTile")});return new de(j)},"leafletRasterLayer");var Kf=At(J=>(j,G)=>{if(G instanceof AbortController)return J(j,G);let ne=new AbortController;return J(j,ne).then(de=>G(void 0,de.data,de.cacheControl||"",de.expires||""),de=>G(de)).catch(de=>G(de)),{cancel:At(()=>ne.abort(),"cancel")}},"v3compat"),vd=class{constructor(j){this.tilev4=At((G,ne)=>fi(this,null,function*(){if(G.type==="json"){let Ot=G.url.substr(10),qt=this.tiles.get(Ot);if(qt||(qt=new dd(Ot),this.tiles.set(Ot,qt)),this.metadata)return{data:yield qt.getTileJson(G.url)};let kt=yield qt.getHeader();return{data:{tiles:[`${G.url}/{z}/{x}/{y}`],minzoom:kt.minZoom,maxzoom:kt.maxZoom,bounds:[kt.minLon,kt.minLat,kt.maxLon,kt.maxLat]}}}let de=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),ye=G.url.match(de);if(!ye)throw new Error("Invalid PMTiles protocol URL");let M=ye[1],p=this.tiles.get(M);p||(p=new dd(M),this.tiles.set(M,p));let Je=ye[2],Ge=ye[3],He=ye[4],ue=yield p.getHeader(),se=yield p==null?void 0:p.getZxy(+Je,+Ge,+He,ne.signal);return se?{data:new Uint8Array(se.data),cacheControl:se.cacheControl,expires:se.expires}:ue.tileType===1?{data:new Uint8Array}:{data:null}}),"tilev4"),this.tile=Kf(this.tilev4),this.tiles=new Map,this.metadata=(j==null?void 0:j.metadata)||!1}add(j){this.tiles.set(j.source.getKey(),j)}get(j){return this.tiles.get(j)}};At(vd,"Protocol");var Jf=vd;function bd(J,j){return(j>>>0)*4294967296+(J>>>0)}At(bd,"toNum");function wd(J,j){let G=j.buf,ne=G[j.pos++],de=(ne&112)>>4;if(ne<128||(ne=G[j.pos++],de|=(ne&127)<<3,ne<128)||(ne=G[j.pos++],de|=(ne&127)<<10,ne<128)||(ne=G[j.pos++],de|=(ne&127)<<17,ne<128)||(ne=G[j.pos++],de|=(ne&127)<<24,ne<128)||(ne=G[j.pos++],de|=(ne&1)<<31,ne<128))return bd(J,de);throw new Error("Expected varint not more than 10 bytes")}At(wd,"readVarintRemainder");function Fa(J){let j=J.buf,G=j[J.pos++],ne=G&127;return G<128||(G=j[J.pos++],ne|=(G&127)<<7,G<128)||(G=j[J.pos++],ne|=(G&127)<<14,G<128)||(G=j[J.pos++],ne|=(G&127)<<21,G<128)?ne:(G=j[J.pos],ne|=(G&15)<<28,wd(ne,J))}At(Fa,"readVarint");function Th(J,j,G,ne){if(ne===0){G===1&&(j[0]=J-1-j[0],j[1]=J-1-j[1]);let de=j[0];j[0]=j[1],j[1]=de}}At(Th,"rotate");function Td(J,j){let G=Ko(2,J),ne=j,de=j,ye=j,M=[0,0],p=1;for(;p26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(j>Ko(2,J)-1||G>Ko(2,J)-1)throw Error("tile x/y outside zoom level bounds");let ne=Yf[J],de=Ko(2,J),ye=0,M=0,p=0,Je=[j,G],Ge=de/2;for(;Ge>0;)ye=(Je[0]&Ge)>0?1:0,M=(Je[1]&Ge)>0?1:0,p+=Ge*Ge*(3*ye^M),Th(Ge,Je,ye,M),Ge=Ge/2;return ne+p}At(Sd,"zxyToTileId");function Qf(J){let j=0;for(let G=0;G<27;G++){let ne=(1<J)return Td(G,J-j);j+=ne}throw Error("Tile zoom level exceeds max safe number limit (26)")}At(Qf,"tileIdToZxy");var em=(J=>(J[J.Unknown=0]="Unknown",J[J.None=1]="None",J[J.Gzip=2]="Gzip",J[J.Brotli=3]="Brotli",J[J.Zstd=4]="Zstd",J))(em||{});function ic(J,j){return fi(this,null,function*(){if(j===1||j===0)return J;if(j===2){if(typeof globalThis.DecompressionStream>"u")return Gf(new Uint8Array(J));let G=new Response(J).body;if(!G)throw Error("Failed to read response stream");let ne=G.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(ne).arrayBuffer()}throw Error("Compression method not supported")})}At(ic,"defaultDecompress");var tm=(J=>(J[J.Unknown=0]="Unknown",J[J.Mvt=1]="Mvt",J[J.Png=2]="Png",J[J.Jpeg=3]="Jpeg",J[J.Webp=4]="Webp",J[J.Avif=5]="Avif",J))(tm||{});function Id(J){return J===1?".mvt":J===2?".png":J===3?".jpg":J===4?".webp":J===5?".avif":""}At(Id,"tileTypeExt");var im=127;function Pd(J,j){let G=0,ne=J.length-1;for(;G<=ne;){let de=ne+G>>1,ye=j-J[de].tileId;if(ye>0)G=de+1;else if(ye<0)ne=de-1;else return J[de]}return ne>=0&&(J[ne].runLength===0||j-J[ne].tileId-1,ye=/Chrome|Chromium|Edg|OPR|Brave/.test(ne);this.chromeWindowsNoCache=!1,de&&ye&&(this.chromeWindowsNoCache=!0)}getKey(){return this.url}setHeaders(j){this.customHeaders=j}getBytes(j,G,ne,de){return fi(this,null,function*(){let ye,M;ne?M=ne:(ye=new AbortController,M=ye.signal);let p=new Headers(this.customHeaders);p.set("range",`bytes=${j}-${j+G-1}`);let Je;this.mustReload?Je="reload":this.chromeWindowsNoCache&&(Je="no-store");let Ge=yield fetch(this.url,{signal:M,cache:Je,headers:p});if(j===0&&Ge.status===416){let se=Ge.headers.get("Content-Range");if(!se||!se.startsWith("bytes */"))throw Error("Missing content-length on 416 response");let Ot=+se.substr(8);Ge=yield fetch(this.url,{signal:M,cache:"reload",headers:{range:`bytes=0-${Ot-1}`}})}let He=Ge.headers.get("Etag");if(He!=null&&He.startsWith("W/")&&(He=null),Ge.status===416||de&&He&&He!==de)throw this.mustReload=!0,new bh(`Server returned non-matching ETag ${de} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);if(Ge.status>=300)throw Error(`Bad response code: ${Ge.status}`);let ue=Ge.headers.get("Content-Length");if(Ge.status===200&&(!ue||+ue>G))throw ye&&ye.abort(),Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield Ge.arrayBuffer(),etag:He||void 0,cacheControl:Ge.headers.get("Cache-Control")||void 0,expires:Ge.headers.get("Expires")||void 0}})}};At(Ad,"FetchSource");var nm=Ad;function Br(J,j){let G=J.getUint32(j+4,!0),ne=J.getUint32(j+0,!0);return G*Ko(2,32)+ne}At(Br,"getUint64");function Cd(J,j){let G=new DataView(J),ne=G.getUint8(7);if(ne>3)throw Error(`Archive is spec version ${ne} but this library supports up to spec version 3`);return{specVersion:ne,rootDirectoryOffset:Br(G,8),rootDirectoryLength:Br(G,16),jsonMetadataOffset:Br(G,24),jsonMetadataLength:Br(G,32),leafDirectoryOffset:Br(G,40),leafDirectoryLength:Br(G,48),tileDataOffset:Br(G,56),tileDataLength:Br(G,64),numAddressedTiles:Br(G,72),numTileEntries:Br(G,80),numTileContents:Br(G,88),clustered:G.getUint8(96)===1,internalCompression:G.getUint8(97),tileCompression:G.getUint8(98),tileType:G.getUint8(99),minZoom:G.getUint8(100),maxZoom:G.getUint8(101),minLon:G.getInt32(102,!0)/1e7,minLat:G.getInt32(106,!0)/1e7,maxLon:G.getInt32(110,!0)/1e7,maxLat:G.getInt32(114,!0)/1e7,centerZoom:G.getUint8(118),centerLon:G.getInt32(119,!0)/1e7,centerLat:G.getInt32(123,!0)/1e7,etag:j}}At(Cd,"bytesToHeader");function Sh(J){let j={buf:new Uint8Array(J),pos:0},G=Fa(j),ne=[],de=0;for(let ye=0;ye0?ne[ye].offset=ne[ye-1].offset+ne[ye-1].length:ne[ye].offset=M-1}return ne}At(Sh,"deserializeIndex");var Md=class extends Error{};At(Md,"EtagMismatch");var bh=Md;function Ih(J,j){return fi(this,null,function*(){let G=yield J.getBytes(0,16384);if(new DataView(G.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");let ne=G.data.slice(0,im),de=Cd(ne,G.etag),ye=G.data.slice(de.rootDirectoryOffset,de.rootDirectoryOffset+de.rootDirectoryLength),M=`${J.getKey()}|${de.etag||""}|${de.rootDirectoryOffset}|${de.rootDirectoryLength}`,p=Sh(yield j(ye,de.internalCompression));return[de,[M,p.length,p]]})}At(Ih,"getHeaderAndRoot");function Ph(J,j,G,ne,de){return fi(this,null,function*(){let ye=yield J.getBytes(G,ne,void 0,de.etag),M=yield j(ye.data,de.internalCompression),p=Sh(M);if(p.length===0)throw new Error("Empty directory is invalid");return p})}At(Ph,"getDirectory");var sm=class{constructor(j=100,G=!0,ne=ic){this.cache=new Map,this.maxCacheEntries=j,this.counter=1,this.decompress=ne}getHeader(j){return fi(this,null,function*(){let G=j.getKey(),ne=this.cache.get(G);if(ne)return ne.lastUsed=this.counter++,ne.data;let de=yield Ih(j,this.decompress);return de[1]&&this.cache.set(de[1][0],{lastUsed:this.counter++,data:de[1][2]}),this.cache.set(G,{lastUsed:this.counter++,data:de[0]}),this.prune(),de[0]})}getDirectory(j,G,ne,de){return fi(this,null,function*(){let ye=`${j.getKey()}|${de.etag||""}|${G}|${ne}`,M=this.cache.get(ye);if(M)return M.lastUsed=this.counter++,M.data;let p=yield Ph(j,this.decompress,G,ne,de);return this.cache.set(ye,{lastUsed:this.counter++,data:p}),this.prune(),p})}prune(){if(this.cache.size>this.maxCacheEntries){let j=1/0,G;this.cache.forEach((ne,de)=>{ne.lastUsed{Ih(j,this.decompress).then(p=>{p[1]&&this.cache.set(p[1][0],{lastUsed:this.counter++,data:Promise.resolve(p[1][2])}),ye(p[0]),this.prune()}).catch(p=>{M(p)})});return this.cache.set(G,{lastUsed:this.counter++,data:de}),de})}getDirectory(j,G,ne,de){return fi(this,null,function*(){let ye=`${j.getKey()}|${de.etag||""}|${G}|${ne}`,M=this.cache.get(ye);if(M)return M.lastUsed=this.counter++,yield M.data;let p=new Promise((Je,Ge)=>{Ph(j,this.decompress,G,ne,de).then(He=>{Je(He),this.prune()}).catch(He=>{Ge(He)})});return this.cache.set(ye,{lastUsed:this.counter++,data:p}),p})}prune(){if(this.cache.size>=this.maxCacheEntries){let j=1/0,G;this.cache.forEach((ne,de)=>{ne.lastUsed{this.getHeader(j).then(M=>{de(),this.invalidations.delete(G)}).catch(M=>{ye(M)})});this.invalidations.set(G,ne)})}};At(kd,"SharedPromiseCache");var am=kd,Ed=class{constructor(j,G,ne){typeof j=="string"?this.source=new nm(j):this.source=j,ne?this.decompress=ne:this.decompress=ic,G?this.cache=G:this.cache=new am}getHeader(){return fi(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(j,G,ne,de){return fi(this,null,function*(){let ye=Sd(j,G,ne),M=yield this.cache.getHeader(this.source);if(jM.maxZoom)return;let p=M.rootDirectoryOffset,Je=M.rootDirectoryLength;for(let Ge=0;Ge<=3;Ge++){let He=yield this.cache.getDirectory(this.source,p,Je,M),ue=Pd(He,ye);if(ue){if(ue.runLength>0){let se=yield this.source.getBytes(M.tileDataOffset+ue.offset,ue.length,de,M.etag);return{data:yield this.decompress(se.data,M.tileCompression),cacheControl:se.cacheControl,expires:se.expires}}p=M.leafDirectoryOffset+ue.offset,Je=ue.length}else return}throw Error("Maximum directory depth exceeded")})}getZxy(j,G,ne,de){return fi(this,null,function*(){try{return yield this.getZxyAttempt(j,G,ne,de)}catch(ye){if(ye instanceof bh)return this.cache.invalidate(this.source),yield this.getZxyAttempt(j,G,ne,de);throw ye}})}getMetadataAttempt(){return fi(this,null,function*(){let j=yield this.cache.getHeader(this.source),G=yield this.source.getBytes(j.jsonMetadataOffset,j.jsonMetadataLength,void 0,j.etag),ne=yield this.decompress(G.data,j.internalCompression),de=new TextDecoder("utf-8");return JSON.parse(de.decode(ne))})}getMetadata(){return fi(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(j){if(j instanceof bh)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw j}})}getTileJson(j){return fi(this,null,function*(){let G=yield this.getHeader(),ne=yield this.getMetadata(),de=Id(G.tileType);return{tilejson:"3.0.0",scheme:"xyz",tiles:[`${j}/{z}/{x}/{y}${de}`],vector_layers:ne.vector_layers,attribution:ne.attribution,description:ne.description,name:ne.name,version:ne.version,bounds:[G.minLon,G.minLat,G.maxLon,G.maxLat],center:[G.centerLon,G.centerLat,G.centerZoom],minzoom:G.minZoom,maxzoom:G.maxZoom}})}};At(Ed,"PMTiles");var dd=Ed;const om=["click"];class lm{constructor(j,G=!0){Xi(this,"button");Xi(this,"clickCallback");this.button=this.createButton();const ne=document.createElement("div");ne.classList.add("maplibregl-ctrl","maplibregl-ctrl-group"),ne.appendChild(this.button),G||(ne.style.display="none"),j.appendChild(ne)}on(j,G){if(!om.includes(j))throw new Error(`Event type ${j} is not supported.`);switch(j){case"click":this.clickCallback=G;break}}turnOn(){this.button.classList.add("maplibregl-ctrl-compass-heading-active"),this.button.setAttribute("aria-pressed","true"),this.startLoading()}turnOff(){this.button.classList.remove("maplibregl-ctrl-compass-heading-active"),this.button.setAttribute("aria-pressed","false"),this.stopLoading()}disable(){this.button.setAttribute("title","Compass not available"),this.button.setAttribute("aria-label","Compass not available"),this.button.setAttribute("disabled","disabled")}startLoading(){this.button.classList.add("maplibregl-ctrl-compass-heading-waiting")}stopLoading(){this.button.classList.remove("maplibregl-ctrl-compass-heading-waiting")}createButton(){const j=document.createElement("button");j.classList.add("maplibregl-ctrl-compass-heading"),j.setAttribute("title","Rotate map to heading-up"),j.setAttribute("aria-label","Rotate map to heading-up"),j.addEventListener("click",()=>{this.clickCallback&&this.clickCallback()});const G=document.createElement("span");return G.classList.add("maplibregl-ctrl-icon"),j.appendChild(G),j}}class cm{constructor(j){Xi(this,"element");this.element=document.createElement("div"),this.element.classList.add("maplibregl-ctrl"),this.element.innerHTML=`
  • heading:
  • -
  • accuracy:
- `,j.appendChild(this.element)}update(j,G){const re=this.element.querySelector(".heading"),he=this.element.querySelector(".accuracy");re&&(re.textContent=j),he&&(he.textContent=G)}}const hm={timeout:3e3,debug:!1,visible:!0},um=["deviceorientation","turnon","turnoff"];class dm{constructor(j){Fi(this,"map");Fi(this,"container",document.createElement("div"));Fi(this,"compassButton");Fi(this,"debugView");Fi(this,"options");Fi(this,"active",!1);Fi(this,"currentHeading");Fi(this,"currentAccuracy");Fi(this,"deviceorientationCallback");Fi(this,"turnonCallback");Fi(this,"turnoffCallback");Fi(this,"onDeviceOrientation",j=>{var he;if(!this.map)return;const G=j;if(this.currentHeading=G.webkitCompassHeading,this.currentAccuracy=G.webkitCompassAccuracy,this.deviceorientationCallback&&this.deviceorientationCallback(G),this.options.debug&&this.updateDebugView(),this.currentHeading===void 0)return;const re=this.map.getBearing();this.options.accuracy&&this.currentAccuracy&&this.currentAccuracy=1&&((he=this.map)==null||he.setBearing(this.currentHeading)),this.compassButton.stopLoading())});this.options={...hm,...j},this.compassButton=new lm(this.container),this.compassButton.on("click",()=>this.onClick()),this.options.debug&&(this.debugView=new cm(this.container))}onAdd(j){return this.map=j,this.map.on("touchmove",()=>{this.active&&(this.turnOff(),this.active=!1)}),this.container}onRemove(){this.map=void 0,this.turnOff()}on(j,G){if(!um.includes(j))throw new Error(`Event type ${j} is not supported.`);switch(j){case"deviceorientation":this.deviceorientationCallback=G;break;case"turnon":this.turnonCallback=G;break;case"turnoff":this.turnoffCallback=G;break}}turnOn(){this.compassButton.turnOn(),this.enableDeviceOrientation(),setTimeout(()=>{this.active&&this.currentHeading===void 0&&this.disable()},this.options.timeout),this.turnonCallback&&this.turnonCallback(),this.active=!0}turnOff(){this.compassButton.turnOff(),window.removeEventListener("deviceorientation",this.onDeviceOrientation,!0),this.options.debug&&this.clearDebugView(),this.turnoffCallback&&this.turnoffCallback(),this.active=!1}onClick(){this.active?this.turnOff():this.turnOn()}enableDeviceOrientation(){if("requestPermission"in window.DeviceOrientationEvent){window.DeviceOrientationEvent.requestPermission().then(j=>{j==="granted"?window.addEventListener("deviceorientation",this.onDeviceOrientation,!0):this.disable()}).catch(()=>{this.disable()});return}window.addEventListener("deviceorientation",this.onDeviceOrientation,!0)}updateDebugView(){var j;(j=this.debugView)==null||j.update(`${this.currentHeading}`,`${this.currentAccuracy}`)}clearDebugView(){var j;(j=this.debugView)==null||j.update("","")}disable(){this.compassButton.disable(),this.turnOff()}}const Va=new tc.Map({container:"app",style:"https://api.protomaps.com/styles/v4/light/en.json?key=afde32549db516d8",center:[139.7538,35.6674],zoom:11}),pm=new Jf;tc.addProtocol("pmtiles",pm.tile);const Ah=new dm({debug:!0});Ah.on("turnon",()=>{Va.setPitch(45)});Ah.on("turnoff",()=>{Va.setPitch(0),Va.setBearing(0)});Va.addControl(Ah,"top-left");Va.addControl(new tc.NavigationControl({showCompass:!0}),"top-right");Va.addControl(new tc.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),"top-right"); + `,j.appendChild(this.element)}update(j){const G=this.element.querySelector(".heading");G&&(G.textContent=j)}}const hm={timeout:3e3,debug:!1,visible:!0},um=["deviceorientation","turnon","turnoff"];class dm{constructor(j){Xi(this,"map");Xi(this,"container",document.createElement("div"));Xi(this,"compassButton");Xi(this,"debugView");Xi(this,"options");Xi(this,"active",!1);Xi(this,"currentHeading");Xi(this,"deviceorientationCallback");Xi(this,"turnonCallback");Xi(this,"turnoffCallback");Xi(this,"onDeviceOrientation",j=>{var de;if(!this.map)return;const G=j;if(this.currentHeading=G.webkitCompassHeading,this.deviceorientationCallback&&this.deviceorientationCallback(G),this.options.debug&&this.updateDebugView(),this.currentHeading===void 0)return;const ne=this.map.getBearing();Math.abs(this.currentHeading-ne)>=1&&((de=this.map)==null||de.setBearing(this.currentHeading)),this.compassButton.stopLoading()});this.options={...hm,...j},this.compassButton=new lm(this.container),this.compassButton.on("click",()=>this.onClick()),this.options.debug&&(this.debugView=new cm(this.container))}onAdd(j){return this.map=j,this.map.on("touchmove",()=>{this.active&&(this.turnOff(),this.active=!1)}),this.container}onRemove(){this.map=void 0,this.turnOff()}on(j,G){if(!um.includes(j))throw new Error(`Event type ${j} is not supported.`);switch(j){case"deviceorientation":this.deviceorientationCallback=G;break;case"turnon":this.turnonCallback=G;break;case"turnoff":this.turnoffCallback=G;break}}turnOn(){this.compassButton.turnOn(),this.enableDeviceOrientation(),setTimeout(()=>{this.active&&this.currentHeading===void 0&&this.disable()},this.options.timeout),this.turnonCallback&&this.turnonCallback(),this.active=!0}turnOff(){this.compassButton.turnOff(),window.removeEventListener("deviceorientation",this.onDeviceOrientation,!0),this.options.debug&&this.clearDebugView(),this.turnoffCallback&&this.turnoffCallback(),this.active=!1}onClick(){this.active?this.turnOff():this.turnOn()}enableDeviceOrientation(){if("requestPermission"in window.DeviceOrientationEvent){window.DeviceOrientationEvent.requestPermission().then(j=>{j==="granted"?window.addEventListener("deviceorientation",this.onDeviceOrientation,!0):this.disable()}).catch(()=>{this.disable()});return}window.addEventListener("deviceorientation",this.onDeviceOrientation,!0)}updateDebugView(){var j;(j=this.debugView)==null||j.update(`${this.currentHeading}`)}clearDebugView(){var j;(j=this.debugView)==null||j.update("")}disable(){this.compassButton.disable(),this.turnOff()}}const Va=new tc.Map({container:"app",style:"https://api.protomaps.com/styles/v4/light/en.json?key=afde32549db516d8",center:[139.7538,35.6674],zoom:11}),pm=new Jf;tc.addProtocol("pmtiles",pm.tile);const Ah=new dm({debug:!0});Ah.on("turnon",()=>{Va.setPitch(45)});Ah.on("turnoff",()=>{Va.setPitch(0),Va.setBearing(0)});Va.addControl(Ah,"top-left");Va.addControl(new tc.NavigationControl({showCompass:!0}),"top-right");Va.addControl(new tc.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),"top-right"); diff --git a/docs/index.html b/docs/index.html index d289545..7c8e1b0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ maplibre-gl-compass - + diff --git a/src/components/DebugView.ts b/src/components/DebugView.ts index 184192a..4f588e0 100644 --- a/src/components/DebugView.ts +++ b/src/components/DebugView.ts @@ -9,20 +9,15 @@ export class DebugView { this.element.innerHTML = `
  • heading:
  • -
  • accuracy:
` parent.appendChild(this.element) } - update(heading: string, accuracy: string) { + update(heading: string) { const headingSpan = this.element.querySelector('.heading') - const accuracySpan = this.element.querySelector('.accuracy') if (headingSpan) { headingSpan.textContent = heading } - if (accuracySpan) { - accuracySpan.textContent = accuracy - } } } diff --git a/src/maplibre-gl-compass.ts b/src/maplibre-gl-compass.ts index bce6979..b4b9e0e 100644 --- a/src/maplibre-gl-compass.ts +++ b/src/maplibre-gl-compass.ts @@ -5,11 +5,9 @@ import { DebugView } from './components/DebugView' // https://developer.mozilla.org/ja/docs/Web/API/DeviceOrientationEvent export type WebkitDeviceOrientationEvent = DeviceOrientationEvent & { webkitCompassHeading: number | undefined - webkitCompassAccuracy: number | undefined } type CompassControlOptions = { - accuracy?: number timeout?: number debug?: boolean visible?: boolean @@ -32,7 +30,6 @@ export class CompassControl implements IControl { private active = false private currentHeading: number | undefined - private currentAccuracy: number | undefined private deviceorientationCallback: | ((event: WebkitDeviceOrientationEvent) => void) @@ -151,7 +148,6 @@ export class CompassControl implements IControl { if (!this.map) return const webkitEvent = event as WebkitDeviceOrientationEvent this.currentHeading = webkitEvent.webkitCompassHeading - this.currentAccuracy = webkitEvent.webkitCompassAccuracy if (this.deviceorientationCallback) { this.deviceorientationCallback(webkitEvent) } @@ -162,13 +158,6 @@ export class CompassControl implements IControl { return } const bearing = this.map.getBearing() - if ( - this.options.accuracy && - this.currentAccuracy && - this.currentAccuracy < this.options.accuracy - ) { - return - } if (Math.abs(this.currentHeading - bearing) >= 1) { this.map?.setBearing(this.currentHeading) } @@ -176,11 +165,11 @@ export class CompassControl implements IControl { } private updateDebugView() { - this.debugView?.update(`${this.currentHeading}`, `${this.currentAccuracy}`) + this.debugView?.update(`${this.currentHeading}`) } private clearDebugView() { - this.debugView?.update('', '') + this.debugView?.update('') } private disable() { diff --git a/tests/DebugView.test.ts b/tests/DebugView.test.ts index 385be25..f1ca083 100644 --- a/tests/DebugView.test.ts +++ b/tests/DebugView.test.ts @@ -18,28 +18,20 @@ describe('DebugView', () => { ).toBeTruthy() }) - it('should update heading and accuracy values', () => { - debugView.update('180.123', '10.789') + it('should update heading values', () => { + debugView.update('180.123') const headingSpan = parentElement.querySelector('.heading') - const accuracySpan = parentElement.querySelector('.accuracy') - expect(headingSpan?.textContent).toBe('180.123') - expect(accuracySpan?.textContent).toBe('10.789') }) it('should handle missing elements gracefully', () => { const headingSpan = parentElement.querySelector('.heading') - const accuracySpan = parentElement.querySelector('.accuracy') headingSpan?.remove() - accuracySpan?.remove() const updatedHeadingSpan = parentElement.querySelector('.heading') - const updatedAccuracySpan = parentElement.querySelector('.accuracy') - - expect(() => debugView.update('180.123', '10.789')).not.toThrow() + expect(() => debugView.update('180.123')).not.toThrow() expect(updatedHeadingSpan).toBeNull() - expect(updatedAccuracySpan).toBeNull() }) }) diff --git a/tests/maplibre-gl-compass.test.ts b/tests/maplibre-gl-compass.test.ts index fc38523..f93cdda 100644 --- a/tests/maplibre-gl-compass.test.ts +++ b/tests/maplibre-gl-compass.test.ts @@ -76,13 +76,11 @@ describe('CompassControl', () => { it('should update debug view when debug option is enabled', () => { const debugControl = new CompassControl({ debug: true }) debugControl['currentHeading'] = 45 - debugControl['currentAccuracy'] = 10 debugControl['updateDebugView']() const debugContainer = debugControl['debugView']?.['element'] expect(debugContainer?.querySelector('.heading')?.textContent).toBe('45') - expect(debugContainer?.querySelector('.accuracy')?.textContent).toBe('10') }) it('should toggle state when clicked', () => {