wafields 0.14.3 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,580 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ap=require("./index-Cgs1ad1I.js");function Dp(wn,Ll){for(var Lr=0;Lr<Ll.length;Lr++){const Ci=Ll[Lr];if(typeof Ci!="string"&&!Array.isArray(Ci)){for(const Or in Ci)if(Or!=="default"&&!(Or in wn)){const Tn=Object.getOwnPropertyDescriptor(Ci,Or);Tn&&Object.defineProperty(wn,Or,Tn.get?Tn:{enumerable:!0,get:()=>Ci[Or]})}}}return Object.freeze(Object.defineProperty(wn,Symbol.toStringTag,{value:"Module"}))}var Fl={exports:{}};/**
2
+ * MapLibre GL JS
3
+ * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.7.1/LICENSE.txt
4
+ */var Rp=Fl.exports,Fh;function Bp(){return Fh||(Fh=1,(function(wn,Ll){(function(Lr,Ci){wn.exports=Ci()})(Rp,(function(){"use strict";var Lr={},Ci={};function Or(R,p,Pi){if(Ci[R]=Pi,R==="index"){var Hi="var sharedModule = {}; ("+Ci.shared+")(sharedModule); ("+Ci.worker+")(sharedModule);",Ge={};return Ci.shared(Ge),Ci.index(Lr,Ge),typeof window<"u"&&Lr.setWorkerUrl(window.URL.createObjectURL(new Blob([Hi],{type:"text/javascript"}))),Lr}}Or("shared",["exports"],(function(R){"use strict";function p(i,e,r,a){return new(r||(r=Promise))((function(l,h){function d(x){try{_(a.next(x))}catch(v){h(v)}}function f(x){try{_(a.throw(x))}catch(v){h(v)}}function _(x){var v;x.done?l(x.value):(v=x.value,v instanceof r?v:new r((function(w){w(v)}))).then(d,f)}_((a=a.apply(i,e||[])).next())}))}function Pi(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var Hi=Ge;function Ge(i,e){this.x=i,this.y=e}Ge.prototype={clone:function(){return new Ge(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,e){return this.clone()._rotateAround(i,e)},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 e=i.x-this.x,r=i.y-this.y;return e*e+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,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult:function(i){var e=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=e,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 e=Math.cos(i),r=Math.sin(i),a=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=a,this},_rotateAround:function(i,e){var r=Math.cos(i),a=Math.sin(i),l=e.y+a*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-a*(this.y-e.y),this.y=l,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Ge.convert=function(i){return i instanceof Ge?i:Array.isArray(i)?new Ge(i[0],i[1]):i};var mt=Pi(Hi),at=Vr;function Vr(i,e,r,a){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(a-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=a}Vr.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,e){if(e===void 0&&(e=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,a=0;a<8;a++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)<e)return r;var h=this.sampleCurveDerivativeX(r);if(Math.abs(h)<1e-6)break;r-=l/h}var d=0,f=1;for(r=i,a=0;a<20&&(l=this.sampleCurveX(r),!(Math.abs(l-i)<e));a++)i>l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var br=Pi(at);let Wi,wr;function ur(){return Wi==null&&(Wi=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Wi}function Gs(){if(wr==null&&(wr=!1,ur())){const i=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(i){for(let r=0;r<25;r++){const a=4*r;i.fillStyle=`rgb(${a},${a+1},${a+2})`,i.fillRect(r%5,Math.floor(r/5),1,1)}const e=i.getImageData(0,0,5,5).data;for(let r=0;r<100;r++)if(r%4!=3&&e[r]!==r){wr=!0;break}}}return wr||!1}function ui(i,e,r,a){const l=new br(i,e,r,a);return h=>l.solve(h)}const Sn=ui(.25,.1,.25,1);function Ai(i,e,r){return Math.min(r,Math.max(e,i))}function Ki(i,e,r){const a=r-e,l=((i-e)%a+a)%a+e;return l===e?r:l}function vi(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}let Ia=1;function Ji(i,e,r){const a={};for(const l in i)a[l]=e.call(this,i[l],l,i);return a}function Xs(i,e,r){const a={};for(const l in i)e.call(this,i[l],l,i)&&(a[l]=i[l]);return a}function ae(i){return Array.isArray(i)?i.map(ae):typeof i=="object"&&i?Ji(i,ae):i}const ka={};function Le(i){ka[i]||(typeof console<"u"&&console.warn(i),ka[i]=!0)}function Xe(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function hr(i){return typeof WorkerGlobalScope<"u"&&i!==void 0&&i instanceof WorkerGlobalScope}let os=null;function Yi(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}const Ma="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function jr(i,e,r,a,l){return p(this,void 0,void 0,(function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const h=new VideoFrame(i,{timestamp:0});try{const d=h==null?void 0:h.format;if(!d||!d.startsWith("BGR")&&!d.startsWith("RGB"))throw new Error(`Unrecognized format ${d}`);const f=d.startsWith("BGR"),_=new Uint8ClampedArray(a*l*4);if(yield h.copyTo(_,(function(x,v,w,I,E){const C=4*Math.max(-v,0),P=(Math.max(0,w)-w)*I*4+C,L=4*I,U=Math.max(0,v),Q=Math.max(0,w);return{rect:{x:U,y:Q,width:Math.min(x.width,v+I)-U,height:Math.min(x.height,w+E)-Q},layout:[{offset:P,stride:L}]}})(i,e,r,a,l)),f)for(let x=0;x<_.length;x+=4){const v=_[x];_[x]=_[x+2],_[x+2]=v}return _}finally{h.close()}}))}let dr,ti;const Di="AbortError";function ls(){return new Error(Di)}const Tr={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Qi(i){return Tr.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))]}const cs="global-dispatcher";class hi extends Error{constructor(e,r,a,l){super(`AJAXError: ${r} (${e}): ${a}`),this.status=e,this.statusText=r,this.url=a,this.body=l}}const Ri=()=>hr(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,Ur=function(i,e){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){const a=Qi(i.url);if(a)return a(i,e);if(hr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,targetMapId:cs},e)}if(!(/^file:/.test(r=i.url)||/^file:/.test(Ri())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return(function(a,l){return p(this,void 0,void 0,(function*(){const h=new Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,cache:a.cache,referrer:Ri(),signal:l.signal});a.type!=="json"||h.headers.has("Accept")||h.headers.set("Accept","application/json");const d=yield fetch(h);if(!d.ok){const x=yield d.blob();throw new hi(d.status,d.statusText,a.url,x)}let f;f=a.type==="arrayBuffer"||a.type==="image"?d.arrayBuffer():a.type==="json"?d.json():d.text();const _=yield f;if(l.signal.aborted)throw ls();return{data:_,cacheControl:d.headers.get("Cache-Control"),expires:d.headers.get("Expires")}}))})(i,e);if(hr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,mustQueue:!0,targetMapId:cs},e)}var r;return(function(a,l){return new Promise(((h,d)=>{var f;const _=new XMLHttpRequest;_.open(a.method||"GET",a.url,!0),a.type!=="arrayBuffer"&&a.type!=="image"||(_.responseType="arraybuffer");for(const x in a.headers)_.setRequestHeader(x,a.headers[x]);a.type==="json"&&(_.responseType="text",!((f=a.headers)===null||f===void 0)&&f.Accept||_.setRequestHeader("Accept","application/json")),_.withCredentials=a.credentials==="include",_.onerror=()=>{d(new Error(_.statusText))},_.onload=()=>{if(!l.signal.aborted)if((_.status>=200&&_.status<300||_.status===0)&&_.response!==null){let x=_.response;if(a.type==="json")try{x=JSON.parse(_.response)}catch(v){return void d(v)}h({data:x,cacheControl:_.getResponseHeader("Cache-Control"),expires:_.getResponseHeader("Expires")})}else{const x=new Blob([_.response],{type:_.getResponseHeader("Content-Type")});d(new hi(_.status,_.statusText,a.url,x))}},l.signal.addEventListener("abort",(()=>{_.abort(),d(ls())})),_.send(a.body)}))})(i,e)};function $r(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;const e=new URL(i),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function Hs(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function pr(i,e,r){if(r&&r[i]){const a=r[i].indexOf(e);a!==-1&&r[i].splice(a,1)}}class Sr{constructor(e,r={}){vi(this,r),this.type=e}}class Ir extends Sr{constructor(e,r={}){super("error",vi({error:e},r))}}class us{on(e,r){return this._listeners=this._listeners||{},Hs(e,r,this._listeners),this}off(e,r){return pr(e,r,this._listeners),pr(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},Hs(e,r,this._oneTimeListeners),this):new Promise((a=>this.once(e,a)))}fire(e,r){typeof e=="string"&&(e=new Sr(e,r||{}));const a=e.type;if(this.listens(a)){e.target=this;const l=this._listeners&&this._listeners[a]?this._listeners[a].slice():[];for(const f of l)f.call(this,e);const h=this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[];for(const f of h)pr(a,f,this._oneTimeListeners),f.call(this,e);const d=this._eventedParent;d&&(vi(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),d.fire(e))}else e instanceof Ir&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,r){return this._eventedParent=e,this._eventedParentData=r,this}}var it={$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 Nr=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Ws(i,e){const r={};for(const a in i)a!=="ref"&&(r[a]=i[a]);return Nr.forEach((a=>{a in e&&(r[a]=e[a])})),r}function te(i,e){if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;for(let r=0;r<i.length;r++)if(!te(i[r],e[r]))return!1;return!0}if(typeof i=="object"&&i!==null&&e!==null){if(typeof e!="object"||Object.keys(i).length!==Object.keys(e).length)return!1;for(const r in i)if(!te(i[r],e[r]))return!1;return!0}return i===e}function ye(i,e){i.push(e)}function Ks(i,e,r){ye(r,{command:"addSource",args:[i,e[i]]})}function kr(i,e,r){ye(e,{command:"removeSource",args:[i]}),r[i]=!0}function fr(i,e,r,a){kr(i,r,a),Ks(i,e,r)}function hs(i,e,r){let a;for(a in i[r])if(Object.prototype.hasOwnProperty.call(i[r],a)&&a!=="data"&&!te(i[r][a],e[r][a]))return!1;for(a in e[r])if(Object.prototype.hasOwnProperty.call(e[r],a)&&a!=="data"&&!te(i[r][a],e[r][a]))return!1;return!0}function bi(i,e,r,a,l,h){i=i||{},e=e||{};for(const d in i)Object.prototype.hasOwnProperty.call(i,d)&&(te(i[d],e[d])||r.push({command:h,args:[a,d,e[d],l]}));for(const d in e)Object.prototype.hasOwnProperty.call(e,d)&&!Object.prototype.hasOwnProperty.call(i,d)&&(te(i[d],e[d])||r.push({command:h,args:[a,d,e[d],l]}))}function Js(i){return i.id}function Ys(i,e){return i[e.id]=e,i}class ht{constructor(e,r,a,l){this.message=(e?`${e}: `:"")+a,l&&(this.identifier=l),r!=null&&r.__line__&&(this.line=r.__line__)}}function tr(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}class He extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}class er{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[a,l]of r)this.bindings[a]=l}concat(e){return new er(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Mr={kind:"null"},_t={kind:"number"},Nt={kind:"string"},Ft={kind:"boolean"},ei={kind:"color"},Bi={kind:"object"},jt={kind:"value"},ir={kind:"collator"},mr={kind:"formatted"},Er={kind:"padding"},rr={kind:"resolvedImage"},j={kind:"variableAnchorOffsetCollection"};function M(i,e){return{kind:"array",itemType:i,N:e}}function k(i){if(i.kind==="array"){const e=k(i.itemType);return typeof i.N=="number"?`array<${e}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const D=[Mr,_t,Nt,Ft,ei,mr,Bi,M(jt),Er,rr,j];function O(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!O(i.itemType,e.itemType))&&(typeof i.N!="number"||i.N===e.N))return null}else{if(i.kind===e.kind)return null;if(i.kind==="value"){for(const r of D)if(!O(r,e))return null}}return`Expected ${k(i)} but found ${k(e)} instead.`}function G(i,e){return e.some((r=>r.kind===i.kind))}function W(i,e){return e.some((r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i))}function Y(i,e){return i.kind==="array"&&e.kind==="array"?i.itemType.kind===e.itemType.kind&&typeof i.N=="number":i.kind===e.kind}const Z=.96422,st=.82521,lt=4/29,et=6/29,dt=3*et*et,At=et*et*et,Dt=Math.PI/180,Kt=180/Math.PI;function Ut(i){return(i%=360)<0&&(i+=360),i}function Jt([i,e,r,a]){let l,h;const d=ke((.2225045*(i=Gt(i))+.7168786*(e=Gt(e))+.0606169*(r=Gt(r)))/1);i===e&&e===r?l=h=d:(l=ke((.4360747*i+.3850649*e+.1430804*r)/Z),h=ke((.0139322*i+.0971045*e+.7141733*r)/st));const f=116*d-16;return[f<0?0:f,500*(l-d),200*(d-h),a]}function Gt(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function ke(i){return i>At?Math.pow(i,1/3):i/dt+lt}function xe([i,e,r,a]){let l=(i+16)/116,h=isNaN(e)?l:l+e/500,d=isNaN(r)?l:l-r/200;return l=1*re(l),h=Z*re(h),d=st*re(d),[Zt(3.1338561*h-1.6168667*l-.4906146*d),Zt(-.9787684*h+1.9161415*l+.033454*d),Zt(.0719453*h-.2289914*l+1.4052427*d),a]}function Zt(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function re(i){return i>et?i*i*i:dt*(i-lt)}function ge(i){return parseInt(i.padEnd(2,i),16)/255}function Ce(i,e){return Re(e?i/100:i,0,1)}function Re(i,e,r){return Math.min(Math.max(e,i),r)}function We(i){return!i.some(Number.isNaN)}const ds={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 se{constructor(e,r,a,l=1,h=!0){this.r=e,this.g=r,this.b=a,this.a=l,h||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[e,r,a,l]))}static parse(e){if(e instanceof se)return e;if(typeof e!="string")return;const r=(function(a){if((a=a.toLowerCase().trim())==="transparent")return[0,0,0,0];const l=ds[a];if(l){const[d,f,_]=l;return[d/255,f/255,_/255,1]}if(a.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(a)){const d=a.length<6?1:2;let f=1;return[ge(a.slice(f,f+=d)),ge(a.slice(f,f+=d)),ge(a.slice(f,f+=d)),ge(a.slice(f,f+d)||"ff")]}if(a.startsWith("rgb")){const d=a.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){const[f,_,x,v,w,I,E,C,P,L,U,Q]=d,X=[v||" ",E||" ",L].join("");if(X===" "||X===" /"||X===",,"||X===",,,"){const J=[x,I,P].join(""),rt=J==="%%%"?100:J===""?255:0;if(rt){const ct=[Re(+_/rt,0,1),Re(+w/rt,0,1),Re(+C/rt,0,1),U?Ce(+U,Q):1];if(We(ct))return ct}}return}}const h=a.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(h){const[d,f,_,x,v,w,I,E,C]=h,P=[_||" ",v||" ",I].join("");if(P===" "||P===" /"||P===",,"||P===",,,"){const L=[+f,Re(+x,0,100),Re(+w,0,100),E?Ce(+E,C):1];if(We(L))return(function([U,Q,X,J]){function rt(ct){const wt=(ct+U/30)%12,Rt=Q*Math.min(X,1-X);return X-Rt*Math.max(-1,Math.min(wt-3,9-wt,1))}return U=Ut(U),Q/=100,X/=100,[rt(0),rt(8),rt(4),J]})(L)}}})(e);return r?new se(...r,!1):void 0}get rgb(){const{r:e,g:r,b:a,a:l}=this,h=l||1/0;return this.overwriteGetter("rgb",[e/h,r/h,a/h,l])}get hcl(){return this.overwriteGetter("hcl",(function(e){const[r,a,l,h]=Jt(e),d=Math.sqrt(a*a+l*l);return[Math.round(1e4*d)?Ut(Math.atan2(l,a)*Kt):NaN,d,r,h]})(this.rgb))}get lab(){return this.overwriteGetter("lab",Jt(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){const[e,r,a,l]=this.rgb;return`rgba(${[e,r,a].map((h=>Math.round(255*h))).join(",")},${l})`}}se.black=new se(0,0,0,1),se.white=new se(1,1,1,1),se.transparent=new se(0,0,0,0),se.red=new se(1,0,0,1);class In{constructor(e,r,a){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=a,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class kn{constructor(e,r,a,l,h){this.text=e,this.image=r,this.scale=a,this.fontStack=l,this.textColor=h}}class di{constructor(e){this.sections=e}static fromString(e){return new di([new kn(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some((e=>e.text.length!==0||e.image&&e.image.name.length!==0))}static factory(e){return e instanceof di?e:di.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map((e=>e.text)).join("")}}class pi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof pi)return e;if(typeof e=="number")return new pi([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const r of e)if(typeof r!="number")return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new pi(e)}}toString(){return JSON.stringify(this.values)}}const Ol=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class wi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof wi)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let r=0;r<e.length;r+=2){const a=e[r],l=e[r+1];if(typeof a!="string"||!Ol.has(a)||!Array.isArray(l)||l.length!==2||typeof l[0]!="number"||typeof l[1]!="number")return}return new wi(e)}}toString(){return JSON.stringify(this.values)}}class fi{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new fi({name:e,available:!1}):null}}function ps(i,e,r,a){return typeof i=="number"&&i>=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?a===void 0||typeof a=="number"&&a>=0&&a<=1?null:`Invalid rgba value [${[i,e,r,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof a=="number"?[i,e,r,a]:[i,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Zr(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof se||i instanceof In||i instanceof di||i instanceof pi||i instanceof wi||i instanceof fi)return!0;if(Array.isArray(i)){for(const e of i)if(!Zr(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!Zr(i[e]))return!1;return!0}return!1}function Me(i){if(i===null)return Mr;if(typeof i=="string")return Nt;if(typeof i=="boolean")return Ft;if(typeof i=="number")return _t;if(i instanceof se)return ei;if(i instanceof In)return ir;if(i instanceof di)return mr;if(i instanceof pi)return Er;if(i instanceof wi)return j;if(i instanceof fi)return rr;if(Array.isArray(i)){const e=i.length;let r;for(const a of i){const l=Me(a);if(r){if(r===l)continue;r=jt;break}r=l}return M(r||jt,e)}return Bi}function Qs(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof se||i instanceof di||i instanceof pi||i instanceof wi||i instanceof fi?i.toString():JSON.stringify(i)}class Fi{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Zr(e[1]))return r.error("invalid value");const a=e[1];let l=Me(a);const h=r.expectedType;return l.kind!=="array"||l.N!==0||!h||h.kind!=="array"||typeof h.N=="number"&&h.N!==0||(l=h),new Fi(l,a)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Se{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const Ea={string:Nt,number:_t,boolean:Ft,object:Bi};class Li{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let a,l=1;const h=e[0];if(h==="array"){let f,_;if(e.length>2){const x=e[1];if(typeof x!="string"||!(x in Ea)||x==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);f=Ea[x],l++}else f=jt;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);_=e[2],l++}a=M(f,_)}else{if(!Ea[h])throw new Error(`Types doesn't contain name = ${h}`);a=Ea[h]}const d=[];for(;l<e.length;l++){const f=r.parse(e[l],l,jt);if(!f)return null;d.push(f)}return new Li(a,d)}evaluate(e){for(let r=0;r<this.args.length;r++){const a=this.args[r].evaluate(e);if(!O(this.type,Me(a)))return a;if(r===this.args.length-1)throw new Se(`Expected value to be of type ${k(this.type)}, but found ${k(Me(a))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Mn={"to-boolean":Ft,"to-color":ei,"to-number":_t,"to-string":Nt};class Oi{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const a=e[0];if(!Mn[a])throw new Error(`Can't parse ${a} as it is not part of the known types`);if((a==="to-boolean"||a==="to-string")&&e.length!==2)return r.error("Expected one argument.");const l=Mn[a],h=[];for(let d=1;d<e.length;d++){const f=r.parse(e[d],d,jt);if(!f)return null;h.push(f)}return new Oi(l,h)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let r,a;for(const l of this.args){if(r=l.evaluate(e),a=null,r instanceof se)return r;if(typeof r=="string"){const h=e.parseColor(r);if(h)return h}else if(Array.isArray(r)&&(a=r.length<3||r.length>4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:ps(r[0],r[1],r[2],r[3]),!a))return new se(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Se(a||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const a of this.args){r=a.evaluate(e);const l=pi.parse(r);if(l)return l}throw new Se(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const a of this.args){r=a.evaluate(e);const l=wi.parse(r);if(l)return l}throw new Se(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const a of this.args){if(r=a.evaluate(e),r===null)return 0;const l=Number(r);if(!isNaN(l))return l}throw new Se(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return di.fromString(Qs(this.args[0].evaluate(e)));case"resolvedImage":return fi.fromString(Qs(this.args[0].evaluate(e)));default:return Qs(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Vl=["Unknown","Point","LineString","Polygon"];class za{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"?Vl[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let r=this._parseColorCache[e];return r||(r=this._parseColorCache[e]=se.parse(e)),r}}class qr{constructor(e,r,a=[],l,h=new er,d=[]){this.registry=e,this.path=a,this.key=a.map((f=>`[${f}]`)).join(""),this.scope=h,this.errors=d,this.expectedType=l,this._isConstant=r}parse(e,r,a,l,h={}){return r?this.concat(r,a,l)._parse(e,h):this._parse(e,h)}_parse(e,r){function a(l,h,d){return d==="assert"?new Li(h,[l]):d==="coerce"?new Oi(h,[l]):l}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const l=e[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 h=this.registry[l];if(h){let d=h.parse(e,this);if(!d)return null;if(this.expectedType){const f=this.expectedType,_=d.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||_.kind!=="value")if(f.kind!=="color"&&f.kind!=="formatted"&&f.kind!=="resolvedImage"||_.kind!=="value"&&_.kind!=="string")if(f.kind!=="padding"||_.kind!=="value"&&_.kind!=="number"&&_.kind!=="array")if(f.kind!=="variableAnchorOffsetCollection"||_.kind!=="value"&&_.kind!=="array"){if(this.checkSubtype(f,_))return null}else d=a(d,f,r.typeAnnotation||"coerce");else d=a(d,f,r.typeAnnotation||"coerce");else d=a(d,f,r.typeAnnotation||"coerce");else d=a(d,f,r.typeAnnotation||"assert")}if(!(d instanceof Fi)&&d.type.kind!=="resolvedImage"&&this._isConstant(d)){const f=new za;try{d=new Fi(d.type,d.evaluate(f))}catch(_){return this.error(_.message),null}}return d}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,a){const l=typeof e=="number"?this.path.concat(e):this.path,h=a?this.scope.concat(a):this.scope;return new qr(this.registry,this._isConstant,l,r||null,h,this.errors)}error(e,...r){const a=`${this.key}${r.map((l=>`[${l}]`)).join("")}`;this.errors.push(new He(a,e))}checkSubtype(e,r){const a=O(e,r);return a&&this.error(a),a}}class zr{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const a=[];for(let h=1;h<e.length-1;h+=2){const d=e[h];if(typeof d!="string")return r.error(`Expected string, but found ${typeof d} instead.`,h);if(/[^a-zA-Z0-9_]/.test(d))return r.error("Variable names must contain only alphanumeric characters or '_'.",h);const f=r.parse(e[h+1],h+1);if(!f)return null;a.push([d,f])}const l=r.parse(e[e.length-1],e.length-1,r.expectedType,a);return l?new zr(a,l):null}outputDefined(){return this.result.outputDefined()}}class ee{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const a=e[1];return r.scope.has(a)?new ee(a,r.scope.get(a)):r.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class En{constructor(e,r,a){this.type=e,this.index=r,this.input=a}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,_t),l=r.parse(e[2],2,M(r.expectedType||jt));return a&&l?new En(l.type.itemType,a,l):null}evaluate(e){const r=this.index.evaluate(e),a=this.input.evaluate(e);if(r<0)throw new Se(`Array index out of bounds: ${r} < 0.`);if(r>=a.length)throw new Se(`Array index out of bounds: ${r} > ${a.length-1}.`);if(r!==Math.floor(r))throw new Se(`Array index must be an integer, but found ${r} instead.`);return a[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class zn{constructor(e,r){this.type=Ft,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,jt),l=r.parse(e[2],2,jt);return a&&l?G(a.type,[Ft,Nt,_t,Mr,jt])?new zn(a,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${k(a.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!a)return!1;if(!W(r,["boolean","string","number","null"]))throw new Se(`Expected first argument to be of type boolean, string, number or null, but found ${k(Me(r))} instead.`);if(!W(a,["string","array"]))throw new Se(`Expected second argument to be of type array or string, but found ${k(Me(a))} instead.`);return a.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class fs{constructor(e,r,a){this.type=_t,this.needle=e,this.haystack=r,this.fromIndex=a}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,jt),l=r.parse(e[2],2,jt);if(!a||!l)return null;if(!G(a.type,[Ft,Nt,_t,Mr,jt]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${k(a.type)} instead`);if(e.length===4){const h=r.parse(e[3],3,_t);return h?new fs(a,l,h):null}return new fs(a,l)}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!W(r,["boolean","string","number","null"]))throw new Se(`Expected first argument to be of type boolean, string, number or null, but found ${k(Me(r))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(e)),W(a,["string"])){const h=a.indexOf(r,l);return h===-1?-1:[...a.slice(0,h)].length}if(W(a,["array"]))return a.indexOf(r,l);throw new Se(`Expected second argument to be of type array or string, but found ${k(Me(a))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class Cn{constructor(e,r,a,l,h,d){this.inputType=e,this.type=r,this.input=a,this.cases=l,this.outputs=h,this.otherwise=d}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let a,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);const h={},d=[];for(let x=2;x<e.length-1;x+=2){let v=e[x];const w=e[x+1];Array.isArray(v)||(v=[v]);const I=r.concat(x);if(v.length===0)return I.error("Expected at least one branch label.");for(const C of v){if(typeof C!="number"&&typeof C!="string")return I.error("Branch labels must be numbers or strings.");if(typeof C=="number"&&Math.abs(C)>Number.MAX_SAFE_INTEGER)return I.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof C=="number"&&Math.floor(C)!==C)return I.error("Numeric branch labels must be integer values.");if(a){if(I.checkSubtype(a,Me(C)))return null}else a=Me(C);if(h[String(C)]!==void 0)return I.error("Branch labels must be unique.");h[String(C)]=d.length}const E=r.parse(w,x,l);if(!E)return null;l=l||E.type,d.push(E)}const f=r.parse(e[1],1,jt);if(!f)return null;const _=r.parse(e[e.length-1],e.length-1,l);return _?f.type.kind!=="value"&&r.concat(1).checkSubtype(a,f.type)?null:new Cn(a,l,f,h,d,_):null}evaluate(e){const r=this.input.evaluate(e);return(Me(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class Ca{constructor(e,r,a){this.type=e,this.branches=r,this.otherwise=a}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let a;r.expectedType&&r.expectedType.kind!=="value"&&(a=r.expectedType);const l=[];for(let d=1;d<e.length-1;d+=2){const f=r.parse(e[d],d,Ft);if(!f)return null;const _=r.parse(e[d+1],d+1,a);if(!_)return null;l.push([f,_]),a=a||_.type}const h=r.parse(e[e.length-1],e.length-1,a);if(!h)return null;if(!a)throw new Error("Can't infer output type");return new Ca(a,l,h)}evaluate(e){for(const[r,a]of this.branches)if(r.evaluate(e))return a.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[r,a]of this.branches)e(r),e(a);e(this.otherwise)}outputDefined(){return this.branches.every((([e,r])=>r.outputDefined()))&&this.otherwise.outputDefined()}}class ta{constructor(e,r,a,l){this.type=e,this.input=r,this.beginIndex=a,this.endIndex=l}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,jt),l=r.parse(e[2],2,_t);if(!a||!l)return null;if(!G(a.type,[M(jt),Nt,jt]))return r.error(`Expected first argument to be of type array or string, but found ${k(a.type)} instead`);if(e.length===4){const h=r.parse(e[3],3,_t);return h?new ta(a.type,a,l,h):null}return new ta(a.type,a,l)}evaluate(e){const r=this.input.evaluate(e),a=this.beginIndex.evaluate(e);let l;if(this.endIndex&&(l=this.endIndex.evaluate(e)),W(r,["string"]))return[...r].slice(a,l).join("");if(W(r,["array"]))return r.slice(a,l);throw new Se(`Expected first argument to be of type array or string, but found ${k(Me(r))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Pa(i,e){const r=i.length-1;let a,l,h=0,d=r,f=0;for(;h<=d;)if(f=Math.floor((h+d)/2),a=i[f],l=i[f+1],a<=e){if(f===r||e<l)return f;h=f+1}else{if(!(a>e))throw new Se("Input is not a number.");d=f-1}return 0}class ms{constructor(e,r,a){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[l,h]of a)this.labels.push(l),this.outputs.push(h)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const a=r.parse(e[1],1,_t);if(!a)return null;const l=[];let h=null;r.expectedType&&r.expectedType.kind!=="value"&&(h=r.expectedType);for(let d=1;d<e.length;d+=2){const f=d===1?-1/0:e[d],_=e[d+1],x=d,v=d+1;if(typeof f!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',x);if(l.length&&l[l.length-1][0]>=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(_,v,h);if(!w)return null;h=h||w.type,l.push([f,w])}return new ms(h,a,l)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return a[0].evaluate(e);const h=r.length;return l>=r[h-1]?a[h-1].evaluate(e):a[Pa(r,l)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Ro(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var jl=Bo;function Bo(i,e,r,a){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(a-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=a}Bo.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,e){if(e===void 0&&(e=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,a=0;a<8;a++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)<e)return r;var h=this.sampleCurveDerivativeX(r);if(Math.abs(h)<1e-6)break;r-=l/h}var d=0,f=1;for(r=i,a=0;a<20&&(l=this.sampleCurveX(r),!(Math.abs(l-i)<e));a++)i>l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var Ul=Ro(jl);function Gr(i,e,r){return i+r*(e-i)}function ea(i,e,r){return i.map(((a,l)=>Gr(a,e[l],r)))}const ii={number:Gr,color:function(i,e,r,a="rgb"){switch(a){case"rgb":{const[l,h,d,f]=ea(i.rgb,e.rgb,r);return new se(l,h,d,f,!1)}case"hcl":{const[l,h,d,f]=i.hcl,[_,x,v,w]=e.hcl;let I,E;if(isNaN(l)||isNaN(_))isNaN(l)?isNaN(_)?I=NaN:(I=_,d!==1&&d!==0||(E=x)):(I=l,v!==1&&v!==0||(E=h));else{let Q=_-l;_>l&&Q>180?Q-=360:_<l&&l-_>180&&(Q+=360),I=l+r*Q}const[C,P,L,U]=(function([Q,X,J,rt]){return Q=isNaN(Q)?0:Q*Dt,xe([J,Math.cos(Q)*X,Math.sin(Q)*X,rt])})([I,E??Gr(h,x,r),Gr(d,v,r),Gr(f,w,r)]);return new se(C,P,L,U,!1)}case"lab":{const[l,h,d,f]=xe(ea(i.lab,e.lab,r));return new se(l,h,d,f,!1)}}},array:ea,padding:function(i,e,r){return new pi(ea(i.values,e.values,r))},variableAnchorOffsetCollection:function(i,e,r){const a=i.values,l=e.values;if(a.length!==l.length)throw new Se(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${e.toString()}`);const h=[];for(let d=0;d<a.length;d+=2){if(a[d]!==l[d])throw new Se(`Cannot interpolate values containing mismatched anchors. from[${d}]: ${a[d]}, to[${d}]: ${l[d]}`);h.push(a[d]);const[f,_]=a[d+1],[x,v]=l[d+1];h.push([Gr(f,x,r),Gr(_,v,r)])}return new wi(h)}};class ri{constructor(e,r,a,l,h){this.type=e,this.operator=r,this.interpolation=a,this.input=l,this.labels=[],this.outputs=[];for(const[d,f]of h)this.labels.push(d),this.outputs.push(f)}static interpolationFactor(e,r,a,l){let h=0;if(e.name==="exponential")h=Aa(r,e.base,a,l);else if(e.name==="linear")h=Aa(r,1,a,l);else if(e.name==="cubic-bezier"){const d=e.controlPoints;h=new Ul(d[0],d[1],d[2],d[3]).solve(Aa(r,1,a,l))}return h}static parse(e,r){let[a,l,h,...d]=e;if(!Array.isArray(l)||l.length===0)return r.error("Expected an interpolation type expression.",1);if(l[0]==="linear")l={name:"linear"};else if(l[0]==="exponential"){const x=l[1];if(typeof x!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);l={name:"exponential",base:x}}else{if(l[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(l[0])}`,1,0);{const x=l.slice(1);if(x.length!==4||x.some((v=>typeof 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(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(h=r.parse(h,2,_t),!h)return null;const f=[];let _=null;a==="interpolate-hcl"||a==="interpolate-lab"?_=ei:r.expectedType&&r.expectedType.kind!=="value"&&(_=r.expectedType);for(let x=0;x<d.length;x+=2){const v=d[x],w=d[x+1],I=x+3,E=x+4;if(typeof v!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',I);if(f.length&&f[f.length-1][0]>=v)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',I);const C=r.parse(w,E,_);if(!C)return null;_=_||C.type,f.push([v,C])}return Y(_,_t)||Y(_,ei)||Y(_,Er)||Y(_,j)||Y(_,M(_t))?new ri(_,a,l,h,f):r.error(`Type ${k(_)} is not interpolatable.`)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return a[0].evaluate(e);const h=r.length;if(l>=r[h-1])return a[h-1].evaluate(e);const d=Pa(r,l),f=ri.interpolationFactor(this.interpolation,l,r[d],r[d+1]),_=a[d].evaluate(e),x=a[d+1].evaluate(e);switch(this.operator){case"interpolate":return ii[this.type.kind](_,x,f);case"interpolate-hcl":return ii.color(_,x,f,"hcl");case"interpolate-lab":return ii.color(_,x,f,"lab")}}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Aa(i,e,r,a){const l=a-r,h=i-r;return l===0?0:e===1?h/l:(Math.pow(e,h)-1)/(Math.pow(e,l)-1)}class Da{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let a=null;const l=r.expectedType;l&&l.kind!=="value"&&(a=l);const h=[];for(const f of e.slice(1)){const _=r.parse(f,1+h.length,a,void 0,{typeAnnotation:"omit"});if(!_)return null;a=a||_.type,h.push(_)}if(!a)throw new Error("No output type");const d=l&&h.some((f=>O(l,f.type)));return new Da(d?jt:a,h)}evaluate(e){let r,a=null,l=0;for(const h of this.args)if(l++,a=h.evaluate(e),a&&a instanceof fi&&!a.available&&(r||(r=a.name),a=null,l===this.args.length&&(a=r)),a!==null)break;return a}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function Ra(i,e){return i==="=="||i==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Fo(i,e,r,a){return a.compare(e,r)===0}function _s(i,e,r){const a=i!=="=="&&i!=="!=";return class Lh{constructor(h,d,f){this.type=Ft,this.lhs=h,this.rhs=d,this.collator=f,this.hasUntypedArgument=h.type.kind==="value"||d.type.kind==="value"}static parse(h,d){if(h.length!==3&&h.length!==4)return d.error("Expected two or three arguments.");const f=h[0];let _=d.parse(h[1],1,jt);if(!_)return null;if(!Ra(f,_.type))return d.concat(1).error(`"${f}" comparisons are not supported for type '${k(_.type)}'.`);let x=d.parse(h[2],2,jt);if(!x)return null;if(!Ra(f,x.type))return d.concat(2).error(`"${f}" comparisons are not supported for type '${k(x.type)}'.`);if(_.type.kind!==x.type.kind&&_.type.kind!=="value"&&x.type.kind!=="value")return d.error(`Cannot compare types '${k(_.type)}' and '${k(x.type)}'.`);a&&(_.type.kind==="value"&&x.type.kind!=="value"?_=new Li(x.type,[_]):_.type.kind!=="value"&&x.type.kind==="value"&&(x=new Li(_.type,[x])));let v=null;if(h.length===4){if(_.type.kind!=="string"&&x.type.kind!=="string"&&_.type.kind!=="value"&&x.type.kind!=="value")return d.error("Cannot use collator to compare non-string types.");if(v=d.parse(h[3],3,ir),!v)return null}return new Lh(_,x,v)}evaluate(h){const d=this.lhs.evaluate(h),f=this.rhs.evaluate(h);if(a&&this.hasUntypedArgument){const _=Me(d),x=Me(f);if(_.kind!==x.kind||_.kind!=="string"&&_.kind!=="number")throw new Se(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${_.kind}, ${x.kind}) instead.`)}if(this.collator&&!a&&this.hasUntypedArgument){const _=Me(d),x=Me(f);if(_.kind!=="string"||x.kind!=="string")return e(h,d,f)}return this.collator?r(h,d,f,this.collator.evaluate(h)):e(h,d,f)}eachChild(h){h(this.lhs),h(this.rhs),this.collator&&h(this.collator)}outputDefined(){return!0}}}const $l=_s("==",(function(i,e,r){return e===r}),Fo),Lo=_s("!=",(function(i,e,r){return e!==r}),(function(i,e,r,a){return!Fo(0,e,r,a)})),Oo=_s("<",(function(i,e,r){return e<r}),(function(i,e,r,a){return a.compare(e,r)<0})),Nl=_s(">",(function(i,e,r){return e>r}),(function(i,e,r,a){return a.compare(e,r)>0})),Zl=_s("<=",(function(i,e,r){return e<=r}),(function(i,e,r,a){return a.compare(e,r)<=0})),Vo=_s(">=",(function(i,e,r){return e>=r}),(function(i,e,r,a){return a.compare(e,r)>=0}));class ia{constructor(e,r,a){this.type=ir,this.locale=a,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const a=e[1];if(typeof a!="object"||Array.isArray(a))return r.error("Collator options argument must be an object.");const l=r.parse(a["case-sensitive"]!==void 0&&a["case-sensitive"],1,Ft);if(!l)return null;const h=r.parse(a["diacritic-sensitive"]!==void 0&&a["diacritic-sensitive"],1,Ft);if(!h)return null;let d=null;return a.locale&&(d=r.parse(a.locale,1,Nt),!d)?null:new ia(l,h,d)}evaluate(e){return new In(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Pn{constructor(e,r,a,l,h){this.type=Nt,this.number=e,this.locale=r,this.currency=a,this.minFractionDigits=l,this.maxFractionDigits=h}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const a=r.parse(e[1],1,_t);if(!a)return null;const l=e[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let h=null;if(l.locale&&(h=r.parse(l.locale,1,Nt),!h))return null;let d=null;if(l.currency&&(d=r.parse(l.currency,1,Nt),!d))return null;let f=null;if(l["min-fraction-digits"]&&(f=r.parse(l["min-fraction-digits"],1,_t),!f))return null;let _=null;return l["max-fraction-digits"]&&(_=r.parse(l["max-fraction-digits"],1,_t),!_)?null:new Pn(a,h,d,f,_)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Ba{constructor(e){this.type=mr,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const a=e[1];if(!Array.isArray(a)&&typeof a=="object")return r.error("First argument must be an image or text section.");const l=[];let h=!1;for(let d=1;d<=e.length-1;++d){const f=e[d];if(h&&typeof f=="object"&&!Array.isArray(f)){h=!1;let _=null;if(f["font-scale"]&&(_=r.parse(f["font-scale"],1,_t),!_))return null;let x=null;if(f["text-font"]&&(x=r.parse(f["text-font"],1,M(Nt)),!x))return null;let v=null;if(f["text-color"]&&(v=r.parse(f["text-color"],1,ei),!v))return null;const w=l[l.length-1];w.scale=_,w.font=x,w.textColor=v}else{const _=r.parse(e[d],1,jt);if(!_)return null;const x=_.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,l.push({content:_,scale:null,font:null,textColor:null})}}return new Ba(l)}evaluate(e){return new di(this.sections.map((r=>{const a=r.content.evaluate(e);return Me(a)===rr?new kn("",a,null,null,null):new kn(Qs(a),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)})))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}}class An{constructor(e){this.type=rr,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const a=r.parse(e[1],1,Nt);return a?new An(a):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),a=fi.fromString(r);return a&&e.availableImages&&(a.available=e.availableImages.indexOf(r)>-1),a}eachChild(e){e(this.input)}outputDefined(){return!1}}class Dn{constructor(e){this.type=_t,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const a=r.parse(e[1],1);return a?a.type.kind!=="array"&&a.type.kind!=="string"&&a.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${k(a.type)} instead.`):new Dn(a):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new Se(`Expected value to be of type string or array, but found ${k(Me(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const sr=8192;function ql(i,e){const r=(180+i[0])/360,a=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,l=Math.pow(2,e.z);return[Math.round(r*l*sr),Math.round(a*l*sr)]}function Rn(i,e){const r=Math.pow(2,e.z);return[(l=(i[0]/sr+e.x)/r,360*l-180),(a=(i[1]/sr+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90)];var a,l}function Xr(i,e){i[0]=Math.min(i[0],e[0]),i[1]=Math.min(i[1],e[1]),i[2]=Math.max(i[2],e[0]),i[3]=Math.max(i[3],e[1])}function Cr(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function ie(i,e,r){const a=i[0]-e[0],l=i[1]-e[1],h=i[0]-r[0],d=i[1]-r[1];return a*d-h*l==0&&a*h<=0&&l*d<=0}function Fa(i,e,r,a){return(l=[a[0]-r[0],a[1]-r[1]])[0]*(h=[e[0]-i[0],e[1]-i[1]])[1]-l[1]*h[0]!=0&&!(!Uo(i,e,r,a)||!Uo(r,a,i,e));var l,h}function Gl(i,e,r){for(const a of r)for(let l=0;l<a.length-1;++l)if(Fa(i,e,a[l],a[l+1]))return!0;return!1}function gs(i,e,r=!1){let a=!1;for(const f of e)for(let _=0;_<f.length-1;_++){if(ie(i,f[_],f[_+1]))return r;(h=f[_])[1]>(l=i)[1]!=(d=f[_+1])[1]>l[1]&&l[0]<(d[0]-h[0])*(l[1]-h[1])/(d[1]-h[1])+h[0]&&(a=!a)}var l,h,d;return a}function Xl(i,e){for(const r of e)if(gs(i,r))return!0;return!1}function jo(i,e){for(const r of i)if(!gs(r,e))return!1;for(let r=0;r<i.length-1;++r)if(Gl(i[r],i[r+1],e))return!1;return!0}function Hl(i,e){for(const r of e)if(jo(i,r))return!0;return!1}function Uo(i,e,r,a){const l=a[0]-r[0],h=a[1]-r[1],d=(i[0]-r[0])*h-l*(i[1]-r[1]),f=(e[0]-r[0])*h-l*(e[1]-r[1]);return d>0&&f<0||d<0&&f>0}function Bn(i,e,r){const a=[];for(let l=0;l<i.length;l++){const h=[];for(let d=0;d<i[l].length;d++){const f=ql(i[l][d],r);Xr(e,f),h.push(f)}a.push(h)}return a}function $o(i,e,r){const a=[];for(let l=0;l<i.length;l++){const h=Bn(i[l],e,r);a.push(h)}return a}function No(i,e,r,a){if(i[0]<r[0]||i[0]>r[2]){const l=.5*a;let h=i[0]-r[0]>l?-a:r[0]-i[0]>l?a:0;h===0&&(h=i[0]-r[2]>l?-a:r[2]-i[0]>l?a:0),i[0]+=h}Xr(e,i)}function Zo(i,e,r,a){const l=Math.pow(2,a.z)*sr,h=[a.x*sr,a.y*sr],d=[];for(const f of i)for(const _ of f){const x=[_.x+h[0],_.y+h[1]];No(x,e,r,l),d.push(x)}return d}function qo(i,e,r,a){const l=Math.pow(2,a.z)*sr,h=[a.x*sr,a.y*sr],d=[];for(const _ of i){const x=[];for(const v of _){const w=[v.x+h[0],v.y+h[1]];Xr(e,w),x.push(w)}d.push(x)}if(e[2]-e[0]<=l/2){(f=e)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const _ of d)for(const x of _)No(x,e,r,l)}var f;return d}class Hr{constructor(e,r){this.type=Ft,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Zr(e[1])){const a=e[1];if(a.type==="FeatureCollection"){const l=[];for(const h of a.features){const{type:d,coordinates:f}=h.geometry;d==="Polygon"&&l.push(f),d==="MultiPolygon"&&l.push(...f)}if(l.length)return new Hr(a,{type:"MultiPolygon",coordinates:l})}else if(a.type==="Feature"){const l=a.geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new Hr(a,a.geometry)}else if(a.type==="Polygon"||a.type==="MultiPolygon")return new Hr(a,a)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(r,a){const l=[1/0,1/0,-1/0,-1/0],h=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(a.type==="Polygon"){const f=Bn(a.coordinates,h,d),_=Zo(r.geometry(),l,h,d);if(!Cr(l,h))return!1;for(const x of _)if(!gs(x,f))return!1}if(a.type==="MultiPolygon"){const f=$o(a.coordinates,h,d),_=Zo(r.geometry(),l,h,d);if(!Cr(l,h))return!1;for(const x of _)if(!Xl(x,f))return!1}return!0})(e,this.geometries);if(e.geometryType()==="LineString")return(function(r,a){const l=[1/0,1/0,-1/0,-1/0],h=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(a.type==="Polygon"){const f=Bn(a.coordinates,h,d),_=qo(r.geometry(),l,h,d);if(!Cr(l,h))return!1;for(const x of _)if(!jo(x,f))return!1}if(a.type==="MultiPolygon"){const f=$o(a.coordinates,h,d),_=qo(r.geometry(),l,h,d);if(!Cr(l,h))return!1;for(const x of _)if(!Hl(x,f))return!1}return!0})(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Go=class{constructor(i=[],e=((r,a)=>r<a?-1:r>a?1:0)){if(this.data=i,this.length=this.data.length,this.compare=e,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],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:e,compare:r}=this,a=e[i];for(;i>0;){const l=i-1>>1,h=e[l];if(r(a,h)>=0)break;e[i]=h,i=l}e[i]=a}_down(i){const{data:e,compare:r}=this,a=this.length>>1,l=e[i];for(;i<a;){let h=1+(i<<1);const d=h+1;if(d<this.length&&r(e[d],e[h])<0&&(h=d),r(e[h],l)>=0)break;e[i]=e[h],i=h}e[i]=l}};function Wl(i,e,r,a,l){Xo(i,e,r,a||i.length-1,l||Kl)}function Xo(i,e,r,a,l){for(;a>r;){if(a-r>600){var h=a-r+1,d=e-r+1,f=Math.log(h),_=.5*Math.exp(2*f/3),x=.5*Math.sqrt(f*_*(h-_)/h)*(d-h/2<0?-1:1);Xo(i,e,Math.max(r,Math.floor(e-d*_/h+x)),Math.min(a,Math.floor(e+(h-d)*_/h+x)),l)}var v=i[e],w=r,I=a;for(ra(i,r,e),l(i[a],v)>0&&ra(i,r,a);w<I;){for(ra(i,w,I),w++,I--;l(i[w],v)<0;)w++;for(;l(i[I],v)>0;)I--}l(i[r],v)===0?ra(i,r,I):ra(i,++I,a),I<=e&&(r=I+1),e<=I&&(a=I-1)}}function ra(i,e,r){var a=i[e];i[e]=i[r],i[r]=a}function Kl(i,e){return i<e?-1:i>e?1:0}function La(i,e){if(i.length<=1)return[i];const r=[];let a,l;for(const h of i){const d=Yl(h);d!==0&&(h.area=Math.abs(d),l===void 0&&(l=d<0),l===d<0?(a&&r.push(a),a=[h]):a.push(h))}if(a&&r.push(a),e>1)for(let h=0;h<r.length;h++)r[h].length<=e||(Wl(r[h],e,1,r[h].length-1,Jl),r[h]=r[h].slice(0,e));return r}function Jl(i,e){return e.area-i.area}function Yl(i){let e=0;for(let r,a,l=0,h=i.length,d=h-1;l<h;d=l++)r=i[l],a=i[d],e+=(a.x-r.x)*(r.y+a.y);return e}const Ho=1/298.257223563,Wo=Ho*(2-Ho),Ko=Math.PI/180;class Fn{constructor(e){const r=6378.137*Ko*1e3,a=Math.cos(e*Ko),l=1/(1-Wo*(1-a*a)),h=Math.sqrt(l);this.kx=r*h*a,this.ky=r*h*l*(1-Wo)}distance(e,r){const a=this.wrap(e[0]-r[0])*this.kx,l=(e[1]-r[1])*this.ky;return Math.sqrt(a*a+l*l)}pointOnLine(e,r){let a,l,h,d,f=1/0;for(let _=0;_<e.length-1;_++){let x=e[_][0],v=e[_][1],w=this.wrap(e[_+1][0]-x)*this.kx,I=(e[_+1][1]-v)*this.ky,E=0;w===0&&I===0||(E=(this.wrap(r[0]-x)*this.kx*w+(r[1]-v)*this.ky*I)/(w*w+I*I),E>1?(x=e[_+1][0],v=e[_+1][1]):E>0&&(x+=w/this.kx*E,v+=I/this.ky*E)),w=this.wrap(r[0]-x)*this.kx,I=(r[1]-v)*this.ky;const C=w*w+I*I;C<f&&(f=C,a=x,l=v,h=_,d=E)}return{point:[a,l],index:h,t:Math.max(0,Math.min(1,d))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function Jo(i,e){return e[0]-i[0]}function Oa(i){return i[1]-i[0]+1}function _r(i,e){return i[1]>=i[0]&&i[1]<e}function Ln(i,e){if(i[0]>i[1])return[null,null];const r=Oa(i);if(e){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 a=Math.floor(r/2)-1;return[[i[0],i[0]+a],[i[0]+a+1,i[1]]]}function On(i,e){if(!_r(e,i.length))return[1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let a=e[0];a<=e[1];++a)Xr(r,i[a]);return r}function Vn(i){const e=[1/0,1/0,-1/0,-1/0];for(const r of i)for(const a of r)Xr(e,a);return e}function Va(i){return i[0]!==-1/0&&i[1]!==-1/0&&i[2]!==1/0&&i[3]!==1/0}function jn(i,e,r){if(!Va(i)||!Va(e))return NaN;let a=0,l=0;return i[2]<e[0]&&(a=e[0]-i[2]),i[0]>e[2]&&(a=i[0]-e[2]),i[1]>e[3]&&(l=i[1]-e[3]),i[3]<e[1]&&(l=e[1]-i[3]),r.distance([0,0],[a,l])}function Wr(i,e,r){const a=r.pointOnLine(e,i);return r.distance(i,a.point)}function Un(i,e,r,a,l){const h=Math.min(Wr(i,[r,a],l),Wr(e,[r,a],l)),d=Math.min(Wr(r,[i,e],l),Wr(a,[i,e],l));return Math.min(h,d)}function Ql(i,e,r,a,l){if(!_r(e,i.length)||!_r(a,r.length))return 1/0;let h=1/0;for(let d=e[0];d<e[1];++d){const f=i[d],_=i[d+1];for(let x=a[0];x<a[1];++x){const v=r[x],w=r[x+1];if(Fa(f,_,v,w))return 0;h=Math.min(h,Un(f,_,v,w,l))}}return h}function be(i,e,r,a,l){if(!_r(e,i.length)||!_r(a,r.length))return NaN;let h=1/0;for(let d=e[0];d<=e[1];++d)for(let f=a[0];f<=a[1];++f)if(h=Math.min(h,l.distance(i[d],r[f])),h===0)return h;return h}function tc(i,e,r){if(gs(i,e,!0))return 0;let a=1/0;for(const l of e){const h=l[0],d=l[l.length-1];if(h!==d&&(a=Math.min(a,Wr(i,[d,h],r)),a===0))return a;const f=r.pointOnLine(l,i);if(a=Math.min(a,r.distance(i,f.point)),a===0)return a}return a}function qt(i,e,r,a){if(!_r(e,i.length))return NaN;for(let h=e[0];h<=e[1];++h)if(gs(i[h],r,!0))return 0;let l=1/0;for(let h=e[0];h<e[1];++h){const d=i[h],f=i[h+1];for(const _ of r)for(let x=0,v=_.length,w=v-1;x<v;w=x++){const I=_[w],E=_[x];if(Fa(d,f,I,E))return 0;l=Math.min(l,Un(d,f,I,E,a))}}return l}function ja(i,e){for(const r of i)for(const a of r)if(gs(a,e,!0))return!0;return!1}function ue(i,e,r,a=1/0){const l=Vn(i),h=Vn(e);if(a!==1/0&&jn(l,h,r)>=a)return a;if(Cr(l,h)){if(ja(i,e))return 0}else if(ja(e,i))return 0;let d=1/0;for(const f of i)for(let _=0,x=f.length,v=x-1;_<x;v=_++){const w=f[v],I=f[_];for(const E of e)for(let C=0,P=E.length,L=P-1;C<P;L=C++){const U=E[L],Q=E[C];if(Fa(w,I,U,Q))return 0;d=Math.min(d,Un(w,I,U,Q,r))}}return d}function ne(i,e,r,a,l,h){if(!h)return;const d=jn(On(a,h),l,r);d<e&&i.push([d,h,[0,0]])}function Kr(i,e,r,a,l,h,d){if(!h||!d)return;const f=jn(On(a,h),On(l,d),r);f<e&&i.push([f,h,d])}function sa(i,e,r,a,l=1/0){let h=Math.min(a.distance(i[0],r[0][0]),l);if(h===0)return h;const d=new Go([[0,[0,i.length-1],[0,0]]],Jo),f=Vn(r);for(;d.length>0;){const _=d.pop();if(_[0]>=h)continue;const x=_[1],v=e?50:100;if(Oa(x)<=v){if(!_r(x,i.length))return NaN;if(e){const w=qt(i,x,r,a);if(isNaN(w)||w===0)return w;h=Math.min(h,w)}else for(let w=x[0];w<=x[1];++w){const I=tc(i[w],r,a);if(h=Math.min(h,I),h===0)return 0}}else{const w=Ln(x,e);ne(d,h,a,i,f,w[0]),ne(d,h,a,i,f,w[1])}}return h}function aa(i,e,r,a,l,h=1/0){let d=Math.min(h,l.distance(i[0],r[0]));if(d===0)return d;const f=new Go([[0,[0,i.length-1],[0,r.length-1]]],Jo);for(;f.length>0;){const _=f.pop();if(_[0]>=d)continue;const x=_[1],v=_[2],w=e?50:100,I=a?50:100;if(Oa(x)<=w&&Oa(v)<=I){if(!_r(x,i.length)&&_r(v,r.length))return NaN;let E;if(e&&a)E=Ql(i,x,r,v,l),d=Math.min(d,E);else if(e&&!a){const C=i.slice(x[0],x[1]+1);for(let P=v[0];P<=v[1];++P)if(E=Wr(r[P],C,l),d=Math.min(d,E),d===0)return d}else if(!e&&a){const C=r.slice(v[0],v[1]+1);for(let P=x[0];P<=x[1];++P)if(E=Wr(i[P],C,l),d=Math.min(d,E),d===0)return d}else E=be(i,x,r,v,l),d=Math.min(d,E)}else{const E=Ln(x,e),C=Ln(v,a);Kr(f,d,l,i,r,E[0],C[0]),Kr(f,d,l,i,r,E[0],C[1]),Kr(f,d,l,i,r,E[1],C[0]),Kr(f,d,l,i,r,E[1],C[1])}}return d}function $n(i){return i.type==="MultiPolygon"?i.coordinates.map((e=>({type:"Polygon",coordinates:e}))):i.type==="MultiLineString"?i.coordinates.map((e=>({type:"LineString",coordinates:e}))):i.type==="MultiPoint"?i.coordinates.map((e=>({type:"Point",coordinates:e}))):[i]}class Jr{constructor(e,r){this.type=_t,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Zr(e[1])){const a=e[1];if(a.type==="FeatureCollection")return new Jr(a,a.features.map((l=>$n(l.geometry))).flat());if(a.type==="Feature")return new Jr(a,$n(a.geometry));if("type"in a&&"coordinates"in a)return new Jr(a,$n(a))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(r,a){const l=r.geometry(),h=l.flat().map((_=>Rn([_.x,_.y],r.canonical)));if(l.length===0)return NaN;const d=new Fn(h[0][1]);let f=1/0;for(const _ of a){switch(_.type){case"Point":f=Math.min(f,aa(h,!1,[_.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,aa(h,!1,_.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,sa(h,!1,_.coordinates,d,f))}if(f===0)return f}return f})(e,this.geometries);if(e.geometryType()==="LineString")return(function(r,a){const l=r.geometry(),h=l.flat().map((_=>Rn([_.x,_.y],r.canonical)));if(l.length===0)return NaN;const d=new Fn(h[0][1]);let f=1/0;for(const _ of a){switch(_.type){case"Point":f=Math.min(f,aa(h,!0,[_.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,aa(h,!0,_.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,sa(h,!0,_.coordinates,d,f))}if(f===0)return f}return f})(e,this.geometries);if(e.geometryType()==="Polygon")return(function(r,a){const l=r.geometry();if(l.length===0||l[0].length===0)return NaN;const h=La(l,0).map((_=>_.map((x=>x.map((v=>Rn([v.x,v.y],r.canonical))))))),d=new Fn(h[0][0][0][1]);let f=1/0;for(const _ of a)for(const x of h){switch(_.type){case"Point":f=Math.min(f,sa([_.coordinates],!1,x,d,f));break;case"LineString":f=Math.min(f,sa(_.coordinates,!0,x,d,f));break;case"Polygon":f=Math.min(f,ue(x,_.coordinates,d,f))}if(f===0)return f}return f})(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const ys={"==":$l,"!=":Lo,">":Nl,"<":Oo,">=":Vo,"<=":Zl,array:Li,at:En,boolean:Li,case:Ca,coalesce:Da,collator:ia,format:Ba,image:An,in:zn,"index-of":fs,interpolate:ri,"interpolate-hcl":ri,"interpolate-lab":ri,length:Dn,let:zr,literal:Fi,match:Cn,number:Li,"number-format":Pn,object:Li,slice:ta,step:ms,string:Li,"to-boolean":Oi,"to-color":Oi,"to-number":Oi,"to-string":Oi,var:ee,within:Hr,distance:Jr};class Ti{constructor(e,r,a,l){this.name=e,this.type=r,this._evaluate=a,this.args=l}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){const a=e[0],l=Ti.definitions[a];if(!l)return r.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0);const h=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===e.length-1));let _=null;for(const[x,v]of f){_=new qr(r.registry,na,r.path,null,r.scope);const w=[];let I=!1;for(let E=1;E<e.length;E++){const C=e[E],P=Array.isArray(x)?x[E-1]:x.type,L=_.parse(C,1+w.length,P);if(!L){I=!0;break}w.push(L)}if(!I)if(Array.isArray(x)&&x.length!==w.length)_.error(`Expected ${x.length} arguments, but found ${w.length} instead.`);else{for(let E=0;E<w.length;E++){const C=Array.isArray(x)?x[E]:x.type,P=w[E];_.concat(E+1).checkSubtype(C,P.type)}if(_.errors.length===0)return new Ti(a,h,v,w)}}if(f.length===1)r.errors.push(..._.errors);else{const x=(f.length?f:d).map((([w])=>{return I=w,Array.isArray(I)?`(${I.map(k).join(", ")})`:`(${k(I.type)}...)`;var I})).join(" | "),v=[];for(let w=1;w<e.length;w++){const I=r.parse(e[w],1+v.length);if(!I)return null;v.push(k(I.type))}r.error(`Expected arguments of type ${x}, but found (${v.join(", ")}) instead.`)}return null}static register(e,r){Ti.definitions=r;for(const a in r)e[a]=Ti}}function Nn(i,[e,r,a,l]){e=e.evaluate(i),r=r.evaluate(i),a=a.evaluate(i);const h=l?l.evaluate(i):1,d=ps(e,r,a,h);if(d)throw new Se(d);return new se(e/255,r/255,a/255,h,!1)}function Zn(i,e){return i in e}function qn(i,e){const r=e[i];return r===void 0?null:r}function Yr(i){return{type:i}}function na(i){if(i instanceof ee)return na(i.boundExpression);if(i instanceof Ti&&i.name==="error"||i instanceof ia||i instanceof Hr||i instanceof Jr)return!1;const e=i instanceof Oi||i instanceof Li;let r=!0;return i.eachChild((a=>{r=e?r&&na(a):r&&a instanceof Fi})),!!r&&oa(i)&&la(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function oa(i){if(i instanceof Ti&&(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 Hr||i instanceof Jr)return!1;let e=!0;return i.eachChild((r=>{e&&!oa(r)&&(e=!1)})),e}function xs(i){if(i instanceof Ti&&i.name==="feature-state")return!1;let e=!0;return i.eachChild((r=>{e&&!xs(r)&&(e=!1)})),e}function la(i,e){if(i instanceof Ti&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild((a=>{r&&!la(a,e)&&(r=!1)})),r}function Ua(i){return{result:"success",value:i}}function vs(i){return{result:"error",value:i}}function bs(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function Yo(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function Gn(i){return!!i.expression&&i.expression.interpolated}function Yt(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function $a(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function ec(i){return i}function Qo(i,e){const r=e.type==="color",a=i.stops&&typeof i.stops[0][0]=="object",l=a||!(a||i.property!==void 0),h=i.type||(Gn(e)?"exponential":"interval");if(r||e.type==="padding"){const v=r?se.parse:pi.parse;(i=tr({},i)).stops&&(i.stops=i.stops.map((w=>[w[0],v(w[1])]))),i.default=v(i.default?i.default:e.default)}if(i.colorSpace&&(d=i.colorSpace)!=="rgb"&&d!=="hcl"&&d!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var d;let f,_,x;if(h==="exponential")f=el;else if(h==="interval")f=Na;else if(h==="categorical"){f=tl,_=Object.create(null);for(const v of i.stops)_[v[0]]=v[1];x=typeof i.stops[0][0]}else{if(h!=="identity")throw new Error(`Unknown function type "${h}"`);f=il}if(a){const v={},w=[];for(let C=0;C<i.stops.length;C++){const P=i.stops[C],L=P[0].zoom;v[L]===void 0&&(v[L]={zoom:L,type:i.type,property:i.property,default:i.default,stops:[]},w.push(L)),v[L].stops.push([P[0].value,P[1]])}const I=[];for(const C of w)I.push([v[C].zoom,Qo(v[C],e)]);const E={name:"linear"};return{kind:"composite",interpolationType:E,interpolationFactor:ri.interpolationFactor.bind(void 0,E),zoomStops:I.map((C=>C[0])),evaluate:({zoom:C},P)=>el({stops:I,base:i.base},e,C).evaluate(C,P)}}if(l){const v=h==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:ri.interpolationFactor.bind(void 0,v),zoomStops:i.stops.map((w=>w[0])),evaluate:({zoom:w})=>f(i,e,w,_,x)}}return{kind:"source",evaluate(v,w){const I=w&&w.properties?w.properties[i.property]:void 0;return I===void 0?ws(i.default,e.default):f(i,e,I,_,x)}}}function ws(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function tl(i,e,r,a,l){return ws(typeof r===l?a[r]:void 0,i.default,e.default)}function Na(i,e,r){if(Yt(r)!=="number")return ws(i.default,e.default);const a=i.stops.length;if(a===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[a-1][0])return i.stops[a-1][1];const l=Pa(i.stops.map((h=>h[0])),r);return i.stops[l][1]}function el(i,e,r){const a=i.base!==void 0?i.base:1;if(Yt(r)!=="number")return ws(i.default,e.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 h=Pa(i.stops.map((v=>v[0])),r),d=(function(v,w,I,E){const C=E-I,P=v-I;return C===0?0:w===1?P/C:(Math.pow(w,P)-1)/(Math.pow(w,C)-1)})(r,a,i.stops[h][0],i.stops[h+1][0]),f=i.stops[h][1],_=i.stops[h+1][1],x=ii[e.type]||ec;return typeof f.evaluate=="function"?{evaluate(...v){const w=f.evaluate.apply(void 0,v),I=_.evaluate.apply(void 0,v);if(w!==void 0&&I!==void 0)return x(w,I,d,i.colorSpace)}}:x(f,_,d,i.colorSpace)}function il(i,e,r){switch(e.type){case"color":r=se.parse(r);break;case"formatted":r=di.fromString(r.toString());break;case"resolvedImage":r=fi.fromString(r.toString());break;case"padding":r=pi.parse(r);break;default:Yt(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return ws(r,i.default,e.default)}Ti.register(ys,{error:[{kind:"error"},[Nt],(i,[e])=>{throw new Se(e.evaluate(i))}],typeof:[Nt,[jt],(i,[e])=>k(Me(e.evaluate(i)))],"to-rgba":[M(_t,4),[ei],(i,[e])=>{const[r,a,l,h]=e.evaluate(i).rgb;return[255*r,255*a,255*l,h]}],rgb:[ei,[_t,_t,_t],Nn],rgba:[ei,[_t,_t,_t,_t],Nn],has:{type:Ft,overloads:[[[Nt],(i,[e])=>Zn(e.evaluate(i),i.properties())],[[Nt,Bi],(i,[e,r])=>Zn(e.evaluate(i),r.evaluate(i))]]},get:{type:jt,overloads:[[[Nt],(i,[e])=>qn(e.evaluate(i),i.properties())],[[Nt,Bi],(i,[e,r])=>qn(e.evaluate(i),r.evaluate(i))]]},"feature-state":[jt,[Nt],(i,[e])=>qn(e.evaluate(i),i.featureState||{})],properties:[Bi,[],i=>i.properties()],"geometry-type":[Nt,[],i=>i.geometryType()],id:[jt,[],i=>i.id()],zoom:[_t,[],i=>i.globals.zoom],"heatmap-density":[_t,[],i=>i.globals.heatmapDensity||0],"line-progress":[_t,[],i=>i.globals.lineProgress||0],accumulated:[jt,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[_t,Yr(_t),(i,e)=>{let r=0;for(const a of e)r+=a.evaluate(i);return r}],"*":[_t,Yr(_t),(i,e)=>{let r=1;for(const a of e)r*=a.evaluate(i);return r}],"-":{type:_t,overloads:[[[_t,_t],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[_t],(i,[e])=>-e.evaluate(i)]]},"/":[_t,[_t,_t],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[_t,[_t,_t],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[_t,[],()=>Math.LN2],pi:[_t,[],()=>Math.PI],e:[_t,[],()=>Math.E],"^":[_t,[_t,_t],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[_t,[_t],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[_t,[_t],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[_t,[_t],(i,[e])=>Math.log(e.evaluate(i))],log2:[_t,[_t],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[_t,[_t],(i,[e])=>Math.sin(e.evaluate(i))],cos:[_t,[_t],(i,[e])=>Math.cos(e.evaluate(i))],tan:[_t,[_t],(i,[e])=>Math.tan(e.evaluate(i))],asin:[_t,[_t],(i,[e])=>Math.asin(e.evaluate(i))],acos:[_t,[_t],(i,[e])=>Math.acos(e.evaluate(i))],atan:[_t,[_t],(i,[e])=>Math.atan(e.evaluate(i))],min:[_t,Yr(_t),(i,e)=>Math.min(...e.map((r=>r.evaluate(i))))],max:[_t,Yr(_t),(i,e)=>Math.max(...e.map((r=>r.evaluate(i))))],abs:[_t,[_t],(i,[e])=>Math.abs(e.evaluate(i))],round:[_t,[_t],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[_t,[_t],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[_t,[_t],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[Ft,[Nt,jt],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[Ft,[jt],(i,[e])=>i.id()===e.value],"filter-type-==":[Ft,[Nt],(i,[e])=>i.geometryType()===e.value],"filter-<":[Ft,[Nt,jt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a<l}],"filter-id-<":[Ft,[jt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<a}],"filter->":[Ft,[Nt,jt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a>l}],"filter-id->":[Ft,[jt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>a}],"filter-<=":[Ft,[Nt,jt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a<=l}],"filter-id-<=":[Ft,[jt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<=a}],"filter->=":[Ft,[Nt,jt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a>=l}],"filter-id->=":[Ft,[jt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>=a}],"filter-has":[Ft,[jt],(i,[e])=>e.value in i.properties()],"filter-has-id":[Ft,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[Ft,[M(Nt)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[Ft,[M(jt)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[Ft,[Nt,M(jt)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[Ft,[Nt,M(jt)],(i,[e,r])=>(function(a,l,h,d){for(;h<=d;){const f=h+d>>1;if(l[f]===a)return!0;l[f]>a?d=f-1:h=f+1}return!1})(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Ft,overloads:[[[Ft,Ft],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[Yr(Ft),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:Ft,overloads:[[[Ft,Ft],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[Yr(Ft),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[Ft,[Ft],(i,[e])=>!e.evaluate(i)],"is-supported-script":[Ft,[Nt],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[Nt,[Nt],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[Nt,[Nt],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[Nt,Yr(jt),(i,e)=>e.map((r=>Qs(r.evaluate(i)))).join("")],"resolved-locale":[Nt,[ir],(i,[e])=>e.evaluate(i).resolvedLocale()]});class Za{constructor(e,r){var a;this.expression=e,this._warningHistory={},this._evaluator=new za,this._defaultValue=r?(a=r).type==="color"&&$a(a.default)?new se(0,0,0,0):a.type==="color"?se.parse(a.default)||null:a.type==="padding"?pi.parse(a.default)||null:a.type==="variableAnchorOffsetCollection"?wi.parse(a.default)||null:a.default===void 0?null:a.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,a,l,h,d){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=a,this._evaluator.canonical=l,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=d,this.expression.evaluate(this._evaluator)}evaluate(e,r,a,l,h,d){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=a||null,this._evaluator.canonical=l,this._evaluator.availableImages=h||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 Se(`Expected value to be one of ${Object.keys(this._enumValues).map((_=>JSON.stringify(_))).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 qa(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in ys}function Ts(i,e){const r=new qr(ys,na,[],e?(function(l){const h={color:ei,string:Nt,number:_t,enum:Nt,boolean:Ft,formatted:mr,padding:Er,resolvedImage:rr,variableAnchorOffsetCollection:j};return l.type==="array"?M(h[l.value]||jt,l.length):h[l.type]})(e):void 0),a=r.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return a?Ua(new Za(a,e)):vs(r.errors)}class Ss{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!xs(r.expression)}evaluateWithoutErrorHandling(e,r,a,l,h,d){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,l,h,d)}evaluate(e,r,a,l,h,d){return this._styleExpression.evaluate(e,r,a,l,h,d)}}class Is{constructor(e,r,a,l){this.kind=e,this.zoomStops=a,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!xs(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(e,r,a,l,h,d){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,l,h,d)}evaluate(e,r,a,l,h,d){return this._styleExpression.evaluate(e,r,a,l,h,d)}interpolationFactor(e,r,a){return this.interpolationType?ri.interpolationFactor(this.interpolationType,e,r,a):0}}function Xn(i,e){const r=Ts(i,e);if(r.result==="error")return r;const a=r.value.expression,l=oa(a);if(!l&&!bs(e))return vs([new He("","data expressions not supported")]);const h=la(a,["zoom"]);if(!h&&!Yo(e))return vs([new He("","zoom expressions not supported")]);const d=ca(a);return d||h?d instanceof He?vs([d]):d instanceof ri&&!Gn(e)?vs([new He("",'"interpolate" expressions cannot be used with this property')]):Ua(d?new Is(l?"camera":"composite",r.value,d.labels,d instanceof ri?d.interpolation:void 0):new Ss(l?"constant":"source",r.value)):vs([new He("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class ks{constructor(e,r){this._parameters=e,this._specification=r,tr(this,Qo(this._parameters,this._specification))}static deserialize(e){return new ks(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ca(i){let e=null;if(i instanceof zr)e=ca(i.result);else if(i instanceof Da){for(const r of i.args)if(e=ca(r),e)break}else(i instanceof ms||i instanceof ri)&&i.input instanceof Ti&&i.input.name==="zoom"&&(e=i);return e instanceof He||i.eachChild((r=>{const a=ca(r);a instanceof He?e=a:!e&&a?e=new He("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&a&&e!==a&&(e=new He("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Ga(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 e of i.slice(1))if(!Ga(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const Xa={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Hn(i){if(i==null)return{filter:()=>!0,needGeometry:!1};Ga(i)||(i=Ha(i));const e=Ts(i,Xa);if(e.result==="error")throw new Error(e.value.map((r=>`${r.key}: ${r.message}`)).join(", "));return{filter:(r,a,l)=>e.value.evaluate(r,a,{},l),needGeometry:rl(i)}}function ic(i,e){return i<e?-1:i>e?1:0}function rl(i){if(!Array.isArray(i))return!1;if(i[0]==="within"||i[0]==="distance")return!0;for(let e=1;e<i.length;e++)if(rl(i[e]))return!0;return!1}function Ha(i){if(!i)return!0;const e=i[0];return i.length<=1?e!=="any":e==="=="?Wn(i[1],i[2],"=="):e==="!="?Oe(Wn(i[1],i[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Wn(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(Ha))):e==="all"?["all"].concat(i.slice(1).map(Ha)):e==="none"?["all"].concat(i.slice(1).map(Ha).map(Oe)):e==="in"?ua(i[1],i.slice(2)):e==="!in"?Oe(ua(i[1],i.slice(2))):e==="has"?ha(i[1]):e!=="!has"||Oe(ha(i[1]));var r}function Wn(i,e,r){switch(i){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,i,e]}}function ua(i,e){if(e.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((r=>typeof r!=typeof e[0]))?["filter-in-large",i,["literal",e.sort(ic)]]:["filter-in-small",i,["literal",e]]}}function ha(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function Oe(i){return["!",i]}function Qr(i){const e=typeof i;if(e==="number"||e==="boolean"||e==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let l="[";for(const h of i)l+=`${Qr(h)},`;return`${l}]`}const r=Object.keys(i).sort();let a="{";for(let l=0;l<r.length;l++)a+=`${JSON.stringify(r[l])}:${Qr(i[r[l]])},`;return`${a}}`}function sl(i){let e="";for(const r of Nr)e+=`/${Qr(i[r])}`;return e}function al(i){const e=i.value;return e?[new ht(i.key,e,"constants have been deprecated as of v8")]:[]}function we(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function Vi(i){if(Array.isArray(i))return i.map(Vi);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const e={};for(const r in i)e[r]=Vi(i[r]);return e}return we(i)}function mi(i){const e=i.key,r=i.value,a=i.valueSpec||{},l=i.objectElementValidators||{},h=i.style,d=i.styleSpec,f=i.validateSpec;let _=[];const x=Yt(r);if(x!=="object")return[new ht(e,r,`object expected, ${x} found`)];for(const v in r){const w=v.split(".")[0],I=a[w]||a["*"];let E;if(l[w])E=l[w];else if(a[w])E=f;else if(l["*"])E=l["*"];else{if(!a["*"]){_.push(new ht(e,r[v],`unknown property "${v}"`));continue}E=f}_=_.concat(E({key:(e&&`${e}.`)+v,value:r[v],valueSpec:I,style:h,styleSpec:d,object:r,objectKey:v,validateSpec:f},r))}for(const v in a)l[v]||a[v].required&&a[v].default===void 0&&r[v]===void 0&&_.push(new ht(e,r,`missing required property "${v}"`));return _}function da(i){const e=i.value,r=i.valueSpec,a=i.style,l=i.styleSpec,h=i.key,d=i.arrayElementValidator||i.validateSpec;if(Yt(e)!=="array")return[new ht(h,e,`array expected, ${Yt(e)} found`)];if(r.length&&e.length!==r.length)return[new ht(h,e,`array length ${r.length} expected, length ${e.length} found`)];if(r["min-length"]&&e.length<r["min-length"])return[new ht(h,e,`array length at least ${r["min-length"]} expected, length ${e.length} found`)];let f={type:r.value,values:r.values};l.$version<7&&(f.function=r.function),Yt(r.value)==="object"&&(f=r.value);let _=[];for(let x=0;x<e.length;x++)_=_.concat(d({array:e,arrayIndex:x,value:e[x],valueSpec:f,validateSpec:i.validateSpec,style:a,styleSpec:l,key:`${h}[${x}]`}));return _}function Kn(i){const e=i.key,r=i.value,a=i.valueSpec;let l=Yt(r);return l==="number"&&r!=r&&(l="NaN"),l!=="number"?[new ht(e,r,`number expected, ${l} found`)]:"minimum"in a&&r<a.minimum?[new ht(e,r,`${r} is less than the minimum value ${a.minimum}`)]:"maximum"in a&&r>a.maximum?[new ht(e,r,`${r} is greater than the maximum value ${a.maximum}`)]:[]}function Wa(i){const e=i.valueSpec,r=we(i.value.type);let a,l,h,d={};const f=r!=="categorical"&&i.value.property===void 0,_=!f,x=Yt(i.value.stops)==="array"&&Yt(i.value.stops[0])==="array"&&Yt(i.value.stops[0][0])==="object",v=mi({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(E){if(r==="identity")return[new ht(E.key,E.value,'identity function may not have a "stops" property')];let C=[];const P=E.value;return C=C.concat(da({key:E.key,value:P,valueSpec:E.valueSpec,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec,arrayElementValidator:w})),Yt(P)==="array"&&P.length===0&&C.push(new ht(E.key,P,"array must have at least one stop")),C},default:function(E){return E.validateSpec({key:E.key,value:E.value,valueSpec:e,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec})}}});return r==="identity"&&f&&v.push(new ht(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||v.push(new ht(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!Gn(i.valueSpec)&&v.push(new ht(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(_&&!bs(i.valueSpec)?v.push(new ht(i.key,i.value,"property functions not supported")):f&&!Yo(i.valueSpec)&&v.push(new ht(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!x||i.value.property!==void 0||v.push(new ht(i.key,i.value,'"property" property is required')),v;function w(E){let C=[];const P=E.value,L=E.key;if(Yt(P)!=="array")return[new ht(L,P,`array expected, ${Yt(P)} found`)];if(P.length!==2)return[new ht(L,P,`array length 2 expected, length ${P.length} found`)];if(x){if(Yt(P[0])!=="object")return[new ht(L,P,`object expected, ${Yt(P[0])} found`)];if(P[0].zoom===void 0)return[new ht(L,P,"object stop key must have zoom")];if(P[0].value===void 0)return[new ht(L,P,"object stop key must have value")];if(h&&h>we(P[0].zoom))return[new ht(L,P[0].zoom,"stop zoom values must appear in ascending order")];we(P[0].zoom)!==h&&(h=we(P[0].zoom),l=void 0,d={}),C=C.concat(mi({key:`${L}[0]`,value:P[0],valueSpec:{zoom:{}},validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec,objectElementValidators:{zoom:Kn,value:I}}))}else C=C.concat(I({key:`${L}[0]`,value:P[0],valueSpec:{},validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec},P));return qa(Vi(P[1]))?C.concat([new ht(`${L}[1]`,P[1],"expressions are not allowed in function stops.")]):C.concat(E.validateSpec({key:`${L}[1]`,value:P[1],valueSpec:e,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec}))}function I(E,C){const P=Yt(E.value),L=we(E.value),U=E.value!==null?E.value:C;if(a){if(P!==a)return[new ht(E.key,U,`${P} stop domain type must match previous stop domain type ${a}`)]}else a=P;if(P!=="number"&&P!=="string"&&P!=="boolean")return[new ht(E.key,U,"stop domain value must be a number, string, or boolean")];if(P!=="number"&&r!=="categorical"){let Q=`number expected, ${P} found`;return bs(e)&&r===void 0&&(Q+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ht(E.key,U,Q)]}return r!=="categorical"||P!=="number"||isFinite(L)&&Math.floor(L)===L?r!=="categorical"&&P==="number"&&l!==void 0&&L<l?[new ht(E.key,U,"stop domain values must appear in ascending order")]:(l=L,r==="categorical"&&L in d?[new ht(E.key,U,"stop domain values must be unique")]:(d[L]=!0,[])):[new ht(E.key,U,`integer expected, found ${L}`)]}}function Ms(i){const e=(i.expressionContext==="property"?Xn:Ts)(Vi(i.value),i.valueSpec);if(e.result==="error")return e.value.map((a=>new ht(`${i.key}${a.key}`,i.value,a.message)));const r=e.value.expression||e.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new ht(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"&&!xs(r))return[new ht(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!xs(r))return[new ht(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!la(r,["zoom","feature-state"]))return[new ht(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!oa(r))return[new ht(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function gr(i){const e=i.key,r=i.value,a=i.valueSpec,l=[];return Array.isArray(a.values)?a.values.indexOf(we(r))===-1&&l.push(new ht(e,r,`expected one of [${a.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(a.values).indexOf(we(r))===-1&&l.push(new ht(e,r,`expected one of [${Object.keys(a.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function Jn(i){return Ga(Vi(i.value))?Ms(tr({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Ka(i)}function Ka(i){const e=i.value,r=i.key;if(Yt(e)!=="array")return[new ht(r,e,`array expected, ${Yt(e)} found`)];const a=i.styleSpec;let l,h=[];if(e.length<1)return[new ht(r,e,"filter array must have at least 1 element")];switch(h=h.concat(gr({key:`${r}[0]`,value:e[0],valueSpec:a.filter_operator,style:i.style,styleSpec:i.styleSpec})),we(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&we(e[1])==="$type"&&h.push(new ht(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&h.push(new ht(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(l=Yt(e[1]),l!=="string"&&h.push(new ht(`${r}[1]`,e[1],`string expected, ${l} found`)));for(let d=2;d<e.length;d++)l=Yt(e[d]),we(e[1])==="$type"?h=h.concat(gr({key:`${r}[${d}]`,value:e[d],valueSpec:a.geometry_type,style:i.style,styleSpec:i.styleSpec})):l!=="string"&&l!=="number"&&l!=="boolean"&&h.push(new ht(`${r}[${d}]`,e[d],`string, number, or boolean expected, ${l} found`));break;case"any":case"all":case"none":for(let d=1;d<e.length;d++)h=h.concat(Ka({key:`${r}[${d}]`,value:e[d],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":l=Yt(e[1]),e.length!==2?h.push(new ht(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):l!=="string"&&h.push(new ht(`${r}[1]`,e[1],`string expected, ${l} found`))}return h}function Yn(i,e){const r=i.key,a=i.validateSpec,l=i.style,h=i.styleSpec,d=i.value,f=i.objectKey,_=h[`${e}_${i.layerType}`];if(!_)return[];const x=f.match(/^(.*)-transition$/);if(e==="paint"&&x&&_[x[1]]&&_[x[1]].transition)return a({key:r,value:d,valueSpec:h.transition,style:l,styleSpec:h});const v=i.valueSpec||_[f];if(!v)return[new ht(r,d,`unknown property "${f}"`)];let w;if(Yt(d)==="string"&&bs(v)&&!v.tokens&&(w=/^{([^}]+)}$/.exec(d)))return[new ht(r,d,`"${f}" does not support interpolation syntax
5
+ Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(w[1])} }\`.`)];const I=[];return i.layerType==="symbol"&&(f==="text-field"&&l&&!l.glyphs&&I.push(new ht(r,d,'use of "text-field" requires a style "glyphs" property')),f==="text-font"&&$a(Vi(d))&&we(d.type)==="identity"&&I.push(new ht(r,d,'"text-font" does not support identity functions'))),I.concat(a({key:i.key,value:d,valueSpec:v,style:l,styleSpec:h,expressionContext:"property",propertyType:e,propertyKey:f}))}function Ja(i){return Yn(i,"paint")}function Qn(i){return Yn(i,"layout")}function to(i){let e=[];const r=i.value,a=i.key,l=i.style,h=i.styleSpec;r.type||r.ref||e.push(new ht(a,r,'either "type" or "ref" is required'));let d=we(r.type);const f=we(r.ref);if(r.id){const _=we(r.id);for(let x=0;x<i.arrayIndex;x++){const v=l.layers[x];we(v.id)===_&&e.push(new ht(a,r.id,`duplicate layer id "${r.id}", previously used at line ${v.id.__line__}`))}}if("ref"in r){let _;["type","source","source-layer","filter","layout"].forEach((x=>{x in r&&e.push(new ht(a,r[x],`"${x}" is prohibited for ref layers`))})),l.layers.forEach((x=>{we(x.id)===f&&(_=x)})),_?_.ref?e.push(new ht(a,r.ref,"ref cannot reference another ref layer")):d=we(_.type):e.push(new ht(a,r.ref,`ref layer "${f}" not found`))}else if(d!=="background")if(r.source){const _=l.sources&&l.sources[r.source],x=_&&we(_.type);_?x==="vector"&&d==="raster"?e.push(new ht(a,r.source,`layer "${r.id}" requires a raster source`)):x!=="raster-dem"&&d==="hillshade"?e.push(new ht(a,r.source,`layer "${r.id}" requires a raster-dem source`)):x==="raster"&&d!=="raster"?e.push(new ht(a,r.source,`layer "${r.id}" requires a vector source`)):x!=="vector"||r["source-layer"]?x==="raster-dem"&&d!=="hillshade"?e.push(new ht(a,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):d!=="line"||!r.paint||!r.paint["line-gradient"]||x==="geojson"&&_.lineMetrics||e.push(new ht(a,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new ht(a,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new ht(a,r.source,`source "${r.source}" not found`))}else e.push(new ht(a,r,'missing required property "source"'));return e=e.concat(mi({key:a,value:r,valueSpec:h.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${a}.type`,value:r.type,valueSpec:h.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:Jn,layout:_=>mi({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":x=>Qn(tr({layerType:d},x))}}),paint:_=>mi({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":x=>Ja(tr({layerType:d},x))}})}})),e}function ts(i){const e=i.value,r=i.key,a=Yt(e);return a!=="string"?[new ht(r,e,`string expected, ${a} found`)]:[]}const Ya={promoteId:function({key:i,value:e}){if(Yt(e)==="string")return ts({key:i,value:e});{const r=[];for(const a in e)r.push(...ts({key:`${i}.${a}`,value:e[a]}));return r}}};function pa(i){const e=i.value,r=i.key,a=i.styleSpec,l=i.style,h=i.validateSpec;if(!e.type)return[new ht(r,e,'"type" is required')];const d=we(e.type);let f;switch(d){case"vector":case"raster":return f=mi({key:r,value:e,valueSpec:a[`source_${d.replace("-","_")}`],style:i.style,styleSpec:a,objectElementValidators:Ya,validateSpec:h}),f;case"raster-dem":return f=(function(_){var x;const v=(x=_.sourceName)!==null&&x!==void 0?x:"",w=_.value,I=_.styleSpec,E=I.source_raster_dem,C=_.style;let P=[];const L=Yt(w);if(w===void 0)return P;if(L!=="object")return P.push(new ht("source_raster_dem",w,`object expected, ${L} found`)),P;const U=we(w.encoding)==="custom",Q=["redFactor","greenFactor","blueFactor","baseShift"],X=_.value.encoding?`"${_.value.encoding}"`:"Default";for(const J in w)!U&&Q.includes(J)?P.push(new ht(J,w[J],`In "${v}": "${J}" is only valid when "encoding" is set to "custom". ${X} encoding found`)):E[J]?P=P.concat(_.validateSpec({key:J,value:w[J],valueSpec:E[J],validateSpec:_.validateSpec,style:C,styleSpec:I})):P.push(new ht(J,w[J],`unknown property "${J}"`));return P})({sourceName:r,value:e,style:i.style,styleSpec:a,validateSpec:h}),f;case"geojson":if(f=mi({key:r,value:e,valueSpec:a.source_geojson,style:l,styleSpec:a,validateSpec:h,objectElementValidators:Ya}),e.cluster)for(const _ in e.clusterProperties){const[x,v]=e.clusterProperties[_],w=typeof x=="string"?[x,["accumulated"],["get",_]]:x;f.push(...Ms({key:`${r}.${_}.map`,value:v,validateSpec:h,expressionContext:"cluster-map"})),f.push(...Ms({key:`${r}.${_}.reduce`,value:w,validateSpec:h,expressionContext:"cluster-reduce"}))}return f;case"video":return mi({key:r,value:e,valueSpec:a.source_video,style:l,validateSpec:h,styleSpec:a});case"image":return mi({key:r,value:e,valueSpec:a.source_image,style:l,validateSpec:h,styleSpec:a});case"canvas":return[new ht(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return gr({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:l,validateSpec:h,styleSpec:a})}}function eo(i){const e=i.value,r=i.styleSpec,a=r.light,l=i.style;let h=[];const d=Yt(e);if(e===void 0)return h;if(d!=="object")return h=h.concat([new ht("light",e,`object expected, ${d} found`)]),h;for(const f in e){const _=f.match(/^(.*)-transition$/);h=h.concat(_&&a[_[1]]&&a[_[1]].transition?i.validateSpec({key:f,value:e[f],valueSpec:r.transition,validateSpec:i.validateSpec,style:l,styleSpec:r}):a[f]?i.validateSpec({key:f,value:e[f],valueSpec:a[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new ht(f,e[f],`unknown property "${f}"`)])}return h}function io(i){const e=i.value,r=i.styleSpec,a=r.sky,l=i.style,h=Yt(e);if(e===void 0)return[];if(h!=="object")return[new ht("sky",e,`object expected, ${h} found`)];let d=[];for(const f in e)d=d.concat(a[f]?i.validateSpec({key:f,value:e[f],valueSpec:a[f],style:l,styleSpec:r}):[new ht(f,e[f],`unknown property "${f}"`)]);return d}function ro(i){const e=i.value,r=i.styleSpec,a=r.terrain,l=i.style;let h=[];const d=Yt(e);if(e===void 0)return h;if(d!=="object")return h=h.concat([new ht("terrain",e,`object expected, ${d} found`)]),h;for(const f in e)h=h.concat(a[f]?i.validateSpec({key:f,value:e[f],valueSpec:a[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new ht(f,e[f],`unknown property "${f}"`)]);return h}function so(i){let e=[];const r=i.value,a=i.key;if(Array.isArray(r)){const l=[],h=[];for(const d in r)r[d].id&&l.includes(r[d].id)&&e.push(new ht(a,r,`all the sprites' ids must be unique, but ${r[d].id} is duplicated`)),l.push(r[d].id),r[d].url&&h.includes(r[d].url)&&e.push(new ht(a,r,`all the sprites' URLs must be unique, but ${r[d].url} is duplicated`)),h.push(r[d].url),e=e.concat(mi({key:`${a}[${d}]`,value:r[d],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return e}return ts({key:a,value:r})}const Qa={"*":()=>[],array:da,boolean:function(i){const e=i.value,r=i.key,a=Yt(e);return a!=="boolean"?[new ht(r,e,`boolean expected, ${a} found`)]:[]},number:Kn,color:function(i){const e=i.key,r=i.value,a=Yt(r);return a!=="string"?[new ht(e,r,`color expected, ${a} found`)]:se.parse(String(r))?[]:[new ht(e,r,`color expected, "${r}" found`)]},constants:al,enum:gr,filter:Jn,function:Wa,layer:to,object:mi,source:pa,light:eo,sky:io,terrain:ro,projection:function(i){const e=i.value,r=i.styleSpec,a=r.projection,l=i.style,h=Yt(e);if(e===void 0)return[];if(h!=="object")return[new ht("projection",e,`object expected, ${h} found`)];let d=[];for(const f in e)d=d.concat(a[f]?i.validateSpec({key:f,value:e[f],valueSpec:a[f],style:l,styleSpec:r}):[new ht(f,e[f],`unknown property "${f}"`)]);return d},string:ts,formatted:function(i){return ts(i).length===0?[]:Ms(i)},resolvedImage:function(i){return ts(i).length===0?[]:Ms(i)},padding:function(i){const e=i.key,r=i.value;if(Yt(r)==="array"){if(r.length<1||r.length>4)return[new ht(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const a={type:"number"};let l=[];for(let h=0;h<r.length;h++)l=l.concat(i.validateSpec({key:`${e}[${h}]`,value:r[h],validateSpec:i.validateSpec,valueSpec:a}));return l}return Kn({key:e,value:r,valueSpec:{}})},variableAnchorOffsetCollection:function(i){const e=i.key,r=i.value,a=Yt(r),l=i.styleSpec;if(a!=="array"||r.length<1||r.length%2!=0)return[new ht(e,r,"variableAnchorOffsetCollection requires a non-empty array of even length")];let h=[];for(let d=0;d<r.length;d+=2)h=h.concat(gr({key:`${e}[${d}]`,value:r[d],valueSpec:l.layout_symbol["text-anchor"]})),h=h.concat(da({key:`${e}[${d+1}]`,value:r[d+1],valueSpec:{length:2,value:"number"},validateSpec:i.validateSpec,style:i.style,styleSpec:l}));return h},sprite:so};function Es(i){const e=i.value,r=i.valueSpec,a=i.styleSpec;return i.validateSpec=Es,r.expression&&$a(we(e))?Wa(i):r.expression&&qa(Vi(e))?Ms(i):r.type&&Qa[r.type]?Qa[r.type](i):mi(tr({},i,{valueSpec:r.type?a[r.type]:r}))}function nl(i){const e=i.value,r=i.key,a=ts(i);return a.length||(e.indexOf("{fontstack}")===-1&&a.push(new ht(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&a.push(new ht(r,e,'"glyphs" url must include a "{range}" token'))),a}function Si(i,e=it){let r=[];return r=r.concat(Es({key:"",value:i,valueSpec:e.$root,styleSpec:e,style:i,validateSpec:Es,objectElementValidators:{glyphs:nl,"*":()=>[]}})),i.constants&&(r=r.concat(al({key:"constants",value:i.constants,style:i,styleSpec:e,validateSpec:Es}))),ao(r)}function ar(i){return function(e){return i({...e,validateSpec:Es})}}function ao(i){return[].concat(i).sort(((e,r)=>e.line-r.line))}function ji(i){return function(...e){return ao(i.apply(this,e))}}Si.source=ji(ar(pa)),Si.sprite=ji(ar(so)),Si.glyphs=ji(ar(nl)),Si.light=ji(ar(eo)),Si.sky=ji(ar(io)),Si.terrain=ji(ar(ro)),Si.layer=ji(ar(to)),Si.filter=ji(ar(Jn)),Si.paintProperty=ji(ar(Ja)),Si.layoutProperty=ji(ar(Qn));const es=Si,rc=es.light,sc=es.sky,ol=es.paintProperty,ll=es.layoutProperty;function no(i,e){let r=!1;if(e&&e.length)for(const a of e)i.fire(new Ir(new Error(a.message))),r=!0;return r}class zs{constructor(e,r,a){const l=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const d=new Int32Array(this.arrayBuffer);e=d[0],this.d=(r=d[1])+2*(a=d[2]);for(let _=0;_<this.d*this.d;_++){const x=d[3+_],v=d[3+_+1];l.push(x===v?null:d.subarray(x,v))}const f=d[3+l.length+1];this.keys=d.subarray(d[3+l.length],f),this.bboxes=d.subarray(f),this.insert=this._insertReadonly}else{this.d=r+2*a;for(let d=0;d<this.d*this.d;d++)l.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=e,this.padding=a,this.scale=r/e,this.uid=0;const h=a/r*e;this.min=-h,this.max=e+h}insert(e,r,a,l,h){this._forEachCell(r,a,l,h,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(r),this.bboxes.push(a),this.bboxes.push(l),this.bboxes.push(h)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,r,a,l,h,d){this.cells[h].push(d)}query(e,r,a,l,h){const d=this.min,f=this.max;if(e<=d&&r<=d&&f<=a&&f<=l&&!h)return Array.prototype.slice.call(this.keys);{const _=[];return this._forEachCell(e,r,a,l,this._queryCell,_,{},h),_}}_queryCell(e,r,a,l,h,d,f,_){const x=this.cells[h];if(x!==null){const v=this.keys,w=this.bboxes;for(let I=0;I<x.length;I++){const E=x[I];if(f[E]===void 0){const C=4*E;(_?_(w[C+0],w[C+1],w[C+2],w[C+3]):e<=w[C+2]&&r<=w[C+3]&&a>=w[C+0]&&l>=w[C+1])?(f[E]=!0,d.push(v[E])):f[E]=!1}}}}_forEachCell(e,r,a,l,h,d,f,_){const x=this._convertToCellCoord(e),v=this._convertToCellCoord(r),w=this._convertToCellCoord(a),I=this._convertToCellCoord(l);for(let E=x;E<=w;E++)for(let C=v;C<=I;C++){const P=this.d*C+E;if((!_||_(this._convertFromCellCoord(E),this._convertFromCellCoord(C),this._convertFromCellCoord(E+1),this._convertFromCellCoord(C+1)))&&h.call(this,e,r,a,l,P,d,f,_))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,r=3+this.cells.length+1+1;let a=0;for(let d=0;d<this.cells.length;d++)a+=this.cells[d].length;const l=new Int32Array(r+a+this.keys.length+this.bboxes.length);l[0]=this.extent,l[1]=this.n,l[2]=this.padding;let h=r;for(let d=0;d<e.length;d++){const f=e[d];l[3+d]=h,l.set(f,h),h+=f.length}return l[3+e.length]=h,l.set(this.keys,h),h+=this.keys.length,l[3+e.length+1]=h,l.set(this.bboxes,h),h+=this.bboxes.length,l.buffer}static serialize(e,r){const a=e.toArrayBuffer();return r&&r.push(a),{buffer:a}}static deserialize(e){return new zs(e.buffer)}}const Ii={};function It(i,e,r={}){if(Ii[i])throw new Error(`${i} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:i,writeable:!1}),Ii[i]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}It("Object",Object),It("TransferableGridIndex",zs),It("Color",se),It("Error",Error),It("AJAXError",hi),It("ResolvedImage",fi),It("StylePropertyFunction",ks),It("StyleExpression",Za,{omit:["_evaluator"]}),It("ZoomDependentExpression",Is),It("ZoomConstantExpression",Ss),It("CompoundExpression",Ti,{omit:["_evaluate"]});for(const i in ys)ys[i]._classRegistryKey||It(`Expression_${i}`,ys[i]);function tn(i){return i&&typeof ArrayBuffer<"u"&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}function oo(i){return i.$name||i.constructor._classRegistryKey}function cl(i){return!(function(e){if(e===null||typeof e!="object")return!1;const r=oo(e);return!(!r||r==="Object")})(i)&&(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob||i instanceof Error||tn(i)||Yi(i)||ArrayBuffer.isView(i)||i instanceof ImageData)}function Cs(i,e){if(cl(i))return(tn(i)||Yi(i))&&e&&e.push(i),ArrayBuffer.isView(i)&&e&&e.push(i.buffer),i instanceof ImageData&&e&&e.push(i.data.buffer),i;if(Array.isArray(i)){const h=[];for(const d of i)h.push(Cs(d,e));return h}if(typeof i!="object")throw new Error("can't serialize object of type "+typeof i);const r=oo(i);if(!r)throw new Error(`can't serialize object of unregistered class ${i.constructor.name}`);if(!Ii[r])throw new Error(`${r} is not registered.`);const{klass:a}=Ii[r],l=a.serialize?a.serialize(i,e):{};if(a.serialize){if(e&&l===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const h in i){if(!i.hasOwnProperty(h)||Ii[r].omit.indexOf(h)>=0)continue;const d=i[h];l[h]=Ii[r].shallow.indexOf(h)>=0?d:Cs(d,e)}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 Ps(i){if(cl(i))return i;if(Array.isArray(i))return i.map(Ps);if(typeof i!="object")throw new Error("can't deserialize object of type "+typeof i);const e=oo(i)||"Object";if(!Ii[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=Ii[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(i);const a=Object.create(r.prototype);for(const l of Object.keys(i)){if(l==="$name")continue;const h=i[l];a[l]=Ii[e].shallow.indexOf(l)>=0?h:Ps(h)}return a}class lo{constructor(){this.first=!0}update(e,r){const a=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<a&&(this.lastIntegerZoom=a,this.lastIntegerZoomTime=r),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=a,!0))}}const Ht={"Latin-1 Supplement":i=>i>=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 co(i){for(const e of i)if(ho(e.charCodeAt(0)))return!0;return!1}function ac(i){for(const e of i)if(!As(e.charCodeAt(0)))return!1;return!0}function uo(i){const e=i.map((r=>{try{return new RegExp(`\\p{sc=${r}}`,"u").source}catch{return null}})).filter((r=>r));return new RegExp(e.join("|"),"u")}const nc=uo(["Arab","Dupl","Mong","Ougr","Syrc"]);function As(i){return!nc.test(String.fromCodePoint(i))}const ul=uo(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function ho(i){return!(i!==746&&i!==747&&(i<4352||!(Ht["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||Ht["CJK Compatibility"](i)||Ht["CJK Strokes"](i)||!(!Ht["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||Ht["Enclosed CJK Letters and Months"](i)||Ht["Ideographic Description Characters"](i)||Ht.Kanbun(i)||Ht.Katakana(i)&&i!==12540||!(!Ht["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)||!(!Ht["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||Ht["Vertical Forms"](i)||Ht["Yijing Hexagram Symbols"](i)||new RegExp("\\p{sc=Cans}","u").test(String.fromCodePoint(i))||new RegExp("\\p{sc=Hang}","u").test(String.fromCodePoint(i))||ul.test(String.fromCodePoint(i)))))}function hl(i){return!(ho(i)||(function(e){return!!(Ht["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||Ht["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||Ht["Letterlike Symbols"](e)||Ht["Number Forms"](e)||Ht["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||Ht["Control Pictures"](e)&&e!==9251||Ht["Optical Character Recognition"](e)||Ht["Enclosed Alphanumerics"](e)||Ht["Geometric Shapes"](e)||Ht["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Ht["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Ht["CJK Symbols and Punctuation"](e)||Ht.Katakana(e)||Ht["Private Use Area"](e)||Ht["CJK Compatibility Forms"](e)||Ht["Small Form Variants"](e)||Ht["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)})(i))}const oc=uo(["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 po(i){return oc.test(String.fromCodePoint(i))}function lc(i,e){return!(!e&&po(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||Ht.Khmer(i))}function cc(i){for(const e of i)if(po(e.charCodeAt(0)))return!0;return!1}const _i=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 de{constructor(e,r){this.zoom=e,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 lo,this.transition={})}isSupportedScript(e){return(function(r,a){for(const l of r)if(!lc(l.charCodeAt(0),a))return!1;return!0})(e,_i.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,r=e-Math.floor(e),a=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*a}:{fromScale:.5,toScale:1,t:1-(1-a)*r}}}class Ds{constructor(e,r){this.property=e,this.value=r,this.expression=(function(a,l){if($a(a))return new ks(a,l);if(qa(a)){const h=Xn(a,l);if(h.result==="error")throw new Error(h.value.map((d=>`${d.key}: ${d.message}`)).join(", "));return h.value}{let h=a;return l.type==="color"&&typeof a=="string"?h=se.parse(a):l.type!=="padding"||typeof a!="number"&&!Array.isArray(a)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(a)&&(h=wi.parse(a)):h=pi.parse(a),{kind:"constant",evaluate:()=>h}}})(r===void 0?e.specification.default:r,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,a){return this.property.possiblyEvaluate(this,e,r,a)}}class en{constructor(e){this.property=e,this.value=new Ds(e,void 0)}transitioned(e,r){return new dl(this.property,this.value,r,vi({},e.transition,this.transition),e.now)}untransitioned(){return new dl(this.property,this.value,null,{},0)}}class rn{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return ae(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new en(this._values[e].property)),this._values[e].value=new Ds(this._values[e].property,r===null?void 0:ae(r))}getTransition(e){return ae(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new en(this._values[e].property)),this._values[e].transition=ae(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const a=this.getValue(r);a!==void 0&&(e[r]=a);const l=this.getTransition(r);l!==void 0&&(e[`${r}-transition`]=l)}return e}transitioned(e,r){const a=new fa(this._properties);for(const l of Object.keys(this._values))a._values[l]=this._values[l].transitioned(e,r._values[l]);return a}untransitioned(){const e=new fa(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class dl{constructor(e,r,a,l,h){this.property=e,this.value=r,this.begin=h+l.delay||0,this.end=this.begin+l.duration||0,e.specification.transition&&(l.delay||l.duration)&&(this.prior=a)}possiblyEvaluate(e,r,a){const l=e.now||0,h=this.value.possiblyEvaluate(e,r,a),d=this.prior;if(d){if(l>this.end)return this.prior=null,h;if(this.value.isDataDriven())return this.prior=null,h;if(l<this.begin)return d.possiblyEvaluate(e,r,a);{const f=(l-this.begin)/(this.end-this.begin);return this.property.interpolate(d.possiblyEvaluate(e,r,a),h,(function(_){if(_<=0)return 0;if(_>=1)return 1;const x=_*_,v=x*_;return 4*(_<.5?v:3*(_-x)+v-.75)})(f))}}return h}}class fa{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,a){const l=new _a(this._properties);for(const h of Object.keys(this._values))l._values[h]=this._values[h].possiblyEvaluate(e,r,a);return l}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class ma{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}hasValue(e){return this._values[e].value!==void 0}getValue(e){return ae(this._values[e].value)}setValue(e,r){this._values[e]=new Ds(this._values[e].property,r===null?void 0:ae(r))}serialize(){const e={};for(const r of Object.keys(this._values)){const a=this.getValue(r);a!==void 0&&(e[r]=a)}return e}possiblyEvaluate(e,r,a){const l=new _a(this._properties);for(const h of Object.keys(this._values))l._values[h]=this._values[h].possiblyEvaluate(e,r,a);return l}}class nr{constructor(e,r,a){this.property=e,this.value=r,this.parameters=a}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,a,l){return this.property.evaluate(this.value,this.parameters,e,r,a,l)}}class _a{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Mt{constructor(e){this.specification=e}possiblyEvaluate(e,r){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(r)}interpolate(e,r,a){const l=ii[this.specification.type];return l?l(e,r,a):e}}class Bt{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,a,l){return new nr(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},a,l)}:e.expression,r)}interpolate(e,r,a){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new nr(this,{kind:"constant",value:void 0},e.parameters);const l=ii[this.specification.type];if(l){const h=l(e.value.value,r.value.value,a);return new nr(this,{kind:"constant",value:h},e.parameters)}return e}evaluate(e,r,a,l,h,d){return e.kind==="constant"?e.value:e.evaluate(r,a,l,h,d)}}class sn extends Bt{possiblyEvaluate(e,r,a,l){if(e.value===void 0)return new nr(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){const h=e.expression.evaluate(r,null,{},a,l),d=e.property.specification.type==="resolvedImage"&&typeof h!="string"?h.name:h,f=this._calculate(d,d,d,r);return new nr(this,{kind:"constant",value:f},r)}if(e.expression.kind==="camera"){const h=this._calculate(e.expression.evaluate({zoom:r.zoom-1}),e.expression.evaluate({zoom:r.zoom}),e.expression.evaluate({zoom:r.zoom+1}),r);return new nr(this,{kind:"constant",value:h},r)}return new nr(this,e.expression,r)}evaluate(e,r,a,l,h,d){if(e.kind==="source"){const f=e.evaluate(r,a,l,h,d);return this._calculate(f,f,f,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},a,l),e.evaluate({zoom:Math.floor(r.zoom)},a,l),e.evaluate({zoom:Math.floor(r.zoom)+1},a,l),r):e.value}_calculate(e,r,a,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class an{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,l){if(e.value!==void 0){if(e.expression.kind==="constant"){const h=e.expression.evaluate(r,null,{},a,l);return this._calculate(h,h,h,r)}return this._calculate(e.expression.evaluate(new de(Math.floor(r.zoom-1),r)),e.expression.evaluate(new de(Math.floor(r.zoom),r)),e.expression.evaluate(new de(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,a,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class fo{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,l){return!!e.expression.evaluate(r,null,{},a,l)}interpolate(){return!1}}class u{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in e){const a=e[r];a.specification.overridable&&this.overridableProperties.push(r);const l=this.defaultPropertyValues[r]=new Ds(a,void 0),h=this.defaultTransitionablePropertyValues[r]=new en(a);this.defaultTransitioningPropertyValues[r]=h.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}It("DataDrivenProperty",Bt),It("DataConstantProperty",Mt),It("CrossFadedDataDrivenProperty",sn),It("CrossFadedProperty",an),It("ColorRampProperty",fo);const t="-transition";class s extends us{constructor(e,r){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1},e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),r.layout&&(this._unevaluatedLayout=new ma(r.layout)),r.paint)){this._transitionablePaint=new rn(r.paint);for(const a in e.paint)this.setPaintProperty(a,e.paint[a],{validate:!1});for(const a in e.layout)this.setLayoutProperty(a,e.layout[a],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new _a(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,a={}){r!=null&&this._validate(ll,`layers.${this.id}.layout.${e}`,e,r,a)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return e.endsWith(t)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,a={}){if(r!=null&&this._validate(ol,`layers.${this.id}.paint.${e}`,e,r,a))return!1;if(e.endsWith(t))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{const l=this._transitionablePaint._values[e],h=l.property.specification["property-type"]==="cross-faded-data-driven",d=l.value.isDataDriven(),f=l.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const _=this._transitionablePaint._values[e].value;return _.isDataDriven()||d||h||this._handleOverridablePaintPropertyUpdate(e,f,_)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,a){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),Xs(e,((r,a)=>!(r===void 0||a==="layout"&&!Object.keys(r).length||a==="paint"&&!Object.keys(r).length)))}_validate(e,r,a,l,h={}){return(!h||h.validate!==!1)&&no(this,e.call(es,{key:r,layerType:this.type,objectKey:a,value:l,styleSpec:it,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof nr&&bs(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const n={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class o{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class c{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function m(i,e=1){let r=0,a=0;return{members:i.map((l=>{const h=n[l.type].BYTES_PER_ELEMENT,d=r=g(r,Math.max(e,h)),f=l.components||1;return a=Math.max(a,h),r+=h*f,{name:l.name,type:l.type,components:f,offset:d}})),size:g(r,Math.max(a,e)),alignment:e}}function g(i,e){return Math.ceil(i/e)*e}class y extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const l=2*e;return this.int16[l+0]=r,this.int16[l+1]=a,e}}y.prototype.bytesPerElement=4,It("StructArrayLayout2i4",y);class b extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const h=3*e;return this.int16[h+0]=r,this.int16[h+1]=a,this.int16[h+2]=l,e}}b.prototype.bytesPerElement=6,It("StructArrayLayout3i6",b);class T extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,a,l)}emplace(e,r,a,l,h){const d=4*e;return this.int16[d+0]=r,this.int16[d+1]=a,this.int16[d+2]=l,this.int16[d+3]=h,e}}T.prototype.bytesPerElement=8,It("StructArrayLayout4i8",T);class S extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,h,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,l,h,d)}emplace(e,r,a,l,h,d,f){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=a,this.int16[_+2]=l,this.int16[_+3]=h,this.int16[_+4]=d,this.int16[_+5]=f,e}}S.prototype.bytesPerElement=12,It("StructArrayLayout2i4i12",S);class z extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,h,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,l,h,d)}emplace(e,r,a,l,h,d,f){const _=4*e,x=8*e;return this.int16[_+0]=r,this.int16[_+1]=a,this.uint8[x+4]=l,this.uint8[x+5]=h,this.uint8[x+6]=d,this.uint8[x+7]=f,e}}z.prototype.bytesPerElement=8,It("StructArrayLayout2i4ub8",z);class A extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const l=2*e;return this.float32[l+0]=r,this.float32[l+1]=a,e}}A.prototype.bytesPerElement=8,It("StructArrayLayout2f8",A);class B extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,h,d,f,_,x,v){const w=this.length;return this.resize(w+1),this.emplace(w,e,r,a,l,h,d,f,_,x,v)}emplace(e,r,a,l,h,d,f,_,x,v,w){const I=10*e;return this.uint16[I+0]=r,this.uint16[I+1]=a,this.uint16[I+2]=l,this.uint16[I+3]=h,this.uint16[I+4]=d,this.uint16[I+5]=f,this.uint16[I+6]=_,this.uint16[I+7]=x,this.uint16[I+8]=v,this.uint16[I+9]=w,e}}B.prototype.bytesPerElement=20,It("StructArrayLayout10ui20",B);class V extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,h,d,f,_,x,v,w,I){const E=this.length;return this.resize(E+1),this.emplace(E,e,r,a,l,h,d,f,_,x,v,w,I)}emplace(e,r,a,l,h,d,f,_,x,v,w,I,E){const C=12*e;return this.int16[C+0]=r,this.int16[C+1]=a,this.int16[C+2]=l,this.int16[C+3]=h,this.uint16[C+4]=d,this.uint16[C+5]=f,this.uint16[C+6]=_,this.uint16[C+7]=x,this.int16[C+8]=v,this.int16[C+9]=w,this.int16[C+10]=I,this.int16[C+11]=E,e}}V.prototype.bytesPerElement=24,It("StructArrayLayout4i4ui4i24",V);class $ extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const h=3*e;return this.float32[h+0]=r,this.float32[h+1]=a,this.float32[h+2]=l,e}}$.prototype.bytesPerElement=12,It("StructArrayLayout3f12",$);class N extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}N.prototype.bytesPerElement=4,It("StructArrayLayout1ul4",N);class q 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(e,r,a,l,h,d,f,_,x){const v=this.length;return this.resize(v+1),this.emplace(v,e,r,a,l,h,d,f,_,x)}emplace(e,r,a,l,h,d,f,_,x,v){const w=10*e,I=5*e;return this.int16[w+0]=r,this.int16[w+1]=a,this.int16[w+2]=l,this.int16[w+3]=h,this.int16[w+4]=d,this.int16[w+5]=f,this.uint32[I+3]=_,this.uint16[w+8]=x,this.uint16[w+9]=v,e}}q.prototype.bytesPerElement=20,It("StructArrayLayout6i1ul2ui20",q);class F extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,h,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,l,h,d)}emplace(e,r,a,l,h,d,f){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=a,this.int16[_+2]=l,this.int16[_+3]=h,this.int16[_+4]=d,this.int16[_+5]=f,e}}F.prototype.bytesPerElement=12,It("StructArrayLayout2i2i2i12",F);class H extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,r,a,l,h)}emplace(e,r,a,l,h,d){const f=4*e,_=8*e;return this.float32[f+0]=r,this.float32[f+1]=a,this.float32[f+2]=l,this.int16[_+6]=h,this.int16[_+7]=d,e}}H.prototype.bytesPerElement=16,It("StructArrayLayout2f1f2i16",H);class K extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,h,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,l,h,d)}emplace(e,r,a,l,h,d,f){const _=16*e,x=4*e,v=8*e;return this.uint8[_+0]=r,this.uint8[_+1]=a,this.float32[x+1]=l,this.float32[x+2]=h,this.int16[v+6]=d,this.int16[v+7]=f,e}}K.prototype.bytesPerElement=16,It("StructArrayLayout2ub2f2i16",K);class tt extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const h=3*e;return this.uint16[h+0]=r,this.uint16[h+1]=a,this.uint16[h+2]=l,e}}tt.prototype.bytesPerElement=6,It("StructArrayLayout3ui6",tt);class ot 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(e,r,a,l,h,d,f,_,x,v,w,I,E,C,P,L,U){const Q=this.length;return this.resize(Q+1),this.emplace(Q,e,r,a,l,h,d,f,_,x,v,w,I,E,C,P,L,U)}emplace(e,r,a,l,h,d,f,_,x,v,w,I,E,C,P,L,U,Q){const X=24*e,J=12*e,rt=48*e;return this.int16[X+0]=r,this.int16[X+1]=a,this.uint16[X+2]=l,this.uint16[X+3]=h,this.uint32[J+2]=d,this.uint32[J+3]=f,this.uint32[J+4]=_,this.uint16[X+10]=x,this.uint16[X+11]=v,this.uint16[X+12]=w,this.float32[J+7]=I,this.float32[J+8]=E,this.uint8[rt+36]=C,this.uint8[rt+37]=P,this.uint8[rt+38]=L,this.uint32[J+10]=U,this.int16[X+22]=Q,e}}ot.prototype.bytesPerElement=48,It("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ot);class ut 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(e,r,a,l,h,d,f,_,x,v,w,I,E,C,P,L,U,Q,X,J,rt,ct,wt,Rt,vt,yt,Ct,kt){const St=this.length;return this.resize(St+1),this.emplace(St,e,r,a,l,h,d,f,_,x,v,w,I,E,C,P,L,U,Q,X,J,rt,ct,wt,Rt,vt,yt,Ct,kt)}emplace(e,r,a,l,h,d,f,_,x,v,w,I,E,C,P,L,U,Q,X,J,rt,ct,wt,Rt,vt,yt,Ct,kt,St){const nt=32*e,Pt=16*e;return this.int16[nt+0]=r,this.int16[nt+1]=a,this.int16[nt+2]=l,this.int16[nt+3]=h,this.int16[nt+4]=d,this.int16[nt+5]=f,this.int16[nt+6]=_,this.int16[nt+7]=x,this.uint16[nt+8]=v,this.uint16[nt+9]=w,this.uint16[nt+10]=I,this.uint16[nt+11]=E,this.uint16[nt+12]=C,this.uint16[nt+13]=P,this.uint16[nt+14]=L,this.uint16[nt+15]=U,this.uint16[nt+16]=Q,this.uint16[nt+17]=X,this.uint16[nt+18]=J,this.uint16[nt+19]=rt,this.uint16[nt+20]=ct,this.uint16[nt+21]=wt,this.uint16[nt+22]=Rt,this.uint32[Pt+12]=vt,this.float32[Pt+13]=yt,this.float32[Pt+14]=Ct,this.uint16[nt+30]=kt,this.uint16[nt+31]=St,e}}ut.prototype.bytesPerElement=64,It("StructArrayLayout8i15ui1ul2f2ui64",ut);class xt extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}xt.prototype.bytesPerElement=4,It("StructArrayLayout1f4",xt);class Tt extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const h=3*e;return this.uint16[6*e+0]=r,this.float32[h+1]=a,this.float32[h+2]=l,e}}Tt.prototype.bytesPerElement=12,It("StructArrayLayout1ui2f12",Tt);class ft extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const h=4*e;return this.uint32[2*e+0]=r,this.uint16[h+2]=a,this.uint16[h+3]=l,e}}ft.prototype.bytesPerElement=8,It("StructArrayLayout1ul2ui8",ft);class pt extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const l=2*e;return this.uint16[l+0]=r,this.uint16[l+1]=a,e}}pt.prototype.bytesPerElement=4,It("StructArrayLayout2ui4",pt);class Et extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}Et.prototype.bytesPerElement=2,It("StructArrayLayout1ui2",Et);class Vt extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,a,l)}emplace(e,r,a,l,h){const d=4*e;return this.float32[d+0]=r,this.float32[d+1]=a,this.float32[d+2]=l,this.float32[d+3]=h,e}}Vt.prototype.bytesPerElement=16,It("StructArrayLayout4f16",Vt);class gt 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 mt(this.anchorPointX,this.anchorPointY)}}gt.prototype.size=20;class bt extends q{get(e){return new gt(this,e)}}It("CollisionBoxArray",bt);class Lt 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(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Lt.prototype.size=48;class pe extends ot{get(e){return new Lt(this,e)}}It("PlacedSymbolArray",pe);class $t 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(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}$t.prototype.size=64;class Xt extends ut{get(e){return new $t(this,e)}}It("SymbolInstanceArray",Xt);class fe extends xt{getoffsetX(e){return this.float32[1*e+0]}}It("GlyphOffsetArray",fe);class Ve extends b{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}It("SymbolLineVertexArray",Ve);class Ui 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]}}Ui.prototype.size=12;class me extends Tt{get(e){return new Ui(this,e)}}It("TextAnchorOffsetArray",me);class si 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]}}si.prototype.size=8;class Ke extends ft{get(e){return new si(this,e)}}It("FeatureIndexArray",Ke);class je extends y{}class Je extends y{}class or extends y{}class Rs extends S{}class nn extends z{}class Bs extends A{}class ki extends B{}class on extends V{}class mo extends ${}class Mi extends N{}class Ei extends F{}class Pr extends K{}class $i extends tt{}class Be extends pt{}const Ue=m([{name:"a_pos",components:2,type:"Int16"}],4),{members:gi}=Ue;class Wt{constructor(e=[]){this.segments=e}prepareSegment(e,r,a,l){let h=this.segments[this.segments.length-1];return e>Wt.MAX_VERTEX_ARRAY_LENGTH&&Le(`Max vertices per segment is ${Wt.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!h||h.vertexLength+e>Wt.MAX_VERTEX_ARRAY_LENGTH||h.sortKey!==l)&&(h={vertexOffset:r.length,primitiveOffset:a.length,vertexLength:0,primitiveLength:0},l!==void 0&&(h.sortKey=l),this.segments.push(h)),h}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,a,l){return new Wt([{vertexOffset:e,primitiveOffset:r,vertexLength:a,primitiveLength:l,vaos:{},sortKey:0}])}}function is(i,e){return 256*(i=Ai(Math.floor(i),0,255))+Ai(Math.floor(e),0,255)}Wt.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,It("SegmentVector",Wt);const Fs=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 Ls={exports:{}},pl={exports:{}};pl.exports=function(i,e){var r,a,l,h,d,f,_,x;for(a=i.length-(r=3&i.length),l=e,d=3432918353,f=461845907,x=0;x<a;)_=255&i.charCodeAt(x)|(255&i.charCodeAt(++x))<<8|(255&i.charCodeAt(++x))<<16|(255&i.charCodeAt(++x))<<24,++x,l=27492+(65535&(h=5*(65535&(l=(l^=_=(65535&(_=(_=(65535&_)*d+(((_>>>16)*d&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(h>>>16)&65535)<<16);switch(_=0,r){case 3:_^=(255&i.charCodeAt(x+2))<<16;case 2:_^=(255&i.charCodeAt(x+1))<<8;case 1:l^=_=(65535&(_=(_=(65535&(_^=255&i.charCodeAt(x)))*d+(((_>>>16)*d&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>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 uc=pl.exports,fl={exports:{}};fl.exports=function(i,e){for(var r,a=i.length,l=e^a,h=0;a>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(h)|(255&i.charCodeAt(++h))<<8|(255&i.charCodeAt(++h))<<16|(255&i.charCodeAt(++h))<<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)),a-=4,++h;switch(a){case 3:l^=(255&i.charCodeAt(h+2))<<16;case 2:l^=(255&i.charCodeAt(h+1))<<8;case 1:l=1540483477*(65535&(l^=255&i.charCodeAt(h)))+((1540483477*(l>>>16)&65535)<<16)}return l=1540483477*(65535&(l^=l>>>13))+((1540483477*(l>>>16)&65535)<<16),(l^=l>>>15)>>>0};var Ar=uc,ml=fl.exports;Ls.exports=Ar,Ls.exports.murmur3=Ar,Ls.exports.murmur2=ml;var ln=Pi(Ls.exports);class ga{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,a,l){this.ids.push(cn(e)),this.positions.push(r,a,l)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=cn(e);let a=0,l=this.ids.length-1;for(;a<l;){const d=a+l>>1;this.ids[d]>=r?l=d:a=d+1}const h=[];for(;this.ids[a]===r;)h.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return h}static serialize(e,r){const a=new Float64Array(e.ids),l=new Uint32Array(e.positions);return un(a,l,0,a.length-1),r&&r.push(a.buffer,l.buffer),{ids:a,positions:l}}static deserialize(e){const r=new ga;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function cn(i){const e=+i;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:ln(String(i))}function un(i,e,r,a){for(;r<a;){const l=i[r+a>>1];let h=r-1,d=a+1;for(;;){do h++;while(i[h]<l);do d--;while(i[d]>l);if(h>=d)break;Os(i,h,d),Os(e,3*h,3*d),Os(e,3*h+1,3*d+1),Os(e,3*h+2,3*d+2)}d-r<a-d?(un(i,e,r,d),r=d+1):(un(i,e,d+1,a),a=d)}}function Os(i,e,r){const a=i[e];i[e]=i[r],i[r]=a}It("FeaturePositionMap",ga);class ya{constructor(e,r){this.gl=e.gl,this.location=r}}class _l extends ya{constructor(e,r){super(e,r),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Qc extends ya{constructor(e,r){super(e,r),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class tu extends ya{constructor(e,r){super(e,r),this.current=se.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const Vh=new Float32Array(16);function hc(i){return[is(255*i.r,255*i.g),is(255*i.b,255*i.a)]}class _o{constructor(e,r,a){this.value=e,this.uniformNames=r.map((l=>`u_${l}`)),this.type=a}setUniform(e,r,a){e.set(a.constantOr(this.value))}getBinding(e,r,a){return this.type==="color"?new tu(e,r):new _l(e,r)}}class hn{constructor(e,r){this.uniformNames=r.map((a=>`u_${a}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=e.tlbr}setUniform(e,r,a,l){const h=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;h&&e.set(h)}getBinding(e,r,a){return a.substr(0,9)==="u_pattern"?new Qc(e,r):new _l(e,r)}}class rs{constructor(e,r,a,l){this.expression=e,this.type=a,this.maxValue=0,this.paintVertexAttributes=r.map((h=>({name:`a_${h}`,type:"Float32",components:a==="color"?2:1,offset:0}))),this.paintVertexArray=new l}populatePaintArray(e,r,a,l,h){const d=this.paintVertexArray.length,f=this.expression.evaluate(new de(0),r,{},l,[],h);this.paintVertexArray.resize(e),this._setPaintValue(d,e,f)}updatePaintArray(e,r,a,l){const h=this.expression.evaluate({zoom:0},a,l);this._setPaintValue(e,r,h)}_setPaintValue(e,r,a){if(this.type==="color"){const l=hc(a);for(let h=e;h<r;h++)this.paintVertexArray.emplace(h,l[0],l[1])}else{for(let l=e;l<r;l++)this.paintVertexArray.emplace(l,a);this.maxValue=Math.max(this.maxValue,Math.abs(a))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class yr{constructor(e,r,a,l,h,d){this.expression=e,this.uniformNames=r.map((f=>`u_${f}_t`)),this.type=a,this.useIntegerZoom=l,this.zoom=h,this.maxValue=0,this.paintVertexAttributes=r.map((f=>({name:`a_${f}`,type:"Float32",components:a==="color"?4:2,offset:0}))),this.paintVertexArray=new d}populatePaintArray(e,r,a,l,h){const d=this.expression.evaluate(new de(this.zoom),r,{},l,[],h),f=this.expression.evaluate(new de(this.zoom+1),r,{},l,[],h),_=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(_,e,d,f)}updatePaintArray(e,r,a,l){const h=this.expression.evaluate({zoom:this.zoom},a,l),d=this.expression.evaluate({zoom:this.zoom+1},a,l);this._setPaintValue(e,r,h,d)}_setPaintValue(e,r,a,l){if(this.type==="color"){const h=hc(a),d=hc(l);for(let f=e;f<r;f++)this.paintVertexArray.emplace(f,h[0],h[1],d[0],d[1])}else{for(let h=e;h<r;h++)this.paintVertexArray.emplace(h,a,l);this.maxValue=Math.max(this.maxValue,Math.abs(a),Math.abs(l))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r){const a=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,l=Ai(this.expression.interpolationFactor(a,this.zoom,this.zoom+1),0,1);e.set(l)}getBinding(e,r,a){return new _l(e,r)}}class Vs{constructor(e,r,a,l,h,d){this.expression=e,this.type=r,this.useIntegerZoom=a,this.zoom=l,this.layerId=d,this.zoomInPaintVertexArray=new h,this.zoomOutPaintVertexArray=new h}populatePaintArray(e,r,a){const l=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(l,e,r.patterns&&r.patterns[this.layerId],a)}updatePaintArray(e,r,a,l,h){this._setPaintValues(e,r,a.patterns&&a.patterns[this.layerId],h)}_setPaintValues(e,r,a,l){if(!l||!a)return;const{min:h,mid:d,max:f}=a,_=l[h],x=l[d],v=l[f];if(_&&x&&v)for(let w=e;w<r;w++)this.zoomInPaintVertexArray.emplace(w,x.tl[0],x.tl[1],x.br[0],x.br[1],_.tl[0],_.tl[1],_.br[0],_.br[1],x.pixelRatio,_.pixelRatio),this.zoomOutPaintVertexArray.emplace(w,x.tl[0],x.tl[1],x.br[0],x.br[1],v.tl[0],v.tl[1],v.br[0],v.br[1],x.pixelRatio,v.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,Fs.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,Fs.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class eu{constructor(e,r,a){this.binders={},this._buffers=[];const l=[];for(const h in e.paint._values){if(!a(h))continue;const d=e.paint.get(h);if(!(d instanceof nr&&bs(d.property.specification)))continue;const f=jh(h,e.type),_=d.value,x=d.property.specification.type,v=d.property.useIntegerZoom,w=d.property.specification["property-type"],I=w==="cross-faded"||w==="cross-faded-data-driven";if(_.kind==="constant")this.binders[h]=I?new hn(_.value,f):new _o(_.value,f,x),l.push(`/u_${h}`);else if(_.kind==="source"||I){const E=iu(h,x,"source");this.binders[h]=I?new Vs(_,x,v,r,E,e.id):new rs(_,f,x,E),l.push(`/a_${h}`)}else{const E=iu(h,x,"composite");this.binders[h]=new yr(_,f,x,v,r,E),l.push(`/z_${h}`)}}this.cacheKey=l.sort().join("")}getMaxValue(e){const r=this.binders[e];return r instanceof rs||r instanceof yr?r.maxValue:0}populatePaintArrays(e,r,a,l,h){for(const d in this.binders){const f=this.binders[d];(f instanceof rs||f instanceof yr||f instanceof Vs)&&f.populatePaintArray(e,r,a,l,h)}}setConstantPatternPositions(e,r){for(const a in this.binders){const l=this.binders[a];l instanceof hn&&l.setConstantPatternPositions(e,r)}}updatePaintArrays(e,r,a,l,h){let d=!1;for(const f in e){const _=r.getPositions(f);for(const x of _){const v=a.feature(x.index);for(const w in this.binders){const I=this.binders[w];if((I instanceof rs||I instanceof yr||I instanceof Vs)&&I.expression.isStateDependent===!0){const E=l.paint.get(w);I.expression=E.value,I.updatePaintArray(x.start,x.end,v,e[f],h),d=!0}}}}return d}defines(){const e=[];for(const r in this.binders){const a=this.binders[r];(a instanceof _o||a instanceof hn)&&e.push(...a.uniformNames.map((l=>`#define HAS_UNIFORM_${l}`)))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const a=this.binders[r];if(a instanceof rs||a instanceof yr)for(let l=0;l<a.paintVertexAttributes.length;l++)e.push(a.paintVertexAttributes[l].name);else if(a instanceof Vs)for(let l=0;l<Fs.members.length;l++)e.push(Fs.members[l].name)}return e}getBinderUniforms(){const e=[];for(const r in this.binders){const a=this.binders[r];if(a instanceof _o||a instanceof hn||a instanceof yr)for(const l of a.uniformNames)e.push(l)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,r){const a=[];for(const l in this.binders){const h=this.binders[l];if(h instanceof _o||h instanceof hn||h instanceof yr){for(const d of h.uniformNames)if(r[d]){const f=h.getBinding(e,r[d],d);a.push({name:d,property:l,binding:f})}}}return a}setUniforms(e,r,a,l){for(const{name:h,property:d,binding:f}of r)this.binders[d].setUniform(f,l,a.get(d),h)}updatePaintBuffers(e){this._buffers=[];for(const r in this.binders){const a=this.binders[r];if(e&&a instanceof Vs){const l=e.fromScale===2?a.zoomInPaintVertexBuffer:a.zoomOutPaintVertexBuffer;l&&this._buffers.push(l)}else(a instanceof rs||a instanceof yr)&&a.paintVertexBuffer&&this._buffers.push(a.paintVertexBuffer)}}upload(e){for(const r in this.binders){const a=this.binders[r];(a instanceof rs||a instanceof yr||a instanceof Vs)&&a.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const r=this.binders[e];(r instanceof rs||r instanceof yr||r instanceof Vs)&&r.destroy()}}}class xa{constructor(e,r,a=(()=>!0)){this.programConfigurations={};for(const l of e)this.programConfigurations[l.id]=new eu(l,r,a);this.needsUpload=!1,this._featureMap=new ga,this._bufferOffset=0}populatePaintArrays(e,r,a,l,h,d){for(const f in this.programConfigurations)this.programConfigurations[f].populatePaintArrays(e,r,l,h,d);r.id!==void 0&&this._featureMap.add(r.id,a,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,a,l){for(const h of a)this.needsUpload=this.programConfigurations[h.id].updatePaintArrays(e,this._featureMap,r,h,l)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function jh(i,e){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(`${e}-`,"").replace(/-/g,"_")]}function iu(i,e,r){const a={color:{source:A,composite:Vt},number:{source:xt,composite:A}},l=(function(h){return{"line-pattern":{source:ki,composite:ki},"fill-pattern":{source:ki,composite:ki},"fill-extrusion-pattern":{source:ki,composite:ki}}[h]})(i);return l&&l[r]||a[e][r]}It("ConstantBinder",_o),It("CrossFadedConstantBinder",hn),It("SourceExpressionBinder",rs),It("CrossFadedCompositeBinder",Vs),It("CompositeExpressionBinder",yr),It("ProgramConfiguration",eu,{omit:["_buffers"]}),It("ProgramConfigurationSet",xa);const Ee=8192,dc=Math.pow(2,14)-1,ru=-dc-1;function va(i){const e=Ee/i.extent,r=i.loadGeometry();for(let a=0;a<r.length;a++){const l=r[a];for(let h=0;h<l.length;h++){const d=l[h],f=Math.round(d.x*e),_=Math.round(d.y*e);d.x=Ai(f,ru,dc),d.y=Ai(_,ru,dc),(f<d.x||f>d.x+1||_<d.y||_>d.y+1)&&Le("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function ba(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?va(i):[]}}function gl(i,e,r,a,l){i.emplaceBack(2*e+(a+1)/2,2*r+(l+1)/2)}class pc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Je,this.indexArray=new $i,this.segments=new Wt,this.programConfigurations=new xa(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){const l=this.layers[0],h=[];let d=null,f=!1;l.type==="circle"&&(d=l.layout.get("circle-sort-key"),f=!d.isConstant());for(const{feature:_,id:x,index:v,sourceLayerIndex:w}of e){const I=this.layers[0]._featureFilter.needGeometry,E=ba(_,I);if(!this.layers[0]._featureFilter.filter(new de(this.zoom),E,a))continue;const C=f?d.evaluate(E,{},a):void 0,P={id:x,properties:_.properties,type:_.type,sourceLayerIndex:w,index:v,geometry:I?E.geometry:va(_),patterns:{},sortKey:C};h.push(P)}f&&h.sort(((_,x)=>_.sortKey-x.sortKey));for(const _ of h){const{geometry:x,index:v,sourceLayerIndex:w}=_,I=e[v].feature;this.addFeature(_,x,v,a),r.featureIndex.insert(I,x,v,w,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gi),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,a,l){for(const h of r)for(const d of h){const f=d.x,_=d.y;if(f<0||f>=Ee||_<0||_>=Ee)continue;const x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),v=x.vertexLength;gl(this.layoutVertexArray,f,_,-1,-1),gl(this.layoutVertexArray,f,_,1,-1),gl(this.layoutVertexArray,f,_,1,1),gl(this.layoutVertexArray,f,_,-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,e,a,{},l)}}function su(i,e){for(let r=0;r<i.length;r++)if(dn(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(dn(i,e[r]))return!0;return!!fc(i,e)}function Uh(i,e,r){return!!dn(i,e)||!!mc(e,i,r)}function au(i,e){if(i.length===1)return ou(e,i[0]);for(let r=0;r<e.length;r++){const a=e[r];for(let l=0;l<a.length;l++)if(dn(i,a[l]))return!0}for(let r=0;r<i.length;r++)if(ou(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(fc(i,e[r]))return!0;return!1}function $h(i,e,r){if(i.length>1){if(fc(i,e))return!0;for(let a=0;a<e.length;a++)if(mc(e[a],i,r))return!0}for(let a=0;a<i.length;a++)if(mc(i[a],e,r))return!0;return!1}function fc(i,e){if(i.length===0||e.length===0)return!1;for(let r=0;r<i.length-1;r++){const a=i[r],l=i[r+1];for(let h=0;h<e.length-1;h++)if(Nh(a,l,e[h],e[h+1]))return!0}return!1}function Nh(i,e,r,a){return Xe(i,r,a)!==Xe(e,r,a)&&Xe(i,e,r)!==Xe(i,e,a)}function mc(i,e,r){const a=r*r;if(e.length===1)return i.distSqr(e[0])<a;for(let l=1;l<e.length;l++)if(nu(i,e[l-1],e[l])<a)return!0;return!1}function nu(i,e,r){const a=e.distSqr(r);if(a===0)return i.distSqr(e);const l=((i.x-e.x)*(r.x-e.x)+(i.y-e.y)*(r.y-e.y))/a;return i.distSqr(l<0?e:l>1?r:r.sub(e)._mult(l)._add(e))}function ou(i,e){let r,a,l,h=!1;for(let d=0;d<i.length;d++){r=i[d];for(let f=0,_=r.length-1;f<r.length;_=f++)a=r[f],l=r[_],a.y>e.y!=l.y>e.y&&e.x<(l.x-a.x)*(e.y-a.y)/(l.y-a.y)+a.x&&(h=!h)}return h}function dn(i,e){let r=!1;for(let a=0,l=i.length-1;a<i.length;l=a++){const h=i[a],d=i[l];h.y>e.y!=d.y>e.y&&e.x<(d.x-h.x)*(e.y-h.y)/(d.y-h.y)+h.x&&(r=!r)}return r}function Zh(i,e,r){const a=r[0],l=r[2];if(i.x<a.x&&e.x<a.x||i.x>l.x&&e.x>l.x||i.y<a.y&&e.y<a.y||i.y>l.y&&e.y>l.y)return!1;const h=Xe(i,e,r[0]);return h!==Xe(i,e,r[1])||h!==Xe(i,e,r[2])||h!==Xe(i,e,r[3])}function go(i,e,r){const a=e.paint.get(i).value;return a.kind==="constant"?a.value:r.programConfigurations.get(e.id).getMaxValue(i)}function yl(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function xl(i,e,r,a,l){if(!e[0]&&!e[1])return i;const h=mt.convert(e)._mult(l);r==="viewport"&&h._rotate(-a);const d=[];for(let f=0;f<i.length;f++)d.push(i[f].sub(h));return d}let lu,cu;It("CircleBucket",pc,{omit:["layers"]});var qh={get paint(){return cu=cu||new u({"circle-radius":new Bt(it.paint_circle["circle-radius"]),"circle-color":new Bt(it.paint_circle["circle-color"]),"circle-blur":new Bt(it.paint_circle["circle-blur"]),"circle-opacity":new Bt(it.paint_circle["circle-opacity"]),"circle-translate":new Mt(it.paint_circle["circle-translate"]),"circle-translate-anchor":new Mt(it.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Mt(it.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Mt(it.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Bt(it.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Bt(it.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Bt(it.paint_circle["circle-stroke-opacity"])})},get layout(){return lu=lu||new u({"circle-sort-key":new Bt(it.layout_circle["circle-sort-key"])})}},ai=1e-6,pn=typeof Float32Array<"u"?Float32Array:Array;function _c(i){return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i}function uu(i,e,r){var a=e[0],l=e[1],h=e[2],d=e[3],f=e[4],_=e[5],x=e[6],v=e[7],w=e[8],I=e[9],E=e[10],C=e[11],P=e[12],L=e[13],U=e[14],Q=e[15],X=r[0],J=r[1],rt=r[2],ct=r[3];return i[0]=X*a+J*f+rt*w+ct*P,i[1]=X*l+J*_+rt*I+ct*L,i[2]=X*h+J*x+rt*E+ct*U,i[3]=X*d+J*v+rt*C+ct*Q,i[4]=(X=r[4])*a+(J=r[5])*f+(rt=r[6])*w+(ct=r[7])*P,i[5]=X*l+J*_+rt*I+ct*L,i[6]=X*h+J*x+rt*E+ct*U,i[7]=X*d+J*v+rt*C+ct*Q,i[8]=(X=r[8])*a+(J=r[9])*f+(rt=r[10])*w+(ct=r[11])*P,i[9]=X*l+J*_+rt*I+ct*L,i[10]=X*h+J*x+rt*E+ct*U,i[11]=X*d+J*v+rt*C+ct*Q,i[12]=(X=r[12])*a+(J=r[13])*f+(rt=r[14])*w+(ct=r[15])*P,i[13]=X*l+J*_+rt*I+ct*L,i[14]=X*h+J*x+rt*E+ct*U,i[15]=X*d+J*v+rt*C+ct*Q,i}Math.hypot||(Math.hypot=function(){for(var i=0,e=arguments.length;e--;)i+=arguments[e]*arguments[e];return Math.sqrt(i)});var yo,Gh=uu;function vl(i,e,r){var a=e[0],l=e[1],h=e[2],d=e[3];return i[0]=r[0]*a+r[4]*l+r[8]*h+r[12]*d,i[1]=r[1]*a+r[5]*l+r[9]*h+r[13]*d,i[2]=r[2]*a+r[6]*l+r[10]*h+r[14]*d,i[3]=r[3]*a+r[7]*l+r[11]*h+r[15]*d,i}yo=new pn(4),pn!=Float32Array&&(yo[0]=0,yo[1]=0,yo[2]=0,yo[3]=0);class Xh extends s{constructor(e){super(e,qh)}createBucket(e){return new pc(e)}queryRadius(e){const r=e;return go("circle-radius",this,r)+go("circle-stroke-width",this,r)+yl(this.paint.get("circle-translate"))}queryIntersectsFeature(e,r,a,l,h,d,f,_){const x=xl(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),d.angle,f),v=this.paint.get("circle-radius").evaluate(r,a)+this.paint.get("circle-stroke-width").evaluate(r,a),w=this.paint.get("circle-pitch-alignment")==="map",I=w?x:(function(C,P){return C.map((L=>hu(L,P)))})(x,_),E=w?v*f:v;for(const C of l)for(const P of C){const L=w?P:hu(P,_);let U=E;const Q=vl([],[P.x,P.y,0,1],_);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?U*=Q[3]/d.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(U*=d.cameraToCenterDistance/Q[3]),Uh(I,L,U))return!0}return!1}}function hu(i,e){const r=vl([],[i.x,i.y,0,1],e);return new mt(r[0]/r[3],r[1]/r[3])}class du extends pc{}let pu;It("HeatmapBucket",du,{omit:["layers"]});var Hh={get paint(){return pu=pu||new u({"heatmap-radius":new Bt(it.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Bt(it.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Mt(it.paint_heatmap["heatmap-intensity"]),"heatmap-color":new fo(it.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Mt(it.paint_heatmap["heatmap-opacity"])})}};function gc(i,{width:e,height:r},a,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==e*r*a)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${e*r*a}`)}else l=new Uint8Array(e*r*a);return i.width=e,i.height=r,i.data=l,i}function fu(i,{width:e,height:r},a){if(e===i.width&&r===i.height)return;const l=gc({},{width:e,height:r},a);yc(i,l,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,e),height:Math.min(i.height,r)},a),i.width=e,i.height=r,i.data=l.data}function yc(i,e,r,a,l,h){if(l.width===0||l.height===0)return e;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>e.width||l.height>e.height||a.x>e.width-l.width||a.y>e.height-l.height)throw new RangeError("out of range destination coordinates for image copy");const d=i.data,f=e.data;if(d===f)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_<l.height;_++){const x=((r.y+_)*i.width+r.x)*h,v=((a.y+_)*e.width+a.x)*h;for(let w=0;w<l.width*h;w++)f[v+w]=d[x+w]}return e}class xo{constructor(e,r){gc(this,e,1,r)}resize(e){fu(this,e,1)}clone(){return new xo({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,a,l,h){yc(e,r,a,l,h,1)}}class Ni{constructor(e,r){gc(this,e,4,r)}resize(e){fu(this,e,4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Ni({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,a,l,h){yc(e,r,a,l,h,4)}}function mu(i){const e={},r=i.resolution||256,a=i.clips?i.clips.length:1,l=i.image||new Ni({width:r,height:a});if(Math.log(r)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${r}`);const h=(d,f,_)=>{e[i.evaluationKey]=_;const x=i.expression.evaluate(e);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;d<a;++d,f+=4*r)for(let _=0,x=0;_<r;_++,x+=4){const v=_/(r-1),{start:w,end:I}=i.clips[d];h(f,x,w*(1-v)+I*v)}else for(let d=0,f=0;d<r;d++,f+=4)h(0,f,d/(r-1));return l}It("AlphaImage",xo),It("RGBAImage",Ni);const xc="big-fb";class Wh extends s{createBucket(e){return new du(e)}constructor(e){super(e,Hh),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=mu({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(xc)&&this.heatmapFbos.delete(xc)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}}let _u;var Kh={get paint(){return _u=_u||new u({"hillshade-illumination-direction":new Mt(it.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Mt(it.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Mt(it.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Mt(it.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Mt(it.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Mt(it.paint_hillshade["hillshade-accent-color"])})}};class Jh extends s{constructor(e){super(e,Kh)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}const Yh=m([{name:"a_pos",components:2,type:"Int16"}],4),{members:Qh}=Yh;function gu(i,e,r=2){const a=e&&e.length,l=a?e[0]*r:i.length;let h=yu(i,0,l,r,!0);const d=[];if(!h||h.next===h.prev)return d;let f,_,x;if(a&&(h=(function(v,w,I,E){const C=[];for(let P=0,L=w.length;P<L;P++){const U=yu(v,w[P]*E,P<L-1?w[P+1]*E:v.length,E,!1);U===U.next&&(U.steiner=!0),C.push(od(U))}C.sort(sd);for(let P=0;P<C.length;P++)I=ad(C[P],I);return I})(i,e,h,r)),i.length>80*r){f=1/0,_=1/0;let v=-1/0,w=-1/0;for(let I=r;I<l;I+=r){const E=i[I],C=i[I+1];E<f&&(f=E),C<_&&(_=C),E>v&&(v=E),C>w&&(w=C)}x=Math.max(v-f,w-_),x=x!==0?32767/x:0}return vo(h,d,r,f,_,x,0),d}function yu(i,e,r,a,l){let h;if(l===(function(d,f,_,x){let v=0;for(let w=f,I=_-x;w<_;w+=x)v+=(d[I]-d[w])*(d[w+1]+d[I+1]),I=w;return v})(i,e,r,a)>0)for(let d=e;d<r;d+=a)h=bu(d/a|0,i[d],i[d+1],h);else for(let d=r-a;d>=e;d-=a)h=bu(d/a|0,i[d],i[d+1],h);return h&&bl(h,h.next)&&(wo(h),h=h.next),h}function wa(i,e){if(!i)return i;e||(e=i);let r,a=i;do if(r=!1,a.steiner||!bl(a,a.next)&&Ie(a.prev,a,a.next)!==0)a=a.next;else{if(wo(a),a=e=a.prev,a===a.next)break;r=!0}while(r||a!==e);return e}function vo(i,e,r,a,l,h,d){if(!i)return;!d&&h&&(function(_,x,v,w){let I=_;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!==_);I.prevZ.nextZ=null,I.prevZ=null,(function(E){let C,P=1;do{let L,U=E;E=null;let Q=null;for(C=0;U;){C++;let X=U,J=0;for(let ct=0;ct<P&&(J++,X=X.nextZ,X);ct++);let rt=P;for(;J>0||rt>0&&X;)J!==0&&(rt===0||!X||U.z<=X.z)?(L=U,U=U.nextZ,J--):(L=X,X=X.nextZ,rt--),Q?Q.nextZ=L:E=L,L.prevZ=Q,Q=L;U=X}Q.nextZ=null,P*=2}while(C>1)})(I)})(i,a,l,h);let f=i;for(;i.prev!==i.next;){const _=i.prev,x=i.next;if(h?ed(i,a,l,h):td(i))e.push(_.i,i.i,x.i),wo(i),i=x.next,f=x.next;else if((i=x)===f){d?d===1?vo(i=id(wa(i),e),e,r,a,l,h,2):d===2&&rd(i,e,r,a,l,h):vo(wa(i),e,r,a,l,h,1);break}}}function td(i){const e=i.prev,r=i,a=i.next;if(Ie(e,r,a)>=0)return!1;const l=e.x,h=r.x,d=a.x,f=e.y,_=r.y,x=a.y,v=l<h?l<d?l:d:h<d?h:d,w=f<_?f<x?f:x:_<x?_:x,I=l>h?l>d?l:d:h>d?h:d,E=f>_?f>x?f:x:_>x?_:x;let C=a.next;for(;C!==e;){if(C.x>=v&&C.x<=I&&C.y>=w&&C.y<=E&&fn(l,f,h,_,d,x,C.x,C.y)&&Ie(C.prev,C,C.next)>=0)return!1;C=C.next}return!0}function ed(i,e,r,a){const l=i.prev,h=i,d=i.next;if(Ie(l,h,d)>=0)return!1;const f=l.x,_=h.x,x=d.x,v=l.y,w=h.y,I=d.y,E=f<_?f<x?f:x:_<x?_:x,C=v<w?v<I?v:I:w<I?w:I,P=f>_?f>x?f:x:_>x?_:x,L=v>w?v>I?v:I:w>I?w:I,U=vc(E,C,e,r,a),Q=vc(P,L,e,r,a);let X=i.prevZ,J=i.nextZ;for(;X&&X.z>=U&&J&&J.z<=Q;){if(X.x>=E&&X.x<=P&&X.y>=C&&X.y<=L&&X!==l&&X!==d&&fn(f,v,_,w,x,I,X.x,X.y)&&Ie(X.prev,X,X.next)>=0||(X=X.prevZ,J.x>=E&&J.x<=P&&J.y>=C&&J.y<=L&&J!==l&&J!==d&&fn(f,v,_,w,x,I,J.x,J.y)&&Ie(J.prev,J,J.next)>=0))return!1;J=J.nextZ}for(;X&&X.z>=U;){if(X.x>=E&&X.x<=P&&X.y>=C&&X.y<=L&&X!==l&&X!==d&&fn(f,v,_,w,x,I,X.x,X.y)&&Ie(X.prev,X,X.next)>=0)return!1;X=X.prevZ}for(;J&&J.z<=Q;){if(J.x>=E&&J.x<=P&&J.y>=C&&J.y<=L&&J!==l&&J!==d&&fn(f,v,_,w,x,I,J.x,J.y)&&Ie(J.prev,J,J.next)>=0)return!1;J=J.nextZ}return!0}function id(i,e){let r=i;do{const a=r.prev,l=r.next.next;!bl(a,l)&&xu(a,r,r.next,l)&&bo(a,l)&&bo(l,a)&&(e.push(a.i,r.i,l.i),wo(r),wo(r.next),r=i=l),r=r.next}while(r!==i);return wa(r)}function rd(i,e,r,a,l,h){let d=i;do{let f=d.next.next;for(;f!==d.prev;){if(d.i!==f.i&&ld(d,f)){let _=vu(d,f);return d=wa(d,d.next),_=wa(_,_.next),vo(d,e,r,a,l,h,0),void vo(_,e,r,a,l,h,0)}f=f.next}d=d.next}while(d!==i)}function sd(i,e){return i.x-e.x}function ad(i,e){const r=(function(l,h){let d=h;const f=l.x,_=l.y;let x,v=-1/0;do{if(_<=d.y&&_>=d.next.y&&d.next.y!==d.y){const P=d.x+(_-d.y)*(d.next.x-d.x)/(d.next.y-d.y);if(P<=f&&P>v&&(v=P,x=d.x<d.next.x?d:d.next,P===f))return x}d=d.next}while(d!==h);if(!x)return null;const w=x,I=x.x,E=x.y;let C=1/0;d=x;do{if(f>=d.x&&d.x>=I&&f!==d.x&&fn(_<E?f:v,_,I,E,_<E?v:f,_,d.x,d.y)){const P=Math.abs(_-d.y)/(f-d.x);bo(d,l)&&(P<C||P===C&&(d.x>x.x||d.x===x.x&&nd(x,d)))&&(x=d,C=P)}d=d.next}while(d!==w);return x})(i,e);if(!r)return e;const a=vu(r,i);return wa(a,a.next),wa(r,r.next)}function nd(i,e){return Ie(i.prev,i,e.prev)<0&&Ie(e.next,i,i.next)<0}function vc(i,e,r,a,l){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*l|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-a)*l|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function od(i){let e=i,r=i;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==i);return r}function fn(i,e,r,a,l,h,d,f){return(l-d)*(e-f)>=(i-d)*(h-f)&&(i-d)*(a-f)>=(r-d)*(e-f)&&(r-d)*(h-f)>=(l-d)*(a-f)}function ld(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!(function(r,a){let l=r;do{if(l.i!==r.i&&l.next.i!==r.i&&l.i!==a.i&&l.next.i!==a.i&&xu(l,l.next,r,a))return!0;l=l.next}while(l!==r);return!1})(i,e)&&(bo(i,e)&&bo(e,i)&&(function(r,a){let l=r,h=!1;const d=(r.x+a.x)/2,f=(r.y+a.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&&(h=!h),l=l.next;while(l!==r);return h})(i,e)&&(Ie(i.prev,i,e.prev)||Ie(i,e.prev,e))||bl(i,e)&&Ie(i.prev,i,i.next)>0&&Ie(e.prev,e,e.next)>0)}function Ie(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function bl(i,e){return i.x===e.x&&i.y===e.y}function xu(i,e,r,a){const l=Tl(Ie(i,e,r)),h=Tl(Ie(i,e,a)),d=Tl(Ie(r,a,i)),f=Tl(Ie(r,a,e));return l!==h&&d!==f||!(l!==0||!wl(i,r,e))||!(h!==0||!wl(i,a,e))||!(d!==0||!wl(r,i,a))||!(f!==0||!wl(r,e,a))}function wl(i,e,r){return e.x<=Math.max(i.x,r.x)&&e.x>=Math.min(i.x,r.x)&&e.y<=Math.max(i.y,r.y)&&e.y>=Math.min(i.y,r.y)}function Tl(i){return i>0?1:i<0?-1:0}function bo(i,e){return Ie(i.prev,i,i.next)<0?Ie(i,e,i.next)>=0&&Ie(i,i.prev,e)>=0:Ie(i,e,i.prev)<0||Ie(i,i.next,e)<0}function vu(i,e){const r=bc(i.i,i.x,i.y),a=bc(e.i,e.x,e.y),l=i.next,h=e.prev;return i.next=e,e.prev=i,r.next=l,l.prev=r,a.next=r,r.prev=a,h.next=a,a.prev=h,a}function bu(i,e,r,a){const l=bc(i,e,r);return a?(l.next=a.next,l.prev=a,a.next.prev=l,a.next=l):(l.prev=l,l.next=l),l}function wo(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 bc(i,e,r){return{i,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function wc(i,e,r){const a=r.patternDependencies;let l=!1;for(const h of e){const d=h.paint.get(`${i}-pattern`);d.isConstant()||(l=!0);const f=d.constantOr(null);f&&(l=!0,a[f.to]=!0,a[f.from]=!0)}return l}function Tc(i,e,r,a,l){const h=l.patternDependencies;for(const d of e){const f=d.paint.get(`${i}-pattern`).value;if(f.kind!=="constant"){let _=f.evaluate({zoom:a-1},r,{},l.availableImages),x=f.evaluate({zoom:a},r,{},l.availableImages),v=f.evaluate({zoom:a+1},r,{},l.availableImages);_=_&&_.name?_.name:_,x=x&&x.name?x.name:x,v=v&&v.name?v.name:v,h[_]=!0,h[x]=!0,h[v]=!0,r.patterns[d.id]={min:_,mid:x,max:v}}}return r}class Sc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new or,this.indexArray=new $i,this.indexArray2=new Be,this.programConfigurations=new xa(e.layers,e.zoom),this.segments=new Wt,this.segments2=new Wt,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){this.hasPattern=wc("fill",this.layers,r);const l=this.layers[0].layout.get("fill-sort-key"),h=!l.isConstant(),d=[];for(const{feature:f,id:_,index:x,sourceLayerIndex:v}of e){const w=this.layers[0]._featureFilter.needGeometry,I=ba(f,w);if(!this.layers[0]._featureFilter.filter(new de(this.zoom),I,a))continue;const E=h?l.evaluate(I,{},a,r.availableImages):void 0,C={id:_,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?I.geometry:va(f),patterns:{},sortKey:E};d.push(C)}h&&d.sort(((f,_)=>f.sortKey-_.sortKey));for(const f of d){const{geometry:_,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){const w=Tc("fill",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,_,x,a,{});r.featureIndex.insert(e[x].feature,_,x,v,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Qh),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,r,a,l,h){for(const d of La(r,500)){let f=0;for(const E of d)f+=E.length;const _=this.segments.prepareSegment(f,this.layoutVertexArray,this.indexArray),x=_.vertexLength,v=[],w=[];for(const E of d){if(E.length===0)continue;E!==d[0]&&w.push(v.length/2);const C=this.segments2.prepareSegment(E.length,this.layoutVertexArray,this.indexArray2),P=C.vertexLength;this.layoutVertexArray.emplaceBack(E[0].x,E[0].y),this.indexArray2.emplaceBack(P+E.length-1,P),v.push(E[0].x),v.push(E[0].y);for(let L=1;L<E.length;L++)this.layoutVertexArray.emplaceBack(E[L].x,E[L].y),this.indexArray2.emplaceBack(P+L-1,P+L),v.push(E[L].x),v.push(E[L].y);C.vertexLength+=E.length,C.primitiveLength+=E.length}const I=gu(v,w);for(let E=0;E<I.length;E+=3)this.indexArray.emplaceBack(x+I[E],x+I[E+1],x+I[E+2]);_.vertexLength+=f,_.primitiveLength+=I.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,h,l)}}let wu,Tu;It("FillBucket",Sc,{omit:["layers","patternFeatures"]});var cd={get paint(){return Tu=Tu||new u({"fill-antialias":new Mt(it.paint_fill["fill-antialias"]),"fill-opacity":new Bt(it.paint_fill["fill-opacity"]),"fill-color":new Bt(it.paint_fill["fill-color"]),"fill-outline-color":new Bt(it.paint_fill["fill-outline-color"]),"fill-translate":new Mt(it.paint_fill["fill-translate"]),"fill-translate-anchor":new Mt(it.paint_fill["fill-translate-anchor"]),"fill-pattern":new sn(it.paint_fill["fill-pattern"])})},get layout(){return wu=wu||new u({"fill-sort-key":new Bt(it.layout_fill["fill-sort-key"])})}};class ud extends s{constructor(e){super(e,cd)}recalculate(e,r){super.recalculate(e,r);const a=this.paint._values["fill-outline-color"];a.value.kind==="constant"&&a.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Sc(e)}queryRadius(){return yl(this.paint.get("fill-translate"))}queryIntersectsFeature(e,r,a,l,h,d,f){return au(xl(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),d.angle,f),l)}isTileClipped(){return!0}}const hd=m([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),dd=m([{name:"a_centroid",components:2,type:"Int16"}],4),{members:pd}=hd;var js={},fd=Hi,Su=mn;function mn(i,e,r,a,l){this.properties={},this.extent=r,this.type=0,this._pbf=i,this._geometry=-1,this._keys=a,this._values=l,i.readFields(md,this,e)}function md(i,e,r){i==1?e.id=r.readVarint():i==2?(function(a,l){for(var h=a.readVarint()+a.pos;a.pos<h;){var d=l._keys[a.readVarint()],f=l._values[a.readVarint()];l.properties[d]=f}})(r,e):i==3?e.type=r.readVarint():i==4&&(e._geometry=r.pos)}function _d(i){for(var e,r,a=0,l=0,h=i.length,d=h-1;l<h;d=l++)a+=((r=i[d]).x-(e=i[l]).x)*(e.y+r.y);return a}mn.types=["Unknown","Point","LineString","Polygon"],mn.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var e,r=i.readVarint()+i.pos,a=1,l=0,h=0,d=0,f=[];i.pos<r;){if(l<=0){var _=i.readVarint();a=7&_,l=_>>3}if(l--,a===1||a===2)h+=i.readSVarint(),d+=i.readSVarint(),a===1&&(e&&f.push(e),e=[]),e.push(new fd(h,d));else{if(a!==7)throw new Error("unknown command "+a);e&&e.push(e[0].clone())}}return e&&f.push(e),f},mn.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var e=i.readVarint()+i.pos,r=1,a=0,l=0,h=0,d=1/0,f=-1/0,_=1/0,x=-1/0;i.pos<e;){if(a<=0){var v=i.readVarint();r=7&v,a=v>>3}if(a--,r===1||r===2)(l+=i.readSVarint())<d&&(d=l),l>f&&(f=l),(h+=i.readSVarint())<_&&(_=h),h>x&&(x=h);else if(r!==7)throw new Error("unknown command "+r)}return[d,_,f,x]},mn.prototype.toGeoJSON=function(i,e,r){var a,l,h=this.extent*Math.pow(2,r),d=this.extent*i,f=this.extent*e,_=this.loadGeometry(),x=mn.types[this.type];function v(E){for(var C=0;C<E.length;C++){var P=E[C];E[C]=[360*(P.x+d)/h-180,360/Math.PI*Math.atan(Math.exp((180-360*(P.y+f)/h)*Math.PI/180))-90]}}switch(this.type){case 1:var w=[];for(a=0;a<_.length;a++)w[a]=_[a][0];v(_=w);break;case 2:for(a=0;a<_.length;a++)v(_[a]);break;case 3:for(_=(function(E){var C=E.length;if(C<=1)return[E];for(var P,L,U=[],Q=0;Q<C;Q++){var X=_d(E[Q]);X!==0&&(L===void 0&&(L=X<0),L===X<0?(P&&U.push(P),P=[E[Q]]):P.push(E[Q]))}return P&&U.push(P),U})(_),a=0;a<_.length;a++)for(l=0;l<_[a].length;l++)v(_[a][l])}_.length===1?_=_[0]:x="Multi"+x;var I={type:"Feature",geometry:{type:x,coordinates:_},properties:this.properties};return"id"in this&&(I.id=this.id),I};var gd=Su,Iu=ku;function ku(i,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=i,this._keys=[],this._values=[],this._features=[],i.readFields(yd,this,e),this.length=this._features.length}function yd(i,e,r){i===15?e.version=r.readVarint():i===1?e.name=r.readString():i===5?e.extent=r.readVarint():i===2?e._features.push(r.pos):i===3?e._keys.push(r.readString()):i===4&&e._values.push((function(a){for(var l=null,h=a.readVarint()+a.pos;a.pos<h;){var d=a.readVarint()>>3;l=d===1?a.readString():d===2?a.readFloat():d===3?a.readDouble():d===4?a.readVarint64():d===5?a.readVarint():d===6?a.readSVarint():d===7?a.readBoolean():null}return l})(r))}ku.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 e=this._pbf.readVarint()+this._pbf.pos;return new gd(this._pbf,e,this.extent,this._keys,this._values)};var xd=Iu;function vd(i,e,r){if(i===3){var a=new xd(r,r.readVarint()+r.pos);a.length&&(e[a.name]=a)}}js.VectorTile=function(i,e){this.layers=i.readFields(vd,{},e)},js.VectorTileFeature=Su,js.VectorTileLayer=Iu;const bd=js.VectorTileFeature.types,Ic=Math.pow(2,13);function To(i,e,r,a,l,h,d,f){i.emplaceBack(e,r,2*Math.floor(a*Ic)+d,l*Ic*2,h*Ic*2,Math.round(f))}class kc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Rs,this.centroidVertexArray=new je,this.indexArray=new $i,this.programConfigurations=new xa(e.layers,e.zoom),this.segments=new Wt,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){this.features=[],this.hasPattern=wc("fill-extrusion",this.layers,r);for(const{feature:l,id:h,index:d,sourceLayerIndex:f}of e){const _=this.layers[0]._featureFilter.needGeometry,x=ba(l,_);if(!this.layers[0]._featureFilter.filter(new de(this.zoom),x,a))continue;const v={id:h,sourceLayerIndex:f,index:d,geometry:_?x.geometry:va(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(Tc("fill-extrusion",this.layers,v,this.zoom,r)):this.addFeature(v,v.geometry,d,a,{}),r.featureIndex.insert(l,v.geometry,d,f,this.index,!0)}}addFeatures(e,r,a){for(const l of this.features){const{geometry:h}=l;this.addFeature(l,h,l.index,r,a)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,pd),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,dd.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,r,a,l,h){for(const d of La(r,500)){const f={x:0,y:0,vertexCount:0};let _=0;for(const C of d)_+=C.length;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const C of d){if(C.length===0||Td(C))continue;let P=0;for(let L=0;L<C.length;L++){const U=C[L];if(L>=1){const Q=C[L-1];if(!wd(U,Q)){x.vertexLength+4>Wt.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const X=U.sub(Q)._perp()._unit(),J=Q.dist(U);P+J>32768&&(P=0),To(this.layoutVertexArray,U.x,U.y,X.x,X.y,0,0,P),To(this.layoutVertexArray,U.x,U.y,X.x,X.y,0,1,P),f.x+=2*U.x,f.y+=2*U.y,f.vertexCount+=2,P+=J,To(this.layoutVertexArray,Q.x,Q.y,X.x,X.y,0,0,P),To(this.layoutVertexArray,Q.x,Q.y,X.x,X.y,0,1,P),f.x+=2*Q.x,f.y+=2*Q.y,f.vertexCount+=2;const rt=x.vertexLength;this.indexArray.emplaceBack(rt,rt+2,rt+1),this.indexArray.emplaceBack(rt+1,rt+2,rt+3),x.vertexLength+=4,x.primitiveLength+=2}}}}if(x.vertexLength+_>Wt.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(_,this.layoutVertexArray,this.indexArray)),bd[e.type]!=="Polygon")continue;const v=[],w=[],I=x.vertexLength;for(const C of d)if(C.length!==0){C!==d[0]&&w.push(v.length/2);for(let P=0;P<C.length;P++){const L=C[P];To(this.layoutVertexArray,L.x,L.y,0,0,1,1,0),f.x+=L.x,f.y+=L.y,f.vertexCount+=1,v.push(L.x),v.push(L.y)}}const E=gu(v,w);for(let C=0;C<E.length;C+=3)this.indexArray.emplaceBack(I+E[C],I+E[C+2],I+E[C+1]);x.primitiveLength+=E.length/3,x.vertexLength+=_;for(let C=0;C<f.vertexCount;C++){const P=Math.floor(f.x/f.vertexCount),L=Math.floor(f.y/f.vertexCount);this.centroidVertexArray.emplaceBack(P,L)}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,h,l)}}function wd(i,e){return i.x===e.x&&(i.x<0||i.x>Ee)||i.y===e.y&&(i.y<0||i.y>Ee)}function Td(i){return i.every((e=>e.x<0))||i.every((e=>e.x>Ee))||i.every((e=>e.y<0))||i.every((e=>e.y>Ee))}let Mu;It("FillExtrusionBucket",kc,{omit:["layers","features"]});var Sd={get paint(){return Mu=Mu||new u({"fill-extrusion-opacity":new Mt(it["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Bt(it["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Mt(it["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Mt(it["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new sn(it["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Bt(it["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Bt(it["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Mt(it["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Id extends s{constructor(e){super(e,Sd)}createBucket(e){return new kc(e)}queryRadius(){return yl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(e,r,a,l,h,d,f,_){const x=xl(e,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,a),w=this.paint.get("fill-extrusion-base").evaluate(r,a),I=(function(C,P,L,U){const Q=[];for(const X of C){const J=[X.x,X.y,0,1];vl(J,J,P),Q.push(new mt(J[0]/J[3],J[1]/J[3]))}return Q})(x,_),E=(function(C,P,L,U){const Q=[],X=[],J=U[8]*P,rt=U[9]*P,ct=U[10]*P,wt=U[11]*P,Rt=U[8]*L,vt=U[9]*L,yt=U[10]*L,Ct=U[11]*L;for(const kt of C){const St=[],nt=[];for(const Pt of kt){const zt=Pt.x,Ot=Pt.y,ce=U[0]*zt+U[4]*Ot+U[12],le=U[1]*zt+U[5]*Ot+U[13],Pe=U[2]*zt+U[6]*Ot+U[14],lr=U[3]*zt+U[7]*Ot+U[15],Ne=Pe+ct,Ae=lr+wt,ni=ce+Rt,oi=le+vt,li=Pe+yt,Te=lr+Ct,De=new mt((ce+J)/Ae,(le+rt)/Ae);De.z=Ne/Ae,St.push(De);const Ye=new mt(ni/Te,oi/Te);Ye.z=li/Te,nt.push(Ye)}Q.push(St),X.push(nt)}return[Q,X]})(l,w,v,_);return(function(C,P,L){let U=1/0;au(L,P)&&(U=Eu(L,P[0]));for(let Q=0;Q<P.length;Q++){const X=P[Q],J=C[Q];for(let rt=0;rt<X.length-1;rt++){const ct=X[rt],wt=[ct,X[rt+1],J[rt+1],J[rt],ct];su(L,wt)&&(U=Math.min(U,Eu(L,wt)))}}return U!==1/0&&U})(E[0],E[1],I)}}function So(i,e){return i.x*e.x+i.y*e.y}function Eu(i,e){if(i.length===1){let r=0;const a=e[r++];let l;for(;!l||a.equals(l);)if(l=e[r++],!l)return 1/0;for(;r<e.length;r++){const h=e[r],d=i[0],f=l.sub(a),_=h.sub(a),x=d.sub(a),v=So(f,f),w=So(f,_),I=So(_,_),E=So(x,f),C=So(x,_),P=v*I-w*w,L=(I*E-w*C)/P,U=(v*C-w*E)/P,Q=a.z*(1-L-U)+l.z*L+h.z*U;if(isFinite(Q))return Q}return 1/0}{let r=1/0;for(const a of e)r=Math.min(r,a.z);return r}}const kd=m([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:Md}=kd,Ed=m([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:zd}=Ed,Cd=js.VectorTileFeature.types,Pd=Math.cos(Math.PI/180*37.5),zu=Math.pow(2,14)/.5;class Mc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((r=>{this.gradients[r.id]={}})),this.layoutVertexArray=new nn,this.layoutVertexArray2=new Bs,this.indexArray=new $i,this.programConfigurations=new xa(e.layers,e.zoom),this.segments=new Wt,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){this.hasPattern=wc("line",this.layers,r);const l=this.layers[0].layout.get("line-sort-key"),h=!l.isConstant(),d=[];for(const{feature:f,id:_,index:x,sourceLayerIndex:v}of e){const w=this.layers[0]._featureFilter.needGeometry,I=ba(f,w);if(!this.layers[0]._featureFilter.filter(new de(this.zoom),I,a))continue;const E=h?l.evaluate(I,{},a):void 0,C={id:_,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?I.geometry:va(f),patterns:{},sortKey:E};d.push(C)}h&&d.sort(((f,_)=>f.sortKey-_.sortKey));for(const f of d){const{geometry:_,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){const w=Tc("line",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,_,x,a,{});r.featureIndex.insert(e[x].feature,_,x,v,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,zd)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Md),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,a,l,h){const d=this.layers[0].layout,f=d.get("line-join").evaluate(e,{}),_=d.get("line-cap"),x=d.get("line-miter-limit"),v=d.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const w of r)this.addLine(w,e,f,_,x,v);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,h,l)}addLine(e,r,a,l,h,d){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let U=0;U<e.length-1;U++)this.totalDistance+=e[U].dist(e[U+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const f=Cd[r.type]==="Polygon";let _=e.length;for(;_>=2&&e[_-1].equals(e[_-2]);)_--;let x=0;for(;x<_-1&&e[x].equals(e[x+1]);)x++;if(_<(f?3:2))return;a==="bevel"&&(h=1.05);const v=this.overscaling<=16?15*Ee/(512*this.overscaling):0,w=this.segments.prepareSegment(10*_,this.layoutVertexArray,this.indexArray);let I,E,C,P,L;this.e1=this.e2=-1,f&&(I=e[_-2],L=e[x].sub(I)._unit()._perp());for(let U=x;U<_;U++){if(C=U===_-1?f?e[x+1]:void 0:e[U+1],C&&e[U].equals(C))continue;L&&(P=L),I&&(E=I),I=e[U],L=C?C.sub(I)._unit()._perp():P,P=P||L;let Q=P.add(L);Q.x===0&&Q.y===0||Q._unit();const X=P.x*L.x+P.y*L.y,J=Q.x*L.x+Q.y*L.y,rt=J!==0?1/J:1/0,ct=2*Math.sqrt(2-2*J),wt=J<Pd&&E&&C,Rt=P.x*L.y-P.y*L.x>0;if(wt&&U>x){const Ct=I.dist(E);if(Ct>2*v){const kt=I.sub(I.sub(E)._mult(v/Ct)._round());this.updateDistance(E,kt),this.addCurrentVertex(kt,P,0,0,w),E=kt}}const vt=E&&C;let yt=vt?a:f?"butt":l;if(vt&&yt==="round"&&(rt<d?yt="miter":rt<=2&&(yt="fakeround")),yt==="miter"&&rt>h&&(yt="bevel"),yt==="bevel"&&(rt>2&&(yt="flipbevel"),rt<h&&(yt="miter")),E&&this.updateDistance(E,I),yt==="miter")Q._mult(rt),this.addCurrentVertex(I,Q,0,0,w);else if(yt==="flipbevel"){if(rt>100)Q=L.mult(-1);else{const Ct=rt*P.add(L).mag()/P.sub(L).mag();Q._perp()._mult(Ct*(Rt?-1:1))}this.addCurrentVertex(I,Q,0,0,w),this.addCurrentVertex(I,Q.mult(-1),0,0,w)}else if(yt==="bevel"||yt==="fakeround"){const Ct=-Math.sqrt(rt*rt-1),kt=Rt?Ct:0,St=Rt?0:Ct;if(E&&this.addCurrentVertex(I,P,kt,St,w),yt==="fakeround"){const nt=Math.round(180*ct/Math.PI/20);for(let Pt=1;Pt<nt;Pt++){let zt=Pt/nt;if(zt!==.5){const ce=zt-.5;zt+=zt*ce*(zt-1)*((1.0904+X*(X*(3.55645-1.43519*X)-3.2452))*ce*ce+(.848013+X*(.215638*X-1.06021)))}const Ot=L.sub(P)._mult(zt)._add(P)._unit()._mult(Rt?-1:1);this.addHalfVertex(I,Ot.x,Ot.y,!1,Rt,0,w)}}C&&this.addCurrentVertex(I,L,-kt,-St,w)}else if(yt==="butt")this.addCurrentVertex(I,Q,0,0,w);else if(yt==="square"){const Ct=E?1:-1;this.addCurrentVertex(I,Q,Ct,Ct,w)}else yt==="round"&&(E&&(this.addCurrentVertex(I,P,0,0,w),this.addCurrentVertex(I,P,1,1,w,!0)),C&&(this.addCurrentVertex(I,L,-1,-1,w,!0),this.addCurrentVertex(I,L,0,0,w)));if(wt&&U<_-1){const Ct=I.dist(C);if(Ct>2*v){const kt=I.add(C.sub(I)._mult(v/Ct)._round());this.updateDistance(I,kt),this.addCurrentVertex(kt,L,0,0,w),I=kt}}}}addCurrentVertex(e,r,a,l,h,d=!1){const f=r.y*l-r.x,_=-r.y-r.x*l;this.addHalfVertex(e,r.x+r.y*a,r.y-r.x*a,d,!1,a,h),this.addHalfVertex(e,f,_,d,!0,-l,h),this.distance>zu/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,r,a,l,h,d))}addHalfVertex({x:e,y:r},a,l,h,d,f,_){const x=.5*(this.lineClips?this.scaledDistance*(zu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(h?1:0),(r<<1)+(d?1:0),Math.round(63*a)+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=_.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,v),_.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(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}}let Cu,Pu;It("LineBucket",Mc,{omit:["layers","patternFeatures"]});var Au={get paint(){return Pu=Pu||new u({"line-opacity":new Bt(it.paint_line["line-opacity"]),"line-color":new Bt(it.paint_line["line-color"]),"line-translate":new Mt(it.paint_line["line-translate"]),"line-translate-anchor":new Mt(it.paint_line["line-translate-anchor"]),"line-width":new Bt(it.paint_line["line-width"]),"line-gap-width":new Bt(it.paint_line["line-gap-width"]),"line-offset":new Bt(it.paint_line["line-offset"]),"line-blur":new Bt(it.paint_line["line-blur"]),"line-dasharray":new an(it.paint_line["line-dasharray"]),"line-pattern":new sn(it.paint_line["line-pattern"]),"line-gradient":new fo(it.paint_line["line-gradient"])})},get layout(){return Cu=Cu||new u({"line-cap":new Mt(it.layout_line["line-cap"]),"line-join":new Bt(it.layout_line["line-join"]),"line-miter-limit":new Mt(it.layout_line["line-miter-limit"]),"line-round-limit":new Mt(it.layout_line["line-round-limit"]),"line-sort-key":new Bt(it.layout_line["line-sort-key"])})}};class Ad extends Bt{possiblyEvaluate(e,r){return r=new de(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(e,r)}evaluate(e,r,a,l){return r=vi({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(e,r,a,l)}}let Sl;class Dd extends s{constructor(e){super(e,Au),this.gradientVersion=0,Sl||(Sl=new Ad(Au.paint.properties["line-width"].specification),Sl.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){const r=this.gradientExpression();this.stepInterpolant=!!(function(a){return a._styleExpression!==void 0})(r)&&r._styleExpression.expression instanceof ms,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,r){super.recalculate(e,r),this.paint._values["line-floorwidth"]=Sl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Mc(e)}queryRadius(e){const r=e,a=Du(go("line-width",this,r),go("line-gap-width",this,r)),l=go("line-offset",this,r);return a/2+Math.abs(l)+yl(this.paint.get("line-translate"))}queryIntersectsFeature(e,r,a,l,h,d,f){const _=xl(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),d.angle,f),x=f/2*Du(this.paint.get("line-width").evaluate(r,a),this.paint.get("line-gap-width").evaluate(r,a)),v=this.paint.get("line-offset").evaluate(r,a);return v&&(l=(function(w,I){const E=[];for(let C=0;C<w.length;C++){const P=w[C],L=[];for(let U=0;U<P.length;U++){const Q=P[U-1],X=P[U],J=P[U+1],rt=U===0?new mt(0,0):X.sub(Q)._unit()._perp(),ct=U===P.length-1?new mt(0,0):J.sub(X)._unit()._perp(),wt=rt._add(ct)._unit(),Rt=wt.x*ct.x+wt.y*ct.y;Rt!==0&&wt._mult(1/Rt),L.push(wt._mult(I)._add(X))}E.push(L)}return E})(l,v*f)),(function(w,I,E){for(let C=0;C<I.length;C++){const P=I[C];if(w.length>=3){for(let L=0;L<P.length;L++)if(dn(w,P[L]))return!0}if($h(w,P,E))return!0}return!1})(_,l,x)}isTileClipped(){return!0}}function Du(i,e){return e>0?e+2*i:i}const Rd=m([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Bd=m([{name:"a_projected_pos",components:3,type:"Float32"}],4);m([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Fd=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 Ru=m([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ld=m([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Od(i,e,r){return i.sections.forEach((a=>{a.text=(function(l,h,d){const f=h.layout.get("text-transform").evaluate(d,{});return f==="uppercase"?l=l.toLocaleUpperCase():f==="lowercase"&&(l=l.toLocaleLowerCase()),_i.applyArabicShaping&&(l=_i.applyArabicShaping(l)),l})(a.text,e,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 Io={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var ze=24,Bu=oe,Fu=function(i,e,r,a,l){var h,d,f=8*l-a-1,_=(1<<f)-1,x=_>>1,v=-7,w=r?l-1:0,I=r?-1:1,E=i[e+w];for(w+=I,h=E&(1<<-v)-1,E>>=-v,v+=f;v>0;h=256*h+i[e+w],w+=I,v-=8);for(d=h&(1<<-v)-1,h>>=-v,v+=a;v>0;d=256*d+i[e+w],w+=I,v-=8);if(h===0)h=1-x;else{if(h===_)return d?NaN:1/0*(E?-1:1);d+=Math.pow(2,a),h-=x}return(E?-1:1)*d*Math.pow(2,h-a)},Lu=function(i,e,r,a,l,h){var d,f,_,x=8*h-l-1,v=(1<<x)-1,w=v>>1,I=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=a?0:h-1,C=a?1:-1,P=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(f=isNaN(e)?1:0,d=v):(d=Math.floor(Math.log(e)/Math.LN2),e*(_=Math.pow(2,-d))<1&&(d--,_*=2),(e+=d+w>=1?I/_:I*Math.pow(2,1-w))*_>=2&&(d++,_/=2),d+w>=v?(f=0,d=v):d+w>=1?(f=(e*_-1)*Math.pow(2,l),d+=w):(f=e*Math.pow(2,w-1)*Math.pow(2,l),d=0));l>=8;i[r+E]=255&f,E+=C,f/=256,l-=8);for(d=d<<l|f,x+=l;x>0;i[r+E]=255&d,E+=C,d/=256,x-=8);i[r+E-C]|=128*P};function oe(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}oe.Varint=0,oe.Fixed64=1,oe.Bytes=2,oe.Fixed32=5;var Ec=4294967296,Ou=1/Ec,Vu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function ss(i){return i.type===oe.Bytes?i.readVarint()+i.pos:i.pos+1}function Vd(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function ju(i,e,r){var a=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(a);for(var l=r.pos-1;l>=i;l--)r.buf[l+a]=r.buf[l]}function jd(i,e){for(var r=0;r<i.length;r++)e.writeVarint(i[r])}function Ud(i,e){for(var r=0;r<i.length;r++)e.writeSVarint(i[r])}function $d(i,e){for(var r=0;r<i.length;r++)e.writeFloat(i[r])}function Nd(i,e){for(var r=0;r<i.length;r++)e.writeDouble(i[r])}function Zd(i,e){for(var r=0;r<i.length;r++)e.writeBoolean(i[r])}function qd(i,e){for(var r=0;r<i.length;r++)e.writeFixed32(i[r])}function Gd(i,e){for(var r=0;r<i.length;r++)e.writeSFixed32(i[r])}function Xd(i,e){for(var r=0;r<i.length;r++)e.writeFixed64(i[r])}function Hd(i,e){for(var r=0;r<i.length;r++)e.writeSFixed64(i[r])}function Il(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+16777216*i[e+3]}function _n(i,e,r){i[r]=e,i[r+1]=e>>>8,i[r+2]=e>>>16,i[r+3]=e>>>24}function Uu(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+(i[e+3]<<24)}oe.prototype={destroy:function(){this.buf=null},readFields:function(i,e,r){for(r=r||this.length;this.pos<r;){var a=this.readVarint(),l=a>>3,h=this.pos;this.type=7&a,i(l,e,this),this.pos===h&&this.skip(a)}return e},readMessage:function(i,e){return this.readFields(i,e,this.readVarint()+this.pos)},readFixed32:function(){var i=Il(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=Uu(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=Il(this.buf,this.pos)+Il(this.buf,this.pos+4)*Ec;return this.pos+=8,i},readSFixed64:function(){var i=Il(this.buf,this.pos)+Uu(this.buf,this.pos+4)*Ec;return this.pos+=8,i},readFloat:function(){var i=Fu(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=Fu(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var e,r,a=this.buf;return e=127&(r=a[this.pos++]),r<128?e:(e|=(127&(r=a[this.pos++]))<<7,r<128?e:(e|=(127&(r=a[this.pos++]))<<14,r<128?e:(e|=(127&(r=a[this.pos++]))<<21,r<128?e:(function(l,h,d){var f,_,x=d.buf;if(f=(112&(_=x[d.pos++]))>>4,_<128||(f|=(127&(_=x[d.pos++]))<<3,_<128)||(f|=(127&(_=x[d.pos++]))<<10,_<128)||(f|=(127&(_=x[d.pos++]))<<17,_<128)||(f|=(127&(_=x[d.pos++]))<<24,_<128)||(f|=(1&(_=x[d.pos++]))<<31,_<128))return Vd(l,f,h);throw new Error("Expected varint not more than 10 bytes")})(e|=(15&(r=a[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,e=this.pos;return this.pos=i,i-e>=12&&Vu?(function(r,a,l){return Vu.decode(r.subarray(a,l))})(this.buf,e,i):(function(r,a,l){for(var h="",d=a;d<l;){var f,_,x,v=r[d],w=null,I=v>239?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?(_=r[d+2],(192&(f=r[d+1]))==128&&(192&_)==128&&((w=(15&v)<<12|(63&f)<<6|63&_)<=2047||w>=55296&&w<=57343)&&(w=null)):I===4&&(_=r[d+2],x=r[d+3],(192&(f=r[d+1]))==128&&(192&_)==128&&(192&x)==128&&((w=(15&v)<<18|(63&f)<<12|(63&_)<<6|63&x)<=65535||w>=1114112)&&(w=null)),w===null?(w=65533,I=1):w>65535&&(w-=65536,h+=String.fromCharCode(w>>>10&1023|55296),w=56320|1023&w),h+=String.fromCharCode(w),d+=I}return h})(this.buf,e,i)},readBytes:function(){var i=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,i);return this.pos=i,e},readPackedVarint:function(i,e){if(this.type!==oe.Bytes)return i.push(this.readVarint(e));var r=ss(this);for(i=i||[];this.pos<r;)i.push(this.readVarint(e));return i},readPackedSVarint:function(i){if(this.type!==oe.Bytes)return i.push(this.readSVarint());var e=ss(this);for(i=i||[];this.pos<e;)i.push(this.readSVarint());return i},readPackedBoolean:function(i){if(this.type!==oe.Bytes)return i.push(this.readBoolean());var e=ss(this);for(i=i||[];this.pos<e;)i.push(this.readBoolean());return i},readPackedFloat:function(i){if(this.type!==oe.Bytes)return i.push(this.readFloat());var e=ss(this);for(i=i||[];this.pos<e;)i.push(this.readFloat());return i},readPackedDouble:function(i){if(this.type!==oe.Bytes)return i.push(this.readDouble());var e=ss(this);for(i=i||[];this.pos<e;)i.push(this.readDouble());return i},readPackedFixed32:function(i){if(this.type!==oe.Bytes)return i.push(this.readFixed32());var e=ss(this);for(i=i||[];this.pos<e;)i.push(this.readFixed32());return i},readPackedSFixed32:function(i){if(this.type!==oe.Bytes)return i.push(this.readSFixed32());var e=ss(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed32());return i},readPackedFixed64:function(i){if(this.type!==oe.Bytes)return i.push(this.readFixed64());var e=ss(this);for(i=i||[];this.pos<e;)i.push(this.readFixed64());return i},readPackedSFixed64:function(i){if(this.type!==oe.Bytes)return i.push(this.readSFixed64());var e=ss(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed64());return i},skip:function(i){var e=7&i;if(e===oe.Varint)for(;this.buf[this.pos++]>127;);else if(e===oe.Bytes)this.pos=this.readVarint()+this.pos;else if(e===oe.Fixed32)this.pos+=4;else{if(e!==oe.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(i,e){this.writeVarint(i<<3|e)},realloc:function(i){for(var e=this.length||16;e<this.pos+i;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(i){this.realloc(4),_n(this.buf,i,this.pos),this.pos+=4},writeSFixed32:function(i){this.realloc(4),_n(this.buf,i,this.pos),this.pos+=4},writeFixed64:function(i){this.realloc(8),_n(this.buf,-1&i,this.pos),_n(this.buf,Math.floor(i*Ou),this.pos+4),this.pos+=8},writeSFixed64:function(i){this.realloc(8),_n(this.buf,-1&i,this.pos),_n(this.buf,Math.floor(i*Ou),this.pos+4),this.pos+=8},writeVarint:function(i){(i=+i||0)>268435455||i<0?(function(e,r){var a,l;if(e>=0?(a=e%4294967296|0,l=e/4294967296|0):(l=~(-e/4294967296),4294967295^(a=~(-e%4294967296))?a=a+1|0:(a=0,l=l+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),(function(h,d,f){f.buf[f.pos++]=127&h|128,h>>>=7,f.buf[f.pos++]=127&h|128,h>>>=7,f.buf[f.pos++]=127&h|128,h>>>=7,f.buf[f.pos++]=127&h|128,f.buf[f.pos]=127&(h>>>=7)})(a,0,r),(function(h,d){var f=(7&h)<<4;d.buf[d.pos++]|=f|((h>>>=3)?128:0),h&&(d.buf[d.pos++]=127&h|((h>>>=7)?128:0),h&&(d.buf[d.pos++]=127&h|((h>>>=7)?128:0),h&&(d.buf[d.pos++]=127&h|((h>>>=7)?128:0),h&&(d.buf[d.pos++]=127&h|((h>>>=7)?128:0),h&&(d.buf[d.pos++]=127&h)))))})(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 e=this.pos;this.pos=(function(a,l,h){for(var d,f,_=0;_<l.length;_++){if((d=l.charCodeAt(_))>55295&&d<57344){if(!f){d>56319||_+1===l.length?(a[h++]=239,a[h++]=191,a[h++]=189):f=d;continue}if(d<56320){a[h++]=239,a[h++]=191,a[h++]=189,f=d;continue}d=f-55296<<10|d-56320|65536,f=null}else f&&(a[h++]=239,a[h++]=191,a[h++]=189,f=null);d<128?a[h++]=d:(d<2048?a[h++]=d>>6|192:(d<65536?a[h++]=d>>12|224:(a[h++]=d>>18|240,a[h++]=d>>12&63|128),a[h++]=d>>6&63|128),a[h++]=63&d|128)}return h})(this.buf,i,this.pos);var r=this.pos-e;r>=128&&ju(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),Lu(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),Lu(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var e=i.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=i[r]},writeRawMessage:function(i,e){this.pos++;var r=this.pos;i(e,this);var a=this.pos-r;a>=128&&ju(r,a,this),this.pos=r-1,this.writeVarint(a),this.pos+=a},writeMessage:function(i,e,r){this.writeTag(i,oe.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(i,e){e.length&&this.writeMessage(i,jd,e)},writePackedSVarint:function(i,e){e.length&&this.writeMessage(i,Ud,e)},writePackedBoolean:function(i,e){e.length&&this.writeMessage(i,Zd,e)},writePackedFloat:function(i,e){e.length&&this.writeMessage(i,$d,e)},writePackedDouble:function(i,e){e.length&&this.writeMessage(i,Nd,e)},writePackedFixed32:function(i,e){e.length&&this.writeMessage(i,qd,e)},writePackedSFixed32:function(i,e){e.length&&this.writeMessage(i,Gd,e)},writePackedFixed64:function(i,e){e.length&&this.writeMessage(i,Xd,e)},writePackedSFixed64:function(i,e){e.length&&this.writeMessage(i,Hd,e)},writeBytesField:function(i,e){this.writeTag(i,oe.Bytes),this.writeBytes(e)},writeFixed32Field:function(i,e){this.writeTag(i,oe.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(i,e){this.writeTag(i,oe.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(i,e){this.writeTag(i,oe.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(i,e){this.writeTag(i,oe.Fixed64),this.writeSFixed64(e)},writeVarintField:function(i,e){this.writeTag(i,oe.Varint),this.writeVarint(e)},writeSVarintField:function(i,e){this.writeTag(i,oe.Varint),this.writeSVarint(e)},writeStringField:function(i,e){this.writeTag(i,oe.Bytes),this.writeString(e)},writeFloatField:function(i,e){this.writeTag(i,oe.Fixed32),this.writeFloat(e)},writeDoubleField:function(i,e){this.writeTag(i,oe.Fixed64),this.writeDouble(e)},writeBooleanField:function(i,e){this.writeVarintField(i,!!e)}};var zc=Pi(Bu);const Cc=3;function Wd(i,e,r){i===1&&r.readMessage(Kd,e)}function Kd(i,e,r){if(i===3){const{id:a,bitmap:l,width:h,height:d,left:f,top:_,advance:x}=r.readMessage(Jd,{});e.push({id:a,bitmap:new xo({width:h+2*Cc,height:d+2*Cc},l),metrics:{width:h,height:d,left:f,top:_,advance:x}})}}function Jd(i,e,r){i===1?e.id=r.readVarint():i===2?e.bitmap=r.readBytes():i===3?e.width=r.readVarint():i===4?e.height=r.readVarint():i===5?e.left=r.readSVarint():i===6?e.top=r.readSVarint():i===7&&(e.advance=r.readVarint())}const $u=Cc;function Nu(i){let e=0,r=0;for(const d of i)e+=d.w*d.h,r=Math.max(r,d.w);i.sort(((d,f)=>f.h-d.h));const a=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let l=0,h=0;for(const d of i)for(let f=a.length-1;f>=0;f--){const _=a[f];if(!(d.w>_.w||d.h>_.h)){if(d.x=_.x,d.y=_.y,h=Math.max(h,d.y+d.h),l=Math.max(l,d.x+d.w),d.w===_.w&&d.h===_.h){const x=a.pop();f<a.length&&(a[f]=x)}else d.h===_.h?(_.x+=d.w,_.w-=d.w):d.w===_.w?(_.y+=d.h,_.h-=d.h):(a.push({x:_.x+d.w,y:_.y,w:_.w-d.w,h:d.h}),_.y+=d.h,_.h-=d.h);break}}return{w:l,h,fill:e/(l*h)||0}}const yi=1;class Pc{constructor(e,{pixelRatio:r,version:a,stretchX:l,stretchY:h,content:d,textFitWidth:f,textFitHeight:_}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=l,this.stretchY=h,this.content=d,this.version=a,this.textFitWidth=f,this.textFitHeight=_}get tl(){return[this.paddedRect.x+yi,this.paddedRect.y+yi]}get br(){return[this.paddedRect.x+this.paddedRect.w-yi,this.paddedRect.y+this.paddedRect.h-yi]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2*yi)/this.pixelRatio,(this.paddedRect.h-2*yi)/this.pixelRatio]}}class Zu{constructor(e,r){const a={},l={};this.haveRenderCallbacks=[];const h=[];this.addImages(e,a,h),this.addImages(r,l,h);const{w:d,h:f}=Nu(h),_=new Ni({width:d||1,height:f||1});for(const x in e){const v=e[x],w=a[x].paddedRect;Ni.copy(v.data,_,{x:0,y:0},{x:w.x+yi,y:w.y+yi},v.data)}for(const x in r){const v=r[x],w=l[x].paddedRect,I=w.x+yi,E=w.y+yi,C=v.data.width,P=v.data.height;Ni.copy(v.data,_,{x:0,y:0},{x:I,y:E},v.data),Ni.copy(v.data,_,{x:0,y:P-1},{x:I,y:E-1},{width:C,height:1}),Ni.copy(v.data,_,{x:0,y:0},{x:I,y:E+P},{width:C,height:1}),Ni.copy(v.data,_,{x:C-1,y:0},{x:I-1,y:E},{width:1,height:P}),Ni.copy(v.data,_,{x:0,y:0},{x:I+C,y:E},{width:1,height:P})}this.image=_,this.iconPositions=a,this.patternPositions=l}addImages(e,r,a){for(const l in e){const h=e[l],d={x:0,y:0,w:h.data.width+2*yi,h:h.data.height+2*yi};a.push(d),r[l]=new Pc(d,h),h.hasRenderCallback&&this.haveRenderCallbacks.push(l)}}patchUpdatedImages(e,r){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const a in e.updatedImages)this.patchUpdatedImage(this.iconPositions[a],e.getImage(a),r),this.patchUpdatedImage(this.patternPositions[a],e.getImage(a),r)}patchUpdatedImage(e,r,a){if(!e||!r||e.version===r.version)return;e.version=r.version;const[l,h]=e.tl;a.update(r.data,void 0,{x:l,y:h})}}var Us;It("ImagePosition",Pc),It("ImageAtlas",Zu),R.ah=void 0,(Us=R.ah||(R.ah={}))[Us.none=0]="none",Us[Us.horizontal=1]="horizontal",Us[Us.vertical=2]="vertical",Us[Us.horizontalOnly=3]="horizontalOnly";const ko=-17;class Mo{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,r){const a=new Mo;return a.scale=e||1,a.fontStack=r,a}static forImage(e){const r=new Mo;return r.imageName=e,r}}class gn{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,r){const a=new gn;for(let l=0;l<e.sections.length;l++){const h=e.sections[l];h.image?a.addImageSection(h):a.addTextSection(h,r)}return a}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(){this.text=(function(e){let r="";for(let a=0;a<e.length;a++){const l=e.charCodeAt(a+1)||null,h=e.charCodeAt(a-1)||null;r+=l&&hl(l)&&!Io[e[a+1]]||h&&hl(h)&&!Io[e[a-1]]||!Io[e[a]]?e[a]:Io[e[a]]}return r})(this.text)}trim(){let e=0;for(let a=0;a<this.text.length&&Ml[this.text.charCodeAt(a)];a++)e++;let r=this.text.length;for(let a=this.text.length-1;a>=0&&a>=e&&Ml[this.text.charCodeAt(a)];a--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const a=new gn;return a.text=this.text.substring(e,r),a.sectionIndex=this.sectionIndex.slice(e,r),a.sections=this.sections,a}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,r)=>Math.max(e,this.sections[r].scale)),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(Mo.forText(e.scale,e.fontStack||r));const a=this.sections.length-1;for(let l=0;l<e.text.length;++l)this.sectionIndex.push(a)}addImageSection(e){const r=e.image?e.image.name:"";if(r.length===0)return void Le("Can't add FormattedSection with an empty image.");const a=this.getNextImageSectionCharCode();a?(this.text+=String.fromCharCode(a),this.sections.push(Mo.forImage(r)),this.sectionIndex.push(this.sections.length-1)):Le("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function kl(i,e,r,a,l,h,d,f,_,x,v,w,I,E,C){const P=gn.fromFeature(i,l);let L;w===R.ah.vertical&&P.verticalizePunctuation();const{processBidirectionalText:U,processStyledBidirectionalText:Q}=_i;if(U&&P.sections.length===1){L=[];const rt=U(P.toString(),Ac(P,x,h,e,a,E));for(const ct of rt){const wt=new gn;wt.text=ct,wt.sections=P.sections;for(let Rt=0;Rt<ct.length;Rt++)wt.sectionIndex.push(0);L.push(wt)}}else if(Q){L=[];const rt=Q(P.text,P.sectionIndex,Ac(P,x,h,e,a,E));for(const ct of rt){const wt=new gn;wt.text=ct[0],wt.sectionIndex=ct[1],wt.sections=P.sections,L.push(wt)}}else L=(function(rt,ct){const wt=[],Rt=rt.text;let vt=0;for(const yt of ct)wt.push(rt.substring(vt,yt)),vt=yt;return vt<Rt.length&&wt.push(rt.substring(vt,Rt.length)),wt})(P,Ac(P,x,h,e,a,E));const X=[],J={positionedLines:X,text:P.toString(),top:v[1],bottom:v[1],left:v[0],right:v[0],writingMode:w,iconsInText:!1,verticalizable:!1};return(function(rt,ct,wt,Rt,vt,yt,Ct,kt,St,nt,Pt,zt){let Ot=0,ce=ko,le=0,Pe=0;const lr=kt==="right"?1:kt==="left"?0:.5;let Ne=0;for(const Te of vt){Te.trim();const De=Te.getMaxScale(),Ye=(De-1)*ze,Ze={positionedGlyphs:[],lineOffset:0};rt.positionedLines[Ne]=Ze;const ci=Ze.positionedGlyphs;let qe=0;if(!Te.length()){ce+=yt,++Ne;continue}for(let xi=0;xi<Te.length();xi++){const Qt=Te.getSection(xi),he=Te.getSectionIndex(xi),_e=Te.getCharCode(xi);let zi=0,ve=null,bn=null,Rr=null,Br=ze;const cr=!(St===R.ah.horizontal||!Pt&&!ho(_e)||Pt&&(Ml[_e]||(Ae=_e,new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(Ae)))));if(Qt.imageName){const Gi=Rt[Qt.imageName];if(!Gi)continue;Rr=Qt.imageName,rt.iconsInText=rt.iconsInText||!0,bn=Gi.paddedRect;const Fe=Gi.displaySize;Qt.scale=Qt.scale*ze/zt,ve={width:Fe[0],height:Fe[1],left:yi,top:-$u,advance:cr?Fe[1]:Fe[0]},zi=Ye+(ze-Fe[1]*Qt.scale),Br=ve.advance;const as=cr?Fe[0]*Qt.scale-ze*De:Fe[1]*Qt.scale-ze*De;as>0&&as>qe&&(qe=as)}else{const Gi=wt[Qt.fontStack],Fe=Gi&&Gi[_e];if(Fe&&Fe.rect)bn=Fe.rect,ve=Fe.metrics;else{const as=ct[Qt.fontStack],Do=as&&as[_e];if(!Do)continue;ve=Do.metrics}zi=(De-Qt.scale)*ze}cr?(rt.verticalizable=!0,ci.push({glyph:_e,imageName:Rr,x:Ot,y:ce+zi,vertical:cr,scale:Qt.scale,fontStack:Qt.fontStack,sectionIndex:he,metrics:ve,rect:bn}),Ot+=Br*Qt.scale+nt):(ci.push({glyph:_e,imageName:Rr,x:Ot,y:ce+zi,vertical:cr,scale:Qt.scale,fontStack:Qt.fontStack,sectionIndex:he,metrics:ve,rect:bn}),Ot+=ve.advance*Qt.scale+nt)}ci.length!==0&&(le=Math.max(Ot-nt,le),ep(ci,0,ci.length-1,lr,qe)),Ot=0;const qi=yt*De+qe;Ze.lineOffset=Math.max(qe,Ye),ce+=qi,Pe=Math.max(qi,Pe),++Ne}var Ae;const ni=ce-ko,{horizontalAlign:oi,verticalAlign:li}=Dc(Ct);(function(Te,De,Ye,Ze,ci,qe,qi,xi,Qt){const he=(De-Ye)*ci;let _e=0;_e=qe!==qi?-xi*Ze-ko:(-Ze*Qt+.5)*qi;for(const zi of Te)for(const ve of zi.positionedGlyphs)ve.x+=he,ve.y+=_e})(rt.positionedLines,lr,oi,li,le,Pe,yt,ni,vt.length),rt.top+=-li*ni,rt.bottom=rt.top+ni,rt.left+=-oi*le,rt.right=rt.left+le})(J,e,r,a,L,d,f,_,w,x,I,C),!(function(rt){for(const ct of rt)if(ct.positionedGlyphs.length!==0)return!1;return!0})(X)&&J}const Ml={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Yd={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},Qd={40:!0};function qu(i,e,r,a,l,h){if(e.imageName){const d=a[e.imageName];return d?d.displaySize[0]*e.scale*ze/h+l:0}{const d=r[e.fontStack],f=d&&d[i];return f?f.metrics.advance*e.scale+l:0}}function Gu(i,e,r,a){const l=Math.pow(i-e,2);return a?i<e?l/2:2*l:l+Math.abs(r)*r}function tp(i,e,r){let a=0;return i===10&&(a-=1e4),r&&(a+=150),i!==40&&i!==65288||(a+=50),e!==41&&e!==65289||(a+=50),a}function Xu(i,e,r,a,l,h){let d=null,f=Gu(e,r,l,h);for(const _ of a){const x=Gu(e-_.x,r,l,h)+_.badness;x<=f&&(d=_,f=x)}return{index:i,x:e,priorBreak:d,badness:f}}function Hu(i){return i?Hu(i.priorBreak).concat(i.index):[]}function Ac(i,e,r,a,l,h){if(!i)return[];const d=[],f=(function(w,I,E,C,P,L){let U=0;for(let Q=0;Q<w.length();Q++){const X=w.getSection(Q);U+=qu(w.getCharCode(Q),X,C,P,I,L)}return U/Math.max(1,Math.ceil(U/E))})(i,e,r,a,l,h),_=i.text.indexOf("​")>=0;let x=0;for(let w=0;w<i.length();w++){const I=i.getSection(w),E=i.getCharCode(w);if(Ml[E]||(x+=qu(E,I,a,l,e,h)),w<i.length()-1){const C=!((v=E)<11904)&&(!!Ht["CJK Compatibility Forms"](v)||!!Ht["CJK Compatibility"](v)||!!Ht["CJK Strokes"](v)||!!Ht["CJK Symbols and Punctuation"](v)||!!Ht["Enclosed CJK Letters and Months"](v)||!!Ht["Halfwidth and Fullwidth Forms"](v)||!!Ht["Ideographic Description Characters"](v)||!!Ht["Vertical Forms"](v)||ul.test(String.fromCodePoint(v)));(Yd[E]||C||I.imageName||w!==i.length()-2&&Qd[i.getCharCode(w+1)])&&d.push(Xu(w+1,x,f,d,tp(E,i.getCharCode(w+1),C&&_),!1))}}var v;return Hu(Xu(i.length(),x,f,d,0,!0))}function Dc(i){let e=.5,r=.5;switch(i){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(i){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function ep(i,e,r,a,l){if(!a&&!l)return;const h=i[r],d=(i[r].x+h.metrics.advance*h.scale)*a;for(let f=e;f<=r;f++)i[f].x-=d,i[f].y+=l}function ip(i,e,r){const{horizontalAlign:a,verticalAlign:l}=Dc(r),h=e[0]-i.displaySize[0]*a,d=e[1]-i.displaySize[1]*l;return{image:i,top:d,bottom:d+i.displaySize[1],left:h,right:h+i.displaySize[0]}}function Wu(i){var e,r;let a=i.left,l=i.top,h=i.right-a,d=i.bottom-l;const f=(e=i.image.textFitWidth)!==null&&e!==void 0?e:"stretchOrShrink",_=(r=i.image.textFitHeight)!==null&&r!==void 0?r:"stretchOrShrink",x=(i.image.content[2]-i.image.content[0])/(i.image.content[3]-i.image.content[1]);if(_==="proportional"){if(f==="stretchOnly"&&h/d<x||f==="proportional"){const v=Math.ceil(d*x);a*=v/h,h=v}}else if(f==="proportional"&&_==="stretchOnly"&&x!==0&&h/d>x){const v=Math.ceil(h/x);l*=v/d,d=v}return{x1:a,y1:l,x2:a+h,y2:l+d}}function Ku(i,e,r,a,l,h){const d=i.image;let f;if(d.content){const L=d.content,U=d.pixelRatio||1;f=[L[0]/U,L[1]/U,d.displaySize[0]-L[2]/U,d.displaySize[1]-L[3]/U]}const _=e.left*h,x=e.right*h;let v,w,I,E;r==="width"||r==="both"?(E=l[0]+_-a[3],w=l[0]+x+a[1]):(E=l[0]+(_+x-d.displaySize[0])/2,w=E+d.displaySize[0]);const C=e.top*h,P=e.bottom*h;return r==="height"||r==="both"?(v=l[1]+C-a[0],I=l[1]+P+a[2]):(v=l[1]+(C+P-d.displaySize[1])/2,I=v+d.displaySize[1]),{image:d,top:v,right:w,bottom:I,left:E,collisionPadding:f}}const Eo=255,Dr=128,$s=Eo*Dr;function Ju(i,e){const{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new de(i+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:a,interpolationType:l}=r;let h=0;for(;h<a.length&&a[h]<=i;)h++;h=Math.max(0,h-1);let d=h;for(;d<a.length&&a[d]<i+1;)d++;d=Math.min(a.length-1,d);const f=a[h],_=a[d];return r.kind==="composite"?{kind:"composite",minZoom:f,maxZoom:_,interpolationType:l}:{kind:"camera",minZoom:f,maxZoom:_,minSize:r.evaluate(new de(f)),maxSize:r.evaluate(new de(_)),interpolationType:l}}}function Rc(i,e,r){let a="never";const l=i.get(e);return l?a=l:i.get(r)&&(a="always"),a}const rp=js.VectorTileFeature.types,sp=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function El(i,e,r,a,l,h,d,f,_,x,v,w,I){const E=f?Math.min($s,Math.round(f[0])):0,C=f?Math.min($s,Math.round(f[1])):0;i.emplaceBack(e,r,Math.round(32*a),Math.round(32*l),h,d,(E<<1)+(_?1:0),C,16*x,16*v,256*w,256*I)}function Bc(i,e,r){i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r)}function ap(i){for(const e of i.sections)if(cc(e.text))return!0;return!1}class Fc{constructor(e){this.layoutVertexArray=new on,this.indexArray=new $i,this.programConfigurations=e,this.segments=new Wt,this.dynamicLayoutVertexArray=new mo,this.opacityVertexArray=new Mi,this.hasVisibleVertices=!1,this.placedSymbolArray=new pe}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,r,a,l){this.isEmpty()||(a&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Rd.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Bd.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,sp,!0),this.opacityVertexBuffer.itemSize=1),(a||l)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}It("SymbolBuffers",Fc);class Lc{constructor(e,r,a){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new a,this.segments=new Wt,this.collisionVertexArray=new Pr}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Fd.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}It("CollisionBuffers",Lc);class yn{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((d=>d.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=_c([]),this.placementViewportMatrix=_c([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ju(this.zoom,r["text-size"]),this.iconSizeData=Ju(this.zoom,r["icon-size"]);const a=this.layers[0].layout,l=a.get("symbol-sort-key"),h=a.get("symbol-z-order");this.canOverlap=Rc(a,"text-overlap","text-allow-overlap")!=="never"||Rc(a,"icon-overlap","icon-allow-overlap")!=="never"||a.get("text-ignore-placement")||a.get("icon-ignore-placement"),this.sortFeaturesByKey=h!=="viewport-y"&&!l.isConstant(),this.sortFeaturesByY=(h==="viewport-y"||h==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,a.get("symbol-placement")==="point"&&(this.writingModes=a.get("text-writing-mode").map((d=>R.ah[d]))),this.stateDependentLayerIds=this.layers.filter((d=>d.isStateDependent())).map((d=>d.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Fc(new xa(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new Fc(new xa(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new fe,this.lineVertexArray=new Ve,this.symbolInstances=new Xt,this.textAnchorOffsets=new me}calculateGlyphDependencies(e,r,a,l,h){for(let d=0;d<e.length;d++)if(r[e.charCodeAt(d)]=!0,(a||l)&&h){const f=Io[e.charAt(d)];f&&(r[f.charCodeAt(0)]=!0)}}populate(e,r,a){const l=this.layers[0],h=l.layout,d=h.get("text-font"),f=h.get("text-field"),_=h.get("icon-image"),x=(f.value.kind!=="constant"||f.value.value instanceof di&&!f.value.value.isEmpty()||f.value.value.toString().length>0)&&(d.value.kind!=="constant"||d.value.value.length>0),v=_.value.kind!=="constant"||!!_.value.value||Object.keys(_.parameters).length>0,w=h.get("symbol-sort-key");if(this.features=[],!x&&!v)return;const I=r.iconDependencies,E=r.glyphDependencies,C=r.availableImages,P=new de(this.zoom);for(const{feature:L,id:U,index:Q,sourceLayerIndex:X}of e){const J=l._featureFilter.needGeometry,rt=ba(L,J);if(!l._featureFilter.filter(P,rt,a))continue;let ct,wt;if(J||(rt.geometry=va(L)),x){const vt=l.getValueAndResolveTokens("text-field",rt,a,C),yt=di.factory(vt),Ct=this.hasRTLText=this.hasRTLText||ap(yt);(!Ct||_i.getRTLTextPluginStatus()==="unavailable"||Ct&&_i.isParsed())&&(ct=Od(yt,l,rt))}if(v){const vt=l.getValueAndResolveTokens("icon-image",rt,a,C);wt=vt instanceof fi?vt:fi.fromString(vt)}if(!ct&&!wt)continue;const Rt=this.sortFeaturesByKey?w.evaluate(rt,{},a):void 0;if(this.features.push({id:U,text:ct,icon:wt,index:Q,sourceLayerIndex:X,geometry:rt.geometry,properties:L.properties,type:rp[L.type],sortKey:Rt}),wt&&(I[wt.name]=!0),ct){const vt=d.evaluate(rt,{},a).join(","),yt=h.get("text-rotation-alignment")!=="viewport"&&h.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(R.ah.vertical)>=0;for(const Ct of ct.sections)if(Ct.image)I[Ct.image.name]=!0;else{const kt=co(ct.toString()),St=Ct.fontStack||vt,nt=E[St]=E[St]||{};this.calculateGlyphDependencies(Ct.text,nt,yt,this.allowVerticalPlacement,kt)}}}h.get("symbol-placement")==="line"&&(this.features=(function(L){const U={},Q={},X=[];let J=0;function rt(vt){X.push(L[vt]),J++}function ct(vt,yt,Ct){const kt=Q[vt];return delete Q[vt],Q[yt]=kt,X[kt].geometry[0].pop(),X[kt].geometry[0]=X[kt].geometry[0].concat(Ct[0]),kt}function wt(vt,yt,Ct){const kt=U[yt];return delete U[yt],U[vt]=kt,X[kt].geometry[0].shift(),X[kt].geometry[0]=Ct[0].concat(X[kt].geometry[0]),kt}function Rt(vt,yt,Ct){const kt=Ct?yt[0][yt[0].length-1]:yt[0][0];return`${vt}:${kt.x}:${kt.y}`}for(let vt=0;vt<L.length;vt++){const yt=L[vt],Ct=yt.geometry,kt=yt.text?yt.text.toString():null;if(!kt){rt(vt);continue}const St=Rt(kt,Ct),nt=Rt(kt,Ct,!0);if(St in Q&&nt in U&&Q[St]!==U[nt]){const Pt=wt(St,nt,Ct),zt=ct(St,nt,X[Pt].geometry);delete U[St],delete Q[nt],Q[Rt(kt,X[zt].geometry,!0)]=zt,X[Pt].geometry=null}else St in Q?ct(St,nt,Ct):nt in U?wt(St,nt,Ct):(rt(vt),U[St]=J-1,Q[nt]=J-1)}return X.filter((vt=>vt.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((L,U)=>L.sortKey-U.sortKey))}update(e,r,a){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,a),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,a))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const a=this.lineVertexArray.length;if(e.segment!==void 0){let l=e.dist(r[e.segment+1]),h=e.dist(r[e.segment]);const d={};for(let f=e.segment+1;f<r.length;f++)d[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:l},f<r.length-1&&(l+=r[f+1].dist(r[f]));for(let f=e.segment||0;f>=0;f--)d[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:h},f>0&&(h+=r[f-1].dist(r[f]));for(let f=0;f<r.length;f++){const _=d[f];this.lineVertexArray.emplaceBack(_.x,_.y,_.tileUnitDistanceFromAnchor)}}return{lineStartIndex:a,lineLength:this.lineVertexArray.length-a}}addSymbols(e,r,a,l,h,d,f,_,x,v,w,I){const E=e.indexArray,C=e.layoutVertexArray,P=e.segments.prepareSegment(4*r.length,C,E,this.canOverlap?d.sortKey:void 0),L=this.glyphOffsetArray.length,U=P.vertexLength,Q=this.allowVerticalPlacement&&f===R.ah.vertical?Math.PI/2:0,X=d.text&&d.text.sections;for(let J=0;J<r.length;J++){const{tl:rt,tr:ct,bl:wt,br:Rt,tex:vt,pixelOffsetTL:yt,pixelOffsetBR:Ct,minFontScaleX:kt,minFontScaleY:St,glyphOffset:nt,isSDF:Pt,sectionIndex:zt}=r[J],Ot=P.vertexLength,ce=nt[1];El(C,_.x,_.y,rt.x,ce+rt.y,vt.x,vt.y,a,Pt,yt.x,yt.y,kt,St),El(C,_.x,_.y,ct.x,ce+ct.y,vt.x+vt.w,vt.y,a,Pt,Ct.x,yt.y,kt,St),El(C,_.x,_.y,wt.x,ce+wt.y,vt.x,vt.y+vt.h,a,Pt,yt.x,Ct.y,kt,St),El(C,_.x,_.y,Rt.x,ce+Rt.y,vt.x+vt.w,vt.y+vt.h,a,Pt,Ct.x,Ct.y,kt,St),Bc(e.dynamicLayoutVertexArray,_,Q),E.emplaceBack(Ot,Ot+1,Ot+2),E.emplaceBack(Ot+1,Ot+2,Ot+3),P.vertexLength+=4,P.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(nt[0]),J!==r.length-1&&zt===r[J+1].sectionIndex||e.programConfigurations.populatePaintArrays(C.length,d,d.index,{},I,X&&X[zt])}e.placedSymbolArray.emplaceBack(_.x,_.y,L,this.glyphOffsetArray.length-L,U,x,v,_.segment,a?a[0]:0,a?a[1]:0,l[0],l[1],f,0,!1,0,w)}_addCollisionDebugVertex(e,r,a,l,h,d){return r.emplaceBack(0,0),e.emplaceBack(a.x,a.y,l,h,Math.round(d.x),Math.round(d.y))}addCollisionDebugVertices(e,r,a,l,h,d,f){const _=h.segments.prepareSegment(4,h.layoutVertexArray,h.indexArray),x=_.vertexLength,v=h.layoutVertexArray,w=h.collisionVertexArray,I=f.anchorX,E=f.anchorY;this._addCollisionDebugVertex(v,w,d,I,E,new mt(e,r)),this._addCollisionDebugVertex(v,w,d,I,E,new mt(a,r)),this._addCollisionDebugVertex(v,w,d,I,E,new mt(a,l)),this._addCollisionDebugVertex(v,w,d,I,E,new mt(e,l)),_.vertexLength+=4;const C=h.indexArray;C.emplaceBack(x,x+1),C.emplaceBack(x+1,x+2),C.emplaceBack(x+2,x+3),C.emplaceBack(x+3,x),_.primitiveLength+=4}addDebugCollisionBoxes(e,r,a,l){for(let h=e;h<r;h++){const d=this.collisionBoxArray.get(h);this.addCollisionDebugVertices(d.x1,d.y1,d.x2,d.y2,l?this.textCollisionBox:this.iconCollisionBox,d.anchorPoint,a)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Lc(Ei,Ru.members,Be),this.iconCollisionBox=new Lc(Ei,Ru.members,Be);for(let e=0;e<this.symbolInstances.length;e++){const r=this.symbolInstances.get(e);this.addDebugCollisionBoxes(r.textBoxStartIndex,r.textBoxEndIndex,r,!0),this.addDebugCollisionBoxes(r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r,!0),this.addDebugCollisionBoxes(r.iconBoxStartIndex,r.iconBoxEndIndex,r,!1),this.addDebugCollisionBoxes(r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex,r,!1)}}_deserializeCollisionBoxesForSymbol(e,r,a,l,h,d,f,_,x){const v={};for(let w=r;w<a;w++){const I=e.get(w);v.textBox={x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,anchorPointX:I.anchorPointX,anchorPointY:I.anchorPointY},v.textFeatureIndex=I.featureIndex;break}for(let w=l;w<h;w++){const I=e.get(w);v.verticalTextBox={x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,anchorPointX:I.anchorPointX,anchorPointY:I.anchorPointY},v.verticalTextFeatureIndex=I.featureIndex;break}for(let w=d;w<f;w++){const I=e.get(w);v.iconBox={x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,anchorPointX:I.anchorPointX,anchorPointY:I.anchorPointY},v.iconFeatureIndex=I.featureIndex;break}for(let w=_;w<x;w++){const I=e.get(w);v.verticalIconBox={x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,anchorPointX:I.anchorPointX,anchorPointY:I.anchorPointY},v.verticalIconFeatureIndex=I.featureIndex;break}return v}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){const a=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,a.textBoxStartIndex,a.textBoxEndIndex,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a.iconBoxStartIndex,a.iconBoxEndIndex,a.verticalIconBoxStartIndex,a.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,r){const a=e.placedSymbolArray.get(r),l=a.vertexStartIndex+4*a.numGlyphs;for(let h=a.vertexStartIndex;h<l;h+=4)e.indexArray.emplaceBack(h,h+1,h+2),e.indexArray.emplaceBack(h+1,h+2,h+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const r=Math.sin(e),a=Math.cos(e),l=[],h=[],d=[];for(let f=0;f<this.symbolInstances.length;++f){d.push(f);const _=this.symbolInstances.get(f);l.push(0|Math.round(r*_.anchorX+a*_.anchorY)),h.push(_.featureIndex)}return d.sort(((f,_)=>l[f]-l[_]||h[_]-h[f])),d}addToSortKeyRanges(e,r){const a=this.sortKeyRanges[this.sortKeyRanges.length-1];a&&a.sortKey===r?a.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const r of this.symbolInstanceIndexes){const a=this.symbolInstances.get(r);this.featureSortOrder.push(a.featureIndex),[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex].forEach(((l,h,d)=>{l>=0&&d.indexOf(l)===h&&this.addIndicesForPlacedSymbol(this.text,l)})),a.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,a.verticalPlacedTextSymbolIndex),a.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.placedIconSymbolIndex),a.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Yu,Qu;It("SymbolBucket",yn,{omit:["layers","collisionBoxArray","features","compareText"]}),yn.MAX_GLYPHS=65535,yn.addDynamicAttributes=Bc;var Oc={get paint(){return Qu=Qu||new u({"icon-opacity":new Bt(it.paint_symbol["icon-opacity"]),"icon-color":new Bt(it.paint_symbol["icon-color"]),"icon-halo-color":new Bt(it.paint_symbol["icon-halo-color"]),"icon-halo-width":new Bt(it.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Bt(it.paint_symbol["icon-halo-blur"]),"icon-translate":new Mt(it.paint_symbol["icon-translate"]),"icon-translate-anchor":new Mt(it.paint_symbol["icon-translate-anchor"]),"text-opacity":new Bt(it.paint_symbol["text-opacity"]),"text-color":new Bt(it.paint_symbol["text-color"],{runtimeType:ei,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new Bt(it.paint_symbol["text-halo-color"]),"text-halo-width":new Bt(it.paint_symbol["text-halo-width"]),"text-halo-blur":new Bt(it.paint_symbol["text-halo-blur"]),"text-translate":new Mt(it.paint_symbol["text-translate"]),"text-translate-anchor":new Mt(it.paint_symbol["text-translate-anchor"])})},get layout(){return Yu=Yu||new u({"symbol-placement":new Mt(it.layout_symbol["symbol-placement"]),"symbol-spacing":new Mt(it.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Mt(it.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Bt(it.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Mt(it.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Mt(it.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Mt(it.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Mt(it.layout_symbol["icon-ignore-placement"]),"icon-optional":new Mt(it.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Mt(it.layout_symbol["icon-rotation-alignment"]),"icon-size":new Bt(it.layout_symbol["icon-size"]),"icon-text-fit":new Mt(it.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Mt(it.layout_symbol["icon-text-fit-padding"]),"icon-image":new Bt(it.layout_symbol["icon-image"]),"icon-rotate":new Bt(it.layout_symbol["icon-rotate"]),"icon-padding":new Bt(it.layout_symbol["icon-padding"]),"icon-keep-upright":new Mt(it.layout_symbol["icon-keep-upright"]),"icon-offset":new Bt(it.layout_symbol["icon-offset"]),"icon-anchor":new Bt(it.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Mt(it.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Mt(it.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Mt(it.layout_symbol["text-rotation-alignment"]),"text-field":new Bt(it.layout_symbol["text-field"]),"text-font":new Bt(it.layout_symbol["text-font"]),"text-size":new Bt(it.layout_symbol["text-size"]),"text-max-width":new Bt(it.layout_symbol["text-max-width"]),"text-line-height":new Mt(it.layout_symbol["text-line-height"]),"text-letter-spacing":new Bt(it.layout_symbol["text-letter-spacing"]),"text-justify":new Bt(it.layout_symbol["text-justify"]),"text-radial-offset":new Bt(it.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Mt(it.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Bt(it.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Bt(it.layout_symbol["text-anchor"]),"text-max-angle":new Mt(it.layout_symbol["text-max-angle"]),"text-writing-mode":new Mt(it.layout_symbol["text-writing-mode"]),"text-rotate":new Bt(it.layout_symbol["text-rotate"]),"text-padding":new Mt(it.layout_symbol["text-padding"]),"text-keep-upright":new Mt(it.layout_symbol["text-keep-upright"]),"text-transform":new Bt(it.layout_symbol["text-transform"]),"text-offset":new Bt(it.layout_symbol["text-offset"]),"text-allow-overlap":new Mt(it.layout_symbol["text-allow-overlap"]),"text-overlap":new Mt(it.layout_symbol["text-overlap"]),"text-ignore-placement":new Mt(it.layout_symbol["text-ignore-placement"]),"text-optional":new Mt(it.layout_symbol["text-optional"])})}};class th{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Mr,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}It("FormatSectionOverride",th,{omit:["defaultValue"]});class zl extends s{constructor(e){super(e,Oc)}recalculate(e,r){if(super.recalculate(e,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 a=this.layout.get("text-writing-mode");if(a){const l=[];for(const h of a)l.indexOf(h)<0&&l.push(h);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,a,l){const h=this.layout.get(e).evaluate(r,{},a,l),d=this._unevaluatedLayout._values[e];return d.isDataDriven()||qa(d.value)||!h?h:(function(f,_){return _.replace(/{([^{}]+)}/g,((x,v)=>f&&v in f?String(f[v]):""))})(r.properties,h)}createBucket(e){return new yn(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Oc.paint.overridableProperties){if(!zl.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),a=new th(r),l=new Za(a,r.property.specification);let h=null;h=r.value.kind==="constant"||r.value.kind==="source"?new Ss("source",l):new Is("composite",l,r.value.zoomStops),this.paint._values[e]=new nr(r.property,h,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,a){return!(!this.layout||r.isDataDriven()||a.isDataDriven())&&zl.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const a=e.get("text-field"),l=Oc.paint.properties[r];let h=!1;const d=f=>{for(const _ of f)if(l.overrides&&l.overrides.hasOverride(_))return void(h=!0)};if(a.value.kind==="constant"&&a.value.value instanceof di)d(a.value.value.sections);else if(a.value.kind==="source"){const f=x=>{h||(x instanceof Fi&&Me(x.value)===mr?d(x.value.sections):x instanceof Ba?d(x.sections):x.eachChild(f))},_=a.value;_._styleExpression&&f(_._styleExpression.expression)}return h}}let eh;var np={get paint(){return eh=eh||new u({"background-color":new Mt(it.paint_background["background-color"]),"background-pattern":new an(it.paint_background["background-pattern"]),"background-opacity":new Mt(it.paint_background["background-opacity"])})}};class op extends s{constructor(e){super(e,np)}}let ih;var lp={get paint(){return ih=ih||new u({"raster-opacity":new Mt(it.paint_raster["raster-opacity"]),"raster-hue-rotate":new Mt(it.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Mt(it.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Mt(it.paint_raster["raster-brightness-max"]),"raster-saturation":new Mt(it.paint_raster["raster-saturation"]),"raster-contrast":new Mt(it.paint_raster["raster-contrast"]),"raster-resampling":new Mt(it.paint_raster["raster-resampling"]),"raster-fade-duration":new Mt(it.paint_raster["raster-fade-duration"])})}};class cp extends s{constructor(e){super(e,lp)}}class up extends s{constructor(e){super(e,{}),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=e}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 hp{constructor(e){this._methodToThrottle=e,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 Vc=63710088e-1;class Ns{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Ns(Ki(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,a=this.lat*r,l=e.lat*r,h=Math.sin(a)*Math.sin(l)+Math.cos(a)*Math.cos(l)*Math.cos((e.lng-this.lng)*r);return Vc*Math.acos(Math.min(h,1))}static convert(e){if(e instanceof Ns)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Ns(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Ns(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const rh=2*Math.PI*Vc;function sh(i){return rh*Math.cos(i*Math.PI/180)}function ah(i){return(180+i)/360}function nh(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function oh(i,e){return i/sh(e)}function jc(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class zo{constructor(e,r,a=0){this.x=+e,this.y=+r,this.z=+a}static fromLngLat(e,r=0){const a=Ns.convert(e);return new zo(ah(a.lng),nh(a.lat),oh(r,a.lat))}toLngLat(){return new Ns(360*this.x-180,jc(this.y))}toAltitude(){return this.z*sh(jc(this.y))}meterInMercatorCoordinateUnits(){return 1/rh*(e=jc(this.y),1/Math.cos(e*Math.PI/180));var e}}function lh(i,e,r){var a=2*Math.PI*6378137/256/Math.pow(2,r);return[i*a-2*Math.PI*6378137/2,e*a-2*Math.PI*6378137/2]}class Uc{constructor(e,r,a){if(!(function(l,h,d){return!(l<0||l>25||d<0||d>=Math.pow(2,l)||h<0||h>=Math.pow(2,l))})(e,r,a))throw new Error(`x=${r}, y=${a}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=r,this.y=a,this.key=Co(0,e,e,r,a)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,a){const l=(d=this.y,f=this.z,_=lh(256*(h=this.x),256*(d=Math.pow(2,f)-d-1),f),x=lh(256*(h+1),256*(d+1),f),_[0]+","+_[1]+","+x[0]+","+x[1]);var h,d,f,_,x;const v=(function(w,I,E){let C,P="";for(let L=w;L>0;L--)C=1<<L-1,P+=(I&C?1:0)+(E&C?2:0);return P})(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(a==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,r>1?"@2x":"").replace(/{quadkey}/g,v).replace(/{bbox-epsg-3857}/g,l)}isChildOf(e){const r=this.z-e.z;return r>0&&e.x===this.x>>r&&e.y===this.y>>r}getTilePoint(e){const r=Math.pow(2,this.z);return new mt((e.x*r-this.x)*Ee,(e.y*r-this.y)*Ee)}toString(){return`${this.z}/${this.x}/${this.y}`}}class ch{constructor(e,r){this.wrap=e,this.canonical=r,this.key=Co(e,r.z,r.z,r.x,r.y)}}class Zi{constructor(e,r,a,l,h){if(e<a)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${a}`);this.overscaledZ=e,this.wrap=r,this.canonical=new Uc(a,+l,+h),this.key=Co(r,e,a,l,h)}clone(){return new Zi(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-e;return e>this.canonical.z?new Zi(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Zi(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const a=this.canonical.z-e;return e>this.canonical.z?Co(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):Co(this.wrap*+r,e,e,this.canonical.x>>a,this.canonical.y>>a)}isChildOf(e){if(e.wrap!==this.wrap)return!1;const r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new Zi(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,a=2*this.canonical.x,l=2*this.canonical.y;return[new Zi(r,this.wrap,r,a,l),new Zi(r,this.wrap,r,a+1,l),new Zi(r,this.wrap,r,a,l+1),new Zi(r,this.wrap,r,a+1,l+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Zi(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Zi(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new ch(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new zo(e.x-this.wrap,e.y))}}function Co(i,e,r,a,l){(i*=2)<0&&(i=-1*i-1);const h=1<<r;return(h*h*i+h*l+a).toString(36)+r.toString(36)+e.toString(36)}It("CanonicalTileID",Uc),It("OverscaledTileID",Zi,{omit:["posMatrix"]});class uh{constructor(e,r,a,l=1,h=1,d=1,f=0){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(a&&!["mapbox","terrarium","custom"].includes(a))return void Le(`"${a}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=r.height;const _=this.dim=r.height-2;switch(this.data=new Uint32Array(r.data.buffer),a){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=l,this.greenFactor=h,this.blueFactor=d,this.baseShift=f;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let x=0;x<_;x++)this.data[this._idx(-1,x)]=this.data[this._idx(0,x)],this.data[this._idx(_,x)]=this.data[this._idx(_-1,x)],this.data[this._idx(x,-1)]=this.data[this._idx(x,0)],this.data[this._idx(x,_)]=this.data[this._idx(x,_-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(_,-1)]=this.data[this._idx(_-1,0)],this.data[this._idx(-1,_)]=this.data[this._idx(0,_-1)],this.data[this._idx(_,_)]=this.data[this._idx(_-1,_-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let x=0;x<_;x++)for(let v=0;v<_;v++){const w=this.get(x,v);w>this.max&&(this.max=w),w<this.min&&(this.min=w)}}get(e,r){const a=new Uint8Array(this.data.buffer),l=4*this._idx(e,r);return this.unpack(a[l],a[l+1],a[l+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,r){if(e<-1||e>=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(e+1)}unpack(e,r,a){return e*this.redFactor+r*this.greenFactor+a*this.blueFactor-this.baseShift}getPixels(){return new Ni({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,a){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let l=r*this.dim,h=r*this.dim+this.dim,d=a*this.dim,f=a*this.dim+this.dim;switch(r){case-1:l=h-1;break;case 1:h=l+1}switch(a){case-1:d=f-1;break;case 1:f=d+1}const _=-r*this.dim,x=-a*this.dim;for(let v=d;v<f;v++)for(let w=l;w<h;w++)this.data[this._idx(w,v)]=e.data[this._idx(w+_,v+x)]}}It("DEMData",uh);class hh{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){const a=e[r];this._stringToNumber[a]=r,this._numberToString[r]=a}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class dh{constructor(e,r,a,l,h){this.type="Feature",this._vectorTileFeature=e,e._z=r,e._x=a,e._y=l,this.properties=e.properties,this.id=h}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(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(e[r]=this[r]);return e}}class ph{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new zs(Ee,16,0),this.grid3D=new zs(Ee,16,0),this.featureIndexArray=new Ke,this.promoteId=r}insert(e,r,a,l,h,d){const f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(a,l,h);const _=d?this.grid3D:this.grid;for(let x=0;x<r.length;x++){const v=r[x],w=[1/0,1/0,-1/0,-1/0];for(let I=0;I<v.length;I++){const E=v[I];w[0]=Math.min(w[0],E.x),w[1]=Math.min(w[1],E.y),w[2]=Math.max(w[2],E.x),w[3]=Math.max(w[3],E.y)}w[0]<Ee&&w[1]<Ee&&w[2]>=0&&w[3]>=0&&_.insert(f,w[0],w[1],w[2],w[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new js.VectorTile(new zc(this.rawTileData)).layers,this.sourceLayerCoder=new hh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,r,a,l){this.loadVTLayers();const h=e.params||{},d=Ee/e.tileSize/e.scale,f=Hn(h.filter),_=e.queryGeometry,x=e.queryPadding*d,v=mh(_),w=this.grid.query(v.minX-x,v.minY-x,v.maxX+x,v.maxY+x),I=mh(e.cameraQueryGeometry),E=this.grid3D.query(I.minX-x,I.minY-x,I.maxX+x,I.maxY+x,((L,U,Q,X)=>(function(J,rt,ct,wt,Rt){for(const yt of J)if(rt<=yt.x&&ct<=yt.y&&wt>=yt.x&&Rt>=yt.y)return!0;const vt=[new mt(rt,ct),new mt(rt,Rt),new mt(wt,Rt),new mt(wt,ct)];if(J.length>2){for(const yt of vt)if(dn(J,yt))return!0}for(let yt=0;yt<J.length-1;yt++)if(Zh(J[yt],J[yt+1],vt))return!0;return!1})(e.cameraQueryGeometry,L-x,U-x,Q+x,X+x)));for(const L of E)w.push(L);w.sort(dp);const C={};let P;for(let L=0;L<w.length;L++){const U=w[L];if(U===P)continue;P=U;const Q=this.featureIndexArray.get(U);let X=null;this.loadMatchingFeature(C,Q.bucketIndex,Q.sourceLayerIndex,Q.featureIndex,f,h.layers,h.availableImages,r,a,l,((J,rt,ct)=>(X||(X=va(J)),rt.queryIntersectsFeature(_,J,ct,X,this.z,e.transform,d,e.pixelPosMatrix))))}return C}loadMatchingFeature(e,r,a,l,h,d,f,_,x,v,w){const I=this.bucketLayerIDs[r];if(d&&!(function(L,U){for(let Q=0;Q<L.length;Q++)if(U.indexOf(L[Q])>=0)return!0;return!1})(d,I))return;const E=this.sourceLayerCoder.decode(a),C=this.vtLayers[E].feature(l);if(h.needGeometry){const L=ba(C,!0);if(!h.filter(new de(this.tileID.overscaledZ),L,this.tileID.canonical))return}else if(!h.filter(new de(this.tileID.overscaledZ),C))return;const P=this.getId(C,E);for(let L=0;L<I.length;L++){const U=I[L];if(d&&d.indexOf(U)<0)continue;const Q=_[U];if(!Q)continue;let X={};P&&v&&(X=v.getState(Q.sourceLayer||"_geojsonTileLayer",P));const J=vi({},x[U]);J.paint=fh(J.paint,Q.paint,C,X,f),J.layout=fh(J.layout,Q.layout,C,X,f);const rt=!w||w(C,Q,X);if(!rt)continue;const ct=new dh(C,this.z,this.x,this.y,P);ct.layer=J;let wt=e[U];wt===void 0&&(wt=e[U]=[]),wt.push({featureIndex:l,feature:ct,intersectionZ:rt})}}lookupSymbolFeatures(e,r,a,l,h,d,f,_){const x={};this.loadVTLayers();const v=Hn(h);for(const w of e)this.loadMatchingFeature(x,a,l,w,v,d,f,_,r);return x}hasLayer(e){for(const r of this.bucketLayerIDs)for(const a of r)if(e===a)return!0;return!1}getId(e,r){let a=e.id;return this.promoteId&&(a=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof a=="boolean"&&(a=Number(a))),a}}function fh(i,e,r,a,l){return Ji(i,((h,d)=>{const f=e instanceof _a?e.get(d):null;return f&&f.evaluate?f.evaluate(r,a,l):f}))}function mh(i){let e=1/0,r=1/0,a=-1/0,l=-1/0;for(const h of i)e=Math.min(e,h.x),r=Math.min(r,h.y),a=Math.max(a,h.x),l=Math.max(l,h.y);return{minX:e,minY:r,maxX:a,maxY:l}}function dp(i,e){return e-i}function _h(i,e,r,a,l){const h=[];for(let d=0;d<i.length;d++){const f=i[d];let _;for(let x=0;x<f.length-1;x++){let v=f[x],w=f[x+1];v.x<e&&w.x<e||(v.x<e?v=new mt(e,v.y+(e-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x<e&&(w=new mt(e,v.y+(e-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y<r&&w.y<r||(v.y<r?v=new mt(v.x+(r-v.y)/(w.y-v.y)*(w.x-v.x),r)._round():w.y<r&&(w=new mt(v.x+(r-v.y)/(w.y-v.y)*(w.x-v.x),r)._round()),v.x>=a&&w.x>=a||(v.x>=a?v=new mt(a,v.y+(a-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x>=a&&(w=new mt(a,v.y+(a-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y>=l&&w.y>=l||(v.y>=l?v=new mt(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round():w.y>=l&&(w=new mt(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round()),_&&v.equals(_[_.length-1])||(_=[v],h.push(_)),_.push(w)))))}}return h}It("FeatureIndex",ph,{omit:["rawTileData","sourceLayerCoder"]});class Zs extends mt{constructor(e,r,a,l){super(e,r),this.angle=a,l!==void 0&&(this.segment=l)}clone(){return new Zs(this.x,this.y,this.angle,this.segment)}}function gh(i,e,r,a,l){if(e.segment===void 0||r===0)return!0;let h=e,d=e.segment+1,f=0;for(;f>-r/2;){if(d--,d<0)return!1;f-=i[d].dist(h),h=i[d]}f+=i[d].dist(i[d+1]),d++;const _=[];let x=0;for(;f<r/2;){const v=i[d],w=i[d+1];if(!w)return!1;let I=i[d-1].angleTo(v)-v.angleTo(w);for(I=Math.abs((I+3*Math.PI)%(2*Math.PI)-Math.PI),_.push({distance:f,angleDelta:I}),x+=I;f-_[0].distance>a;)x-=_.shift().angleDelta;if(x>l)return!1;d++,f+=v.dist(w)}return!0}function yh(i){let e=0;for(let r=0;r<i.length-1;r++)e+=i[r].dist(i[r+1]);return e}function xh(i,e,r){return i?.6*e*r:0}function vh(i,e){return Math.max(i?i.right-i.left:0,e?e.right-e.left:0)}function pp(i,e,r,a,l,h){const d=xh(r,l,h),f=vh(r,a)*h;let _=0;const x=yh(i)/2;for(let v=0;v<i.length-1;v++){const w=i[v],I=i[v+1],E=w.dist(I);if(_+E>x){const C=(x-_)/E,P=ii.number(w.x,I.x,C),L=ii.number(w.y,I.y,C),U=new Zs(P,L,I.angleTo(w),v);return U._round(),!d||gh(i,U,f,d,e)?U:void 0}_+=E}}function fp(i,e,r,a,l,h,d,f,_){const x=xh(a,h,d),v=vh(a,l),w=v*d,I=i[0].x===0||i[0].x===_||i[0].y===0||i[0].y===_;return e-w<e/4&&(e=w+e/4),bh(i,I?e/2*f%e:(v/2+2*h)*d*f%e,e,x,r,w,I,!1,_)}function bh(i,e,r,a,l,h,d,f,_){const x=h/2,v=yh(i);let w=0,I=e-r,E=[];for(let C=0;C<i.length-1;C++){const P=i[C],L=i[C+1],U=P.dist(L),Q=L.angleTo(P);for(;I+r<w+U;){I+=r;const X=(I-w)/U,J=ii.number(P.x,L.x,X),rt=ii.number(P.y,L.y,X);if(J>=0&&J<_&&rt>=0&&rt<_&&I-x>=0&&I+x<=v){const ct=new Zs(J,rt,Q,C);ct._round(),a&&!gh(i,ct,h,a,l)||E.push(ct)}}w+=U}return f||E.length||d||(E=bh(i,w/2,r,a,l,h,d,!0,_)),E}It("Anchor",Zs);const xn=yi;function wh(i,e,r,a){const l=[],h=i.image,d=h.pixelRatio,f=h.paddedRect.w-2*xn,_=h.paddedRect.h-2*xn;let x={x1:i.left,y1:i.top,x2:i.right,y2:i.bottom};const v=h.stretchX||[[0,f]],w=h.stretchY||[[0,_]],I=(nt,Pt)=>nt+Pt[1]-Pt[0],E=v.reduce(I,0),C=w.reduce(I,0),P=f-E,L=_-C;let U=0,Q=E,X=0,J=C,rt=0,ct=P,wt=0,Rt=L;if(h.content&&a){const nt=h.content,Pt=nt[2]-nt[0],zt=nt[3]-nt[1];(h.textFitWidth||h.textFitHeight)&&(x=Wu(i)),U=Cl(v,0,nt[0]),X=Cl(w,0,nt[1]),Q=Cl(v,nt[0],nt[2]),J=Cl(w,nt[1],nt[3]),rt=nt[0]-U,wt=nt[1]-X,ct=Pt-Q,Rt=zt-J}const vt=x.x1,yt=x.y1,Ct=x.x2-vt,kt=x.y2-yt,St=(nt,Pt,zt,Ot)=>{const ce=Pl(nt.stretch-U,Q,Ct,vt),le=Al(nt.fixed-rt,ct,nt.stretch,E),Pe=Pl(Pt.stretch-X,J,kt,yt),lr=Al(Pt.fixed-wt,Rt,Pt.stretch,C),Ne=Pl(zt.stretch-U,Q,Ct,vt),Ae=Al(zt.fixed-rt,ct,zt.stretch,E),ni=Pl(Ot.stretch-X,J,kt,yt),oi=Al(Ot.fixed-wt,Rt,Ot.stretch,C),li=new mt(ce,Pe),Te=new mt(Ne,Pe),De=new mt(Ne,ni),Ye=new mt(ce,ni),Ze=new mt(le/d,lr/d),ci=new mt(Ae/d,oi/d),qe=e*Math.PI/180;if(qe){const Qt=Math.sin(qe),he=Math.cos(qe),_e=[he,-Qt,Qt,he];li._matMult(_e),Te._matMult(_e),Ye._matMult(_e),De._matMult(_e)}const qi=nt.stretch+nt.fixed,xi=Pt.stretch+Pt.fixed;return{tl:li,tr:Te,bl:Ye,br:De,tex:{x:h.paddedRect.x+xn+qi,y:h.paddedRect.y+xn+xi,w:zt.stretch+zt.fixed-qi,h:Ot.stretch+Ot.fixed-xi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ze,pixelOffsetBR:ci,minFontScaleX:ct/d/Ct,minFontScaleY:Rt/d/kt,isSDF:r}};if(a&&(h.stretchX||h.stretchY)){const nt=Th(v,P,E),Pt=Th(w,L,C);for(let zt=0;zt<nt.length-1;zt++){const Ot=nt[zt],ce=nt[zt+1];for(let le=0;le<Pt.length-1;le++)l.push(St(Ot,Pt[le],ce,Pt[le+1]))}}else l.push(St({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:f+1},{fixed:0,stretch:_+1}));return l}function Cl(i,e,r){let a=0;for(const l of i)a+=Math.max(e,Math.min(r,l[1]))-Math.max(e,Math.min(r,l[0]));return a}function Th(i,e,r){const a=[{fixed:-xn,stretch:0}];for(const[l,h]of i){const d=a[a.length-1];a.push({fixed:l-d.stretch,stretch:d.stretch}),a.push({fixed:l-d.stretch,stretch:d.stretch+(h-l)})}return a.push({fixed:e+xn,stretch:r}),a}function Pl(i,e,r,a){return i/e*r+a}function Al(i,e,r,a){return i-e*r/a}class Dl{constructor(e,r,a,l,h,d,f,_,x,v){var w;if(this.boxStartIndex=e.length,x){let I=d.top,E=d.bottom;const C=d.collisionPadding;C&&(I-=C[1],E+=C[3]);let P=E-I;P>0&&(P=Math.max(10,P),this.circleDiameter=P)}else{const I=!((w=d.image)===null||w===void 0)&&w.content&&(d.image.textFitWidth||d.image.textFitHeight)?Wu(d):{x1:d.left,y1:d.top,x2:d.right,y2:d.bottom};I.y1=I.y1*f-_[0],I.y2=I.y2*f+_[2],I.x1=I.x1*f-_[3],I.x2=I.x2*f+_[1];const E=d.collisionPadding;if(E&&(I.x1-=E[0]*f,I.y1-=E[1]*f,I.x2+=E[2]*f,I.y2+=E[3]*f),v){const C=new mt(I.x1,I.y1),P=new mt(I.x2,I.y1),L=new mt(I.x1,I.y2),U=new mt(I.x2,I.y2),Q=v*Math.PI/180;C._rotate(Q),P._rotate(Q),L._rotate(Q),U._rotate(Q),I.x1=Math.min(C.x,P.x,L.x,U.x),I.x2=Math.max(C.x,P.x,L.x,U.x),I.y1=Math.min(C.y,P.y,L.y,U.y),I.y2=Math.max(C.y,P.y,L.y,U.y)}e.emplaceBack(r.x,r.y,I.x1,I.y1,I.x2,I.y2,a,l,h)}this.boxEndIndex=e.length}}class mp{constructor(e=[],r=((a,l)=>a<l?-1:a>l?1:0)){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let a=(this.length>>1)-1;a>=0;a--)this._down(a)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:a}=this,l=r[e];for(;e>0;){const h=e-1>>1,d=r[h];if(a(l,d)>=0)break;r[e]=d,e=h}r[e]=l}_down(e){const{data:r,compare:a}=this,l=this.length>>1,h=r[e];for(;e<l;){let d=1+(e<<1);const f=d+1;if(f<this.length&&a(r[f],r[d])<0&&(d=f),a(r[d],h)>=0)break;r[e]=r[d],e=d}r[e]=h}}function _p(i,e=1,r=!1){let a=1/0,l=1/0,h=-1/0,d=-1/0;const f=i[0];for(let E=0;E<f.length;E++){const C=f[E];(!E||C.x<a)&&(a=C.x),(!E||C.y<l)&&(l=C.y),(!E||C.x>h)&&(h=C.x),(!E||C.y>d)&&(d=C.y)}const _=Math.min(h-a,d-l);let x=_/2;const v=new mp([],gp);if(_===0)return new mt(a,l);for(let E=a;E<h;E+=_)for(let C=l;C<d;C+=_)v.push(new vn(E+x,C+x,x,i));let w=(function(E){let C=0,P=0,L=0;const U=E[0];for(let Q=0,X=U.length,J=X-1;Q<X;J=Q++){const rt=U[Q],ct=U[J],wt=rt.x*ct.y-ct.x*rt.y;P+=(rt.x+ct.x)*wt,L+=(rt.y+ct.y)*wt,C+=3*wt}return new vn(P/C,L/C,0,E)})(i),I=v.length;for(;v.length;){const E=v.pop();(E.d>w.d||!w.d)&&(w=E,r&&console.log("found best %d after %d probes",Math.round(1e4*E.d)/1e4,I)),E.max-w.d<=e||(x=E.h/2,v.push(new vn(E.p.x-x,E.p.y-x,x,i)),v.push(new vn(E.p.x+x,E.p.y-x,x,i)),v.push(new vn(E.p.x-x,E.p.y+x,x,i)),v.push(new vn(E.p.x+x,E.p.y+x,x,i)),I+=4)}return r&&(console.log(`num probes: ${I}`),console.log(`best distance: ${w.d}`)),w.p}function gp(i,e){return e.max-i.max}function vn(i,e,r,a){this.p=new mt(i,e),this.h=r,this.d=(function(l,h){let d=!1,f=1/0;for(let _=0;_<h.length;_++){const x=h[_];for(let v=0,w=x.length,I=w-1;v<w;I=v++){const E=x[v],C=x[I];E.y>l.y!=C.y>l.y&&l.x<(C.x-E.x)*(l.y-E.y)/(C.y-E.y)+E.x&&(d=!d),f=Math.min(f,nu(l,E,C))}}return(d?1:-1)*Math.sqrt(f)})(this.p,a),this.max=this.d+this.h*Math.SQRT2}var $e;R.aq=void 0,($e=R.aq||(R.aq={}))[$e.center=1]="center",$e[$e.left=2]="left",$e[$e.right=3]="right",$e[$e.top=4]="top",$e[$e.bottom=5]="bottom",$e[$e["top-left"]=6]="top-left",$e[$e["top-right"]=7]="top-right",$e[$e["bottom-left"]=8]="bottom-left",$e[$e["bottom-right"]=9]="bottom-right";const qs=7,$c=Number.POSITIVE_INFINITY;function Sh(i,e){return e[1]!==$c?(function(r,a,l){let h=0,d=0;switch(a=Math.abs(a),l=Math.abs(l),r){case"top-right":case"top-left":case"top":d=l-qs;break;case"bottom-right":case"bottom-left":case"bottom":d=-l+qs}switch(r){case"top-right":case"bottom-right":case"right":h=-a;break;case"top-left":case"bottom-left":case"left":h=a}return[h,d]})(i,e[0],e[1]):(function(r,a){let l=0,h=0;a<0&&(a=0);const d=a/Math.SQRT2;switch(r){case"top-right":case"top-left":h=d-qs;break;case"bottom-right":case"bottom-left":h=-d+qs;break;case"bottom":h=-a+qs;break;case"top":h=a-qs}switch(r){case"top-right":case"bottom-right":l=-d;break;case"top-left":case"bottom-left":l=d;break;case"left":l=a;break;case"right":l=-a}return[l,h]})(i,e[0])}function Ih(i,e,r){var a;const l=i.layout,h=(a=l.get("text-variable-anchor-offset"))===null||a===void 0?void 0:a.evaluate(e,{},r);if(h){const f=h.values,_=[];for(let x=0;x<f.length;x+=2){const v=_[x]=f[x],w=f[x+1].map((I=>I*ze));v.startsWith("top")?w[1]-=qs:v.startsWith("bottom")&&(w[1]+=qs),_[x+1]=w}return new wi(_)}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(e,{},r)*ze,$c]:l.get("text-offset").evaluate(e,{},r).map((x=>x*ze));const _=[];for(const x of d)_.push(x,Sh(x,f));return new wi(_)}return null}function Nc(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 yp(i,e,r,a,l,h,d,f,_,x,v){let w=h.textMaxSize.evaluate(e,{});w===void 0&&(w=d);const I=i.layers[0].layout,E=I.get("icon-offset").evaluate(e,{},v),C=Mh(r.horizontal),P=d/24,L=i.tilePixelRatio*P,U=i.tilePixelRatio*w/24,Q=i.tilePixelRatio*f,X=i.tilePixelRatio*I.get("symbol-spacing"),J=I.get("text-padding")*i.tilePixelRatio,rt=(function(nt,Pt,zt,Ot=1){const ce=nt.get("icon-padding").evaluate(Pt,{},zt),le=ce&&ce.values;return[le[0]*Ot,le[1]*Ot,le[2]*Ot,le[3]*Ot]})(I,e,v,i.tilePixelRatio),ct=I.get("text-max-angle")/180*Math.PI,wt=I.get("text-rotation-alignment")!=="viewport"&&I.get("symbol-placement")!=="point",Rt=I.get("icon-rotation-alignment")==="map"&&I.get("symbol-placement")!=="point",vt=I.get("symbol-placement"),yt=X/2,Ct=I.get("icon-text-fit");let kt;a&&Ct!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(kt=Ku(a,r.vertical,Ct,I.get("icon-text-fit-padding"),E,P)),C&&(a=Ku(a,C,Ct,I.get("icon-text-fit-padding"),E,P)));const St=(nt,Pt)=>{Pt.x<0||Pt.x>=Ee||Pt.y<0||Pt.y>=Ee||(function(zt,Ot,ce,le,Pe,lr,Ne,Ae,ni,oi,li,Te,De,Ye,Ze,ci,qe,qi,xi,Qt,he,_e,zi,ve,bn){const Rr=zt.addToLineVertexArray(Ot,ce);let Br,cr,Gi,Fe,as=0,Do=0,Ph=0,Ah=0,Jc=-1,Yc=-1;const ns={};let Dh=ln("");if(zt.allowVerticalPlacement&&le.vertical){const Qe=Ae.layout.get("text-rotate").evaluate(he,{},ve)+90;Gi=new Dl(ni,Ot,oi,li,Te,le.vertical,De,Ye,Ze,Qe),Ne&&(Fe=new Dl(ni,Ot,oi,li,Te,Ne,qe,qi,Ze,Qe))}if(Pe){const Qe=Ae.layout.get("icon-rotate").evaluate(he,{}),Xi=Ae.layout.get("icon-text-fit")!=="none",Ta=wh(Pe,Qe,zi,Xi),vr=Ne?wh(Ne,Qe,zi,Xi):void 0;cr=new Dl(ni,Ot,oi,li,Te,Pe,qe,qi,!1,Qe),as=4*Ta.length;const Sa=zt.iconSizeData;let Fr=null;Sa.kind==="source"?(Fr=[Dr*Ae.layout.get("icon-size").evaluate(he,{})],Fr[0]>$s&&Le(`${zt.layerIds[0]}: Value for "icon-size" is >= ${Eo}. Reduce your "icon-size".`)):Sa.kind==="composite"&&(Fr=[Dr*_e.compositeIconSizes[0].evaluate(he,{},ve),Dr*_e.compositeIconSizes[1].evaluate(he,{},ve)],(Fr[0]>$s||Fr[1]>$s)&&Le(`${zt.layerIds[0]}: Value for "icon-size" is >= ${Eo}. Reduce your "icon-size".`)),zt.addSymbols(zt.icon,Ta,Fr,Qt,xi,he,R.ah.none,Ot,Rr.lineStartIndex,Rr.lineLength,-1,ve),Jc=zt.icon.placedSymbolArray.length-1,vr&&(Do=4*vr.length,zt.addSymbols(zt.icon,vr,Fr,Qt,xi,he,R.ah.vertical,Ot,Rr.lineStartIndex,Rr.lineLength,-1,ve),Yc=zt.icon.placedSymbolArray.length-1)}const Rh=Object.keys(le.horizontal);for(const Qe of Rh){const Xi=le.horizontal[Qe];if(!Br){Dh=ln(Xi.text);const vr=Ae.layout.get("text-rotate").evaluate(he,{},ve);Br=new Dl(ni,Ot,oi,li,Te,Xi,De,Ye,Ze,vr)}const Ta=Xi.positionedLines.length===1;if(Ph+=kh(zt,Ot,Xi,lr,Ae,Ze,he,ci,Rr,le.vertical?R.ah.horizontal:R.ah.horizontalOnly,Ta?Rh:[Qe],ns,Jc,_e,ve),Ta)break}le.vertical&&(Ah+=kh(zt,Ot,le.vertical,lr,Ae,Ze,he,ci,Rr,R.ah.vertical,["vertical"],ns,Yc,_e,ve));const bp=Br?Br.boxStartIndex:zt.collisionBoxArray.length,wp=Br?Br.boxEndIndex:zt.collisionBoxArray.length,Tp=Gi?Gi.boxStartIndex:zt.collisionBoxArray.length,Sp=Gi?Gi.boxEndIndex:zt.collisionBoxArray.length,Ip=cr?cr.boxStartIndex:zt.collisionBoxArray.length,kp=cr?cr.boxEndIndex:zt.collisionBoxArray.length,Mp=Fe?Fe.boxStartIndex:zt.collisionBoxArray.length,Ep=Fe?Fe.boxEndIndex:zt.collisionBoxArray.length;let xr=-1;const Bl=(Qe,Xi)=>Qe&&Qe.circleDiameter?Math.max(Qe.circleDiameter,Xi):Xi;xr=Bl(Br,xr),xr=Bl(Gi,xr),xr=Bl(cr,xr),xr=Bl(Fe,xr);const Bh=xr>-1?1:0;Bh&&(xr*=bn/ze),zt.glyphOffsetArray.length>=yn.MAX_GLYPHS&&Le("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),he.sortKey!==void 0&&zt.addToSortKeyRanges(zt.symbolInstances.length,he.sortKey);const zp=Ih(Ae,he,ve),[Cp,Pp]=(function(Qe,Xi){const Ta=Qe.length,vr=Xi==null?void 0:Xi.values;if((vr==null?void 0:vr.length)>0)for(let Sa=0;Sa<vr.length;Sa+=2){const Fr=vr[Sa+1];Qe.emplaceBack(R.aq[vr[Sa]],Fr[0],Fr[1])}return[Ta,Qe.length]})(zt.textAnchorOffsets,zp);zt.symbolInstances.emplaceBack(Ot.x,Ot.y,ns.right>=0?ns.right:-1,ns.center>=0?ns.center:-1,ns.left>=0?ns.left:-1,ns.vertical||-1,Jc,Yc,Dh,bp,wp,Tp,Sp,Ip,kp,Mp,Ep,oi,Ph,Ah,as,Do,Bh,0,De,xr,Cp,Pp)})(i,Pt,nt,r,a,l,kt,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,L,[J,J,J,J],wt,_,Q,rt,Rt,E,e,h,x,v,d)};if(vt==="line")for(const nt of _h(e.geometry,0,0,Ee,Ee)){const Pt=fp(nt,X,ct,r.vertical||C,a,24,U,i.overscaling,Ee);for(const zt of Pt)C&&xp(i,C.text,yt,zt)||St(nt,zt)}else if(vt==="line-center"){for(const nt of e.geometry)if(nt.length>1){const Pt=pp(nt,ct,r.vertical||C,a,24,U);Pt&&St(nt,Pt)}}else if(e.type==="Polygon")for(const nt of La(e.geometry,0)){const Pt=_p(nt,16);St(nt[0],new Zs(Pt.x,Pt.y,0))}else if(e.type==="LineString")for(const nt of e.geometry)St(nt,new Zs(nt[0].x,nt[0].y,0));else if(e.type==="Point")for(const nt of e.geometry)for(const Pt of nt)St([Pt],new Zs(Pt.x,Pt.y,0))}function kh(i,e,r,a,l,h,d,f,_,x,v,w,I,E,C){const P=(function(Q,X,J,rt,ct,wt,Rt,vt){const yt=rt.layout.get("text-rotate").evaluate(wt,{})*Math.PI/180,Ct=[];for(const kt of X.positionedLines)for(const St of kt.positionedGlyphs){if(!St.rect)continue;const nt=St.rect||{};let Pt=$u+1,zt=!0,Ot=1,ce=0;const le=(ct||vt)&&St.vertical,Pe=St.metrics.advance*St.scale/2;if(vt&&X.verticalizable&&(ce=kt.lineOffset/2-(St.imageName?-(ze-St.metrics.width*St.scale)/2:(St.scale-1)*ze)),St.imageName){const Qt=Rt[St.imageName];zt=Qt.sdf,Ot=Qt.pixelRatio,Pt=yi/Ot}const lr=ct?[St.x+Pe,St.y]:[0,0];let Ne=ct?[0,0]:[St.x+Pe+J[0],St.y+J[1]-ce],Ae=[0,0];le&&(Ae=Ne,Ne=[0,0]);const ni=St.metrics.isDoubleResolution?2:1,oi=(St.metrics.left-Pt)*St.scale-Pe+Ne[0],li=(-St.metrics.top-Pt)*St.scale+Ne[1],Te=oi+nt.w/ni*St.scale/Ot,De=li+nt.h/ni*St.scale/Ot,Ye=new mt(oi,li),Ze=new mt(Te,li),ci=new mt(oi,De),qe=new mt(Te,De);if(le){const Qt=new mt(-Pe,Pe-ko),he=-Math.PI/2,_e=ze/2-Pe,zi=new mt(5-ko-_e,-(St.imageName?_e:0)),ve=new mt(...Ae);Ye._rotateAround(he,Qt)._add(zi)._add(ve),Ze._rotateAround(he,Qt)._add(zi)._add(ve),ci._rotateAround(he,Qt)._add(zi)._add(ve),qe._rotateAround(he,Qt)._add(zi)._add(ve)}if(yt){const Qt=Math.sin(yt),he=Math.cos(yt),_e=[he,-Qt,Qt,he];Ye._matMult(_e),Ze._matMult(_e),ci._matMult(_e),qe._matMult(_e)}const qi=new mt(0,0),xi=new mt(0,0);Ct.push({tl:Ye,tr:Ze,bl:ci,br:qe,tex:nt,writingMode:X.writingMode,glyphOffset:lr,sectionIndex:St.sectionIndex,isSDF:zt,pixelOffsetTL:qi,pixelOffsetBR:xi,minFontScaleX:0,minFontScaleY:0})}return Ct})(0,r,f,l,h,d,a,i.allowVerticalPlacement),L=i.textSizeData;let U=null;L.kind==="source"?(U=[Dr*l.layout.get("text-size").evaluate(d,{})],U[0]>$s&&Le(`${i.layerIds[0]}: Value for "text-size" is >= ${Eo}. Reduce your "text-size".`)):L.kind==="composite"&&(U=[Dr*E.compositeTextSizes[0].evaluate(d,{},C),Dr*E.compositeTextSizes[1].evaluate(d,{},C)],(U[0]>$s||U[1]>$s)&&Le(`${i.layerIds[0]}: Value for "text-size" is >= ${Eo}. Reduce your "text-size".`)),i.addSymbols(i.text,P,U,f,h,d,x,e,_.lineStartIndex,_.lineLength,I,C);for(const Q of v)w[Q]=i.text.placedSymbolArray.length-1;return 4*P.length}function Mh(i){for(const e in i)return i[e];return null}function xp(i,e,r,a){const l=i.compareText;if(e in l){const h=l[e];for(let d=h.length-1;d>=0;d--)if(a.dist(h[d])<r)return!0}else l[e]=[];return l[e].push(a),!1}const Eh=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Zc{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[r,a]=new Uint8Array(e,0,2);if(r!==219)throw new Error("Data does not appear to be in a KDBush format.");const l=a>>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);const h=Eh[15&a];if(!h)throw new Error("Unrecognized array type.");const[d]=new Uint16Array(e,2,1),[f]=new Uint32Array(e,4,1);return new Zc(f,d,h,e)}constructor(e,r=64,a=Float64Array,l){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=a,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const h=Eh.indexOf(this.ArrayType),d=2*e*this.ArrayType.BYTES_PER_ELEMENT,f=e*this.IndexArrayType.BYTES_PER_ELEMENT,_=(8-f%8)%8;if(h<0)throw new Error(`Unexpected typed array class: ${a}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+f+_,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+d+f+_),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+f+_,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+h]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const a=this._pos>>1;return this.ids[a]=a,this.coords[this._pos++]=e,this.coords[this._pos++]=r,a}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return qc(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,a,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:h,coords:d,nodeSize:f}=this,_=[0,h.length-1,0],x=[];for(;_.length;){const v=_.pop()||0,w=_.pop()||0,I=_.pop()||0;if(w-I<=f){for(let L=I;L<=w;L++){const U=d[2*L],Q=d[2*L+1];U>=e&&U<=a&&Q>=r&&Q<=l&&x.push(h[L])}continue}const E=I+w>>1,C=d[2*E],P=d[2*E+1];C>=e&&C<=a&&P>=r&&P<=l&&x.push(h[E]),(v===0?e<=C:r<=P)&&(_.push(I),_.push(E-1),_.push(1-v)),(v===0?a>=C:l>=P)&&(_.push(E+1),_.push(w),_.push(1-v))}return x}within(e,r,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:h,nodeSize:d}=this,f=[0,l.length-1,0],_=[],x=a*a;for(;f.length;){const v=f.pop()||0,w=f.pop()||0,I=f.pop()||0;if(w-I<=d){for(let L=I;L<=w;L++)Ch(h[2*L],h[2*L+1],e,r)<=x&&_.push(l[L]);continue}const E=I+w>>1,C=h[2*E],P=h[2*E+1];Ch(C,P,e,r)<=x&&_.push(l[E]),(v===0?e-a<=C:r-a<=P)&&(f.push(I),f.push(E-1),f.push(1-v)),(v===0?e+a>=C:r+a>=P)&&(f.push(E+1),f.push(w),f.push(1-v))}return _}}function qc(i,e,r,a,l,h){if(l-a<=r)return;const d=a+l>>1;zh(i,e,d,a,l,h),qc(i,e,r,a,d-1,1-h),qc(i,e,r,d+1,l,1-h)}function zh(i,e,r,a,l,h){for(;l>a;){if(l-a>600){const x=l-a+1,v=r-a+1,w=Math.log(x),I=.5*Math.exp(2*w/3),E=.5*Math.sqrt(w*I*(x-I)/x)*(v-x/2<0?-1:1);zh(i,e,r,Math.max(a,Math.floor(r-v*I/x+E)),Math.min(l,Math.floor(r+(x-v)*I/x+E)),h)}const d=e[2*r+h];let f=a,_=l;for(Po(i,e,a,r),e[2*l+h]>d&&Po(i,e,a,l);f<_;){for(Po(i,e,f,_),f++,_--;e[2*f+h]<d;)f++;for(;e[2*_+h]>d;)_--}e[2*a+h]===d?Po(i,e,a,_):(_++,Po(i,e,_,l)),_<=r&&(a=_+1),r<=_&&(l=_-1)}}function Po(i,e,r,a){Gc(i,r,a),Gc(e,2*r,2*a),Gc(e,2*r+1,2*a+1)}function Gc(i,e,r){const a=i[e];i[e]=i[r],i[r]=a}function Ch(i,e,r,a){const l=i-r,h=e-a;return l*l+h*h}var Xc;R.bg=void 0,(Xc=R.bg||(R.bg={})).create="create",Xc.load="load",Xc.fullLoad="fullLoad";let Rl=null,Ao=[];const Hc=1e3/60,Wc="loadTime",Kc="fullLoadTime",vp={mark(i){performance.mark(i)},frame(i){const e=i;Rl!=null&&Ao.push(e-Rl),Rl=e},clearMetrics(){Rl=null,Ao=[],performance.clearMeasures(Wc),performance.clearMeasures(Kc);for(const i in R.bg)performance.clearMarks(R.bg[i])},getPerformanceMetrics(){performance.measure(Wc,R.bg.create,R.bg.load),performance.measure(Kc,R.bg.create,R.bg.fullLoad);const i=performance.getEntriesByName(Wc)[0].duration,e=performance.getEntriesByName(Kc)[0].duration,r=Ao.length,a=1/(Ao.reduce(((h,d)=>h+d),0)/r/1e3),l=Ao.filter((h=>h>Hc)).reduce(((h,d)=>h+(d-Hc)/Hc),0);return{loadTime:i,fullLoadTime:e,fps:a,percentDroppedFrames:l/(r+l)*100,totalFrames:r}}};R.$=class extends T{},R.A=pn,R.B=sc,R.C=function(i){if(os==null){const e=i.navigator?i.navigator.userAgent:null;os=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return os},R.D=Mt,R.E=us,R.F=class{constructor(i,e){this.target=i,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new hp((()=>this.process())),this.subscription=(function(r,a,l,h){return r.addEventListener(a,l,!1),{unsubscribe:()=>{r.removeEventListener(a,l,!1)}}})(this.target,"message",(r=>this.receive(r))),this.globalScope=hr(self)?i:window}registerMessageHandler(i,e){this.messageHandlers[i]=e}sendAsync(i,e){return new Promise(((r,a)=>{const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[l]={resolve:r,reject:a},e&&e.signal.addEventListener("abort",(()=>{delete this.resolveRejects[l];const f={id:l,type:"<cancel>",origin:location.origin,targetMapId:i.targetMapId,sourceMapId:this.mapId};this.target.postMessage(f)}),{once:!0});const h=[],d=Object.assign(Object.assign({},i),{id:l,sourceMapId:this.mapId,origin:location.origin,data:Cs(i.data,h)});this.target.postMessage(d,{transfer:h})}))}receive(i){const e=i.data,r=e.id;if(!(e.origin!=="file://"&&location.origin!=="file://"&&e.origin!=="resource://android"&&location.origin!=="resource://android"&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(e.type==="<cancel>"){delete this.tasks[r];const a=this.abortControllers[r];return delete this.abortControllers[r],void(a&&a.abort())}if(hr(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e)}}process(){if(this.taskQueue.length===0)return;const i=this.taskQueue.shift(),e=this.tasks[i];delete this.tasks[i],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(i,e)}processTask(i,e){return p(this,void 0,void 0,(function*(){if(e.type==="<response>"){const l=this.resolveRejects[i];return delete this.resolveRejects[i],l?void(e.error?l.reject(Ps(e.error)):l.resolve(Ps(e.data))):void 0}if(!this.messageHandlers[e.type])return void this.completeTask(i,new Error(`Could not find a registered handler for ${e.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const r=Ps(e.data),a=new AbortController;this.abortControllers[i]=a;try{const l=yield this.messageHandlers[e.type](e.sourceMapId,r,a);this.completeTask(i,null,l)}catch(l){this.completeTask(i,l)}}))}completeTask(i,e,r){const a=[];delete this.abortControllers[i];const l={id:i,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?Cs(e):null,data:Cs(r,a)};this.target.postMessage(l,{transfer:a})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},R.G=cs,R.H=function(){var i=new pn(16);return pn!=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},R.I=Pc,R.J=function(i,e,r){var a,l,h,d,f,_,x,v,w,I,E,C,P=r[0],L=r[1],U=r[2];return e===i?(i[12]=e[0]*P+e[4]*L+e[8]*U+e[12],i[13]=e[1]*P+e[5]*L+e[9]*U+e[13],i[14]=e[2]*P+e[6]*L+e[10]*U+e[14],i[15]=e[3]*P+e[7]*L+e[11]*U+e[15]):(l=e[1],h=e[2],d=e[3],f=e[4],_=e[5],x=e[6],v=e[7],w=e[8],I=e[9],E=e[10],C=e[11],i[0]=a=e[0],i[1]=l,i[2]=h,i[3]=d,i[4]=f,i[5]=_,i[6]=x,i[7]=v,i[8]=w,i[9]=I,i[10]=E,i[11]=C,i[12]=a*P+f*L+w*U+e[12],i[13]=l*P+_*L+I*U+e[13],i[14]=h*P+x*L+E*U+e[14],i[15]=d*P+v*L+C*U+e[15]),i},R.K=function(i,e,r){var a=r[0],l=r[1],h=r[2];return i[0]=e[0]*a,i[1]=e[1]*a,i[2]=e[2]*a,i[3]=e[3]*a,i[4]=e[4]*l,i[5]=e[5]*l,i[6]=e[6]*l,i[7]=e[7]*l,i[8]=e[8]*h,i[9]=e[9]*h,i[10]=e[10]*h,i[11]=e[11]*h,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},R.L=uu,R.M=function(i,e){const r={};for(let a=0;a<e.length;a++){const l=e[a];l in i&&(r[l]=i[l])}return r},R.N=Ns,R.O=ah,R.P=mt,R.Q=nh,R.R=Ni,R.S=Zi,R.T=rn,R.U=ur,R.V=Gs,R.W=jr,R.X=Ee,R.Y=m,R.Z=zo,R._=p,R.a=Tr,R.a$=function(i,e){var r=i[0],a=i[1],l=i[2],h=i[3],d=i[4],f=i[5],_=i[6],x=i[7],v=i[8],w=i[9],I=i[10],E=i[11],C=i[12],P=i[13],L=i[14],U=i[15],Q=e[0],X=e[1],J=e[2],rt=e[3],ct=e[4],wt=e[5],Rt=e[6],vt=e[7],yt=e[8],Ct=e[9],kt=e[10],St=e[11],nt=e[12],Pt=e[13],zt=e[14],Ot=e[15];return Math.abs(r-Q)<=ai*Math.max(1,Math.abs(r),Math.abs(Q))&&Math.abs(a-X)<=ai*Math.max(1,Math.abs(a),Math.abs(X))&&Math.abs(l-J)<=ai*Math.max(1,Math.abs(l),Math.abs(J))&&Math.abs(h-rt)<=ai*Math.max(1,Math.abs(h),Math.abs(rt))&&Math.abs(d-ct)<=ai*Math.max(1,Math.abs(d),Math.abs(ct))&&Math.abs(f-wt)<=ai*Math.max(1,Math.abs(f),Math.abs(wt))&&Math.abs(_-Rt)<=ai*Math.max(1,Math.abs(_),Math.abs(Rt))&&Math.abs(x-vt)<=ai*Math.max(1,Math.abs(x),Math.abs(vt))&&Math.abs(v-yt)<=ai*Math.max(1,Math.abs(v),Math.abs(yt))&&Math.abs(w-Ct)<=ai*Math.max(1,Math.abs(w),Math.abs(Ct))&&Math.abs(I-kt)<=ai*Math.max(1,Math.abs(I),Math.abs(kt))&&Math.abs(E-St)<=ai*Math.max(1,Math.abs(E),Math.abs(St))&&Math.abs(C-nt)<=ai*Math.max(1,Math.abs(C),Math.abs(nt))&&Math.abs(P-Pt)<=ai*Math.max(1,Math.abs(P),Math.abs(Pt))&&Math.abs(L-zt)<=ai*Math.max(1,Math.abs(L),Math.abs(zt))&&Math.abs(U-Ot)<=ai*Math.max(1,Math.abs(U),Math.abs(Ot))},R.a0=Wt,R.a1=Uc,R.a2=ht,R.a3=i=>{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e)};for(const a of i){const l=window.document.createElement("source");$r(a)||(e.crossOrigin="Anonymous"),l.src=a,e.appendChild(l)}}))},R.a4=function(){return Ia++},R.a5=bt,R.a6=yn,R.a7=Hn,R.a8=ba,R.a9=dh,R.aA=function(i){if(i.type==="custom")return new up(i);switch(i.type){case"background":return new op(i);case"circle":return new Xh(i);case"fill":return new ud(i);case"fill-extrusion":return new Id(i);case"heatmap":return new Wh(i);case"hillshade":return new Jh(i);case"line":return new Dd(i);case"raster":return new cp(i);case"symbol":return new zl(i)}},R.aB=ae,R.aC=function(i,e){if(!i)return[{command:"setStyle",args:[e]}];let r=[];try{if(!te(i.version,e.version))return[{command:"setStyle",args:[e]}];te(i.center,e.center)||r.push({command:"setCenter",args:[e.center]}),te(i.zoom,e.zoom)||r.push({command:"setZoom",args:[e.zoom]}),te(i.bearing,e.bearing)||r.push({command:"setBearing",args:[e.bearing]}),te(i.pitch,e.pitch)||r.push({command:"setPitch",args:[e.pitch]}),te(i.sprite,e.sprite)||r.push({command:"setSprite",args:[e.sprite]}),te(i.glyphs,e.glyphs)||r.push({command:"setGlyphs",args:[e.glyphs]}),te(i.transition,e.transition)||r.push({command:"setTransition",args:[e.transition]}),te(i.light,e.light)||r.push({command:"setLight",args:[e.light]}),te(i.terrain,e.terrain)||r.push({command:"setTerrain",args:[e.terrain]}),te(i.sky,e.sky)||r.push({command:"setSky",args:[e.sky]}),te(i.projection,e.projection)||r.push({command:"setProjection",args:[e.projection]});const a={},l=[];(function(d,f,_,x){let v;for(v in f=f||{},d=d||{})Object.prototype.hasOwnProperty.call(d,v)&&(Object.prototype.hasOwnProperty.call(f,v)||kr(v,_,x));for(v in f)Object.prototype.hasOwnProperty.call(f,v)&&(Object.prototype.hasOwnProperty.call(d,v)?te(d[v],f[v])||(d[v].type==="geojson"&&f[v].type==="geojson"&&hs(d,f,v)?ye(_,{command:"setGeoJSONSourceData",args:[v,f[v].data]}):fr(v,f,_,x)):Ks(v,f,_))})(i.sources,e.sources,l,a);const h=[];i.layers&&i.layers.forEach((d=>{"source"in d&&a[d.source]?r.push({command:"removeLayer",args:[d.id]}):h.push(d)})),r=r.concat(l),(function(d,f,_){f=f||[];const x=(d=d||[]).map(Js),v=f.map(Js),w=d.reduce(Ys,{}),I=f.reduce(Ys,{}),E=x.slice(),C=Object.create(null);let P,L,U,Q,X;for(let J=0,rt=0;J<x.length;J++)P=x[J],Object.prototype.hasOwnProperty.call(I,P)?rt++:(ye(_,{command:"removeLayer",args:[P]}),E.splice(E.indexOf(P,rt),1));for(let J=0,rt=0;J<v.length;J++)P=v[v.length-1-J],E[E.length-1-J]!==P&&(Object.prototype.hasOwnProperty.call(w,P)?(ye(_,{command:"removeLayer",args:[P]}),E.splice(E.lastIndexOf(P,E.length-rt),1)):rt++,Q=E[E.length-J],ye(_,{command:"addLayer",args:[I[P],Q]}),E.splice(E.length-J,0,P),C[P]=!0);for(let J=0;J<v.length;J++)if(P=v[J],L=w[P],U=I[P],!C[P]&&!te(L,U))if(te(L.source,U.source)&&te(L["source-layer"],U["source-layer"])&&te(L.type,U.type)){for(X in bi(L.layout,U.layout,_,P,null,"setLayoutProperty"),bi(L.paint,U.paint,_,P,null,"setPaintProperty"),te(L.filter,U.filter)||ye(_,{command:"setFilter",args:[P,U.filter]}),te(L.minzoom,U.minzoom)&&te(L.maxzoom,U.maxzoom)||ye(_,{command:"setLayerZoomRange",args:[P,U.minzoom,U.maxzoom]}),L)Object.prototype.hasOwnProperty.call(L,X)&&X!=="layout"&&X!=="paint"&&X!=="filter"&&X!=="metadata"&&X!=="minzoom"&&X!=="maxzoom"&&(X.indexOf("paint.")===0?bi(L[X],U[X],_,P,X.slice(6),"setPaintProperty"):te(L[X],U[X])||ye(_,{command:"setLayerProperty",args:[P,X,U[X]]}));for(X in U)Object.prototype.hasOwnProperty.call(U,X)&&!Object.prototype.hasOwnProperty.call(L,X)&&X!=="layout"&&X!=="paint"&&X!=="filter"&&X!=="metadata"&&X!=="minzoom"&&X!=="maxzoom"&&(X.indexOf("paint.")===0?bi(L[X],U[X],_,P,X.slice(6),"setPaintProperty"):te(L[X],U[X])||ye(_,{command:"setLayerProperty",args:[P,X,U[X]]}))}else ye(_,{command:"removeLayer",args:[P]}),Q=E[E.lastIndexOf(P)+1],ye(_,{command:"addLayer",args:[U,Q]})})(h,e.layers,r)}catch(a){console.warn("Unable to compute style diff:",a),r=[{command:"setStyle",args:[e]}]}return r},R.aD=function(i){const e=[],r=i.id;return r===void 0&&e.push({message:`layers.${r}: missing required property "id"`}),i.render===void 0&&e.push({message:`layers.${r}: missing required method "render"`}),i.renderingMode&&i.renderingMode!=="2d"&&i.renderingMode!=="3d"&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},R.aE=function i(e,r){if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(let a=0;a<e.length;a++)if(!i(e[a],r[a]))return!1;return!0}if(typeof e=="object"&&e!==null&&r!==null){if(typeof r!="object"||Object.keys(e).length!==Object.keys(r).length)return!1;for(const a in e)if(!i(e[a],r[a]))return!1;return!0}return e===r},R.aF=Ji,R.aG=Xs,R.aH=class extends ya{constructor(i,e){super(i,e),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},R.aI=_l,R.aJ=class extends ya{constructor(i,e){super(i,e),this.current=Vh}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},R.aK=Qc,R.aL=tu,R.aM=se,R.aN=class extends ya{constructor(i,e){super(i,e),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},R.aO=class extends ya{constructor(i,e){super(i,e),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},R.aP=function(i,e,r,a,l,h,d){var f=1/(e-r),_=1/(a-l),x=1/(h-d);return i[0]=-2*f,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*_,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*x,i[11]=0,i[12]=(e+r)*f,i[13]=(l+a)*_,i[14]=(d+h)*x,i[15]=1,i},R.aQ=Gh,R.aR=class extends H{},R.aS=Ld,R.aT=class extends tt{},R.aU=xc,R.aV=function(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))},R.aW=mu,R.aX=je,R.aY=$i,R.aZ=class extends Et{},R.a_=function(i,e){return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]&&i[3]===e[3]&&i[4]===e[4]&&i[5]===e[5]&&i[6]===e[6]&&i[7]===e[7]&&i[8]===e[8]&&i[9]===e[9]&&i[10]===e[10]&&i[11]===e[11]&&i[12]===e[12]&&i[13]===e[13]&&i[14]===e[14]&&i[15]===e[15]},R.aa=function(i){const e={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((r,a,l,h)=>{const d=l||h;return e[a]=!d||d.toLowerCase(),""})),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},R.ab=function(i,e){const r=[];for(const a in i)a in e||r.push(a);return r},R.ac=Ai,R.ad=function(i,e,r){var a=Math.sin(r),l=Math.cos(r),h=e[0],d=e[1],f=e[2],_=e[3],x=e[4],v=e[5],w=e[6],I=e[7];return e!==i&&(i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=h*l+x*a,i[1]=d*l+v*a,i[2]=f*l+w*a,i[3]=_*l+I*a,i[4]=x*l-h*a,i[5]=v*l-d*a,i[6]=w*l-f*a,i[7]=I*l-_*a,i},R.ae=function(i){var e=new pn(16);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e},R.af=vl,R.ag=function(i,e){let r=0,a=0;if(i.kind==="constant")a=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:l,minZoom:h,maxZoom:d}=i,f=l?Ai(ri.interpolationFactor(l,e,h,d),0,1):0;i.kind==="camera"?a=ii.number(i.minSize,i.maxSize,f):r=f}return{uSizeT:r,uSize:a}},R.ai=function(i,{uSize:e,uSizeT:r},{lowerSize:a,upperSize:l}){return i.kind==="source"?a/Dr:i.kind==="composite"?ii.number(a/Dr,l/Dr,r):e},R.aj=Bc,R.ak=function(i,e,r,a){const l=e.y-i.y,h=e.x-i.x,d=a.y-r.y,f=a.x-r.x,_=d*h-f*l;if(_===0)return null;const x=(f*(i.y-r.y)-d*(i.x-r.x))/_;return new mt(i.x+x*h,i.y+x*l)},R.al=_h,R.am=su,R.an=_c,R.ao=function(i){let e=1/0,r=1/0,a=-1/0,l=-1/0;for(const h of i)e=Math.min(e,h.x),r=Math.min(r,h.y),a=Math.max(a,h.x),l=Math.max(l,h.y);return[e,r,a,l]},R.ap=ze,R.ar=Rc,R.as=function(i,e){var r=e[0],a=e[1],l=e[2],h=e[3],d=e[4],f=e[5],_=e[6],x=e[7],v=e[8],w=e[9],I=e[10],E=e[11],C=e[12],P=e[13],L=e[14],U=e[15],Q=r*f-a*d,X=r*_-l*d,J=r*x-h*d,rt=a*_-l*f,ct=a*x-h*f,wt=l*x-h*_,Rt=v*P-w*C,vt=v*L-I*C,yt=v*U-E*C,Ct=w*L-I*P,kt=w*U-E*P,St=I*U-E*L,nt=Q*St-X*kt+J*Ct+rt*yt-ct*vt+wt*Rt;return nt?(i[0]=(f*St-_*kt+x*Ct)*(nt=1/nt),i[1]=(l*kt-a*St-h*Ct)*nt,i[2]=(P*wt-L*ct+U*rt)*nt,i[3]=(I*ct-w*wt-E*rt)*nt,i[4]=(_*yt-d*St-x*vt)*nt,i[5]=(r*St-l*yt+h*vt)*nt,i[6]=(L*J-C*wt-U*X)*nt,i[7]=(v*wt-I*J+E*X)*nt,i[8]=(d*kt-f*yt+x*Rt)*nt,i[9]=(a*yt-r*kt-h*Rt)*nt,i[10]=(C*ct-P*J+U*Q)*nt,i[11]=(w*J-v*ct-E*Q)*nt,i[12]=(f*vt-d*Ct-_*Rt)*nt,i[13]=(r*Ct-a*vt+l*Rt)*nt,i[14]=(P*X-C*rt-L*Q)*nt,i[15]=(v*rt-w*X+I*Q)*nt,i):null},R.at=Nc,R.au=Dc,R.av=Zc,R.aw=function(){const i={},e=it.$version;for(const r in it.$root){const a=it.$root[r];if(a.required){let l=null;l=r==="version"?e:a.type==="array"?[]:{},l!=null&&(i[r]=l)}}return i},R.ax=lo,R.ay=Ri,R.az=function(i){i=i.slice();const e=Object.create(null);for(let r=0;r<i.length;r++)e[i[r].id]=i[r];for(let r=0;r<i.length;r++)"ref"in i[r]&&(i[r]=Ws(i[r],e[i[r].ref]));return i},R.b=Yi,R.b0=function(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},R.b1=function(i,e,r){return i[0]=e[0]*r[0],i[1]=e[1]*r[1],i[2]=e[2]*r[2],i[3]=e[3]*r[3],i},R.b2=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3]*e[3]},R.b3=Ki,R.b4=ch,R.b5=oh,R.b6=function(i,e,r,a,l){var h,d=1/Math.tan(e/2);return i[0]=d/r,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=d,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,l!=null&&l!==1/0?(i[10]=(l+a)*(h=1/(a-l)),i[14]=2*l*a*h):(i[10]=-1,i[14]=-2*a),i},R.b7=function(i,e,r){var a=Math.sin(r),l=Math.cos(r),h=e[4],d=e[5],f=e[6],_=e[7],x=e[8],v=e[9],w=e[10],I=e[11];return e!==i&&(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[4]=h*l+x*a,i[5]=d*l+v*a,i[6]=f*l+w*a,i[7]=_*l+I*a,i[8]=x*l-h*a,i[9]=v*l-d*a,i[10]=w*l-f*a,i[11]=I*l-_*a,i},R.b8=ui,R.b9=Sn,R.bA=Bu,R.bB=function(i){return i.message===Di},R.bC=Ts,R.bD=_i,R.ba=function(i){return i*Math.PI/180},R.bb=function(i,e){const{x:r,y:a}=zo.fromLngLat(e);return!(i<0||i>25||a<0||a>=1||r<0||r>=1)},R.bc=function(i,e){return i[0]=e[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=e[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=e[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},R.bd=class extends b{},R.be=Vc,R.bf=vp,R.bh=hi,R.bi=function(i,e){Tr.REGISTERED_PROTOCOLS[i]=e},R.bj=function(i){delete Tr.REGISTERED_PROTOCOLS[i]},R.bk=function(i,e){const r={};for(let l=0;l<i.length;l++){const h=e&&e[i[l].id]||sl(i[l]);e&&(e[i[l].id]=h);let d=r[h];d||(d=r[h]=[]),d.push(i[l])}const a=[];for(const l in r)a.push(r[l]);return a},R.bl=It,R.bm=hh,R.bn=ph,R.bo=Zu,R.bp=function(i){i.bucket.createArrays(),i.bucket.tilePixelRatio=Ee/(512*i.bucket.overscaling),i.bucket.compareText={},i.bucket.iconsNeedLinear=!1;const e=i.bucket.layers[0],r=e.layout,a=e._unevaluatedLayout._values,l={layoutIconSize:a["icon-size"].possiblyEvaluate(new de(i.bucket.zoom+1),i.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new de(i.bucket.zoom+1),i.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new de(18))};if(i.bucket.textSizeData.kind==="composite"){const{minZoom:x,maxZoom:v}=i.bucket.textSizeData;l.compositeTextSizes=[a["text-size"].possiblyEvaluate(new de(x),i.canonical),a["text-size"].possiblyEvaluate(new de(v),i.canonical)]}if(i.bucket.iconSizeData.kind==="composite"){const{minZoom:x,maxZoom:v}=i.bucket.iconSizeData;l.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new de(x),i.canonical),a["icon-size"].possiblyEvaluate(new de(v),i.canonical)]}const h=r.get("text-line-height")*ze,d=r.get("text-rotation-alignment")!=="viewport"&&r.get("symbol-placement")!=="point",f=r.get("text-keep-upright"),_=r.get("text-size");for(const x of i.bucket.features){const v=r.get("text-font").evaluate(x,{},i.canonical).join(","),w=_.evaluate(x,{},i.canonical),I=l.layoutTextSize.evaluate(x,{},i.canonical),E=l.layoutIconSize.evaluate(x,{},i.canonical),C={horizontal:{},vertical:void 0},P=x.text;let L,U=[0,0];if(P){const J=P.toString(),rt=r.get("text-letter-spacing").evaluate(x,{},i.canonical)*ze,ct=ac(J)?rt:0,wt=r.get("text-anchor").evaluate(x,{},i.canonical),Rt=Ih(e,x,i.canonical);if(!Rt){const kt=r.get("text-radial-offset").evaluate(x,{},i.canonical);U=kt?Sh(wt,[kt*ze,$c]):r.get("text-offset").evaluate(x,{},i.canonical).map((St=>St*ze))}let vt=d?"center":r.get("text-justify").evaluate(x,{},i.canonical);const yt=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(x,{},i.canonical)*ze:1/0,Ct=()=>{i.bucket.allowVerticalPlacement&&co(J)&&(C.vertical=kl(P,i.glyphMap,i.glyphPositions,i.imagePositions,v,yt,h,wt,"left",ct,U,R.ah.vertical,!0,I,w))};if(!d&&Rt){const kt=new Set;if(vt==="auto")for(let nt=0;nt<Rt.values.length;nt+=2)kt.add(Nc(Rt.values[nt]));else kt.add(vt);let St=!1;for(const nt of kt)if(!C.horizontal[nt])if(St)C.horizontal[nt]=C.horizontal[0];else{const Pt=kl(P,i.glyphMap,i.glyphPositions,i.imagePositions,v,yt,h,"center",nt,ct,U,R.ah.horizontal,!1,I,w);Pt&&(C.horizontal[nt]=Pt,St=Pt.positionedLines.length===1)}Ct()}else{vt==="auto"&&(vt=Nc(wt));const kt=kl(P,i.glyphMap,i.glyphPositions,i.imagePositions,v,yt,h,wt,vt,ct,U,R.ah.horizontal,!1,I,w);kt&&(C.horizontal[vt]=kt),Ct(),co(J)&&d&&f&&(C.vertical=kl(P,i.glyphMap,i.glyphPositions,i.imagePositions,v,yt,h,wt,vt,ct,U,R.ah.vertical,!1,I,w))}}let Q=!1;if(x.icon&&x.icon.name){const J=i.imageMap[x.icon.name];J&&(L=ip(i.imagePositions[x.icon.name],r.get("icon-offset").evaluate(x,{},i.canonical),r.get("icon-anchor").evaluate(x,{},i.canonical)),Q=!!J.sdf,i.bucket.sdfIcons===void 0?i.bucket.sdfIcons=Q:i.bucket.sdfIcons!==Q&&Le("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(J.pixelRatio!==i.bucket.pixelRatio||r.get("icon-rotate").constantOr(1)!==0)&&(i.bucket.iconsNeedLinear=!0))}const X=Mh(C.horizontal)||C.vertical;i.bucket.iconsInText=!!X&&X.iconsInText,(X||L)&&yp(i.bucket,x,C,L,i.imageMap,l,I,E,U,Q,i.canonical)}i.showCollisionBoxes&&i.bucket.generateCollisionDebugBuffers()},R.bq=Mc,R.br=Sc,R.bs=kc,R.bt=js,R.bu=zc,R.bv=class{constructor(i){this._marks={start:[i.url,"start"].join("#"),end:[i.url,"end"].join("#"),measure:i.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let i=performance.getEntriesByName(this._marks.measure);return i.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),i=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),i}},R.bw=function(i,e,r,a,l){return p(this,void 0,void 0,(function*(){if(Gs())try{return yield jr(i,e,r,a,l)}catch{}return(function(h,d,f,_,x){const v=h.width,w=h.height;dr&&ti||(dr=new OffscreenCanvas(v,w),ti=dr.getContext("2d",{willReadFrequently:!0})),dr.width=v,dr.height=w,ti.drawImage(h,0,0,v,w);const I=ti.getImageData(d,f,_,x);return ti.clearRect(0,0,v,w),I.data})(i,e,r,a,l)}))},R.bx=uh,R.by=Pi,R.bz=Hi,R.c=ls,R.d=i=>p(void 0,void 0,void 0,(function*(){if(i.byteLength===0)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(i)],{type:"image/png"});try{return createImageBitmap(e)}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.`)}})),R.e=vi,R.f=i=>new Promise(((e,r)=>{const a=new Image;a.onload=()=>{e(a),URL.revokeObjectURL(a.src),a.onload=null,window.requestAnimationFrame((()=>{a.src=Ma}))},a.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"});a.src=i.byteLength?URL.createObjectURL(l):Ma})),R.g=Qi,R.h=(i,e)=>Ur(vi(i,{type:"json"}),e),R.i=hr,R.j=Ir,R.k=Sr,R.l=(i,e)=>Ur(vi(i,{type:"arrayBuffer"}),e),R.m=Ur,R.n=function(i){return new zc(i).readFields(Wd,[])},R.o=xo,R.p=Nu,R.q=u,R.r=rc,R.s=$r,R.t=no,R.u=es,R.v=it,R.w=Le,R.x=function([i,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(e)*Math.sin(r),y:i*Math.sin(e)*Math.sin(r),z:i*Math.cos(r)}},R.y=ii,R.z=de})),Or("worker",["./shared"],(function(R){"use strict";class p{constructor(M){this.keyCache={},M&&this.replace(M)}replace(M){this._layerConfigs={},this._layers={},this.update(M,[])}update(M,k){for(const O of M){this._layerConfigs[O.id]=O;const G=this._layers[O.id]=R.aA(O);G._featureFilter=R.a7(G.filter),this.keyCache[O.id]&&delete this.keyCache[O.id]}for(const O of k)delete this.keyCache[O],delete this._layerConfigs[O],delete this._layers[O];this.familiesBySource={};const D=R.bk(Object.values(this._layerConfigs),this.keyCache);for(const O of D){const G=O.map((et=>this._layers[et.id])),W=G[0];if(W.visibility==="none")continue;const Y=W.source||"";let Z=this.familiesBySource[Y];Z||(Z=this.familiesBySource[Y]={});const st=W.sourceLayer||"_geojsonTileLayer";let lt=Z[st];lt||(lt=Z[st]=[]),lt.push(G)}}}class Pi{constructor(M){const k={},D=[];for(const Y in M){const Z=M[Y],st=k[Y]={};for(const lt in Z){const et=Z[+lt];if(!et||et.bitmap.width===0||et.bitmap.height===0)continue;const dt={x:0,y:0,w:et.bitmap.width+2,h:et.bitmap.height+2};D.push(dt),st[lt]={rect:dt,metrics:et.metrics}}}const{w:O,h:G}=R.p(D),W=new R.o({width:O||1,height:G||1});for(const Y in M){const Z=M[Y];for(const st in Z){const lt=Z[+st];if(!lt||lt.bitmap.width===0||lt.bitmap.height===0)continue;const et=k[Y][st].rect;R.o.copy(lt.bitmap,W,{x:0,y:0},{x:et.x+1,y:et.y+1},lt.bitmap)}}this.image=W,this.positions=k}}R.bl("GlyphAtlas",Pi);class Hi{constructor(M){this.tileID=new R.S(M.tileID.overscaledZ,M.tileID.wrap,M.tileID.canonical.z,M.tileID.canonical.x,M.tileID.canonical.y),this.uid=M.uid,this.zoom=M.zoom,this.pixelRatio=M.pixelRatio,this.tileSize=M.tileSize,this.source=M.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=M.showCollisionBoxes,this.collectResourceTiming=!!M.collectResourceTiming,this.returnDependencies=!!M.returnDependencies,this.promoteId=M.promoteId,this.inFlightDependencies=[]}parse(M,k,D,O){return R._(this,void 0,void 0,(function*(){this.status="parsing",this.data=M,this.collisionBoxArray=new R.a5;const G=new R.bm(Object.keys(M.layers).sort()),W=new R.bn(this.tileID,this.promoteId);W.bucketLayerIDs=[];const Y={},Z={featureIndex:W,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:D},st=k.familiesBySource[this.source];for(const Zt in st){const re=M.layers[Zt];if(!re)continue;re.version===1&&R.w(`Vector tile source "${this.source}" layer "${Zt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const ge=G.encode(Zt),Ce=[];for(let Re=0;Re<re.length;Re++){const We=re.feature(Re),ds=W.getId(We,Zt);Ce.push({feature:We,id:ds,index:Re,sourceLayerIndex:ge})}for(const Re of st[Zt]){const We=Re[0];We.source!==this.source&&R.w(`layer.source = ${We.source} does not equal this.source = ${this.source}`),We.minzoom&&this.zoom<Math.floor(We.minzoom)||We.maxzoom&&this.zoom>=We.maxzoom||We.visibility!=="none"&&(Ge(Re,this.zoom,D),(Y[We.id]=We.createBucket({index:W.bucketLayerIDs.length,layers:Re,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:ge,sourceID:this.source})).populate(Ce,Z,this.tileID.canonical),W.bucketLayerIDs.push(Re.map((ds=>ds.id))))}}const lt=R.aF(Z.glyphDependencies,(Zt=>Object.keys(Zt).map(Number)));this.inFlightDependencies.forEach((Zt=>Zt==null?void 0:Zt.abort())),this.inFlightDependencies=[];let et=Promise.resolve({});if(Object.keys(lt).length){const Zt=new AbortController;this.inFlightDependencies.push(Zt),et=O.sendAsync({type:"GG",data:{stacks:lt,source:this.source,tileID:this.tileID,type:"glyphs"}},Zt)}const dt=Object.keys(Z.iconDependencies);let At=Promise.resolve({});if(dt.length){const Zt=new AbortController;this.inFlightDependencies.push(Zt),At=O.sendAsync({type:"GI",data:{icons:dt,source:this.source,tileID:this.tileID,type:"icons"}},Zt)}const Dt=Object.keys(Z.patternDependencies);let Kt=Promise.resolve({});if(Dt.length){const Zt=new AbortController;this.inFlightDependencies.push(Zt),Kt=O.sendAsync({type:"GI",data:{icons:Dt,source:this.source,tileID:this.tileID,type:"patterns"}},Zt)}const[Ut,Jt,Gt]=yield Promise.all([et,At,Kt]),ke=new Pi(Ut),xe=new R.bo(Jt,Gt);for(const Zt in Y){const re=Y[Zt];re instanceof R.a6?(Ge(re.layers,this.zoom,D),R.bp({bucket:re,glyphMap:Ut,glyphPositions:ke.positions,imageMap:Jt,imagePositions:xe.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):re.hasPattern&&(re instanceof R.bq||re instanceof R.br||re instanceof R.bs)&&(Ge(re.layers,this.zoom,D),re.addFeatures(Z,this.tileID.canonical,xe.patternPositions))}return this.status="done",{buckets:Object.values(Y).filter((Zt=>!Zt.isEmpty())),featureIndex:W,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:ke.image,imageAtlas:xe,glyphMap:this.returnDependencies?Ut:null,iconMap:this.returnDependencies?Jt:null,glyphPositions:this.returnDependencies?ke.positions:null}}))}}function Ge(j,M,k){const D=new R.z(M);for(const O of j)O.recalculate(D,k)}class mt{constructor(M,k,D){this.actor=M,this.layerIndex=k,this.availableImages=D,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(M,k){return R._(this,void 0,void 0,(function*(){const D=yield R.l(M.request,k);try{return{vectorTile:new R.bt.VectorTile(new R.bu(D.data)),rawData:D.data,cacheControl:D.cacheControl,expires:D.expires}}catch(O){const G=new Uint8Array(D.data);let W=`Unable to parse the tile at ${M.request.url}, `;throw W+=G[0]===31&&G[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${O.message}`,new Error(W)}}))}loadTile(M){return R._(this,void 0,void 0,(function*(){const k=M.uid,D=!!(M&&M.request&&M.request.collectResourceTiming)&&new R.bv(M.request),O=new Hi(M);this.loading[k]=O;const G=new AbortController;O.abort=G;try{const W=yield this.loadVectorTile(M,G);if(delete this.loading[k],!W)return null;const Y=W.rawData,Z={};W.expires&&(Z.expires=W.expires),W.cacheControl&&(Z.cacheControl=W.cacheControl);const st={};if(D){const et=D.finish();et&&(st.resourceTiming=JSON.parse(JSON.stringify(et)))}O.vectorTile=W.vectorTile;const lt=O.parse(W.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[k]=O,this.fetching[k]={rawTileData:Y,cacheControl:Z,resourceTiming:st};try{const et=yield lt;return R.e({rawTileData:Y.slice(0)},et,Z,st)}finally{delete this.fetching[k]}}catch(W){throw delete this.loading[k],O.status="done",this.loaded[k]=O,W}}))}reloadTile(M){return R._(this,void 0,void 0,(function*(){const k=M.uid;if(!this.loaded||!this.loaded[k])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const D=this.loaded[k];if(D.showCollisionBoxes=M.showCollisionBoxes,D.status==="parsing"){const O=yield D.parse(D.vectorTile,this.layerIndex,this.availableImages,this.actor);let G;if(this.fetching[k]){const{rawTileData:W,cacheControl:Y,resourceTiming:Z}=this.fetching[k];delete this.fetching[k],G=R.e({rawTileData:W.slice(0)},O,Y,Z)}else G=O;return G}if(D.status==="done"&&D.vectorTile)return D.parse(D.vectorTile,this.layerIndex,this.availableImages,this.actor)}))}abortTile(M){return R._(this,void 0,void 0,(function*(){const k=this.loading,D=M.uid;k&&k[D]&&k[D].abort&&(k[D].abort.abort(),delete k[D])}))}removeTile(M){return R._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[M.uid]&&delete this.loaded[M.uid]}))}}class at{constructor(){this.loaded={}}loadTile(M){return R._(this,void 0,void 0,(function*(){const{uid:k,encoding:D,rawImageData:O,redFactor:G,greenFactor:W,blueFactor:Y,baseShift:Z}=M,st=O.width+2,lt=O.height+2,et=R.b(O)?new R.R({width:st,height:lt},yield R.bw(O,-1,-1,st,lt)):O,dt=new R.bx(k,et,D,G,W,Y,Z);return this.loaded=this.loaded||{},this.loaded[k]=dt,dt}))}removeTile(M){const k=this.loaded,D=M.uid;k&&k[D]&&delete k[D]}}function Vr(j,M){if(j.length!==0){br(j[0],M);for(var k=1;k<j.length;k++)br(j[k],!M)}}function br(j,M){for(var k=0,D=0,O=0,G=j.length,W=G-1;O<G;W=O++){var Y=(j[O][0]-j[W][0])*(j[W][1]+j[O][1]),Z=k+Y;D+=Math.abs(k)>=Math.abs(Y)?k-Z+Y:Y-Z+k,k=Z}k+D>=0!=!!M&&j.reverse()}var Wi=R.by((function j(M,k){var D,O=M&&M.type;if(O==="FeatureCollection")for(D=0;D<M.features.length;D++)j(M.features[D],k);else if(O==="GeometryCollection")for(D=0;D<M.geometries.length;D++)j(M.geometries[D],k);else if(O==="Feature")j(M.geometry,k);else if(O==="Polygon")Vr(M.coordinates,k);else if(O==="MultiPolygon")for(D=0;D<M.coordinates.length;D++)Vr(M.coordinates[D],k);return M}));const wr=R.bt.VectorTileFeature.prototype.toGeoJSON;var ur={exports:{}},Gs=R.bz,ui=R.bt.VectorTileFeature,Sn=Ai;function Ai(j,M){this.options=M||{},this.features=j,this.length=j.length}function Ki(j,M){this.id=typeof j.id=="number"?j.id:void 0,this.type=j.type,this.rawGeometry=j.type===1?[j.geometry]:j.geometry,this.properties=j.tags,this.extent=M||4096}Ai.prototype.feature=function(j){return new Ki(this.features[j],this.options.extent)},Ki.prototype.loadGeometry=function(){var j=this.rawGeometry;this.geometry=[];for(var M=0;M<j.length;M++){for(var k=j[M],D=[],O=0;O<k.length;O++)D.push(new Gs(k[O][0],k[O][1]));this.geometry.push(D)}return this.geometry},Ki.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var j=this.geometry,M=1/0,k=-1/0,D=1/0,O=-1/0,G=0;G<j.length;G++)for(var W=j[G],Y=0;Y<W.length;Y++){var Z=W[Y];M=Math.min(M,Z.x),k=Math.max(k,Z.x),D=Math.min(D,Z.y),O=Math.max(O,Z.y)}return[M,D,k,O]},Ki.prototype.toGeoJSON=ui.prototype.toGeoJSON;var vi=R.bA,Ia=Sn;function Ji(j){var M=new vi;return(function(k,D){for(var O in k.layers)D.writeMessage(3,Xs,k.layers[O])})(j,M),M.finish()}function Xs(j,M){var k;M.writeVarintField(15,j.version||1),M.writeStringField(1,j.name||""),M.writeVarintField(5,j.extent||4096);var D={keys:[],values:[],keycache:{},valuecache:{}};for(k=0;k<j.length;k++)D.feature=j.feature(k),M.writeMessage(2,ae,D);var O=D.keys;for(k=0;k<O.length;k++)M.writeStringField(3,O[k]);var G=D.values;for(k=0;k<G.length;k++)M.writeMessage(4,os,G[k])}function ae(j,M){var k=j.feature;k.id!==void 0&&M.writeVarintField(1,k.id),M.writeMessage(2,ka,j),M.writeVarintField(3,k.type),M.writeMessage(4,hr,k)}function ka(j,M){var k=j.feature,D=j.keys,O=j.values,G=j.keycache,W=j.valuecache;for(var Y in k.properties){var Z=k.properties[Y],st=G[Y];if(Z!==null){st===void 0&&(D.push(Y),G[Y]=st=D.length-1),M.writeVarint(st);var lt=typeof Z;lt!=="string"&&lt!=="boolean"&&lt!=="number"&&(Z=JSON.stringify(Z));var et=lt+":"+Z,dt=W[et];dt===void 0&&(O.push(Z),W[et]=dt=O.length-1),M.writeVarint(dt)}}}function Le(j,M){return(M<<3)+(7&j)}function Xe(j){return j<<1^j>>31}function hr(j,M){for(var k=j.loadGeometry(),D=j.type,O=0,G=0,W=k.length,Y=0;Y<W;Y++){var Z=k[Y],st=1;D===1&&(st=Z.length),M.writeVarint(Le(1,st));for(var lt=D===3?Z.length-1:Z.length,et=0;et<lt;et++){et===1&&D!==1&&M.writeVarint(Le(2,lt-1));var dt=Z[et].x-O,At=Z[et].y-G;M.writeVarint(Xe(dt)),M.writeVarint(Xe(At)),O+=dt,G+=At}D===3&&M.writeVarint(Le(7,1))}}function os(j,M){var k=typeof j;k==="string"?M.writeStringField(1,j):k==="boolean"?M.writeBooleanField(7,j):k==="number"&&(j%1!=0?M.writeDoubleField(3,j):j<0?M.writeSVarintField(6,j):M.writeVarintField(5,j))}ur.exports=Ji,ur.exports.fromVectorTileJs=Ji,ur.exports.fromGeojsonVt=function(j,M){M=M||{};var k={};for(var D in j)k[D]=new Ia(j[D].features,M),k[D].name=D,k[D].version=M.version,k[D].extent=M.extent;return Ji({layers:k})},ur.exports.GeoJSONWrapper=Ia;var Yi=R.by(ur.exports);const Ma={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:j=>j},jr=Math.fround||(dr=new Float32Array(1),j=>(dr[0]=+j,dr[0]));var dr;const ti=3,Di=5,ls=6;class Tr{constructor(M){this.options=Object.assign(Object.create(Ma),M),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(M){const{log:k,minZoom:D,maxZoom:O}=this.options;k&&console.time("total time");const G=`prepare ${M.length} points`;k&&console.time(G),this.points=M;const W=[];for(let Z=0;Z<M.length;Z++){const st=M[Z];if(!st.geometry)continue;const[lt,et]=st.geometry.coordinates,dt=jr(hi(lt)),At=jr(Ri(et));W.push(dt,At,1/0,Z,-1,1),this.options.reduce&&W.push(0)}let Y=this.trees[O+1]=this._createTree(W);k&&console.timeEnd(G);for(let Z=O;Z>=D;Z--){const st=+Date.now();Y=this.trees[Z]=this._createTree(this._cluster(Y,Z)),k&&console.log("z%d: %d clusters in %dms",Z,Y.numItems,+Date.now()-st)}return k&&console.timeEnd("total time"),this}getClusters(M,k){let D=((M[0]+180)%360+360)%360-180;const O=Math.max(-90,Math.min(90,M[1]));let G=M[2]===180?180:((M[2]+180)%360+360)%360-180;const W=Math.max(-90,Math.min(90,M[3]));if(M[2]-M[0]>=360)D=-180,G=180;else if(D>G){const et=this.getClusters([D,O,180,W],k),dt=this.getClusters([-180,O,G,W],k);return et.concat(dt)}const Y=this.trees[this._limitZoom(k)],Z=Y.range(hi(D),Ri(W),hi(G),Ri(O)),st=Y.data,lt=[];for(const et of Z){const dt=this.stride*et;lt.push(st[dt+Di]>1?Qi(st,dt,this.clusterProps):this.points[st[dt+ti]])}return lt}getChildren(M){const k=this._getOriginId(M),D=this._getOriginZoom(M),O="No cluster with the specified id.",G=this.trees[D];if(!G)throw new Error(O);const W=G.data;if(k*this.stride>=W.length)throw new Error(O);const Y=this.options.radius/(this.options.extent*Math.pow(2,D-1)),Z=G.within(W[k*this.stride],W[k*this.stride+1],Y),st=[];for(const lt of Z){const et=lt*this.stride;W[et+4]===M&&st.push(W[et+Di]>1?Qi(W,et,this.clusterProps):this.points[W[et+ti]])}if(st.length===0)throw new Error(O);return st}getLeaves(M,k,D){const O=[];return this._appendLeaves(O,M,k=k||10,D=D||0,0),O}getTile(M,k,D){const O=this.trees[this._limitZoom(M)],G=Math.pow(2,M),{extent:W,radius:Y}=this.options,Z=Y/W,st=(D-Z)/G,lt=(D+1+Z)/G,et={features:[]};return this._addTileFeatures(O.range((k-Z)/G,st,(k+1+Z)/G,lt),O.data,k,D,G,et),k===0&&this._addTileFeatures(O.range(1-Z/G,st,1,lt),O.data,G,D,G,et),k===G-1&&this._addTileFeatures(O.range(0,st,Z/G,lt),O.data,-1,D,G,et),et.features.length?et:null}getClusterExpansionZoom(M){let k=this._getOriginZoom(M)-1;for(;k<=this.options.maxZoom;){const D=this.getChildren(M);if(k++,D.length!==1)break;M=D[0].properties.cluster_id}return k}_appendLeaves(M,k,D,O,G){const W=this.getChildren(k);for(const Y of W){const Z=Y.properties;if(Z&&Z.cluster?G+Z.point_count<=O?G+=Z.point_count:G=this._appendLeaves(M,Z.cluster_id,D,O,G):G<O?G++:M.push(Y),M.length===D)break}return G}_createTree(M){const k=new R.av(M.length/this.stride|0,this.options.nodeSize,Float32Array);for(let D=0;D<M.length;D+=this.stride)k.add(M[D],M[D+1]);return k.finish(),k.data=M,k}_addTileFeatures(M,k,D,O,G,W){for(const Y of M){const Z=Y*this.stride,st=k[Z+Di]>1;let lt,et,dt;if(st)lt=cs(k,Z,this.clusterProps),et=k[Z],dt=k[Z+1];else{const Kt=this.points[k[Z+ti]];lt=Kt.properties;const[Ut,Jt]=Kt.geometry.coordinates;et=hi(Ut),dt=Ri(Jt)}const At={type:1,geometry:[[Math.round(this.options.extent*(et*G-D)),Math.round(this.options.extent*(dt*G-O))]],tags:lt};let Dt;Dt=st||this.options.generateId?k[Z+ti]:this.points[k[Z+ti]].id,Dt!==void 0&&(At.id=Dt),W.features.push(At)}}_limitZoom(M){return Math.max(this.options.minZoom,Math.min(Math.floor(+M),this.options.maxZoom+1))}_cluster(M,k){const{radius:D,extent:O,reduce:G,minPoints:W}=this.options,Y=D/(O*Math.pow(2,k)),Z=M.data,st=[],lt=this.stride;for(let et=0;et<Z.length;et+=lt){if(Z[et+2]<=k)continue;Z[et+2]=k;const dt=Z[et],At=Z[et+1],Dt=M.within(Z[et],Z[et+1],Y),Kt=Z[et+Di];let Ut=Kt;for(const Jt of Dt){const Gt=Jt*lt;Z[Gt+2]>k&&(Ut+=Z[Gt+Di])}if(Ut>Kt&&Ut>=W){let Jt,Gt=dt*Kt,ke=At*Kt,xe=-1;const Zt=((et/lt|0)<<5)+(k+1)+this.points.length;for(const re of Dt){const ge=re*lt;if(Z[ge+2]<=k)continue;Z[ge+2]=k;const Ce=Z[ge+Di];Gt+=Z[ge]*Ce,ke+=Z[ge+1]*Ce,Z[ge+4]=Zt,G&&(Jt||(Jt=this._map(Z,et,!0),xe=this.clusterProps.length,this.clusterProps.push(Jt)),G(Jt,this._map(Z,ge)))}Z[et+4]=Zt,st.push(Gt/Ut,ke/Ut,1/0,Zt,-1,Ut),G&&st.push(xe)}else{for(let Jt=0;Jt<lt;Jt++)st.push(Z[et+Jt]);if(Ut>1)for(const Jt of Dt){const Gt=Jt*lt;if(!(Z[Gt+2]<=k)){Z[Gt+2]=k;for(let ke=0;ke<lt;ke++)st.push(Z[Gt+ke])}}}}return st}_getOriginId(M){return M-this.points.length>>5}_getOriginZoom(M){return(M-this.points.length)%32}_map(M,k,D){if(M[k+Di]>1){const W=this.clusterProps[M[k+ls]];return D?Object.assign({},W):W}const O=this.points[M[k+ti]].properties,G=this.options.map(O);return D&&G===O?Object.assign({},G):G}}function Qi(j,M,k){return{type:"Feature",id:j[M+ti],properties:cs(j,M,k),geometry:{type:"Point",coordinates:[(D=j[M],360*(D-.5)),Ur(j[M+1])]}};var D}function cs(j,M,k){const D=j[M+Di],O=D>=1e4?`${Math.round(D/1e3)}k`:D>=1e3?Math.round(D/100)/10+"k":D,G=j[M+ls],W=G===-1?{}:Object.assign({},k[G]);return Object.assign(W,{cluster:!0,cluster_id:j[M+ti],point_count:D,point_count_abbreviated:O})}function hi(j){return j/360+.5}function Ri(j){const M=Math.sin(j*Math.PI/180),k=.5-.25*Math.log((1+M)/(1-M))/Math.PI;return k<0?0:k>1?1:k}function Ur(j){const M=(180-360*j)*Math.PI/180;return 360*Math.atan(Math.exp(M))/Math.PI-90}function $r(j,M,k,D){let O=D;const G=M+(k-M>>1);let W,Y=k-M;const Z=j[M],st=j[M+1],lt=j[k],et=j[k+1];for(let dt=M+3;dt<k;dt+=3){const At=Hs(j[dt],j[dt+1],Z,st,lt,et);if(At>O)W=dt,O=At;else if(At===O){const Dt=Math.abs(dt-G);Dt<Y&&(W=dt,Y=Dt)}}O>D&&(W-M>3&&$r(j,M,W,D),j[W+2]=O,k-W>3&&$r(j,W,k,D))}function Hs(j,M,k,D,O,G){let W=O-k,Y=G-D;if(W!==0||Y!==0){const Z=((j-k)*W+(M-D)*Y)/(W*W+Y*Y);Z>1?(k=O,D=G):Z>0&&(k+=W*Z,D+=Y*Z)}return W=j-k,Y=M-D,W*W+Y*Y}function pr(j,M,k,D){const O={id:j??null,type:M,geometry:k,tags:D,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(M==="Point"||M==="MultiPoint"||M==="LineString")Sr(O,k);else if(M==="Polygon")Sr(O,k[0]);else if(M==="MultiLineString")for(const G of k)Sr(O,G);else if(M==="MultiPolygon")for(const G of k)Sr(O,G[0]);return O}function Sr(j,M){for(let k=0;k<M.length;k+=3)j.minX=Math.min(j.minX,M[k]),j.minY=Math.min(j.minY,M[k+1]),j.maxX=Math.max(j.maxX,M[k]),j.maxY=Math.max(j.maxY,M[k+1])}function Ir(j,M,k,D){if(!M.geometry)return;const O=M.geometry.coordinates;if(O&&O.length===0)return;const G=M.geometry.type,W=Math.pow(k.tolerance/((1<<k.maxZoom)*k.extent),2);let Y=[],Z=M.id;if(k.promoteId?Z=M.properties[k.promoteId]:k.generateId&&(Z=D||0),G==="Point")us(O,Y);else if(G==="MultiPoint")for(const st of O)us(st,Y);else if(G==="LineString")it(O,Y,W,!1);else if(G==="MultiLineString"){if(k.lineMetrics){for(const st of O)Y=[],it(st,Y,W,!1),j.push(pr(Z,"LineString",Y,M.properties));return}Nr(O,Y,W,!1)}else if(G==="Polygon")Nr(O,Y,W,!0);else{if(G!=="MultiPolygon"){if(G==="GeometryCollection"){for(const st of M.geometry.geometries)Ir(j,{id:Z,geometry:st,properties:M.properties},k,D);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const st of O){const lt=[];Nr(st,lt,W,!0),Y.push(lt)}}j.push(pr(Z,G,Y,M.properties))}function us(j,M){M.push(Ws(j[0]),te(j[1]),0)}function it(j,M,k,D){let O,G,W=0;for(let Z=0;Z<j.length;Z++){const st=Ws(j[Z][0]),lt=te(j[Z][1]);M.push(st,lt,0),Z>0&&(W+=D?(O*lt-st*G)/2:Math.sqrt(Math.pow(st-O,2)+Math.pow(lt-G,2))),O=st,G=lt}const Y=M.length-3;M[2]=1,$r(M,0,Y,k),M[Y+2]=1,M.size=Math.abs(W),M.start=0,M.end=M.size}function Nr(j,M,k,D){for(let O=0;O<j.length;O++){const G=[];it(j[O],G,k,D),M.push(G)}}function Ws(j){return j/360+.5}function te(j){const M=Math.sin(j*Math.PI/180),k=.5-.25*Math.log((1+M)/(1-M))/Math.PI;return k<0?0:k>1?1:k}function ye(j,M,k,D,O,G,W,Y){if(D/=M,G>=(k/=M)&&W<D)return j;if(W<k||G>=D)return null;const Z=[];for(const st of j){const lt=st.geometry;let et=st.type;const dt=O===0?st.minX:st.minY,At=O===0?st.maxX:st.maxY;if(dt>=k&&At<D){Z.push(st);continue}if(At<k||dt>=D)continue;let Dt=[];if(et==="Point"||et==="MultiPoint")Ks(lt,Dt,k,D,O);else if(et==="LineString")kr(lt,Dt,k,D,O,!1,Y.lineMetrics);else if(et==="MultiLineString")hs(lt,Dt,k,D,O,!1);else if(et==="Polygon")hs(lt,Dt,k,D,O,!0);else if(et==="MultiPolygon")for(const Kt of lt){const Ut=[];hs(Kt,Ut,k,D,O,!0),Ut.length&&Dt.push(Ut)}if(Dt.length){if(Y.lineMetrics&&et==="LineString"){for(const Kt of Dt)Z.push(pr(st.id,et,Kt,st.tags));continue}et!=="LineString"&&et!=="MultiLineString"||(Dt.length===1?(et="LineString",Dt=Dt[0]):et="MultiLineString"),et!=="Point"&&et!=="MultiPoint"||(et=Dt.length===3?"Point":"MultiPoint"),Z.push(pr(st.id,et,Dt,st.tags))}}return Z.length?Z:null}function Ks(j,M,k,D,O){for(let G=0;G<j.length;G+=3){const W=j[G+O];W>=k&&W<=D&&bi(M,j[G],j[G+1],j[G+2])}}function kr(j,M,k,D,O,G,W){let Y=fr(j);const Z=O===0?Js:Ys;let st,lt,et=j.start;for(let Ut=0;Ut<j.length-3;Ut+=3){const Jt=j[Ut],Gt=j[Ut+1],ke=j[Ut+2],xe=j[Ut+3],Zt=j[Ut+4],re=O===0?Jt:Gt,ge=O===0?xe:Zt;let Ce=!1;W&&(st=Math.sqrt(Math.pow(Jt-xe,2)+Math.pow(Gt-Zt,2))),re<k?ge>k&&(lt=Z(Y,Jt,Gt,xe,Zt,k),W&&(Y.start=et+st*lt)):re>D?ge<D&&(lt=Z(Y,Jt,Gt,xe,Zt,D),W&&(Y.start=et+st*lt)):bi(Y,Jt,Gt,ke),ge<k&&re>=k&&(lt=Z(Y,Jt,Gt,xe,Zt,k),Ce=!0),ge>D&&re<=D&&(lt=Z(Y,Jt,Gt,xe,Zt,D),Ce=!0),!G&&Ce&&(W&&(Y.end=et+st*lt),M.push(Y),Y=fr(j)),W&&(et+=st)}let dt=j.length-3;const At=j[dt],Dt=j[dt+1],Kt=O===0?At:Dt;Kt>=k&&Kt<=D&&bi(Y,At,Dt,j[dt+2]),dt=Y.length-3,G&&dt>=3&&(Y[dt]!==Y[0]||Y[dt+1]!==Y[1])&&bi(Y,Y[0],Y[1],Y[2]),Y.length&&M.push(Y)}function fr(j){const M=[];return M.size=j.size,M.start=j.start,M.end=j.end,M}function hs(j,M,k,D,O,G){for(const W of j)kr(W,M,k,D,O,G,!1)}function bi(j,M,k,D){j.push(M,k,D)}function Js(j,M,k,D,O,G){const W=(G-M)/(D-M);return bi(j,G,k+(O-k)*W,1),W}function Ys(j,M,k,D,O,G){const W=(G-k)/(O-k);return bi(j,M+(D-M)*W,G,1),W}function ht(j,M){const k=[];for(let D=0;D<j.length;D++){const O=j[D],G=O.type;let W;if(G==="Point"||G==="MultiPoint"||G==="LineString")W=tr(O.geometry,M);else if(G==="MultiLineString"||G==="Polygon"){W=[];for(const Y of O.geometry)W.push(tr(Y,M))}else if(G==="MultiPolygon"){W=[];for(const Y of O.geometry){const Z=[];for(const st of Y)Z.push(tr(st,M));W.push(Z)}}k.push(pr(O.id,G,W,O.tags))}return k}function tr(j,M){const k=[];k.size=j.size,j.start!==void 0&&(k.start=j.start,k.end=j.end);for(let D=0;D<j.length;D+=3)k.push(j[D]+M,j[D+1],j[D+2]);return k}function He(j,M){if(j.transformed)return j;const k=1<<j.z,D=j.x,O=j.y;for(const G of j.features){const W=G.geometry,Y=G.type;if(G.geometry=[],Y===1)for(let Z=0;Z<W.length;Z+=2)G.geometry.push(er(W[Z],W[Z+1],M,k,D,O));else for(let Z=0;Z<W.length;Z++){const st=[];for(let lt=0;lt<W[Z].length;lt+=2)st.push(er(W[Z][lt],W[Z][lt+1],M,k,D,O));G.geometry.push(st)}}return j.transformed=!0,j}function er(j,M,k,D,O,G){return[Math.round(k*(j*D-O)),Math.round(k*(M*D-G))]}function Mr(j,M,k,D,O){const G=M===O.maxZoom?0:O.tolerance/((1<<M)*O.extent),W={features:[],numPoints:0,numSimplified:0,numFeatures:j.length,source:null,x:k,y:D,z:M,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const Y of j)_t(W,Y,G,O);return W}function _t(j,M,k,D){const O=M.geometry,G=M.type,W=[];if(j.minX=Math.min(j.minX,M.minX),j.minY=Math.min(j.minY,M.minY),j.maxX=Math.max(j.maxX,M.maxX),j.maxY=Math.max(j.maxY,M.maxY),G==="Point"||G==="MultiPoint")for(let Y=0;Y<O.length;Y+=3)W.push(O[Y],O[Y+1]),j.numPoints++,j.numSimplified++;else if(G==="LineString")Nt(W,O,j,k,!1,!1);else if(G==="MultiLineString"||G==="Polygon")for(let Y=0;Y<O.length;Y++)Nt(W,O[Y],j,k,G==="Polygon",Y===0);else if(G==="MultiPolygon")for(let Y=0;Y<O.length;Y++){const Z=O[Y];for(let st=0;st<Z.length;st++)Nt(W,Z[st],j,k,!0,st===0)}if(W.length){let Y=M.tags||null;if(G==="LineString"&&D.lineMetrics){Y={};for(const st in M.tags)Y[st]=M.tags[st];Y.mapbox_clip_start=O.start/O.size,Y.mapbox_clip_end=O.end/O.size}const Z={geometry:W,type:G==="Polygon"||G==="MultiPolygon"?3:G==="LineString"||G==="MultiLineString"?2:1,tags:Y};M.id!==null&&(Z.id=M.id),j.features.push(Z)}}function Nt(j,M,k,D,O,G){const W=D*D;if(D>0&&M.size<(O?W:D))return void(k.numPoints+=M.length/3);const Y=[];for(let Z=0;Z<M.length;Z+=3)(D===0||M[Z+2]>W)&&(k.numSimplified++,Y.push(M[Z],M[Z+1])),k.numPoints++;O&&(function(Z,st){let lt=0;for(let et=0,dt=Z.length,At=dt-2;et<dt;At=et,et+=2)lt+=(Z[et]-Z[At])*(Z[et+1]+Z[At+1]);if(lt>0===st)for(let et=0,dt=Z.length;et<dt/2;et+=2){const At=Z[et],Dt=Z[et+1];Z[et]=Z[dt-2-et],Z[et+1]=Z[dt-1-et],Z[dt-2-et]=At,Z[dt-1-et]=Dt}})(Y,G),j.push(Y)}const Ft={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class ei{constructor(M,k){const D=(k=this.options=(function(G,W){for(const Y in W)G[Y]=W[Y];return G})(Object.create(Ft),k)).debug;if(D&&console.time("preprocess data"),k.maxZoom<0||k.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(k.promoteId&&k.generateId)throw new Error("promoteId and generateId cannot be used together.");let O=(function(G,W){const Y=[];if(G.type==="FeatureCollection")for(let Z=0;Z<G.features.length;Z++)Ir(Y,G.features[Z],W,Z);else Ir(Y,G.type==="Feature"?G:{geometry:G},W);return Y})(M,k);this.tiles={},this.tileCoords=[],D&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",k.indexMaxZoom,k.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),O=(function(G,W){const Y=W.buffer/W.extent;let Z=G;const st=ye(G,1,-1-Y,Y,0,-1,2,W),lt=ye(G,1,1-Y,2+Y,0,-1,2,W);return(st||lt)&&(Z=ye(G,1,-Y,1+Y,0,-1,2,W)||[],st&&(Z=ht(st,1).concat(Z)),lt&&(Z=Z.concat(ht(lt,-1)))),Z})(O,k),O.length&&this.splitTile(O,0,0,0),D&&(O.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(M,k,D,O,G,W,Y){const Z=[M,k,D,O],st=this.options,lt=st.debug;for(;Z.length;){O=Z.pop(),D=Z.pop(),k=Z.pop(),M=Z.pop();const et=1<<k,dt=Bi(k,D,O);let At=this.tiles[dt];if(!At&&(lt>1&&console.time("creation"),At=this.tiles[dt]=Mr(M,k,D,O,st),this.tileCoords.push({z:k,x:D,y:O}),lt)){lt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",k,D,O,At.numFeatures,At.numPoints,At.numSimplified),console.timeEnd("creation"));const Ce=`z${k}`;this.stats[Ce]=(this.stats[Ce]||0)+1,this.total++}if(At.source=M,G==null){if(k===st.indexMaxZoom||At.numPoints<=st.indexMaxPoints)continue}else{if(k===st.maxZoom||k===G)continue;if(G!=null){const Ce=G-k;if(D!==W>>Ce||O!==Y>>Ce)continue}}if(At.source=null,M.length===0)continue;lt>1&&console.time("clipping");const Dt=.5*st.buffer/st.extent,Kt=.5-Dt,Ut=.5+Dt,Jt=1+Dt;let Gt=null,ke=null,xe=null,Zt=null,re=ye(M,et,D-Dt,D+Ut,0,At.minX,At.maxX,st),ge=ye(M,et,D+Kt,D+Jt,0,At.minX,At.maxX,st);M=null,re&&(Gt=ye(re,et,O-Dt,O+Ut,1,At.minY,At.maxY,st),ke=ye(re,et,O+Kt,O+Jt,1,At.minY,At.maxY,st),re=null),ge&&(xe=ye(ge,et,O-Dt,O+Ut,1,At.minY,At.maxY,st),Zt=ye(ge,et,O+Kt,O+Jt,1,At.minY,At.maxY,st),ge=null),lt>1&&console.timeEnd("clipping"),Z.push(Gt||[],k+1,2*D,2*O),Z.push(ke||[],k+1,2*D,2*O+1),Z.push(xe||[],k+1,2*D+1,2*O),Z.push(Zt||[],k+1,2*D+1,2*O+1)}}getTile(M,k,D){M=+M,k=+k,D=+D;const O=this.options,{extent:G,debug:W}=O;if(M<0||M>24)return null;const Y=1<<M,Z=Bi(M,k=k+Y&Y-1,D);if(this.tiles[Z])return He(this.tiles[Z],G);W>1&&console.log("drilling down to z%d-%d-%d",M,k,D);let st,lt=M,et=k,dt=D;for(;!st&&lt>0;)lt--,et>>=1,dt>>=1,st=this.tiles[Bi(lt,et,dt)];return st&&st.source?(W>1&&(console.log("found parent tile z%d-%d-%d",lt,et,dt),console.time("drilling down")),this.splitTile(st.source,lt,et,dt,M,k,D),W>1&&console.timeEnd("drilling down"),this.tiles[Z]?He(this.tiles[Z],G):null):null}}function Bi(j,M,k){return 32*((1<<j)*k+M)+j}function jt(j,M){return M?j.properties[M]:j.id}function ir(j,M){if(j==null)return!0;if(j.type==="Feature")return jt(j,M)!=null;if(j.type==="FeatureCollection"){const k=new Set;for(const D of j.features){const O=jt(D,M);if(O==null||k.has(O))return!1;k.add(O)}return!0}return!1}function mr(j,M){const k=new Map;if(j!=null)if(j.type==="Feature")k.set(jt(j,M),j);else for(const D of j.features)k.set(jt(D,M),D);return k}class Er extends mt{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(M,k){return R._(this,void 0,void 0,(function*(){const D=M.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const O=this._geoJSONIndex.getTile(D.z,D.x,D.y);if(!O)return null;const G=new class{constructor(Y){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=R.X,this.length=Y.length,this._features=Y}feature(Y){return new class{constructor(Z){this._feature=Z,this.extent=R.X,this.type=Z.type,this.properties=Z.tags,"id"in Z&&!isNaN(Z.id)&&(this.id=parseInt(Z.id,10))}loadGeometry(){if(this._feature.type===1){const Z=[];for(const st of this._feature.geometry)Z.push([new R.P(st[0],st[1])]);return Z}{const Z=[];for(const st of this._feature.geometry){const lt=[];for(const et of st)lt.push(new R.P(et[0],et[1]));Z.push(lt)}return Z}}toGeoJSON(Z,st,lt){return wr.call(this,Z,st,lt)}}(this._features[Y])}}(O.features);let W=Yi(G);return W.byteOffset===0&&W.byteLength===W.buffer.byteLength||(W=new Uint8Array(W)),{vectorTile:G,rawData:W.buffer}}))}loadData(M){return R._(this,void 0,void 0,(function*(){var k;(k=this._pendingRequest)===null||k===void 0||k.abort();const D=!!(M&&M.request&&M.request.collectResourceTiming)&&new R.bv(M.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(M,this._pendingRequest),this._geoJSONIndex=M.cluster?new Tr((function({superclusterOptions:W,clusterProperties:Y}){if(!Y||!W)return W;const Z={},st={},lt={accumulated:null,zoom:0},et={properties:null},dt=Object.keys(Y);for(const At of dt){const[Dt,Kt]=Y[At],Ut=R.bC(Kt),Jt=R.bC(typeof Dt=="string"?[Dt,["accumulated"],["get",At]]:Dt);Z[At]=Ut.value,st[At]=Jt.value}return W.map=At=>{et.properties=At;const Dt={};for(const Kt of dt)Dt[Kt]=Z[Kt].evaluate(lt,et);return Dt},W.reduce=(At,Dt)=>{et.properties=Dt;for(const Kt of dt)lt.accumulated=At[Kt],At[Kt]=st[Kt].evaluate(lt,et)},W})(M)).load((yield this._pendingData).features):(O=yield this._pendingData,new ei(O,M.geojsonVtOptions)),this.loaded={};const G={};if(D){const W=D.finish();W&&(G.resourceTiming={},G.resourceTiming[M.source]=JSON.parse(JSON.stringify(W)))}return G}catch(G){if(delete this._pendingRequest,R.bB(G))return{abandoned:!0};throw G}var O}))}getData(){return R._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(M){const k=this.loaded;return k&&k[M.uid]?super.reloadTile(M):this.loadTile(M)}loadAndProcessGeoJSON(M,k){return R._(this,void 0,void 0,(function*(){let D=yield this.loadGeoJSON(M,k);if(delete this._pendingRequest,typeof D!="object")throw new Error(`Input data given to '${M.source}' is not a valid GeoJSON object.`);if(Wi(D,!0),M.filter){const O=R.bC(M.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(O.result==="error")throw new Error(O.value.map((G=>`${G.key}: ${G.message}`)).join(", "));D={type:"FeatureCollection",features:D.features.filter((G=>O.value.evaluate({zoom:0},G)))}}return D}))}loadGeoJSON(M,k){return R._(this,void 0,void 0,(function*(){const{promoteId:D}=M;if(M.request){const O=yield R.h(M.request,k);return this._dataUpdateable=ir(O.data,D)?mr(O.data,D):void 0,O.data}if(typeof M.data=="string")try{const O=JSON.parse(M.data);return this._dataUpdateable=ir(O,D)?mr(O,D):void 0,O}catch{throw new Error(`Input data given to '${M.source}' is not a valid GeoJSON object.`)}if(!M.dataDiff)throw new Error(`Input data given to '${M.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${M.source}`);return(function(O,G,W){var Y,Z,st,lt;if(G.removeAll&&O.clear(),G.remove)for(const et of G.remove)O.delete(et);if(G.add)for(const et of G.add){const dt=jt(et,W);dt!=null&&O.set(dt,et)}if(G.update)for(const et of G.update){let dt=O.get(et.id);if(dt==null)continue;const At=!et.removeAllProperties&&(((Y=et.removeProperties)===null||Y===void 0?void 0:Y.length)>0||((Z=et.addOrUpdateProperties)===null||Z===void 0?void 0:Z.length)>0);if((et.newGeometry||et.removeAllProperties||At)&&(dt=Object.assign({},dt),O.set(et.id,dt),At&&(dt.properties=Object.assign({},dt.properties))),et.newGeometry&&(dt.geometry=et.newGeometry),et.removeAllProperties)dt.properties={};else if(((st=et.removeProperties)===null||st===void 0?void 0:st.length)>0)for(const Dt of et.removeProperties)Object.prototype.hasOwnProperty.call(dt.properties,Dt)&&delete dt.properties[Dt];if(((lt=et.addOrUpdateProperties)===null||lt===void 0?void 0:lt.length)>0)for(const{key:Dt,value:Kt}of et.addOrUpdateProperties)dt.properties[Dt]=Kt}})(this._dataUpdateable,M.dataDiff,D),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(M){return R._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(M){return this._geoJSONIndex.getClusterExpansionZoom(M.clusterId)}getClusterChildren(M){return this._geoJSONIndex.getChildren(M.clusterId)}getClusterLeaves(M){return this._geoJSONIndex.getLeaves(M.clusterId,M.limit,M.offset)}}class rr{constructor(M){this.self=M,this.actor=new R.F(M),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(k,D)=>{if(this.externalWorkerSourceTypes[k])throw new Error(`Worker source with name "${k}" already registered.`);this.externalWorkerSourceTypes[k]=D},this.self.addProtocol=R.bi,this.self.removeProtocol=R.bj,this.self.registerRTLTextPlugin=k=>{if(R.bD.isParsed())throw new Error("RTL text plugin already registered.");R.bD.setMethods(k)},this.actor.registerMessageHandler("LDT",((k,D)=>this._getDEMWorkerSource(k,D.source).loadTile(D))),this.actor.registerMessageHandler("RDT",((k,D)=>R._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(k,D.source).removeTile(D)})))),this.actor.registerMessageHandler("GCEZ",((k,D)=>R._(this,void 0,void 0,(function*(){return this._getWorkerSource(k,D.type,D.source).getClusterExpansionZoom(D)})))),this.actor.registerMessageHandler("GCC",((k,D)=>R._(this,void 0,void 0,(function*(){return this._getWorkerSource(k,D.type,D.source).getClusterChildren(D)})))),this.actor.registerMessageHandler("GCL",((k,D)=>R._(this,void 0,void 0,(function*(){return this._getWorkerSource(k,D.type,D.source).getClusterLeaves(D)})))),this.actor.registerMessageHandler("LD",((k,D)=>this._getWorkerSource(k,D.type,D.source).loadData(D))),this.actor.registerMessageHandler("GD",((k,D)=>this._getWorkerSource(k,D.type,D.source).getData())),this.actor.registerMessageHandler("LT",((k,D)=>this._getWorkerSource(k,D.type,D.source).loadTile(D))),this.actor.registerMessageHandler("RT",((k,D)=>this._getWorkerSource(k,D.type,D.source).reloadTile(D))),this.actor.registerMessageHandler("AT",((k,D)=>this._getWorkerSource(k,D.type,D.source).abortTile(D))),this.actor.registerMessageHandler("RMT",((k,D)=>this._getWorkerSource(k,D.type,D.source).removeTile(D))),this.actor.registerMessageHandler("RS",((k,D)=>R._(this,void 0,void 0,(function*(){if(!this.workerSources[k]||!this.workerSources[k][D.type]||!this.workerSources[k][D.type][D.source])return;const O=this.workerSources[k][D.type][D.source];delete this.workerSources[k][D.type][D.source],O.removeSource!==void 0&&O.removeSource(D)})))),this.actor.registerMessageHandler("RM",(k=>R._(this,void 0,void 0,(function*(){delete this.layerIndexes[k],delete this.availableImages[k],delete this.workerSources[k],delete this.demWorkerSources[k]})))),this.actor.registerMessageHandler("SR",((k,D)=>R._(this,void 0,void 0,(function*(){this.referrer=D})))),this.actor.registerMessageHandler("SRPS",((k,D)=>this._syncRTLPluginState(k,D))),this.actor.registerMessageHandler("IS",((k,D)=>R._(this,void 0,void 0,(function*(){this.self.importScripts(D)})))),this.actor.registerMessageHandler("SI",((k,D)=>this._setImages(k,D))),this.actor.registerMessageHandler("UL",((k,D)=>R._(this,void 0,void 0,(function*(){this._getLayerIndex(k).update(D.layers,D.removedIds)})))),this.actor.registerMessageHandler("SL",((k,D)=>R._(this,void 0,void 0,(function*(){this._getLayerIndex(k).replace(D)}))))}_setImages(M,k){return R._(this,void 0,void 0,(function*(){this.availableImages[M]=k;for(const D in this.workerSources[M]){const O=this.workerSources[M][D];for(const G in O)O[G].availableImages=k}}))}_syncRTLPluginState(M,k){return R._(this,void 0,void 0,(function*(){if(R.bD.isParsed())return R.bD.getState();if(k.pluginStatus!=="loading")return R.bD.setState(k),k;const D=k.pluginURL;if(this.self.importScripts(D),R.bD.isParsed()){const O={pluginStatus:"loaded",pluginURL:D};return R.bD.setState(O),O}throw R.bD.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${D}`)}))}_getAvailableImages(M){let k=this.availableImages[M];return k||(k=[]),k}_getLayerIndex(M){let k=this.layerIndexes[M];return k||(k=this.layerIndexes[M]=new p),k}_getWorkerSource(M,k,D){if(this.workerSources[M]||(this.workerSources[M]={}),this.workerSources[M][k]||(this.workerSources[M][k]={}),!this.workerSources[M][k][D]){const O={sendAsync:(G,W)=>(G.targetMapId=M,this.actor.sendAsync(G,W))};switch(k){case"vector":this.workerSources[M][k][D]=new mt(O,this._getLayerIndex(M),this._getAvailableImages(M));break;case"geojson":this.workerSources[M][k][D]=new Er(O,this._getLayerIndex(M),this._getAvailableImages(M));break;default:this.workerSources[M][k][D]=new this.externalWorkerSourceTypes[k](O,this._getLayerIndex(M),this._getAvailableImages(M))}}return this.workerSources[M][k][D]}_getDEMWorkerSource(M,k){return this.demWorkerSources[M]||(this.demWorkerSources[M]={}),this.demWorkerSources[M][k]||(this.demWorkerSources[M][k]=new at),this.demWorkerSources[M][k]}}return R.i(self)&&(self.worker=new rr(self)),rr})),Or("index",["exports","./shared"],(function(R,p){"use strict";var Pi="4.7.1";let Hi,Ge;const mt={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:u=>new Promise(((t,s)=>{const n=requestAnimationFrame(t);u.signal.addEventListener("abort",(()=>{cancelAnimationFrame(n),s(p.c())}))})),getImageData(u,t=0){return this.getImageCanvasContext(u).getImageData(-t,-t,u.width+2*t,u.height+2*t)},getImageCanvasContext(u){const t=window.document.createElement("canvas"),s=t.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("failed to create canvas 2d context");return t.width=u.width,t.height=u.height,s.drawImage(u,0,0,u.width,u.height),s},resolveURL:u=>(Hi||(Hi=document.createElement("a")),Hi.href=u,Hi.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(Ge==null&&(Ge=matchMedia("(prefers-reduced-motion: reduce)")),Ge.matches)}};class at{static testProp(t){if(!at.docStyle)return t[0];for(let s=0;s<t.length;s++)if(t[s]in at.docStyle)return t[s];return t[0]}static create(t,s,n){const o=window.document.createElement(t);return s!==void 0&&(o.className=s),n&&n.appendChild(o),o}static createNS(t,s){return window.document.createElementNS(t,s)}static disableDrag(){at.docStyle&&at.selectProp&&(at.userSelect=at.docStyle[at.selectProp],at.docStyle[at.selectProp]="none")}static enableDrag(){at.docStyle&&at.selectProp&&(at.docStyle[at.selectProp]=at.userSelect)}static setTransform(t,s){t.style[at.transformProp]=s}static addEventListener(t,s,n,o={}){t.addEventListener(s,n,"passive"in o?o:o.capture)}static removeEventListener(t,s,n,o={}){t.removeEventListener(s,n,"passive"in o?o:o.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",at.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",at.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",at.suppressClickInternal,!0)}),0)}static getScale(t){const s=t.getBoundingClientRect();return{x:s.width/t.offsetWidth||1,y:s.height/t.offsetHeight||1,boundingClientRect:s}}static getPoint(t,s,n){const o=s.boundingClientRect;return new p.P((n.clientX-o.left)/s.x-t.clientLeft,(n.clientY-o.top)/s.y-t.clientTop)}static mousePos(t,s){const n=at.getScale(t);return at.getPoint(t,n,s)}static touchPos(t,s){const n=[],o=at.getScale(t);for(let c=0;c<s.length;c++)n.push(at.getPoint(t,o,s[c]));return n}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}}at.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,at.selectProp=at.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),at.transformProp=at.testProp(["transform","WebkitTransform"]);const Vr={supported:!1,testSupport:function(u){!wr&&Wi&&(ur?Gs(u):br=u)}};let br,Wi,wr=!1,ur=!1;function Gs(u){const t=u.createTexture();u.bindTexture(u.TEXTURE_2D,t);try{if(u.texImage2D(u.TEXTURE_2D,0,u.RGBA,u.RGBA,u.UNSIGNED_BYTE,Wi),u.isContextLost())return;Vr.supported=!0}catch{}u.deleteTexture(t),wr=!0}var ui;typeof document<"u"&&(Wi=document.createElement("img"),Wi.onload=()=>{br&&Gs(br),br=null,ur=!0},Wi.onerror=()=>{wr=!0,br=null},Wi.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),(function(u){let t,s,n,o;u.resetRequestQueue=()=>{t=[],s=0,n=0,o={}},u.addThrottleControl=y=>{const b=n++;return o[b]=y,b},u.removeThrottleControl=y=>{delete o[y],m()},u.getImage=(y,b,T=!0)=>new Promise(((S,z)=>{Vr.supported&&(y.headers||(y.headers={}),y.headers.accept="image/webp,*/*"),p.e(y,{type:"image"}),t.push({abortController:b,requestParameters:y,supportImageRefresh:T,state:"queued",onError:A=>{z(A)},onSuccess:A=>{S(A)}}),m()}));const c=y=>p._(this,void 0,void 0,(function*(){y.state="running";const{requestParameters:b,supportImageRefresh:T,onError:S,onSuccess:z,abortController:A}=y,B=T===!1&&!p.i(self)&&!p.g(b.url)&&(!b.headers||Object.keys(b.headers).reduce(((N,q)=>N&&q==="accept"),!0));s++;const V=B?g(b,A):p.m(b,A);try{const N=yield V;delete y.abortController,y.state="completed",N.data instanceof HTMLImageElement||p.b(N.data)?z(N):N.data&&z({data:yield($=N.data,typeof createImageBitmap=="function"?p.d($):p.f($)),cacheControl:N.cacheControl,expires:N.expires})}catch(N){delete y.abortController,S(N)}finally{s--,m()}var $})),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=s;b<y&&t.length>0;b++){const T=t.shift();T.abortController.signal.aborted?b--:c(T)}},g=(y,b)=>new Promise(((T,S)=>{const z=new Image,A=y.url,B=y.credentials;B&&B==="include"?z.crossOrigin="use-credentials":(B&&B==="same-origin"||!p.s(A))&&(z.crossOrigin="anonymous"),b.signal.addEventListener("abort",(()=>{z.src="",S(p.c())})),z.fetchPriority="high",z.onload=()=>{z.onerror=z.onload=null,T({data:z})},z.onerror=()=>{z.onerror=z.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."))},z.src=A}))})(ui||(ui={})),ui.resetRequestQueue();class Sn{constructor(t){this._transformRequestFn=t}transformRequest(t,s){return this._transformRequestFn&&this._transformRequestFn(t,s)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function Ai(u){var t=new p.A(3);return t[0]=u[0],t[1]=u[1],t[2]=u[2],t}var Ki,vi=function(u,t,s){return u[0]=t[0]-s[0],u[1]=t[1]-s[1],u[2]=t[2]-s[2],u};Ki=new p.A(3),p.A!=Float32Array&&(Ki[0]=0,Ki[1]=0,Ki[2]=0);var Ia=function(u){var t=u[0],s=u[1];return t*t+s*s};function Ji(u){const t=[];if(typeof u=="string")t.push({id:"default",url:u});else if(u&&u.length>0){const s=[];for(const{id:n,url:o}of u){const c=`${n}${o}`;s.indexOf(c)===-1&&(s.push(c),t.push({id:n,url:o}))}}return t}function Xs(u,t,s){const n=u.split("?");return n[0]+=`${t}${s}`,n.join("?")}(function(){var u=new p.A(2);p.A!=Float32Array&&(u[0]=0,u[1]=0)})();class ae{constructor(t,s,n,o){this.context=t,this.format=n,this.texture=t.gl.createTexture(),this.update(s,o)}update(t,s,n){const{width:o,height:c}=t,m=!(this.size&&this.size[0]===o&&this.size[1]===c||n),{context:g}=this,{gl:y}=g;if(this.useMipmap=!!(s&&s.useMipmap),y.bindTexture(y.TEXTURE_2D,this.texture),g.pixelStoreUnpackFlipY.set(!1),g.pixelStoreUnpack.set(1),g.pixelStoreUnpackPremultiplyAlpha.set(this.format===y.RGBA&&(!s||s.premultiply!==!1)),m)this.size=[o,c],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||p.b(t)?y.texImage2D(y.TEXTURE_2D,0,this.format,this.format,y.UNSIGNED_BYTE,t):y.texImage2D(y.TEXTURE_2D,0,this.format,o,c,0,this.format,y.UNSIGNED_BYTE,t.data);else{const{x:b,y:T}=n||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||p.b(t)?y.texSubImage2D(y.TEXTURE_2D,0,b,T,y.RGBA,y.UNSIGNED_BYTE,t):y.texSubImage2D(y.TEXTURE_2D,0,b,T,o,c,y.RGBA,y.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&y.generateMipmap(y.TEXTURE_2D)}bind(t,s,n){const{context:o}=this,{gl:c}=o;c.bindTexture(c.TEXTURE_2D,this.texture),n!==c.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(n=c.LINEAR),t!==this.filter&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,t),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,n||t),this.filter=t),s!==this.wrap&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,s),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,s),this.wrap=s)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function ka(u){const{userImage:t}=u;return!!(t&&t.render&&t.render())&&(u.data.replace(new Uint8Array(t.data.buffer)),!0)}class Le 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(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:s,promiseResolve:n}of this.requestors)n(this._getImagesForIds(s));this.requestors=[]}}getImage(t){const s=this.images[t];if(s&&!s.data&&s.spriteData){const n=s.spriteData;s.data=new p.R({width:n.width,height:n.height},n.context.getImageData(n.x,n.y,n.width,n.height).data),s.spriteData=null}return s}addImage(t,s){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,s)&&(this.images[t]=s)}_validate(t,s){let n=!0;const o=s.data||s.spriteData;return this._validateStretch(s.stretchX,o&&o.width)||(this.fire(new p.j(new Error(`Image "${t}" has invalid "stretchX" value`))),n=!1),this._validateStretch(s.stretchY,o&&o.height)||(this.fire(new p.j(new Error(`Image "${t}" has invalid "stretchY" value`))),n=!1),this._validateContent(s.content,s)||(this.fire(new p.j(new Error(`Image "${t}" has invalid "content" value`))),n=!1),n}_validateStretch(t,s){if(!t)return!0;let n=0;for(const o of t){if(o[0]<n||o[1]<o[0]||s<o[1])return!1;n=o[1]}return!0}_validateContent(t,s){if(!t)return!0;if(t.length!==4)return!1;const n=s.spriteData,o=n&&n.width||s.data.width,c=n&&n.height||s.data.height;return!(t[0]<0||o<t[0]||t[1]<0||c<t[1]||t[2]<0||o<t[2]||t[3]<0||c<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,s,n=!0){const o=this.getImage(t);if(n&&(o.data.width!==s.data.width||o.data.height!==s.data.height))throw new Error(`size mismatch between old image (${o.data.width}x${o.data.height}) and new image (${s.data.width}x${s.data.height}).`);s.version=o.version+1,this.images[t]=s,this.updatedImages[t]=!0}removeImage(t){const s=this.images[t];delete this.images[t],delete this.patterns[t],s.userImage&&s.userImage.onRemove&&s.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t){return new Promise(((s,n)=>{let o=!0;if(!this.isLoaded())for(const c of t)this.images[c]||(o=!1);this.isLoaded()||o?s(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:s})}))}_getImagesForIds(t){const s={};for(const n of t){let o=this.getImage(n);o||(this.fire(new p.k("styleimagemissing",{id:n})),o=this.getImage(n)),o?s[n]={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 "${n}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return s}getPixelSize(){const{width:t,height:s}=this.atlasImage;return{width:t,height:s}}getPattern(t){const s=this.patterns[t],n=this.getImage(t);if(!n)return null;if(s&&s.position.version===n.version)return s.position;if(s)s.position.version=n.version;else{const o={w:n.data.width+2,h:n.data.height+2,x:0,y:0},c=new p.I(o,n);this.patterns[t]={bin:o,position:c}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const s=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new ae(t,this.atlasImage,s.RGBA),this.atlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const c in this.patterns)t.push(this.patterns[c].bin);const{w:s,h:n}=p.p(t),o=this.atlasImage;o.resize({width:s||1,height:n||1});for(const c in this.patterns){const{bin:m}=this.patterns[c],g=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:g,y},{width:T,height:S}),p.R.copy(b,o,{x:0,y:S-1},{x:g,y:y-1},{width:T,height:1}),p.R.copy(b,o,{x:0,y:0},{x:g,y:y+S},{width:T,height:1}),p.R.copy(b,o,{x:T-1,y:0},{x:g-1,y},{width:1,height:S}),p.R.copy(b,o,{x:0,y:0},{x:g+T,y},{width:1,height:S})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const s of t){if(this.callbackDispatchedThisFrame[s])continue;this.callbackDispatchedThisFrame[s]=!0;const n=this.getImage(s);n||p.w(`Image with ID: "${s}" was not found`),ka(n)&&this.updateImage(s,n)}}}const Xe=1e20;function hr(u,t,s,n,o,c,m,g,y){for(let b=t;b<t+n;b++)os(u,s*c+b,c,o,m,g,y);for(let b=s;b<s+o;b++)os(u,b*c+t,1,n,m,g,y)}function os(u,t,s,n,o,c,m){c[0]=0,m[0]=-Xe,m[1]=Xe,o[0]=u[t];for(let g=1,y=0,b=0;g<n;g++){o[g]=u[t+g*s];const T=g*g;do{const S=c[y];b=(o[g]-o[S]+T-S*S)/(g-S)/2}while(b<=m[y]&&--y>-1);y++,c[y]=g,m[y]=b,m[y+1]=Xe}for(let g=0,y=0;g<n;g++){for(;m[y+1]<g;)y++;const b=c[y],T=g-b;u[t+g*s]=o[b]+T*T}}class Yi{constructor(t,s){this.requestManager=t,this.localIdeographFontFamily=s,this.entries={}}setURL(t){this.url=t}getGlyphs(t){return p._(this,void 0,void 0,(function*(){const s=[];for(const c in t)for(const m of t[c])s.push(this._getAndCacheGlyphsPromise(c,m));const n=yield Promise.all(s),o={};for(const{stack:c,id:m,glyph:g}of n)o[c]||(o[c]={}),o[c][m]=g&&{id:g.id,bitmap:g.bitmap.clone(),metrics:g.metrics};return o}))}_getAndCacheGlyphsPromise(t,s){return p._(this,void 0,void 0,(function*(){let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{}});let o=n.glyphs[s];if(o!==void 0)return{stack:t,id:s,glyph:o};if(o=this._tinySDF(n,t,s),o)return n.glyphs[s]=o,{stack:t,id:s,glyph:o};const c=Math.floor(s/256);if(256*c>65535)throw new Error("glyphs > 65535 not supported");if(n.ranges[c])return{stack:t,id:s,glyph:o};if(!this.url)throw new Error("glyphsUrl is not set");if(!n.requests[c]){const g=Yi.loadGlyphRange(t,c,this.url,this.requestManager);n.requests[c]=g}const m=yield n.requests[c];for(const g in m)this._doesCharSupportLocalGlyph(+g)||(n.glyphs[+g]=m[+g]);return n.ranges[c]=!0,{stack:t,id:s,glyph:m[s]||null}}))}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&new RegExp("\\p{Ideo}|\\p{sc=Hang}|\\p{sc=Hira}|\\p{sc=Kana}","u").test(String.fromCodePoint(t))}_tinySDF(t,s,n){const o=this.localIdeographFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let c=t.tinySDF;if(!c){let g="400";/bold/i.test(s)?g="900":/medium/i.test(s)?g="500":/light/i.test(s)&&(g="200"),c=t.tinySDF=new Yi.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:g})}const m=c.draw(String.fromCharCode(n));return{id:n,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}}}}Yi.loadGlyphRange=function(u,t,s,n){return p._(this,void 0,void 0,(function*(){const o=256*t,c=o+255,m=n.transformRequest(s.replace("{fontstack}",u).replace("{range}",`${o}-${c}`),"Glyphs"),g=yield p.l(m,new AbortController);if(!g||!g.data)throw new Error(`Could not load glyph range. range: ${t}, ${o}-${c}`);const y={};for(const b of p.n(g.data))y[b.id]=b;return y}))},Yi.TinySDF=class{constructor({fontSize:u=24,buffer:t=3,radius:s=8,cutoff:n=.25,fontFamily:o="sans-serif",fontWeight:c="normal",fontStyle:m="normal"}={}){this.buffer=t,this.cutoff=n,this.radius=s;const g=this.size=u+4*t,y=this._createCanvas(g),b=this.ctx=y.getContext("2d",{willReadFrequently:!0});b.font=`${m} ${c} ${u}px ${o}`,b.textBaseline="alphabetic",b.textAlign="left",b.fillStyle="black",this.gridOuter=new Float64Array(g*g),this.gridInner=new Float64Array(g*g),this.f=new Float64Array(g),this.z=new Float64Array(g+1),this.v=new Uint16Array(g)}_createCanvas(u){const t=document.createElement("canvas");return t.width=t.height=u,t}draw(u){const{width:t,actualBoundingBoxAscent:s,actualBoundingBoxDescent:n,actualBoundingBoxLeft:o,actualBoundingBoxRight:c}=this.ctx.measureText(u),m=Math.ceil(s),g=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(c-o))),y=Math.min(this.size-this.buffer,m+Math.ceil(n)),b=g+2*this.buffer,T=y+2*this.buffer,S=Math.max(b*T,0),z=new Uint8ClampedArray(S),A={data:z,width:b,height:T,glyphWidth:g,glyphHeight:y,glyphTop:m,glyphLeft:0,glyphAdvance:t};if(g===0||y===0)return A;const{ctx:B,buffer:V,gridInner:$,gridOuter:N}=this;B.clearRect(V,V,g,y),B.fillText(u,V,V+m);const q=B.getImageData(V,V,g,y);N.fill(Xe,0,S),$.fill(0,0,S);for(let F=0;F<y;F++)for(let H=0;H<g;H++){const K=q.data[4*(F*g+H)+3]/255;if(K===0)continue;const tt=(F+V)*b+H+V;if(K===1)N[tt]=0,$[tt]=Xe;else{const ot=.5-K;N[tt]=ot>0?ot*ot:0,$[tt]=ot<0?ot*ot:0}}hr(N,0,0,b,T,b,this.f,this.v,this.z),hr($,V,V,g,y,b,this.f,this.v,this.z);for(let F=0;F<S;F++){const H=Math.sqrt(N[F])-Math.sqrt($[F]);z[F]=Math.round(255-255*(H/this.radius+this.cutoff))}return A}};class Ma{constructor(){this.specification=p.v.light.position}possiblyEvaluate(t,s){return p.x(t.expression.evaluate(s))}interpolate(t,s,n){return{x:p.y.number(t.x,s.x,n),y:p.y.number(t.y,s.y,n),z:p.y.number(t.z,s.z,n)}}}let jr;class dr extends p.E{constructor(t){super(),jr=jr||new p.q({anchor:new p.D(p.v.light.anchor),position:new Ma,color:new p.D(p.v.light.color),intensity:new p.D(p.v.light.intensity)}),this._transitionable=new p.T(jr),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,s={}){if(!this._validate(p.r,t,s))for(const n in t){const o=t[n];n.endsWith("-transition")?this._transitionable.setTransition(n.slice(0,-11),o):this._transitionable.setValue(n,o)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,s,n){return(!n||n.validate!==!1)&&p.t(this,t.call(p.u,{value:s,style:{glyphs:!0,sprite:!0},styleSpec:p.v}))}}const ti=new p.q({"sky-color":new p.D(p.v.sky["sky-color"]),"horizon-color":new p.D(p.v.sky["horizon-color"]),"fog-color":new p.D(p.v.sky["fog-color"]),"fog-ground-blend":new p.D(p.v.sky["fog-ground-blend"]),"horizon-fog-blend":new p.D(p.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new p.D(p.v.sky["sky-horizon-blend"]),"atmosphere-blend":new p.D(p.v.sky["atmosphere-blend"])});class Di extends p.E{constructor(t){super(),this._transitionable=new p.T(ti),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new p.z(0))}setSky(t,s={}){if(!this._validate(p.B,t,s)){t||(t={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const n in t){const o=t[n];n.endsWith("-transition")?this._transitionable.setTransition(n.slice(0,-11),o):this._transitionable.setValue(n,o)}}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,s,n={}){return(n==null?void 0:n.validate)!==!1&&p.t(this,t.call(p.u,p.e({value:s,style:{glyphs:!0,sprite:!0},styleSpec:p.v})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class ls{constructor(t,s){this.width=t,this.height=s,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,s){const n=t.join(",")+String(s);return this.dashEntry[n]||(this.dashEntry[n]=this.addDash(t,s)),this.dashEntry[n]}getDashRanges(t,s,n){const o=[];let c=t.length%2==1?-t[t.length-1]*n:0,m=t[0]*n,g=!0;o.push({left:c,right:m,isDash:g,zeroLength:t[0]===0});let y=t[0];for(let b=1;b<t.length;b++){g=!g;const T=t[b];c=y*n,y+=T,m=y*n,o.push({left:c,right:m,isDash:g,zeroLength:T===0})}return o}addRoundDash(t,s,n){const o=s/2;for(let c=-n;c<=n;c++){const m=this.width*(this.nextRow+n+c);let g=0,y=t[g];for(let b=0;b<this.width;b++){b/y.right>1&&(y=t[++g]);const T=Math.abs(b-y.left),S=Math.abs(b-y.right),z=Math.min(T,S);let A;const B=c/n*(o+1);if(y.isDash){const V=o-Math.abs(B);A=Math.sqrt(z*z+V*V)}else A=o-Math.sqrt(z*z+B*B);this.data[m+b]=Math.max(0,Math.min(255,A+128))}}}addRegularDash(t){for(let g=t.length-1;g>=0;--g){const y=t[g],b=t[g+1];y.zeroLength?t.splice(g,1):b&&b.isDash===y.isDash&&(b.left=y.left,t.splice(g,1))}const s=t[0],n=t[t.length-1];s.isDash===n.isDash&&(s.left=n.left-this.width,n.right=s.right+this.width);const o=this.width*this.nextRow;let c=0,m=t[c];for(let g=0;g<this.width;g++){g/m.right>1&&(m=t[++c]);const y=Math.abs(g-m.left),b=Math.abs(g-m.right),T=Math.min(y,b);this.data[o+g]=Math.max(0,Math.min(255,(m.isDash?T:-T)+128))}}addDash(t,s){const n=s?7:0,o=2*n+1;if(this.nextRow+o>this.height)return p.w("LineAtlas out of space"),null;let c=0;for(let g=0;g<t.length;g++)c+=t[g];if(c!==0){const g=this.width/c,y=this.getDashRanges(t,this.width,g);s?this.addRoundDash(y,g,n):this.addRegularDash(y)}const m={y:(this.nextRow+n+.5)/this.height,height:2*n/this.height,width:c};return this.nextRow+=o,this.dirty=!0,m}bind(t){const s=t.gl;this.texture?(s.bindTexture(s.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,s.texSubImage2D(s.TEXTURE_2D,0,0,0,this.width,this.height,s.ALPHA,s.UNSIGNED_BYTE,this.data))):(this.texture=s.createTexture(),s.bindTexture(s.TEXTURE_2D,this.texture),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.REPEAT),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.REPEAT),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texImage2D(s.TEXTURE_2D,0,s.ALPHA,this.width,this.height,0,s.ALPHA,s.UNSIGNED_BYTE,this.data))}}const Tr="maplibre_preloaded_worker_pool";class Qi{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Qi.workerCount;)this.workers.push(new Worker(p.a.WORKER_URL));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.numActive()===0&&(this.workers.forEach((s=>{s.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Tr]}numActive(){return Object.keys(this.active).length}}const cs=Math.floor(mt.hardwareConcurrency/2);let hi,Ri;function Ur(){return hi||(hi=new Qi),hi}Qi.workerCount=p.C(globalThis)?Math.max(Math.min(cs,3),1):1;class $r{constructor(t,s){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=s;const n=this.workerPool.acquire(s);for(let o=0;o<n.length;o++){const c=new p.F(n[o],s);c.name=`Worker ${o}`,this.actors.push(c)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,s){const n=[];for(const o of this.actors)n.push(o.sendAsync({type:t,data:s}));return Promise.all(n)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach((s=>{s.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,s){for(const n of this.actors)n.registerMessageHandler(t,s)}}function Hs(){return Ri||(Ri=new $r(Ur(),p.G),Ri.registerMessageHandler("GR",((u,t,s)=>p.m(t,s)))),Ri}function pr(u,t){const s=p.H();return p.J(s,s,[1,1,0]),p.K(s,s,[.5*u.width,.5*u.height,1]),p.L(s,s,u.calculatePosMatrix(t.toUnwrapped()))}function Sr(u,t,s,n,o,c){const m=(function(S,z,A){if(S)for(const B of S){const V=z[B];if(V&&V.source===A&&V.type==="fill-extrusion")return!0}else for(const B in z){const V=z[B];if(V.source===A&&V.type==="fill-extrusion")return!0}return!1})(o&&o.layers,t,u.id),g=c.maxPitchScaleFactor(),y=u.tilesIn(n,g,m);y.sort(Ir);const b=[];for(const S of y)b.push({wrappedTileID:S.tileID.wrapped().key,queryResults:S.tile.queryRenderedFeatures(t,s,u._state,S.queryGeometry,S.cameraQueryGeometry,S.scale,o,c,g,pr(u.transform,S.tileID))});const T=(function(S){const z={},A={};for(const B of S){const V=B.queryResults,$=B.wrappedTileID,N=A[$]=A[$]||{};for(const q in V){const F=V[q],H=N[q]=N[q]||{},K=z[q]=z[q]||[];for(const tt of F)H[tt.featureIndex]||(H[tt.featureIndex]=!0,K.push(tt))}}return z})(b);for(const S in T)T[S].forEach((z=>{const A=z.feature,B=u.getFeatureState(A.layer["source-layer"],A.id);A.source=A.layer.source,A.layer["source-layer"]&&(A.sourceLayer=A.layer["source-layer"]),A.state=B}));return T}function Ir(u,t){const s=u.tileID,n=t.tileID;return s.overscaledZ-n.overscaledZ||s.canonical.y-n.canonical.y||s.wrap-n.wrap||s.canonical.x-n.canonical.x}function us(u,t,s){return p._(this,void 0,void 0,(function*(){let n=u;if(u.url?n=(yield p.h(t.transformRequest(u.url,"Source"),s)).data:yield mt.frameAsync(s),!n)return null;const o=p.M(p.e(n,u),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in n&&n.vector_layers&&(o.vectorLayerIds=n.vector_layers.map((c=>c.id))),o}))}class it{constructor(t,s){t&&(s?this.setSouthWest(t).setNorthEast(s):Array.isArray(t)&&(t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof p.N?new p.N(t.lng,t.lat):p.N.convert(t),this}setSouthWest(t){return this._sw=t instanceof p.N?new p.N(t.lng,t.lat):p.N.convert(t),this}extend(t){const s=this._sw,n=this._ne;let o,c;if(t instanceof p.N)o=t,c=t;else{if(!(t instanceof it))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(it.convert(t)):this.extend(p.N.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(p.N.convert(t)):this;if(o=t._sw,c=t._ne,!o||!c)return this}return s||n?(s.lng=Math.min(o.lng,s.lng),s.lat=Math.min(o.lat,s.lat),n.lng=Math.max(c.lng,n.lng),n.lat=Math.max(c.lat,n.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(t){const{lng:s,lat:n}=p.N.convert(t);let o=this._sw.lng<=s&&s<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=s&&s>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(t){return t instanceof it?t:t&&new it(t)}static fromLngLat(t,s=0){const n=360*s/40075017,o=n/Math.cos(Math.PI/180*t.lat);return new it(new p.N(t.lng-o,t.lat-n),new p.N(t.lng+o,t.lat+n))}adjustAntiMeridian(){const t=new p.N(this._sw.lng,this._sw.lat),s=new p.N(this._ne.lng,this._ne.lat);return new it(t,t.lng>s.lng?new p.N(s.lng+360,s.lat):s)}}class Nr{constructor(t,s,n){this.bounds=it.convert(this.validateBounds(t)),this.minzoom=s||0,this.maxzoom=n||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const s=Math.pow(2,t.z),n=Math.floor(p.O(this.bounds.getWest())*s),o=Math.floor(p.Q(this.bounds.getNorth())*s),c=Math.ceil(p.O(this.bounds.getEast())*s),m=Math.ceil(p.Q(this.bounds.getSouth())*s);return t.x>=n&&t.x<c&&t.y>=o&&t.y<m}}class Ws extends p.E{constructor(t,s,n,o){if(super(),this.id=t,this.dispatcher=n,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,p.e(this,p.M(s,["url","scheme","tileSize","promoteId"])),this._options=p.e({type:"vector"},s),this._collectResourceTiming=s.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(o)}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 t=yield us(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),t&&(p.e(this,t),t.bounds&&(this.tileBounds=new Nr(t.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(t){this._tileJSONRequest=null,this.fire(new p.j(t))}}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.abort(),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return p.e({},this._options)}loadTile(t){return p._(this,void 0,void 0,(function*(){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n={request:this.map._requestManager.transformRequest(s,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};n.request.collectResourceTiming=this._collectResourceTiming;let o="RT";if(t.actor&&t.state!=="expired"){if(t.state==="loading")return new Promise(((c,m)=>{t.reloadPromise={resolve:c,reject:m}}))}else t.actor=this.dispatcher.getActor(),o="LT";t.abortController=new AbortController;try{const c=yield t.actor.sendAsync({type:o,data:n},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,c)}catch(c){if(delete t.abortController,t.aborted)return;if(c&&c.status!==404)throw c;this._afterTileLoadWorkerResponse(t,null)}}))}_afterTileLoadWorkerResponse(t,s){if(s&&s.resourceTiming&&(t.resourceTiming=s.resourceTiming),s&&this.map._refreshExpiredTiles&&t.setExpiryData(s),t.loadVectorData(s,this.map.painter),t.reloadPromise){const n=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(n.resolve).catch(n.reject)}}abortTile(t){return p._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}unloadTile(t){return p._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class te extends p.E{constructor(t,s,n,o){super(),this.id=t,this.dispatcher=n,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"},s),p.e(this,p.M(s,["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 t=yield us(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,t&&(p.e(this,t),t.bounds&&(this.tileBounds=new Nr(t.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(t){this._tileJSONRequest=null,this.fire(new p.j(t))}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return p.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return p._(this,void 0,void 0,(function*(){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const n=yield ui.getImage(this.map._requestManager.transformRequest(s,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(n&&n.data){this.map._refreshExpiredTiles&&n.cacheControl&&n.expires&&t.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});const o=this.map.painter.context,c=o.gl,m=n.data;t.texture=this.map.painter.getTileTexture(m.width),t.texture?t.texture.update(m,{useMipmap:!0}):(t.texture=new ae(o,m,c.RGBA,{useMipmap:!0}),t.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE,c.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(n){if(delete t.abortController,t.aborted)t.state="unloaded";else if(n)throw t.state="errored",n}}))}abortTile(t){return p._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)}))}unloadTile(t){return p._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)}))}hasTransition(){return!1}}class ye extends te{constructor(t,s,n,o){super(t,s,n,o),this.type="raster-dem",this.maxzoom=22,this._options=p.e({type:"raster-dem"},s),this.encoding=s.encoding||"mapbox",this.redFactor=s.redFactor,this.greenFactor=s.greenFactor,this.blueFactor=s.blueFactor,this.baseShift=s.baseShift}loadTile(t){return p._(this,void 0,void 0,(function*(){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n=this.map._requestManager.transformRequest(s,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const o=yield ui.getImage(n,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(o&&o.data){const c=o.data;this.map._refreshExpiredTiles&&o.cacheControl&&o.expires&&t.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});const m=p.b(c)&&p.U()?c:yield this.readImageNow(c),g={type:this.type,uid:t.uid,source:this.id,rawImageData:m,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||t.state==="expired"){t.actor=this.dispatcher.getActor();const y=yield t.actor.sendAsync({type:"LDT",data:g});t.dem=y,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}}catch(o){if(delete t.abortController,t.aborted)t.state="unloaded";else if(o)throw t.state="errored",o}}))}readImageNow(t){return p._(this,void 0,void 0,(function*(){if(typeof VideoFrame<"u"&&p.V()){const s=t.width+2,n=t.height+2;try{return new p.R({width:s,height:n},yield p.W(t,-1,-1,s,n))}catch{}}return mt.getImageData(t,1)}))}_getNeighboringTiles(t){const s=t.canonical,n=Math.pow(2,s.z),o=(s.x-1+n)%n,c=s.x===0?t.wrap-1:t.wrap,m=(s.x+1+n)%n,g=s.x+1===n?t.wrap+1:t.wrap,y={};return y[new p.S(t.overscaledZ,c,s.z,o,s.y).key]={backfilled:!1},y[new p.S(t.overscaledZ,g,s.z,m,s.y).key]={backfilled:!1},s.y>0&&(y[new p.S(t.overscaledZ,c,s.z,o,s.y-1).key]={backfilled:!1},y[new p.S(t.overscaledZ,t.wrap,s.z,s.x,s.y-1).key]={backfilled:!1},y[new p.S(t.overscaledZ,g,s.z,m,s.y-1).key]={backfilled:!1}),s.y+1<n&&(y[new p.S(t.overscaledZ,c,s.z,o,s.y+1).key]={backfilled:!1},y[new p.S(t.overscaledZ,t.wrap,s.z,s.x,s.y+1).key]={backfilled:!1},y[new p.S(t.overscaledZ,g,s.z,m,s.y+1).key]={backfilled:!1}),y}unloadTile(t){return p._(this,void 0,void 0,(function*(){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&(yield t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}}))}))}}class Ks extends p.E{constructor(t,s,n,o){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=n.getActor(),this.setEventedParent(o),this._data=s.data,this._options=p.e({},s),this._collectResourceTiming=s.collectResourceTiming,s.maxzoom!==void 0&&(this.maxzoom=s.maxzoom),s.type&&(this.type=s.type),s.attribution&&(this.attribution=s.attribution),this.promoteId=s.promoteId;const c=p.X/this.tileSize;s.clusterMaxZoom!==void 0&&this.maxzoom<=s.clusterMaxZoom&&p.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${s.clusterMaxZoom}".`),this.workerOptions=p.e({source:this.id,cluster:s.cluster||!1,geojsonVtOptions:{buffer:(s.buffer!==void 0?s.buffer:128)*c,tolerance:(s.tolerance!==void 0?s.tolerance:.375)*c,extent:p.X,maxZoom:this.maxzoom,lineMetrics:s.lineMetrics||!1,generateId:s.generateId||!1},superclusterOptions:{maxZoom:s.clusterMaxZoom!==void 0?s.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,s.clusterMinPoints||2),extent:p.X,radius:(s.clusterRadius||50)*c,log:!1,generateId:s.generateId||!1},clusterProperties:s.clusterProperties,filter:s.filter},s.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}load(){return p._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData(),this}updateData(t){return this._updateWorkerData(t),this}getData(){return p._(this,void 0,void 0,(function*(){const t=p.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:t})}))}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t&&(t.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=t.clusterRadius),t.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=t.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(t){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}getClusterChildren(t){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}getClusterLeaves(t,s,n){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:s,offset:n}})}_updateWorkerData(t){return p._(this,void 0,void 0,(function*(){const s=p.e({type:this.type},this.workerOptions);t?s.dataDiff=t:typeof this._data=="string"?(s.request=this.map._requestManager.transformRequest(mt.resolveURL(this._data),"Source"),s.request.collectResourceTiming=this._collectResourceTiming):s.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new p.k("dataloading",{dataType:"source"}));try{const n=yield this.actor.sendAsync({type:"LD",data:s});if(this._pendingLoads--,this._removed||n.abandoned)return void this.fire(new p.k("dataabort",{dataType:"source"}));let o=null;n.resourceTiming&&n.resourceTiming[this.id]&&(o=n.resourceTiming[this.id].slice(0));const c={dataType:"source"};this._collectResourceTiming&&o&&o.length>0&&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(n){if(this._pendingLoads--,this._removed)return void this.fire(new p.k("dataabort",{dataType:"source"}));this.fire(new p.j(n))}}))}loaded(){return this._pendingLoads===0}loadTile(t){return p._(this,void 0,void 0,(function*(){const s=t.actor?"RT":"LT";t.actor=this.actor;const n={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.abortController=new AbortController;const o=yield this.actor.sendAsync({type:s,data:n},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(o,this.map.painter,s==="RT")}))}abortTile(t){return p._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}))}unloadTile(t){return p._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.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 fr extends p.E{constructor(t,s,n,o){super(),this.id=t,this.dispatcher=n,this.coordinates=s.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=s}load(t){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 s=yield ui.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,s&&s.data&&(this.image=s.data,t&&(this.coordinates=t),this._finishLoading())}catch(s){this._request=null,this._loaded=!0,this.fire(new p.j(s))}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.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(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const s=t.map(p.Z.fromLngLat);this.tileID=(function(o){let c=1/0,m=1/0,g=-1/0,y=-1/0;for(const z of o)c=Math.min(c,z.x),m=Math.min(m,z.y),g=Math.max(g,z.x),y=Math.max(y,z.y);const b=Math.max(g-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+g)/2*S),Math.floor((m+y)/2*S))})(s),this.minzoom=this.maxzoom=this.tileID.z;const n=s.map((o=>this.tileID.getTilePoint(o)._round()));return this._boundsArray=new p.$,this._boundsArray.emplaceBack(n[0].x,n[0].y,0,0),this._boundsArray.emplaceBack(n[1].x,n[1].y,p.X,0),this._boundsArray.emplaceBack(n[3].x,n[3].y,0,p.X),this._boundsArray.emplaceBack(n[2].x,n[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 t=this.map.painter.context,s=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,kr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture||(this.texture=new ae(t,this.image,s.RGBA),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE));let n=!1;for(const o in this.tiles){const c=this.tiles[o];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,n=!0)}n&&this.fire(new p.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return p._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class hs extends fr{constructor(t,s,n,o){super(t,s,n,o),this.roundZoom=!0,this.type="video",this.options=s}load(){return p._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const s of t.urls)this.urls.push(this.map._requestManager.transformRequest(s,"Source").url);try{const s=yield p.a3(this.urls);if(this._loaded=!0,!s)return;this.video=s,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(s){this.fire(new p.j(s))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const s=this.video.seekable;t<s.start(0)||t>s.end(0)?this.fire(new p.j(new p.a2(`sources.${this.id}`,null,`Playback for this video can be set only between the ${s.start(0)} and ${s.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,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 t=this.map.painter.context,s=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,kr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,this.video)):(this.texture=new ae(t,this.video,s.RGBA),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE));let n=!1;for(const o in this.tiles){const c=this.tiles[o];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,n=!0)}n&&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 bi extends fr{constructor(t,s,n,o){super(t,s,n,o),s.coordinates?Array.isArray(s.coordinates)&&s.coordinates.length===4&&!s.coordinates.some((c=>!Array.isArray(c)||c.length!==2||c.some((m=>typeof m!="number"))))||this.fire(new p.j(new p.a2(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new p.j(new p.a2(`sources.${t}`,null,'missing required property "coordinates"'))),s.animate&&typeof s.animate!="boolean"&&this.fire(new p.j(new p.a2(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),s.canvas?typeof s.canvas=="string"||s.canvas instanceof HTMLCanvasElement||this.fire(new p.j(new p.a2(`sources.${t}`,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.${t}`,null,'missing required property "canvas"'))),this.options=s,this.animate=s.animate===void 0||s.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(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const s=this.map.painter.context,n=s.gl;this.boundsBuffer||(this.boundsBuffer=s.createVertexBuffer(this._boundsArray,kr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new ae(s,this.canvas,n.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 t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const Js={},Ys=u=>{switch(u){case"geojson":return Ks;case"image":return fr;case"raster":return te;case"raster-dem":return ye;case"vector":return Ws;case"video":return hs;case"canvas":return bi}return Js[u]},ht="RTLPluginLoaded";class tr extends p.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Hs()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((s=>{throw this.status="error",s}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return p._(this,arguments,void 0,(function*(s,n=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=mt.resolveURL(s),!this.url)throw new Error(`requested url ${s} is invalid`);if(this.status==="unavailable"){if(!n)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(ht))}))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let He=null;function er(){return He||(He=new tr),He}class Mr{constructor(t,s){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=p.a4(),this.uses=0,this.tileSize=s,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const s=t+this.timeAdded;s<this.fadeEndTime||(this.fadeEndTime=s)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,s,n){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=(function(o,c){const m={};if(!c)return m;for(const g of o){const y=g.layerIds.map((b=>c.getLayer(b))).filter(Boolean);if(y.length!==0){g.layers=y,g.stateDependentLayerIds&&(g.stateDependentLayers=g.stateDependentLayerIds.map((b=>y.filter((T=>T.id===b))[0])));for(const b of y)m[b.id]=g}}return m})(t.buckets,s.style),this.hasSymbolBuckets=!1;for(const o in this.buckets){const c=this.buckets[o];if(c instanceof p.a6){if(this.hasSymbolBuckets=!0,!n)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,er().lazyLoad();break}}this.queryPadding=0;for(const o in this.buckets){const c=this.buckets[o];this.queryPadding=Math.max(this.queryPadding,s.style.getLayer(o).queryRadius(c))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new p.a5}unloadVectorData(){for(const t in this.buckets)this.buckets[t].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(t){return this.buckets[t.id]}upload(t){for(const n in this.buckets){const o=this.buckets[n];o.uploadPending()&&o.upload(t)}const s=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new ae(t,this.imageAtlas.image,s.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new ae(t,this.glyphAtlasImage,s.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,s,n,o,c,m,g,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:g,queryPadding:this.queryPadding*b},t,s,n):{}}querySourceFeatures(t,s){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),c=s&&s.sourceLayer?s.sourceLayer:"",m=o._geojsonTileLayer||o[c];if(!m)return;const g=p.a7(s&&s.filter),{z:y,x:b,y:T}=this.tileID.canonical,S={z:y,x:b,y:T};for(let z=0;z<m.length;z++){const A=m.feature(z);if(g.needGeometry){const $=p.a8(A,!0);if(!g.filter(new p.z(this.tileID.overscaledZ),$,this.tileID.canonical))continue}else if(!g.filter(new p.z(this.tileID.overscaledZ),A))continue;const B=n.getId(A,c),V=new p.a9(A,y,b,T,B);V.tile=S,t.push(V)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const s=this.expirationTime;if(t.cacheControl){const n=p.aa(t.cacheControl);n["max-age"]&&(this.expirationTime=Date.now()+1e3*n["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const n=Date.now();let o=!1;if(this.expirationTime>n)o=!1;else if(s)if(this.expirationTime<s)o=!0;else{const c=this.expirationTime-s;c?this.expirationTime=n+Math.max(c,3e4):o=!0}else o=!0;o?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(t,s){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(t).length===0)return;const n=this.latestFeatureIndex.loadVTLayers();for(const o in this.buckets){if(!s.style.hasLayer(o))continue;const c=this.buckets[o],m=c.layers[0].sourceLayer||"_geojsonTileLayer",g=n[m],y=t[m];if(!g||!y||Object.keys(y).length===0)continue;c.update(y,g,this.imageAtlas&&this.imageAtlas.patternPositions||{});const b=s&&s.style&&s.style.getLayer(o);b&&(this.queryPadding=Math.max(this.queryPadding,b.queryRadius(c)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<mt.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=mt.now()+t}setDependencies(t,s){const n={};for(const o of s)n[o]=!0;this.dependencies[t]=n}hasDependency(t,s){for(const n of t){const o=this.dependencies[n];if(o){for(const c of s)if(o[c])return!0}}return!1}}class _t{constructor(t,s){this.max=t,this.onRemove=s,this.reset()}reset(){for(const t in this.data)for(const s of this.data[t])s.timeout&&clearTimeout(s.timeout),this.onRemove(s.value);return this.data={},this.order=[],this}add(t,s,n){const o=t.wrapped().key;this.data[o]===void 0&&(this.data[o]=[]);const c={value:s,timeout:void 0};if(n!==void 0&&(c.timeout=setTimeout((()=>{this.remove(t,c)}),n)),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(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const s=this.data[t].shift();return s.timeout&&clearTimeout(s.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),s.value}getByKey(t){const s=this.data[t];return s?s[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,s){if(!this.has(t))return this;const n=t.wrapped().key,o=s===void 0?0:this.data[n].indexOf(s),c=this.data[n][o];return this.data[n].splice(o,1),c.timeout&&clearTimeout(c.timeout),this.data[n].length===0&&delete this.data[n],this.onRemove(c.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const s=this._getAndRemoveByKey(this.order[0]);s&&this.onRemove(s)}return this}filter(t){const s=[];for(const n in this.data)for(const o of this.data[n])t(o.value)||s.push(o);for(const n of s)this.remove(n.value.tileID,n)}}class Nt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,s,n){const o=String(s);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][o]=this.stateChanges[t][o]||{},p.e(this.stateChanges[t][o],n),this.deletedStates[t]===null){this.deletedStates[t]={};for(const c in this.state[t])c!==o&&(this.deletedStates[t][c]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][o]===null){this.deletedStates[t][o]={};for(const c in this.state[t][o])n[c]||(this.deletedStates[t][o][c]=null)}else for(const c in n)this.deletedStates[t]&&this.deletedStates[t][o]&&this.deletedStates[t][o][c]===null&&delete this.deletedStates[t][o][c]}removeFeatureState(t,s,n){if(this.deletedStates[t]===null)return;const o=String(s);if(this.deletedStates[t]=this.deletedStates[t]||{},n&&s!==void 0)this.deletedStates[t][o]!==null&&(this.deletedStates[t][o]=this.deletedStates[t][o]||{},this.deletedStates[t][o][n]=null);else if(s!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][o])for(n in this.deletedStates[t][o]={},this.stateChanges[t][o])this.deletedStates[t][o][n]=null;else this.deletedStates[t][o]=null;else this.deletedStates[t]=null}getState(t,s){const n=String(s),o=p.e({},(this.state[t]||{})[n],(this.stateChanges[t]||{})[n]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const c=this.deletedStates[t][s];if(c===null)return{};for(const m in c)delete o[m]}return o}initializeTileState(t,s){t.setFeatureState(this.state,s)}coalesceChanges(t,s){const n={};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];n[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 g of Object.keys(this.deletedStates[o][m]))delete this.state[o][m][g];c[m]=this.state[o][m]}n[o]=n[o]||{},p.e(n[o],c)}if(this.stateChanges={},this.deletedStates={},Object.keys(n).length!==0)for(const o in t)t[o].setFeatureState(n,s)}}class Ft extends p.E{constructor(t,s,n){super(),this.id=t,this.dispatcher=n,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,g)=>{const y=new(Ys(c.type))(o,c,m,g);if(y.id!==o)throw new Error(`Expected Source id to be ${o} instead of ${y.id}`);return y})(t,s,n,this),this._tiles={},this._cache=new _t(0,(o=>this._unloadTile(o))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Nt,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}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 t in this._tiles){const s=this._tiles[t];if(s.state!=="loaded"&&s.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,s,n){return p._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,s,n)}catch(o){t.state="errored",o.status!==404?this._source.fire(new p.j(o,{tile:t})):this.update(this.transform,this.terrain)}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new p.k("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const s in this._tiles){const n=this._tiles[s];n.upload(t),n.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(ei).map((t=>t.key))}getRenderableIds(t){const s=[];for(const n in this._tiles)this._isIdRenderable(n,t)&&s.push(this._tiles[n]);return t?s.sort(((n,o)=>{const c=n.tileID,m=o.tileID,g=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-g.y||y.x-g.x})).map((n=>n.tileID.key)):s.map((n=>n.tileID)).sort(ei).map((n=>n.key))}hasRenderableParent(t){const s=this.findLoadedParent(t,0);return!!s&&this._isIdRenderable(s.tileID.key)}_isIdRenderable(t,s){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(s||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(t,"reloading")}}_reloadTile(t,s){return p._(this,void 0,void 0,(function*(){const n=this._tiles[t];n&&(n.state!=="loading"&&(n.state=s),yield this._loadTile(n,t,s))}))}_tileLoaded(t,s,n){t.timeAdded=mt.now(),n==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(s,t),this.getSource().type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new p.k("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const s=this.getRenderableIds();for(let o=0;o<s.length;o++){const c=s[o];if(t.neighboringTiles&&t.neighboringTiles[c]){const m=this.getTileByID(c);n(t,m),n(m,t)}}function n(o,c){o.needsHillshadePrepare=!0,o.needsTerrainPrepare=!0;let m=c.tileID.canonical.x-o.tileID.canonical.x;const g=c.tileID.canonical.y-o.tileID.canonical.y,y=Math.pow(2,o.tileID.canonical.z),b=c.tileID.key;m===0&&g===0||Math.abs(g)>1||(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,g),o.neighboringTiles&&o.neighboringTiles[b]&&(o.neighboringTiles[b].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,s,n,o){for(const c in this._tiles){let m=this._tiles[c];if(o[c]||!m.hasData()||m.tileID.overscaledZ<=s||m.tileID.overscaledZ>n)continue;let g=m.tileID;for(;m&&m.tileID.overscaledZ>s+1;){const b=m.tileID.scaledTo(m.tileID.overscaledZ-1);m=this._tiles[b.key],m&&m.hasData()&&(g=b)}let y=g;for(;y.overscaledZ>s;)if(y=y.scaledTo(y.overscaledZ-1),t[y.key]){o[g.key]=g;break}}}findLoadedParent(t,s){if(t.key in this._loadedParentTiles){const n=this._loadedParentTiles[t.key];return n&&n.tileID.overscaledZ>=s?n:null}for(let n=t.overscaledZ-1;n>=s;n--){const o=t.scaledTo(n),c=this._getLoadedTile(o);if(c)return c}}findLoadedSibling(t){return this._getLoadedTile(t)}_getLoadedTile(t){const s=this._tiles[t.key];return s&&s.hasData()?s:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const s=Math.ceil(t.width/this._source.tileSize)+1,n=Math.ceil(t.height/this._source.tileSize)+1,o=Math.floor(s*n*(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(t){const s=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,s){const n={};for(const o in this._tiles){const c=this._tiles[o];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+s),n[c.tileID.key]=c}this._tiles=n;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(t,s,n,o,c,m){const g={},y={},b=Object.keys(t),T=mt.now();for(const S of b){const z=t[S],A=this._tiles[S];if(!A||A.fadeEndTime!==0&&A.fadeEndTime<=T)continue;const B=this.findLoadedParent(z,s),V=this.findLoadedSibling(z),$=B||V||null;$&&(this._addTile($.tileID),g[$.tileID.key]=$.tileID),y[S]=z}this._retainLoadedChildren(y,o,n,t);for(const S in g)t[S]||(this._coveredTiles[S]=!0,t[S]=g[S]);if(m){const S={},z={};for(const A of c)this._tiles[A.key].hasData()?S[A.key]=A:z[A.key]=A;for(const A in z){const B=z[A].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]=t[B[0].key]=B[0],S[B[1].key]=t[B[1].key]=B[1],S[B[2].key]=t[B[2].key]=B[2],S[B[3].key]=t[B[3].key]=B[3],delete z[A])}for(const A in z){const B=z[A],V=this.findLoadedParent(B,this._source.minzoom),$=this.findLoadedSibling(B),N=V||$||null;if(N){S[N.tileID.key]=t[N.tileID.key]=N.tileID;for(const q in S)S[q].isChildOf(N.tileID)&&delete S[q]}}for(const A in this._tiles)S[A]||(this._coveredTiles[A]=!0)}}update(t,s){if(!this._sourceLoaded||this._paused)return;let n;this.transform=t,this.terrain=s,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((T=>new p.S(T.canonical.z,T.wrap,T.canonical.z,T.canonical.x,T.canonical.y))):(n=t.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:s}),this._source.hasTile&&(n=n.filter((T=>this._source.hasTile(T))))):n=[];const o=t.coveringZoomLevel(this._source),c=Math.max(o-Ft.maxOverzooming,this._source.minzoom),m=Math.max(o+Ft.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const T={};for(const S of n)if(S.canonical.z>this._source.minzoom){const z=S.scaledTo(S.canonical.z-1);T[z.key]=z;const A=S.scaledTo(Math.max(this._source.minzoom,Math.min(S.canonical.z,5)));T[A.key]=A}n=n.concat(Object.values(T))}const g=n.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,g&&this.fire(new p.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const y=this._updateRetainedTiles(n,o);Bi(this._source.type)&&this._updateCoveredAndRetainedTiles(y,c,m,o,n,s);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 t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,s){var n;const o={},c={},m=Math.max(s-Ft.maxOverzooming,this._source.minzoom),g=Math.max(s+Ft.maxUnderzooming,this._source.minzoom),y={};for(const b of t){const T=this._addTile(b);o[b.key]=b,T.hasData()||s<this._source.maxzoom&&(y[b.key]=b)}this._retainLoadedChildren(y,s,g,o);for(const b of t){let T=this._tiles[b.key];if(T.hasData())continue;if(s+1>this._source.maxzoom){const z=b.children(this._source.maxzoom)[0],A=this.getTile(z);if(A&&A.hasData()){o[z.key]=z;continue}}else{const z=b.children(this._source.maxzoom);if(o[z[0].key]&&o[z[1].key]&&o[z[2].key]&&o[z[3].key])continue}let S=T.wasRequested();for(let z=b.overscaledZ-1;z>=m;--z){const A=b.scaledTo(z);if(c[A.key])break;if(c[A.key]=!0,T=this.getTile(A),!T&&S&&(T=this._addTile(A)),T){const B=T.hasData();if((B||!(!((n=this.map)===null||n===void 0)&&n.cancelPendingTileRequestsWhileZooming)||S)&&(o[A.key]=A),S=T.wasRequested(),B)break}}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const s=[];let n,o=this._tiles[t].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}s.push(o.key);const c=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(c),n)break;o=c}for(const c of s)this._loadedParentTiles[c]=n}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const t in this._tiles){const s=this._tiles[t].tileID,n=this._getLoadedTile(s);this._loadedSiblingTiles[s.key]=n}}_addTile(t){let s=this._tiles[t.key];if(s)return s;s=this._cache.getAndRemove(t),s&&(this._setTileReloadTimer(t.key,s),s.tileID=t,this._state.initializeTileState(s,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,s)));const n=s;return s||(s=new Mr(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(s,t.key,s.state)),s.uses++,this._tiles[t.key]=s,n||this._source.fire(new p.k("dataloading",{tile:s,coord:s.tileID,dataType:"source"})),s}_setTileReloadTimer(t,s){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const n=s.getExpiryTimeout();n&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),n))}_removeTile(t){const s=this._tiles[t];s&&(s.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),s.uses>0||(s.hasData()&&s.state!=="reloading"?this._cache.add(s.tileID,s,s.getExpiryTimeout()):(s.aborted=!0,this._abortTile(s),this._unloadTile(s))))}_dataHandler(t){const s=t.sourceDataType;t.dataType==="source"&&s==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&t.dataType==="source"&&s==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,s,n){const o=[],c=this.transform;if(!c)return o;const m=n?c.getCameraQueryGeometry(t):t,g=t.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,z=-1/0,A=-1/0;for(const B of y)T=Math.min(T,B.x),S=Math.min(S,B.y),z=Math.max(z,B.x),A=Math.max(A,B.y);for(let B=0;B<b.length;B++){const V=this._tiles[b[B]];if(V.holdingForFade())continue;const $=V.tileID,N=Math.pow(2,c.zoom-V.tileID.overscaledZ),q=s*V.queryPadding*p.X/V.tileSize/N,F=[$.getTilePoint(new p.Z(T,S)),$.getTilePoint(new p.Z(z,A))];if(F[0].x-q<p.X&&F[0].y-q<p.X&&F[1].x+q>=0&&F[1].y+q>=0){const H=g.map((tt=>$.getTilePoint(tt))),K=y.map((tt=>$.getTilePoint(tt)));o.push({tile:V,tileID:$,queryGeometry:H,cameraQueryGeometry:K,scale:N})}}return o}getVisibleCoordinates(t){const s=this.getRenderableIds(t).map((n=>this._tiles[n].tileID));for(const n of s)n.posMatrix=this.transform.calculatePosMatrix(n.toUnwrapped());return s}hasTransition(){if(this._source.hasTransition())return!0;if(Bi(this._source.type)){const t=mt.now();for(const s in this._tiles)if(this._tiles[s].fadeEndTime>=t)return!0}return!1}setFeatureState(t,s,n){this._state.updateState(t=t||"_geojsonTileLayer",s,n)}removeFeatureState(t,s,n){this._state.removeFeatureState(t=t||"_geojsonTileLayer",s,n)}getFeatureState(t,s){return this._state.getState(t=t||"_geojsonTileLayer",s)}setDependencies(t,s,n){const o=this._tiles[t];o&&o.setDependencies(s,n)}reloadTilesForDependencies(t,s){for(const n in this._tiles)this._tiles[n].hasDependency(t,s)&&this._reloadTile(n,"reloading");this._cache.filter((n=>!n.hasDependency(t,s)))}}function ei(u,t){const s=Math.abs(2*u.wrap)-+(u.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return u.overscaledZ-t.overscaledZ||n-s||t.canonical.y-u.canonical.y||t.canonical.x-u.canonical.x}function Bi(u){return u==="raster"||u==="image"||u==="video"}Ft.maxOverzooming=10,Ft.maxUnderzooming=3;class jt{constructor(t,s){this.reset(t,s)}reset(t,s){this.points=t||[],this._distances=[0];for(let n=1;n<this.points.length;n++)this._distances[n]=this._distances[n-1]+this.points[n].dist(this.points[n-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(s||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=p.ac(t,0,1);let s=1,n=this._distances[s];const o=t*this.paddedLength+this.padding;for(;n<o&&s<this._distances.length;)n=this._distances[++s];const c=s-1,m=this._distances[c],g=n-m,y=g>0?(o-m)/g:0;return this.points[c].mult(1-y).add(this.points[s].mult(y))}}function ir(u,t){let s=!0;return u==="always"||u!=="never"&&t!=="never"||(s=!1),s}class mr{constructor(t,s,n){const o=this.boxCells=[],c=this.circleCells=[];this.xCellCount=Math.ceil(t/n),this.yCellCount=Math.ceil(s/n);for(let m=0;m<this.xCellCount*this.yCellCount;m++)o.push([]),c.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=s,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/s,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,s,n,o,c){this._forEachCell(s,n,o,c,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(s),this.bboxes.push(n),this.bboxes.push(o),this.bboxes.push(c)}insertCircle(t,s,n,o){this._forEachCell(s-o,n-o,s+o,n+o,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(s),this.circles.push(n),this.circles.push(o)}_insertBoxCell(t,s,n,o,c,m){this.boxCells[c].push(m)}_insertCircleCell(t,s,n,o,c,m){this.circleCells[c].push(m)}_query(t,s,n,o,c,m,g){if(n<0||t>this.width||o<0||s>this.height)return[];const y=[];if(t<=0&&s<=0&&this.width<=n&&this.height<=o){if(c)return[{key:null,x1:t,y1:s,x2:n,y2:o}];for(let b=0;b<this.boxKeys.length;b++)y.push({key:this.boxKeys[b],x1:this.bboxes[4*b],y1:this.bboxes[4*b+1],x2:this.bboxes[4*b+2],y2:this.bboxes[4*b+3]});for(let b=0;b<this.circleKeys.length;b++){const T=this.circles[3*b],S=this.circles[3*b+1],z=this.circles[3*b+2];y.push({key:this.circleKeys[b],x1:T-z,y1:S-z,x2:T+z,y2:S+z})}}else this._forEachCell(t,s,n,o,this._queryCell,y,{hitTest:c,overlapMode:m,seenUids:{box:{},circle:{}}},g);return y}query(t,s,n,o){return this._query(t,s,n,o,!1,null)}hitTest(t,s,n,o,c,m){return this._query(t,s,n,o,!0,c,m).length>0}hitTestCircle(t,s,n,o,c){const m=t-n,g=t+n,y=s-n,b=s+n;if(g<0||m>this.width||b<0||y>this.height)return!1;const T=[];return this._forEachCell(m,y,g,b,this._queryCellCircle,T,{hitTest:!0,overlapMode:o,circle:{x:t,y:s,radius:n},seenUids:{box:{},circle:{}}},c),T.length>0}_queryCell(t,s,n,o,c,m,g,y){const{seenUids:b,hitTest:T,overlapMode:S}=g,z=this.boxCells[c];if(z!==null){const B=this.bboxes;for(const V of z)if(!b.box[V]){b.box[V]=!0;const $=4*V,N=this.boxKeys[V];if(t<=B[$+2]&&s<=B[$+3]&&n>=B[$+0]&&o>=B[$+1]&&(!y||y(N))&&(!T||!ir(S,N.overlapMode))&&(m.push({key:N,x1:B[$],y1:B[$+1],x2:B[$+2],y2:B[$+3]}),T))return!0}}const A=this.circleCells[c];if(A!==null){const B=this.circles;for(const V of A)if(!b.circle[V]){b.circle[V]=!0;const $=3*V,N=this.circleKeys[V];if(this._circleAndRectCollide(B[$],B[$+1],B[$+2],t,s,n,o)&&(!y||y(N))&&(!T||!ir(S,N.overlapMode))){const q=B[$],F=B[$+1],H=B[$+2];if(m.push({key:N,x1:q-H,y1:F-H,x2:q+H,y2:F+H}),T)return!0}}}return!1}_queryCellCircle(t,s,n,o,c,m,g,y){const{circle:b,seenUids:T,overlapMode:S}=g,z=this.boxCells[c];if(z!==null){const B=this.bboxes;for(const V of z)if(!T.box[V]){T.box[V]=!0;const $=4*V,N=this.boxKeys[V];if(this._circleAndRectCollide(b.x,b.y,b.radius,B[$+0],B[$+1],B[$+2],B[$+3])&&(!y||y(N))&&!ir(S,N.overlapMode))return m.push(!0),!0}}const A=this.circleCells[c];if(A!==null){const B=this.circles;for(const V of A)if(!T.circle[V]){T.circle[V]=!0;const $=3*V,N=this.circleKeys[V];if(this._circlesCollide(B[$],B[$+1],B[$+2],b.x,b.y,b.radius)&&(!y||y(N))&&!ir(S,N.overlapMode))return m.push(!0),!0}}}_forEachCell(t,s,n,o,c,m,g,y){const b=this._convertToXCellCoord(t),T=this._convertToYCellCoord(s),S=this._convertToXCellCoord(n),z=this._convertToYCellCoord(o);for(let A=b;A<=S;A++)for(let B=T;B<=z;B++)if(c.call(this,t,s,n,o,this.xCellCount*B+A,m,g,y))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,s,n,o,c,m){const g=o-t,y=c-s,b=n+m;return b*b>g*g+y*y}_circleAndRectCollide(t,s,n,o,c,m,g){const y=(m-o)/2,b=Math.abs(t-(o+y));if(b>y+n)return!1;const T=(g-c)/2,S=Math.abs(s-(c+T));if(S>T+n)return!1;if(b<=y||S<=T)return!0;const z=b-y,A=S-T;return z*z+A*A<=n*n}}function Er(u,t,s,n,o){const c=p.H();return t?(p.K(c,c,[1/o,1/o,1]),s||p.ad(c,c,n.angle)):p.L(c,n.labelPlaneMatrix,u),c}function rr(u,t,s,n,o){if(t){const c=p.ae(u);return p.K(c,c,[o,o,1]),s||p.ad(c,c,-n.angle),c}return n.glCoordMatrix}function j(u,t,s,n){let o;n?(o=[u,t,n(u,t),1],p.af(o,o,s)):(o=[u,t,0,1],Kt(o,o,s));const c=o[3];return{point:new p.P(o[0]/c,o[1]/c),signedDistanceFromCamera:c,isOccluded:!1}}function M(u,t){return .5+u/t*.5}function k(u,t){return u.x>=-t[0]&&u.x<=t[0]&&u.y>=-t[1]&&u.y<=t[1]}function D(u,t,s,n,o,c,m,g,y,b,T,S,z,A,B){const V=n?u.textSizeData:u.iconSizeData,$=p.ag(V,s.transform.zoom),N=[256/s.width*2+1,256/s.height*2+1],q=n?u.text.dynamicLayoutVertexArray:u.icon.dynamicLayoutVertexArray;q.clear();const F=u.lineVertexArray,H=n?u.text.placedSymbolArray:u.icon.placedSymbolArray,K=s.transform.width/s.transform.height;let tt=!1;for(let ot=0;ot<H.length;ot++){const ut=H.get(ot);if(ut.hidden||ut.writingMode===p.ah.vertical&&!tt){Dt(ut.numGlyphs,q);continue}tt=!1;const xt=j(ut.anchorX,ut.anchorY,t,B);if(!k(xt.point,N)){Dt(ut.numGlyphs,q);continue}const Tt=M(s.transform.cameraToCenterDistance,xt.signedDistanceFromCamera),ft=p.ai(V,$,ut),pt=m?ft/Tt:ft*Tt,Et={getElevation:B,labelPlaneMatrix:o,lineVertexArray:F,pitchWithMap:m,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},projection:b,tileAnchorPoint:new p.P(ut.anchorX,ut.anchorY),unwrappedTileID:T,width:S,height:z,translation:A},Vt=W(Et,ut,pt,!1,g,t,c,u.glyphOffsetArray,q,K,y);tt=Vt.useVertical,(Vt.notEnoughRoom||tt||Vt.needsFlipping&&W(Et,ut,pt,!0,g,t,c,u.glyphOffsetArray,q,K,y).notEnoughRoom)&&Dt(ut.numGlyphs,q)}n?u.text.dynamicLayoutVertexBuffer.updateData(q):u.icon.dynamicLayoutVertexBuffer.updateData(q)}function O(u,t,s,n,o,c,m,g){const y=c.glyphStartIndex+c.numGlyphs,b=c.lineStartIndex,T=c.lineStartIndex+c.lineLength,S=t.getoffsetX(c.glyphStartIndex),z=t.getoffsetX(y-1),A=dt(u*S,s,n,o,c.segment,b,T,g,m);if(!A)return null;const B=dt(u*z,s,n,o,c.segment,b,T,g,m);return B?g.projectionCache.anyProjectionOccluded?null:{first:A,last:B}:null}function G(u,t,s,n){return u===p.ah.horizontal&&Math.abs(s.y-t.y)>Math.abs(s.x-t.x)*n?{useVertical:!0}:(u===p.ah.vertical?t.y<s.y:t.x>s.x)?{needsFlipping:!0}:null}function W(u,t,s,n,o,c,m,g,y,b,T){const S=s/24,z=t.lineOffsetX*S,A=t.lineOffsetY*S;let B;if(t.numGlyphs>1){const V=t.glyphStartIndex+t.numGlyphs,$=t.lineStartIndex,N=t.lineStartIndex+t.lineLength,q=O(S,g,z,A,n,t,T,u);if(!q)return{notEnoughRoom:!0};const F=j(q.first.point.x,q.first.point.y,m,u.getElevation).point,H=j(q.last.point.x,q.last.point.y,m,u.getElevation).point;if(o&&!n){const K=G(t.writingMode,F,H,b);if(K)return K}B=[q.first];for(let K=t.glyphStartIndex+1;K<V-1;K++)B.push(dt(S*g.getoffsetX(K),z,A,n,t.segment,$,N,u,T));B.push(q.last)}else{if(o&&!n){const $=j(u.tileAnchorPoint.x,u.tileAnchorPoint.y,c,u.getElevation).point,N=t.lineStartIndex+t.segment+1,q=new p.P(u.lineVertexArray.getx(N),u.lineVertexArray.gety(N)),F=j(q.x,q.y,c,u.getElevation),H=F.signedDistanceFromCamera>0?F.point:(function(tt,ot,ut,xt,Tt,ft){return Y(tt,ot,ut,1,Tt,ft)})(u.tileAnchorPoint,q,$,0,c,u),K=G(t.writingMode,$,H,b);if(K)return K}const V=dt(S*g.getoffsetX(t.glyphStartIndex),z,A,n,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,u,T);if(!V||u.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};B=[V]}for(const V of B)p.aj(y,V.point,V.angle);return{}}function Y(u,t,s,n,o,c){const m=u.add(u.sub(t)._unit()),g=o!==void 0?j(m.x,m.y,o,c.getElevation).point:st(m.x,m.y,c).point,y=s.sub(g);return s.add(y._mult(n/y.mag()))}function Z(u,t,s){const n=t.projectionCache;if(n.projections[u])return n.projections[u];const o=new p.P(t.lineVertexArray.getx(u),t.lineVertexArray.gety(u)),c=st(o.x,o.y,t);if(c.signedDistanceFromCamera>0)return n.projections[u]=c.point,n.anyProjectionOccluded=n.anyProjectionOccluded||c.isOccluded,c.point;const m=u-s.direction;return(function(g,y,b,T,S){return Y(g,y,b,T,void 0,S)})(s.distanceFromAnchor===0?t.tileAnchorPoint:new p.P(t.lineVertexArray.getx(m),t.lineVertexArray.gety(m)),o,s.previousVertex,s.absOffsetX-s.distanceFromAnchor+1,t)}function st(u,t,s){const n=u+s.translation[0],o=t+s.translation[1];let c;return!s.pitchWithMap&&s.projection.useSpecialProjectionForSymbols?(c=s.projection.projectTileCoordinates(n,o,s.unwrappedTileID,s.getElevation),c.point.x=(.5*c.point.x+.5)*s.width,c.point.y=(.5*-c.point.y+.5)*s.height):(c=j(n,o,s.labelPlaneMatrix,s.getElevation),c.isOccluded=!1),c}function lt(u,t,s){return u._unit()._perp()._mult(t*s)}function et(u,t,s,n,o,c,m,g,y){if(g.projectionCache.offsets[u])return g.projectionCache.offsets[u];const b=s.add(t);if(u+y.direction<n||u+y.direction>=o)return g.projectionCache.offsets[u]=b,b;const T=Z(u+y.direction,g,y),S=lt(T.sub(s),m,y.direction),z=s.add(S),A=T.add(S);return g.projectionCache.offsets[u]=p.ak(c,b,z,A)||b,g.projectionCache.offsets[u]}function dt(u,t,s,n,o,c,m,g,y){const b=n?u-t:u+t;let T=b>0?1:-1,S=0;n&&(T*=-1,S=Math.PI),T<0&&(S+=Math.PI);let z,A=T>0?c+o:c+o+1;g.projectionCache.cachedAnchorPoint?z=g.projectionCache.cachedAnchorPoint:(z=st(g.tileAnchorPoint.x,g.tileAnchorPoint.y,g).point,g.projectionCache.cachedAnchorPoint=z);let B,V,$=z,N=z,q=0,F=0;const H=Math.abs(b),K=[];let tt;for(;q+F<=H;){if(A+=T,A<c||A>=m)return null;q+=F,N=$,V=B;const xt={absOffsetX:H,direction:T,distanceFromAnchor:q,previousVertex:N};if($=Z(A,g,xt),s===0)K.push(N),tt=$.sub(N);else{let Tt;const ft=$.sub(N);Tt=ft.mag()===0?lt(Z(A+T,g,xt).sub($),s,T):lt(ft,s,T),V||(V=N.add(Tt)),B=et(A,Tt,$,c,m,V,s,g,xt),K.push(V),tt=B.sub(V)}F=tt.mag()}const ot=tt._mult((H-q)/F)._add(V||N),ut=S+Math.atan2($.y-N.y,$.x-N.x);return K.push(ot),{point:ot,angle:y?ut:0,path:K}}const At=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Dt(u,t){for(let s=0;s<u;s++){const n=t.length;t.resize(n+4),t.float32.set(At,3*n)}}function Kt(u,t,s){const n=t[0],o=t[1];return u[0]=s[0]*n+s[4]*o+s[12],u[1]=s[1]*n+s[5]*o+s[13],u[3]=s[3]*n+s[7]*o+s[15],u}const Ut=100;class Jt{constructor(t,s,n=new mr(t.width+200,t.height+200,25),o=new mr(t.width+200,t.height+200,25)){this.transform=t,this.mapProjection=s,this.grid=n,this.ignoredGrid=o,this.pitchFactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+Ut,this.screenBottomBoundary=t.height+Ut,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,s,n,o,c,m,g,y,b,T,S){const z=t.anchorPointX+y[0],A=t.anchorPointY+y[1],B=this.projectAndGetPerspectiveRatio(o,z,A,c,T),V=n*B.perspectiveRatio;let $;if(m||g)$=this._projectCollisionBox(t,V,o,c,m,g,y,B,T,S);else{const K=B.point.x+(S?S.x*V:0),tt=B.point.y+(S?S.y*V:0);$={allPointsOccluded:!1,box:[K+t.x1*V,tt+t.y1*V,K+t.x2*V,tt+t.y2*V]}}const[N,q,F,H]=$.box;return this.mapProjection.useSpecialProjectionForSymbols&&(m?$.allPointsOccluded:this.mapProjection.isOccluded(z,A,c))||B.perspectiveRatio<this.perspectiveRatioCutoff||!this.isInsideGrid(N,q,F,H)||s!=="always"&&this.grid.hitTest(N,q,F,H,s,b)?{box:[N,q,F,H],placeable:!1,offscreen:!1}:{box:[N,q,F,H],placeable:!0,offscreen:this.isOffscreen(N,q,F,H)}}placeCollisionCircles(t,s,n,o,c,m,g,y,b,T,S,z,A,B,V,$){const N=[],q=new p.P(s.anchorX,s.anchorY),F=this.getPerspectiveRatio(m,q.x,q.y,g,$),H=(S?c/F:c*F)/p.ap,K={getElevation:$,labelPlaneMatrix:y,lineVertexArray:n,pitchWithMap:S,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},projection:this.mapProjection,tileAnchorPoint:q,unwrappedTileID:g,width:this.transform.width,height:this.transform.height,translation:V},tt=O(H,o,s.lineOffsetX*H,s.lineOffsetY*H,!1,s,!1,K);let ot=!1,ut=!1,xt=!0;if(tt){const Tt=.5*A*F+B,ft=new p.P(-100,-100),pt=new p.P(this.screenRightBoundary,this.screenBottomBoundary),Et=new jt,Vt=tt.first,gt=tt.last;let bt=[];for(let $t=Vt.path.length-1;$t>=1;$t--)bt.push(Vt.path[$t]);for(let $t=1;$t<gt.path.length;$t++)bt.push(gt.path[$t]);const Lt=2.5*Tt;if(b){const $t=this.projectPathToScreenSpace(bt,K,b);bt=$t.some((Xt=>Xt.signedDistanceFromCamera<=0))?[]:$t.map((Xt=>Xt.point))}let pe=[];if(bt.length>0){const $t=bt[0].clone(),Xt=bt[0].clone();for(let fe=1;fe<bt.length;fe++)$t.x=Math.min($t.x,bt[fe].x),$t.y=Math.min($t.y,bt[fe].y),Xt.x=Math.max(Xt.x,bt[fe].x),Xt.y=Math.max(Xt.y,bt[fe].y);pe=$t.x>=ft.x&&Xt.x<=pt.x&&$t.y>=ft.y&&Xt.y<=pt.y?[bt]:Xt.x<ft.x||$t.x>pt.x||Xt.y<ft.y||$t.y>pt.y?[]:p.al([bt],ft.x,ft.y,pt.x,pt.y)}for(const $t of pe){Et.reset($t,.25*Tt);let Xt=0;Xt=Et.length<=.5*Tt?1:Math.ceil(Et.paddedLength/Lt)+1;for(let fe=0;fe<Xt;fe++){const Ve=fe/Math.max(Xt-1,1),Ui=Et.lerp(Ve),me=Ui.x+Ut,si=Ui.y+Ut;N.push(me,si,Tt,0);const Ke=me-Tt,je=si-Tt,Je=me+Tt,or=si+Tt;if(xt=xt&&this.isOffscreen(Ke,je,Je,or),ut=ut||this.isInsideGrid(Ke,je,Je,or),t!=="always"&&this.grid.hitTestCircle(me,si,Tt,t,z)&&(ot=!0,!T))return{circles:[],offscreen:!1,collisionDetected:ot}}}}return{circles:!T&&ot||!ut||F<this.perspectiveRatioCutoff?[]:N,offscreen:xt,collisionDetected:ot}}projectPathToScreenSpace(t,s,n){return t.map((o=>j(o.x,o.y,n,s.getElevation)))}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const s=[];let n=1/0,o=1/0,c=-1/0,m=-1/0;for(const T of t){const S=new p.P(T.x+Ut,T.y+Ut);n=Math.min(n,S.x),o=Math.min(o,S.y),c=Math.max(c,S.x),m=Math.max(m,S.y),s.push(S)}const g=this.grid.query(n,o,c,m).concat(this.ignoredGrid.query(n,o,c,m)),y={},b={};for(const T of g){const S=T.key;if(y[S.bucketInstanceId]===void 0&&(y[S.bucketInstanceId]={}),y[S.bucketInstanceId][S.featureIndex])continue;const z=[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(s,z)&&(y[S.bucketInstanceId][S.featureIndex]=!0,b[S.bucketInstanceId]===void 0&&(b[S.bucketInstanceId]=[]),b[S.bucketInstanceId].push(S.featureIndex))}return b}insertCollisionBox(t,s,n,o,c,m){(n?this.ignoredGrid:this.grid).insert({bucketInstanceId:o,featureIndex:c,collisionGroupID:m,overlapMode:s},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,s,n,o,c,m){const g=n?this.ignoredGrid:this.grid,y={bucketInstanceId:o,featureIndex:c,collisionGroupID:m,overlapMode:s};for(let b=0;b<t.length;b+=4)g.insertCircle(y,t[b],t[b+1],t[b+2])}projectAndGetPerspectiveRatio(t,s,n,o,c){let m;c?(m=[s,n,c(s,n),1],p.af(m,m,t)):(m=[s,n,0,1],Kt(m,m,t));const g=m[3];return{point:new p.P((m[0]/g+1)/2*this.transform.width+Ut,(-m[1]/g+1)/2*this.transform.height+Ut),perspectiveRatio:.5+this.transform.cameraToCenterDistance/g*.5,isOccluded:!1,signedDistanceFromCamera:g}}getPerspectiveRatio(t,s,n,o,c){const m=this.mapProjection.useSpecialProjectionForSymbols?this.mapProjection.projectTileCoordinates(s,n,o,c):j(s,n,t,c);return .5+this.transform.cameraToCenterDistance/m.signedDistanceFromCamera*.5}isOffscreen(t,s,n,o){return n<Ut||t>=this.screenRightBoundary||o<Ut||s>this.screenBottomBoundary}isInsideGrid(t,s,n,o){return n>=0&&t<this.gridRightBoundary&&o>=0&&s<this.gridBottomBoundary}getViewportMatrix(){const t=p.an([]);return p.J(t,t,[-100,-100,0]),t}_projectCollisionBox(t,s,n,o,c,m,g,y,b,T){let S=new p.P(1,0),z=new p.P(0,1);const A=new p.P(t.anchorPointX+g[0],t.anchorPointY+g[1]);if(m&&!c){const xt=this.projectAndGetPerspectiveRatio(n,A.x+1,A.y,o,b).point.sub(y.point).unit(),Tt=Math.atan(xt.y/xt.x)+(xt.x<0?Math.PI:0),ft=Math.sin(Tt),pt=Math.cos(Tt);S=new p.P(pt,ft),z=new p.P(-ft,pt)}else if(!m&&c){const xt=-this.transform.angle,Tt=Math.sin(xt),ft=Math.cos(xt);S=new p.P(ft,Tt),z=new p.P(-Tt,ft)}let B=y.point,V=s;if(c){B=A;const xt=this.transform.zoom-Math.floor(this.transform.zoom);V=Math.pow(2,-xt),V*=this.mapProjection.getPitchedTextCorrection(this.transform,A,o),T||(V*=p.ac(.5+y.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))}T&&(B=B.add(S.mult(T.x*V)).add(z.mult(T.y*V)));const $=t.x1*V,N=t.x2*V,q=($+N)/2,F=t.y1*V,H=t.y2*V,K=(F+H)/2,tt=[{offsetX:$,offsetY:F},{offsetX:q,offsetY:F},{offsetX:N,offsetY:F},{offsetX:N,offsetY:K},{offsetX:N,offsetY:H},{offsetX:q,offsetY:H},{offsetX:$,offsetY:H},{offsetX:$,offsetY:K}];let ot=[];for(const{offsetX:xt,offsetY:Tt}of tt)ot.push(new p.P(B.x+S.x*xt+z.x*Tt,B.y+S.y*xt+z.y*Tt));let ut=!1;if(c){const xt=ot.map((Tt=>this.projectAndGetPerspectiveRatio(n,Tt.x,Tt.y,o,b)));ut=xt.some((Tt=>!Tt.isOccluded)),ot=xt.map((Tt=>Tt.point))}else ut=!0;return{box:p.ao(ot),allPointsOccluded:!ut}}}function Gt(u,t,s){return t*(p.X/(u.tileSize*Math.pow(2,s-u.tileID.overscaledZ)))}class ke{constructor(t,s,n,o){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?s:-s))):o&&n?1:0,this.placed=n}isHidden(){return this.opacity===0&&!this.placed}}class xe{constructor(t,s,n,o,c){this.text=new ke(t?t.text:null,s,n,c),this.icon=new ke(t?t.icon:null,s,o,c)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Zt{constructor(t,s,n){this.text=t,this.icon=s,this.skipFade=n}}class re{constructor(){this.invProjMatrix=p.H(),this.viewportMatrix=p.H(),this.circles=[]}}class ge{constructor(t,s,n,o,c){this.bucketInstanceId=t,this.featureIndex=s,this.sourceLayerIndex=n,this.bucketIndex=o,this.tileID=c}}class Ce{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const s=++this.maxGroupID;this.collisionGroups[t]={ID:s,predicate:n=>n.collisionGroupID===s}}return this.collisionGroups[t]}}function Re(u,t,s,n,o){const{horizontalAlign:c,verticalAlign:m}=p.au(u);return new p.P(-(c-.5)*t+n[0]*o,-(m-.5)*s+n[1]*o)}class We{constructor(t,s,n,o,c,m){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new Jt(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new Ce(c),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=m,m&&(m.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const s=this.terrain;return s?(n,o)=>s.getElevation(t,n,o):null}getBucketParts(t,s,n,o){const c=n.getBucket(s),m=n.latestFeatureIndex;if(!c||!m||s.id!==c.layerIds[0])return;const g=n.collisionBoxArray,y=c.layers[0].layout,b=c.layers[0].paint,T=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),S=n.tileSize/p.X,z=n.tileID.toUnwrapped(),A=this.transform.calculatePosMatrix(z),B=y.get("text-pitch-alignment")==="map",V=y.get("text-rotation-alignment")==="map",$=Gt(n,1,this.transform.zoom),N=this.collisionIndex.mapProjection.translatePosition(this.transform,n,b.get("text-translate"),b.get("text-translate-anchor")),q=this.collisionIndex.mapProjection.translatePosition(this.transform,n,b.get("icon-translate"),b.get("icon-translate-anchor")),F=Er(A,B,V,this.transform,$);let H=null;if(B){const tt=rr(A,B,V,this.transform,$);H=p.L([],this.transform.labelPlaneMatrix,tt)}this.retainedQueryData[c.bucketInstanceId]=new ge(c.bucketInstanceId,m,c.sourceLayerIndex,c.index,n.tileID);const K={bucket:c,layout:y,translationText:N,translationIcon:q,posMatrix:A,unwrappedTileID:z,textLabelPlaneMatrix:F,labelToScreenMatrix:H,scale:T,textPixelRatio:S,holdingForFade:n.holdingForFade(),collisionBoxArray:g,partiallyEvaluatedTextSize:p.ag(c.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(c.sourceID)};if(o)for(const tt of c.sortKeyRanges){const{sortKey:ot,symbolInstanceStart:ut,symbolInstanceEnd:xt}=tt;t.push({sortKey:ot,symbolInstanceStart:ut,symbolInstanceEnd:xt,parameters:K})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:c.symbolInstances.length,parameters:K})}attemptAnchorPlacement(t,s,n,o,c,m,g,y,b,T,S,z,A,B,V,$,N,q,F){const H=p.aq[t.textAnchor],K=[t.textOffset0,t.textOffset1],tt=Re(H,n,o,K,c),ot=this.collisionIndex.placeCollisionBox(s,z,y,b,T,g,m,$,S.predicate,F,tt);if((!q||this.collisionIndex.placeCollisionBox(q,z,y,b,T,g,m,N,S.predicate,F,tt).placeable)&&ot.placeable){let ut;if(this.prevPlacement&&this.prevPlacement.variableOffsets[A.crossTileID]&&this.prevPlacement.placements[A.crossTileID]&&this.prevPlacement.placements[A.crossTileID].text&&(ut=this.prevPlacement.variableOffsets[A.crossTileID].anchor),A.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[A.crossTileID]={textOffset:K,width:n,height:o,anchor:H,textBoxScale:c,prevAnchor:ut},this.markUsedJustification(B,H,A,V),B.allowVerticalPlacement&&(this.markUsedOrientation(B,V,A),this.placedOrientations[A.crossTileID]=V),{shift:tt,placedGlyphBoxes:ot}}}placeLayerBucketPart(t,s,n){const{bucket:o,layout:c,translationText:m,translationIcon:g,posMatrix:y,unwrappedTileID:b,textLabelPlaneMatrix:T,labelToScreenMatrix:S,textPixelRatio:z,holdingForFade:A,collisionBoxArray:B,partiallyEvaluatedTextSize:V,collisionGroup:$}=t.parameters,N=c.get("text-optional"),q=c.get("icon-optional"),F=p.ar(c,"text-overlap","text-allow-overlap"),H=F==="always",K=p.ar(c,"icon-overlap","icon-allow-overlap"),tt=K==="always",ot=c.get("text-rotation-alignment")==="map",ut=c.get("text-pitch-alignment")==="map",xt=c.get("icon-text-fit")!=="none",Tt=c.get("symbol-z-order")==="viewport-y",ft=H&&(tt||!o.hasIconData()||q),pt=tt&&(H||!o.hasTextData()||N);!o.collisionArrays&&B&&o.deserializeCollisionBoxes(B);const Et=this._getTerrainElevationFunc(this.retainedQueryData[o.bucketInstanceId].tileID),Vt=(gt,bt,Lt)=>{var pe,$t;if(s[gt.crossTileID])return;if(A)return void(this.placements[gt.crossTileID]=new Zt(!1,!1,!1));let Xt=!1,fe=!1,Ve=!0,Ui=null,me={box:null,placeable:!1,offscreen:null},si={box:null,placeable:!1,offscreen:null},Ke=null,je=null,Je=null,or=0,Rs=0,nn=0;bt.textFeatureIndex?or=bt.textFeatureIndex:gt.useRuntimeCollisionCircles&&(or=gt.featureIndex),bt.verticalTextFeatureIndex&&(Rs=bt.verticalTextFeatureIndex);const Bs=bt.textBox;if(Bs){const Mi=Be=>{let Ue=p.ah.horizontal;if(o.allowVerticalPlacement&&!Be&&this.prevPlacement){const gi=this.prevPlacement.placedOrientations[gt.crossTileID];gi&&(this.placedOrientations[gt.crossTileID]=gi,Ue=gi,this.markUsedOrientation(o,Ue,gt))}return Ue},Ei=(Be,Ue)=>{if(o.allowVerticalPlacement&&gt.numVerticalGlyphVertices>0&&bt.verticalTextBox){for(const gi of o.writingModes)if(gi===p.ah.vertical?(me=Ue(),si=me):me=Be(),me&&me.placeable)break}else me=Be()},Pr=gt.textAnchorOffsetStartIndex,$i=gt.textAnchorOffsetEndIndex;if($i===Pr){const Be=(Ue,gi)=>{const Wt=this.collisionIndex.placeCollisionBox(Ue,F,z,y,b,ut,ot,m,$.predicate,Et);return Wt&&Wt.placeable&&(this.markUsedOrientation(o,gi,gt),this.placedOrientations[gt.crossTileID]=gi),Wt};Ei((()=>Be(Bs,p.ah.horizontal)),(()=>{const Ue=bt.verticalTextBox;return o.allowVerticalPlacement&&gt.numVerticalGlyphVertices>0&&Ue?Be(Ue,p.ah.vertical):{box:null,offscreen:null}})),Mi(me&&me.placeable)}else{let Be=p.aq[($t=(pe=this.prevPlacement)===null||pe===void 0?void 0:pe.variableOffsets[gt.crossTileID])===null||$t===void 0?void 0:$t.anchor];const Ue=(Wt,is,Fs)=>{const Ls=Wt.x2-Wt.x1,pl=Wt.y2-Wt.y1,uc=gt.textBoxScale,fl=xt&&K==="never"?is:null;let Ar=null,ml=F==="never"?1:2,ln="never";Be&&ml++;for(let ga=0;ga<ml;ga++){for(let cn=Pr;cn<$i;cn++){const un=o.textAnchorOffsets.get(cn);if(Be&&un.textAnchor!==Be)continue;const Os=this.attemptAnchorPlacement(un,Wt,Ls,pl,uc,ot,ut,z,y,b,$,ln,gt,o,Fs,m,g,fl,Et);if(Os&&(Ar=Os.placedGlyphBoxes,Ar&&Ar.placeable))return Xt=!0,Ui=Os.shift,Ar}Be?Be=null:ln=F}return n&&!Ar&&(Ar={box:this.collisionIndex.placeCollisionBox(Bs,"always",z,y,b,ut,ot,m,$.predicate,Et,new p.P(0,0)).box,offscreen:!1,placeable:!1}),Ar};Ei((()=>Ue(Bs,bt.iconBox,p.ah.horizontal)),(()=>{const Wt=bt.verticalTextBox;return o.allowVerticalPlacement&&(!me||!me.placeable)&&gt.numVerticalGlyphVertices>0&&Wt?Ue(Wt,bt.verticalIconBox,p.ah.vertical):{box:null,occluded:!0,offscreen:null}})),me&&(Xt=me.placeable,Ve=me.offscreen);const gi=Mi(me&&me.placeable);if(!Xt&&this.prevPlacement){const Wt=this.prevPlacement.variableOffsets[gt.crossTileID];Wt&&(this.variableOffsets[gt.crossTileID]=Wt,this.markUsedJustification(o,Wt.anchor,gt,gi))}}}if(Ke=me,Xt=Ke&&Ke.placeable,Ve=Ke&&Ke.offscreen,gt.useRuntimeCollisionCircles){const Mi=o.text.placedSymbolArray.get(gt.centerJustifiedTextSymbolIndex),Ei=p.ai(o.textSizeData,V,Mi),Pr=c.get("text-padding");je=this.collisionIndex.placeCollisionCircles(F,Mi,o.lineVertexArray,o.glyphOffsetArray,Ei,y,b,T,S,n,ut,$.predicate,gt.collisionCircleDiameter,Pr,m,Et),je.circles.length&&je.collisionDetected&&!n&&p.w("Collisions detected, but collision boxes are not shown"),Xt=H||je.circles.length>0&&!je.collisionDetected,Ve=Ve&&je.offscreen}if(bt.iconFeatureIndex&&(nn=bt.iconFeatureIndex),bt.iconBox){const Mi=Ei=>this.collisionIndex.placeCollisionBox(Ei,K,z,y,b,ut,ot,g,$.predicate,Et,xt&&Ui?Ui:void 0);si&&si.placeable&&bt.verticalIconBox?(Je=Mi(bt.verticalIconBox),fe=Je.placeable):(Je=Mi(bt.iconBox),fe=Je.placeable),Ve=Ve&&Je.offscreen}const ki=N||gt.numHorizontalGlyphVertices===0&&gt.numVerticalGlyphVertices===0,on=q||gt.numIconVertices===0;ki||on?on?ki||(fe=fe&&Xt):Xt=fe&&Xt:fe=Xt=fe&&Xt;const mo=fe&&Je.placeable;if(Xt&&Ke.placeable&&this.collisionIndex.insertCollisionBox(Ke.box,F,c.get("text-ignore-placement"),o.bucketInstanceId,si&&si.placeable&&Rs?Rs:or,$.ID),mo&&this.collisionIndex.insertCollisionBox(Je.box,K,c.get("icon-ignore-placement"),o.bucketInstanceId,nn,$.ID),je&&Xt&&this.collisionIndex.insertCollisionCircles(je.circles,F,c.get("text-ignore-placement"),o.bucketInstanceId,or,$.ID),n&&this.storeCollisionData(o.bucketInstanceId,Lt,bt,Ke,Je,je),gt.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[gt.crossTileID]=new Zt(Xt||ft,fe||pt,Ve||o.justReloaded),s[gt.crossTileID]=!0};if(Tt){if(t.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const gt=o.getSortedSymbolIndexes(this.transform.angle);for(let bt=gt.length-1;bt>=0;--bt){const Lt=gt[bt];Vt(o.symbolInstances.get(Lt),o.collisionArrays[Lt],Lt)}}else for(let gt=t.symbolInstanceStart;gt<t.symbolInstanceEnd;gt++)Vt(o.symbolInstances.get(gt),o.collisionArrays[gt],gt);if(n&&o.bucketInstanceId in this.collisionCircleArrays){const gt=this.collisionCircleArrays[o.bucketInstanceId];p.as(gt.invProjMatrix,y),gt.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}storeCollisionData(t,s,n,o,c,m){if(n.textBox||n.iconBox){let g,y;this.collisionBoxArrays.has(t)?g=this.collisionBoxArrays.get(t):(g=new Map,this.collisionBoxArrays.set(t,g)),g.has(s)?y=g.get(s):(y={text:null,icon:null},g.set(s,y)),n.textBox&&(y.text=o.box),n.iconBox&&(y.icon=c.box)}if(m){let g=this.collisionCircleArrays[t];g===void 0&&(g=this.collisionCircleArrays[t]=new re);for(let y=0;y<m.circles.length;y+=4)g.circles.push(m.circles[y+0]),g.circles.push(m.circles[y+1]),g.circles.push(m.circles[y+2]),g.circles.push(m.collisionDetected?1:0)}}markUsedJustification(t,s,n,o){let c;c=o===p.ah.vertical?n.verticalPlacedTextSymbolIndex:{left:n.leftJustifiedTextSymbolIndex,center:n.centerJustifiedTextSymbolIndex,right:n.rightJustifiedTextSymbolIndex}[p.at(s)];const m=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex,n.verticalPlacedTextSymbolIndex];for(const g of m)g>=0&&(t.text.placedSymbolArray.get(g).crossTileID=c>=0&&g!==c?0:n.crossTileID)}markUsedOrientation(t,s,n){const o=s===p.ah.horizontal||s===p.ah.horizontalOnly?s:0,c=s===p.ah.vertical?s:0,m=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const g of m)t.text.placedSymbolArray.get(g).placedOrientation=o;n.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=c)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const s=this.prevPlacement;let n=!1;this.prevZoomAdjustment=s?s.zoomAdjustment(this.transform.zoom):0;const o=s?s.symbolFadeChange(t):1,c=s?s.opacities:{},m=s?s.variableOffsets:{},g=s?s.placedOrientations:{};for(const y in this.placements){const b=this.placements[y],T=c[y];T?(this.opacities[y]=new xe(T,o,b.text,b.icon),n=n||b.text!==T.text.placed||b.icon!==T.icon.placed):(this.opacities[y]=new xe(null,o,b.text,b.icon,b.skipFade),n=n||b.text||b.icon)}for(const y in c){const b=c[y];if(!this.opacities[y]){const T=new xe(b,o,!1,!1);T.isHidden()||(this.opacities[y]=T,n=n||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 g)this.placedOrientations[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.placedOrientations[y]=g[y]);if(s&&s.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");n?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=s?s.lastPlacementChangeTime:t)}updateLayerOpacities(t,s){const n={};for(const o of s){const c=o.getBucket(t);c&&o.latestFeatureIndex&&t.id===c.layerIds[0]&&this.updateBucketOpacities(c,o.tileID,n,o.collisionBoxArray)}}updateBucketOpacities(t,s,n,o){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0],m=c.layout,g=new xe(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",z=m.get("text-pitch-alignment")==="map",A=m.get("icon-text-fit")!=="none",B=new xe(null,0,y&&(b||!t.hasIconData()||m.get("icon-optional")),b&&(y||!t.hasTextData()||m.get("text-optional")),!0);!t.collisionArrays&&o&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(o);const V=(N,q,F)=>{for(let H=0;H<q/4;H++)N.opacityVertexArray.emplaceBack(F);N.hasVisibleVertices=N.hasVisibleVertices||F!==ps},$=this.collisionBoxArrays.get(t.bucketInstanceId);for(let N=0;N<t.symbolInstances.length;N++){const q=t.symbolInstances.get(N),{numHorizontalGlyphVertices:F,numVerticalGlyphVertices:H,crossTileID:K}=q;let tt=this.opacities[K];n[K]?tt=g:tt||(tt=B,this.opacities[K]=tt),n[K]=!0;const ot=q.numIconVertices>0,ut=this.placedOrientations[q.crossTileID],xt=ut===p.ah.vertical,Tt=ut===p.ah.horizontal||ut===p.ah.horizontalOnly;if(F>0||H>0){const pt=fi(tt.text);V(t.text,F,xt?ps:pt),V(t.text,H,Tt?ps:pt);const Et=tt.text.isHidden();[q.rightJustifiedTextSymbolIndex,q.centerJustifiedTextSymbolIndex,q.leftJustifiedTextSymbolIndex].forEach((bt=>{bt>=0&&(t.text.placedSymbolArray.get(bt).hidden=Et||xt?1:0)})),q.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(q.verticalPlacedTextSymbolIndex).hidden=Et||Tt?1:0);const Vt=this.variableOffsets[q.crossTileID];Vt&&this.markUsedJustification(t,Vt.anchor,q,ut);const gt=this.placedOrientations[q.crossTileID];gt&&(this.markUsedJustification(t,"left",q,gt),this.markUsedOrientation(t,gt,q))}if(ot){const pt=fi(tt.icon),Et=!(A&&q.verticalPlacedIconSymbolIndex&&xt);q.placedIconSymbolIndex>=0&&(V(t.icon,q.numIconVertices,Et?pt:ps),t.icon.placedSymbolArray.get(q.placedIconSymbolIndex).hidden=tt.icon.isHidden()),q.verticalPlacedIconSymbolIndex>=0&&(V(t.icon,q.numVerticalIconVertices,Et?ps:pt),t.icon.placedSymbolArray.get(q.verticalPlacedIconSymbolIndex).hidden=tt.icon.isHidden())}const ft=$&&$.has(N)?$.get(N):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const pt=t.collisionArrays[N];if(pt){let Et=new p.P(0,0);if(pt.textBox||pt.verticalTextBox){let Vt=!0;if(T){const gt=this.variableOffsets[K];gt?(Et=Re(gt.anchor,gt.width,gt.height,gt.textOffset,gt.textBoxScale),S&&Et._rotate(z?this.transform.angle:-this.transform.angle)):Vt=!1}if(pt.textBox||pt.verticalTextBox){let gt;pt.textBox&&(gt=xt),pt.verticalTextBox&&(gt=Tt),ds(t.textCollisionBox.collisionVertexArray,tt.text.placed,!Vt||gt,ft.text,Et.x,Et.y)}}if(pt.iconBox||pt.verticalIconBox){const Vt=!!(!Tt&&pt.verticalIconBox);let gt;pt.iconBox&&(gt=Vt),pt.verticalIconBox&&(gt=!Vt),ds(t.iconCollisionBox.collisionVertexArray,tt.icon.placed,gt,ft.icon,A?Et.x:0,A?Et.y:0)}}}}if(t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(t.bucketInstanceId in this.collisionCircleArrays){const N=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=N.invProjMatrix,t.placementViewportMatrix=N.viewportMatrix,t.collisionCircleArray=N.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,s){const n=this.zoomAtLastRecencyCheck===s?1-this.zoomAdjustment(s):1;return this.zoomAtLastRecencyCheck=s,this.commitTime+this.fadeDuration*n>t}setStale(){this.stale=!0}}function ds(u,t,s,n,o,c){n&&n.length!==0||(n=[0,0,0,0]);const m=n[0]-Ut,g=n[1]-Ut,y=n[2]-Ut,b=n[3]-Ut;u.emplaceBack(t?1:0,s?1:0,o||0,c||0,m,g),u.emplaceBack(t?1:0,s?1:0,o||0,c||0,y,g),u.emplaceBack(t?1:0,s?1:0,o||0,c||0,y,b),u.emplaceBack(t?1:0,s?1:0,o||0,c||0,m,b)}const se=Math.pow(2,25),In=Math.pow(2,24),kn=Math.pow(2,17),di=Math.pow(2,16),pi=Math.pow(2,9),Ol=Math.pow(2,8),wi=Math.pow(2,1);function fi(u){if(u.opacity===0&&!u.placed)return 0;if(u.opacity===1&&u.placed)return 4294967295;const t=u.placed?1:0,s=Math.floor(127*u.opacity);return s*se+t*In+s*kn+t*di+s*pi+t*Ol+s*wi+t}const ps=0;function Zr(){return{isOccluded:(u,t,s)=>!1,getPitchedTextCorrection:(u,t,s)=>1,get useSpecialProjectionForSymbols(){return!1},projectTileCoordinates(u,t,s,n){throw new Error("Not implemented.")},translatePosition:(u,t,s,n)=>(function(o,c,m,g,y=!1){if(!m[0]&&!m[1])return[0,0];const b=y?g==="map"?o.angle:0:g==="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]:Gt(c,m[0],o.zoom),y?m[1]:Gt(c,m[1],o.zoom)]})(u,t,s,n),getCircleRadiusCorrection:u=>1}}class Me{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,s,n,o,c){const m=this._bucketParts;for(;this._currentTileIndex<t.length;)if(s.getBucketParts(m,o,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,c())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,m.sort(((g,y)=>g.sortKey-y.sortKey)));this._currentPartIndex<m.length;)if(s.placeLayerBucketPart(m[this._currentPartIndex],this._seenCrossTileIDs,n),this._currentPartIndex++,c())return!0;return!1}}class Qs{constructor(t,s,n,o,c,m,g,y){this.placement=new We(t,Zr(),s,m,g,y),this._currentPlacementIndex=n.length-1,this._forceFullPlacement=o,this._showCollisionBoxes=c,this._done=!1}isDone(){return this._done}continuePlacement(t,s,n){const o=mt.now(),c=()=>!this._forceFullPlacement&&mt.now()-o>2;for(;this._currentPlacementIndex>=0;){const m=s[t[this._currentPlacementIndex]],g=this.placement.collisionIndex.transform.zoom;if(m.type==="symbol"&&(!m.minzoom||m.minzoom<=g)&&(!m.maxzoom||m.maxzoom>g)){if(this._inProgressLayer||(this._inProgressLayer=new Me(m)),this._inProgressLayer.continuePlacement(n[m.source],this.placement,this._showCollisionBoxes,m,c))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Fi=512/p.X/2;class Se{constructor(t,s,n){this.tileID=t,this.bucketInstanceId=n,this._symbolsByKey={};const o=new Map;for(let c=0;c<s.length;c++){const m=s.get(c),g=m.key,y=o.get(g);y?y.push(m):o.set(g,[m])}for(const[c,m]of o){const g={positions:m.map((y=>({x:Math.floor(y.anchorX*Fi),y:Math.floor(y.anchorY*Fi)}))),crossTileIDs:m.map((y=>y.crossTileID))};if(g.positions.length>128){const y=new p.av(g.positions.length,16,Uint16Array);for(const{x:b,y:T}of g.positions)y.add(b,T);y.finish(),delete g.positions,g.index=y}this._symbolsByKey[c]=g}}getScaledCoordinates(t,s){const{x:n,y:o,z:c}=this.tileID.canonical,{x:m,y:g,z:y}=s.canonical,b=Fi/Math.pow(2,y-c),T=(g*p.X+t.anchorY)*b,S=o*p.X*Fi;return{x:Math.floor((m*p.X+t.anchorX)*b-n*p.X*Fi),y:Math.floor(T-S)}}findMatches(t,s,n){const o=this.tileID.canonical.z<s.canonical.z?1:Math.pow(2,this.tileID.canonical.z-s.canonical.z);for(let c=0;c<t.length;c++){const m=t.get(c);if(m.crossTileID)continue;const g=this._symbolsByKey[m.key];if(!g)continue;const y=this.getScaledCoordinates(m,s);if(g.index){const b=g.index.range(y.x-o,y.y-o,y.x+o,y.y+o).sort();for(const T of b){const S=g.crossTileIDs[T];if(!n[S]){n[S]=!0,m.crossTileID=S;break}}}else if(g.positions)for(let b=0;b<g.positions.length;b++){const T=g.positions[b],S=g.crossTileIDs[b];if(Math.abs(T.x-y.x)<=o&&Math.abs(T.y-y.y)<=o&&!n[S]){n[S]=!0,m.crossTileID=S;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}}class Ea{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Li{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const s=Math.round((t-this.lng)/360);if(s!==0)for(const n in this.indexes){const o=this.indexes[n],c={};for(const m in o){const g=o[m];g.tileID=g.tileID.unwrapTo(g.tileID.wrap+s),c[g.tileID.key]=g}this.indexes[n]=c}this.lng=t}addBucket(t,s,n){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===s.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let c=0;c<s.symbolInstances.length;c++)s.symbolInstances.get(c).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const o=this.usedCrossTileIDs[t.overscaledZ];for(const c in this.indexes){const m=this.indexes[c];if(Number(c)>t.overscaledZ)for(const g in m){const y=m[g];y.tileID.isChildOf(t)&&y.findMatches(s.symbolInstances,t,o)}else{const g=m[t.scaledTo(Number(c)).key];g&&g.findMatches(s.symbolInstances,t,o)}}for(let c=0;c<s.symbolInstances.length;c++){const m=s.symbolInstances.get(c);m.crossTileID||(m.crossTileID=n.generate(),o[m.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Se(t,s.symbolInstances,s.bucketInstanceId),!0}removeBucketCrossTileIDs(t,s){for(const n of s.getCrossTileIDsLists())for(const o of n)delete this.usedCrossTileIDs[t][o]}removeStaleBuckets(t){let s=!1;for(const n in this.indexes){const o=this.indexes[n];for(const c in o)t[o[c].bucketInstanceId]||(this.removeBucketCrossTileIDs(n,o[c]),delete o[c],s=!0)}return s}}class Mn{constructor(){this.layerIndexes={},this.crossTileIDs=new Ea,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,s,n){let o=this.layerIndexes[t.id];o===void 0&&(o=this.layerIndexes[t.id]=new Li);let c=!1;const m={};o.handleWrapJump(n);for(const g of s){const y=g.getBucket(t);y&&t.id===y.layerIds[0]&&(y.bucketInstanceId||(y.bucketInstanceId=++this.maxBucketInstanceId),o.addBucket(g.tileID,y,this.crossTileIDs)&&(c=!0),m[y.bucketInstanceId]=!0)}return o.removeStaleBuckets(m)&&(c=!0),c}pruneUnusedLayers(t){const s={};t.forEach((n=>{s[n]=!0}));for(const n in this.layerIndexes)s[n]||delete this.layerIndexes[n]}}const Oi=(u,t)=>p.t(u,t&&t.filter((s=>s.identifier!=="source.canvas"))),Vl=p.aw();class za extends p.E{constructor(t,s={}){super(),this._rtlPluginLoaded=()=>{for(const n in this.sourceCaches){const o=this.sourceCaches[n].getSource().type;o!=="vector"&&o!=="geojson"||this.sourceCaches[n].reload()}},this.map=t,this.dispatcher=new $r(Ur(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((n,o)=>this.getGlyphs(n,o))),this.dispatcher.registerMessageHandler("GI",((n,o)=>this.getImages(n,o))),this.imageManager=new Le,this.imageManager.setEventedParent(this),this.glyphManager=new Yi(t._requestManager,s.localIdeographFontFamily),this.lineAtlas=new ls(256,512),this.crossTileSymbolIndex=new Mn,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()),er().on(ht,this._rtlPluginLoaded),this.on("data",(n=>{if(n.dataType!=="source"||n.sourceDataType!=="metadata")return;const o=this.sourceCaches[n.sourceId];if(!o)return;const c=o.getSource();if(c&&c.vectorLayerIds)for(const m in this._layers){const g=this._layers[m];g.source===c.id&&this._validateLayer(g)}}))}loadURL(t,s={},n){this.fire(new p.k("dataloading",{dataType:"style"})),s.validate=typeof s.validate!="boolean"||s.validate;const o=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController;const c=this._loadStyleRequest;p.h(o,this._loadStyleRequest).then((m=>{this._loadStyleRequest=null,this._load(m.data,s,n)})).catch((m=>{this._loadStyleRequest=null,m&&!c.signal.aborted&&this.fire(new p.j(m))}))}loadJSON(t,s={},n){this.fire(new p.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,mt.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,s.validate=s.validate!==!1,this._load(t,s,n)})).catch((()=>{}))}loadEmpty(){this.fire(new p.k("dataloading",{dataType:"style"})),this._load(Vl,{validate:!1})}_load(t,s,n){var o;const c=s.transformStyle?s.transformStyle(n,t):t;if(!s.validate||!Oi(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 dr(this.stylesheet.light),this.sky=new Di(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 t=p.az(this.stylesheet.layers);this.dispatcher.broadcast("SL",t),this._order=t.map((s=>s.id)),this._layers={},this._serializedLayers=null;for(const s of t){const n=p.aA(s);n.setEventedParent(this,{layer:{id:s.id}}),this._layers[s.id]=n}}_loadSprite(t,s=!1,n=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,(function(c,m,g,y){return p._(this,void 0,void 0,(function*(){const b=Ji(c),T=g>1?"@2x":"",S={},z={};for(const{id:A,url:B}of b){const V=m.transformRequest(Xs(B,T,".json"),"SpriteJSON");S[A]=p.h(V,y);const $=m.transformRequest(Xs(B,T,".png"),"SpriteImage");z[A]=ui.getImage($,y)}return yield Promise.all([...Object.values(S),...Object.values(z)]),(function(A,B){return p._(this,void 0,void 0,(function*(){const V={};for(const $ in A){V[$]={};const N=mt.getImageCanvasContext((yield B[$]).data),q=(yield A[$]).data;for(const F in q){const{width:H,height:K,x:tt,y:ot,sdf:ut,pixelRatio:xt,stretchX:Tt,stretchY:ft,content:pt,textFitWidth:Et,textFitHeight:Vt}=q[F];V[$][F]={data:null,pixelRatio:xt,sdf:ut,stretchX:Tt,stretchY:ft,content:pt,textFitWidth:Et,textFitHeight:Vt,spriteData:{width:H,height:K,x:tt,y:ot,context:N}}}}return V}))})(S,z)}))})(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((c=>{if(this._spriteRequest=null,c)for(const m in c){this._spritesImagesIds[m]=[];const g=this._spritesImagesIds[m]?this._spritesImagesIds[m].filter((y=>!(y in c))):[];for(const y of g)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]),s&&(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(),s&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"})),n&&n(o)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!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(t){const s=this.sourceCaches[t.source];if(!s)return;const n=t.sourceLayer;if(!n)return;const o=s.getSource();(o.type==="geojson"||o.vectorLayerIds&&o.vectorLayerIds.indexOf(n)===-1)&&this.fire(new p.j(new Error(`Source layer "${n}" does not exist on source "${o.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t,s=!1){const n=this._serializedAllLayers();if(!t||t.length===0)return Object.values(s?p.aB(n):n);const o=[];for(const c of t)if(n[c]){const m=s?p.aB(n[c]):n[c];o.push(m)}return o}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const s=Object.keys(this._layers);for(const n of s){const o=this._layers[n];o.type!=="custom"&&(t[n]=o.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition()||this.sky&&this.sky.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const s=this._changed;if(s){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 g=this._updatedSources[m];if(g==="reload")this._reloadSource(m);else{if(g!=="clear")throw new Error(`Invalid action ${g}`);this._clearSource(m)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const m in this._updatedPaintProps)this._layers[m].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}const n={};for(const o in this.sourceCaches){const c=this.sourceCaches[o];n[o]=c.used,c.used=!1}for(const o of this._order){const c=this._layers[o];c.recalculate(t,this._availableImages),!c.isHidden(t.zoom)&&c.source&&(this.sourceCaches[c.source].used=!0)}for(const o in n){const c=this.sourceCaches[o];!!n[o]!=!!c.used&&c.fire(new p.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:o}))}this.light.recalculate(t),this.sky.recalculate(t),this.z=t.zoom,s&&this.fire(new p.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const s in this.sourceCaches)this.sourceCaches[s].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,s){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:s})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,s={}){var n;this._checkLoaded();const o=this.serialize();if(t=s.transformStyle?s.transformStyle(o,t):t,((n=s.validate)===null||n===void 0||n)&&Oi(this,p.u(t)))return!1;(t=p.aB(t)).layers=p.az(t.layers);const c=p.aC(o,t),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 g of m.operations)g();return this.stylesheet=t,this._serializedLayers=null,!0}_getOperationsToPerform(t){const s=[],n=[];for(const o of t)switch(o.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":s.push((()=>this.addLayer.apply(this,o.args)));break;case"removeLayer":s.push((()=>this.removeLayer.apply(this,o.args)));break;case"setPaintProperty":s.push((()=>this.setPaintProperty.apply(this,o.args)));break;case"setLayoutProperty":s.push((()=>this.setLayoutProperty.apply(this,o.args)));break;case"setFilter":s.push((()=>this.setFilter.apply(this,o.args)));break;case"addSource":s.push((()=>this.addSource.apply(this,o.args)));break;case"removeSource":s.push((()=>this.removeSource.apply(this,o.args)));break;case"setLayerZoomRange":s.push((()=>this.setLayerZoomRange.apply(this,o.args)));break;case"setLight":s.push((()=>this.setLight.apply(this,o.args)));break;case"setGeoJSONSourceData":s.push((()=>this.setGeoJSONSourceData.apply(this,o.args)));break;case"setGlyphs":s.push((()=>this.setGlyphs.apply(this,o.args)));break;case"setSprite":s.push((()=>this.setSprite.apply(this,o.args)));break;case"setSky":s.push((()=>this.setSky.apply(this,o.args)));break;case"setTerrain":s.push((()=>this.map.setTerrain.apply(this,o.args)));break;case"setTransition":s.push((()=>{}));break;default:n.push(o.command)}return{operations:s,unimplemented:n}}addImage(t,s){if(this.getImage(t))return this.fire(new p.j(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,s),this._afterImageUpdated(t)}updateImage(t,s){this.imageManager.updateImage(t,s)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new p.j(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!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(t,s,n={}){if(this._checkLoaded(),this.sourceCaches[t]!==void 0)throw new Error(`Source "${t}" already exists.`);if(!s.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(s).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(s.type)>=0&&this._validate(p.u.source,`sources.${t}`,s,null,n))return;this.map&&this.map._collectResourceTiming&&(s.collectResourceTiming=!0);const o=this.sourceCaches[t]=new Ft(t,s,this.dispatcher);o.style=this,o.setEventedParent(this,(()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:t}))),o.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error("There is no source with this ID");for(const n in this._layers)if(this._layers[n].source===t)return this.fire(new p.j(new Error(`Source "${t}" cannot be removed while layer "${n}" is using it.`)));const s=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],s.fire(new p.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),s.setEventedParent(null),s.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,s){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error(`There is no source with this ID=${t}`);const n=this.sourceCaches[t].getSource();if(n.type!=="geojson")throw new Error(`geojsonSource.type is ${n.type}, which is !== 'geojson`);n.setData(s),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,s,n={}){this._checkLoaded();const o=t.id;if(this.getLayer(o))return void this.fire(new p.j(new Error(`Layer "${o}" already exists on this map.`)));let c;if(t.type==="custom"){if(Oi(this,p.aD(t)))return;c=p.aA(t)}else{if("source"in t&&typeof t.source=="object"&&(this.addSource(o,t.source),t=p.aB(t),t=p.e(t,{source:o})),this._validate(p.u.layer,`layers.${o}`,t,{arrayIndex:-1},n))return;c=p.aA(t),this._validateLayer(c),c.setEventedParent(this,{layer:{id:o}})}const m=s?this._order.indexOf(s):this._order.length;if(s&&m===-1)this.fire(new p.j(new Error(`Cannot add layer "${o}" before non-existing layer "${s}".`)));else{if(this._order.splice(m,0,o),this._layerOrderChanged=!0,this._layers[o]=c,this._removedLayers[o]&&c.source&&c.type!=="custom"){const g=this._removedLayers[o];delete this._removedLayers[o],g.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(t,s){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new p.j(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===s)return;const n=this._order.indexOf(t);this._order.splice(n,1);const o=s?this._order.indexOf(s):this._order.length;s&&o===-1?this.fire(new p.j(new Error(`Cannot move layer "${t}" before non-existing layer "${s}".`))):(this._order.splice(o,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const s=this._layers[t];if(!s)return void this.fire(new p.j(new Error(`Cannot remove non-existing layer "${t}".`)));s.setEventedParent(null);const n=this._order.indexOf(t);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=s,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],s.onRemove&&s.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,s,n){this._checkLoaded();const o=this.getLayer(t);o?o.minzoom===s&&o.maxzoom===n||(s!=null&&(o.minzoom=s),n!=null&&(o.maxzoom=n),this._updateLayer(o)):this.fire(new p.j(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,s,n={}){this._checkLoaded();const o=this.getLayer(t);if(o){if(!p.aE(o.filter,s))return s==null?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(p.u.filter,`layers.${o.id}.filter`,s,null,n)||(o.filter=p.aB(s),this._updateLayer(o)))}else this.fire(new p.j(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return p.aB(this.getLayer(t).filter)}setLayoutProperty(t,s,n,o={}){this._checkLoaded();const c=this.getLayer(t);c?p.aE(c.getLayoutProperty(s),n)||(c.setLayoutProperty(s,n,o),this._updateLayer(c)):this.fire(new p.j(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,s){const n=this.getLayer(t);if(n)return n.getLayoutProperty(s);this.fire(new p.j(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,s,n,o={}){this._checkLoaded();const c=this.getLayer(t);c?p.aE(c.getPaintProperty(s),n)||(c.setPaintProperty(s,n,o)&&this._updateLayer(c),this._changed=!0,this._updatedPaintProps[t]=!0,this._serializedLayers=null):this.fire(new p.j(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,s){return this.getLayer(t).getPaintProperty(s)}setFeatureState(t,s){this._checkLoaded();const n=t.source,o=t.sourceLayer,c=this.sourceCaches[n];if(c===void 0)return void this.fire(new p.j(new Error(`The source '${n}' 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?(t.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),c.setFeatureState(o,t.id,s)):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,s){this._checkLoaded();const n=t.source,o=this.sourceCaches[n];if(o===void 0)return void this.fire(new p.j(new Error(`The source '${n}' does not exist in the map's style.`)));const c=o.getSource().type,m=c==="vector"?t.sourceLayer:void 0;c!=="vector"||m?s&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new p.j(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(m,t.id,s):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const s=t.source,n=t.sourceLayer,o=this.sourceCaches[s];if(o!==void 0)return o.getSource().type!=="vector"||n?(t.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),o.getFeatureState(n,t.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 '${s}' 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 t=p.aF(this.sourceCaches,(c=>c.serialize())),s=this._serializeByIds(this._order,!0),n=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:t,layers:s,terrain:n},(c=>c!==void 0))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.sourceCaches[t.source].getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const s=m=>this._layers[m].type==="fill-extrusion",n={},o=[];for(let m=this._order.length-1;m>=0;m--){const g=this._order[m];if(s(g)){n[g]=m;for(const y of t){const b=y[g];if(b)for(const T of b)o.push(T)}}}o.sort(((m,g)=>g.intersectionZ-m.intersectionZ));const c=[];for(let m=this._order.length-1;m>=0;m--){const g=this._order[m];if(s(g))for(let y=o.length-1;y>=0;y--){const b=o[y].feature;if(n[b.layer.id]<m)break;c.push(b),o.pop()}else for(const y of t){const b=y[g];if(b)for(const T of b)c.push(T.feature)}}return c}queryRenderedFeatures(t,s,n){s&&s.filter&&this._validate(p.u.filter,"queryRenderedFeatures.filter",s.filter,null,s);const o={};if(s&&s.layers){if(!Array.isArray(s.layers))return this.fire(new p.j(new Error("parameters.layers must be an Array."))),[];for(const g of s.layers){const y=this._layers[g];if(!y)return this.fire(new p.j(new Error(`The layer '${g}' does not exist in the map's style and cannot be queried for features.`))),[];o[y.source]=!0}}const c=[];s.availableImages=this._availableImages;const m=this._serializedAllLayers();for(const g in this.sourceCaches)s.layers&&!o[g]||c.push(Sr(this.sourceCaches[g],this._layers,m,t,s,n));return this.placement&&c.push((function(g,y,b,T,S,z,A){const B={},V=z.queryRenderedSymbols(T),$=[];for(const N of Object.keys(V).map(Number))$.push(A[N]);$.sort(Ir);for(const N of $){const q=N.featureIndex.lookupSymbolFeatures(V[N.bucketInstanceId],y,N.bucketIndex,N.sourceLayerIndex,S.filter,S.layers,S.availableImages,g);for(const F in q){const H=B[F]=B[F]||[],K=q[F];K.sort(((tt,ot)=>{const ut=N.featureSortOrder;if(ut){const xt=ut.indexOf(tt.featureIndex);return ut.indexOf(ot.featureIndex)-xt}return ot.featureIndex-tt.featureIndex}));for(const tt of K)H.push(tt)}}for(const N in B)B[N].forEach((q=>{const F=q.feature,H=b[g[N].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=H}));return B})(this._layers,m,this.sourceCaches,t,s,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(t,s){s&&s.filter&&this._validate(p.u.filter,"querySourceFeatures.filter",s.filter,null,s);const n=this.sourceCaches[t];return n?(function(o,c){const m=o.getRenderableIds().map((b=>o.getTileByID(b))),g=[],y={};for(let b=0;b<m.length;b++){const T=m[b],S=T.tileID.canonical.key;y[S]||(y[S]=!0,T.querySourceFeatures(g,c))}return g})(n,s):[]}getLight(){return this.light.getLight()}setLight(t,s={}){this._checkLoaded();const n=this.light.getLight();let o=!1;for(const m in t)if(!p.aE(t[m],n[m])){o=!0;break}if(!o)return;const c={now:mt.now(),transition:p.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,s),this.light.updateTransitions(c)}getSky(){var t;return(t=this.stylesheet)===null||t===void 0?void 0:t.sky}setSky(t,s={}){const n=this.getSky();let o=!1;if(!t&&!n)return;if(t&&!n)o=!0;else if(!t&&n)o=!0;else for(const m in t)if(!p.aE(t[m],n[m])){o=!0;break}if(!o)return;const c={now:mt.now(),transition:p.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,s),this.sky.updateTransitions(c)}_validate(t,s,n,o,c={}){return(!c||c.validate!==!1)&&Oi(this,t.call(p.u,p.e({key:s,style:this.serialize(),value:n,styleSpec:p.v},o)))}_remove(t=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),er().off(ht,this._rtlPluginLoaded);for(const s in this._layers)this._layers[s].setEventedParent(null);for(const s in this.sourceCaches){const n=this.sourceCaches[s];n.setEventedParent(null),n.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const s in this.sourceCaches)this.sourceCaches[s].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(t,s,n,o,c=!1){let m=!1,g=!1;const y={};for(const b of this._order){const T=this._layers[b];if(T.type!=="symbol")continue;if(!y[T.source]){const z=this.sourceCaches[T.source];y[T.source]=z.getRenderableIds(!0).map((A=>z.getTileByID(A))).sort(((A,B)=>B.tileID.overscaledZ-A.tileID.overscaledZ||(A.tileID.isLessThan(B.tileID)?-1:1)))}const S=this.crossTileSymbolIndex.addLayer(T,y[T.source],t.center.lng);m=m||S}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((c=c||this._layerOrderChanged||n===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(mt.now(),t.zoom))&&(this.pauseablePlacement=new Qs(t,this.map.terrain,this._order,c,s,n,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(mt.now()),g=!0),m&&this.pauseablePlacement.placement.setStale()),g||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(mt.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,s){return p._(this,void 0,void 0,(function*(){const n=yield this.imageManager.getImages(s.icons);this._updateTilesForChangedImages();const o=this.sourceCaches[s.source];return o&&o.setDependencies(s.tileID.key,s.type,s.icons),n}))}getGlyphs(t,s){return p._(this,void 0,void 0,(function*(){const n=yield this.glyphManager.getGlyphs(s.stacks),o=this.sourceCaches[s.source];return o&&o.setDependencies(s.tileID.key,s.type,[""]),n}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,s={}){this._checkLoaded(),t&&this._validate(p.u.glyphs,"glyphs",t,null,s)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,s,n={},o){this._checkLoaded();const c=[{id:t,url:s}],m=[...Ji(this.stylesheet.sprite),...c];this._validate(p.u.sprite,"sprite",m,null,n)||(this.stylesheet.sprite=m,this._loadSprite(c,!0,o))}removeSprite(t){this._checkLoaded();const s=Ji(this.stylesheet.sprite);if(s.find((n=>n.id===t))){if(this._spritesImagesIds[t])for(const n of this._spritesImagesIds[t])this.imageManager.removeImage(n),this._changedImages[n]=!0;s.splice(s.findIndex((n=>n.id===t)),1),this.stylesheet.sprite=s.length>0?s:void 0,delete this._spritesImagesIds[t],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 "${t}" doesn't exists on this map.`)))}getSprite(){return Ji(this.stylesheet.sprite)}setSprite(t,s={},n){this._checkLoaded(),t&&this._validate(p.u.sprite,"sprite",t,null,s)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,n):(this._unloadSprite(),n&&n(null)))}}var qr=p.Y([{name:"a_pos",type:"Int16",components:2}]);const zr={prelude:ee(`#ifdef GL_ES
6
+ precision mediump float;
7
+ #else
8
+ #if !defined(lowp)
9
+ #define lowp
10
+ #endif
11
+ #if !defined(mediump)
12
+ #define mediump
13
+ #endif
14
+ #if !defined(highp)
15
+ #define highp
16
+ #endif
17
+ #endif
18
+ `,`#ifdef GL_ES
19
+ precision highp float;
20
+ #else
21
+ #if !defined(lowp)
22
+ #define lowp
23
+ #endif
24
+ #if !defined(mediump)
25
+ #define mediump
26
+ #endif
27
+ #if !defined(highp)
28
+ #define highp
29
+ #endif
30
+ #endif
31
+ vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
32
+ );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}
33
+ #ifdef TERRAIN3D
34
+ uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;
35
+ #endif
36
+ const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {
37
+ #ifdef TERRAIN3D
38
+ highp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));
39
+ #else
40
+ return 1.0;
41
+ #endif
42
+ }float calculate_visibility(vec4 pos) {
43
+ #ifdef TERRAIN3D
44
+ vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;
45
+ #else
46
+ return 1.0;
47
+ #endif
48
+ }float ele(vec2 pos) {
49
+ #ifdef TERRAIN3D
50
+ vec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
51
+ #else
52
+ return 0.0;
53
+ #endif
54
+ }float get_elevation(vec2 pos) {
55
+ #ifdef TERRAIN3D
56
+ vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
57
+ #else
58
+ return 0.0;
59
+ #endif
60
+ }`),background:ee(`uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;
61
+ #ifdef OVERDRAW_INSPECTOR
62
+ gl_FragColor=vec4(1.0);
63
+ #endif
64
+ }`,"attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:ee(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;
65
+ #ifdef OVERDRAW_INSPECTOR
66
+ gl_FragColor=vec4(1.0);
67
+ #endif
68
+ }`,"uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:ee(`varying vec3 v_data;varying float v_visibility;
69
+ #pragma mapbox: define highp vec4 color
70
+ #pragma mapbox: define mediump float radius
71
+ #pragma mapbox: define lowp float blur
72
+ #pragma mapbox: define lowp float opacity
73
+ #pragma mapbox: define highp vec4 stroke_color
74
+ #pragma mapbox: define mediump float stroke_width
75
+ #pragma mapbox: define lowp float stroke_opacity
76
+ void main() {
77
+ #pragma mapbox: initialize highp vec4 color
78
+ #pragma mapbox: initialize mediump float radius
79
+ #pragma mapbox: initialize lowp float blur
80
+ #pragma mapbox: initialize lowp float opacity
81
+ #pragma mapbox: initialize highp vec4 stroke_color
82
+ #pragma mapbox: initialize mediump float stroke_width
83
+ #pragma mapbox: initialize lowp float stroke_opacity
84
+ vec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);
85
+ #ifdef OVERDRAW_INSPECTOR
86
+ gl_FragColor=vec4(1.0);
87
+ #endif
88
+ }`,`uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;
89
+ #pragma mapbox: define highp vec4 color
90
+ #pragma mapbox: define mediump float radius
91
+ #pragma mapbox: define lowp float blur
92
+ #pragma mapbox: define lowp float opacity
93
+ #pragma mapbox: define highp vec4 stroke_color
94
+ #pragma mapbox: define mediump float stroke_width
95
+ #pragma mapbox: define lowp float stroke_opacity
96
+ void main(void) {
97
+ #pragma mapbox: initialize highp vec4 color
98
+ #pragma mapbox: initialize mediump float radius
99
+ #pragma mapbox: initialize lowp float blur
100
+ #pragma mapbox: initialize lowp float opacity
101
+ #pragma mapbox: initialize highp vec4 stroke_color
102
+ #pragma mapbox: initialize mediump float stroke_width
103
+ #pragma mapbox: initialize lowp float stroke_opacity
104
+ vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:ee("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:ee(`uniform highp float u_intensity;varying vec2 v_extrude;
105
+ #pragma mapbox: define highp float weight
106
+ #define GAUSS_COEF 0.3989422804014327
107
+ void main() {
108
+ #pragma mapbox: initialize highp float weight
109
+ float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);
110
+ #ifdef OVERDRAW_INSPECTOR
111
+ gl_FragColor=vec4(1.0);
112
+ #endif
113
+ }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;
114
+ #pragma mapbox: define highp float weight
115
+ #pragma mapbox: define mediump float radius
116
+ const highp float ZERO=1.0/255.0/16.0;
117
+ #define GAUSS_COEF 0.3989422804014327
118
+ void main(void) {
119
+ #pragma mapbox: initialize highp float weight
120
+ #pragma mapbox: initialize mediump float radius
121
+ vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,get_elevation(floor(a_pos*0.5)),1);gl_Position=u_matrix*pos;}`),heatmapTexture:ee(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;
122
+ #ifdef OVERDRAW_INSPECTOR
123
+ gl_FragColor=vec4(0.0);
124
+ #endif
125
+ }`,"uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:ee("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_anchor_pos;attribute vec2 a_placed;attribute vec2 a_box_real;uniform mat4 u_matrix;uniform vec2 u_pixel_extrude_scale;varying float v_placed;varying float v_notUsed;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:ee("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:ee("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:ee(`#pragma mapbox: define highp vec4 color
126
+ #pragma mapbox: define lowp float opacity
127
+ void main() {
128
+ #pragma mapbox: initialize highp vec4 color
129
+ #pragma mapbox: initialize lowp float opacity
130
+ gl_FragColor=color*opacity;
131
+ #ifdef OVERDRAW_INSPECTOR
132
+ gl_FragColor=vec4(1.0);
133
+ #endif
134
+ }`,`attribute vec2 a_pos;uniform mat4 u_matrix;
135
+ #pragma mapbox: define highp vec4 color
136
+ #pragma mapbox: define lowp float opacity
137
+ void main() {
138
+ #pragma mapbox: initialize highp vec4 color
139
+ #pragma mapbox: initialize lowp float opacity
140
+ gl_Position=u_matrix*vec4(a_pos,0,1);}`),fillOutline:ee(`varying vec2 v_pos;
141
+ #pragma mapbox: define highp vec4 outline_color
142
+ #pragma mapbox: define lowp float opacity
143
+ void main() {
144
+ #pragma mapbox: initialize highp vec4 outline_color
145
+ #pragma mapbox: initialize lowp float opacity
146
+ float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);
147
+ #ifdef OVERDRAW_INSPECTOR
148
+ gl_FragColor=vec4(1.0);
149
+ #endif
150
+ }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;
151
+ #pragma mapbox: define highp vec4 outline_color
152
+ #pragma mapbox: define lowp float opacity
153
+ void main() {
154
+ #pragma mapbox: initialize highp vec4 outline_color
155
+ #pragma mapbox: initialize lowp float opacity
156
+ gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillOutlinePattern:ee(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
157
+ #pragma mapbox: define lowp float opacity
158
+ #pragma mapbox: define lowp vec4 pattern_from
159
+ #pragma mapbox: define lowp vec4 pattern_to
160
+ void main() {
161
+ #pragma mapbox: initialize lowp float opacity
162
+ #pragma mapbox: initialize mediump vec4 pattern_from
163
+ #pragma mapbox: initialize mediump vec4 pattern_to
164
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;
165
+ #ifdef OVERDRAW_INSPECTOR
166
+ gl_FragColor=vec4(1.0);
167
+ #endif
168
+ }`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
169
+ #pragma mapbox: define lowp float opacity
170
+ #pragma mapbox: define lowp vec4 pattern_from
171
+ #pragma mapbox: define lowp vec4 pattern_to
172
+ #pragma mapbox: define lowp float pixel_ratio_from
173
+ #pragma mapbox: define lowp float pixel_ratio_to
174
+ void main() {
175
+ #pragma mapbox: initialize lowp float opacity
176
+ #pragma mapbox: initialize mediump vec4 pattern_from
177
+ #pragma mapbox: initialize mediump vec4 pattern_to
178
+ #pragma mapbox: initialize lowp float pixel_ratio_from
179
+ #pragma mapbox: initialize lowp float pixel_ratio_to
180
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillPattern:ee(`#ifdef GL_ES
181
+ precision highp float;
182
+ #endif
183
+ uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;
184
+ #pragma mapbox: define lowp float opacity
185
+ #pragma mapbox: define lowp vec4 pattern_from
186
+ #pragma mapbox: define lowp vec4 pattern_to
187
+ void main() {
188
+ #pragma mapbox: initialize lowp float opacity
189
+ #pragma mapbox: initialize mediump vec4 pattern_from
190
+ #pragma mapbox: initialize mediump vec4 pattern_to
191
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;
192
+ #ifdef OVERDRAW_INSPECTOR
193
+ gl_FragColor=vec4(1.0);
194
+ #endif
195
+ }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;
196
+ #pragma mapbox: define lowp float opacity
197
+ #pragma mapbox: define lowp vec4 pattern_from
198
+ #pragma mapbox: define lowp vec4 pattern_to
199
+ #pragma mapbox: define lowp float pixel_ratio_from
200
+ #pragma mapbox: define lowp float pixel_ratio_to
201
+ void main() {
202
+ #pragma mapbox: initialize lowp float opacity
203
+ #pragma mapbox: initialize mediump vec4 pattern_from
204
+ #pragma mapbox: initialize mediump vec4 pattern_to
205
+ #pragma mapbox: initialize lowp float pixel_ratio_from
206
+ #pragma mapbox: initialize lowp float pixel_ratio_to
207
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:ee(`varying vec4 v_color;void main() {gl_FragColor=v_color;
208
+ #ifdef OVERDRAW_INSPECTOR
209
+ gl_FragColor=vec4(1.0);
210
+ #endif
211
+ }`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;
212
+ #ifdef TERRAIN3D
213
+ attribute vec2 a_centroid;
214
+ #endif
215
+ varying vec4 v_color;
216
+ #pragma mapbox: define highp float base
217
+ #pragma mapbox: define highp float height
218
+ #pragma mapbox: define highp vec4 color
219
+ void main() {
220
+ #pragma mapbox: initialize highp float base
221
+ #pragma mapbox: initialize highp float height
222
+ #pragma mapbox: initialize highp vec4 color
223
+ vec3 normal=a_normal_ed.xyz;
224
+ #ifdef TERRAIN3D
225
+ float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
226
+ #else
227
+ float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
228
+ #endif
229
+ base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:ee(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
230
+ #pragma mapbox: define lowp float base
231
+ #pragma mapbox: define lowp float height
232
+ #pragma mapbox: define lowp vec4 pattern_from
233
+ #pragma mapbox: define lowp vec4 pattern_to
234
+ #pragma mapbox: define lowp float pixel_ratio_from
235
+ #pragma mapbox: define lowp float pixel_ratio_to
236
+ void main() {
237
+ #pragma mapbox: initialize lowp float base
238
+ #pragma mapbox: initialize lowp float height
239
+ #pragma mapbox: initialize mediump vec4 pattern_from
240
+ #pragma mapbox: initialize mediump vec4 pattern_to
241
+ #pragma mapbox: initialize lowp float pixel_ratio_from
242
+ #pragma mapbox: initialize lowp float pixel_ratio_to
243
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;
244
+ #ifdef OVERDRAW_INSPECTOR
245
+ gl_FragColor=vec4(1.0);
246
+ #endif
247
+ }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;
248
+ #ifdef TERRAIN3D
249
+ attribute vec2 a_centroid;
250
+ #endif
251
+ varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
252
+ #pragma mapbox: define lowp float base
253
+ #pragma mapbox: define lowp float height
254
+ #pragma mapbox: define lowp vec4 pattern_from
255
+ #pragma mapbox: define lowp vec4 pattern_to
256
+ #pragma mapbox: define lowp float pixel_ratio_from
257
+ #pragma mapbox: define lowp float pixel_ratio_to
258
+ void main() {
259
+ #pragma mapbox: initialize lowp float base
260
+ #pragma mapbox: initialize lowp float height
261
+ #pragma mapbox: initialize mediump vec4 pattern_from
262
+ #pragma mapbox: initialize mediump vec4 pattern_to
263
+ #pragma mapbox: initialize lowp float pixel_ratio_from
264
+ #pragma mapbox: initialize lowp float pixel_ratio_to
265
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;
266
+ #ifdef TERRAIN3D
267
+ float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
268
+ #else
269
+ float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
270
+ #endif
271
+ base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0
272
+ ? a_pos
273
+ : vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:ee(`#ifdef GL_ES
274
+ precision highp float;
275
+ #endif
276
+ uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
277
+ #ifdef OVERDRAW_INSPECTOR
278
+ gl_FragColor=vec4(1.0);
279
+ #endif
280
+ }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:ee(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;
281
+ #define PI 3.141592653589793
282
+ void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;
283
+ #ifdef OVERDRAW_INSPECTOR
284
+ gl_FragColor=vec4(1.0);
285
+ #endif
286
+ }`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:ee(`uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;
287
+ #pragma mapbox: define highp vec4 color
288
+ #pragma mapbox: define lowp float blur
289
+ #pragma mapbox: define lowp float opacity
290
+ void main() {
291
+ #pragma mapbox: initialize highp vec4 color
292
+ #pragma mapbox: initialize lowp float blur
293
+ #pragma mapbox: initialize lowp float opacity
294
+ float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);
295
+ #ifdef OVERDRAW_INSPECTOR
296
+ gl_FragColor=vec4(1.0);
297
+ #endif
298
+ }`,`
299
+ #define scale 0.015873016
300
+ attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;
301
+ #pragma mapbox: define highp vec4 color
302
+ #pragma mapbox: define lowp float blur
303
+ #pragma mapbox: define lowp float opacity
304
+ #pragma mapbox: define mediump float gapwidth
305
+ #pragma mapbox: define lowp float offset
306
+ #pragma mapbox: define mediump float width
307
+ void main() {
308
+ #pragma mapbox: initialize highp vec4 color
309
+ #pragma mapbox: initialize lowp float blur
310
+ #pragma mapbox: initialize lowp float opacity
311
+ #pragma mapbox: initialize mediump float gapwidth
312
+ #pragma mapbox: initialize lowp float offset
313
+ #pragma mapbox: initialize mediump float width
314
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
315
+ #ifdef TERRAIN3D
316
+ v_gamma_scale=1.0;
317
+ #else
318
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
319
+ #endif
320
+ v_width2=vec2(outset,inset);}`),lineGradient:ee(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;
321
+ #pragma mapbox: define lowp float blur
322
+ #pragma mapbox: define lowp float opacity
323
+ void main() {
324
+ #pragma mapbox: initialize lowp float blur
325
+ #pragma mapbox: initialize lowp float opacity
326
+ float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);
327
+ #ifdef OVERDRAW_INSPECTOR
328
+ gl_FragColor=vec4(1.0);
329
+ #endif
330
+ }`,`
331
+ #define scale 0.015873016
332
+ attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;
333
+ #pragma mapbox: define lowp float blur
334
+ #pragma mapbox: define lowp float opacity
335
+ #pragma mapbox: define mediump float gapwidth
336
+ #pragma mapbox: define lowp float offset
337
+ #pragma mapbox: define mediump float width
338
+ void main() {
339
+ #pragma mapbox: initialize lowp float blur
340
+ #pragma mapbox: initialize lowp float opacity
341
+ #pragma mapbox: initialize mediump float gapwidth
342
+ #pragma mapbox: initialize lowp float offset
343
+ #pragma mapbox: initialize mediump float width
344
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
345
+ #ifdef TERRAIN3D
346
+ v_gamma_scale=1.0;
347
+ #else
348
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
349
+ #endif
350
+ v_width2=vec2(outset,inset);}`),linePattern:ee(`#ifdef GL_ES
351
+ precision highp float;
352
+ #endif
353
+ uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
354
+ #pragma mapbox: define lowp vec4 pattern_from
355
+ #pragma mapbox: define lowp vec4 pattern_to
356
+ #pragma mapbox: define lowp float pixel_ratio_from
357
+ #pragma mapbox: define lowp float pixel_ratio_to
358
+ #pragma mapbox: define lowp float blur
359
+ #pragma mapbox: define lowp float opacity
360
+ void main() {
361
+ #pragma mapbox: initialize mediump vec4 pattern_from
362
+ #pragma mapbox: initialize mediump vec4 pattern_to
363
+ #pragma mapbox: initialize lowp float pixel_ratio_from
364
+ #pragma mapbox: initialize lowp float pixel_ratio_to
365
+ #pragma mapbox: initialize lowp float blur
366
+ #pragma mapbox: initialize lowp float opacity
367
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;
368
+ #ifdef OVERDRAW_INSPECTOR
369
+ gl_FragColor=vec4(1.0);
370
+ #endif
371
+ }`,`
372
+ #define scale 0.015873016
373
+ #define LINE_DISTANCE_SCALE 2.0
374
+ attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
375
+ #pragma mapbox: define lowp float blur
376
+ #pragma mapbox: define lowp float opacity
377
+ #pragma mapbox: define lowp float offset
378
+ #pragma mapbox: define mediump float gapwidth
379
+ #pragma mapbox: define mediump float width
380
+ #pragma mapbox: define lowp float floorwidth
381
+ #pragma mapbox: define lowp vec4 pattern_from
382
+ #pragma mapbox: define lowp vec4 pattern_to
383
+ #pragma mapbox: define lowp float pixel_ratio_from
384
+ #pragma mapbox: define lowp float pixel_ratio_to
385
+ void main() {
386
+ #pragma mapbox: initialize lowp float blur
387
+ #pragma mapbox: initialize lowp float opacity
388
+ #pragma mapbox: initialize lowp float offset
389
+ #pragma mapbox: initialize mediump float gapwidth
390
+ #pragma mapbox: initialize mediump float width
391
+ #pragma mapbox: initialize lowp float floorwidth
392
+ #pragma mapbox: initialize mediump vec4 pattern_from
393
+ #pragma mapbox: initialize mediump vec4 pattern_to
394
+ #pragma mapbox: initialize lowp float pixel_ratio_from
395
+ #pragma mapbox: initialize lowp float pixel_ratio_to
396
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
397
+ #ifdef TERRAIN3D
398
+ v_gamma_scale=1.0;
399
+ #else
400
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
401
+ #endif
402
+ v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:ee(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;
403
+ #pragma mapbox: define highp vec4 color
404
+ #pragma mapbox: define lowp float blur
405
+ #pragma mapbox: define lowp float opacity
406
+ #pragma mapbox: define mediump float width
407
+ #pragma mapbox: define lowp float floorwidth
408
+ void main() {
409
+ #pragma mapbox: initialize highp vec4 color
410
+ #pragma mapbox: initialize lowp float blur
411
+ #pragma mapbox: initialize lowp float opacity
412
+ #pragma mapbox: initialize mediump float width
413
+ #pragma mapbox: initialize lowp float floorwidth
414
+ float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);
415
+ #ifdef OVERDRAW_INSPECTOR
416
+ gl_FragColor=vec4(1.0);
417
+ #endif
418
+ }`,`
419
+ #define scale 0.015873016
420
+ #define LINE_DISTANCE_SCALE 2.0
421
+ attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;
422
+ #pragma mapbox: define highp vec4 color
423
+ #pragma mapbox: define lowp float blur
424
+ #pragma mapbox: define lowp float opacity
425
+ #pragma mapbox: define mediump float gapwidth
426
+ #pragma mapbox: define lowp float offset
427
+ #pragma mapbox: define mediump float width
428
+ #pragma mapbox: define lowp float floorwidth
429
+ void main() {
430
+ #pragma mapbox: initialize highp vec4 color
431
+ #pragma mapbox: initialize lowp float blur
432
+ #pragma mapbox: initialize lowp float opacity
433
+ #pragma mapbox: initialize mediump float gapwidth
434
+ #pragma mapbox: initialize lowp float offset
435
+ #pragma mapbox: initialize mediump float width
436
+ #pragma mapbox: initialize lowp float floorwidth
437
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
438
+ #ifdef TERRAIN3D
439
+ v_gamma_scale=1.0;
440
+ #else
441
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
442
+ #endif
443
+ v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}`),raster:ee(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
444
+ #ifdef OVERDRAW_INSPECTOR
445
+ gl_FragColor=vec4(1.0);
446
+ #endif
447
+ }`,"uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:ee(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
448
+ #pragma mapbox: define lowp float opacity
449
+ void main() {
450
+ #pragma mapbox: initialize lowp float opacity
451
+ lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;
452
+ #ifdef OVERDRAW_INSPECTOR
453
+ gl_FragColor=vec4(1.0);
454
+ #endif
455
+ }`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_tex;varying float v_fade_opacity;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}
456
+ #pragma mapbox: define lowp float opacity
457
+ void main() {
458
+ #pragma mapbox: initialize lowp float opacity
459
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
460
+ camera_to_anchor_distance/u_camera_to_center_distance :
461
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:ee(`#define SDF_PX 8.0
462
+ uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;
463
+ #pragma mapbox: define highp vec4 fill_color
464
+ #pragma mapbox: define highp vec4 halo_color
465
+ #pragma mapbox: define lowp float opacity
466
+ #pragma mapbox: define lowp float halo_width
467
+ #pragma mapbox: define lowp float halo_blur
468
+ void main() {
469
+ #pragma mapbox: initialize highp vec4 fill_color
470
+ #pragma mapbox: initialize highp vec4 halo_color
471
+ #pragma mapbox: initialize lowp float opacity
472
+ #pragma mapbox: initialize lowp float halo_width
473
+ #pragma mapbox: initialize lowp float halo_blur
474
+ float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);
475
+ #ifdef OVERDRAW_INSPECTOR
476
+ gl_FragColor=vec4(1.0);
477
+ #endif
478
+ }`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_data0;varying vec3 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}
479
+ #pragma mapbox: define highp vec4 fill_color
480
+ #pragma mapbox: define highp vec4 halo_color
481
+ #pragma mapbox: define lowp float opacity
482
+ #pragma mapbox: define lowp float halo_width
483
+ #pragma mapbox: define lowp float halo_blur
484
+ void main() {
485
+ #pragma mapbox: initialize highp vec4 fill_color
486
+ #pragma mapbox: initialize highp vec4 halo_color
487
+ #pragma mapbox: initialize lowp float opacity
488
+ #pragma mapbox: initialize lowp float halo_width
489
+ #pragma mapbox: initialize lowp float halo_blur
490
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
491
+ camera_to_anchor_distance/u_camera_to_center_distance :
492
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:ee(`#define SDF_PX 8.0
493
+ #define SDF 1.0
494
+ #define ICON 0.0
495
+ uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;
496
+ #pragma mapbox: define highp vec4 fill_color
497
+ #pragma mapbox: define highp vec4 halo_color
498
+ #pragma mapbox: define lowp float opacity
499
+ #pragma mapbox: define lowp float halo_width
500
+ #pragma mapbox: define lowp float halo_blur
501
+ void main() {
502
+ #pragma mapbox: initialize highp vec4 fill_color
503
+ #pragma mapbox: initialize highp vec4 halo_color
504
+ #pragma mapbox: initialize lowp float opacity
505
+ #pragma mapbox: initialize lowp float halo_width
506
+ #pragma mapbox: initialize lowp float halo_blur
507
+ float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;
508
+ #ifdef OVERDRAW_INSPECTOR
509
+ gl_FragColor=vec4(1.0);
510
+ #endif
511
+ return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
512
+ #ifdef OVERDRAW_INSPECTOR
513
+ gl_FragColor=vec4(1.0);
514
+ #endif
515
+ }`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec4 v_data0;varying vec4 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}
516
+ #pragma mapbox: define highp vec4 fill_color
517
+ #pragma mapbox: define highp vec4 halo_color
518
+ #pragma mapbox: define lowp float opacity
519
+ #pragma mapbox: define lowp float halo_width
520
+ #pragma mapbox: define lowp float halo_blur
521
+ void main() {
522
+ #pragma mapbox: initialize highp vec4 fill_color
523
+ #pragma mapbox: initialize highp vec4 halo_color
524
+ #pragma mapbox: initialize lowp float opacity
525
+ #pragma mapbox: initialize lowp float halo_width
526
+ #pragma mapbox: initialize lowp float halo_blur
527
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
528
+ camera_to_anchor_distance/u_camera_to_center_distance :
529
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:ee("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;varying vec2 v_texture_pos;varying float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture2D(u_texture,v_texture_pos);if (v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);gl_FragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {gl_FragColor=surface_color;}}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform mat4 u_fog_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:ee("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:ee("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);}"),sky:ee("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform float u_horizon;uniform float u_sky_horizon_blend;void main() {float y=gl_FragCoord.y;if (y > u_horizon) {float blend=y-u_horizon;if (blend < u_sky_horizon_blend) {gl_FragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {gl_FragColor=u_sky_color;}}}","attribute vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function ee(u,t){const s=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=t.match(/attribute ([\w]+) ([\w]+)/g),o=u.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),c=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),m=c?c.concat(o):o,g={};return{fragmentSource:u=u.replace(s,((y,b,T,S,z)=>(g[z]=!0,b==="define"?`
530
+ #ifndef HAS_UNIFORM_u_${z}
531
+ varying ${T} ${S} ${z};
532
+ #else
533
+ uniform ${T} ${S} u_${z};
534
+ #endif
535
+ `:`
536
+ #ifdef HAS_UNIFORM_u_${z}
537
+ ${T} ${S} ${z} = u_${z};
538
+ #endif
539
+ `))),vertexSource:t=t.replace(s,((y,b,T,S,z)=>{const A=S==="float"?"vec2":"vec4",B=z.match(/color/)?"color":A;return g[z]?b==="define"?`
540
+ #ifndef HAS_UNIFORM_u_${z}
541
+ uniform lowp float u_${z}_t;
542
+ attribute ${T} ${A} a_${z};
543
+ varying ${T} ${S} ${z};
544
+ #else
545
+ uniform ${T} ${S} u_${z};
546
+ #endif
547
+ `:B==="vec4"?`
548
+ #ifndef HAS_UNIFORM_u_${z}
549
+ ${z} = a_${z};
550
+ #else
551
+ ${T} ${S} ${z} = u_${z};
552
+ #endif
553
+ `:`
554
+ #ifndef HAS_UNIFORM_u_${z}
555
+ ${z} = unpack_mix_${B}(a_${z}, u_${z}_t);
556
+ #else
557
+ ${T} ${S} ${z} = u_${z};
558
+ #endif
559
+ `:b==="define"?`
560
+ #ifndef HAS_UNIFORM_u_${z}
561
+ uniform lowp float u_${z}_t;
562
+ attribute ${T} ${A} a_${z};
563
+ #else
564
+ uniform ${T} ${S} u_${z};
565
+ #endif
566
+ `:B==="vec4"?`
567
+ #ifndef HAS_UNIFORM_u_${z}
568
+ ${T} ${S} ${z} = a_${z};
569
+ #else
570
+ ${T} ${S} ${z} = u_${z};
571
+ #endif
572
+ `:`
573
+ #ifndef HAS_UNIFORM_u_${z}
574
+ ${T} ${S} ${z} = unpack_mix_${B}(a_${z}, u_${z}_t);
575
+ #else
576
+ ${T} ${S} ${z} = u_${z};
577
+ #endif
578
+ `})),staticAttributes:n,staticUniforms:m}}class En{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,s,n,o,c,m,g,y,b){this.context=t;let T=this.boundPaintVertexBuffers.length!==o.length;for(let S=0;!T&&S<o.length;S++)this.boundPaintVertexBuffers[S]!==o[S]&&(T=!0);!this.vao||this.boundProgram!==s||this.boundLayoutVertexBuffer!==n||T||this.boundIndexBuffer!==c||this.boundVertexOffset!==m||this.boundDynamicVertexBuffer!==g||this.boundDynamicVertexBuffer2!==y||this.boundDynamicVertexBuffer3!==b?this.freshBind(s,n,o,c,m,g,y,b):(t.bindVertexArray.set(this.vao),g&&g.bind(),c&&c.dynamicDraw&&c.bind(),y&&y.bind(),b&&b.bind())}freshBind(t,s,n,o,c,m,g,y){const b=t.numAttributes,T=this.context,S=T.gl;this.vao&&this.destroy(),this.vao=T.createVertexArray(),T.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=s,this.boundPaintVertexBuffers=n,this.boundIndexBuffer=o,this.boundVertexOffset=c,this.boundDynamicVertexBuffer=m,this.boundDynamicVertexBuffer2=g,this.boundDynamicVertexBuffer3=y,s.enableAttributes(S,t);for(const z of n)z.enableAttributes(S,t);m&&m.enableAttributes(S,t),g&&g.enableAttributes(S,t),y&&y.enableAttributes(S,t),s.bind(),s.setVertexAttribPointers(S,t,c);for(const z of n)z.bind(),z.setVertexAttribPointers(S,t,c);m&&(m.bind(),m.setVertexAttribPointers(S,t,c)),o&&o.bind(),g&&(g.bind(),g.setVertexAttribPointers(S,t,c)),y&&(y.bind(),y.setVertexAttribPointers(S,t,c)),T.currentNumAttributes=b}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const zn=(u,t,s,n,o)=>({u_matrix:u,u_texture:0,u_ele_delta:t,u_fog_matrix:s,u_fog_color:n?n.properties.get("fog-color"):p.aM.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:n?n.calculateFogBlendOpacity(o):0,u_horizon_color:n?n.properties.get("horizon-color"):p.aM.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1});function fs(u){const t=[];for(let s=0;s<u.length;s++){if(u[s]===null)continue;const n=u[s].split(" ");t.push(n.pop())}return t}class Cn{constructor(t,s,n,o,c,m){const g=t.gl;this.program=g.createProgram();const y=fs(s.staticAttributes),b=n?n.getBinderAttributes():[],T=y.concat(b),S=zr.prelude.staticUniforms?fs(zr.prelude.staticUniforms):[],z=s.staticUniforms?fs(s.staticUniforms):[],A=n?n.getBinderUniforms():[],B=S.concat(z).concat(A),V=[];for(const tt of B)V.indexOf(tt)<0&&V.push(tt);const $=n?n.defines():[];c&&$.push("#define OVERDRAW_INSPECTOR;"),m&&$.push("#define TERRAIN3D;");const N=$.concat(zr.prelude.fragmentSource,s.fragmentSource).join(`
579
+ `),q=$.concat(zr.prelude.vertexSource,s.vertexSource).join(`
580
+ `),F=g.createShader(g.FRAGMENT_SHADER);if(g.isContextLost())return void(this.failedToCreate=!0);if(g.shaderSource(F,N),g.compileShader(F),!g.getShaderParameter(F,g.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${g.getShaderInfoLog(F)}`);g.attachShader(this.program,F);const H=g.createShader(g.VERTEX_SHADER);if(g.isContextLost())return void(this.failedToCreate=!0);if(g.shaderSource(H,q),g.compileShader(H),!g.getShaderParameter(H,g.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${g.getShaderInfoLog(H)}`);g.attachShader(this.program,H),this.attributes={};const K={};this.numAttributes=T.length;for(let tt=0;tt<this.numAttributes;tt++)T[tt]&&(g.bindAttribLocation(this.program,tt,T[tt]),this.attributes[T[tt]]=tt);if(g.linkProgram(this.program),!g.getProgramParameter(this.program,g.LINK_STATUS))throw new Error(`Program failed to link: ${g.getProgramInfoLog(this.program)}`);g.deleteShader(H),g.deleteShader(F);for(let tt=0;tt<V.length;tt++){const ot=V[tt];if(ot&&!K[ot]){const ut=g.getUniformLocation(this.program,ot);ut&&(K[ot]=ut)}}this.fixedUniforms=o(t,K),this.terrainUniforms=((tt,ot)=>({u_depth:new p.aH(tt,ot.u_depth),u_terrain:new p.aH(tt,ot.u_terrain),u_terrain_dim:new p.aI(tt,ot.u_terrain_dim),u_terrain_matrix:new p.aJ(tt,ot.u_terrain_matrix),u_terrain_unpack:new p.aK(tt,ot.u_terrain_unpack),u_terrain_exaggeration:new p.aI(tt,ot.u_terrain_exaggeration)}))(t,K),this.binderUniforms=n?n.getUniforms(t,K):[]}draw(t,s,n,o,c,m,g,y,b,T,S,z,A,B,V,$,N,q){const F=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(n),t.setStencilMode(o),t.setColorMode(c),t.setCullFace(m),y){t.activeTexture.set(F.TEXTURE2),F.bindTexture(F.TEXTURE_2D,y.depthTexture),t.activeTexture.set(F.TEXTURE3),F.bindTexture(F.TEXTURE_2D,y.texture);for(const K in this.terrainUniforms)this.terrainUniforms[K].set(y[K])}for(const K in this.fixedUniforms)this.fixedUniforms[K].set(g[K]);V&&V.setUniforms(t,this.binderUniforms,A,{zoom:B});let H=0;switch(s){case F.LINES:H=2;break;case F.TRIANGLES:H=3;break;case F.LINE_STRIP:H=1}for(const K of z.get()){const tt=K.vaos||(K.vaos={});(tt[b]||(tt[b]=new En)).bind(t,this,T,V?V.getPaintVertexBuffers():[],S,K.vertexOffset,$,N,q),F.drawElements(s,K.primitiveLength*H,F.UNSIGNED_SHORT,K.primitiveOffset*H*2)}}}function Ca(u,t,s){const n=1/Gt(s,1,t.transform.tileZoom),o=Math.pow(2,s.tileID.overscaledZ),c=s.tileSize*Math.pow(2,t.transform.tileZoom)/o,m=c*(s.tileID.canonical.x+s.tileID.wrap*o),g=c*s.tileID.canonical.y;return{u_image:0,u_texsize:s.imageAtlasTexture.size,u_scale:[n,u.fromScale,u.toScale],u_fade:u.t,u_pixel_coord_upper:[m>>16,g>>16],u_pixel_coord_lower:[65535&m,65535&g]}}const ta=(u,t,s,n)=>{const o=t.style.light,c=o.properties.get("position"),m=[c.x,c.y,c.z],g=(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),z=Math.cos(T);b[0]=z,b[1]=S,b[2]=0,b[3]=-S,b[4]=z,b[5]=0,b[6]=0,b[7]=0,b[8]=1})(g,-t.transform.angle),(function(b,T,S){var z=T[0],A=T[1],B=T[2];b[0]=z*S[0]+A*S[3]+B*S[6],b[1]=z*S[1]+A*S[4]+B*S[7],b[2]=z*S[2]+A*S[5]+B*S[8]})(m,m,g);const y=o.properties.get("color");return{u_matrix:u,u_lightpos:m,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+s,u_opacity:n}},Pa=(u,t,s,n,o,c,m)=>p.e(ta(u,t,s,n),Ca(c,t,m),{u_height_factor:-Math.pow(2,o.overscaledZ)/m.tileSize/8}),ms=u=>({u_matrix:u}),Ro=(u,t,s,n)=>p.e(ms(u),Ca(s,t,n)),jl=(u,t)=>({u_matrix:u,u_world:t}),Bo=(u,t,s,n,o)=>p.e(Ro(u,t,s,n),{u_world:o}),Ul=(u,t,s,n)=>{const o=u.transform;let c,m;if(n.paint.get("circle-pitch-alignment")==="map"){const g=Gt(s,1,o.zoom);c=!0,m=[g,g]}else c=!1,m=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(n.paint.get("circle-pitch-scale")==="map"),u_matrix:u.translatePosMatrix(t.posMatrix,s,n.paint.get("circle-translate"),n.paint.get("circle-translate-anchor")),u_pitch_with_map:+c,u_device_pixel_ratio:u.pixelRatio,u_extrude_scale:m}},Gr=(u,t,s)=>({u_matrix:u,u_inv_matrix:t,u_camera_to_center_distance:s.cameraToCenterDistance,u_viewport_size:[s.width,s.height]}),ea=(u,t,s=1)=>({u_matrix:u,u_color:t,u_overlay:0,u_overlay_scale:s}),ii=u=>({u_matrix:u}),ri=(u,t,s,n)=>({u_matrix:u,u_extrude_scale:Gt(t,1,s),u_intensity:n}),Aa=(u,t,s,n)=>{const o=p.H();p.aP(o,0,u.width,u.height,0,0,1);const c=u.context.gl;return{u_matrix:o,u_world:[c.drawingBufferWidth,c.drawingBufferHeight],u_image:s,u_color_ramp:n,u_opacity:t.paint.get("heatmap-opacity")}};function Da(u,t){const s=Math.pow(2,t.canonical.z),n=t.canonical.y;return[new p.Z(0,n/s).toLngLat().lat,new p.Z(0,(n+1)/s).toLngLat().lat]}const Ra=(u,t,s,n)=>{const o=u.transform;return{u_matrix:Oo(u,t,s,n),u_ratio:1/Gt(t,1,o.zoom),u_device_pixel_ratio:u.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Fo=(u,t,s,n,o)=>p.e(Ra(u,t,s,o),{u_image:0,u_image_height:n}),_s=(u,t,s,n,o)=>{const c=u.transform,m=Lo(t,c);return{u_matrix:Oo(u,t,s,o),u_texsize:t.imageAtlasTexture.size,u_ratio:1/Gt(t,1,c.zoom),u_device_pixel_ratio:u.pixelRatio,u_image:0,u_scale:[m,n.fromScale,n.toScale],u_fade:n.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},$l=(u,t,s,n,o,c)=>{const m=u.lineAtlas,g=Lo(t,u.transform),y=s.layout.get("line-cap")==="round",b=m.getDash(n.from,y),T=m.getDash(n.to,y),S=b.width*o.fromScale,z=T.width*o.toScale;return p.e(Ra(u,t,s,c),{u_patternscale_a:[g/S,-b.height/2],u_patternscale_b:[g/z,-T.height/2],u_sdfgamma:m.width/(256*Math.min(S,z)*u.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:T.y,u_mix:o.t})};function Lo(u,t){return 1/Gt(u,1,t.tileZoom)}function Oo(u,t,s,n){return u.translatePosMatrix(n?n.posMatrix:t.tileID.posMatrix,t,s.paint.get("line-translate"),s.paint.get("line-translate-anchor"))}const Nl=(u,t,s,n,o)=>{return{u_matrix:u,u_tl_parent:t,u_scale_parent:s,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.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:Zl(o.paint.get("raster-hue-rotate"))};var c,m};function Zl(u){u*=Math.PI/180;const t=Math.sin(u),s=Math.cos(u);return[(2*s+1)/3,(-Math.sqrt(3)*t-s+1)/3,(Math.sqrt(3)*t-s+1)/3]}const Vo=(u,t,s,n,o,c,m,g,y,b,T,S,z,A)=>{const B=m.transform;return{u_is_size_zoom_constant:+(u==="constant"||u==="source"),u_is_size_feature_constant:+(u==="constant"||u==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:B.cameraToCenterDistance,u_pitch:B.pitch/360*2*Math.PI,u_rotate_symbol:+s,u_aspect_ratio:B.width/B.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:g,u_label_plane_matrix:y,u_coord_matrix:b,u_is_text:+S,u_pitch_with_map:+n,u_is_along_line:o,u_is_variable_anchor:c,u_texsize:z,u_texture:0,u_translation:T,u_pitched_scale:A}},ia=(u,t,s,n,o,c,m,g,y,b,T,S,z,A,B)=>{const V=m.transform;return p.e(Vo(u,t,s,n,o,c,m,g,y,b,T,S,z,B),{u_gamma_scale:n?Math.cos(V._pitch)*V.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:+A})},Pn=(u,t,s,n,o,c,m,g,y,b,T,S,z,A)=>p.e(ia(u,t,s,n,o,c,m,g,y,b,T,!0,S,!0,A),{u_texsize_icon:z,u_texture_icon:1}),Ba=(u,t,s)=>({u_matrix:u,u_opacity:t,u_color:s}),An=(u,t,s,n,o,c)=>p.e((function(m,g,y,b){const T=y.imageManager.getPattern(m.from.toString()),S=y.imageManager.getPattern(m.to.toString()),{width:z,height:A}=y.imageManager.getPixelSize(),B=Math.pow(2,b.tileID.overscaledZ),V=b.tileSize*Math.pow(2,y.transform.tileZoom)/B,$=V*(b.tileID.canonical.x+b.tileID.wrap*B),N=V*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:[z,A],u_mix:g.t,u_pattern_size_a:T.displaySize,u_pattern_size_b:S.displaySize,u_scale_a:g.fromScale,u_scale_b:g.toScale,u_tile_units_to_pixels:1/Gt(b,1,y.transform.tileZoom),u_pixel_coord_upper:[$>>16,N>>16],u_pixel_coord_lower:[65535&$,65535&N]}})(n,c,s,o),{u_matrix:u,u_opacity:t}),Dn={fillExtrusion:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_lightpos:new p.aN(u,t.u_lightpos),u_lightintensity:new p.aI(u,t.u_lightintensity),u_lightcolor:new p.aN(u,t.u_lightcolor),u_vertical_gradient:new p.aI(u,t.u_vertical_gradient),u_opacity:new p.aI(u,t.u_opacity)}),fillExtrusionPattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_lightpos:new p.aN(u,t.u_lightpos),u_lightintensity:new p.aI(u,t.u_lightintensity),u_lightcolor:new p.aN(u,t.u_lightcolor),u_vertical_gradient:new p.aI(u,t.u_vertical_gradient),u_height_factor:new p.aI(u,t.u_height_factor),u_image:new p.aH(u,t.u_image),u_texsize:new p.aO(u,t.u_texsize),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade),u_opacity:new p.aI(u,t.u_opacity)}),fill:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix)}),fillPattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_image:new p.aH(u,t.u_image),u_texsize:new p.aO(u,t.u_texsize),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade)}),fillOutline:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_world:new p.aO(u,t.u_world)}),fillOutlinePattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_world:new p.aO(u,t.u_world),u_image:new p.aH(u,t.u_image),u_texsize:new p.aO(u,t.u_texsize),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade)}),circle:(u,t)=>({u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_scale_with_map:new p.aH(u,t.u_scale_with_map),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_extrude_scale:new p.aO(u,t.u_extrude_scale),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_matrix:new p.aJ(u,t.u_matrix)}),collisionBox:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_pixel_extrude_scale:new p.aO(u,t.u_pixel_extrude_scale)}),collisionCircle:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_inv_matrix:new p.aJ(u,t.u_inv_matrix),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_viewport_size:new p.aO(u,t.u_viewport_size)}),debug:(u,t)=>({u_color:new p.aL(u,t.u_color),u_matrix:new p.aJ(u,t.u_matrix),u_overlay:new p.aH(u,t.u_overlay),u_overlay_scale:new p.aI(u,t.u_overlay_scale)}),clippingMask:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix)}),heatmap:(u,t)=>({u_extrude_scale:new p.aI(u,t.u_extrude_scale),u_intensity:new p.aI(u,t.u_intensity),u_matrix:new p.aJ(u,t.u_matrix)}),heatmapTexture:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_world:new p.aO(u,t.u_world),u_image:new p.aH(u,t.u_image),u_color_ramp:new p.aH(u,t.u_color_ramp),u_opacity:new p.aI(u,t.u_opacity)}),hillshade:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_image:new p.aH(u,t.u_image),u_latrange:new p.aO(u,t.u_latrange),u_light:new p.aO(u,t.u_light),u_shadow:new p.aL(u,t.u_shadow),u_highlight:new p.aL(u,t.u_highlight),u_accent:new p.aL(u,t.u_accent)}),hillshadePrepare:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_image:new p.aH(u,t.u_image),u_dimension:new p.aO(u,t.u_dimension),u_zoom:new p.aI(u,t.u_zoom),u_unpack:new p.aK(u,t.u_unpack)}),line:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels)}),lineGradient:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels),u_image:new p.aH(u,t.u_image),u_image_height:new p.aI(u,t.u_image_height)}),linePattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_texsize:new p.aO(u,t.u_texsize),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_image:new p.aH(u,t.u_image),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade)}),lineSDF:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels),u_patternscale_a:new p.aO(u,t.u_patternscale_a),u_patternscale_b:new p.aO(u,t.u_patternscale_b),u_sdfgamma:new p.aI(u,t.u_sdfgamma),u_image:new p.aH(u,t.u_image),u_tex_y_a:new p.aI(u,t.u_tex_y_a),u_tex_y_b:new p.aI(u,t.u_tex_y_b),u_mix:new p.aI(u,t.u_mix)}),raster:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_tl_parent:new p.aO(u,t.u_tl_parent),u_scale_parent:new p.aI(u,t.u_scale_parent),u_buffer_scale:new p.aI(u,t.u_buffer_scale),u_fade_t:new p.aI(u,t.u_fade_t),u_opacity:new p.aI(u,t.u_opacity),u_image0:new p.aH(u,t.u_image0),u_image1:new p.aH(u,t.u_image1),u_brightness_low:new p.aI(u,t.u_brightness_low),u_brightness_high:new p.aI(u,t.u_brightness_high),u_saturation_factor:new p.aI(u,t.u_saturation_factor),u_contrast_factor:new p.aI(u,t.u_contrast_factor),u_spin_weights:new p.aN(u,t.u_spin_weights)}),symbolIcon:(u,t)=>({u_is_size_zoom_constant:new p.aH(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(u,t.u_is_size_feature_constant),u_size_t:new p.aI(u,t.u_size_t),u_size:new p.aI(u,t.u_size),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_pitch:new p.aI(u,t.u_pitch),u_rotate_symbol:new p.aH(u,t.u_rotate_symbol),u_aspect_ratio:new p.aI(u,t.u_aspect_ratio),u_fade_change:new p.aI(u,t.u_fade_change),u_matrix:new p.aJ(u,t.u_matrix),u_label_plane_matrix:new p.aJ(u,t.u_label_plane_matrix),u_coord_matrix:new p.aJ(u,t.u_coord_matrix),u_is_text:new p.aH(u,t.u_is_text),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_is_along_line:new p.aH(u,t.u_is_along_line),u_is_variable_anchor:new p.aH(u,t.u_is_variable_anchor),u_texsize:new p.aO(u,t.u_texsize),u_texture:new p.aH(u,t.u_texture),u_translation:new p.aO(u,t.u_translation),u_pitched_scale:new p.aI(u,t.u_pitched_scale)}),symbolSDF:(u,t)=>({u_is_size_zoom_constant:new p.aH(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(u,t.u_is_size_feature_constant),u_size_t:new p.aI(u,t.u_size_t),u_size:new p.aI(u,t.u_size),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_pitch:new p.aI(u,t.u_pitch),u_rotate_symbol:new p.aH(u,t.u_rotate_symbol),u_aspect_ratio:new p.aI(u,t.u_aspect_ratio),u_fade_change:new p.aI(u,t.u_fade_change),u_matrix:new p.aJ(u,t.u_matrix),u_label_plane_matrix:new p.aJ(u,t.u_label_plane_matrix),u_coord_matrix:new p.aJ(u,t.u_coord_matrix),u_is_text:new p.aH(u,t.u_is_text),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_is_along_line:new p.aH(u,t.u_is_along_line),u_is_variable_anchor:new p.aH(u,t.u_is_variable_anchor),u_texsize:new p.aO(u,t.u_texsize),u_texture:new p.aH(u,t.u_texture),u_gamma_scale:new p.aI(u,t.u_gamma_scale),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_is_halo:new p.aH(u,t.u_is_halo),u_translation:new p.aO(u,t.u_translation),u_pitched_scale:new p.aI(u,t.u_pitched_scale)}),symbolTextAndIcon:(u,t)=>({u_is_size_zoom_constant:new p.aH(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(u,t.u_is_size_feature_constant),u_size_t:new p.aI(u,t.u_size_t),u_size:new p.aI(u,t.u_size),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_pitch:new p.aI(u,t.u_pitch),u_rotate_symbol:new p.aH(u,t.u_rotate_symbol),u_aspect_ratio:new p.aI(u,t.u_aspect_ratio),u_fade_change:new p.aI(u,t.u_fade_change),u_matrix:new p.aJ(u,t.u_matrix),u_label_plane_matrix:new p.aJ(u,t.u_label_plane_matrix),u_coord_matrix:new p.aJ(u,t.u_coord_matrix),u_is_text:new p.aH(u,t.u_is_text),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_is_along_line:new p.aH(u,t.u_is_along_line),u_is_variable_anchor:new p.aH(u,t.u_is_variable_anchor),u_texsize:new p.aO(u,t.u_texsize),u_texsize_icon:new p.aO(u,t.u_texsize_icon),u_texture:new p.aH(u,t.u_texture),u_texture_icon:new p.aH(u,t.u_texture_icon),u_gamma_scale:new p.aI(u,t.u_gamma_scale),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_is_halo:new p.aH(u,t.u_is_halo),u_translation:new p.aO(u,t.u_translation),u_pitched_scale:new p.aI(u,t.u_pitched_scale)}),background:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_opacity:new p.aI(u,t.u_opacity),u_color:new p.aL(u,t.u_color)}),backgroundPattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_opacity:new p.aI(u,t.u_opacity),u_image:new p.aH(u,t.u_image),u_pattern_tl_a:new p.aO(u,t.u_pattern_tl_a),u_pattern_br_a:new p.aO(u,t.u_pattern_br_a),u_pattern_tl_b:new p.aO(u,t.u_pattern_tl_b),u_pattern_br_b:new p.aO(u,t.u_pattern_br_b),u_texsize:new p.aO(u,t.u_texsize),u_mix:new p.aI(u,t.u_mix),u_pattern_size_a:new p.aO(u,t.u_pattern_size_a),u_pattern_size_b:new p.aO(u,t.u_pattern_size_b),u_scale_a:new p.aI(u,t.u_scale_a),u_scale_b:new p.aI(u,t.u_scale_b),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_tile_units_to_pixels:new p.aI(u,t.u_tile_units_to_pixels)}),terrain:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_texture:new p.aH(u,t.u_texture),u_ele_delta:new p.aI(u,t.u_ele_delta),u_fog_matrix:new p.aJ(u,t.u_fog_matrix),u_fog_color:new p.aL(u,t.u_fog_color),u_fog_ground_blend:new p.aI(u,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new p.aI(u,t.u_fog_ground_blend_opacity),u_horizon_color:new p.aL(u,t.u_horizon_color),u_horizon_fog_blend:new p.aI(u,t.u_horizon_fog_blend)}),terrainDepth:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ele_delta:new p.aI(u,t.u_ele_delta)}),terrainCoords:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_texture:new p.aH(u,t.u_texture),u_terrain_coords_id:new p.aI(u,t.u_terrain_coords_id),u_ele_delta:new p.aI(u,t.u_ele_delta)}),sky:(u,t)=>({u_sky_color:new p.aL(u,t.u_sky_color),u_horizon_color:new p.aL(u,t.u_horizon_color),u_horizon:new p.aI(u,t.u_horizon),u_sky_horizon_blend:new p.aI(u,t.u_sky_horizon_blend)})};class sr{constructor(t,s,n){this.context=t;const o=t.gl;this.buffer=o.createBuffer(),this.dynamicDraw=!!n,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const s=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),s.bufferSubData(s.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const ql={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Rn{constructor(t,s,n,o){this.length=s.length,this.attributes=n,this.itemSize=s.bytesPerElement,this.dynamicDraw=o,this.context=t;const c=t.gl;this.buffer=c.createBuffer(),t.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const s=this.context.gl;this.bind(),s.bufferSubData(s.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,s){for(let n=0;n<this.attributes.length;n++){const o=s.attributes[this.attributes[n].name];o!==void 0&&t.enableVertexAttribArray(o)}}setVertexAttribPointers(t,s,n){for(let o=0;o<this.attributes.length;o++){const c=this.attributes[o],m=s.attributes[c.name];m!==void 0&&t.vertexAttribPointer(m,c.components,t[ql[c.type]],!1,this.itemSize,c.offset+this.itemSize*(n||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Xr=new WeakMap;function Cr(u){var t;if(Xr.has(u))return Xr.get(u);{const s=(t=u.getParameter(u.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return Xr.set(u,s),s}}class ie{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Fa extends ie{getDefault(){return p.aM.transparent}set(t){const s=this.current;(t.r!==s.r||t.g!==s.g||t.b!==s.b||t.a!==s.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Gl extends ie{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class gs extends ie{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Xl extends ie{getDefault(){return[!0,!0,!0,!0]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class jo extends ie{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Hl extends ie{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Uo extends ie{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const s=this.current;(t.func!==s.func||t.ref!==s.ref||t.mask!==s.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Bn extends ie{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class $o extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.STENCIL_TEST):s.disable(s.STENCIL_TEST),this.current=t,this.dirty=!1}}class No extends ie{getDefault(){return[0,1]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class Zo extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.DEPTH_TEST):s.disable(s.DEPTH_TEST),this.current=t,this.dirty=!1}}class qo extends ie{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Hr extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.BLEND):s.disable(s.BLEND),this.current=t,this.dirty=!1}}class Go extends ie{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class Wl extends ie{getDefault(){return p.aM.transparent}set(t){const s=this.current;(t.r!==s.r||t.g!==s.g||t.b!==s.b||t.a!==s.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Xo extends ie{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class ra extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.CULL_FACE):s.disable(s.CULL_FACE),this.current=t,this.dirty=!1}}class Kl extends ie{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class La extends ie{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Jl extends ie{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Yl extends ie{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Ho extends ie{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Wo extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindFramebuffer(s.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Ko extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindRenderbuffer(s.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Fn extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindTexture(s.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class Jo extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindBuffer(s.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Oa extends ie{getDefault(){return null}set(t){const s=this.gl;s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class _r extends ie{getDefault(){return null}set(t){var s;if(t===this.current&&!this.dirty)return;const n=this.gl;Cr(n)?n.bindVertexArray(t):(s=n.getExtension("OES_vertex_array_object"))===null||s===void 0||s.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class Ln extends ie{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class On extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class Vn extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class Va extends ie{constructor(t,s){super(t),this.context=t,this.parent=s}getDefault(){return null}}class jn extends Va{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class Wr extends Va{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Un extends Va{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Ql{constructor(t,s,n,o,c){this.context=t,this.width=s,this.height=n;const m=t.gl,g=this.framebuffer=m.createFramebuffer();if(this.colorAttachment=new jn(t,g),o)this.depthAttachment=c?new Un(t,g):new Wr(t,g);else if(c)throw new Error("Stencil cannot be set without depth");if(m.checkFramebufferStatus(m.FRAMEBUFFER)!==m.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const t=this.context.gl,s=this.colorAttachment.get();if(s&&t.deleteTexture(s),this.depthAttachment){const n=this.depthAttachment.get();n&&t.deleteRenderbuffer(n)}t.deleteFramebuffer(this.framebuffer)}}class be{constructor(t,s,n){this.blendFunction=t,this.blendColor=s,this.mask=n}}be.Replace=[1,0],be.disabled=new be(be.Replace,p.aM.transparent,[!1,!1,!1,!1]),be.unblended=new be(be.Replace,p.aM.transparent,[!0,!0,!0,!0]),be.alphaBlended=new be([1,771],p.aM.transparent,[!0,!0,!0,!0]);class tc{constructor(t){var s,n;if(this.gl=t,this.clearColor=new Fa(this),this.clearDepth=new Gl(this),this.clearStencil=new gs(this),this.colorMask=new Xl(this),this.depthMask=new jo(this),this.stencilMask=new Hl(this),this.stencilFunc=new Uo(this),this.stencilOp=new Bn(this),this.stencilTest=new $o(this),this.depthRange=new No(this),this.depthTest=new Zo(this),this.depthFunc=new qo(this),this.blend=new Hr(this),this.blendFunc=new Go(this),this.blendColor=new Wl(this),this.blendEquation=new Xo(this),this.cullFace=new ra(this),this.cullFaceSide=new Kl(this),this.frontFace=new La(this),this.program=new Jl(this),this.activeTexture=new Yl(this),this.viewport=new Ho(this),this.bindFramebuffer=new Wo(this),this.bindRenderbuffer=new Ko(this),this.bindTexture=new Fn(this),this.bindVertexBuffer=new Jo(this),this.bindElementBuffer=new Oa(this),this.bindVertexArray=new _r(this),this.pixelStoreUnpack=new Ln(this),this.pixelStoreUnpackPremultiplyAlpha=new On(this),this.pixelStoreUnpackFlipY=new Vn(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),Cr(t)){this.HALF_FLOAT=t.HALF_FLOAT;const o=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(s=t.RGBA16F)!==null&&s!==void 0?s:o==null?void 0:o.RGBA16F_EXT,this.RGB16F=(n=t.RGB16F)!==null&&n!==void 0?n:o==null?void 0:o.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const o=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=o==null?void 0:o.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,s){return new sr(this,t,s)}createVertexBuffer(t,s,n){return new Rn(this,t,s,n)}createRenderbuffer(t,s,n){const o=this.gl,c=o.createRenderbuffer();return this.bindRenderbuffer.set(c),o.renderbufferStorage(o.RENDERBUFFER,t,s,n),this.bindRenderbuffer.set(null),c}createFramebuffer(t,s,n,o){return new Ql(this,t,s,n,o)}clear({color:t,depth:s,stencil:n}){const o=this.gl;let c=0;t&&(c|=o.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),s!==void 0&&(c|=o.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(s),this.depthMask.set(!0)),n!==void 0&&(c|=o.STENCIL_BUFFER_BIT,this.clearStencil.set(n),this.stencilMask.set(255)),o.clear(c)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){p.aE(t.blendFunction,be.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return Cr(this.gl)?this.gl.createVertexArray():(t=this.gl.getExtension("OES_vertex_array_object"))===null||t===void 0?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var s;return Cr(this.gl)?this.gl.deleteVertexArray(t):(s=this.gl.getExtension("OES_vertex_array_object"))===null||s===void 0?void 0:s.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}class qt{constructor(t,s,n){this.func=t,this.mask=s,this.range=n}}qt.ReadOnly=!1,qt.ReadWrite=!0,qt.disabled=new qt(519,qt.ReadOnly,[0,1]);const ja=7680;class ue{constructor(t,s,n,o,c,m){this.test=t,this.ref=s,this.mask=n,this.fail=o,this.depthFail=c,this.pass=m}}ue.disabled=new ue({func:519,mask:0},0,0,ja,ja,ja);class ne{constructor(t,s,n){this.enable=t,this.mode=s,this.frontFace=n}}let Kr;function sa(u,t,s,n,o){const c=u.context,m=c.gl,g=u.useProgram("collisionBox"),y=[];let b=0,T=0;for(let N=0;N<n.length;N++){const q=n[N],F=t.getTile(q).getBucket(s);if(!F)continue;const H=o?F.textCollisionBox:F.iconCollisionBox,K=F.collisionCircleArray;if(K.length>0){const tt=p.H();p.aQ(tt,F.placementInvProjMatrix,u.transform.glCoordMatrix),p.aQ(tt,tt,F.placementViewportMatrix),y.push({circleArray:K,circleOffset:T,transform:q.posMatrix,invTransform:tt,coord:q}),b+=K.length/4,T=b}H&&g.draw(c,m.LINES,qt.disabled,ue.disabled,u.colorModeForRenderPass(),ne.disabled,{u_matrix:q.posMatrix,u_pixel_extrude_scale:[1/(S=u.transform).width,1/S.height]},u.style.map.terrain&&u.style.map.terrain.getTerrainData(q),s.id,H.layoutVertexBuffer,H.indexBuffer,H.segments,null,u.transform.zoom,null,null,H.collisionVertexBuffer)}var S;if(!o||!y.length)return;const z=u.useProgram("collisionCircle"),A=new p.aR;A.resize(4*b),A._trim();let B=0;for(const N of y)for(let q=0;q<N.circleArray.length/4;q++){const F=4*q,H=N.circleArray[F+0],K=N.circleArray[F+1],tt=N.circleArray[F+2],ot=N.circleArray[F+3];A.emplace(B++,H,K,tt,ot,0),A.emplace(B++,H,K,tt,ot,1),A.emplace(B++,H,K,tt,ot,2),A.emplace(B++,H,K,tt,ot,3)}(!Kr||Kr.length<2*b)&&(Kr=(function(N){const q=2*N,F=new p.aT;F.resize(q),F._trim();for(let H=0;H<q;H++){const K=6*H;F.uint16[K+0]=4*H+0,F.uint16[K+1]=4*H+1,F.uint16[K+2]=4*H+2,F.uint16[K+3]=4*H+2,F.uint16[K+4]=4*H+3,F.uint16[K+5]=4*H+0}return F})(b));const V=c.createIndexBuffer(Kr,!0),$=c.createVertexBuffer(A,p.aS.members,!0);for(const N of y){const q=Gr(N.transform,N.invTransform,u.transform);z.draw(c,m.TRIANGLES,qt.disabled,ue.disabled,u.colorModeForRenderPass(),ne.disabled,q,u.style.map.terrain&&u.style.map.terrain.getTerrainData(N.coord),s.id,$,V,p.a0.simpleSegment(0,2*N.circleOffset,N.circleArray.length,N.circleArray.length/2),null,u.transform.zoom,null,null,null)}$.destroy(),V.destroy()}ne.disabled=new ne(!1,1029,2305),ne.backCCW=new ne(!0,1029,2305);const aa=p.an(new Float32Array(16));function $n(u,t,s,n,o,c){const{horizontalAlign:m,verticalAlign:g}=p.au(u);return new p.P((-(m-.5)*t/o+n[0])*c,(-(g-.5)*s/o+n[1])*c)}function Jr(u,t,s,n,o,c){const m=t.tileAnchorPoint.add(new p.P(t.translation[0],t.translation[1]));if(t.pitchWithMap){let g=n.mult(c);s||(g=g.rotate(-o));const y=m.add(g);return j(y.x,y.y,t.labelPlaneMatrix,t.getElevation).point}if(s){const g=st(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(u),y=Math.atan(g.y/g.x)+(g.x<0?Math.PI:0);return u.add(n.rotate(y))}return u.add(n)}function ys(u,t,s,n,o,c,m,g,y,b,T,S,z,A){const B=u.text.placedSymbolArray,V=u.text.dynamicLayoutVertexArray,$=u.icon.dynamicLayoutVertexArray,N={};V.clear();for(let q=0;q<B.length;q++){const F=B.get(q),H=F.hidden||!F.crossTileID||u.allowVerticalPlacement&&!F.placedOrientation?null:n[F.crossTileID];if(H){const K=new p.P(F.anchorX,F.anchorY),tt={getElevation:A,width:o.width,height:o.height,labelPlaneMatrix:c,lineVertexArray:null,pitchWithMap:s,projection:T,projectionCache:null,tileAnchorPoint:K,translation:S,unwrappedTileID:z},ot=s?j(K.x,K.y,m,A):st(K.x,K.y,tt),ut=M(o.cameraToCenterDistance,ot.signedDistanceFromCamera);let xt=p.ai(u.textSizeData,y,F)*ut/p.ap;s&&(xt*=u.tilePixelRatio/g);const{width:Tt,height:ft,anchor:pt,textOffset:Et,textBoxScale:Vt}=H,gt=$n(pt,Tt,ft,Et,Vt,xt),bt=T.getPitchedTextCorrection(o,K.add(new p.P(S[0],S[1])),z),Lt=Jr(ot.point,tt,t,gt,o.angle,bt),pe=u.allowVerticalPlacement&&F.placedOrientation===p.ah.vertical?Math.PI/2:0;for(let $t=0;$t<F.numGlyphs;$t++)p.aj(V,Lt,pe);b&&F.associatedIconIndex>=0&&(N[F.associatedIconIndex]={shiftedAnchor:Lt,angle:pe})}else Dt(F.numGlyphs,V)}if(b){$.clear();const q=u.icon.placedSymbolArray;for(let F=0;F<q.length;F++){const H=q.get(F);if(H.hidden)Dt(H.numGlyphs,$);else{const K=N[F];if(K)for(let tt=0;tt<H.numGlyphs;tt++)p.aj($,K.shiftedAnchor,K.angle);else Dt(H.numGlyphs,$)}}u.icon.dynamicLayoutVertexBuffer.updateData($)}u.text.dynamicLayoutVertexBuffer.updateData(V)}function Ti(u,t,s){return s.iconsInText&&t?"symbolTextAndIcon":u?"symbolSDF":"symbolIcon"}function Nn(u,t,s,n,o,c,m,g,y,b,T,S){const z=u.context,A=z.gl,B=u.transform,V=Zr(),$=g==="map",N=y==="map",q=g!=="viewport"&&s.layout.get("symbol-placement")!=="point",F=$&&!N&&!q,H=!N&&q,K=!s.layout.get("symbol-sort-key").isConstant();let tt=!1;const ot=u.depthModeForSublayer(0,qt.ReadOnly),ut=s._unevaluatedLayout.hasValue("text-variable-anchor")||s._unevaluatedLayout.hasValue("text-variable-anchor-offset"),xt=[],Tt=V.getCircleRadiusCorrection(B);for(const ft of n){const pt=t.getTile(ft),Et=pt.getBucket(s);if(!Et)continue;const Vt=o?Et.text:Et.icon;if(!Vt||!Vt.segments.get().length||!Vt.hasVisibleVertices)continue;const gt=Vt.programConfigurations.get(s.id),bt=o||Et.sdfIcons,Lt=o?Et.textSizeData:Et.iconSizeData,pe=N||B.pitch!==0,$t=u.useProgram(Ti(bt,o,Et),gt),Xt=p.ag(Lt,B.zoom),fe=u.style.map.terrain&&u.style.map.terrain.getTerrainData(ft);let Ve,Ui,me,si,Ke=[0,0],je=null;if(o)Ui=pt.glyphAtlasTexture,me=A.LINEAR,Ve=pt.glyphAtlasTexture.size,Et.iconsInText&&(Ke=pt.imageAtlasTexture.size,je=pt.imageAtlasTexture,si=pe||u.options.rotating||u.options.zooming||Lt.kind==="composite"||Lt.kind==="camera"?A.LINEAR:A.NEAREST);else{const Wt=s.layout.get("icon-size").constantOr(0)!==1||Et.iconsNeedLinear;Ui=pt.imageAtlasTexture,me=bt||u.options.rotating||u.options.zooming||Wt||pe?A.LINEAR:A.NEAREST,Ve=pt.imageAtlasTexture.size}const Je=Gt(pt,1,u.transform.zoom),or=H?ft.posMatrix:aa,Rs=Er(or,N,$,u.transform,Je),nn=rr(or,N,$,u.transform,Je),Bs=rr(ft.posMatrix,N,$,u.transform,Je),ki=V.translatePosition(u.transform,pt,c,m),on=ut&&Et.hasTextData(),mo=s.layout.get("icon-text-fit")!=="none"&&on&&Et.hasIconData();if(q){const Wt=u.style.map.terrain?(Fs,Ls)=>u.style.map.terrain.getElevation(ft,Fs,Ls):null,is=s.layout.get("text-rotation-alignment")==="map";D(Et,ft.posMatrix,u,o,Rs,Bs,N,b,is,V,ft.toUnwrapped(),B.width,B.height,ki,Wt)}const Mi=ft.posMatrix,Ei=o&&ut||mo,Pr=q||Ei?aa:Rs,$i=nn,Be=bt&&s.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Ue;Ue=bt?Et.iconsInText?Pn(Lt.kind,Xt,F,N,q,Ei,u,Mi,Pr,$i,ki,Ve,Ke,Tt):ia(Lt.kind,Xt,F,N,q,Ei,u,Mi,Pr,$i,ki,o,Ve,!0,Tt):Vo(Lt.kind,Xt,F,N,q,Ei,u,Mi,Pr,$i,ki,o,Ve,Tt);const gi={program:$t,buffers:Vt,uniformValues:Ue,atlasTexture:Ui,atlasTextureIcon:je,atlasInterpolation:me,atlasInterpolationIcon:si,isSDF:bt,hasHalo:Be};if(K&&Et.canOverlap){tt=!0;const Wt=Vt.segments.get();for(const is of Wt)xt.push({segments:new p.a0([is]),sortKey:is.sortKey,state:gi,terrainData:fe})}else xt.push({segments:Vt.segments,sortKey:0,state:gi,terrainData:fe})}tt&&xt.sort(((ft,pt)=>ft.sortKey-pt.sortKey));for(const ft of xt){const pt=ft.state;if(z.activeTexture.set(A.TEXTURE0),pt.atlasTexture.bind(pt.atlasInterpolation,A.CLAMP_TO_EDGE),pt.atlasTextureIcon&&(z.activeTexture.set(A.TEXTURE1),pt.atlasTextureIcon&&pt.atlasTextureIcon.bind(pt.atlasInterpolationIcon,A.CLAMP_TO_EDGE)),pt.isSDF){const Et=pt.uniformValues;pt.hasHalo&&(Et.u_is_halo=1,Zn(pt.buffers,ft.segments,s,u,pt.program,ot,T,S,Et,ft.terrainData)),Et.u_is_halo=0}Zn(pt.buffers,ft.segments,s,u,pt.program,ot,T,S,pt.uniformValues,ft.terrainData)}}function Zn(u,t,s,n,o,c,m,g,y,b){const T=n.context;o.draw(T,T.gl.TRIANGLES,c,m,g,ne.disabled,y,b,s.id,u.layoutVertexBuffer,u.indexBuffer,t,s.paint,n.transform.zoom,u.programConfigurations.get(s.id),u.dynamicLayoutVertexBuffer,u.opacityVertexBuffer)}function qn(u,t,s,n){const o=u.context,c=o.gl,m=ue.disabled,g=new be([c.ONE,c.ONE],p.aM.transparent,[!0,!0,!0,!0]),y=t.getBucket(s);if(!y)return;const b=n.key;let T=s.heatmapFbos.get(b);T||(T=na(o,t.tileSize,t.tileSize),s.heatmapFbos.set(b,T)),o.bindFramebuffer.set(T.framebuffer),o.viewport.set([0,0,t.tileSize,t.tileSize]),o.clear({color:p.aM.transparent});const S=y.programConfigurations.get(s.id),z=u.useProgram("heatmap",S),A=u.style.map.terrain.getTerrainData(n);z.draw(o,c.TRIANGLES,qt.disabled,m,g,ne.disabled,ri(n.posMatrix,t,u.transform.zoom,s.paint.get("heatmap-intensity")),A,s.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,s.paint,u.transform.zoom,S)}function Yr(u,t,s){const n=u.context,o=n.gl;n.setColorMode(u.colorModeForRenderPass());const c=oa(n,t),m=s.key,g=t.heatmapFbos.get(m);g&&(n.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,g.colorAttachment.get()),n.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE),u.useProgram("heatmapTexture").draw(n,o.TRIANGLES,qt.disabled,ue.disabled,u.colorModeForRenderPass(),ne.disabled,Aa(u,t,0,1),null,t.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments,t.paint,u.transform.zoom),g.destroy(),t.heatmapFbos.delete(m))}function na(u,t,s){var n,o;const c=u.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 g=(n=u.HALF_FLOAT)!==null&&n!==void 0?n:c.UNSIGNED_BYTE,y=(o=u.RGBA16F)!==null&&o!==void 0?o:c.RGBA;c.texImage2D(c.TEXTURE_2D,0,y,t,s,0,c.RGBA,g,null);const b=u.createFramebuffer(t,s,!1,!1);return b.colorAttachment.set(m),b}function oa(u,t){return t.colorRampTexture||(t.colorRampTexture=new ae(u,t.colorRamp,u.gl.RGBA)),t.colorRampTexture}function xs(u,t,s,n,o){if(!s||!n||!n.imageAtlas)return;const c=n.imageAtlas.patternPositions;let m=c[s.to.toString()],g=c[s.from.toString()];if(!m&&g&&(m=g),!g&&m&&(g=m),!m||!g){const y=o.getPaintProperty(t);m=c[y],g=c[y]}m&&g&&u.setConstantPatternPositions(m,g)}function la(u,t,s,n,o,c,m){const g=u.context.gl,y="fill-pattern",b=s.paint.get(y),T=b&&b.constantOr(1),S=s.getCrossfadeParameters();let z,A,B,V,$;m?(A=T&&!s.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",z=g.LINES):(A=T?"fillPattern":"fill",z=g.TRIANGLES);const N=b.constantOr(null);for(const q of n){const F=t.getTile(q);if(T&&!F.patternsLoaded())continue;const H=F.getBucket(s);if(!H)continue;const K=H.programConfigurations.get(s.id),tt=u.useProgram(A,K),ot=u.style.map.terrain&&u.style.map.terrain.getTerrainData(q);T&&(u.context.activeTexture.set(g.TEXTURE0),F.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),K.updatePaintBuffers(S)),xs(K,y,N,F,s);const ut=ot?q:null,xt=u.translatePosMatrix(ut?ut.posMatrix:q.posMatrix,F,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));if(m){V=H.indexBuffer2,$=H.segments2;const Tt=[g.drawingBufferWidth,g.drawingBufferHeight];B=A==="fillOutlinePattern"&&T?Bo(xt,u,S,F,Tt):jl(xt,Tt)}else V=H.indexBuffer,$=H.segments,B=T?Ro(xt,u,S,F):ms(xt);tt.draw(u.context,z,o,u.stencilModeForClipping(q),c,ne.disabled,B,ot,s.id,H.layoutVertexBuffer,V,$,s.paint,u.transform.zoom,K)}}function Ua(u,t,s,n,o,c,m){const g=u.context,y=g.gl,b="fill-extrusion-pattern",T=s.paint.get(b),S=T.constantOr(1),z=s.getCrossfadeParameters(),A=s.paint.get("fill-extrusion-opacity"),B=T.constantOr(null);for(const V of n){const $=t.getTile(V),N=$.getBucket(s);if(!N)continue;const q=u.style.map.terrain&&u.style.map.terrain.getTerrainData(V),F=N.programConfigurations.get(s.id),H=u.useProgram(S?"fillExtrusionPattern":"fillExtrusion",F);S&&(u.context.activeTexture.set(y.TEXTURE0),$.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),F.updatePaintBuffers(z)),xs(F,b,B,$,s);const K=u.translatePosMatrix(V.posMatrix,$,s.paint.get("fill-extrusion-translate"),s.paint.get("fill-extrusion-translate-anchor")),tt=s.paint.get("fill-extrusion-vertical-gradient"),ot=S?Pa(K,u,tt,A,V,z,$):ta(K,u,tt,A);H.draw(g,g.gl.TRIANGLES,o,c,m,ne.backCCW,ot,q,s.id,N.layoutVertexBuffer,N.indexBuffer,N.segments,s.paint,u.transform.zoom,F,u.style.map.terrain&&N.centroidVertexBuffer)}}function vs(u,t,s,n,o,c,m){const g=u.context,y=g.gl,b=s.fbo;if(!b)return;const T=u.useProgram("hillshade"),S=u.style.map.terrain&&u.style.map.terrain.getTerrainData(t);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b.colorAttachment.get()),T.draw(g,y.TRIANGLES,o,c,m,ne.disabled,((z,A,B,V)=>{const $=B.paint.get("hillshade-shadow-color"),N=B.paint.get("hillshade-highlight-color"),q=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-=z.transform.angle);const H=!z.options.moving;return{u_matrix:V?V.posMatrix:z.transform.calculatePosMatrix(A.tileID.toUnwrapped(),H),u_image:0,u_latrange:Da(0,A.tileID),u_light:[B.paint.get("hillshade-exaggeration"),F],u_shadow:$,u_highlight:N,u_accent:q}})(u,s,n,S?t:null),S,n.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments)}function bs(u,t,s,n,o,c){const m=u.context,g=m.gl,y=t.dem;if(y&&y.data){const b=y.dim,T=y.stride,S=y.getPixels();if(m.activeTexture.set(g.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||u.getTileTexture(T),t.demTexture){const A=t.demTexture;A.update(S,{premultiply:!1}),A.bind(g.NEAREST,g.CLAMP_TO_EDGE)}else t.demTexture=new ae(m,S,g.RGBA,{premultiply:!1}),t.demTexture.bind(g.NEAREST,g.CLAMP_TO_EDGE);m.activeTexture.set(g.TEXTURE0);let z=t.fbo;if(!z){const A=new ae(m,{width:b,height:b,data:null},g.RGBA);A.bind(g.LINEAR,g.CLAMP_TO_EDGE),z=t.fbo=m.createFramebuffer(b,b,!0,!1),z.colorAttachment.set(A.texture)}m.bindFramebuffer.set(z.framebuffer),m.viewport.set([0,0,b,b]),u.useProgram("hillshadePrepare").draw(m,g.TRIANGLES,n,o,c,ne.disabled,((A,B)=>{const V=B.stride,$=p.H();return p.aP($,0,p.X,-p.X,0,0,1),p.J($,$,[0,-p.X,0]),{u_matrix:$,u_image:1,u_dimension:[V,V],u_zoom:A.overscaledZ,u_unpack:B.getUnpackVector()}})(t.tileID,y),null,s.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function Yo(u,t,s,n,o,c){const m=n.paint.get("raster-fade-duration");if(!c&&m>0){const g=mt.now(),y=(g-u.timeAdded)/m,b=t?(g-t.timeAdded)/m:-1,T=s.getSource(),S=o.coveringZoomLevel({tileSize:T.tileSize,roundZoom:T.roundZoom}),z=!t||Math.abs(t.tileID.overscaledZ-S)>Math.abs(u.tileID.overscaledZ-S),A=z&&u.refreshedUponExpiration?1:p.ac(z?y:1-b,0,1);return u.refreshedUponExpiration&&y>=1&&(u.refreshedUponExpiration=!1),t?{opacity:1,mix:1-A}:{opacity:A,mix:0}}return{opacity:1,mix:0}}const Gn=new p.aM(1,0,0,1),Yt=new p.aM(0,1,0,1),$a=new p.aM(0,0,1,1),ec=new p.aM(1,0,1,1),Qo=new p.aM(0,1,1,1);function ws(u,t,s,n){Na(u,0,t+s/2,u.transform.width,s,n)}function tl(u,t,s,n){Na(u,t-s/2,0,s,u.transform.height,n)}function Na(u,t,s,n,o,c){const m=u.context,g=m.gl;g.enable(g.SCISSOR_TEST),g.scissor(t*u.pixelRatio,s*u.pixelRatio,n*u.pixelRatio,o*u.pixelRatio),m.clear({color:c}),g.disable(g.SCISSOR_TEST)}function el(u,t,s){const n=u.context,o=n.gl,c=s.posMatrix,m=u.useProgram("debug"),g=qt.disabled,y=ue.disabled,b=u.colorModeForRenderPass(),T="$debug",S=u.style.map.terrain&&u.style.map.terrain.getTerrainData(s);n.activeTexture.set(o.TEXTURE0);const z=t.getTileByID(s.key).latestRawTileData,A=Math.floor((z&&z.byteLength||0)/1024),B=t.getTile(s).tileSize,V=512/Math.min(B,512)*(s.overscaledZ/u.transform.zoom)*.5;let $=s.canonical.toString();s.overscaledZ!==s.canonical.z&&($+=` => ${s.overscaledZ}`),(function(N,q){N.initDebugOverlayCanvas();const F=N.debugOverlayCanvas,H=N.context.gl,K=N.debugOverlayCanvas.getContext("2d");K.clearRect(0,0,F.width,F.height),K.shadowColor="white",K.shadowBlur=2,K.lineWidth=1.5,K.strokeStyle="white",K.textBaseline="top",K.font="bold 36px Open Sans, sans-serif",K.fillText(q,5,5),K.strokeText(q,5,5),N.debugOverlayTexture.update(F),N.debugOverlayTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE)})(u,`${$} ${A}kB`),m.draw(n,o.TRIANGLES,g,y,be.alphaBlended,ne.disabled,ea(c,p.aM.transparent,V),null,T,u.debugBuffer,u.quadTriangleIndexBuffer,u.debugSegments),m.draw(n,o.LINE_STRIP,g,y,b,ne.disabled,ea(c,p.aM.red),S,T,u.debugBuffer,u.tileBorderIndexBuffer,u.debugSegments)}function il(u,t,s){const n=u.context,o=n.gl,c=u.colorModeForRenderPass(),m=new qt(o.LEQUAL,qt.ReadWrite,u.depthRangeFor3D),g=u.useProgram("terrain"),y=t.getTerrainMesh();n.bindFramebuffer.set(null),n.viewport.set([0,0,u.width,u.height]);for(const b of s){const T=u.renderToTexture.getTexture(b),S=t.getTerrainData(b.tileID);n.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,T.texture);const z=u.transform.calculatePosMatrix(b.tileID.toUnwrapped()),A=t.getMeshFrameDelta(u.transform.zoom),B=u.transform.calculateFogMatrix(b.tileID.toUnwrapped()),V=zn(z,A,B,u.style.sky,u.transform.pitch);g.draw(n,o.TRIANGLES,m,ue.disabled,c,ne.backCCW,V,S,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}class Za{constructor(t,s,n){this.vertexBuffer=t,this.indexBuffer=s,this.segments=n}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class qa{constructor(t,s){this.context=new tc(t),this.transform=s,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:p.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Ft.maxUnderzooming+Ft.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Mn}resize(t,s,n){if(this.width=Math.floor(t*n),this.height=Math.floor(s*n),this.pixelRatio=n,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 t=this.context,s=new p.aX;s.emplaceBack(0,0),s.emplaceBack(p.X,0),s.emplaceBack(0,p.X),s.emplaceBack(p.X,p.X),this.tileExtentBuffer=t.createVertexBuffer(s,qr.members),this.tileExtentSegments=p.a0.simpleSegment(0,0,4,2);const 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.debugBuffer=t.createVertexBuffer(n,qr.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=t.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=t.createVertexBuffer(c,qr.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=t.createIndexBuffer(m);const g=new p.aY;g.emplaceBack(0,1,2),g.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(g);const y=this.context.gl;this.stencilClearMode=new ue({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){const t=this.context,s=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=p.H();p.aP(n,0,this.width,this.height,0,0,1),p.K(n,n,[s.drawingBufferWidth,s.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,s.TRIANGLES,qt.disabled,this.stencilClearMode,be.disabled,ne.disabled,ii(n),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,s){if(this.currentStencilSource===t.source||!t.isTileClipped()||!s||!s.length)return;this.currentStencilSource=t.source;const n=this.context,o=n.gl;this.nextStencilID+s.length>256&&this.clearStencil(),n.setColorMode(be.disabled),n.setDepthMode(qt.disabled);const c=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const m of s){const g=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);c.draw(n,o.TRIANGLES,qt.disabled,new ue({func:o.ALWAYS,mask:0},g,255,o.KEEP,o.KEEP,o.REPLACE),be.disabled,ne.disabled,ii(m.posMatrix),y,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,s=this.context.gl;return new ue({func:s.NOTEQUAL,mask:255},t,255,s.KEEP,s.KEEP,s.REPLACE)}stencilModeForClipping(t){const s=this.context.gl;return new ue({func:s.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,s.KEEP,s.KEEP,s.REPLACE)}stencilConfigForOverlap(t){const s=this.context.gl,n=t.sort(((m,g)=>g.overscaledZ-m.overscaledZ)),o=n[n.length-1].overscaledZ,c=n[0].overscaledZ-o+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();const m={};for(let g=0;g<c;g++)m[g+o]=new ue({func:s.GEQUAL,mask:255},g+this.nextStencilID,255,s.KEEP,s.KEEP,s.REPLACE);return this.nextStencilID+=c,[m,n]}return[{[o]:ue.disabled},n]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new be([t.CONSTANT_COLOR,t.ONE],new p.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?be.unblended:be.alphaBlended}depthModeForSublayer(t,s,n){if(!this.opaquePassEnabledForLayer())return qt.disabled;const o=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new qt(n||this.context.gl.LEQUAL,s,[o,o])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,s){this.style=t,this.options=s,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(mt.now()),this.imageManager.beginFrame();const n=this.style._order,o=this.style.sourceCaches,c={},m={},g={};for(const y in o){const b=o[y];b.used&&b.prepare(this.context),c[y]=b.getVisibleCoordinates(),m[y]=c[y].slice().reverse(),g[y]=b.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let y=0;y<n.length;y++)if(this.style._layers[n[y]].is3D()){this.opaquePassCutoff=y;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const y of n){const b=this.style._layers[y];if(!b.hasOffscreenPass()||b.isHidden(this.transform.zoom))continue;const T=m[b.source];(b.type==="custom"||T.length)&&this.renderLayer(this,o[b.source],b,T)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:s.showOverdrawInspector?p.aM.black:p.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&(function(y,b){const T=y.context,S=T.gl,z=((N,q,F)=>({u_sky_color:N.properties.get("sky-color"),u_horizon_color:N.properties.get("horizon-color"),u_horizon:(q.height/2+q.getHorizon())*F,u_sky_horizon_blend:N.properties.get("sky-horizon-blend")*q.height/2*F}))(b,y.style.map.transform,y.pixelRatio),A=new qt(S.LEQUAL,qt.ReadWrite,[0,1]),B=ue.disabled,V=y.colorModeForRenderPass(),$=y.useProgram("sky");if(!b.mesh){const N=new p.aX;N.emplaceBack(-1,-1),N.emplaceBack(1,-1),N.emplaceBack(1,1),N.emplaceBack(-1,1);const q=new p.aY;q.emplaceBack(0,1,2),q.emplaceBack(0,2,3),b.mesh=new Za(T.createVertexBuffer(N,qr.members),T.createIndexBuffer(q),p.a0.simpleSegment(0,0,N.length,q.length))}$.draw(T,S.TRIANGLES,A,B,V,ne.disabled,z,void 0,"sky",b.mesh.vertexBuffer,b.mesh.indexBuffer,b.mesh.segments)})(this,this.style.sky),this._showOverdrawInspector=s.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){const y=this.style._layers[n[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.currentLayer<n.length;this.currentLayer++){const y=this.style._layers[n[this.currentLayer]],b=o[y.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(y))continue;const T=(y.type==="symbol"?g:m)[y.source];this._renderTileClippingMasks(y,c[y.source]),this.renderLayer(this,b,y,T)}if(this.options.showTileBoundaries){const y=(function(b,T){let S=null;const z=Object.values(b._layers).flatMap(($=>$.source&&!$.isHidden(T)?[b.sourceCaches[$.source]]:[])),A=z.filter(($=>$.getSource().type==="vector")),B=z.filter(($=>$.getSource().type!=="vector")),V=$=>{(!S||S.getSource().maxzoom<$.getSource().maxzoom)&&(S=$)};return A.forEach(($=>V($))),S||B.forEach(($=>V($))),S})(this.style,this.transform.zoom);y&&(function(b,T,S){for(let z=0;z<S.length;z++)el(b,T,S[z])})(this,y,y.getVisibleCoordinates())}this.options.showPadding&&(function(y){const b=y.transform.padding;ws(y,y.transform.height-(b.top||0),3,Gn),ws(y,b.bottom||0,3,Yt),tl(y,b.left||0,3,$a),tl(y,y.transform.width-(b.right||0),3,ec);const T=y.transform.centerPoint;(function(S,z,A,B){Na(S,z-1,A-10,2,20,B),Na(S,z-10,A-1,20,2,B)})(y,T.x,y.transform.height-T.y,Qo)})(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const s=this.terrainFacilitator.matrix,n=this.transform.modelViewProjectionMatrix;let o=this.terrainFacilitator.dirty;o||(o=t?!p.a_(s,n):!p.a$(s,n)),o||(o=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),o&&(p.b0(s,n),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(c,m){const g=c.context,y=g.gl,b=be.unblended,T=new qt(y.LEQUAL,qt.ReadWrite,[0,1]),S=m.getTerrainMesh(),z=m.sourceCache.getRenderableTiles(),A=c.useProgram("terrainDepth");g.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),g.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),g.clear({color:p.aM.transparent,depth:1});for(const B of z){const V=m.getTerrainData(B.tileID),$={u_matrix:c.transform.calculatePosMatrix(B.tileID.toUnwrapped()),u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};A.draw(g,y.TRIANGLES,T,ue.disabled,b,ne.backCCW,$,V,"terrain",S.vertexBuffer,S.indexBuffer,S.segments)}g.bindFramebuffer.set(null),g.viewport.set([0,0,c.width,c.height])})(this,this.style.map.terrain),(function(c,m){const g=c.context,y=g.gl,b=be.unblended,T=new qt(y.LEQUAL,qt.ReadWrite,[0,1]),S=m.getTerrainMesh(),z=m.getCoordsTexture(),A=m.sourceCache.getRenderableTiles(),B=c.useProgram("terrainCoords");g.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),g.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),g.clear({color:p.aM.transparent,depth:1}),m.coordsIndex=[];for(const V of A){const $=m.getTerrainData(V.tileID);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,z.texture);const N={u_matrix:c.transform.calculatePosMatrix(V.tileID.toUnwrapped()),u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};B.draw(g,y.TRIANGLES,T,ue.disabled,b,ne.backCCW,N,$,"terrain",S.vertexBuffer,S.indexBuffer,S.segments),m.coordsIndex.push(V.tileID.key)}g.bindFramebuffer.set(null),g.viewport.set([0,0,c.width,c.height])})(this,this.style.map.terrain))}renderLayer(t,s,n,o){if(!n.isHidden(this.transform.zoom)&&(n.type==="background"||n.type==="custom"||(o||[]).length))switch(this.id=n.id,n.type){case"symbol":(function(c,m,g,y,b){if(c.renderPass!=="translucent")return;const T=ue.disabled,S=c.colorModeForRenderPass();(g._unevaluatedLayout.hasValue("text-variable-anchor")||g._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(z,A,B,V,$,N,q,F,H){const K=A.transform,tt=Zr(),ot=$==="map",ut=N==="map";for(const xt of z){const Tt=V.getTile(xt),ft=Tt.getBucket(B);if(!ft||!ft.text||!ft.text.segments.get().length)continue;const pt=p.ag(ft.textSizeData,K.zoom),Et=Gt(Tt,1,A.transform.zoom),Vt=Er(xt.posMatrix,ut,ot,A.transform,Et),gt=B.layout.get("icon-text-fit")!=="none"&&ft.hasIconData();if(pt){const bt=Math.pow(2,K.zoom-Tt.tileID.overscaledZ),Lt=A.style.map.terrain?($t,Xt)=>A.style.map.terrain.getElevation(xt,$t,Xt):null,pe=tt.translatePosition(K,Tt,q,F);ys(ft,ot,ut,H,K,Vt,xt.posMatrix,bt,pt,gt,tt,pe,xt.toUnwrapped(),Lt)}}})(y,c,g,m,g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),b),g.paint.get("icon-opacity").constantOr(1)!==0&&Nn(c,m,g,y,!1,g.paint.get("icon-translate"),g.paint.get("icon-translate-anchor"),g.layout.get("icon-rotation-alignment"),g.layout.get("icon-pitch-alignment"),g.layout.get("icon-keep-upright"),T,S),g.paint.get("text-opacity").constantOr(1)!==0&&Nn(c,m,g,y,!0,g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),g.layout.get("text-keep-upright"),T,S),m.map.showCollisionBoxes&&(sa(c,m,g,y,!0),sa(c,m,g,y,!1))})(t,s,n,o,this.style.placement.variableOffsets);break;case"circle":(function(c,m,g,y){if(c.renderPass!=="translucent")return;const b=g.paint.get("circle-opacity"),T=g.paint.get("circle-stroke-width"),S=g.paint.get("circle-stroke-opacity"),z=!g.layout.get("circle-sort-key").isConstant();if(b.constantOr(1)===0&&(T.constantOr(1)===0||S.constantOr(1)===0))return;const A=c.context,B=A.gl,V=c.depthModeForSublayer(0,qt.ReadOnly),$=ue.disabled,N=c.colorModeForRenderPass(),q=[];for(let F=0;F<y.length;F++){const H=y[F],K=m.getTile(H),tt=K.getBucket(g);if(!tt)continue;const ot=tt.programConfigurations.get(g.id),ut=c.useProgram("circle",ot),xt=tt.layoutVertexBuffer,Tt=tt.indexBuffer,ft=c.style.map.terrain&&c.style.map.terrain.getTerrainData(H),pt={programConfiguration:ot,program:ut,layoutVertexBuffer:xt,indexBuffer:Tt,uniformValues:Ul(c,H,K,g),terrainData:ft};if(z){const Et=tt.segments.get();for(const Vt of Et)q.push({segments:new p.a0([Vt]),sortKey:Vt.sortKey,state:pt})}else q.push({segments:tt.segments,sortKey:0,state:pt})}z&&q.sort(((F,H)=>F.sortKey-H.sortKey));for(const F of q){const{programConfiguration:H,program:K,layoutVertexBuffer:tt,indexBuffer:ot,uniformValues:ut,terrainData:xt}=F.state;K.draw(A,B.TRIANGLES,V,$,N,ne.disabled,ut,xt,g.id,tt,ot,F.segments,g.paint,c.transform.zoom,H)}})(t,s,n,o);break;case"heatmap":(function(c,m,g,y){if(g.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"?qn(c,S,g,T):c.renderPass==="translucent"&&Yr(c,g,T))}b.viewport.set([0,0,c.width,c.height])}else c.renderPass==="offscreen"?(function(T,S,z,A){const B=T.context,V=B.gl,$=ue.disabled,N=new be([V.ONE,V.ONE],p.aM.transparent,[!0,!0,!0,!0]);(function(q,F,H){const K=q.gl;q.activeTexture.set(K.TEXTURE1),q.viewport.set([0,0,F.width/4,F.height/4]);let tt=H.heatmapFbos.get(p.aU);tt?(K.bindTexture(K.TEXTURE_2D,tt.colorAttachment.get()),q.bindFramebuffer.set(tt.framebuffer)):(tt=na(q,F.width/4,F.height/4),H.heatmapFbos.set(p.aU,tt))})(B,T,z),B.clear({color:p.aM.transparent});for(let q=0;q<A.length;q++){const F=A[q];if(S.hasRenderableParent(F))continue;const H=S.getTile(F),K=H.getBucket(z);if(!K)continue;const tt=K.programConfigurations.get(z.id),ot=T.useProgram("heatmap",tt),{zoom:ut}=T.transform;ot.draw(B,V.TRIANGLES,qt.disabled,$,N,ne.disabled,ri(F.posMatrix,H,ut,z.paint.get("heatmap-intensity")),null,z.id,K.layoutVertexBuffer,K.indexBuffer,K.segments,z.paint,T.transform.zoom,tt)}B.viewport.set([0,0,T.width,T.height])})(c,m,g,y):c.renderPass==="translucent"&&(function(T,S){const z=T.context,A=z.gl;z.setColorMode(T.colorModeForRenderPass());const B=S.heatmapFbos.get(p.aU);B&&(z.activeTexture.set(A.TEXTURE0),A.bindTexture(A.TEXTURE_2D,B.colorAttachment.get()),z.activeTexture.set(A.TEXTURE1),oa(z,S).bind(A.LINEAR,A.CLAMP_TO_EDGE),T.useProgram("heatmapTexture").draw(z,A.TRIANGLES,qt.disabled,ue.disabled,T.colorModeForRenderPass(),ne.disabled,Aa(T,S,0,1),null,S.id,T.viewportBuffer,T.quadTriangleIndexBuffer,T.viewportSegments,S.paint,T.transform.zoom))})(c,g)})(t,s,n,o);break;case"line":(function(c,m,g,y){if(c.renderPass!=="translucent")return;const b=g.paint.get("line-opacity"),T=g.paint.get("line-width");if(b.constantOr(1)===0||T.constantOr(1)===0)return;const S=c.depthModeForSublayer(0,qt.ReadOnly),z=c.colorModeForRenderPass(),A=g.paint.get("line-dasharray"),B=g.paint.get("line-pattern"),V=B.constantOr(1),$=g.paint.get("line-gradient"),N=g.getCrossfadeParameters(),q=V?"linePattern":A?"lineSDF":$?"lineGradient":"line",F=c.context,H=F.gl;let K=!0;for(const tt of y){const ot=m.getTile(tt);if(V&&!ot.patternsLoaded())continue;const ut=ot.getBucket(g);if(!ut)continue;const xt=ut.programConfigurations.get(g.id),Tt=c.context.program.get(),ft=c.useProgram(q,xt),pt=K||ft.program!==Tt,Et=c.style.map.terrain&&c.style.map.terrain.getTerrainData(tt),Vt=B.constantOr(null);if(Vt&&ot.imageAtlas){const Lt=ot.imageAtlas,pe=Lt.patternPositions[Vt.to.toString()],$t=Lt.patternPositions[Vt.from.toString()];pe&&$t&&xt.setConstantPatternPositions(pe,$t)}const gt=Et?tt:null,bt=V?_s(c,ot,g,N,gt):A?$l(c,ot,g,A,N,gt):$?Fo(c,ot,g,ut.lineClipsArray.length,gt):Ra(c,ot,g,gt);if(V)F.activeTexture.set(H.TEXTURE0),ot.imageAtlasTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE),xt.updatePaintBuffers(N);else if(A&&(pt||c.lineAtlas.dirty))F.activeTexture.set(H.TEXTURE0),c.lineAtlas.bind(F);else if($){const Lt=ut.gradients[g.id];let pe=Lt.texture;if(g.gradientVersion!==Lt.version){let $t=256;if(g.stepInterpolant){const Xt=m.getSource().maxzoom,fe=tt.canonical.z===Xt?Math.ceil(1<<c.transform.maxZoom-tt.canonical.z):1;$t=p.ac(p.aV(ut.maxLineLength/p.X*1024*fe),256,F.maxTextureSize)}Lt.gradient=p.aW({expression:g.gradientExpression(),evaluationKey:"lineProgress",resolution:$t,image:Lt.gradient||void 0,clips:ut.lineClipsArray}),Lt.texture?Lt.texture.update(Lt.gradient):Lt.texture=new ae(F,Lt.gradient,H.RGBA),Lt.version=g.gradientVersion,pe=Lt.texture}F.activeTexture.set(H.TEXTURE0),pe.bind(g.stepInterpolant?H.NEAREST:H.LINEAR,H.CLAMP_TO_EDGE)}ft.draw(F,H.TRIANGLES,S,c.stencilModeForClipping(tt),z,ne.disabled,bt,Et,g.id,ut.layoutVertexBuffer,ut.indexBuffer,ut.segments,g.paint,c.transform.zoom,xt,ut.layoutVertexBuffer2),K=!1}})(t,s,n,o);break;case"fill":(function(c,m,g,y){const b=g.paint.get("fill-color"),T=g.paint.get("fill-opacity");if(T.constantOr(1)===0)return;const S=c.colorModeForRenderPass(),z=g.paint.get("fill-pattern"),A=c.opaquePassEnabledForLayer()&&!z.constantOr(1)&&b.constantOr(p.aM.transparent).a===1&&T.constantOr(0)===1?"opaque":"translucent";if(c.renderPass===A){const B=c.depthModeForSublayer(1,c.renderPass==="opaque"?qt.ReadWrite:qt.ReadOnly);la(c,m,g,y,B,S,!1)}if(c.renderPass==="translucent"&&g.paint.get("fill-antialias")){const B=c.depthModeForSublayer(g.getPaintProperty("fill-outline-color")?2:0,qt.ReadOnly);la(c,m,g,y,B,S,!0)}})(t,s,n,o);break;case"fill-extrusion":(function(c,m,g,y){const b=g.paint.get("fill-extrusion-opacity");if(b!==0&&c.renderPass==="translucent"){const T=new qt(c.context.gl.LEQUAL,qt.ReadWrite,c.depthRangeFor3D);if(b!==1||g.paint.get("fill-extrusion-pattern").constantOr(1))Ua(c,m,g,y,T,ue.disabled,be.disabled),Ua(c,m,g,y,T,c.stencilModeFor3D(),c.colorModeForRenderPass());else{const S=c.colorModeForRenderPass();Ua(c,m,g,y,T,ue.disabled,S)}}})(t,s,n,o);break;case"hillshade":(function(c,m,g,y){if(c.renderPass!=="offscreen"&&c.renderPass!=="translucent")return;const b=c.context,T=c.depthModeForSublayer(0,qt.ReadOnly),S=c.colorModeForRenderPass(),[z,A]=c.renderPass==="translucent"?c.stencilConfigForOverlap(y):[{},y];for(const B of A){const V=m.getTile(B);V.needsHillshadePrepare!==void 0&&V.needsHillshadePrepare&&c.renderPass==="offscreen"?bs(c,V,g,T,ue.disabled,S):c.renderPass==="translucent"&&vs(c,B,V,g,T,z[B.overscaledZ],S)}b.viewport.set([0,0,c.width,c.height])})(t,s,n,o);break;case"raster":(function(c,m,g,y){if(c.renderPass!=="translucent"||g.paint.get("raster-opacity")===0||!y.length)return;const b=c.context,T=b.gl,S=m.getSource(),z=c.useProgram("raster"),A=c.colorModeForRenderPass(),[B,V]=S instanceof fr?[{},y]:c.stencilConfigForOverlap(y),$=V[V.length-1].overscaledZ,N=!c.options.moving;for(const q of V){const F=c.depthModeForSublayer(q.overscaledZ-$,g.paint.get("raster-opacity")===1?qt.ReadWrite:qt.ReadOnly,T.LESS),H=m.getTile(q);H.registerFadeDuration(g.paint.get("raster-fade-duration"));const K=m.findLoadedParent(q,0),tt=m.findLoadedSibling(q),ot=Yo(H,K||tt||null,m,g,c.transform,c.style.map.terrain);let ut,xt;const Tt=g.paint.get("raster-resampling")==="nearest"?T.NEAREST:T.LINEAR;b.activeTexture.set(T.TEXTURE0),H.texture.bind(Tt,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST),b.activeTexture.set(T.TEXTURE1),K?(K.texture.bind(Tt,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST),ut=Math.pow(2,K.tileID.overscaledZ-H.tileID.overscaledZ),xt=[H.tileID.canonical.x*ut%1,H.tileID.canonical.y*ut%1]):H.texture.bind(Tt,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST),H.texture.useMipmap&&b.extTextureFilterAnisotropic&&c.transform.pitch>20&&T.texParameterf(T.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);const ft=c.style.map.terrain&&c.style.map.terrain.getTerrainData(q),pt=ft?q:null,Et=pt?pt.posMatrix:c.transform.calculatePosMatrix(q.toUnwrapped(),N),Vt=Nl(Et,xt||[0,0],ut||1,ot,g);S instanceof fr?z.draw(b,T.TRIANGLES,F,ue.disabled,A,ne.disabled,Vt,ft,g.id,S.boundsBuffer,c.quadTriangleIndexBuffer,S.boundsSegments):z.draw(b,T.TRIANGLES,F,B[q.overscaledZ],A,ne.disabled,Vt,ft,g.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments)}})(t,s,n,o);break;case"background":(function(c,m,g,y){const b=g.paint.get("background-color"),T=g.paint.get("background-opacity");if(T===0)return;const S=c.context,z=S.gl,A=c.transform,B=A.tileSize,V=g.paint.get("background-pattern");if(c.isPatternMissing(V))return;const $=!V&&b.a===1&&T===1&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==$)return;const N=ue.disabled,q=c.depthModeForSublayer(0,$==="opaque"?qt.ReadWrite:qt.ReadOnly),F=c.colorModeForRenderPass(),H=c.useProgram(V?"backgroundPattern":"background"),K=y||A.coveringTiles({tileSize:B,terrain:c.style.map.terrain});V&&(S.activeTexture.set(z.TEXTURE0),c.imageManager.bind(c.context));const tt=g.getCrossfadeParameters();for(const ot of K){const ut=y?ot.posMatrix:c.transform.calculatePosMatrix(ot.toUnwrapped()),xt=V?An(ut,T,c,V,{tileID:ot,tileSize:B},tt):Ba(ut,T,b),Tt=c.style.map.terrain&&c.style.map.terrain.getTerrainData(ot);H.draw(S,z.TRIANGLES,q,N,F,ne.disabled,xt,Tt,g.id,c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}})(t,0,n,o);break;case"custom":(function(c,m,g){const y=c.context,b=g.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(ue.disabled);const T=b.renderingMode==="3d"?new qt(c.context.gl.LEQUAL,qt.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,qt.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)}})(t,0,n)}}translatePosMatrix(t,s,n,o,c){if(!n[0]&&!n[1])return t;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);n=[n[0]*T-n[1]*b,n[0]*b+n[1]*T]}const g=[c?n[0]:Gt(s,n[0],this.transform.zoom),c?n[1]:Gt(s,n[1],this.transform.zoom),0],y=new Float32Array(16);return p.J(y,t,g),y}saveTileTexture(t){const s=this._tileTextures[t.size[0]];s?s.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const s=this._tileTextures[t];return s&&s.length>0?s.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const s=this.imageManager.getPattern(t.from.toString()),n=this.imageManager.getPattern(t.to.toString());return!s||!n}useProgram(t,s){this.cache=this.cache||{};const n=t+(s?s.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[n]||(this.cache[n]=new Cn(this.context,zr[t],s,Dn[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[n]}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 t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new ae(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:s}=this.context.gl;return this.width!==t||this.height!==s}}class Ts{constructor(t,s){this.points=t,this.planes=s}static fromInvProjectionMatrix(t,s,n){const o=Math.pow(2,n),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((g=>{const y=1/(g=p.af([],g,t))[3]/s*o;return p.b1(g,g,[y,y,1/g[3],y])})),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((g=>{const y=(function(z,A){var B=A[0],V=A[1],$=A[2],N=B*B+V*V+$*$;return N>0&&(N=1/Math.sqrt(N)),z[0]=A[0]*N,z[1]=A[1]*N,z[2]=A[2]*N,z})([],(function(z,A,B){var V=A[0],$=A[1],N=A[2],q=B[0],F=B[1],H=B[2];return z[0]=$*H-N*F,z[1]=N*q-V*H,z[2]=V*F-$*q,z})([],vi([],c[g[0]],c[g[1]]),vi([],c[g[2]],c[g[1]]))),b=-((T=y)[0]*(S=c[g[1]])[0]+T[1]*S[1]+T[2]*S[2]);var T,S;return y.concat(b)}));return new Ts(c,m)}}class Ss{constructor(t,s){this.min=t,this.max=s,this.center=(function(n,o,c){return n[0]=.5*o[0],n[1]=.5*o[1],n[2]=.5*o[2],n})([],(function(n,o,c){return n[0]=o[0]+c[0],n[1]=o[1]+c[1],n[2]=o[2]+c[2],n})([],this.min,this.max))}quadrant(t){const s=[t%2==0,t<2],n=Ai(this.min),o=Ai(this.max);for(let c=0;c<s.length;c++)n[c]=s[c]?this.min[c]:this.center[c],o[c]=s[c]?this.center[c]:this.max[c];return o[2]=this.max[2],new Ss(n,o)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersects(t){const s=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]];let n=!0;for(let o=0;o<t.planes.length;o++){const c=t.planes[o];let m=0;for(let g=0;g<s.length;g++)p.b2(c,s[g])>=0&&m++;if(m===0)return 0;m!==s.length&&(n=!1)}if(n)return 2;for(let o=0;o<3;o++){let c=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let g=0;g<t.points.length;g++){const y=t.points[g][o]-this.min[o];c=Math.min(c,y),m=Math.max(m,y)}if(m<0||c>this.max[o]-this.min[o])return 0}return 1}}class Is{constructor(t=0,s=0,n=0,o=0){if(isNaN(t)||t<0||isNaN(s)||s<0||isNaN(n)||n<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=s,this.left=n,this.right=o}interpolate(t,s,n){return s.top!=null&&t.top!=null&&(this.top=p.y.number(t.top,s.top,n)),s.bottom!=null&&t.bottom!=null&&(this.bottom=p.y.number(t.bottom,s.bottom,n)),s.left!=null&&t.left!=null&&(this.left=p.y.number(t.left,s.left,n)),s.right!=null&&t.right!=null&&(this.right=p.y.number(t.right,s.right,n)),this}getCenter(t,s){const n=p.ac((this.left+t-this.right)/2,0,t),o=p.ac((this.top+s-this.bottom)/2,0,s);return new p.P(n,o)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Is(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Xn=85.051129;class ks{constructor(t,s,n,o,c){this.tileSize=512,this._renderWorldCopies=c===void 0||!!c,this._minZoom=t||0,this._maxZoom=s||22,this._minPitch=n??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 Is,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const t=new ks(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.lngRange=t.lngRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this.minElevationForCurrentTile=t.minElevationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}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(t){const s=-p.b3(t,-180,180)*Math.PI/180;this.angle!==s&&(this._unmodified=!1,this.angle=s,this._calcMatrices(),this.rotationMatrix=(function(){var n=new p.A(4);return p.A!=Float32Array&&(n[1]=0,n[2]=0),n[0]=1,n[3]=1,n})(),(function(n,o,c){var m=o[0],g=o[1],y=o[2],b=o[3],T=Math.sin(c),S=Math.cos(c);n[0]=m*S+y*T,n[1]=g*S+b*T,n[2]=m*-T+y*S,n[3]=g*-T+b*S})(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const s=p.ac(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==s&&(this._unmodified=!1,this._pitch=s,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const s=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==s&&(this._unmodified=!1,this._zoom=s,this.tileZoom=Math.max(0,Math.floor(s)),this.scale=this.zoomScale(s),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,s,n){this._unmodified=!1,this._edgeInsets.interpolate(t,s,n),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const s=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,s)}getVisibleUnwrappedCoordinates(t){const s=[new p.b4(0,t)];if(this._renderWorldCopies){const n=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)),g=Math.floor(Math.min(n.x,o.x,c.x,m.x)),y=Math.floor(Math.max(n.x,o.x,c.x,m.x)),b=1;for(let T=g-b;T<=y+b;T++)T!==0&&s.push(new p.b4(T,t))}return s}coveringTiles(t){var s,n;let o=this.coveringZoomLevel(t);const c=o;if(t.minzoom!==void 0&&o<t.minzoom)return[];t.maxzoom!==void 0&&o>t.maxzoom&&(o=t.maxzoom);const m=this.pointCoordinate(this.getCameraPoint()),g=p.Z.fromLngLat(this.center),y=Math.pow(2,o),b=[y*m.x,y*m.y,0],T=[y*g.x,y*g.y,0],S=Ts.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,o);let z=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(z=o);const A=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,B=F=>({aabb:new Ss([F*y,0,0],[(F+1)*y,y,0]),zoom:0,x:0,y:0,wrap:F,fullyVisible:!1}),V=[],$=[],N=o,q=t.reparseOverscaled?c:o;if(this._renderWorldCopies)for(let F=1;F<=3;F++)V.push(B(-F)),V.push(B(F));for(V.push(B(0));V.length>0;){const F=V.pop(),H=F.x,K=F.y;let tt=F.fullyVisible;if(!tt){const ft=F.aabb.intersects(S);if(ft===0)continue;tt=ft===2}const ot=t.terrain?b:T,ut=F.aabb.distanceX(ot),xt=F.aabb.distanceY(ot),Tt=Math.max(Math.abs(ut),Math.abs(xt));if(F.zoom===N||Tt>A+(1<<N-F.zoom)-2&&F.zoom>=z){const ft=N-F.zoom,pt=b[0]-.5-(H<<ft),Et=b[1]-.5-(K<<ft);$.push({tileID:new p.S(F.zoom===N?q:F.zoom,F.wrap,F.zoom,H,K),distanceSq:Ia([T[0]-.5-H,T[1]-.5-K]),tileDistanceToCamera:Math.sqrt(pt*pt+Et*Et)})}else for(let ft=0;ft<4;ft++){const pt=(H<<1)+ft%2,Et=(K<<1)+(ft>>1),Vt=F.zoom+1;let gt=F.aabb.quadrant(ft);if(t.terrain){const bt=new p.S(Vt,F.wrap,Vt,pt,Et),Lt=t.terrain.getMinMaxElevation(bt),pe=(s=Lt.minElevation)!==null&&s!==void 0?s:this.elevation,$t=(n=Lt.maxElevation)!==null&&n!==void 0?n:this.elevation;gt=new Ss([gt.min[0],gt.min[1],pe],[gt.max[0],gt.max[1],$t])}V.push({aabb:gt,zoom:Vt,x:pt,y:Et,wrap:F.wrap,fullyVisible:tt})}}return $.sort(((F,H)=>F.distanceSq-H.distanceSq)).map((F=>F.tileID))}resize(t,s){this.width=t,this.height=s,this.pixelsToGLUnits=[2/t,-2/s],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const s=p.ac(t.lat,-85.051129,Xn);return new p.P(p.O(t.lng)*this.worldSize,p.Q(s)*this.worldSize)}unproject(t){return new p.Z(t.x/this.worldSize,t.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(t){const s=this.elevation,n=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,o=this.pointLocation(this.centerPoint,t),c=t.getElevationForLngLatZoom(o,this.tileZoom);if(!(this.elevation-c))return;const m=n+s-c,g=Math.cos(this._pitch)*this.cameraToCenterDistance/m/p.b5(1,o.lat),y=this.scaleZoom(g/this.tileSize);this._elevation=c,this._center=o,this.zoom=y}setLocationAtPoint(t,s){const n=this.pointCoordinate(s),o=this.pointCoordinate(this.centerPoint),c=this.locationCoordinate(t),m=new p.Z(c.x-(n.x-o.x),c.y-(n.y-o.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,s){return s?this.coordinatePoint(this.locationCoordinate(t),s.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,s){return this.coordinateLocation(this.pointCoordinate(t,s))}locationCoordinate(t){return p.Z.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,s){if(s){const z=s.pointCoordinate(t);if(z!=null)return z}const n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];p.af(n,n,this.pixelMatrixInverse),p.af(o,o,this.pixelMatrixInverse);const c=n[3],m=o[3],g=n[1]/c,y=o[1]/m,b=n[2]/c,T=o[2]/m,S=b===T?0:(0-b)/(T-b);return new p.Z(p.y.number(n[0]/c,o[0]/m,S)/this.worldSize,p.y.number(g,y,S)/this.worldSize)}coordinatePoint(t,s=0,n=this.pixelMatrix){const o=[t.x*this.worldSize,t.y*this.worldSize,s,1];return p.af(o,o,n),new p.P(o[0]/o[3],o[1]/o[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return new it().extend(this.pointLocation(new p.P(0,t))).extend(this.pointLocation(new p.P(this.width,t))).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 it([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(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,Xn])}calculateTileMatrix(t){const s=t.canonical,n=this.worldSize/this.zoomScale(s.z),o=s.x+Math.pow(2,s.z)*t.wrap,c=p.an(new Float64Array(16));return p.J(c,c,[o*n,s.y*n,0]),p.K(c,c,[n/p.X,n/p.X,1]),c}calculatePosMatrix(t,s=!1){const n=t.key,o=s?this._alignedPosMatrixCache:this._posMatrixCache;if(o[n])return o[n];const c=this.calculateTileMatrix(t);return p.L(c,s?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,c),o[n]=new Float32Array(c),o[n]}calculateFogMatrix(t){const s=t.key,n=this._fogMatrixCache;if(n[s])return n[s];const o=this.calculateTileMatrix(t);return p.L(o,this.fogMatrix,o),n[s]=new Float32Array(o),n[s]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,s){s=p.ac(+s,this.minZoom,this.maxZoom);const n={center:new p.N(t.lng,t.lat),zoom:s};let o=this.lngRange;if(!this._renderWorldCopies&&o===null){const F=179.9999999999;o=[-F,F]}const c=this.tileSize*this.zoomScale(n.zoom);let m=0,g=c,y=0,b=c,T=0,S=0;const{x:z,y:A}=this.size;if(this.latRange){const F=this.latRange;m=p.Q(F[1])*c,g=p.Q(F[0])*c,g-m<A&&(T=A/(g-m))}o&&(y=p.b3(p.O(o[0])*c,0,c),b=p.b3(p.O(o[1])*c,0,c),b<y&&(b+=c),b-y<z&&(S=z/(b-y)));const{x:B,y:V}=this.project.call({worldSize:c},t);let $,N;const q=Math.max(S||0,T||0);if(q){const F=new p.P(S?(b+y)/2:B,T?(g+m)/2:V);return n.center=this.unproject.call({worldSize:c},F).wrap(),n.zoom+=this.scaleZoom(q),n}if(this.latRange){const F=A/2;V-F<m&&(N=m+F),V+F>g&&(N=g-F)}if(o){const F=(y+b)/2;let H=B;this._renderWorldCopies&&(H=p.b3(B,F-c/2,F+c/2));const K=z/2;H-K<y&&($=y+K),H+K>b&&($=b-K)}if($!==void 0||N!==void 0){const F=new p.P($??B,N??V);n.center=this.unproject.call({worldSize:c},F).wrap()}return n}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:s,zoom:n}=this.getConstrained(this.center,this.zoom);this.center=s,this.zoom=n,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,s=this.point.x,n=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),g=c-m*this._pixelPerMeter/Math.cos(this._pitch),y=m<0?g:c,b=Math.PI/2+this._pitch,T=this._fov*(.5+t.y/this.height),S=Math.sin(T)*y/Math.sin(p.ac(Math.PI-b-T,.01,Math.PI-.01)),z=this.getHorizon(),A=2*Math.atan(z/this.cameraToCenterDistance)*(.5+t.y/(2*z)),B=Math.sin(A)*y/Math.sin(p.ac(Math.PI-b-A,.01,Math.PI-.01)),V=Math.min(S,B);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*V+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*-t.x/this.width,o[9]=2*t.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,[-s,-n,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*-t.x/this.width,this.fogMatrix[9]=2*t.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,[-s,-n,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 $=this.width%2/2,N=this.height%2/2,q=Math.cos(this.angle),F=Math.sin(this.angle),H=s-Math.round(s)+q*$+F*N,K=n-Math.round(n)+q*N+F*$,tt=new Float64Array(o);if(p.J(tt,tt,[H>.5?H-1:H,K>.5?K-1:K,0]),this.alignedModelViewProjectionMatrix=tt,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 t=this.pointCoordinate(new p.P(0,0)),s=[t.x*this.worldSize,t.y*this.worldSize,0,1];return p.af(s,s,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new p.P(0,t))}getCameraQueryGeometry(t){const s=this.getCameraPoint();if(t.length===1)return[t[0],s];{let n=s.x,o=s.y,c=s.x,m=s.y;for(const g of t)n=Math.min(n,g.x),o=Math.min(o,g.y),c=Math.max(c,g.x),m=Math.max(m,g.y);return[new p.P(n,o),new p.P(c,o),new p.P(c,m),new p.P(n,m),new p.P(n,o)]}}lngLatToCameraDepth(t,s){const n=this.locationCoordinate(t),o=[n.x*this.worldSize,n.y*this.worldSize,s,1];return p.af(o,o,this.modelViewProjectionMatrix),o[2]/o[3]}}function ca(u,t){let s,n=!1,o=null,c=null;const m=()=>{o=null,n&&(u.apply(c,s),o=setTimeout(m,t),n=!1)};return(...g)=>(n=!0,c=this,s=g,o||m(),o)}class Ga{constructor(t){this._getCurrentHash=()=>{const s=window.location.hash.replace("#","");if(this._hashName){let n;return s.split("&").map((o=>o.split("="))).forEach((o=>{o[0]===this._hashName&&(n=o)})),(n&&n[1]||"").split("/")}return s.split("/")},this._onHashChange=()=>{const s=this._getCurrentHash();if(s.length>=3&&!s.some((n=>isNaN(n)))){const n=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(s[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+s[2],+s[1]],zoom:+s[0],bearing:n,pitch:+(s[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const s=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,s)},this._removeHash=()=>{const s=this._getCurrentHash();if(s.length===0)return;const n=s.join("/");let o=n;o.split("&").length>0&&(o=o.split("&")[0]),this._hashName&&(o=`${this._hashName}=${n}`);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=ca(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,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(t){const s=this._map.getCenter(),n=Math.round(100*this._map.getZoom())/100,o=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,o),m=Math.round(s.lng*c)/c,g=Math.round(s.lat*c)/c,y=this._map.getBearing(),b=this._map.getPitch();let T="";if(T+=t?`/${m}/${g}/${n}`:`${n}/${g}/${m}`,(y||b)&&(T+="/"+Math.round(10*y)/10),b&&(T+=`/${Math.round(b)}`),this._hashName){const S=this._hashName;let z=!1;const A=window.location.hash.slice(1).split("&").map((B=>{const V=B.split("=")[0];return V===S?(z=!0,`${V}=${T}`):B})).filter((B=>B));return z||A.push(`${S}=${T}`),`#${A.join("&")}`}return`#${T}`}}const Xa={linearity:.3,easing:p.b8(0,0,.3,1)},Hn=p.e({deceleration:2500,maxSpeed:1400},Xa),ic=p.e({deceleration:20,maxSpeed:1400},Xa),rl=p.e({deceleration:1e3,maxSpeed:360},Xa),Ha=p.e({deceleration:1e3,maxSpeed:90},Xa);class Wn{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:mt.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,s=mt.now();for(;t.length>0&&s-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const s={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)s.zoom+=c.zoomDelta||0,s.bearing+=c.bearingDelta||0,s.pitch+=c.pitchDelta||0,c.panDelta&&s.pan._add(c.panDelta),c.around&&(s.around=c.around),c.pinchAround&&(s.pinchAround=c.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(s.pan.mag()){const c=ha(s.pan.mag(),n,p.e({},Hn,t||{}));o.offset=s.pan.mult(c.amount/s.pan.mag()),o.center=this._map.transform.center,ua(o,c)}if(s.zoom){const c=ha(s.zoom,n,ic);o.zoom=this._map.transform.zoom+c.amount,ua(o,c)}if(s.bearing){const c=ha(s.bearing,n,rl);o.bearing=this._map.transform.bearing+p.ac(c.amount,-179,179),ua(o,c)}if(s.pitch){const c=ha(s.pitch,n,Ha);o.pitch=this._map.transform.pitch+c.amount,ua(o,c)}if(o.zoom||o.bearing){const c=s.pinchAround===void 0?s.around:s.pinchAround;o.around=c?this._map.unproject(c):this._map.getCenter()}return this.clear(),p.e(o,{noMoveStart:!0})}}function ua(u,t){(!u.duration||u.duration<t.duration)&&(u.duration=t.duration,u.easing=t.easing)}function ha(u,t,s){const{maxSpeed:n,linearity:o,deceleration:c}=s,m=p.ac(u*o/(t/1e3),-n,n),g=Math.abs(m)/(c*o);return{easing:s.easing,duration:1e3*g,amount:m*(g/2)}}class Oe extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,s,n,o={}){const c=at.mousePos(s.getCanvas(),n),m=s.unproject(c);super(t,p.e({point:c,lngLat:m,originalEvent:n},o)),this._defaultPrevented=!1,this.target=s}}class Qr extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,s,n){const o=t==="touchend"?n.changedTouches:n.touches,c=at.touchPos(s.getCanvasContainer(),o),m=c.map((y=>s.unproject(y))),g=c.reduce(((y,b,T,S)=>y.add(b.div(S.length))),new p.P(0,0));super(t,{points:c,point:g,lngLats:m,lngLat:s.unproject(g),originalEvent:n}),this._defaultPrevented=!1}}class sl extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,s,n){super(t,{originalEvent:n}),this._defaultPrevented=!1}}class al{constructor(t,s){this._map=t,this._clickTolerance=s.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new sl(t.type,this._map,t))}mousedown(t,s){return this._mousedownPos=s,this._firePreventable(new Oe(t.type,this._map,t))}mouseup(t){this._map.fire(new Oe(t.type,this._map,t))}click(t,s){this._mousedownPos&&this._mousedownPos.dist(s)>=this._clickTolerance||this._map.fire(new Oe(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Oe(t.type,this._map,t))}mouseover(t){this._map.fire(new Oe(t.type,this._map,t))}mouseout(t){this._map.fire(new Oe(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Qr(t.type,this._map,t))}touchmove(t){this._map.fire(new Qr(t.type,this._map,t))}touchend(t){this._map.fire(new Qr(t.type,this._map,t))}touchcancel(t){this._map.fire(new Qr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class we{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Oe(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Oe("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Oe(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Vi{constructor(t){this._map=t}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(t){return this.transform.pointLocation(p.P.convert(t),this._map.terrain)}}class mi{constructor(t,s){this._map=t,this._tr=new Vi(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=s.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,s){this.isEnabled()&&t.shiftKey&&t.button===0&&(at.disableDrag(),this._startPos=this._lastPos=s,this._active=!0)}mousemoveWindow(t,s){if(!this._active)return;const n=s;if(this._lastPos.equals(n)||!this._box&&n.dist(this._startPos)<this._clickTolerance)return;const o=this._startPos;this._lastPos=n,this._box||(this._box=at.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const c=Math.min(o.x,n.x),m=Math.max(o.x,n.x),g=Math.min(o.y,n.y),y=Math.max(o.y,n.y);at.setTransform(this._box,`translate(${c}px,${g}px)`),this._box.style.width=m-c+"px",this._box.style.height=y-g+"px"}mouseupWindow(t,s){if(!this._active||t.button!==0)return;const n=this._startPos,o=s;if(this.reset(),at.suppressClick(),n.x!==o.x||n.y!==o.y)return this._map.fire(new p.k("boxzoomend",{originalEvent:t})),{cameraAnimation:c=>c.fitScreenCoordinates(n,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(at.remove(this._box),this._box=null),at.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,s){return this._map.fire(new p.k(t,{originalEvent:s}))}}function da(u,t){if(u.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${u.length}, points ${t.length}`);const s={};for(let n=0;n<u.length;n++)s[u[n].identifier]=t[n];return s}class Kn{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,s,n){(this.centroid||n.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),n.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)})(s),this.touches=da(n,s)))}touchmove(t,s,n){if(this.aborted||!this.centroid)return;const o=da(n,s);for(const c in this.touches){const m=o[c];(!m||m.dist(this.touches[c])>30)&&(this.aborted=!0)}}touchend(t,s,n){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),n.length===0){const o=!this.aborted&&this.centroid;if(this.reset(),o)return o}}}class Wa{constructor(t){this.singleTap=new Kn(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,s,n){this.singleTap.touchstart(t,s,n)}touchmove(t,s,n){this.singleTap.touchmove(t,s,n)}touchend(t,s,n){const o=this.singleTap.touchend(t,s,n);if(o){const c=t.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(o)<30;if(c&&m||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Ms{constructor(t){this._tr=new Vi(t),this._zoomIn=new Wa({numTouches:1,numTaps:2}),this._zoomOut=new Wa({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,s,n){this._zoomIn.touchstart(t,s,n),this._zoomOut.touchstart(t,s,n)}touchmove(t,s,n){this._zoomIn.touchmove(t,s,n),this._zoomOut.touchmove(t,s,n)}touchend(t,s,n){const o=this._zoomIn.touchend(t,s,n),c=this._zoomOut.touchend(t,s,n),m=this._tr;return o?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(o)},{originalEvent:t})}):c?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(c)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class gr{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const s=this._moveFunction(...t);if(s.bearingDelta||s.pitchDelta||s.around||s.panDelta)return this._active=!0,s}dragStart(t,s){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=s.length?s[0]:s,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,s){if(!this.isEnabled())return;const n=this._lastPoint;if(!n)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const o=s.length?s[0]:s;return!this._moved&&o.dist(n)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=o,this._move(n,o))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&at.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const Jn={0:1,2:2};class Ka{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const s=at.mouseButton(t);this._eventButton=s}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!(function(s,n){const o=Jn[n];return s.buttons===void 0||(s.buttons&o)!==o})(t,this._eventButton)}isValidEndEvent(t){return at.mouseButton(t)===this._eventButton}}class Yn{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return t.targetTouches.length===1}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}const Ja=u=>{u.mousedown=u.dragStart,u.mousemoveWindow=u.dragMove,u.mouseup=u.dragEnd,u.contextmenu=t=>{t.preventDefault()}},Qn=({enable:u,clickTolerance:t,bearingDegreesPerPixelMoved:s=.8})=>{const n=new Ka({checkCorrectEvent:o=>at.mouseButton(o)===0&&o.ctrlKey||at.mouseButton(o)===2});return new gr({clickTolerance:t,move:(o,c)=>({bearingDelta:(c.x-o.x)*s}),moveStateManager:n,enable:u,assignEvents:Ja})},to=({enable:u,clickTolerance:t,pitchDegreesPerPixelMoved:s=-.5})=>{const n=new Ka({checkCorrectEvent:o=>at.mouseButton(o)===0&&o.ctrlKey||at.mouseButton(o)===2});return new gr({clickTolerance:t,move:(o,c)=>({pitchDelta:(c.y-o.y)*s}),moveStateManager:n,enable:u,assignEvents:Ja})};class ts{constructor(t,s){this._clickTolerance=t.clickTolerance||1,this._map=s,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new p.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,s,n){return this._calculateTransform(t,s,n)}touchmove(t,s,n){if(this._active){if(!this._shouldBePrevented(n.length))return t.preventDefault(),this._calculateTransform(t,s,n);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,s,n){this._calculateTransform(t,s,n),this._active&&this._shouldBePrevented(n.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,s,n){n.length>0&&(this._active=!0);const o=da(n,s),c=new p.P(0,0),m=new p.P(0,0);let g=0;for(const b in o){const T=o[b],S=this._touches[b];S&&(c._add(T),m._add(T.sub(S)),g++,o[b]=T)}if(this._touches=o,this._shouldBePrevented(g)||!m.mag())return;const y=m.div(g);return this._sum._add(y),this._sum.mag()<this._clickTolerance?void 0:{around:c.div(g),panDelta:y}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ya{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,s,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([s[0],s[1]]))}touchmove(t,s,n){if(!this._firstTwoTouches)return;t.preventDefault();const[o,c]=this._firstTwoTouches,m=pa(n,s,o),g=pa(n,s,c);if(!m||!g)return;const y=this._aroundCenter?null:m.add(g).div(2);return this._move([m,g],y,t)}touchend(t,s,n){if(!this._firstTwoTouches)return;const[o,c]=this._firstTwoTouches,m=pa(n,s,o),g=pa(n,s,c);m&&g||(this._active&&at.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function pa(u,t,s){for(let n=0;n<u.length;n++)if(u[n].identifier===s)return t[n]}function eo(u,t){return Math.log(u/t)/Math.LN2}class io extends Ya{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,s){const n=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(eo(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:eo(this._distance,n),pinchAround:s}}}function ro(u,t){return 180*u.angleWith(t)/Math.PI}class so extends Ya{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,s,n){const o=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:ro(this._vector,o),pinchAround:s}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const s=25/(Math.PI*this._minDiameter)*360,n=ro(t,this._startVector);return Math.abs(n)<s}}function Qa(u){return Math.abs(u.y)>Math.abs(u.x)}class Es extends Ya{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,s,n){super.touchstart(t,s,n),this._currentTouchCount=n.length}_start(t){this._lastPoints=t,Qa(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,s,n){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const o=t[0].sub(this._lastPoints[0]),c=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(o,c,n.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(t,s,n){if(this._valid!==void 0)return this._valid;const o=t.mag()>=2,c=s.mag()>=2;if(!o&&!c)return;if(!o||!c)return this._firstMove===void 0&&(this._firstMove=n),n-this._firstMove<100&&void 0;const m=t.y>0==s.y>0;return Qa(t)&&Qa(s)&&m}}const nl={panStep:100,bearingStep:15,pitchStep:10};class Si{constructor(t){this._tr=new Vi(t);const s=nl;this._panStep=s.panStep,this._bearingStep=s.bearingStep,this._pitchStep=s.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let s=0,n=0,o=0,c=0,m=0;switch(t.keyCode){case 61:case 107:case 171:case 187:s=1;break;case 189:case 109:case 173:s=-1;break;case 37:t.shiftKey?n=-1:(t.preventDefault(),c=-1);break;case 39:t.shiftKey?n=1:(t.preventDefault(),c=1);break;case 38:t.shiftKey?o=1:(t.preventDefault(),m=-1);break;case 40:t.shiftKey?o=-1:(t.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(n=0,o=0),{cameraAnimation:g=>{const y=this._tr;g.easeTo({duration:300,easeId:"keyboardHandler",easing:ar,zoom:s?Math.round(y.zoom)+s*(t.shiftKey?2:1):y.zoom,bearing:y.bearing+n*this._bearingStep,pitch:y.pitch+o*this._pitchStep,offset:[-c*this._panStep,-m*this._panStep],center:y.center},{originalEvent:t})}}}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 ar(u){return u*(2-u)}const ao=4.000244140625;class ji{constructor(t,s){this._onTimeout=n=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(n)},this._map=t,this._tr=new Vi(t),this._triggerRenderFrame=s,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let s=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const n=mt.now(),o=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,s!==0&&s%ao==0?this._type="wheel":s!==0&&Math.abs(s)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=s,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(o*s)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,s+=this._lastValue)),t.shiftKey&&s&&(s/=4),this._type&&(this._lastWheelEvent=t,this._delta-=s,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const s=at.mousePos(this._map.getCanvas(),t),n=this._tr;this._around=s.y>n.transform.height/2-n.transform.getHorizon()?p.N.convert(this._aroundCenter?n.center:n.unproject(s)):p.N.convert(n.center),this._aroundPoint=n.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._tr.transform;if(this._delta!==0){const y=this._type==="wheel"&&Math.abs(this._delta)>ao?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"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(T*b))),this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const s=typeof this._targetZoom=="number"?this._targetZoom:t.zoom,n=this._startZoom,o=this._easing;let c,m=!1;const g=mt.now()-this._lastWheelEventTime;if(this._type==="wheel"&&n&&o&&g){const y=Math.min(g/200,1),b=o(y);c=p.y.number(n,s,b),y<1?this._frameId||(this._frameId=!0):m=!0}else c=s,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-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let s=p.b9;if(this._prevEase){const n=this._prevEase,o=(mt.now()-n.start)/n.duration,c=n.easing(o+.01)-n.easing(o),m=.27/Math.sqrt(c*c+1e-4)*.01,g=Math.sqrt(.0729-m*m);s=p.b8(m,g,.25,1)}return this._prevEase={start:mt.now(),duration:t,easing:s},s}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class es{constructor(t,s){this._clickZoom=t,this._tapZoom=s}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class rc{constructor(t){this._tr=new Vi(t),this.reset()}reset(){this._active=!1}dblclick(t,s){return t.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(s)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class sc{constructor(){this._tap=new Wa({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(t,s,n){if(!this._swipePoint)if(this._tapTime){const o=s[0],c=t.timeStamp-this._tapTime<500,m=this._tapPoint.dist(o)<30;c&&m?n.length>0&&(this._swipePoint=o,this._swipeTouch=n[0].identifier):this.reset()}else this._tap.touchstart(t,s,n)}touchmove(t,s,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const o=s[0],c=o.y-this._swipePoint.y;return this._swipePoint=o,t.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(t,s,n)}touchend(t,s,n){if(this._tapTime)this._swipePoint&&n.length===0&&this.reset();else{const o=this._tap.touchend(t,s,n);o&&(this._tapTime=t.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 ol{constructor(t,s,n){this._el=t,this._mousePan=s,this._touchPan=n}enable(t){this._inertiaOptions=t||{},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 ll{constructor(t,s,n){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=s,this._mousePitch=n}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 no{constructor(t,s,n,o){this._el=t,this._touchZoom=s,this._touchRotate=n,this._tapDragZoom=o,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),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 zs{constructor(t,s){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=t,this._options=s,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=at.create("div","maplibregl-cooperative-gesture-screen",t);let s=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(s=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const n=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),o=document.createElement("div");o.className="maplibregl-desktop-message",o.textContent=s,this._container.appendChild(o);const c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=n,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(at.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(t){return t[this._bypassKey]}notifyGestureBlocked(t,s){this._enabled&&(this._map.fire(new p.k("cooperativegestureprevented",{gestureType:t,originalEvent:s})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const Ii=u=>u.zoom||u.drag||u.pitch||u.rotate;class It extends p.k{}function tn(u){return u.panDelta&&u.panDelta.mag()||u.zoomDelta||u.bearingDelta||u.pitchDelta}class oo{constructor(t,s){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,g={needsRenderFrame:!1},y={},b={},T=o.touches,S=T?this._getMapTouches(T):void 0,z=S?at.touchPos(this._map.getCanvas(),S):at.mousePos(this._map.getCanvas(),o);for(const{handlerName:V,handler:$,allowed:N}of this._handlers){if(!$.isEnabled())continue;let q;this._blockedByActive(b,N,V)?$.reset():$[c||o.type]&&(q=$[c||o.type](o,z,S),this.mergeHandlerResult(g,y,q,V,m),q&&q.needsRenderFrame&&this._triggerRenderFrame()),(q||$.isActive())&&(b[V]=$)}const A={};for(const V in this._previousActiveHandlers)b[V]||(A[V]=m);this._previousActiveHandlers=b,(Object.keys(A).length||tn(g))&&(this._changes.push([g,y,A]),this._triggerRenderFrame()),(Object.keys(b).length||tn(g))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:B}=g;B&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],B(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wn(t),this._bearingSnap=s.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(s);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[o,c,m]of this._listeners)at.addEventListener(o,c,o===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[t,s,n]of this._listeners)at.removeEventListener(t,s,t===document?this.handleWindowEvent:this.handleEvent,n)}_addDefaultHandlers(t){const s=this._map,n=s.getCanvasContainer();this._add("mapEvent",new al(s,t));const o=s.boxZoom=new mi(s,t);this._add("boxZoom",o),t.interactive&&t.boxZoom&&o.enable();const c=s.cooperativeGestures=new zs(s,t.cooperativeGestures);this._add("cooperativeGestures",c),t.cooperativeGestures&&c.enable();const m=new Ms(s),g=new rc(s);s.doubleClickZoom=new es(g,m),this._add("tapZoom",m),this._add("clickZoom",g),t.interactive&&t.doubleClickZoom&&s.doubleClickZoom.enable();const y=new sc;this._add("tapDragZoom",y);const b=s.touchPitch=new Es(s);this._add("touchPitch",b),t.interactive&&t.touchPitch&&s.touchPitch.enable(t.touchPitch);const T=Qn(t),S=to(t);s.dragRotate=new ll(t,T,S),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",S,["mouseRotate"]),t.interactive&&t.dragRotate&&s.dragRotate.enable();const z=(({enable:q,clickTolerance:F})=>{const H=new Ka({checkCorrectEvent:K=>at.mouseButton(K)===0&&!K.ctrlKey});return new gr({clickTolerance:F,move:(K,tt)=>({around:tt,panDelta:tt.sub(K)}),activateOnStart:!0,moveStateManager:H,enable:q,assignEvents:Ja})})(t),A=new ts(t,s);s.dragPan=new ol(n,z,A),this._add("mousePan",z),this._add("touchPan",A,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&s.dragPan.enable(t.dragPan);const B=new so,V=new io;s.touchZoomRotate=new no(n,V,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",V,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&s.touchZoomRotate.enable(t.touchZoomRotate);const $=s.scrollZoom=new ji(s,(()=>this._triggerRenderFrame()));this._add("scrollZoom",$,["mousePan"]),t.interactive&&t.scrollZoom&&s.scrollZoom.enable(t.scrollZoom);const N=s.keyboard=new Si(s);this._add("keyboard",N),t.interactive&&t.keyboard&&s.keyboard.enable(),this._add("blockableMapEvent",new we(s))}_add(t,s,n){this._handlers.push({handlerName:t,handler:s,allowed:n}),this._handlersById[t]=s}stop(t){if(!this._updatingCamera){for(const{handler:s}of this._handlers)s.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Ii(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,s,n){for(const o in t)if(o!==n&&(!s||s.indexOf(o)<0))return!0;return!1}_getMapTouches(t){const s=[];for(const n of t)this._el.contains(n.target)&&s.push(n);return s}mergeHandlerResult(t,s,n,o,c){if(!n)return;p.e(t,n);const m={handlerName:o,originalEvent:n.originalEvent||c};n.zoomDelta!==void 0&&(s.zoom=m),n.panDelta!==void 0&&(s.drag=m),n.pitchDelta!==void 0&&(s.pitch=m),n.bearingDelta!==void 0&&(s.rotate=m)}_applyChanges(){const t={},s={},n={};for(const[o,c,m]of this._changes)o.panDelta&&(t.panDelta=(t.panDelta||new p.P(0,0))._add(o.panDelta)),o.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+o.pitchDelta),o.around!==void 0&&(t.around=o.around),o.pinchAround!==void 0&&(t.pinchAround=o.pinchAround),o.noInertia&&(t.noInertia=o.noInertia),p.e(s,c),p.e(n,m);this._updateMapTransform(t,s,n),this._changes=[]}_updateMapTransform(t,s,n){const o=this._map,c=o._getTransformForUpdate(),m=o.terrain;if(!(tn(t)||m&&this._terrainMovement))return this._fireEvents(s,n,!0);let{panDelta:g,zoomDelta:y,bearingDelta:b,pitchDelta:T,around:S,pinchAround:z}=t;z!==void 0&&(S=z),o._stop(!0),S=S||o.transform.centerPoint;const A=c.pointLocation(g?S.sub(g):S);b&&(c.bearing+=b),T&&(c.pitch+=T),y&&(c.zoom+=y),m?this._terrainMovement||!s.drag&&!s.zoom?s.drag&&this._terrainMovement?c.center=c.pointLocation(c.centerPoint.sub(g)):c.setLocationAtPoint(A,S):(this._terrainMovement=!0,this._map._elevationFreeze=!0,c.setLocationAtPoint(A,S)):c.setLocationAtPoint(A,S),o._applyUpdatedTransform(c),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(s,n,!0)}_fireEvents(t,s,n){const o=Ii(this._eventsInProgress),c=Ii(t),m={};for(const S in t){const{originalEvent:z}=t[S];this._eventsInProgress[S]||(m[`${S}start`]=z),this._eventsInProgress[S]=t[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 t){const{originalEvent:z}=t[S];this._fireEvent(S,z)}const g={};let y;for(const S in this._eventsInProgress){const{handlerName:z,originalEvent:A}=this._eventsInProgress[S];this._handlersById[z].isActive()||(delete this._eventsInProgress[S],y=s[z]||A,g[`${S}end`]=y)}for(const S in g)this._fireEvent(S,g[S]);const b=Ii(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(n&&T){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),z=A=>A!==0&&-this._bearingSnap<A&&A<this._bearingSnap;!S||!S.essential&&mt.prefersReducedMotion?(this._map.fire(new p.k("moveend",{originalEvent:y})),z(this._map.getBearing())&&this._map.resetNorth()):(z(S.bearing||this._map.getBearing())&&(S.bearing=0),S.freezeElevation=!0,this._map.easeTo(S,{originalEvent:y})),this._updatingCamera=!1}}_fireEvent(t,s){this._map.fire(new p.k(t,s?{originalEvent:s}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new It("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class cl extends p.E{constructor(t,s){super(),this._renderFrameCallback=()=>{const n=Math.min((mt.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(n)),n<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=s.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState}))}getCenter(){return new p.N(this.transform.center.lng,this.transform.center.lat)}setCenter(t,s){return this.jumpTo({center:t},s)}panBy(t,s,n){return t=p.P.convert(t).mult(-1),this.panTo(this.transform.center,p.e({offset:t},s),n)}panTo(t,s,n){return this.easeTo(p.e({center:t},s),n)}getZoom(){return this.transform.zoom}setZoom(t,s){return this.jumpTo({zoom:t},s),this}zoomTo(t,s,n){return this.easeTo(p.e({zoom:t},s),n)}zoomIn(t,s){return this.zoomTo(this.getZoom()+1,t,s),this}zoomOut(t,s){return this.zoomTo(this.getZoom()-1,t,s),this}getBearing(){return this.transform.bearing}setBearing(t,s){return this.jumpTo({bearing:t},s),this}getPadding(){return this.transform.padding}setPadding(t,s){return this.jumpTo({padding:t},s),this}rotateTo(t,s,n){return this.easeTo(p.e({bearing:t},s),n)}resetNorth(t,s){return this.rotateTo(0,p.e({duration:1e3},t),s),this}resetNorthPitch(t,s){return this.easeTo(p.e({bearing:0,pitch:0,duration:1e3},t),s),this}snapToNorth(t,s){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,s):this}getPitch(){return this.transform.pitch}setPitch(t,s){return this.jumpTo({pitch:t},s),this}cameraForBounds(t,s){t=it.convert(t).adjustAntiMeridian();const n=s&&s.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),n,s)}_cameraForBoxAndBearing(t,s,n,o){const c={top:0,bottom:0,right:0,left:0};if(typeof(o=p.e({padding:c,offset:[0,0],maxZoom:this.transform.maxZoom},o)).padding=="number"){const ft=o.padding;o.padding={top:ft,bottom:ft,right:ft,left:ft}}o.padding=p.e(c,o.padding);const m=this.transform,g=m.padding,y=new it(t,s),b=m.project(y.getNorthWest()),T=m.project(y.getNorthEast()),S=m.project(y.getSouthEast()),z=m.project(y.getSouthWest()),A=p.ba(-n),B=b.rotate(A),V=T.rotate(A),$=S.rotate(A),N=z.rotate(A),q=new p.P(Math.max(B.x,V.x,N.x,$.x),Math.max(B.y,V.y,N.y,$.y)),F=new p.P(Math.min(B.x,V.x,N.x,$.x),Math.min(B.y,V.y,N.y,$.y)),H=q.sub(F),K=(m.width-(g.left+g.right+o.padding.left+o.padding.right))/H.x,tt=(m.height-(g.top+g.bottom+o.padding.top+o.padding.bottom))/H.y;if(tt<0||K<0)return void p.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const ot=Math.min(m.scaleZoom(m.scale*Math.min(K,tt)),o.maxZoom),ut=p.P.convert(o.offset),xt=new p.P((o.padding.left-o.padding.right)/2,(o.padding.top-o.padding.bottom)/2).rotate(p.ba(n)),Tt=ut.add(xt).mult(m.scale/m.zoomScale(ot));return{center:m.unproject(b.add(S).div(2).sub(Tt)),zoom:ot,bearing:n}}fitBounds(t,s,n){return this._fitInternal(this.cameraForBounds(t,s),s,n)}fitScreenCoordinates(t,s,n,o,c){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(p.P.convert(t)),this.transform.pointLocation(p.P.convert(s)),n,o),o,c)}_fitInternal(t,s,n){return t?(delete(s=p.e(t,s)).padding,s.linear?this.easeTo(s,n):this.flyTo(s,n)):this}jumpTo(t,s){this.stop();const n=this._getTransformForUpdate();let o=!1,c=!1,m=!1;return"zoom"in t&&n.zoom!==+t.zoom&&(o=!0,n.zoom=+t.zoom),t.center!==void 0&&(n.center=p.N.convert(t.center)),"bearing"in t&&n.bearing!==+t.bearing&&(c=!0,n.bearing=+t.bearing),"pitch"in t&&n.pitch!==+t.pitch&&(m=!0,n.pitch=+t.pitch),t.padding==null||n.isPaddingEqual(t.padding)||(n.padding=t.padding),this._applyUpdatedTransform(n),this.fire(new p.k("movestart",s)).fire(new p.k("move",s)),o&&this.fire(new p.k("zoomstart",s)).fire(new p.k("zoom",s)).fire(new p.k("zoomend",s)),c&&this.fire(new p.k("rotatestart",s)).fire(new p.k("rotate",s)).fire(new p.k("rotateend",s)),m&&this.fire(new p.k("pitchstart",s)).fire(new p.k("pitch",s)).fire(new p.k("pitchend",s)),this.fire(new p.k("moveend",s))}calculateCameraOptionsFromTo(t,s,n,o=0){const c=p.Z.fromLngLat(t,s),m=p.Z.fromLngLat(n,o),g=m.x-c.x,y=m.y-c.y,b=m.z-c.z,T=Math.hypot(g,y,b);if(T===0)throw new Error("Can't calculate camera options with same From and To");const S=Math.hypot(g,y),z=this.transform.scaleZoom(this.transform.cameraToCenterDistance/T/this.transform.tileSize),A=180*Math.atan2(g,-y)/Math.PI;let B=180*Math.acos(S/T)/Math.PI;return B=b<0?90-B:90+B,{center:m.toLngLat(),zoom:z,pitch:B,bearing:A}}easeTo(t,s){var n;this._stop(!1,t.easeId),((t=p.e({offset:[0,0],duration:500,easing:p.b9},t)).animate===!1||!t.essential&&mt.prefersReducedMotion)&&(t.duration=0);const o=this._getTransformForUpdate(),c=o.zoom,m=o.bearing,g=o.pitch,y=o.padding,b="bearing"in t?this._normalizeBearing(t.bearing,m):m,T="pitch"in t?+t.pitch:g,S="padding"in t?t.padding:o.padding,z=p.P.convert(t.offset);let A=o.centerPoint.add(z);const B=o.pointLocation(A),{center:V,zoom:$}=o.getConstrained(p.N.convert(t.center||B),(n=t.zoom)!==null&&n!==void 0?n:c);this._normalizeCenter(V,o);const N=o.project(B),q=o.project(V).sub(N),F=o.zoomScale($-c);let H,K;t.around&&(H=p.N.convert(t.around),K=o.locationPoint(H));const tt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||$!==c,this._rotating=this._rotating||m!==b,this._pitching=this._pitching||T!==g,this._padding=!o.isPaddingEqual(S),this._easeId=t.easeId,this._prepareEase(s,t.noMoveStart,tt),this.terrain&&this._prepareElevation(V),this._ease((ot=>{if(this._zooming&&(o.zoom=p.y.number(c,$,ot)),this._rotating&&(o.bearing=p.y.number(m,b,ot)),this._pitching&&(o.pitch=p.y.number(g,T,ot)),this._padding&&(o.interpolatePadding(y,S,ot),A=o.centerPoint.add(z)),this.terrain&&!t.freezeElevation&&this._updateElevation(ot),H)o.setLocationAtPoint(H,K);else{const ut=o.zoomScale(o.zoom-c),xt=$>c?Math.min(2,F):Math.max(.5,F),Tt=Math.pow(xt,1-ot),ft=o.unproject(N.add(q.mult(ot*Tt)).mult(ut));o.setLocationAtPoint(o.renderWorldCopies?ft.wrap():ft,A)}this._applyUpdatedTransform(o),this._fireMoveEvents(s)}),(ot=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(s,ot)}),t),this}_prepareEase(t,s,n={}){this._moving=!0,s||n.moving||this.fire(new p.k("movestart",t)),this._zooming&&!n.zooming&&this.fire(new p.k("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new p.k("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new p.k("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const s=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&s!==this._elevationTarget){const n=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(n-(s-(n*t+this._elevationStart))/(1-t)),this._elevationTarget=s}this.transform.elevation=p.y.number(this._elevationStart,this._elevationTarget,t)}_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(t){const s=t.getCameraPosition(),n=this.terrain.getElevationForLngLatZoom(s.lngLat,t.zoom);if(s.altitude<n){const o=this.calculateCameraOptionsFromTo(s.lngLat,n,t.center,t.elevation);return{pitch:o.pitch,zoom:o.zoom}}return{}}_applyUpdatedTransform(t){const s=[];if(this.terrain&&s.push((o=>this._elevateCameraIfInsideTerrain(o))),this.transformCameraUpdate&&s.push((o=>this.transformCameraUpdate(o))),!s.length)return;const n=t.clone();for(const o of s){const c=n.clone(),{center:m,zoom:g,pitch:y,bearing:b,elevation:T}=o(c);m&&(c.center=m),g!==void 0&&(c.zoom=g),y!==void 0&&(c.pitch=y),b!==void 0&&(c.bearing=b),T!==void 0&&(c.elevation=T),n.apply(c)}this.transform.apply(n)}_fireMoveEvents(t){this.fire(new p.k("move",t)),this._zooming&&this.fire(new p.k("zoom",t)),this._rotating&&this.fire(new p.k("rotate",t)),this._pitching&&this.fire(new p.k("pitch",t))}_afterEase(t,s){if(this._easeId&&s&&this._easeId===s)return;delete this._easeId;const n=this._zooming,o=this._rotating,c=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new p.k("zoomend",t)),o&&this.fire(new p.k("rotateend",t)),c&&this.fire(new p.k("pitchend",t)),this.fire(new p.k("moveend",t))}flyTo(t,s){var n;if(!t.essential&&mt.prefersReducedMotion){const bt=p.M(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(bt,s)}this.stop(),t=p.e({offset:[0,0],speed:1.2,curve:1.42,easing:p.b9},t);const o=this._getTransformForUpdate(),c=o.zoom,m=o.bearing,g=o.pitch,y=o.padding,b="bearing"in t?this._normalizeBearing(t.bearing,m):m,T="pitch"in t?+t.pitch:g,S="padding"in t?t.padding:o.padding,z=p.P.convert(t.offset);let A=o.centerPoint.add(z);const B=o.pointLocation(A),{center:V,zoom:$}=o.getConstrained(p.N.convert(t.center||B),(n=t.zoom)!==null&&n!==void 0?n:c);this._normalizeCenter(V,o);const N=o.zoomScale($-c),q=o.project(B),F=o.project(V).sub(q);let H=t.curve;const K=Math.max(o.width,o.height),tt=K/N,ot=F.mag();if("minZoom"in t){const bt=p.ac(Math.min(t.minZoom,c,$),o.minZoom,o.maxZoom),Lt=K/o.zoomScale(bt-c);H=Math.sqrt(Lt/ot*2)}const ut=H*H;function xt(bt){const Lt=(tt*tt-K*K+(bt?-1:1)*ut*ut*ot*ot)/(2*(bt?tt:K)*ut*ot);return Math.log(Math.sqrt(Lt*Lt+1)-Lt)}function Tt(bt){return(Math.exp(bt)-Math.exp(-bt))/2}function ft(bt){return(Math.exp(bt)+Math.exp(-bt))/2}const pt=xt(!1);let Et=function(bt){return ft(pt)/ft(pt+H*bt)},Vt=function(bt){return K*((ft(pt)*(Tt(Lt=pt+H*bt)/ft(Lt))-Tt(pt))/ut)/ot;var Lt},gt=(xt(!0)-pt)/H;if(Math.abs(ot)<1e-6||!isFinite(gt)){if(Math.abs(K-tt)<1e-6)return this.easeTo(t,s);const bt=tt<K?-1:1;gt=Math.abs(Math.log(tt/K))/H,Vt=()=>0,Et=Lt=>Math.exp(bt*H*Lt)}return t.duration="duration"in t?+t.duration:1e3*gt/("screenSpeed"in t?+t.screenSpeed/H:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=m!==b,this._pitching=T!==g,this._padding=!o.isPaddingEqual(S),this._prepareEase(s,!1),this.terrain&&this._prepareElevation(V),this._ease((bt=>{const Lt=bt*gt,pe=1/Et(Lt);o.zoom=bt===1?$:c+o.scaleZoom(pe),this._rotating&&(o.bearing=p.y.number(m,b,bt)),this._pitching&&(o.pitch=p.y.number(g,T,bt)),this._padding&&(o.interpolatePadding(y,S,bt),A=o.centerPoint.add(z)),this.terrain&&!t.freezeElevation&&this._updateElevation(bt);const $t=bt===1?V:o.unproject(q.add(F.mult(Vt(Lt))).mult(pe));o.setLocationAtPoint(o.renderWorldCopies?$t.wrap():$t,A),this._applyUpdatedTransform(o),this._fireMoveEvents(s)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(s)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,s){var n;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,s)}return t||(n=this.handlers)===null||n===void 0||n.stop(!1),this}_ease(t,s,n){n.animate===!1||n.duration===0?(t(1),s()):(this._easeStart=mt.now(),this._easeOptions=n,this._onEaseFrame=t,this._onEaseEnd=s,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,s){t=p.b3(t,-180,180);const n=Math.abs(t-s);return Math.abs(t-360-s)<n&&(t-=360),Math.abs(t+360-s)<n&&(t+=360),t}_normalizeCenter(t,s){if(!s.renderWorldCopies||s.lngRange)return;const n=t.lng-s.center.lng;t.lng+=n>180?-360:n<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(p.N.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}const Cs={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Ps{constructor(t=Cs){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=s=>{!s||s.sourceDataType!=="metadata"&&s.sourceDataType!=="visibility"&&s.dataType!=="style"&&s.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=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=at.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=at.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=at.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(){at.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(t,s){const n=this._map._getUIString(`AttributionControl.${s}`);t.title=n,t.setAttribute("aria-label",n)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((o=>typeof o!="string"?"":o))):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const o=this._map.style.stylesheet;this.styleOwner=o.owner,this.styleId=o.id}const s=this._map.style.sourceCaches;for(const o in s){const c=s[o];if(c.used||c.usedForTerrain){const m=c.getSource();m.attribution&&t.indexOf(m.attribution)<0&&t.push(m.attribution)}}t=t.filter((o=>String(o).trim())),t.sort(((o,c)=>o.length-c.length)),t=t.filter(((o,c)=>{for(let m=c+1;m<t.length;m++)if(t[m].indexOf(o)>=0)return!1;return!0}));const n=t.join(" | ");n!==this._attribHTML&&(this._attribHTML=n,t.length?(this._innerContainer.innerHTML=n,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class lo{constructor(t={}){this._updateCompact=()=>{const s=this._container.children;if(s.length){const n=s[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&n.classList.add("maplibregl-compact"):n.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=at.create("div","maplibregl-ctrl");const s=at.create("a","maplibregl-ctrl-logo");return s.target="_blank",s.rel="noopener nofollow",s.href="https://maplibre.org/",s.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),s.setAttribute("rel","noopener nofollow"),this._container.appendChild(s),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){at.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Ht{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const s=++this._id;return this._queue.push({callback:t,id:s,cancelled:!1}),s}remove(t){const s=this._currentlyRunning,n=s?this._queue.concat(s):this._queue;for(const o of n)if(o.id===t)return void(o.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const s=this._currentlyRunning=this._queue;this._queue=[];for(const n of s)if(!n.cancelled&&(n.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var co=p.Y([{name:"a_pos3d",type:"Int16",components:3}]);class ac extends p.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,s){this.sourceCache.update(t,s),this._renderableTilesKeys=[];const n={};for(const o of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:s}))n[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 Mr(o,this.tileSize));for(const o in this._tiles)n[o]||delete this._tiles[o]}freeRtt(t){for(const s in this._tiles){const n=this._tiles[s];(!t||n.tileID.equals(t)||n.tileID.isChildOf(t)||t.isChildOf(n.tileID))&&(n.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const s={};for(const n of this._renderableTilesKeys){const o=this._tiles[n].tileID;if(o.canonical.equals(t.canonical)){const c=t.clone();c.posMatrix=new Float64Array(16),p.aP(c.posMatrix,0,p.X,0,p.X,0,1),s[n]=c}else if(o.canonical.isChildOf(t.canonical)){const c=t.clone();c.posMatrix=new Float64Array(16);const m=o.canonical.z-t.canonical.z,g=o.canonical.x-(o.canonical.x>>m<<m),y=o.canonical.y-(o.canonical.y>>m<<m),b=p.X>>m;p.aP(c.posMatrix,0,b,0,b,0,1),p.J(c.posMatrix,c.posMatrix,[-g*b,-y*b,0]),s[n]=c}else if(t.canonical.isChildOf(o.canonical)){const c=t.clone();c.posMatrix=new Float64Array(16);const m=t.canonical.z-o.canonical.z,g=t.canonical.x-(t.canonical.x>>m<<m),y=t.canonical.y-(t.canonical.y>>m<<m),b=p.X>>m;p.aP(c.posMatrix,0,p.X,0,p.X,0,1),p.J(c.posMatrix,c.posMatrix,[g*b,y*b,0]),p.K(c.posMatrix,c.posMatrix,[1/2**m,1/2**m,0]),s[n]=c}}return s}getSourceTile(t,s){const n=this.sourceCache._source;let o=t.overscaledZ-this.deltaZoom;if(o>n.maxzoom&&(o=n.maxzoom),o<n.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(o).key);let c=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!c||!c.dem)&&s)for(;o>=n.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(t.scaledTo(o--).key);return c}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((s=>s.timeAdded>=t))}}class uo{constructor(t,s,n){this.painter=t,this.sourceCache=new ac(s),this.options=n,this.exaggeration=typeof n.exaggeration=="number"?n.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,s,n,o=p.X){var c;if(!(s>=0&&s<o&&n>=0&&n<o))return 0;const m=this.getTerrainData(t),g=(c=m.tile)===null||c===void 0?void 0:c.dem;if(!g)return 0;const y=(function(B,V,$){var N=V[0],q=V[1];return B[0]=$[0]*N+$[4]*q+$[12],B[1]=$[1]*N+$[5]*q+$[13],B})([],[s/o*p.X,n/o*p.X],m.u_terrain_matrix),b=[y[0]*g.dim,y[1]*g.dim],T=Math.floor(b[0]),S=Math.floor(b[1]),z=b[0]-T,A=b[1]-S;return g.get(T,S)*(1-z)*(1-A)+g.get(T+1,S)*z*(1-A)+g.get(T,S+1)*(1-z)*A+g.get(T+1,S+1)*z*A}getElevationForLngLatZoom(t,s){if(!p.bb(s,t.wrap()))return 0;const{tileID:n,mercatorX:o,mercatorY:c}=this._getOverscaledTileIDFromLngLatZoom(t,s);return this.getElevation(n,o%p.X,c%p.X,p.X)}getElevation(t,s,n,o=p.X){return this.getDEMElevation(t,s,n,o)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const o=this.painter.context,c=new p.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new ae(o,c,o.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new ae(o,new p.R({width:1,height:1}),o.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(o.gl.NEAREST,o.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=p.an([])}const s=this.sourceCache.getSourceTile(t,!0);if(s&&s.dem&&(!s.demTexture||s.needsTerrainPrepare)){const o=this.painter.context;s.demTexture=this.painter.getTileTexture(s.dem.stride),s.demTexture?s.demTexture.update(s.dem.getPixels(),{premultiply:!1}):s.demTexture=new ae(o,s.dem.getPixels(),o.gl.RGBA,{premultiply:!1}),s.demTexture.bind(o.gl.NEAREST,o.gl.CLAMP_TO_EDGE),s.needsTerrainPrepare=!1}const n=s&&s+s.tileID.key+t.key;if(n&&!this._demMatrixCache[n]){const o=this.sourceCache.sourceCache._source.maxzoom;let c=t.canonical.z-s.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=o?c=t.canonical.z-o:p.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=t.canonical.x-(t.canonical.x>>c<<c),g=t.canonical.y-(t.canonical.y>>c<<c),y=p.bc(new Float64Array(16),[1/(p.X<<c),1/(p.X<<c),0]);p.J(y,y,[m*p.X,g*p.X,0]),this._demMatrixCache[t.key]={matrix:y,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:s&&s.dem&&s.dem.dim||1,u_terrain_matrix:n?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:s&&s.dem&&s.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(s&&s.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:s}}getFramebuffer(t){const s=this.painter,n=s.width/devicePixelRatio,o=s.height/devicePixelRatio;return!this._fbo||this._fbo.width===n&&this._fbo.height===o||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new ae(s.context,{width:n,height:o,data:null},s.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(s.context.gl.NEAREST,s.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new ae(s.context,{width:n,height:o,data:null},s.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(s.context.gl.NEAREST,s.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=s.context.createFramebuffer(n,o,!0,!1),this._fbo.depthAttachment.set(s.context.createRenderbuffer(s.context.gl.DEPTH_COMPONENT16,n,o))),this._fbo.colorAttachment.set(t==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const s=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let c=0,m=0;c<this._coordsTextureSize;c++)for(let g=0;g<this._coordsTextureSize;g++,m+=4)s[m+0]=255&g,s[m+1]=255&c,s[m+2]=g>>8<<4|c>>8,s[m+3]=0;const n=new p.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(s.buffer)),o=new ae(t,n,t.gl.RGBA,{premultiply:!1});return o.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const s=new Uint8Array(4),n=this.painter.context,o=n.gl,c=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),g=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(c,g-m-1,1,1,o.RGBA,o.UNSIGNED_BYTE,s),n.bindFramebuffer.set(null);const y=s[0]+(s[2]>>4<<8),b=s[1]+((15&s[2])<<8),T=this.coordsIndex[255-s[3]],S=T&&this.sourceCache.getTileByID(T);if(!S)return null;const z=this._coordsTextureSize,A=(1<<S.tileID.canonical.z)*z;return new p.Z((S.tileID.canonical.x*z+y)/A+S.tileID.wrap,(S.tileID.canonical.y*z+b)/A,this.getElevation(S.tileID,y,b,z))}depthAtPoint(t){const s=new Uint8Array(4),n=this.painter.context,o=n.gl;return n.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),o.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,o.RGBA,o.UNSIGNED_BYTE,s),n.bindFramebuffer.set(null),(s[0]/16777216+s[1]/65536+s[2]/256+s[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;const t=this.painter.context,s=new p.bd,n=new p.aY,o=this.meshSize,c=p.X/o,m=o*o;for(let S=0;S<=o;S++)for(let z=0;z<=o;z++)s.emplaceBack(z*c,S*c,0);for(let S=0;S<m;S+=o+1)for(let z=0;z<o;z++)n.emplaceBack(z+S,o+z+S+1,o+z+S+2),n.emplaceBack(z+S,o+z+S+2,z+S+1);const g=s.length,y=g+2*(o+1);for(const S of[0,1])for(let z=0;z<=o;z++)for(const A of[0,1])s.emplaceBack(z*c,S*p.X,A);for(let S=0;S<2*o;S+=2)n.emplaceBack(y+S,y+S+1,y+S+3),n.emplaceBack(y+S,y+S+3,y+S+2),n.emplaceBack(g+S,g+S+3,g+S+1),n.emplaceBack(g+S,g+S+2,g+S+3);const b=s.length,T=b+2*(o+1);for(const S of[0,1])for(let z=0;z<=o;z++)for(const A of[0,1])s.emplaceBack(S*p.X,z*c,A);for(let S=0;S<2*o;S+=2)n.emplaceBack(b+S,b+S+1,b+S+3),n.emplaceBack(b+S,b+S+3,b+S+2),n.emplaceBack(T+S,T+S+3,T+S+1),n.emplaceBack(T+S,T+S+2,T+S+3);return this._mesh=new Za(t.createVertexBuffer(s,co.members),t.createIndexBuffer(n),p.a0.simpleSegment(0,0,s.length,n.length)),this._mesh}getMeshFrameDelta(t){return 2*Math.PI*p.be/Math.pow(2,t)/5}getMinTileElevationForLngLatZoom(t,s){var n;const{tileID:o}=this._getOverscaledTileIDFromLngLatZoom(t,s);return(n=this.getMinMaxElevation(o).minElevation)!==null&&n!==void 0?n:0}getMinMaxElevation(t){const s=this.getTerrainData(t).tile,n={minElevation:null,maxElevation:null};return s&&s.dem&&(n.minElevation=s.dem.min*this.exaggeration,n.maxElevation=s.dem.max*this.exaggeration),n}_getOverscaledTileIDFromLngLatZoom(t,s){const n=p.Z.fromLngLat(t.wrap()),o=(1<<s)*p.X,c=n.x*o,m=n.y*o,g=Math.floor(c/p.X),y=Math.floor(m/p.X);return{tileID:new p.S(s,0,s,g,y),mercatorX:c,mercatorY:m}}}class nc{constructor(t,s,n){this._context=t,this._size=s,this._tileSize=n,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const s=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),n=new ae(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return n.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),s.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),s.colorAttachment.set(n.texture),{id:t,fbo:s,texture:n,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((s=>t.id!==s)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const s of this._recentlyUsed)if(!this._objects[s].inUse)return this._objects[s];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&this._objects.some((t=>!t.inUse))===!1}}const As={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class ul{constructor(t,s){this.painter=t,this.terrain=s,this.pool=new nc(t.context,30,s.sourceCache.tileSize*s.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,s){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((n=>!t._layers[n].isHidden(s))),this._coordsDescendingInv={};for(const n in t.sourceCaches){this._coordsDescendingInv[n]={};const o=t.sourceCaches[n].getVisibleCoordinates();for(const c of o){const m=this.terrain.sourceCache.getTerrainCoords(c);for(const g in m)this._coordsDescendingInv[n][g]||(this._coordsDescendingInv[n][g]=[]),this._coordsDescendingInv[n][g].push(m[g])}}this._coordsDescendingInvStr={};for(const n of t._order){const o=t._layers[n],c=o.source;if(As[o.type]&&!this._coordsDescendingInvStr[c]){this._coordsDescendingInvStr[c]={};for(const m in this._coordsDescendingInv[c])this._coordsDescendingInvStr[c][m]=this._coordsDescendingInv[c][m].map((g=>g.key)).sort().join()}}for(const n of this._renderableTiles)for(const o in this._coordsDescendingInvStr){const c=this._coordsDescendingInvStr[o][n.tileID.key];c&&c!==n.rttCoords[o]&&(n.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const s=t.type,n=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(As[s]&&(this._prevType&&As[this._prevType]||this._stacks.push([]),this._prevType=s,this._stacks[this._stacks.length-1].push(t.id),!o))return!0;if(As[this._prevType]||As[s]&&o){this._prevType=s;const c=this._stacks.length-1,m=this._stacks[c]||[];for(const g of this._renderableTiles){if(this.pool.isFull()&&(il(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(g),g.rtt[c]){const b=this.pool.getObjectForId(g.rtt[c].id);if(b.stamp===g.rtt[c].stamp){this.pool.useObject(b);continue}}const y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),g.rtt[c]={id:y.id,stamp:y.stamp},n.context.bindFramebuffer.set(y.fbo.framebuffer),n.context.clear({color:p.aM.transparent,stencil:0}),n.currentStencilSource=void 0;for(let b=0;b<m.length;b++){const T=n.style._layers[m[b]],S=T.source?this._coordsDescendingInv[T.source][g.tileID.key]:[g.tileID];n.context.viewport.set([0,0,y.fbo.width,y.fbo.height]),n._renderTileClippingMasks(T,S),n.renderLayer(n,n.style.sourceCaches[T.source],T,S),T.source&&(g.rttCoords[T.source]=this._coordsDescendingInvStr[T.source][g.tileID.key])}}return il(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),As[s]}return!1}}const ho={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},hl=Pi,oc={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Cs,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,refreshExpiredTiles:!0,scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],zoom:0,bearing:0,pitch:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:p.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0},po=u=>{u.touchstart=u.dragStart,u.touchmoveWindow=u.dragMove,u.touchend=u.dragEnd},lc={showCompass:!0,showZoom:!0,visualizePitch:!1};class cc{constructor(t,s,n=!1){this.mousedown=m=>{this.startMouse(p.e({},m,{ctrlKey:!0,preventDefault:()=>m.preventDefault()}),at.mousePos(this.element,m)),at.addEventListener(window,"mousemove",this.mousemove),at.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=m=>{this.moveMouse(m,at.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=at.touchPos(this.element,m.targetTouches)[0],this.startTouch(m,this._startPos),at.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),at.addEventListener(window,"touchend",this.touchend))},this.touchmove=m=>{m.targetTouches.length!==1?this.reset():(this._lastPos=at.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._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{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=t.dragRotate._mouseRotate.getClickTolerance(),c=t.dragRotate._mousePitch.getClickTolerance();this.element=s,this.mouseRotate=Qn({clickTolerance:o,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:g,bearingDegreesPerPixelMoved:y=.8})=>{const b=new Yn;return new gr({clickTolerance:g,move:(T,S)=>({bearingDelta:(S.x-T.x)*y}),moveStateManager:b,enable:m,assignEvents:po})})({clickTolerance:o,enable:!0}),this.map=t,n&&(this.mousePitch=to({clickTolerance:c,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:g,pitchDegreesPerPixelMoved:y=-.5})=>{const b=new Yn;return new gr({clickTolerance:g,move:(T,S)=>({pitchDelta:(S.y-T.y)*y}),moveStateManager:b,enable:m,assignEvents:po})})({clickTolerance:c,enable:!0})),at.addEventListener(s,"mousedown",this.mousedown),at.addEventListener(s,"touchstart",this.touchstart,{passive:!1}),at.addEventListener(s,"touchcancel",this.reset)}startMouse(t,s){this.mouseRotate.dragStart(t,s),this.mousePitch&&this.mousePitch.dragStart(t,s),at.disableDrag()}startTouch(t,s){this.touchRotate.dragStart(t,s),this.touchPitch&&this.touchPitch.dragStart(t,s),at.disableDrag()}moveMouse(t,s){const n=this.map,{bearingDelta:o}=this.mouseRotate.dragMove(t,s)||{};if(o&&n.setBearing(n.getBearing()+o),this.mousePitch){const{pitchDelta:c}=this.mousePitch.dragMove(t,s)||{};c&&n.setPitch(n.getPitch()+c)}}moveTouch(t,s){const n=this.map,{bearingDelta:o}=this.touchRotate.dragMove(t,s)||{};if(o&&n.setBearing(n.getBearing()+o),this.touchPitch){const{pitchDelta:c}=this.touchPitch.dragMove(t,s)||{};c&&n.setPitch(n.getPitch()+c)}}off(){const t=this.element;at.removeEventListener(t,"mousedown",this.mousedown),at.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),at.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),at.removeEventListener(window,"touchend",this.touchend),at.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){at.enableDrag(),at.removeEventListener(window,"mousemove",this.mousemove),at.removeEventListener(window,"mouseup",this.mouseup),at.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),at.removeEventListener(window,"touchend",this.touchend)}}let _i;function de(u,t,s){const n=new p.N(u.lng,u.lat);if(u=new p.N(u.lng,u.lat),t){const o=new p.N(u.lng-360,u.lat),c=new p.N(u.lng+360,u.lat),m=s.locationPoint(u).distSqr(t);s.locationPoint(o).distSqr(t)<m?u=o:s.locationPoint(c).distSqr(t)<m&&(u=c)}for(;Math.abs(u.lng-s.center.lng)>180;){const o=s.locationPoint(u);if(o.x>=0&&o.y>=0&&o.x<=s.width&&o.y<=s.height)break;u.lng>s.center.lng?u.lng-=360:u.lng+=360}return u.lng!==n.lng&&s.locationPoint(u).y>s.height/2-s.getHorizon()?u:n}const Ds={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 en(u,t,s){const n=u.classList;for(const o in Ds)n.remove(`maplibregl-${s}-anchor-${o}`);n.add(`maplibregl-${s}-anchor-${t}`)}class rn extends p.E{constructor(t){if(super(),this._onKeyPress=s=>{const n=s.code,o=s.charCode||s.keyCode;n!=="Space"&&n!=="Enter"&&o!==32&&o!==13||this.togglePopup()},this._onMapClick=s=>{const n=s.originalEvent.target,o=this._element;this._popup&&(n===o||o.contains(n))&&this.togglePopup()},this._update=s=>{var n;if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();((s==null?void 0:s.type)==="terrain"||(s==null?void 0:s.type)==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?de(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.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||s&&s.type!=="moveend"||(this._pos=this._pos.round()),at.setTransform(this._element,`${Ds[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${m} ${c}`),mt.frameAsync(new AbortController).then((()=>{this._updateOpacity(s&&s.type==="moveend")})).catch((()=>{}))},this._onMove=s=>{if(!this._isDragging){const n=this._clickTolerance||this._map._clickTolerance;this._isDragging=s.point.dist(this._pointerdownPos)>=n}this._isDragging&&(this._pos=s.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=s=>{this._element.contains(s.originalEvent.target)&&(s.preventDefault(),this._positionDelta=s.point.sub(this._pos).add(this._offset),this._pointerdownPos=s.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=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._subpixelPositioning=t&&t.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment!=="auto"?t.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(t==null?void 0:t.opacity,t==null?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=p.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=at.create("div");const s=at.createNS("http://www.w3.org/2000/svg","svg"),n=41,o=27;s.setAttributeNS(null,"display","block"),s.setAttributeNS(null,"height",`${n}px`),s.setAttributeNS(null,"width",`${o}px`),s.setAttributeNS(null,"viewBox",`0 0 ${o} ${n}`);const c=at.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=at.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const g=at.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"transform","translate(3.0, 29.0)"),g.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 N of y){const q=at.createNS("http://www.w3.org/2000/svg","ellipse");q.setAttributeNS(null,"opacity","0.04"),q.setAttributeNS(null,"cx","10.5"),q.setAttributeNS(null,"cy","5.80029008"),q.setAttributeNS(null,"rx",N.rx),q.setAttributeNS(null,"ry",N.ry),g.appendChild(q)}const b=at.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=at.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=at.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const z=at.createNS("http://www.w3.org/2000/svg","path");z.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(z);const A=at.createNS("http://www.w3.org/2000/svg","g");A.setAttributeNS(null,"transform","translate(6.0, 7.0)"),A.setAttributeNS(null,"fill","#FFFFFF");const B=at.createNS("http://www.w3.org/2000/svg","g");B.setAttributeNS(null,"transform","translate(8.0, 8.0)");const V=at.createNS("http://www.w3.org/2000/svg","circle");V.setAttributeNS(null,"fill","#000000"),V.setAttributeNS(null,"opacity","0.25"),V.setAttributeNS(null,"cx","5.5"),V.setAttributeNS(null,"cy","5.5"),V.setAttributeNS(null,"r","5.4999962");const $=at.createNS("http://www.w3.org/2000/svg","circle");$.setAttributeNS(null,"fill","#FFFFFF"),$.setAttributeNS(null,"cx","5.5"),$.setAttributeNS(null,"cy","5.5"),$.setAttributeNS(null,"r","5.4999962"),B.appendChild(V),B.appendChild($),m.appendChild(g),m.appendChild(b),m.appendChild(S),m.appendChild(A),m.appendChild(B),s.appendChild(m),s.setAttributeNS(null,"height",n*this._scale+"px"),s.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(s),this._offset=p.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(s=>{s.preventDefault()})),this._element.addEventListener("mousedown",(s=>{s.preventDefault()})),en(this._element,this._anchor,"marker"),t&&t.className)for(const s of t.className.split(" "))this._element.classList.add(s);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.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),at.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=p.N.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const s=Math.abs(13.5)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[s,-1*(38.1-13.5+s)],"bottom-right":[-s,-1*(38.1-13.5+s)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var s,n;if(!(!((s=this._map)===null||s===void 0)&&s.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(t)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 g=-this._offset.y/o.transform._pixelPerMeter,y=Math.sin(o.getPitch()*Math.PI/180)*g,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;!((n=this._popup)===null||n===void 0)&&n.isOpen()&&T&&this._popup.remove(),this._element.style.opacity=T?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=p.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(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(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,s){return t===void 0&&s===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),t!==void 0&&(this._opacity=t),s!==void 0&&(this._opacityWhenCovered=s),this._map&&this._updateOpacity(!0),this}}const dl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let fa=0,ma=!1;const nr={maxWidth:100,unit:"metric"};function _a(u,t,s){const n=s&&s.maxWidth||100,o=u._container.clientHeight/2,c=u.unproject([0,o]),m=u.unproject([n,o]),g=c.distanceTo(m);if(s&&s.unit==="imperial"){const y=3.2808*g;y>5280?Mt(t,n,y/5280,u._getUIString("ScaleControl.Miles")):Mt(t,n,y,u._getUIString("ScaleControl.Feet"))}else s&&s.unit==="nautical"?Mt(t,n,g/1852,u._getUIString("ScaleControl.NauticalMiles")):g>=1e3?Mt(t,n,g/1e3,u._getUIString("ScaleControl.Kilometers")):Mt(t,n,g,u._getUIString("ScaleControl.Meters"))}function Mt(u,t,s,n){const o=(function(c){const m=Math.pow(10,`${Math.floor(c)}`.length-1);let g=c/m;return g=g>=10?10:g>=5?5:g>=3?3:g>=2?2:g>=1?1:(function(y){const b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b})(g),m*g})(s);u.style.width=t*(o/s)+"px",u.innerHTML=`${o}&nbsp;${n}`}const Bt={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},sn=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function an(u){if(u){if(typeof u=="number"){const t=Math.round(Math.abs(u)/Math.SQRT2);return{center:new p.P(0,0),top:new p.P(0,u),"top-left":new p.P(t,t),"top-right":new p.P(-t,t),bottom:new p.P(0,-u),"bottom-left":new p.P(t,-t),"bottom-right":new p.P(-t,-t),left:new p.P(u,0),right:new p.P(-u,0)}}if(u instanceof p.P||Array.isArray(u)){const t=p.P.convert(u);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:p.P.convert(u.center||[0,0]),top:p.P.convert(u.top||[0,0]),"top-left":p.P.convert(u["top-left"]||[0,0]),"top-right":p.P.convert(u["top-right"]||[0,0]),bottom:p.P.convert(u.bottom||[0,0]),"bottom-left":p.P.convert(u["bottom-left"]||[0,0]),"bottom-right":p.P.convert(u["bottom-right"]||[0,0]),left:p.P.convert(u.left||[0,0]),right:p.P.convert(u.right||[0,0])}}return an(new p.P(0,0))}const fo=Pi;R.AJAXError=p.bh,R.Evented=p.E,R.LngLat=p.N,R.MercatorCoordinate=p.Z,R.Point=p.P,R.addProtocol=p.bi,R.config=p.a,R.removeProtocol=p.bj,R.AttributionControl=Ps,R.BoxZoomHandler=mi,R.CanvasSource=bi,R.CooperativeGesturesHandler=zs,R.DoubleClickZoomHandler=es,R.DragPanHandler=ol,R.DragRotateHandler=ll,R.EdgeInsets=Is,R.FullscreenControl=class extends p.E{constructor(u={}){super(),this._onFullscreenChange=()=>{var t;let s=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((t=s==null?void 0:s.shadowRoot)===null||t===void 0)&&t.fullscreenElement;)s=s.shadowRoot.fullscreenElement;s===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,u&&u.container&&(u.container instanceof HTMLElement?this._container=u.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(u){return this._map=u,this._container||(this._container=this._map.getContainer()),this._controlContainer=at.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){at.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const u=this._fullscreenButton=at.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);at.create("span","maplibregl-ctrl-icon",u).setAttribute("aria-hidden","true"),u.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const u=this._getTitle();this._fullscreenButton.setAttribute("aria-label",u),this._fullscreenButton.title=u}_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()}},R.GeoJSONSource=Ks,R.GeolocateControl=class extends p.E{constructor(u){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new p.k("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,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(t),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new p.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{const s=new p.N(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,o=this._map.getBearing(),c=p.e({bearing:o},this.options.fitBoundsOptions),m=it.fromLngLat(s,n);this._map.fitBounds(m,c,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const s=new p.N(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(s).addTo(this._map),this._userLocationDotMarker.setLngLat(s).addTo(this._map),this._accuracy=t.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=t=>{if(this._map){if(this.options.trackUserLocation)if(t.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 s=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=s,this._geolocateButton.setAttribute("aria-label",s),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&ma)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new p.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=at.create("button","maplibregl-ctrl-geolocate",this._container),at.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){p.w("Geolocation support is not available so the GeolocateControl will be disabled.");const s=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=s,this._geolocateButton.setAttribute("aria-label",s)}else{const s=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=s,this._geolocateButton.setAttribute("aria-label",s)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=at.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new rn({element:this._dotElement}),this._circleElement=at.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new rn({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",(s=>{s.geolocateSource||this._watchState!=="ACTIVE_LOCK"||s.originalEvent&&s.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({},dl,u)}onAdd(u){return this._map=u,this._container=at.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),(function(){return p._(this,arguments,void 0,(function*(t=!1){if(_i!==void 0&&!t)return _i;if(window.navigator.permissions===void 0)return _i=!!window.navigator.geolocation,_i;try{_i=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{_i=!!window.navigator.geolocation}return _i}))})().then((t=>this._finishSetupUI(t))),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(),at.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,fa=0,ma=!1}_isOutOfMapMaxBounds(u){const t=this._map.getMaxBounds(),s=u.coords;return t&&(s.longitude<t.getWest()||s.longitude>t.getEast()||s.latitude<t.getSouth()||s.latitude>t.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 u=this._map.getBounds(),t=u.getSouthEast(),s=u.getNorthEast(),n=t.distanceTo(s),o=Math.ceil(this._accuracy/(n/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":fa--,ma=!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 u;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),fa++,fa>1?(u={maximumAge:6e5,timeout:0},ma=!0):(u=this.options.positionOptions,ma=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,u)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},R.Hash=Ga,R.ImageSource=fr,R.KeyboardHandler=Si,R.LngLatBounds=it,R.LogoControl=lo,R.Map=class extends cl{constructor(u){p.bf.mark(p.bg.create);const t=Object.assign(Object.assign({},oc),u);if(t.minZoom!=null&&t.maxZoom!=null&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(t.minPitch!=null&&t.maxPitch!=null&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(t.minPitch!=null&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(t.maxPitch!=null&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new ks(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ht,this._controls=[],this._mapId=p.a4(),this._contextLost=s=>{s.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new p.k("webglcontextlost",{originalEvent:s}))},this._contextRestored=s=>{this._setupPainter(),this.resize(),this._update(),this.fire(new p.k("webglcontextrestored",{originalEvent:s}))},this._onMapScroll=s=>{if(s.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=t.preserveDrawingBuffer===!0,this._antialias=t.antialias===!0,this._trackResize=t.trackResize===!0,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles===!0,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions===!0,this._collectResourceTiming=t.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},ho),t.locale),this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this.transformCameraUpdate=t.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=t.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=ui.addThrottleControl((()=>this.isMoving())),this._requestManager=new Sn(t.transformRequest),typeof t.container=="string"){if(this._container=document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(t.maxBounds&&this.setMaxBounds(t.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 s=!1;const n=ca((o=>{this._trackResize&&!this._removed&&(this.resize(o),this.redraw())}),50);this._resizeObserver=new ResizeObserver((o=>{s?n(o):s=!0})),this._resizeObserver.observe(this._container)}this.handlers=new oo(this,t),this._hash=t.hash&&new Ga(typeof t.hash=="string"&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,p.e({},t.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new Ps(typeof t.attributionControl=="boolean"?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new lo,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(s=>{this._update(s.dataType==="style"),this.fire(new p.k(`${s.dataType}data`,s))})),this.on("dataloading",(s=>{this.fire(new p.k(`${s.dataType}dataloading`,s))})),this.on("dataabort",(s=>{this.fire(new p.k("sourcedataabort",s))}))}_getMapId(){return this._mapId}addControl(u,t){if(t===void 0&&(t=u.getDefaultPosition?u.getDefaultPosition():"top-right"),!u||!u.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 s=u.onAdd(this);this._controls.push(u);const n=this._controlPositions[t];return t.indexOf("bottom")!==-1?n.insertBefore(s,n.firstChild):n.appendChild(s),this}removeControl(u){if(!u||!u.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 t=this._controls.indexOf(u);return t>-1&&this._controls.splice(t,1),u.onRemove(this),this}hasControl(u){return this._controls.indexOf(u)>-1}calculateCameraOptionsFromTo(u,t,s,n){return n==null&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(s,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(u,t,s,n)}resize(u){var t;const s=this._containerDimensions(),n=s[0],o=s[1],c=this._getClampedPixelRatio(n,o);if(this._resizeCanvas(n,o,c),this.painter.resize(n,o,c),this.painter.overLimit()){const g=this.painter.context.gl;this._maxCanvasSize=[g.drawingBufferWidth,g.drawingBufferHeight];const y=this._getClampedPixelRatio(n,o);this._resizeCanvas(n,o,y),this.painter.resize(n,o,y)}this.transform.resize(n,o),(t=this._requestedCameraState)===null||t===void 0||t.resize(n,o);const m=!this._moving;return m&&(this.stop(),this.fire(new p.k("movestart",u)).fire(new p.k("move",u))),this.fire(new p.k("resize",u)),m&&this.fire(new p.k("moveend",u)),this}_getClampedPixelRatio(u,t){const{0:s,1:n}=this._maxCanvasSize,o=this.getPixelRatio(),c=u*o,m=t*o;return Math.min(c>s?s/c:1,m>n?n/m:1)*o}getPixelRatio(){var u;return(u=this._overridePixelRatio)!==null&&u!==void 0?u:devicePixelRatio}setPixelRatio(u){this._overridePixelRatio=u,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(u){return this.transform.setMaxBounds(it.convert(u)),this._update()}setMinZoom(u){if((u=u??-2)>=-2&&u<=this.transform.maxZoom)return this.transform.minZoom=u,this._update(),this.getZoom()<u&&this.setZoom(u),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(u){if((u=u??22)>=this.transform.minZoom)return this.transform.maxZoom=u,this._update(),this.getZoom()>u&&this.setZoom(u),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(u){if((u=u??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(u>=0&&u<=this.transform.maxPitch)return this.transform.minPitch=u,this._update(),this.getPitch()<u&&this.setPitch(u),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(u){if((u=u??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(u>=this.transform.minPitch)return this.transform.maxPitch=u,this._update(),this.getPitch()>u&&this.setPitch(u),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(u){return this.transform.renderWorldCopies=u,this._update()}project(u){return this.transform.locationPoint(p.N.convert(u),this.style&&this.terrain)}unproject(u){return this.transform.pointLocation(p.P.convert(u),this.terrain)}isMoving(){var u;return this._moving||((u=this.handlers)===null||u===void 0?void 0:u.isMoving())}isZooming(){var u;return this._zooming||((u=this.handlers)===null||u===void 0?void 0:u.isZooming())}isRotating(){var u;return this._rotating||((u=this.handlers)===null||u===void 0?void 0:u.isRotating())}_createDelegatedListener(u,t,s){if(u==="mouseenter"||u==="mouseover"){let n=!1;return{layers:t,listener:s,delegates:{mousemove:o=>{const c=t.filter((g=>this.getLayer(g))),m=c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[];m.length?n||(n=!0,s.call(this,new Oe(u,this,o.originalEvent,{features:m}))):n=!1},mouseout:()=>{n=!1}}}}if(u==="mouseleave"||u==="mouseout"){let n=!1;return{layers:t,listener:s,delegates:{mousemove:o=>{const c=t.filter((m=>this.getLayer(m)));(c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[]).length?n=!0:n&&(n=!1,s.call(this,new Oe(u,this,o.originalEvent)))},mouseout:o=>{n&&(n=!1,s.call(this,new Oe(u,this,o.originalEvent)))}}}}{const n=o=>{const c=t.filter((g=>this.getLayer(g))),m=c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[];m.length&&(o.features=m,s.call(this,o),delete o.features)};return{layers:t,listener:s,delegates:{[u]:n}}}}_saveDelegatedListener(u,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[u]=this._delegatedListeners[u]||[],this._delegatedListeners[u].push(t)}_removeDelegatedListener(u,t,s){if(!this._delegatedListeners||!this._delegatedListeners[u])return;const n=this._delegatedListeners[u];for(let o=0;o<n.length;o++){const c=n[o];if(c.listener===s&&c.layers.length===t.length&&c.layers.every((m=>t.includes(m)))){for(const m in c.delegates)this.off(m,c.delegates[m]);return void n.splice(o,1)}}}on(u,t,s){if(s===void 0)return super.on(u,t);const n=this._createDelegatedListener(u,typeof t=="string"?[t]:t,s);this._saveDelegatedListener(u,n);for(const o in n.delegates)this.on(o,n.delegates[o]);return this}once(u,t,s){if(s===void 0)return super.once(u,t);const n=typeof t=="string"?[t]:t,o=this._createDelegatedListener(u,n,s);for(const c in o.delegates){const m=o.delegates[c];o.delegates[c]=(...g)=>{this._removeDelegatedListener(u,n,s),m(...g)}}this._saveDelegatedListener(u,o);for(const c in o.delegates)this.once(c,o.delegates[c]);return this}off(u,t,s){return s===void 0?super.off(u,t):(this._removeDelegatedListener(u,typeof t=="string"?[t]:t,s),this)}queryRenderedFeatures(u,t){if(!this.style)return[];let s;const n=u instanceof p.P||Array.isArray(u),o=n?u:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(n?{}:u)||{},o instanceof p.P||typeof o[0]=="number")s=[p.P.convert(o)];else{const c=p.P.convert(o[0]),m=p.P.convert(o[1]);s=[c,new p.P(m.x,c.y),m,new p.P(c.x,m.y),c]}return this.style.queryRenderedFeatures(s,t,this.transform)}querySourceFeatures(u,t){return this.style.querySourceFeatures(u,t)}setStyle(u,t){return(t=p.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&u?(this._diffStyle(u,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(u,t))}setTransformRequest(u){return this._requestManager.setTransformRequest(u),this}_getUIString(u){const t=this._locale[u];if(t==null)throw new Error(`Missing UI string '${u}'`);return t}_updateStyle(u,t){if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(u,t)));const s=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!u)),u?(this.style=new za(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof u=="string"?this.style.loadURL(u,t,s):this.style.loadJSON(u,t,s),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new za(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(u,t){if(typeof u=="string"){const s=this._requestManager.transformRequest(u,"Style");p.h(s,new AbortController).then((n=>{this._updateDiff(n.data,t)})).catch((n=>{n&&this.fire(new p.j(n))}))}else typeof u=="object"&&this._updateDiff(u,t)}_updateDiff(u,t){try{this.style.setState(u,t)&&this._update(!0)}catch(s){p.w(`Unable to perform style diff: ${s.message||s.error||s}. Rebuilding the style from scratch.`),this._updateStyle(u,t)}}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(u,t){return this._lazyInitEmptyStyle(),this.style.addSource(u,t),this._update(!0)}isSourceLoaded(u){const t=this.style&&this.style.sourceCaches[u];if(t!==void 0)return t.loaded();this.fire(new p.j(new Error(`There is no source with ID '${u}'`)))}setTerrain(u){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),u){const t=this.style.sourceCaches[u.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${u.source}`);this.terrain===null&&t.reload();for(const s in this.style._layers){const n=this.style._layers[s];n.type==="hillshade"&&n.source===u.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 uo(this.painter,t,u),this.painter.renderToTexture=new ul(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=s=>{s.dataType==="style"?this.terrain.sourceCache.freeRtt():s.dataType==="source"&&s.tile&&(s.sourceId!==u.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(s.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new p.k("terrain",{terrain:u})),this}getTerrain(){var u,t;return(t=(u=this.terrain)===null||u===void 0?void 0:u.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const u=this.style&&this.style.sourceCaches;for(const t in u){const s=u[t]._tiles;for(const n in s){const o=s[n];if(o.state!=="loaded"&&o.state!=="errored")return!1}}return!0}removeSource(u){return this.style.removeSource(u),this._update(!0)}getSource(u){return this.style.getSource(u)}addImage(u,t,s={}){const{pixelRatio:n=1,sdf:o=!1,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b}=s;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||p.b(t))){if(t.width===void 0||t.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:z}=t,A=t;return this.style.addImage(u,{data:new p.R({width:T,height:S},new Uint8Array(z)),pixelRatio:n,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:o,version:0,userImage:A}),A.onAdd&&A.onAdd(this,u),this}}{const{width:T,height:S,data:z}=mt.getImageData(t);this.style.addImage(u,{data:new p.R({width:T,height:S},z),pixelRatio:n,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:o,version:0})}}updateImage(u,t){const s=this.style.getImage(u);if(!s)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 n=t instanceof HTMLImageElement||p.b(t)?mt.getImageData(t):t,{width:o,height:c,data:m}=n;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!==s.data.width||c!==s.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 g=!(t instanceof HTMLImageElement||p.b(t));return s.data.replace(m,g),this.style.updateImage(u,s),this}getImage(u){return this.style.getImage(u)}hasImage(u){return u?!!this.style.getImage(u):(this.fire(new p.j(new Error("Missing required image id"))),!1)}removeImage(u){this.style.removeImage(u)}loadImage(u){return ui.getImage(this._requestManager.transformRequest(u,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(u,t){return this._lazyInitEmptyStyle(),this.style.addLayer(u,t),this._update(!0)}moveLayer(u,t){return this.style.moveLayer(u,t),this._update(!0)}removeLayer(u){return this.style.removeLayer(u),this._update(!0)}getLayer(u){return this.style.getLayer(u)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(u,t,s){return this.style.setLayerZoomRange(u,t,s),this._update(!0)}setFilter(u,t,s={}){return this.style.setFilter(u,t,s),this._update(!0)}getFilter(u){return this.style.getFilter(u)}setPaintProperty(u,t,s,n={}){return this.style.setPaintProperty(u,t,s,n),this._update(!0)}getPaintProperty(u,t){return this.style.getPaintProperty(u,t)}setLayoutProperty(u,t,s,n={}){return this.style.setLayoutProperty(u,t,s,n),this._update(!0)}getLayoutProperty(u,t){return this.style.getLayoutProperty(u,t)}setGlyphs(u,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(u,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(u,t,s={}){return this._lazyInitEmptyStyle(),this.style.addSprite(u,t,s,(n=>{n||this._update(!0)})),this}removeSprite(u){return this._lazyInitEmptyStyle(),this.style.removeSprite(u),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(u,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(u,t,(s=>{s||this._update(!0)})),this}setLight(u,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(u,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(u){return this._lazyInitEmptyStyle(),this.style.setSky(u),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(u,t){return this.style.setFeatureState(u,t),this._update()}removeFeatureState(u,t){return this.style.removeFeatureState(u,t),this._update()}getFeatureState(u){return this.style.getFeatureState(u)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let u=0,t=0;return this._container&&(u=this._container.clientWidth||400,t=this._container.clientHeight||300),[u,t]}_setupContainer(){const u=this._container;u.classList.add("maplibregl-map");const t=this._canvasContainer=at.create("div","maplibregl-canvas-container",u);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=at.create("canvas","maplibregl-canvas",t),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 s=this._containerDimensions(),n=this._getClampedPixelRatio(s[0],s[1]);this._resizeCanvas(s[0],s[1],n);const o=this._controlContainer=at.create("div","maplibregl-control-container",u),c=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((m=>{c[m]=at.create("div",`maplibregl-ctrl-${m} `,o)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(u,t,s){this._canvas.width=Math.floor(s*u),this._canvas.height=Math.floor(s*t),this._canvas.style.width=`${u}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const u={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let t=null;this._canvas.addEventListener("webglcontextcreationerror",(n=>{t={requestedAttributes:u},n&&(t.statusMessage=n.statusMessage,t.type=n.type)}),{once:!0});const s=this._canvas.getContext("webgl2",u)||this._canvas.getContext("webgl",u);if(!s){const n="Failed to initialize WebGL";throw t?(t.message=n,new Error(JSON.stringify(t))):new Error(n)}this.painter=new qa(s,this.transform),Vr.testSupport(s)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(u){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||u,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(u){return this._update(),this._renderTaskQueue.add(u)}_cancelRenderFrame(u){this._renderTaskQueue.remove(u)}_render(u){const t=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(u),this._removed)return;let s=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const o=this.transform.zoom,c=mt.now();this.style.zoomHistory.update(o,c);const m=new p.z(o,{now:c,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),g=m.crossFadingFactor();g===1&&g===this._crossFadingFactor||(s=!0,this._crossFadingFactor=g),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,t,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,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()||s)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const n=this._sourcesDirty||this._styleDirty||this._placementDirty;return n||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new p.k("idle")),!this._loaded||this._fullyLoaded||n||(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 u;this._hash&&this._hash.remove();for(const s of this._controls)s.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),ui.removeThrottleControl(this._imageQueueHandle),(u=this._resizeObserver)===null||u===void 0||u.disconnect();const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t!=null&&t.loseContext&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),at.remove(this._canvasContainer),at.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,mt.frameAsync(this._frameRequest).then((u=>{p.bf.frame(u),this._frameRequest=null,this._render(u)})).catch((()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(u){this._showTileBoundaries!==u&&(this._showTileBoundaries=u,this._update())}get showPadding(){return!!this._showPadding}set showPadding(u){this._showPadding!==u&&(this._showPadding=u,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(u){this._showCollisionBoxes!==u&&(this._showCollisionBoxes=u,u?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(u){this._showOverdrawInspector!==u&&(this._showOverdrawInspector=u,this._update())}get repaint(){return!!this._repaint}set repaint(u){this._repaint!==u&&(this._repaint=u,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(u){this._vertices=u,this._update()}get version(){return hl}getCameraTargetElevation(){return this.transform.elevation}},R.MapMouseEvent=Oe,R.MapTouchEvent=Qr,R.MapWheelEvent=sl,R.Marker=rn,R.NavigationControl=class{constructor(u){this._updateZoomButtons=()=>{const t=this._map.getZoom(),s=t===this._map.getMaxZoom(),n=t===this._map.getMinZoom();this._zoomInButton.disabled=s,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",s.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.toString())},this._rotateCompassArrow=()=>{const t=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=t},this._setButtonTitle=(t,s)=>{const n=this._map._getUIString(`NavigationControl.${s}`);t.title=n,t.setAttribute("aria-label",n)},this.options=p.e({},lc,u),this._container=at.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),at.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),at.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=at.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(u){return this._map=u,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(){at.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(u,t){const s=at.create("button",u,this._container);return s.type="button",s.addEventListener("click",t),s}},R.Popup=class extends p.E{constructor(u){super(),this.remove=()=>(this._content&&at.remove(this._content),this._container&&(at.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=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{var s;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=at.create("div","maplibregl-popup",this._map.getContainer()),this._tip=at.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const g of this.options.className.split(" "))this._container.classList.add(g);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?de(this._lngLat,this._flatPos,this._map.transform):(s=this._lngLat)===null||s===void 0?void 0:s.wrap(),this._trackPointer&&!t)return;const n=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationPoint(this._lngLat));let o=this.options.anchor;const c=an(this.options.offset);if(!o){const g=this._container.offsetWidth,y=this._container.offsetHeight;let b;b=n.y+c.bottom.y<y?["top"]:n.y>this._map.transform.height-y?["bottom"]:[],n.x<g/2?b.push("left"):n.x>this._map.transform.width-g/2&&b.push("right"),o=b.length===0?"bottom":b.join("-")}let m=n.add(c[o]);this.options.subpixelPositioning||(m=m.round()),at.setTransform(this._container,`${Ds[o]} translate(${m.x}px,${m.y}px)`),en(this._container,o,"popup")},this._onClose=()=>{this.remove()},this.options=p.e(Object.create(Bt),u)}addTo(u){return this._map&&this.remove(),this._map=u,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(u){return this._lngLat=p.N.convert(u),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(u){return this.setDOMContent(document.createTextNode(u))}setHTML(u){const t=document.createDocumentFragment(),s=document.createElement("body");let n;for(s.innerHTML=u;n=s.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){var u;return(u=this._container)===null||u===void 0?void 0:u.style.maxWidth}setMaxWidth(u){return this.options.maxWidth=u,this._update(),this}setDOMContent(u){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=at.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(u),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(u){return this._container&&this._container.classList.add(u),this}removeClassName(u){return this._container&&this._container.classList.remove(u),this}setOffset(u){return this.options.offset=u,this._update(),this}toggleClassName(u){if(this._container)return this._container.classList.toggle(u)}setSubpixelPositioning(u){this.options.subpixelPositioning=u}_createCloseButton(){this.options.closeButton&&(this._closeButton=at.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const u=this._container.querySelector(sn);u&&u.focus()}},R.RasterDEMTileSource=ye,R.RasterTileSource=te,R.ScaleControl=class{constructor(u){this._onMove=()=>{_a(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,_a(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},nr),u)}getDefaultPosition(){return"bottom-left"}onAdd(u){return this._map=u,this._container=at.create("div","maplibregl-ctrl maplibregl-ctrl-scale",u.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){at.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},R.ScrollZoomHandler=ji,R.Style=za,R.TerrainControl=class{constructor(u){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=u}onAdd(u){return this._map=u,this._container=at.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=at.create("button","maplibregl-ctrl-terrain",this._container),at.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(){at.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},R.TwoFingersTouchPitchHandler=Es,R.TwoFingersTouchRotateHandler=so,R.TwoFingersTouchZoomHandler=io,R.TwoFingersTouchZoomRotateHandler=no,R.VectorTileSource=Ws,R.VideoSource=hs,R.addSourceType=(u,t)=>p._(void 0,void 0,void 0,(function*(){if(Ys(u))throw new Error(`A source type called "${u}" already exists.`);((s,n)=>{Js[s]=n})(u,t)})),R.clearPrewarmedResources=function(){const u=hi;u&&(u.isPreloaded()&&u.numActive()===1?(u.release(Tr),hi=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},R.getMaxParallelImageRequests=function(){return p.a.MAX_PARALLEL_IMAGE_REQUESTS},R.getRTLTextPluginStatus=function(){return er().getRTLTextPluginStatus()},R.getVersion=function(){return fo},R.getWorkerCount=function(){return Qi.workerCount},R.getWorkerUrl=function(){return p.a.WORKER_URL},R.importScriptInWorkers=function(u){return Hs().broadcast("IS",u)},R.prewarm=function(){Ur().acquire(Tr)},R.setMaxParallelImageRequests=function(u){p.a.MAX_PARALLEL_IMAGE_REQUESTS=u},R.setRTLTextPlugin=function(u,t){return er().setRTLTextPlugin(u,t)},R.setWorkerCount=function(u){Qi.workerCount=u},R.setWorkerUrl=function(u){p.a.WORKER_URL=u}}));var Tn=Lr;return Tn}))})(Fl,Fl.exports)),Fl.exports}var Oh=Bp();const Fp=Ap.xn(Oh),Lp=Dp({__proto__:null,default:Fp},[Oh]);exports.m=Lp;