@rcpch/imd-map 0.1.0 → 0.2.0

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.
@@ -1,5 +1,5 @@
1
- "use strict";var RcpchImdMap=(()=>{var Kf=Object.create;var ec=Object.defineProperty;var Jf=Object.getOwnPropertyDescriptor;var Yf=Object.getOwnPropertyNames;var Qf=Object.getPrototypeOf,em=Object.prototype.hasOwnProperty;var tm=(R,X)=>()=>(X||R((X={exports:{}}).exports,X),X.exports),im=(R,X)=>{for(var re in X)ec(R,re,{get:X[re],enumerable:!0})},Id=(R,X,re,ce)=>{if(X&&typeof X=="object"||typeof X=="function")for(let I of Yf(X))!em.call(R,I)&&I!==re&&ec(R,I,{get:()=>X[I],enumerable:!(ce=Jf(X,I))||ce.enumerable});return R};var tc=(R,X,re)=>(re=R!=null?Kf(Qf(R)):{},Id(X||!R||!R.__esModule?ec(re,"default",{value:R,enumerable:!0}):re,R)),rm=R=>Id(ec({},"__esModule",{value:!0}),R);var Ha=tm((Ih,Ch)=>{"use strict";(function(R,X){typeof Ih=="object"&&typeof Ch<"u"?Ch.exports=X():typeof define=="function"&&define.amd?define(X):(R=typeof globalThis<"u"?globalThis:R||self,R.maplibregl=X())})(Ih,(function(){"use strict";var R={},X={};function re(I,p,Se){if(X[I]=Se,I==="index"){var Ce="var sharedModule = {}; ("+X.shared+")(sharedModule); ("+X.worker+")(sharedModule);",$e={};return X.shared($e),X.index(R,$e),typeof window<"u"&&R.setWorkerUrl(window.URL.createObjectURL(new Blob([Ce],{type:"text/javascript"}))),R}}re("shared",["exports"],(function(I){"use strict";function p(i,t,r,s){return new(r||(r=Promise))((function(l,u){function d(x){try{g(s.next(x))}catch(v){u(v)}}function f(x){try{g(s.throw(x))}catch(v){u(v)}}function g(x){var v;x.done?l(x.value):(v=x.value,v instanceof r?v:new r((function(w){w(v)}))).then(d,f)}g((s=s.apply(i,t||[])).next())}))}function Se(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var Ce=$e;function $e(i,t){this.x=i,this.y=t}$e.prototype={clone:function(){return new $e(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,t){return this.clone()._rotateAround(i,t)},matMult:function(i){return this.clone()._matMult(i)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var t=i.x-this.x,r=i.y-this.y;return t*t+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,t){return Math.atan2(this.x*t-this.y*i,this.x*i+this.y*t)},_matMult:function(i){var t=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=t,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var t=Math.cos(i),r=Math.sin(i),s=r*this.x+t*this.y;return this.x=t*this.x-r*this.y,this.y=s,this},_rotateAround:function(i,t){var r=Math.cos(i),s=Math.sin(i),l=t.y+s*(this.x-t.x)+r*(this.y-t.y);return this.x=t.x+r*(this.x-t.x)-s*(this.y-t.y),this.y=l,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},$e.convert=function(i){return i instanceof $e?i:Array.isArray(i)?new $e(i[0],i[1]):i};var pe=Se(Ce),K=ht;function ht(i,t,r,s){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(s-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=t,this.p2x=r,this.p2y=s}ht.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,t){if(t===void 0&&(t=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,s=0;s<8;s++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)<t)return r;var u=this.sampleCurveDerivativeX(r);if(Math.abs(u)<1e-6)break;r-=l/u}var d=0,f=1;for(r=i,s=0;s<20&&(l=this.sampleCurveX(r),!(Math.abs(l-i)<t));s++)i>l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,t){return this.sampleCurveY(this.solveCurveX(i,t))}};var Dt=Se(K);let Nt,Jt;function li(){return Nt==null&&(Nt=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Nt}function $i(){if(Jt==null&&(Jt=!1,li())){let t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let s=0;s<25;s++){let l=4*s;t.fillStyle=`rgb(${l},${l+1},${l+2})`,t.fillRect(s%5,Math.floor(s/5),1,1)}let r=t.getImageData(0,0,5,5).data;for(let s=0;s<100;s++)if(s%4!=3&&r[s]!==s){Jt=!0;break}}}return Jt||!1}function et(i,t,r,s){let l=new Dt(i,t,r,s);return u=>l.solve(u)}let He=et(.25,.1,.25,1);function Je(i,t,r){return Math.min(r,Math.max(t,i))}function Pt(i,t,r){let s=r-t,l=((i-t)%s+s)%s+t;return l===t?r:l}function Mt(i,...t){for(let r of t)for(let s in r)i[s]=r[s];return i}let Vt=1;function _t(i,t,r){let s={};for(let l in i)s[l]=t.call(this,i[l],l,i);return s}function yi(i,t,r){let s={};for(let l in i)t.call(this,i[l],l,i)&&(s[l]=i[l]);return s}function Ye(i){return Array.isArray(i)?i.map(Ye):typeof i=="object"&&i?_t(i,Ye):i}let Yt={};function ze(i){Yt[i]||(typeof console<"u"&&console.warn(i),Yt[i]=!0)}function tt(i,t,r){return(r.y-i.y)*(t.x-i.x)>(t.y-i.y)*(r.x-i.x)}function st(i){return typeof WorkerGlobalScope<"u"&&i!==void 0&&i instanceof WorkerGlobalScope}let Qt=null;function qt(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}let Qi="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function er(i,t,r,s,l){return p(this,void 0,void 0,(function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");let u=new VideoFrame(i,{timestamp:0});try{let d=u?.format;if(!d||!d.startsWith("BGR")&&!d.startsWith("RGB"))throw new Error(`Unrecognized format ${d}`);let f=d.startsWith("BGR"),g=new Uint8ClampedArray(s*l*4);if(yield u.copyTo(g,(function(x,v,w,C,A){let k=4*Math.max(-v,0),z=(Math.max(0,w)-w)*C*4+k,O=4*C,j=Math.max(0,v),ie=Math.max(0,w);return{rect:{x:j,y:ie,width:Math.min(x.width,v+C)-j,height:Math.min(x.height,w+A)-ie},layout:[{offset:z,stride:O}]}})(i,t,r,s,l)),f)for(let x=0;x<g.length;x+=4){let v=g[x];g[x]=g[x+2],g[x+2]=v}return g}finally{u.close()}}))}let ci,Zt,tr="AbortError";function xn(){return new Error(tr)}let Or={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function yr(i){return Or.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))]}let vn="global-dispatcher";class Di extends Error{constructor(t,r,s,l){super(`AJAXError: ${r} (${t}): ${s}`),this.status=t,this.statusText=r,this.url=s,this.body=l}}let ir=()=>st(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,Yr=function(i,t){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){let s=yr(i.url);if(s)return s(i,t);if(st(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,targetMapId:vn},t)}if(!(/^file:/.test(r=i.url)||/^file:/.test(ir())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return(function(s,l){return p(this,void 0,void 0,(function*(){let u=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:ir(),signal:l.signal});s.type!=="json"||u.headers.has("Accept")||u.headers.set("Accept","application/json");let d=yield fetch(u);if(!d.ok){let x=yield d.blob();throw new Di(d.status,d.statusText,s.url,x)}let f;f=s.type==="arrayBuffer"||s.type==="image"?d.arrayBuffer():s.type==="json"?d.json():d.text();let g=yield f;if(l.signal.aborted)throw xn();return{data:g,cacheControl:d.headers.get("Cache-Control"),expires:d.headers.get("Expires")}}))})(i,t);if(st(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,mustQueue:!0,targetMapId:vn},t)}var r;return(function(s,l){return new Promise(((u,d)=>{var f;let g=new XMLHttpRequest;g.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(g.responseType="arraybuffer");for(let x in s.headers)g.setRequestHeader(x,s.headers[x]);s.type==="json"&&(g.responseType="text",!((f=s.headers)===null||f===void 0)&&f.Accept||g.setRequestHeader("Accept","application/json")),g.withCredentials=s.credentials==="include",g.onerror=()=>{d(new Error(g.statusText))},g.onload=()=>{if(!l.signal.aborted)if((g.status>=200&&g.status<300||g.status===0)&&g.response!==null){let x=g.response;if(s.type==="json")try{x=JSON.parse(g.response)}catch(v){return void d(v)}u({data:x,cacheControl:g.getResponseHeader("Cache-Control"),expires:g.getResponseHeader("Expires")})}else{let x=new Blob([g.response],{type:g.getResponseHeader("Content-Type")});d(new Di(g.status,g.statusText,s.url,x))}},l.signal.addEventListener("abort",(()=>{g.abort(),d(xn())})),g.send(s.body)}))})(i,t)};function Qr(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;let t=new URL(i),r=window.location;return t.protocol===r.protocol&&t.host===r.host}function ls(i,t,r){r[i]&&r[i].indexOf(t)!==-1||(r[i]=r[i]||[],r[i].push(t))}function Er(i,t,r){if(r&&r[i]){let s=r[i].indexOf(t);s!==-1&&r[i].splice(s,1)}}class Nr{constructor(t,r={}){Mt(this,r),this.type=t}}class Vr extends Nr{constructor(t,r={}){super("error",Mt({error:t},r))}}class bn{on(t,r){return this._listeners=this._listeners||{},ls(t,r,this._listeners),this}off(t,r){return Er(t,r,this._listeners),Er(t,r,this._oneTimeListeners),this}once(t,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},ls(t,r,this._oneTimeListeners),this):new Promise((s=>this.once(t,s)))}fire(t,r){typeof t=="string"&&(t=new Nr(t,r||{}));let s=t.type;if(this.listens(s)){t.target=this;let l=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(let f of l)f.call(this,t);let u=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(let f of u)Er(s,f,this._oneTimeListeners),f.call(this,t);let d=this._eventedParent;d&&(Mt(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),d.fire(t))}else t instanceof Vr&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,r){return this._eventedParent=t,this._eventedParentData=r,this}}var oe={$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"}}};let en=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function cs(i,t){let r={};for(let s in i)s!=="ref"&&(r[s]=i[s]);return en.forEach((s=>{s in t&&(r[s]=t[s])})),r}function mt(i,t){if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(let r=0;r<i.length;r++)if(!mt(i[r],t[r]))return!1;return!0}if(typeof i=="object"&&i!==null&&t!==null){if(typeof t!="object"||Object.keys(i).length!==Object.keys(t).length)return!1;for(let r in i)if(!mt(i[r],t[r]))return!1;return!0}return i===t}function Bt(i,t){i.push(t)}function hs(i,t,r){Bt(r,{command:"addSource",args:[i,t[i]]})}function Ur(i,t,r){Bt(t,{command:"removeSource",args:[i]}),r[i]=!0}function kr(i,t,r,s){Ur(i,r,s),hs(i,t,r)}function wn(i,t,r){let s;for(s in i[r])if(Object.prototype.hasOwnProperty.call(i[r],s)&&s!=="data"&&!mt(i[r][s],t[r][s]))return!1;for(s in t[r])if(Object.prototype.hasOwnProperty.call(t[r],s)&&s!=="data"&&!mt(i[r][s],t[r][s]))return!1;return!0}function qi(i,t,r,s,l,u){i=i||{},t=t||{};for(let d in i)Object.prototype.hasOwnProperty.call(i,d)&&(mt(i[d],t[d])||r.push({command:u,args:[s,d,t[d],l]}));for(let d in t)Object.prototype.hasOwnProperty.call(t,d)&&!Object.prototype.hasOwnProperty.call(i,d)&&(mt(i[d],t[d])||r.push({command:u,args:[s,d,t[d],l]}))}function us(i){return i.id}function ds(i,t){return i[t.id]=t,i}class ge{constructor(t,r,s,l){this.message=(t?`${t}: `:"")+s,l&&(this.identifier=l),r!=null&&r.__line__&&(this.line=r.__line__)}}function xr(i,...t){for(let r of t)for(let s in r)i[s]=r[s];return i}class xi extends Error{constructor(t,r){super(r),this.message=r,this.key=t}}class vr{constructor(t,r=[]){this.parent=t,this.bindings={};for(let[s,l]of r)this.bindings[s]=l}concat(t){return new vr(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}let jr={kind:"null"},ve={kind:"number"},it={kind:"string"},qe={kind:"boolean"},Ii={kind:"color"},rr={kind:"object"},Xe={kind:"value"},br={kind:"collator"},zr={kind:"formatted"},$r={kind:"padding"},wr={kind:"resolvedImage"},U={kind:"variableAnchorOffsetCollection"};function M(i,t){return{kind:"array",itemType:i,N:t}}function P(i){if(i.kind==="array"){let t=P(i.itemType);return typeof i.N=="number"?`array<${t}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${t}>`}return i.kind}let D=[jr,ve,it,qe,Ii,zr,rr,M(Xe),$r,wr,U];function N(i,t){if(t.kind==="error")return null;if(i.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!N(i.itemType,t.itemType))&&(typeof i.N!="number"||i.N===t.N))return null}else{if(i.kind===t.kind)return null;if(i.kind==="value"){for(let r of D)if(!N(r,t))return null}}return`Expected ${P(i)} but found ${P(t)} instead.`}function W(i,t){return t.some((r=>r.kind===i.kind))}function Y(i,t){return t.some((r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i))}function te(i,t){return i.kind==="array"&&t.kind==="array"?i.itemType.kind===t.itemType.kind&&typeof i.N=="number":i.kind===t.kind}let Z=.96422,le=.82521,de=4/29,se=6/29,_e=3*se*se,Ne=se*se*se,Ve=Math.PI/180,ut=180/Math.PI;function Ke(i){return(i%=360)<0&&(i+=360),i}function dt([i,t,r,s]){let l,u,d=Wt((.2225045*(i=ot(i))+.7168786*(t=ot(t))+.0606169*(r=ot(r)))/1);i===t&&t===r?l=u=d:(l=Wt((.4360747*i+.3850649*t+.1430804*r)/Z),u=Wt((.0139322*i+.0971045*t+.7141733*r)/le));let f=116*d-16;return[f<0?0:f,500*(l-d),200*(d-u),s]}function ot(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function Wt(i){return i>Ne?Math.pow(i,1/3):i/_e+de}function Ft([i,t,r,s]){let l=(i+16)/116,u=isNaN(t)?l:l+t/500,d=isNaN(r)?l:l-r/200;return l=1*xt(l),u=Z*xt(u),d=le*xt(d),[rt(3.1338561*u-1.6168667*l-.4906146*d),rt(-.9787684*u+1.9161415*l+.033454*d),rt(.0719453*u-.2289914*l+1.4052427*d),s]}function rt(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function xt(i){return i>se?i*i*i:_e*(i-de)}function Rt(i){return parseInt(i.padEnd(2,i),16)/255}function ti(i,t){return si(t?i/100:i,0,1)}function si(i,t,r){return Math.min(Math.max(t,i),r)}function vi(i){return!i.some(Number.isNaN)}let Sn={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 vt{constructor(t,r,s,l=1,u=!0){this.r=t,this.g=r,this.b=s,this.a=l,u||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[t,r,s,l]))}static parse(t){if(t instanceof vt)return t;if(typeof t!="string")return;let r=(function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];let l=Sn[s];if(l){let[d,f,g]=l;return[d/255,f/255,g/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){let d=s.length<6?1:2,f=1;return[Rt(s.slice(f,f+=d)),Rt(s.slice(f,f+=d)),Rt(s.slice(f,f+=d)),Rt(s.slice(f,f+d)||"ff")]}if(s.startsWith("rgb")){let d=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){let[f,g,x,v,w,C,A,k,z,O,j,ie]=d,H=[v||" ",A||" ",O].join("");if(H===" "||H===" /"||H===",,"||H===",,,"){let ee=[x,C,z].join(""),ae=ee==="%%%"?100:ee===""?255:0;if(ae){let fe=[si(+g/ae,0,1),si(+w/ae,0,1),si(+k/ae,0,1),j?ti(+j,ie):1];if(vi(fe))return fe}}return}}let u=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(u){let[d,f,g,x,v,w,C,A,k]=u,z=[g||" ",v||" ",C].join("");if(z===" "||z===" /"||z===",,"||z===",,,"){let O=[+f,si(+x,0,100),si(+w,0,100),A?ti(+A,k):1];if(vi(O))return(function([j,ie,H,ee]){function ae(fe){let Me=(fe+j/30)%12,Ue=ie*Math.min(H,1-H);return H-Ue*Math.max(-1,Math.min(Me-3,9-Me,1))}return j=Ke(j),ie/=100,H/=100,[ae(0),ae(8),ae(4),ee]})(O)}}})(t);return r?new vt(...r,!1):void 0}get rgb(){let{r:t,g:r,b:s,a:l}=this,u=l||1/0;return this.overwriteGetter("rgb",[t/u,r/u,s/u,l])}get hcl(){return this.overwriteGetter("hcl",(function(t){let[r,s,l,u]=dt(t),d=Math.sqrt(s*s+l*l);return[Math.round(1e4*d)?Ke(Math.atan2(l,s)*ut):NaN,d,r,u]})(this.rgb))}get lab(){return this.overwriteGetter("lab",dt(this.rgb))}overwriteGetter(t,r){return Object.defineProperty(this,t,{value:r}),r}toString(){let[t,r,s,l]=this.rgb;return`rgba(${[t,r,s].map((u=>Math.round(255*u))).join(",")},${l})`}}vt.black=new vt(0,0,0,1),vt.white=new vt(1,1,1,1),vt.transparent=new vt(0,0,0,0),vt.red=new vt(1,0,0,1);class No{constructor(t,r,s){this.sensitivity=t?r?"variant":"case":r?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,r){return this.collator.compare(t,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Vo{constructor(t,r,s,l,u){this.text=t,this.image=r,this.scale=s,this.fontStack=l,this.textColor=u}}class Ri{constructor(t){this.sections=t}static fromString(t){return new Ri([new Vo(t,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some((t=>t.text.length!==0||t.image&&t.image.name.length!==0))}static factory(t){return t instanceof Ri?t:Ri.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map((t=>t.text)).join("")}}class Bi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Bi)return t;if(typeof t=="number")return new Bi([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let r of t)if(typeof r!="number")return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new Bi(t)}}toString(){return JSON.stringify(this.values)}}let hc=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Zi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Zi)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let r=0;r<t.length;r+=2){let s=t[r],l=t[r+1];if(typeof s!="string"||!hc.has(s)||!Array.isArray(l)||l.length!==2||typeof l[0]!="number"||typeof l[1]!="number")return}return new Zi(t)}}toString(){return JSON.stringify(this.values)}}class Fi{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Fi({name:t,available:!1}):null}}function Tn(i,t,r,s){return typeof i=="number"&&i>=0&&i<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof r=="number"&&r>=0&&r<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[i,t,r,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[i,t,r,s]:[i,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function tn(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof vt||i instanceof No||i instanceof Ri||i instanceof Bi||i instanceof Zi||i instanceof Fi)return!0;if(Array.isArray(i)){for(let t of i)if(!tn(t))return!1;return!0}if(typeof i=="object"){for(let t in i)if(!tn(i[t]))return!1;return!0}return!1}function Xt(i){if(i===null)return jr;if(typeof i=="string")return it;if(typeof i=="boolean")return qe;if(typeof i=="number")return ve;if(i instanceof vt)return Ii;if(i instanceof No)return br;if(i instanceof Ri)return zr;if(i instanceof Bi)return $r;if(i instanceof Zi)return U;if(i instanceof Fi)return wr;if(Array.isArray(i)){let t=i.length,r;for(let s of i){let l=Xt(s);if(r){if(r===l)continue;r=Xe;break}r=l}return M(r||Xe,t)}return rr}function ps(i){let t=typeof i;return i===null?"":t==="string"||t==="number"||t==="boolean"?String(i):i instanceof vt||i instanceof Ri||i instanceof Bi||i instanceof Zi||i instanceof Fi?i.toString():JSON.stringify(i)}class nr{constructor(t,r){this.type=t,this.value=r}static parse(t,r){if(t.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!tn(t[1]))return r.error("invalid value");let s=t[1],l=Xt(s),u=r.expectedType;return l.kind!=="array"||l.N!==0||!u||u.kind!=="array"||typeof u.N=="number"&&u.N!==0||(l=u),new nr(l,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Gt{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}let Us={string:it,number:ve,boolean:qe,object:rr};class sr{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s,l=1,u=t[0];if(u==="array"){let f,g;if(t.length>2){let x=t[1];if(typeof x!="string"||!(x in Us)||x==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);f=Us[x],l++}else f=Xe;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return r.error('The length argument to "array" must be a positive integer literal',2);g=t[2],l++}s=M(f,g)}else{if(!Us[u])throw new Error(`Types doesn't contain name = ${u}`);s=Us[u]}let d=[];for(;l<t.length;l++){let f=r.parse(t[l],l,Xe);if(!f)return null;d.push(f)}return new sr(s,d)}evaluate(t){for(let r=0;r<this.args.length;r++){let s=this.args[r].evaluate(t);if(!N(this.type,Xt(s)))return s;if(r===this.args.length-1)throw new Gt(`Expected value to be of type ${P(this.type)}, but found ${P(Xt(s))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}let Uo={"to-boolean":qe,"to-color":Ii,"to-number":ve,"to-string":it};class or{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s=t[0];if(!Uo[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&t.length!==2)return r.error("Expected one argument.");let l=Uo[s],u=[];for(let d=1;d<t.length;d++){let f=r.parse(t[d],d,Xe);if(!f)return null;u.push(f)}return new or(l,u)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let r,s;for(let l of this.args){if(r=l.evaluate(t),s=null,r instanceof vt)return r;if(typeof r=="string"){let u=t.parseColor(r);if(u)return u}else if(Array.isArray(r)&&(s=r.length<3||r.length>4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:Tn(r[0],r[1],r[2],r[3]),!s))return new vt(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Gt(s||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(let s of this.args){r=s.evaluate(t);let l=Bi.parse(r);if(l)return l}throw new Gt(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(let s of this.args){r=s.evaluate(t);let l=Zi.parse(r);if(l)return l}throw new Gt(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(let s of this.args){if(r=s.evaluate(t),r===null)return 0;let l=Number(r);if(!isNaN(l))return l}throw new Gt(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return Ri.fromString(ps(this.args[0].evaluate(t)));case"resolvedImage":return Fi.fromString(ps(this.args[0].evaluate(t)));default:return ps(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}let uc=["Unknown","Point","LineString","Polygon"];class js{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"?uc[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let r=this._parseColorCache[t];return r||(r=this._parseColorCache[t]=vt.parse(t)),r}}class rn{constructor(t,r,s=[],l,u=new vr,d=[]){this.registry=t,this.path=s,this.key=s.map((f=>`[${f}]`)).join(""),this.scope=u,this.errors=d,this.expectedType=l,this._isConstant=r}parse(t,r,s,l,u={}){return r?this.concat(r,s,l)._parse(t,u):this._parse(t,u)}_parse(t,r){function s(l,u,d){return d==="assert"?new sr(u,[l]):d==="coerce"?new or(u,[l]):l}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let l=t[0];if(typeof l!="string")return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let u=this.registry[l];if(u){let d=u.parse(t,this);if(!d)return null;if(this.expectedType){let f=this.expectedType,g=d.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||g.kind!=="value")if(f.kind!=="color"&&f.kind!=="formatted"&&f.kind!=="resolvedImage"||g.kind!=="value"&&g.kind!=="string")if(f.kind!=="padding"||g.kind!=="value"&&g.kind!=="number"&&g.kind!=="array")if(f.kind!=="variableAnchorOffsetCollection"||g.kind!=="value"&&g.kind!=="array"){if(this.checkSubtype(f,g))return null}else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"assert")}if(!(d instanceof nr)&&d.type.kind!=="resolvedImage"&&this._isConstant(d)){let f=new js;try{d=new nr(d.type,d.evaluate(f))}catch(g){return this.error(g.message),null}}return d}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(t===void 0?"'undefined' value invalid. Use null instead.":typeof t=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,r,s){let l=typeof t=="number"?this.path.concat(t):this.path,u=s?this.scope.concat(s):this.scope;return new rn(this.registry,this._isConstant,l,r||null,u,this.errors)}error(t,...r){let s=`${this.key}${r.map((l=>`[${l}]`)).join("")}`;this.errors.push(new xi(s,t))}checkSubtype(t,r){let s=N(t,r);return s&&this.error(s),s}}class qr{constructor(t,r){this.type=r.type,this.bindings=[].concat(t),this.result=r}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let r of this.bindings)t(r[1]);t(this.result)}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let s=[];for(let u=1;u<t.length-1;u+=2){let d=t[u];if(typeof d!="string")return r.error(`Expected string, but found ${typeof d} instead.`,u);if(/[^a-zA-Z0-9_]/.test(d))return r.error("Variable names must contain only alphanumeric characters or '_'.",u);let f=r.parse(t[u+1],u+1);if(!f)return null;s.push([d,f])}let l=r.parse(t[t.length-1],t.length-1,r.expectedType,s);return l?new qr(s,l):null}outputDefined(){return this.result.outputDefined()}}class gt{constructor(t,r){this.type=r.type,this.name=t,this.boundExpression=r}static parse(t,r){if(t.length!==2||typeof t[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");let s=t[1];return r.scope.has(s)?new gt(s,r.scope.get(s)):r.error(`Unknown variable "${s}". Make sure "${s}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}}class jo{constructor(t,r,s){this.type=t,this.index=r,this.input=s}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let s=r.parse(t[1],1,ve),l=r.parse(t[2],2,M(r.expectedType||Xe));return s&&l?new jo(l.type.itemType,s,l):null}evaluate(t){let r=this.index.evaluate(t),s=this.input.evaluate(t);if(r<0)throw new Gt(`Array index out of bounds: ${r} < 0.`);if(r>=s.length)throw new Gt(`Array index out of bounds: ${r} > ${s.length-1}.`);if(r!==Math.floor(r))throw new Gt(`Array index must be an integer, but found ${r} instead.`);return s[r]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class $o{constructor(t,r){this.type=qe,this.needle=t,this.haystack=r}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let s=r.parse(t[1],1,Xe),l=r.parse(t[2],2,Xe);return s&&l?W(s.type,[qe,it,ve,jr,Xe])?new $o(s,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`):null}evaluate(t){let r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!s)return!1;if(!Y(r,["boolean","string","number","null"]))throw new Gt(`Expected first argument to be of type boolean, string, number or null, but found ${P(Xt(r))} instead.`);if(!Y(s,["string","array"]))throw new Gt(`Expected second argument to be of type array or string, but found ${P(Xt(s))} instead.`);return s.indexOf(r)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class In{constructor(t,r,s){this.type=ve,this.needle=t,this.haystack=r,this.fromIndex=s}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);let s=r.parse(t[1],1,Xe),l=r.parse(t[2],2,Xe);if(!s||!l)return null;if(!W(s.type,[qe,it,ve,jr,Xe]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`);if(t.length===4){let u=r.parse(t[3],3,ve);return u?new In(s,l,u):null}return new In(s,l)}evaluate(t){let r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!Y(r,["boolean","string","number","null"]))throw new Gt(`Expected first argument to be of type boolean, string, number or null, but found ${P(Xt(r))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(t)),Y(s,["string"])){let u=s.indexOf(r,l);return u===-1?-1:[...s.slice(0,u)].length}if(Y(s,["array"]))return s.indexOf(r,l);throw new Gt(`Expected second argument to be of type array or string, but found ${P(Xt(s))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class qo{constructor(t,r,s,l,u,d){this.inputType=t,this.type=r,this.input=s,this.cases=l,this.outputs=u,this.otherwise=d}static parse(t,r){if(t.length<5)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return r.error("Expected an even number of arguments.");let s,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);let u={},d=[];for(let x=2;x<t.length-1;x+=2){let v=t[x],w=t[x+1];Array.isArray(v)||(v=[v]);let C=r.concat(x);if(v.length===0)return C.error("Expected at least one branch label.");for(let k of v){if(typeof k!="number"&&typeof k!="string")return C.error("Branch labels must be numbers or strings.");if(typeof k=="number"&&Math.abs(k)>Number.MAX_SAFE_INTEGER)return C.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof k=="number"&&Math.floor(k)!==k)return C.error("Numeric branch labels must be integer values.");if(s){if(C.checkSubtype(s,Xt(k)))return null}else s=Xt(k);if(u[String(k)]!==void 0)return C.error("Branch labels must be unique.");u[String(k)]=d.length}let A=r.parse(w,x,l);if(!A)return null;l=l||A.type,d.push(A)}let f=r.parse(t[1],1,Xe);if(!f)return null;let g=r.parse(t[t.length-1],t.length-1,l);return g?f.type.kind!=="value"&&r.concat(1).checkSubtype(s,f.type)?null:new qo(s,l,f,u,d,g):null}evaluate(t){let r=this.input.evaluate(t);return(Xt(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class $s{constructor(t,r,s){this.type=t,this.branches=r,this.otherwise=s}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return r.error("Expected an odd number of arguments.");let s;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);let l=[];for(let d=1;d<t.length-1;d+=2){let f=r.parse(t[d],d,qe);if(!f)return null;let g=r.parse(t[d+1],d+1,s);if(!g)return null;l.push([f,g]),s=s||g.type}let u=r.parse(t[t.length-1],t.length-1,s);if(!u)return null;if(!s)throw new Error("Can't infer output type");return new $s(s,l,u)}evaluate(t){for(let[r,s]of this.branches)if(r.evaluate(t))return s.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(let[r,s]of this.branches)t(r),t(s);t(this.otherwise)}outputDefined(){return this.branches.every((([t,r])=>r.outputDefined()))&&this.otherwise.outputDefined()}}class fs{constructor(t,r,s,l){this.type=t,this.input=r,this.beginIndex=s,this.endIndex=l}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);let s=r.parse(t[1],1,Xe),l=r.parse(t[2],2,ve);if(!s||!l)return null;if(!W(s.type,[M(Xe),it,Xe]))return r.error(`Expected first argument to be of type array or string, but found ${P(s.type)} instead`);if(t.length===4){let u=r.parse(t[3],3,ve);return u?new fs(s.type,s,l,u):null}return new fs(s.type,s,l)}evaluate(t){let r=this.input.evaluate(t),s=this.beginIndex.evaluate(t),l;if(this.endIndex&&(l=this.endIndex.evaluate(t)),Y(r,["string"]))return[...r].slice(s,l).join("");if(Y(r,["array"]))return r.slice(s,l);throw new Gt(`Expected first argument to be of type array or string, but found ${P(Xt(r))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function qs(i,t){let r=i.length-1,s,l,u=0,d=r,f=0;for(;u<=d;)if(f=Math.floor((u+d)/2),s=i[f],l=i[f+1],s<=t){if(f===r||t<l)return f;u=f+1}else{if(!(s>t))throw new Gt("Input is not a number.");d=f-1}return 0}class Cn{constructor(t,r,s){this.type=t,this.input=r,this.labels=[],this.outputs=[];for(let[l,u]of s)this.labels.push(l),this.outputs.push(u)}static parse(t,r){if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");let s=r.parse(t[1],1,ve);if(!s)return null;let l=[],u=null;r.expectedType&&r.expectedType.kind!=="value"&&(u=r.expectedType);for(let d=1;d<t.length;d+=2){let f=d===1?-1/0:t[d],g=t[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);let w=r.parse(g,v,u);if(!w)return null;u=u||w.type,l.push([f,w])}return new Cn(u,s,l)}evaluate(t){let r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);let l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);let u=r.length;return l>=r[u-1]?s[u-1].evaluate(t):s[qs(r,l)].evaluate(t)}eachChild(t){t(this.input);for(let r of this.outputs)t(r)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Ya(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var dc=Qa;function Qa(i,t,r,s){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(s-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=t,this.p2x=r,this.p2y=s}Qa.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,t){if(t===void 0&&(t=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,s=0;s<8;s++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)<t)return r;var u=this.sampleCurveDerivativeX(r);if(Math.abs(u)<1e-6)break;r-=l/u}var d=0,f=1;for(r=i,s=0;s<20&&(l=this.sampleCurveX(r),!(Math.abs(l-i)<t));s++)i>l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,t){return this.sampleCurveY(this.solveCurveX(i,t))}};var pc=Ya(dc);function nn(i,t,r){return i+r*(t-i)}function ms(i,t,r){return i.map(((s,l)=>nn(s,t[l],r)))}let Ci={number:nn,color:function(i,t,r,s="rgb"){switch(s){case"rgb":{let[l,u,d,f]=ms(i.rgb,t.rgb,r);return new vt(l,u,d,f,!1)}case"hcl":{let[l,u,d,f]=i.hcl,[g,x,v,w]=t.hcl,C,A;if(isNaN(l)||isNaN(g))isNaN(l)?isNaN(g)?C=NaN:(C=g,d!==1&&d!==0||(A=x)):(C=l,v!==1&&v!==0||(A=u));else{let ie=g-l;g>l&&ie>180?ie-=360:g<l&&l-g>180&&(ie+=360),C=l+r*ie}let[k,z,O,j]=(function([ie,H,ee,ae]){return ie=isNaN(ie)?0:ie*Ve,Ft([ee,Math.cos(ie)*H,Math.sin(ie)*H,ae])})([C,A??nn(u,x,r),nn(d,v,r),nn(f,w,r)]);return new vt(k,z,O,j,!1)}case"lab":{let[l,u,d,f]=Ft(ms(i.lab,t.lab,r));return new vt(l,u,d,f,!1)}}},array:ms,padding:function(i,t,r){return new Bi(ms(i.values,t.values,r))},variableAnchorOffsetCollection:function(i,t,r){let s=i.values,l=t.values;if(s.length!==l.length)throw new Gt(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${t.toString()}`);let u=[];for(let d=0;d<s.length;d+=2){if(s[d]!==l[d])throw new Gt(`Cannot interpolate values containing mismatched anchors. from[${d}]: ${s[d]}, to[${d}]: ${l[d]}`);u.push(s[d]);let[f,g]=s[d+1],[x,v]=l[d+1];u.push([nn(f,x,r),nn(g,v,r)])}return new Zi(u)}};class Pi{constructor(t,r,s,l,u){this.type=t,this.operator=r,this.interpolation=s,this.input=l,this.labels=[],this.outputs=[];for(let[d,f]of u)this.labels.push(d),this.outputs.push(f)}static interpolationFactor(t,r,s,l){let u=0;if(t.name==="exponential")u=Zs(r,t.base,s,l);else if(t.name==="linear")u=Zs(r,1,s,l);else if(t.name==="cubic-bezier"){let d=t.controlPoints;u=new pc(d[0],d[1],d[2],d[3]).solve(Zs(r,1,s,l))}return u}static parse(t,r){let[s,l,u,...d]=t;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"){let 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);{let 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(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(u=r.parse(u,2,ve),!u)return null;let f=[],g=null;s==="interpolate-hcl"||s==="interpolate-lab"?g=Ii:r.expectedType&&r.expectedType.kind!=="value"&&(g=r.expectedType);for(let x=0;x<d.length;x+=2){let v=d[x],w=d[x+1],C=x+3,A=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.',C);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.',C);let k=r.parse(w,A,g);if(!k)return null;g=g||k.type,f.push([v,k])}return te(g,ve)||te(g,Ii)||te(g,$r)||te(g,U)||te(g,M(ve))?new Pi(g,s,l,u,f):r.error(`Type ${P(g)} is not interpolatable.`)}evaluate(t){let r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);let l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);let u=r.length;if(l>=r[u-1])return s[u-1].evaluate(t);let d=qs(r,l),f=Pi.interpolationFactor(this.interpolation,l,r[d],r[d+1]),g=s[d].evaluate(t),x=s[d+1].evaluate(t);switch(this.operator){case"interpolate":return Ci[this.type.kind](g,x,f);case"interpolate-hcl":return Ci.color(g,x,f,"hcl");case"interpolate-lab":return Ci.color(g,x,f,"lab")}}eachChild(t){t(this.input);for(let r of this.outputs)t(r)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Zs(i,t,r,s){let l=s-r,u=i-r;return l===0?0:t===1?u/l:(Math.pow(t,u)-1)/(Math.pow(t,l)-1)}class Gs{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expectected at least one argument.");let s=null,l=r.expectedType;l&&l.kind!=="value"&&(s=l);let u=[];for(let f of t.slice(1)){let g=r.parse(f,1+u.length,s,void 0,{typeAnnotation:"omit"});if(!g)return null;s=s||g.type,u.push(g)}if(!s)throw new Error("No output type");let d=l&&u.some((f=>N(l,f.type)));return new Gs(d?Xe:s,u)}evaluate(t){let r,s=null,l=0;for(let u of this.args)if(l++,s=u.evaluate(t),s&&s instanceof Fi&&!s.available&&(r||(r=s.name),s=null,l===this.args.length&&(s=r)),s!==null)break;return s}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function Hs(i,t){return i==="=="||i==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function el(i,t,r,s){return s.compare(t,r)===0}function Pn(i,t,r){let s=i!=="=="&&i!=="!=";return class Cd{constructor(u,d,f){this.type=qe,this.lhs=u,this.rhs=d,this.collator=f,this.hasUntypedArgument=u.type.kind==="value"||d.type.kind==="value"}static parse(u,d){if(u.length!==3&&u.length!==4)return d.error("Expected two or three arguments.");let f=u[0],g=d.parse(u[1],1,Xe);if(!g)return null;if(!Hs(f,g.type))return d.concat(1).error(`"${f}" comparisons are not supported for type '${P(g.type)}'.`);let x=d.parse(u[2],2,Xe);if(!x)return null;if(!Hs(f,x.type))return d.concat(2).error(`"${f}" comparisons are not supported for type '${P(x.type)}'.`);if(g.type.kind!==x.type.kind&&g.type.kind!=="value"&&x.type.kind!=="value")return d.error(`Cannot compare types '${P(g.type)}' and '${P(x.type)}'.`);s&&(g.type.kind==="value"&&x.type.kind!=="value"?g=new sr(x.type,[g]):g.type.kind!=="value"&&x.type.kind==="value"&&(x=new sr(g.type,[x])));let v=null;if(u.length===4){if(g.type.kind!=="string"&&x.type.kind!=="string"&&g.type.kind!=="value"&&x.type.kind!=="value")return d.error("Cannot use collator to compare non-string types.");if(v=d.parse(u[3],3,br),!v)return null}return new Cd(g,x,v)}evaluate(u){let d=this.lhs.evaluate(u),f=this.rhs.evaluate(u);if(s&&this.hasUntypedArgument){let g=Xt(d),x=Xt(f);if(g.kind!==x.kind||g.kind!=="string"&&g.kind!=="number")throw new Gt(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${g.kind}, ${x.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){let g=Xt(d),x=Xt(f);if(g.kind!=="string"||x.kind!=="string")return t(u,d,f)}return this.collator?r(u,d,f,this.collator.evaluate(u)):t(u,d,f)}eachChild(u){u(this.lhs),u(this.rhs),this.collator&&u(this.collator)}outputDefined(){return!0}}}let fc=Pn("==",(function(i,t,r){return t===r}),el),tl=Pn("!=",(function(i,t,r){return t!==r}),(function(i,t,r,s){return!el(0,t,r,s)})),il=Pn("<",(function(i,t,r){return t<r}),(function(i,t,r,s){return s.compare(t,r)<0})),mc=Pn(">",(function(i,t,r){return t>r}),(function(i,t,r,s){return s.compare(t,r)>0})),gc=Pn("<=",(function(i,t,r){return t<=r}),(function(i,t,r,s){return s.compare(t,r)<=0})),rl=Pn(">=",(function(i,t,r){return t>=r}),(function(i,t,r,s){return s.compare(t,r)>=0}));class gs{constructor(t,r,s){this.type=br,this.locale=s,this.caseSensitive=t,this.diacriticSensitive=r}static parse(t,r){if(t.length!==2)return r.error("Expected one argument.");let s=t[1];if(typeof s!="object"||Array.isArray(s))return r.error("Collator options argument must be an object.");let l=r.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,qe);if(!l)return null;let u=r.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,qe);if(!u)return null;let d=null;return s.locale&&(d=r.parse(s.locale,1,it),!d)?null:new gs(l,u,d)}evaluate(t){return new No(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class Zo{constructor(t,r,s,l,u){this.type=it,this.number=t,this.locale=r,this.currency=s,this.minFractionDigits=l,this.maxFractionDigits=u}static parse(t,r){if(t.length!==3)return r.error("Expected two arguments.");let s=r.parse(t[1],1,ve);if(!s)return null;let l=t[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let u=null;if(l.locale&&(u=r.parse(l.locale,1,it),!u))return null;let d=null;if(l.currency&&(d=r.parse(l.currency,1,it),!d))return null;let f=null;if(l["min-fraction-digits"]&&(f=r.parse(l["min-fraction-digits"],1,ve),!f))return null;let g=null;return l["max-fraction-digits"]&&(g=r.parse(l["max-fraction-digits"],1,ve),!g)?null:new Zo(s,u,d,f,g)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class Ws{constructor(t){this.type=zr,this.sections=t}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s=t[1];if(!Array.isArray(s)&&typeof s=="object")return r.error("First argument must be an image or text section.");let l=[],u=!1;for(let d=1;d<=t.length-1;++d){let f=t[d];if(u&&typeof f=="object"&&!Array.isArray(f)){u=!1;let g=null;if(f["font-scale"]&&(g=r.parse(f["font-scale"],1,ve),!g))return null;let x=null;if(f["text-font"]&&(x=r.parse(f["text-font"],1,M(it)),!x))return null;let v=null;if(f["text-color"]&&(v=r.parse(f["text-color"],1,Ii),!v))return null;let w=l[l.length-1];w.scale=g,w.font=x,w.textColor=v}else{let g=r.parse(t[d],1,Xe);if(!g)return null;let x=g.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");u=!0,l.push({content:g,scale:null,font:null,textColor:null})}}return new Ws(l)}evaluate(t){return new Ri(this.sections.map((r=>{let s=r.content.evaluate(t);return Xt(s)===wr?new Vo("",s,null,null,null):new Vo(ps(s),null,r.scale?r.scale.evaluate(t):null,r.font?r.font.evaluate(t).join(","):null,r.textColor?r.textColor.evaluate(t):null)})))}eachChild(t){for(let r of this.sections)t(r.content),r.scale&&t(r.scale),r.font&&t(r.font),r.textColor&&t(r.textColor)}outputDefined(){return!1}}class Go{constructor(t){this.type=wr,this.input=t}static parse(t,r){if(t.length!==2)return r.error("Expected two arguments.");let s=r.parse(t[1],1,it);return s?new Go(s):r.error("No image name provided.")}evaluate(t){let r=this.input.evaluate(t),s=Fi.fromString(r);return s&&t.availableImages&&(s.available=t.availableImages.indexOf(r)>-1),s}eachChild(t){t(this.input)}outputDefined(){return!1}}class Ho{constructor(t){this.type=ve,this.input=t}static parse(t,r){if(t.length!==2)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);let s=r.parse(t[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${P(s.type)} instead.`):new Ho(s):null}evaluate(t){let r=this.input.evaluate(t);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new Gt(`Expected value to be of type string or array, but found ${P(Xt(r))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}let Sr=8192;function _c(i,t){let r=(180+i[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,l=Math.pow(2,t.z);return[Math.round(r*l*Sr),Math.round(s*l*Sr)]}function Wo(i,t){let r=Math.pow(2,t.z);return[(l=(i[0]/Sr+t.x)/r,360*l-180),(s=(i[1]/Sr+t.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,l}function sn(i,t){i[0]=Math.min(i[0],t[0]),i[1]=Math.min(i[1],t[1]),i[2]=Math.max(i[2],t[0]),i[3]=Math.max(i[3],t[1])}function Zr(i,t){return!(i[0]<=t[0]||i[2]>=t[2]||i[1]<=t[1]||i[3]>=t[3])}function yt(i,t,r){let s=i[0]-t[0],l=i[1]-t[1],u=i[0]-r[0],d=i[1]-r[1];return s*d-u*l==0&&s*u<=0&&l*d<=0}function Xs(i,t,r,s){return(l=[s[0]-r[0],s[1]-r[1]])[0]*(u=[t[0]-i[0],t[1]-i[1]])[1]-l[1]*u[0]!=0&&!(!sl(i,t,r,s)||!sl(r,s,i,t));var l,u}function yc(i,t,r){for(let s of r)for(let l=0;l<s.length-1;++l)if(Xs(i,t,s[l],s[l+1]))return!0;return!1}function Mn(i,t,r=!1){let s=!1;for(let f of t)for(let g=0;g<f.length-1;g++){if(yt(i,f[g],f[g+1]))return r;(u=f[g])[1]>(l=i)[1]!=(d=f[g+1])[1]>l[1]&&l[0]<(d[0]-u[0])*(l[1]-u[1])/(d[1]-u[1])+u[0]&&(s=!s)}var l,u,d;return s}function xc(i,t){for(let r of t)if(Mn(i,r))return!0;return!1}function nl(i,t){for(let r of i)if(!Mn(r,t))return!1;for(let r=0;r<i.length-1;++r)if(yc(i[r],i[r+1],t))return!1;return!0}function vc(i,t){for(let r of t)if(nl(i,r))return!0;return!1}function sl(i,t,r,s){let l=s[0]-r[0],u=s[1]-r[1],d=(i[0]-r[0])*u-l*(i[1]-r[1]),f=(t[0]-r[0])*u-l*(t[1]-r[1]);return d>0&&f<0||d<0&&f>0}function Xo(i,t,r){let s=[];for(let l=0;l<i.length;l++){let u=[];for(let d=0;d<i[l].length;d++){let f=_c(i[l][d],r);sn(t,f),u.push(f)}s.push(u)}return s}function ol(i,t,r){let s=[];for(let l=0;l<i.length;l++){let u=Xo(i[l],t,r);s.push(u)}return s}function al(i,t,r,s){if(i[0]<r[0]||i[0]>r[2]){let l=.5*s,u=i[0]-r[0]>l?-s:r[0]-i[0]>l?s:0;u===0&&(u=i[0]-r[2]>l?-s:r[2]-i[0]>l?s:0),i[0]+=u}sn(t,i)}function ll(i,t,r,s){let l=Math.pow(2,s.z)*Sr,u=[s.x*Sr,s.y*Sr],d=[];for(let f of i)for(let g of f){let x=[g.x+u[0],g.y+u[1]];al(x,t,r,l),d.push(x)}return d}function cl(i,t,r,s){let l=Math.pow(2,s.z)*Sr,u=[s.x*Sr,s.y*Sr],d=[];for(let g of i){let x=[];for(let v of g){let w=[v.x+u[0],v.y+u[1]];sn(t,w),x.push(w)}d.push(x)}if(t[2]-t[0]<=l/2){(f=t)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(let g of d)for(let x of g)al(x,t,r,l)}var f;return d}class on{constructor(t,r){this.type=qe,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(tn(t[1])){let s=t[1];if(s.type==="FeatureCollection"){let l=[];for(let u of s.features){let{type:d,coordinates:f}=u.geometry;d==="Polygon"&&l.push(f),d==="MultiPolygon"&&l.push(...f)}if(l.length)return new on(s,{type:"MultiPolygon",coordinates:l})}else if(s.type==="Feature"){let l=s.geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new on(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new on(s,s)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return(function(r,s){let l=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(s.type==="Polygon"){let f=Xo(s.coordinates,u,d),g=ll(r.geometry(),l,u,d);if(!Zr(l,u))return!1;for(let x of g)if(!Mn(x,f))return!1}if(s.type==="MultiPolygon"){let f=ol(s.coordinates,u,d),g=ll(r.geometry(),l,u,d);if(!Zr(l,u))return!1;for(let x of g)if(!xc(x,f))return!1}return!0})(t,this.geometries);if(t.geometryType()==="LineString")return(function(r,s){let l=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(s.type==="Polygon"){let f=Xo(s.coordinates,u,d),g=cl(r.geometry(),l,u,d);if(!Zr(l,u))return!1;for(let x of g)if(!nl(x,f))return!1}if(s.type==="MultiPolygon"){let f=ol(s.coordinates,u,d),g=cl(r.geometry(),l,u,d);if(!Zr(l,u))return!1;for(let x of g)if(!vc(x,f))return!1}return!0})(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let hl=class{constructor(i=[],t=((r,s)=>r<s?-1:r>s?1:0)){if(this.data=i,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(i){this.data.push(i),this._up(this.length++)}pop(){if(this.length===0)return;let i=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),i}peek(){return this.data[0]}_up(i){let{data:t,compare:r}=this,s=t[i];for(;i>0;){let l=i-1>>1,u=t[l];if(r(s,u)>=0)break;t[i]=u,i=l}t[i]=s}_down(i){let{data:t,compare:r}=this,s=this.length>>1,l=t[i];for(;i<s;){let u=1+(i<<1),d=u+1;if(d<this.length&&r(t[d],t[u])<0&&(u=d),r(t[u],l)>=0)break;t[i]=t[u],i=u}t[i]=l}};function bc(i,t,r,s,l){ul(i,t,r,s||i.length-1,l||wc)}function ul(i,t,r,s,l){for(;s>r;){if(s-r>600){var u=s-r+1,d=t-r+1,f=Math.log(u),g=.5*Math.exp(2*f/3),x=.5*Math.sqrt(f*g*(u-g)/u)*(d-u/2<0?-1:1);ul(i,t,Math.max(r,Math.floor(t-d*g/u+x)),Math.min(s,Math.floor(t+(u-d)*g/u+x)),l)}var v=i[t],w=r,C=s;for(_s(i,r,t),l(i[s],v)>0&&_s(i,r,s);w<C;){for(_s(i,w,C),w++,C--;l(i[w],v)<0;)w++;for(;l(i[C],v)>0;)C--}l(i[r],v)===0?_s(i,r,C):_s(i,++C,s),C<=t&&(r=C+1),t<=C&&(s=C-1)}}function _s(i,t,r){var s=i[t];i[t]=i[r],i[r]=s}function wc(i,t){return i<t?-1:i>t?1:0}function Ks(i,t){if(i.length<=1)return[i];let r=[],s,l;for(let u of i){let d=Tc(u);d!==0&&(u.area=Math.abs(d),l===void 0&&(l=d<0),l===d<0?(s&&r.push(s),s=[u]):s.push(u))}if(s&&r.push(s),t>1)for(let u=0;u<r.length;u++)r[u].length<=t||(bc(r[u],t,1,r[u].length-1,Sc),r[u]=r[u].slice(0,t));return r}function Sc(i,t){return t.area-i.area}function Tc(i){let t=0;for(let r,s,l=0,u=i.length,d=u-1;l<u;d=l++)r=i[l],s=i[d],t+=(s.x-r.x)*(r.y+s.y);return t}let dl=1/298.257223563,pl=dl*(2-dl),fl=Math.PI/180;class Ko{constructor(t){let r=6378.137*fl*1e3,s=Math.cos(t*fl),l=1/(1-pl*(1-s*s)),u=Math.sqrt(l);this.kx=r*u*s,this.ky=r*u*l*(1-pl)}distance(t,r){let s=this.wrap(t[0]-r[0])*this.kx,l=(t[1]-r[1])*this.ky;return Math.sqrt(s*s+l*l)}pointOnLine(t,r){let s,l,u,d,f=1/0;for(let g=0;g<t.length-1;g++){let x=t[g][0],v=t[g][1],w=this.wrap(t[g+1][0]-x)*this.kx,C=(t[g+1][1]-v)*this.ky,A=0;w===0&&C===0||(A=(this.wrap(r[0]-x)*this.kx*w+(r[1]-v)*this.ky*C)/(w*w+C*C),A>1?(x=t[g+1][0],v=t[g+1][1]):A>0&&(x+=w/this.kx*A,v+=C/this.ky*A)),w=this.wrap(r[0]-x)*this.kx,C=(r[1]-v)*this.ky;let k=w*w+C*C;k<f&&(f=k,s=x,l=v,u=g,d=A)}return{point:[s,l],index:u,t:Math.max(0,Math.min(1,d))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function ml(i,t){return t[0]-i[0]}function Js(i){return i[1]-i[0]+1}function Lr(i,t){return i[1]>=i[0]&&i[1]<t}function Jo(i,t){if(i[0]>i[1])return[null,null];let r=Js(i);if(t){if(r===2)return[i,null];let l=Math.floor(r/2);return[[i[0],i[0]+l],[i[0]+l,i[1]]]}if(r===1)return[i,null];let s=Math.floor(r/2)-1;return[[i[0],i[0]+s],[i[0]+s+1,i[1]]]}function Yo(i,t){if(!Lr(t,i.length))return[1/0,1/0,-1/0,-1/0];let r=[1/0,1/0,-1/0,-1/0];for(let s=t[0];s<=t[1];++s)sn(r,i[s]);return r}function Qo(i){let t=[1/0,1/0,-1/0,-1/0];for(let r of i)for(let s of r)sn(t,s);return t}function Ys(i){return i[0]!==-1/0&&i[1]!==-1/0&&i[2]!==1/0&&i[3]!==1/0}function ea(i,t,r){if(!Ys(i)||!Ys(t))return NaN;let s=0,l=0;return i[2]<t[0]&&(s=t[0]-i[2]),i[0]>t[2]&&(s=i[0]-t[2]),i[1]>t[3]&&(l=i[1]-t[3]),i[3]<t[1]&&(l=t[1]-i[3]),r.distance([0,0],[s,l])}function an(i,t,r){let s=r.pointOnLine(t,i);return r.distance(i,s.point)}function ta(i,t,r,s,l){let u=Math.min(an(i,[r,s],l),an(t,[r,s],l)),d=Math.min(an(r,[i,t],l),an(s,[i,t],l));return Math.min(u,d)}function Ic(i,t,r,s,l){if(!Lr(t,i.length)||!Lr(s,r.length))return 1/0;let u=1/0;for(let d=t[0];d<t[1];++d){let f=i[d],g=i[d+1];for(let x=s[0];x<s[1];++x){let v=r[x],w=r[x+1];if(Xs(f,g,v,w))return 0;u=Math.min(u,ta(f,g,v,w,l))}}return u}function Ut(i,t,r,s,l){if(!Lr(t,i.length)||!Lr(s,r.length))return NaN;let u=1/0;for(let d=t[0];d<=t[1];++d)for(let f=s[0];f<=s[1];++f)if(u=Math.min(u,l.distance(i[d],r[f])),u===0)return u;return u}function Cc(i,t,r){if(Mn(i,t,!0))return 0;let s=1/0;for(let l of t){let u=l[0],d=l[l.length-1];if(u!==d&&(s=Math.min(s,an(i,[d,u],r)),s===0))return s;let f=r.pointOnLine(l,i);if(s=Math.min(s,r.distance(i,f.point)),s===0)return s}return s}function nt(i,t,r,s){if(!Lr(t,i.length))return NaN;for(let u=t[0];u<=t[1];++u)if(Mn(i[u],r,!0))return 0;let l=1/0;for(let u=t[0];u<t[1];++u){let d=i[u],f=i[u+1];for(let g of r)for(let x=0,v=g.length,w=v-1;x<v;w=x++){let C=g[w],A=g[x];if(Xs(d,f,C,A))return 0;l=Math.min(l,ta(d,f,C,A,s))}}return l}function Qs(i,t){for(let r of i)for(let s of r)if(Mn(s,t,!0))return!0;return!1}function It(i,t,r,s=1/0){let l=Qo(i),u=Qo(t);if(s!==1/0&&ea(l,u,r)>=s)return s;if(Zr(l,u)){if(Qs(i,t))return 0}else if(Qs(t,i))return 0;let d=1/0;for(let f of i)for(let g=0,x=f.length,v=x-1;g<x;v=g++){let w=f[v],C=f[g];for(let A of t)for(let k=0,z=A.length,O=z-1;k<z;O=k++){let j=A[O],ie=A[k];if(Xs(w,C,j,ie))return 0;d=Math.min(d,ta(w,C,j,ie,r))}}return d}function bt(i,t,r,s,l,u){if(!u)return;let d=ea(Yo(s,u),l,r);d<t&&i.push([d,u,[0,0]])}function ln(i,t,r,s,l,u,d){if(!u||!d)return;let f=ea(Yo(s,u),Yo(l,d),r);f<t&&i.push([f,u,d])}function ys(i,t,r,s,l=1/0){let u=Math.min(s.distance(i[0],r[0][0]),l);if(u===0)return u;let d=new hl([[0,[0,i.length-1],[0,0]]],ml),f=Qo(r);for(;d.length>0;){let g=d.pop();if(g[0]>=u)continue;let x=g[1],v=t?50:100;if(Js(x)<=v){if(!Lr(x,i.length))return NaN;if(t){let w=nt(i,x,r,s);if(isNaN(w)||w===0)return w;u=Math.min(u,w)}else for(let w=x[0];w<=x[1];++w){let C=Cc(i[w],r,s);if(u=Math.min(u,C),u===0)return 0}}else{let w=Jo(x,t);bt(d,u,s,i,f,w[0]),bt(d,u,s,i,f,w[1])}}return u}function xs(i,t,r,s,l,u=1/0){let d=Math.min(u,l.distance(i[0],r[0]));if(d===0)return d;let f=new hl([[0,[0,i.length-1],[0,r.length-1]]],ml);for(;f.length>0;){let g=f.pop();if(g[0]>=d)continue;let x=g[1],v=g[2],w=t?50:100,C=s?50:100;if(Js(x)<=w&&Js(v)<=C){if(!Lr(x,i.length)&&Lr(v,r.length))return NaN;let A;if(t&&s)A=Ic(i,x,r,v,l),d=Math.min(d,A);else if(t&&!s){let k=i.slice(x[0],x[1]+1);for(let z=v[0];z<=v[1];++z)if(A=an(r[z],k,l),d=Math.min(d,A),d===0)return d}else if(!t&&s){let k=r.slice(v[0],v[1]+1);for(let z=x[0];z<=x[1];++z)if(A=an(i[z],k,l),d=Math.min(d,A),d===0)return d}else A=Ut(i,x,r,v,l),d=Math.min(d,A)}else{let A=Jo(x,t),k=Jo(v,s);ln(f,d,l,i,r,A[0],k[0]),ln(f,d,l,i,r,A[0],k[1]),ln(f,d,l,i,r,A[1],k[0]),ln(f,d,l,i,r,A[1],k[1])}}return d}function ia(i){return i.type==="MultiPolygon"?i.coordinates.map((t=>({type:"Polygon",coordinates:t}))):i.type==="MultiLineString"?i.coordinates.map((t=>({type:"LineString",coordinates:t}))):i.type==="MultiPoint"?i.coordinates.map((t=>({type:"Point",coordinates:t}))):[i]}class cn{constructor(t,r){this.type=ve,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(tn(t[1])){let s=t[1];if(s.type==="FeatureCollection")return new cn(s,s.features.map((l=>ia(l.geometry))).flat());if(s.type==="Feature")return new cn(s,ia(s.geometry));if("type"in s&&"coordinates"in s)return new cn(s,ia(s))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return(function(r,s){let l=r.geometry(),u=l.flat().map((g=>Wo([g.x,g.y],r.canonical)));if(l.length===0)return NaN;let d=new Ko(u[0][1]),f=1/0;for(let g of s){switch(g.type){case"Point":f=Math.min(f,xs(u,!1,[g.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,xs(u,!1,g.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,ys(u,!1,g.coordinates,d,f))}if(f===0)return f}return f})(t,this.geometries);if(t.geometryType()==="LineString")return(function(r,s){let l=r.geometry(),u=l.flat().map((g=>Wo([g.x,g.y],r.canonical)));if(l.length===0)return NaN;let d=new Ko(u[0][1]),f=1/0;for(let g of s){switch(g.type){case"Point":f=Math.min(f,xs(u,!0,[g.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,xs(u,!0,g.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,ys(u,!0,g.coordinates,d,f))}if(f===0)return f}return f})(t,this.geometries);if(t.geometryType()==="Polygon")return(function(r,s){let l=r.geometry();if(l.length===0||l[0].length===0)return NaN;let u=Ks(l,0).map((g=>g.map((x=>x.map((v=>Wo([v.x,v.y],r.canonical))))))),d=new Ko(u[0][0][0][1]),f=1/0;for(let g of s)for(let x of u){switch(g.type){case"Point":f=Math.min(f,ys([g.coordinates],!1,x,d,f));break;case"LineString":f=Math.min(f,ys(g.coordinates,!0,x,d,f));break;case"Polygon":f=Math.min(f,It(x,g.coordinates,d,f))}if(f===0)return f}return f})(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}let An={"==":fc,"!=":tl,">":mc,"<":il,">=":rl,"<=":gc,array:sr,at:jo,boolean:sr,case:$s,coalesce:Gs,collator:gs,format:Ws,image:Go,in:$o,"index-of":In,interpolate:Pi,"interpolate-hcl":Pi,"interpolate-lab":Pi,length:Ho,let:qr,literal:nr,match:qo,number:sr,"number-format":Zo,object:sr,slice:fs,step:Cn,string:sr,"to-boolean":or,"to-color":or,"to-number":or,"to-string":or,var:gt,within:on,distance:cn};class Gi{constructor(t,r,s,l){this.name=t,this.type=r,this._evaluate=s,this.args=l}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,r){let s=t[0],l=Gi.definitions[s];if(!l)return r.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);let u=Array.isArray(l)?l[0]:l.type,d=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,f=d.filter((([x])=>!Array.isArray(x)||x.length===t.length-1)),g=null;for(let[x,v]of f){g=new rn(r.registry,vs,r.path,null,r.scope);let w=[],C=!1;for(let A=1;A<t.length;A++){let k=t[A],z=Array.isArray(x)?x[A-1]:x.type,O=g.parse(k,1+w.length,z);if(!O){C=!0;break}w.push(O)}if(!C)if(Array.isArray(x)&&x.length!==w.length)g.error(`Expected ${x.length} arguments, but found ${w.length} instead.`);else{for(let A=0;A<w.length;A++){let k=Array.isArray(x)?x[A]:x.type,z=w[A];g.concat(A+1).checkSubtype(k,z.type)}if(g.errors.length===0)return new Gi(s,u,v,w)}}if(f.length===1)r.errors.push(...g.errors);else{let x=(f.length?f:d).map((([w])=>{return C=w,Array.isArray(C)?`(${C.map(P).join(", ")})`:`(${P(C.type)}...)`;var C})).join(" | "),v=[];for(let w=1;w<t.length;w++){let C=r.parse(t[w],1+v.length);if(!C)return null;v.push(P(C.type))}r.error(`Expected arguments of type ${x}, but found (${v.join(", ")}) instead.`)}return null}static register(t,r){Gi.definitions=r;for(let s in r)t[s]=Gi}}function ra(i,[t,r,s,l]){t=t.evaluate(i),r=r.evaluate(i),s=s.evaluate(i);let u=l?l.evaluate(i):1,d=Tn(t,r,s,u);if(d)throw new Gt(d);return new vt(t/255,r/255,s/255,u,!1)}function na(i,t){return i in t}function sa(i,t){let r=t[i];return r===void 0?null:r}function hn(i){return{type:i}}function vs(i){if(i instanceof gt)return vs(i.boundExpression);if(i instanceof Gi&&i.name==="error"||i instanceof gs||i instanceof on||i instanceof cn)return!1;let t=i instanceof or||i instanceof sr,r=!0;return i.eachChild((s=>{r=t?r&&vs(s):r&&s instanceof nr})),!!r&&bs(i)&&ws(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function bs(i){if(i instanceof Gi&&(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 on||i instanceof cn)return!1;let t=!0;return i.eachChild((r=>{t&&!bs(r)&&(t=!1)})),t}function En(i){if(i instanceof Gi&&i.name==="feature-state")return!1;let t=!0;return i.eachChild((r=>{t&&!En(r)&&(t=!1)})),t}function ws(i,t){if(i instanceof Gi&&t.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild((s=>{r&&!ws(s,t)&&(r=!1)})),r}function eo(i){return{result:"success",value:i}}function kn(i){return{result:"error",value:i}}function zn(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function gl(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function oa(i){return!!i.expression&&i.expression.interpolated}function pt(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function to(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function Pc(i){return i}function _l(i,t){let r=t.type==="color",s=i.stops&&typeof i.stops[0][0]=="object",l=s||!(s||i.property!==void 0),u=i.type||(oa(t)?"exponential":"interval");if(r||t.type==="padding"){let v=r?vt.parse:Bi.parse;(i=xr({},i)).stops&&(i.stops=i.stops.map((w=>[w[0],v(w[1])]))),i.default=v(i.default?i.default:t.default)}if(i.colorSpace&&(d=i.colorSpace)!=="rgb"&&d!=="hcl"&&d!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var d;let f,g,x;if(u==="exponential")f=xl;else if(u==="interval")f=io;else if(u==="categorical"){f=yl,g=Object.create(null);for(let v of i.stops)g[v[0]]=v[1];x=typeof i.stops[0][0]}else{if(u!=="identity")throw new Error(`Unknown function type "${u}"`);f=vl}if(s){let v={},w=[];for(let k=0;k<i.stops.length;k++){let z=i.stops[k],O=z[0].zoom;v[O]===void 0&&(v[O]={zoom:O,type:i.type,property:i.property,default:i.default,stops:[]},w.push(O)),v[O].stops.push([z[0].value,z[1]])}let C=[];for(let k of w)C.push([v[k].zoom,_l(v[k],t)]);let A={name:"linear"};return{kind:"composite",interpolationType:A,interpolationFactor:Pi.interpolationFactor.bind(void 0,A),zoomStops:C.map((k=>k[0])),evaluate:({zoom:k},z)=>xl({stops:C,base:i.base},t,k).evaluate(k,z)}}if(l){let v=u==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:Pi.interpolationFactor.bind(void 0,v),zoomStops:i.stops.map((w=>w[0])),evaluate:({zoom:w})=>f(i,t,w,g,x)}}return{kind:"source",evaluate(v,w){let C=w&&w.properties?w.properties[i.property]:void 0;return C===void 0?Ln(i.default,t.default):f(i,t,C,g,x)}}}function Ln(i,t,r){return i!==void 0?i:t!==void 0?t:r!==void 0?r:void 0}function yl(i,t,r,s,l){return Ln(typeof r===l?s[r]:void 0,i.default,t.default)}function io(i,t,r){if(pt(r)!=="number")return Ln(i.default,t.default);let s=i.stops.length;if(s===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[s-1][0])return i.stops[s-1][1];let l=qs(i.stops.map((u=>u[0])),r);return i.stops[l][1]}function xl(i,t,r){let s=i.base!==void 0?i.base:1;if(pt(r)!=="number")return Ln(i.default,t.default);let 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];let u=qs(i.stops.map((v=>v[0])),r),d=(function(v,w,C,A){let k=A-C,z=v-C;return k===0?0:w===1?z/k:(Math.pow(w,z)-1)/(Math.pow(w,k)-1)})(r,s,i.stops[u][0],i.stops[u+1][0]),f=i.stops[u][1],g=i.stops[u+1][1],x=Ci[t.type]||Pc;return typeof f.evaluate=="function"?{evaluate(...v){let w=f.evaluate.apply(void 0,v),C=g.evaluate.apply(void 0,v);if(w!==void 0&&C!==void 0)return x(w,C,d,i.colorSpace)}}:x(f,g,d,i.colorSpace)}function vl(i,t,r){switch(t.type){case"color":r=vt.parse(r);break;case"formatted":r=Ri.fromString(r.toString());break;case"resolvedImage":r=Fi.fromString(r.toString());break;case"padding":r=Bi.parse(r);break;default:pt(r)===t.type||t.type==="enum"&&t.values[r]||(r=void 0)}return Ln(r,i.default,t.default)}Gi.register(An,{error:[{kind:"error"},[it],(i,[t])=>{throw new Gt(t.evaluate(i))}],typeof:[it,[Xe],(i,[t])=>P(Xt(t.evaluate(i)))],"to-rgba":[M(ve,4),[Ii],(i,[t])=>{let[r,s,l,u]=t.evaluate(i).rgb;return[255*r,255*s,255*l,u]}],rgb:[Ii,[ve,ve,ve],ra],rgba:[Ii,[ve,ve,ve,ve],ra],has:{type:qe,overloads:[[[it],(i,[t])=>na(t.evaluate(i),i.properties())],[[it,rr],(i,[t,r])=>na(t.evaluate(i),r.evaluate(i))]]},get:{type:Xe,overloads:[[[it],(i,[t])=>sa(t.evaluate(i),i.properties())],[[it,rr],(i,[t,r])=>sa(t.evaluate(i),r.evaluate(i))]]},"feature-state":[Xe,[it],(i,[t])=>sa(t.evaluate(i),i.featureState||{})],properties:[rr,[],i=>i.properties()],"geometry-type":[it,[],i=>i.geometryType()],id:[Xe,[],i=>i.id()],zoom:[ve,[],i=>i.globals.zoom],"heatmap-density":[ve,[],i=>i.globals.heatmapDensity||0],"line-progress":[ve,[],i=>i.globals.lineProgress||0],accumulated:[Xe,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[ve,hn(ve),(i,t)=>{let r=0;for(let s of t)r+=s.evaluate(i);return r}],"*":[ve,hn(ve),(i,t)=>{let r=1;for(let s of t)r*=s.evaluate(i);return r}],"-":{type:ve,overloads:[[[ve,ve],(i,[t,r])=>t.evaluate(i)-r.evaluate(i)],[[ve],(i,[t])=>-t.evaluate(i)]]},"/":[ve,[ve,ve],(i,[t,r])=>t.evaluate(i)/r.evaluate(i)],"%":[ve,[ve,ve],(i,[t,r])=>t.evaluate(i)%r.evaluate(i)],ln2:[ve,[],()=>Math.LN2],pi:[ve,[],()=>Math.PI],e:[ve,[],()=>Math.E],"^":[ve,[ve,ve],(i,[t,r])=>Math.pow(t.evaluate(i),r.evaluate(i))],sqrt:[ve,[ve],(i,[t])=>Math.sqrt(t.evaluate(i))],log10:[ve,[ve],(i,[t])=>Math.log(t.evaluate(i))/Math.LN10],ln:[ve,[ve],(i,[t])=>Math.log(t.evaluate(i))],log2:[ve,[ve],(i,[t])=>Math.log(t.evaluate(i))/Math.LN2],sin:[ve,[ve],(i,[t])=>Math.sin(t.evaluate(i))],cos:[ve,[ve],(i,[t])=>Math.cos(t.evaluate(i))],tan:[ve,[ve],(i,[t])=>Math.tan(t.evaluate(i))],asin:[ve,[ve],(i,[t])=>Math.asin(t.evaluate(i))],acos:[ve,[ve],(i,[t])=>Math.acos(t.evaluate(i))],atan:[ve,[ve],(i,[t])=>Math.atan(t.evaluate(i))],min:[ve,hn(ve),(i,t)=>Math.min(...t.map((r=>r.evaluate(i))))],max:[ve,hn(ve),(i,t)=>Math.max(...t.map((r=>r.evaluate(i))))],abs:[ve,[ve],(i,[t])=>Math.abs(t.evaluate(i))],round:[ve,[ve],(i,[t])=>{let r=t.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[ve,[ve],(i,[t])=>Math.floor(t.evaluate(i))],ceil:[ve,[ve],(i,[t])=>Math.ceil(t.evaluate(i))],"filter-==":[qe,[it,Xe],(i,[t,r])=>i.properties()[t.value]===r.value],"filter-id-==":[qe,[Xe],(i,[t])=>i.id()===t.value],"filter-type-==":[qe,[it],(i,[t])=>i.geometryType()===t.value],"filter-<":[qe,[it,Xe],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s<l}],"filter-id-<":[qe,[Xe],(i,[t])=>{let r=i.id(),s=t.value;return typeof r==typeof s&&r<s}],"filter->":[qe,[it,Xe],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s>l}],"filter-id->":[qe,[Xe],(i,[t])=>{let r=i.id(),s=t.value;return typeof r==typeof s&&r>s}],"filter-<=":[qe,[it,Xe],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s<=l}],"filter-id-<=":[qe,[Xe],(i,[t])=>{let r=i.id(),s=t.value;return typeof r==typeof s&&r<=s}],"filter->=":[qe,[it,Xe],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s>=l}],"filter-id->=":[qe,[Xe],(i,[t])=>{let r=i.id(),s=t.value;return typeof r==typeof s&&r>=s}],"filter-has":[qe,[Xe],(i,[t])=>t.value in i.properties()],"filter-has-id":[qe,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[qe,[M(it)],(i,[t])=>t.value.indexOf(i.geometryType())>=0],"filter-id-in":[qe,[M(Xe)],(i,[t])=>t.value.indexOf(i.id())>=0],"filter-in-small":[qe,[it,M(Xe)],(i,[t,r])=>r.value.indexOf(i.properties()[t.value])>=0],"filter-in-large":[qe,[it,M(Xe)],(i,[t,r])=>(function(s,l,u,d){for(;u<=d;){let f=u+d>>1;if(l[f]===s)return!0;l[f]>s?d=f-1:u=f+1}return!1})(i.properties()[t.value],r.value,0,r.value.length-1)],all:{type:qe,overloads:[[[qe,qe],(i,[t,r])=>t.evaluate(i)&&r.evaluate(i)],[hn(qe),(i,t)=>{for(let r of t)if(!r.evaluate(i))return!1;return!0}]]},any:{type:qe,overloads:[[[qe,qe],(i,[t,r])=>t.evaluate(i)||r.evaluate(i)],[hn(qe),(i,t)=>{for(let r of t)if(r.evaluate(i))return!0;return!1}]]},"!":[qe,[qe],(i,[t])=>!t.evaluate(i)],"is-supported-script":[qe,[it],(i,[t])=>{let r=i.globals&&i.globals.isSupportedScript;return!r||r(t.evaluate(i))}],upcase:[it,[it],(i,[t])=>t.evaluate(i).toUpperCase()],downcase:[it,[it],(i,[t])=>t.evaluate(i).toLowerCase()],concat:[it,hn(Xe),(i,t)=>t.map((r=>ps(r.evaluate(i)))).join("")],"resolved-locale":[it,[br],(i,[t])=>t.evaluate(i).resolvedLocale()]});class ro{constructor(t,r){var s;this.expression=t,this._warningHistory={},this._evaluator=new js,this._defaultValue=r?(s=r).type==="color"&&to(s.default)?new vt(0,0,0,0):s.type==="color"?vt.parse(s.default)||null:s.type==="padding"?Bi.parse(s.default)||null:s.type==="variableAnchorOffsetCollection"?Zi.parse(s.default)||null:s.default===void 0?null:s.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._evaluator.globals=t,this._evaluator.feature=r,this._evaluator.featureState=s,this._evaluator.canonical=l,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=d,this.expression.evaluate(this._evaluator)}evaluate(t,r,s,l,u,d){this._evaluator.globals=t,this._evaluator.feature=r||null,this._evaluator.featureState=s||null,this._evaluator.canonical=l,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=d||null;try{let 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 Gt(`Expected value to be one of ${Object.keys(this._enumValues).map((g=>JSON.stringify(g))).join(", ")}, but found ${JSON.stringify(f)} instead.`);return f}catch(f){return this._warningHistory[f.message]||(this._warningHistory[f.message]=!0,typeof console<"u"&&console.warn(f.message)),this._defaultValue}}}function no(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in An}function Dn(i,t){let r=new rn(An,vs,[],t?(function(l){let u={color:Ii,string:it,number:ve,enum:it,boolean:qe,formatted:zr,padding:$r,resolvedImage:wr,variableAnchorOffsetCollection:U};return l.type==="array"?M(u[l.value]||Xe,l.length):u[l.type]})(t):void 0),s=r.parse(i,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return s?eo(new ro(s,t)):kn(r.errors)}class Rn{constructor(t,r){this.kind=t,this._styleExpression=r,this.isStateDependent=t!=="constant"&&!En(r.expression)}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,u,d)}evaluate(t,r,s,l,u,d){return this._styleExpression.evaluate(t,r,s,l,u,d)}}class Bn{constructor(t,r,s,l){this.kind=t,this.zoomStops=s,this._styleExpression=r,this.isStateDependent=t!=="camera"&&!En(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,u,d)}evaluate(t,r,s,l,u,d){return this._styleExpression.evaluate(t,r,s,l,u,d)}interpolationFactor(t,r,s){return this.interpolationType?Pi.interpolationFactor(this.interpolationType,t,r,s):0}}function aa(i,t){let r=Dn(i,t);if(r.result==="error")return r;let s=r.value.expression,l=bs(s);if(!l&&!zn(t))return kn([new xi("","data expressions not supported")]);let u=ws(s,["zoom"]);if(!u&&!gl(t))return kn([new xi("","zoom expressions not supported")]);let d=Ss(s);return d||u?d instanceof xi?kn([d]):d instanceof Pi&&!oa(t)?kn([new xi("",'"interpolate" expressions cannot be used with this property')]):eo(d?new Bn(l?"camera":"composite",r.value,d.labels,d instanceof Pi?d.interpolation:void 0):new Rn(l?"constant":"source",r.value)):kn([new xi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Fn{constructor(t,r){this._parameters=t,this._specification=r,xr(this,_l(this._parameters,this._specification))}static deserialize(t){return new Fn(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Ss(i){let t=null;if(i instanceof qr)t=Ss(i.result);else if(i instanceof Gs){for(let r of i.args)if(t=Ss(r),t)break}else(i instanceof Cn||i instanceof Pi)&&i.input instanceof Gi&&i.input.name==="zoom"&&(t=i);return t instanceof xi||i.eachChild((r=>{let s=Ss(r);s instanceof xi?t=s:!t&&s?t=new xi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&s&&t!==s&&(t=new xi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}function so(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(let t of i.slice(1))if(!so(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}let oo={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function la(i){if(i==null)return{filter:()=>!0,needGeometry:!1};so(i)||(i=ao(i));let t=Dn(i,oo);if(t.result==="error")throw new Error(t.value.map((r=>`${r.key}: ${r.message}`)).join(", "));return{filter:(r,s,l)=>t.value.evaluate(r,s,{},l),needGeometry:bl(i)}}function Mc(i,t){return i<t?-1:i>t?1:0}function bl(i){if(!Array.isArray(i))return!1;if(i[0]==="within"||i[0]==="distance")return!0;for(let t=1;t<i.length;t++)if(bl(i[t]))return!0;return!1}function ao(i){if(!i)return!0;let t=i[0];return i.length<=1?t!=="any":t==="=="?ca(i[1],i[2],"=="):t==="!="?hi(ca(i[1],i[2],"==")):t==="<"||t===">"||t==="<="||t===">="?ca(i[1],i[2],t):t==="any"?(r=i.slice(1),["any"].concat(r.map(ao))):t==="all"?["all"].concat(i.slice(1).map(ao)):t==="none"?["all"].concat(i.slice(1).map(ao).map(hi)):t==="in"?Ts(i[1],i.slice(2)):t==="!in"?hi(Ts(i[1],i.slice(2))):t==="has"?Is(i[1]):t!=="!has"||hi(Is(i[1]));var r}function ca(i,t,r){switch(i){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,i,t]}}function Ts(i,t){if(t.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((r=>typeof r!=typeof t[0]))?["filter-in-large",i,["literal",t.sort(Mc)]]:["filter-in-small",i,["literal",t]]}}function Is(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function hi(i){return["!",i]}function un(i){let t=typeof i;if(t==="number"||t==="boolean"||t==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let l="[";for(let u of i)l+=`${un(u)},`;return`${l}]`}let r=Object.keys(i).sort(),s="{";for(let l=0;l<r.length;l++)s+=`${JSON.stringify(r[l])}:${un(i[r[l]])},`;return`${s}}`}function wl(i){let t="";for(let r of en)t+=`/${un(i[r])}`;return t}function Sl(i){let t=i.value;return t?[new ge(i.key,t,"constants have been deprecated as of v8")]:[]}function jt(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function ar(i){if(Array.isArray(i))return i.map(ar);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){let t={};for(let r in i)t[r]=ar(i[r]);return t}return jt(i)}function Oi(i){let t=i.key,r=i.value,s=i.valueSpec||{},l=i.objectElementValidators||{},u=i.style,d=i.styleSpec,f=i.validateSpec,g=[],x=pt(r);if(x!=="object")return[new ge(t,r,`object expected, ${x} found`)];for(let v in r){let w=v.split(".")[0],C=s[w]||s["*"],A;if(l[w])A=l[w];else if(s[w])A=f;else if(l["*"])A=l["*"];else{if(!s["*"]){g.push(new ge(t,r[v],`unknown property "${v}"`));continue}A=f}g=g.concat(A({key:(t&&`${t}.`)+v,value:r[v],valueSpec:C,style:u,styleSpec:d,object:r,objectKey:v,validateSpec:f},r))}for(let v in s)l[v]||s[v].required&&s[v].default===void 0&&r[v]===void 0&&g.push(new ge(t,r,`missing required property "${v}"`));return g}function Cs(i){let t=i.value,r=i.valueSpec,s=i.style,l=i.styleSpec,u=i.key,d=i.arrayElementValidator||i.validateSpec;if(pt(t)!=="array")return[new ge(u,t,`array expected, ${pt(t)} found`)];if(r.length&&t.length!==r.length)return[new ge(u,t,`array length ${r.length} expected, length ${t.length} found`)];if(r["min-length"]&&t.length<r["min-length"])return[new ge(u,t,`array length at least ${r["min-length"]} expected, length ${t.length} found`)];let f={type:r.value,values:r.values};l.$version<7&&(f.function=r.function),pt(r.value)==="object"&&(f=r.value);let g=[];for(let x=0;x<t.length;x++)g=g.concat(d({array:t,arrayIndex:x,value:t[x],valueSpec:f,validateSpec:i.validateSpec,style:s,styleSpec:l,key:`${u}[${x}]`}));return g}function ha(i){let t=i.key,r=i.value,s=i.valueSpec,l=pt(r);return l==="number"&&r!=r&&(l="NaN"),l!=="number"?[new ge(t,r,`number expected, ${l} found`)]:"minimum"in s&&r<s.minimum?[new ge(t,r,`${r} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&r>s.maximum?[new ge(t,r,`${r} is greater than the maximum value ${s.maximum}`)]:[]}function lo(i){let t=i.valueSpec,r=jt(i.value.type),s,l,u,d={},f=r!=="categorical"&&i.value.property===void 0,g=!f,x=pt(i.value.stops)==="array"&&pt(i.value.stops[0])==="array"&&pt(i.value.stops[0][0])==="object",v=Oi({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(A){if(r==="identity")return[new ge(A.key,A.value,'identity function may not have a "stops" property')];let k=[],z=A.value;return k=k.concat(Cs({key:A.key,value:z,valueSpec:A.valueSpec,validateSpec:A.validateSpec,style:A.style,styleSpec:A.styleSpec,arrayElementValidator:w})),pt(z)==="array"&&z.length===0&&k.push(new ge(A.key,z,"array must have at least one stop")),k},default:function(A){return A.validateSpec({key:A.key,value:A.value,valueSpec:t,validateSpec:A.validateSpec,style:A.style,styleSpec:A.styleSpec})}}});return r==="identity"&&f&&v.push(new ge(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||v.push(new ge(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!oa(i.valueSpec)&&v.push(new ge(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(g&&!zn(i.valueSpec)?v.push(new ge(i.key,i.value,"property functions not supported")):f&&!gl(i.valueSpec)&&v.push(new ge(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!x||i.value.property!==void 0||v.push(new ge(i.key,i.value,'"property" property is required')),v;function w(A){let k=[],z=A.value,O=A.key;if(pt(z)!=="array")return[new ge(O,z,`array expected, ${pt(z)} found`)];if(z.length!==2)return[new ge(O,z,`array length 2 expected, length ${z.length} found`)];if(x){if(pt(z[0])!=="object")return[new ge(O,z,`object expected, ${pt(z[0])} found`)];if(z[0].zoom===void 0)return[new ge(O,z,"object stop key must have zoom")];if(z[0].value===void 0)return[new ge(O,z,"object stop key must have value")];if(u&&u>jt(z[0].zoom))return[new ge(O,z[0].zoom,"stop zoom values must appear in ascending order")];jt(z[0].zoom)!==u&&(u=jt(z[0].zoom),l=void 0,d={}),k=k.concat(Oi({key:`${O}[0]`,value:z[0],valueSpec:{zoom:{}},validateSpec:A.validateSpec,style:A.style,styleSpec:A.styleSpec,objectElementValidators:{zoom:ha,value:C}}))}else k=k.concat(C({key:`${O}[0]`,value:z[0],valueSpec:{},validateSpec:A.validateSpec,style:A.style,styleSpec:A.styleSpec},z));return no(ar(z[1]))?k.concat([new ge(`${O}[1]`,z[1],"expressions are not allowed in function stops.")]):k.concat(A.validateSpec({key:`${O}[1]`,value:z[1],valueSpec:t,validateSpec:A.validateSpec,style:A.style,styleSpec:A.styleSpec}))}function C(A,k){let z=pt(A.value),O=jt(A.value),j=A.value!==null?A.value:k;if(s){if(z!==s)return[new ge(A.key,j,`${z} stop domain type must match previous stop domain type ${s}`)]}else s=z;if(z!=="number"&&z!=="string"&&z!=="boolean")return[new ge(A.key,j,"stop domain value must be a number, string, or boolean")];if(z!=="number"&&r!=="categorical"){let ie=`number expected, ${z} found`;return zn(t)&&r===void 0&&(ie+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ge(A.key,j,ie)]}return r!=="categorical"||z!=="number"||isFinite(O)&&Math.floor(O)===O?r!=="categorical"&&z==="number"&&l!==void 0&&O<l?[new ge(A.key,j,"stop domain values must appear in ascending order")]:(l=O,r==="categorical"&&O in d?[new ge(A.key,j,"stop domain values must be unique")]:(d[O]=!0,[])):[new ge(A.key,j,`integer expected, found ${O}`)]}}function On(i){let t=(i.expressionContext==="property"?aa:Dn)(ar(i.value),i.valueSpec);if(t.result==="error")return t.value.map((s=>new ge(`${i.key}${s.key}`,i.value,s.message)));let r=t.value.expression||t.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new ge(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"&&!En(r))return[new ge(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!En(r))return[new ge(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!ws(r,["zoom","feature-state"]))return[new ge(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!bs(r))return[new ge(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Dr(i){let t=i.key,r=i.value,s=i.valueSpec,l=[];return Array.isArray(s.values)?s.values.indexOf(jt(r))===-1&&l.push(new ge(t,r,`expected one of [${s.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(s.values).indexOf(jt(r))===-1&&l.push(new ge(t,r,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function ua(i){return so(ar(i.value))?On(xr({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):co(i)}function co(i){let t=i.value,r=i.key;if(pt(t)!=="array")return[new ge(r,t,`array expected, ${pt(t)} found`)];let s=i.styleSpec,l,u=[];if(t.length<1)return[new ge(r,t,"filter array must have at least 1 element")];switch(u=u.concat(Dr({key:`${r}[0]`,value:t[0],valueSpec:s.filter_operator,style:i.style,styleSpec:i.styleSpec})),jt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&jt(t[1])==="$type"&&u.push(new ge(r,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&u.push(new ge(r,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(l=pt(t[1]),l!=="string"&&u.push(new ge(`${r}[1]`,t[1],`string expected, ${l} found`)));for(let d=2;d<t.length;d++)l=pt(t[d]),jt(t[1])==="$type"?u=u.concat(Dr({key:`${r}[${d}]`,value:t[d],valueSpec:s.geometry_type,style:i.style,styleSpec:i.styleSpec})):l!=="string"&&l!=="number"&&l!=="boolean"&&u.push(new ge(`${r}[${d}]`,t[d],`string, number, or boolean expected, ${l} found`));break;case"any":case"all":case"none":for(let d=1;d<t.length;d++)u=u.concat(co({key:`${r}[${d}]`,value:t[d],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":l=pt(t[1]),t.length!==2?u.push(new ge(r,t,`filter array for "${t[0]}" operator must have 2 elements`)):l!=="string"&&u.push(new ge(`${r}[1]`,t[1],`string expected, ${l} found`))}return u}function da(i,t){let r=i.key,s=i.validateSpec,l=i.style,u=i.styleSpec,d=i.value,f=i.objectKey,g=u[`${t}_${i.layerType}`];if(!g)return[];let x=f.match(/^(.*)-transition$/);if(t==="paint"&&x&&g[x[1]]&&g[x[1]].transition)return s({key:r,value:d,valueSpec:u.transition,style:l,styleSpec:u});let v=i.valueSpec||g[f];if(!v)return[new ge(r,d,`unknown property "${f}"`)];let w;if(pt(d)==="string"&&zn(v)&&!v.tokens&&(w=/^{([^}]+)}$/.exec(d)))return[new ge(r,d,`"${f}" does not support interpolation syntax
2
- Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(w[1])} }\`.`)];let C=[];return i.layerType==="symbol"&&(f==="text-field"&&l&&!l.glyphs&&C.push(new ge(r,d,'use of "text-field" requires a style "glyphs" property')),f==="text-font"&&to(ar(d))&&jt(d.type)==="identity"&&C.push(new ge(r,d,'"text-font" does not support identity functions'))),C.concat(s({key:i.key,value:d,valueSpec:v,style:l,styleSpec:u,expressionContext:"property",propertyType:t,propertyKey:f}))}function ho(i){return da(i,"paint")}function pa(i){return da(i,"layout")}function fa(i){let t=[],r=i.value,s=i.key,l=i.style,u=i.styleSpec;r.type||r.ref||t.push(new ge(s,r,'either "type" or "ref" is required'));let d=jt(r.type),f=jt(r.ref);if(r.id){let g=jt(r.id);for(let x=0;x<i.arrayIndex;x++){let v=l.layers[x];jt(v.id)===g&&t.push(new ge(s,r.id,`duplicate layer id "${r.id}", previously used at line ${v.id.__line__}`))}}if("ref"in r){let g;["type","source","source-layer","filter","layout"].forEach((x=>{x in r&&t.push(new ge(s,r[x],`"${x}" is prohibited for ref layers`))})),l.layers.forEach((x=>{jt(x.id)===f&&(g=x)})),g?g.ref?t.push(new ge(s,r.ref,"ref cannot reference another ref layer")):d=jt(g.type):t.push(new ge(s,r.ref,`ref layer "${f}" not found`))}else if(d!=="background")if(r.source){let g=l.sources&&l.sources[r.source],x=g&&jt(g.type);g?x==="vector"&&d==="raster"?t.push(new ge(s,r.source,`layer "${r.id}" requires a raster source`)):x!=="raster-dem"&&d==="hillshade"?t.push(new ge(s,r.source,`layer "${r.id}" requires a raster-dem source`)):x==="raster"&&d!=="raster"?t.push(new ge(s,r.source,`layer "${r.id}" requires a vector source`)):x!=="vector"||r["source-layer"]?x==="raster-dem"&&d!=="hillshade"?t.push(new ge(s,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):d!=="line"||!r.paint||!r.paint["line-gradient"]||x==="geojson"&&g.lineMetrics||t.push(new ge(s,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new ge(s,r,`layer "${r.id}" must specify a "source-layer"`)):t.push(new ge(s,r.source,`source "${r.source}" not found`))}else t.push(new ge(s,r,'missing required property "source"'));return t=t.concat(Oi({key:s,value:r,valueSpec:u.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${s}.type`,value:r.type,valueSpec:u.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:ua,layout:g=>Oi({layer:r,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>pa(xr({layerType:d},x))}}),paint:g=>Oi({layer:r,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>ho(xr({layerType:d},x))}})}})),t}function dn(i){let t=i.value,r=i.key,s=pt(t);return s!=="string"?[new ge(r,t,`string expected, ${s} found`)]:[]}let uo={promoteId:function({key:i,value:t}){if(pt(t)==="string")return dn({key:i,value:t});{let r=[];for(let s in t)r.push(...dn({key:`${i}.${s}`,value:t[s]}));return r}}};function Ps(i){let t=i.value,r=i.key,s=i.styleSpec,l=i.style,u=i.validateSpec;if(!t.type)return[new ge(r,t,'"type" is required')];let d=jt(t.type),f;switch(d){case"vector":case"raster":return f=Oi({key:r,value:t,valueSpec:s[`source_${d.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:uo,validateSpec:u}),f;case"raster-dem":return f=(function(g){var x;let v=(x=g.sourceName)!==null&&x!==void 0?x:"",w=g.value,C=g.styleSpec,A=C.source_raster_dem,k=g.style,z=[],O=pt(w);if(w===void 0)return z;if(O!=="object")return z.push(new ge("source_raster_dem",w,`object expected, ${O} found`)),z;let j=jt(w.encoding)==="custom",ie=["redFactor","greenFactor","blueFactor","baseShift"],H=g.value.encoding?`"${g.value.encoding}"`:"Default";for(let ee in w)!j&&ie.includes(ee)?z.push(new ge(ee,w[ee],`In "${v}": "${ee}" is only valid when "encoding" is set to "custom". ${H} encoding found`)):A[ee]?z=z.concat(g.validateSpec({key:ee,value:w[ee],valueSpec:A[ee],validateSpec:g.validateSpec,style:k,styleSpec:C})):z.push(new ge(ee,w[ee],`unknown property "${ee}"`));return z})({sourceName:r,value:t,style:i.style,styleSpec:s,validateSpec:u}),f;case"geojson":if(f=Oi({key:r,value:t,valueSpec:s.source_geojson,style:l,styleSpec:s,validateSpec:u,objectElementValidators:uo}),t.cluster)for(let g in t.clusterProperties){let[x,v]=t.clusterProperties[g],w=typeof x=="string"?[x,["accumulated"],["get",g]]:x;f.push(...On({key:`${r}.${g}.map`,value:v,validateSpec:u,expressionContext:"cluster-map"})),f.push(...On({key:`${r}.${g}.reduce`,value:w,validateSpec:u,expressionContext:"cluster-reduce"}))}return f;case"video":return Oi({key:r,value:t,valueSpec:s.source_video,style:l,validateSpec:u,styleSpec:s});case"image":return Oi({key:r,value:t,valueSpec:s.source_image,style:l,validateSpec:u,styleSpec:s});case"canvas":return[new ge(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Dr({key:`${r}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:l,validateSpec:u,styleSpec:s})}}function ma(i){let t=i.value,r=i.styleSpec,s=r.light,l=i.style,u=[],d=pt(t);if(t===void 0)return u;if(d!=="object")return u=u.concat([new ge("light",t,`object expected, ${d} found`)]),u;for(let f in t){let g=f.match(/^(.*)-transition$/);u=u.concat(g&&s[g[1]]&&s[g[1]].transition?i.validateSpec({key:f,value:t[f],valueSpec:r.transition,validateSpec:i.validateSpec,style:l,styleSpec:r}):s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new ge(f,t[f],`unknown property "${f}"`)])}return u}function ga(i){let t=i.value,r=i.styleSpec,s=r.sky,l=i.style,u=pt(t);if(t===void 0)return[];if(u!=="object")return[new ge("sky",t,`object expected, ${u} found`)];let d=[];for(let f in t)d=d.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],style:l,styleSpec:r}):[new ge(f,t[f],`unknown property "${f}"`)]);return d}function _a(i){let t=i.value,r=i.styleSpec,s=r.terrain,l=i.style,u=[],d=pt(t);if(t===void 0)return u;if(d!=="object")return u=u.concat([new ge("terrain",t,`object expected, ${d} found`)]),u;for(let f in t)u=u.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new ge(f,t[f],`unknown property "${f}"`)]);return u}function ya(i){let t=[],r=i.value,s=i.key;if(Array.isArray(r)){let l=[],u=[];for(let d in r)r[d].id&&l.includes(r[d].id)&&t.push(new ge(s,r,`all the sprites' ids must be unique, but ${r[d].id} is duplicated`)),l.push(r[d].id),r[d].url&&u.includes(r[d].url)&&t.push(new ge(s,r,`all the sprites' URLs must be unique, but ${r[d].url} is duplicated`)),u.push(r[d].url),t=t.concat(Oi({key:`${s}[${d}]`,value:r[d],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return t}return dn({key:s,value:r})}let po={"*":()=>[],array:Cs,boolean:function(i){let t=i.value,r=i.key,s=pt(t);return s!=="boolean"?[new ge(r,t,`boolean expected, ${s} found`)]:[]},number:ha,color:function(i){let t=i.key,r=i.value,s=pt(r);return s!=="string"?[new ge(t,r,`color expected, ${s} found`)]:vt.parse(String(r))?[]:[new ge(t,r,`color expected, "${r}" found`)]},constants:Sl,enum:Dr,filter:ua,function:lo,layer:fa,object:Oi,source:Ps,light:ma,sky:ga,terrain:_a,projection:function(i){let t=i.value,r=i.styleSpec,s=r.projection,l=i.style,u=pt(t);if(t===void 0)return[];if(u!=="object")return[new ge("projection",t,`object expected, ${u} found`)];let d=[];for(let f in t)d=d.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],style:l,styleSpec:r}):[new ge(f,t[f],`unknown property "${f}"`)]);return d},string:dn,formatted:function(i){return dn(i).length===0?[]:On(i)},resolvedImage:function(i){return dn(i).length===0?[]:On(i)},padding:function(i){let t=i.key,r=i.value;if(pt(r)==="array"){if(r.length<1||r.length>4)return[new ge(t,r,`padding requires 1 to 4 values; ${r.length} values found`)];let s={type:"number"},l=[];for(let u=0;u<r.length;u++)l=l.concat(i.validateSpec({key:`${t}[${u}]`,value:r[u],validateSpec:i.validateSpec,valueSpec:s}));return l}return ha({key:t,value:r,valueSpec:{}})},variableAnchorOffsetCollection:function(i){let t=i.key,r=i.value,s=pt(r),l=i.styleSpec;if(s!=="array"||r.length<1||r.length%2!=0)return[new ge(t,r,"variableAnchorOffsetCollection requires a non-empty array of even length")];let u=[];for(let d=0;d<r.length;d+=2)u=u.concat(Dr({key:`${t}[${d}]`,value:r[d],valueSpec:l.layout_symbol["text-anchor"]})),u=u.concat(Cs({key:`${t}[${d+1}]`,value:r[d+1],valueSpec:{length:2,value:"number"},validateSpec:i.validateSpec,style:i.style,styleSpec:l}));return u},sprite:ya};function Nn(i){let t=i.value,r=i.valueSpec,s=i.styleSpec;return i.validateSpec=Nn,r.expression&&to(jt(t))?lo(i):r.expression&&no(ar(t))?On(i):r.type&&po[r.type]?po[r.type](i):Oi(xr({},i,{valueSpec:r.type?s[r.type]:r}))}function Tl(i){let t=i.value,r=i.key,s=dn(i);return s.length||(t.indexOf("{fontstack}")===-1&&s.push(new ge(r,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&s.push(new ge(r,t,'"glyphs" url must include a "{range}" token'))),s}function Hi(i,t=oe){let r=[];return r=r.concat(Nn({key:"",value:i,valueSpec:t.$root,styleSpec:t,style:i,validateSpec:Nn,objectElementValidators:{glyphs:Tl,"*":()=>[]}})),i.constants&&(r=r.concat(Sl({key:"constants",value:i.constants,style:i,styleSpec:t,validateSpec:Nn}))),xa(r)}function Tr(i){return function(t){return i({...t,validateSpec:Nn})}}function xa(i){return[].concat(i).sort(((t,r)=>t.line-r.line))}function lr(i){return function(...t){return xa(i.apply(this,t))}}Hi.source=lr(Tr(Ps)),Hi.sprite=lr(Tr(ya)),Hi.glyphs=lr(Tr(Tl)),Hi.light=lr(Tr(ma)),Hi.sky=lr(Tr(ga)),Hi.terrain=lr(Tr(_a)),Hi.layer=lr(Tr(fa)),Hi.filter=lr(Tr(ua)),Hi.paintProperty=lr(Tr(ho)),Hi.layoutProperty=lr(Tr(pa));let pn=Hi,Ac=pn.light,Ec=pn.sky,Il=pn.paintProperty,Cl=pn.layoutProperty;function va(i,t){let r=!1;if(t&&t.length)for(let s of t)i.fire(new Vr(new Error(s.message))),r=!0;return r}class Vn{constructor(t,r,s){let l=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;let d=new Int32Array(this.arrayBuffer);t=d[0],this.d=(r=d[1])+2*(s=d[2]);for(let g=0;g<this.d*this.d;g++){let x=d[3+g],v=d[3+g+1];l.push(x===v?null:d.subarray(x,v))}let 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*s;for(let d=0;d<this.d*this.d;d++)l.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=t,this.padding=s,this.scale=r/t,this.uid=0;let u=s/r*t;this.min=-u,this.max=t+u}insert(t,r,s,l,u){this._forEachCell(r,s,l,u,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(r),this.bboxes.push(s),this.bboxes.push(l),this.bboxes.push(u)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,r,s,l,u,d){this.cells[u].push(d)}query(t,r,s,l,u){let d=this.min,f=this.max;if(t<=d&&r<=d&&f<=s&&f<=l&&!u)return Array.prototype.slice.call(this.keys);{let g=[];return this._forEachCell(t,r,s,l,this._queryCell,g,{},u),g}}_queryCell(t,r,s,l,u,d,f,g){let x=this.cells[u];if(x!==null){let v=this.keys,w=this.bboxes;for(let C=0;C<x.length;C++){let A=x[C];if(f[A]===void 0){let k=4*A;(g?g(w[k+0],w[k+1],w[k+2],w[k+3]):t<=w[k+2]&&r<=w[k+3]&&s>=w[k+0]&&l>=w[k+1])?(f[A]=!0,d.push(v[A])):f[A]=!1}}}}_forEachCell(t,r,s,l,u,d,f,g){let x=this._convertToCellCoord(t),v=this._convertToCellCoord(r),w=this._convertToCellCoord(s),C=this._convertToCellCoord(l);for(let A=x;A<=w;A++)for(let k=v;k<=C;k++){let z=this.d*k+A;if((!g||g(this._convertFromCellCoord(A),this._convertFromCellCoord(k),this._convertFromCellCoord(A+1),this._convertFromCellCoord(k+1)))&&u.call(this,t,r,s,l,z,d,f,g))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let t=this.cells,r=3+this.cells.length+1+1,s=0;for(let d=0;d<this.cells.length;d++)s+=this.cells[d].length;let l=new Int32Array(r+s+this.keys.length+this.bboxes.length);l[0]=this.extent,l[1]=this.n,l[2]=this.padding;let u=r;for(let d=0;d<t.length;d++){let f=t[d];l[3+d]=u,l.set(f,u),u+=f.length}return l[3+t.length]=u,l.set(this.keys,u),u+=this.keys.length,l[3+t.length+1]=u,l.set(this.bboxes,u),u+=this.bboxes.length,l.buffer}static serialize(t,r){let s=t.toArrayBuffer();return r&&r.push(s),{buffer:s}}static deserialize(t){return new Vn(t.buffer)}}let Wi={};function ke(i,t,r={}){if(Wi[i])throw new Error(`${i} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:i,writeable:!1}),Wi[i]={klass:t,omit:r.omit||[],shallow:r.shallow||[]}}ke("Object",Object),ke("TransferableGridIndex",Vn),ke("Color",vt),ke("Error",Error),ke("AJAXError",Di),ke("ResolvedImage",Fi),ke("StylePropertyFunction",Fn),ke("StyleExpression",ro,{omit:["_evaluator"]}),ke("ZoomDependentExpression",Bn),ke("ZoomConstantExpression",Rn),ke("CompoundExpression",Gi,{omit:["_evaluate"]});for(let i in An)An[i]._classRegistryKey||ke(`Expression_${i}`,An[i]);function fo(i){return i&&typeof ArrayBuffer<"u"&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}function ba(i){return i.$name||i.constructor._classRegistryKey}function Pl(i){return!(function(t){if(t===null||typeof t!="object")return!1;let r=ba(t);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||fo(i)||qt(i)||ArrayBuffer.isView(i)||i instanceof ImageData)}function Un(i,t){if(Pl(i))return(fo(i)||qt(i))&&t&&t.push(i),ArrayBuffer.isView(i)&&t&&t.push(i.buffer),i instanceof ImageData&&t&&t.push(i.data.buffer),i;if(Array.isArray(i)){let u=[];for(let d of i)u.push(Un(d,t));return u}if(typeof i!="object")throw new Error("can't serialize object of type "+typeof i);let r=ba(i);if(!r)throw new Error(`can't serialize object of unregistered class ${i.constructor.name}`);if(!Wi[r])throw new Error(`${r} is not registered.`);let{klass:s}=Wi[r],l=s.serialize?s.serialize(i,t):{};if(s.serialize){if(t&&l===t[t.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(let u in i){if(!i.hasOwnProperty(u)||Wi[r].omit.indexOf(u)>=0)continue;let d=i[u];l[u]=Wi[r].shallow.indexOf(u)>=0?d:Un(d,t)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(l.$name=r),l}function jn(i){if(Pl(i))return i;if(Array.isArray(i))return i.map(jn);if(typeof i!="object")throw new Error("can't deserialize object of type "+typeof i);let t=ba(i)||"Object";if(!Wi[t])throw new Error(`can't deserialize unregistered class ${t}`);let{klass:r}=Wi[t];if(!r)throw new Error(`can't deserialize unregistered class ${t}`);if(r.deserialize)return r.deserialize(i);let s=Object.create(r.prototype);for(let l of Object.keys(i)){if(l==="$name")continue;let u=i[l];s[l]=Wi[t].shallow.indexOf(l)>=0?u:jn(u)}return s}class wa{constructor(){this.first=!0}update(t,r){let s=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<s&&(this.lastIntegerZoom=s,this.lastIntegerZoomTime=r),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=s,!0))}}let lt={"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 Sa(i){for(let t of i)if(Ia(t.charCodeAt(0)))return!0;return!1}function kc(i){for(let t of i)if(!$n(t.charCodeAt(0)))return!1;return!0}function Ta(i){let t=i.map((r=>{try{return new RegExp(`\\p{sc=${r}}`,"u").source}catch{return null}})).filter((r=>r));return new RegExp(t.join("|"),"u")}let zc=Ta(["Arab","Dupl","Mong","Ougr","Syrc"]);function $n(i){return!zc.test(String.fromCodePoint(i))}let Ml=Ta(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function Ia(i){return!(i!==746&&i!==747&&(i<4352||!(lt["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||lt["CJK Compatibility"](i)||lt["CJK Strokes"](i)||!(!lt["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||lt["Enclosed CJK Letters and Months"](i)||lt["Ideographic Description Characters"](i)||lt.Kanbun(i)||lt.Katakana(i)&&i!==12540||!(!lt["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)||!(!lt["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||lt["Vertical Forms"](i)||lt["Yijing Hexagram Symbols"](i)||/\p{sc=Cans}/u.test(String.fromCodePoint(i))||/\p{sc=Hang}/u.test(String.fromCodePoint(i))||Ml.test(String.fromCodePoint(i)))))}function Al(i){return!(Ia(i)||(function(t){return!!(lt["Latin-1 Supplement"](t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||lt["General Punctuation"](t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||lt["Letterlike Symbols"](t)||lt["Number Forms"](t)||lt["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||lt["Control Pictures"](t)&&t!==9251||lt["Optical Character Recognition"](t)||lt["Enclosed Alphanumerics"](t)||lt["Geometric Shapes"](t)||lt["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||lt["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||lt["CJK Symbols and Punctuation"](t)||lt.Katakana(t)||lt["Private Use Area"](t)||lt["CJK Compatibility Forms"](t)||lt["Small Form Variants"](t)||lt["Halfwidth and Fullwidth Forms"](t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)})(i))}let Lc=Ta(["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 Ca(i){return Lc.test(String.fromCodePoint(i))}function Dc(i,t){return!(!t&&Ca(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||lt.Khmer(i))}function Rc(i){for(let t of i)if(Ca(t.charCodeAt(0)))return!0;return!1}let Ni=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 At{constructor(t,r){this.zoom=t,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new wa,this.transition={})}isSupportedScript(t){return(function(r,s){for(let l of r)if(!Dc(l.charCodeAt(0),s))return!1;return!0})(t,Ni.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let t=this.zoom,r=t-Math.floor(t),s=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*r}}}class qn{constructor(t,r){this.property=t,this.value=r,this.expression=(function(s,l){if(to(s))return new Fn(s,l);if(no(s)){let u=aa(s,l);if(u.result==="error")throw new Error(u.value.map((d=>`${d.key}: ${d.message}`)).join(", "));return u.value}{let u=s;return l.type==="color"&&typeof s=="string"?u=vt.parse(s):l.type!=="padding"||typeof s!="number"&&!Array.isArray(s)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(s)&&(u=Zi.parse(s)):u=Bi.parse(s),{kind:"constant",evaluate:()=>u}}})(r===void 0?t.specification.default:r,t.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(t,r,s){return this.property.possiblyEvaluate(this,t,r,s)}}class mo{constructor(t){this.property=t,this.value=new qn(t,void 0)}transitioned(t,r){return new El(this.property,this.value,r,Mt({},t.transition,this.transition),t.now)}untransitioned(){return new El(this.property,this.value,null,{},0)}}class go{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return Ye(this._values[t].value.value)}setValue(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new mo(this._values[t].property)),this._values[t].value=new qn(this._values[t].property,r===null?void 0:Ye(r))}getTransition(t){return Ye(this._values[t].transition)}setTransition(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new mo(this._values[t].property)),this._values[t].transition=Ye(r)||void 0}serialize(){let t={};for(let r of Object.keys(this._values)){let s=this.getValue(r);s!==void 0&&(t[r]=s);let l=this.getTransition(r);l!==void 0&&(t[`${r}-transition`]=l)}return t}transitioned(t,r){let s=new Ms(this._properties);for(let l of Object.keys(this._values))s._values[l]=this._values[l].transitioned(t,r._values[l]);return s}untransitioned(){let t=new Ms(this._properties);for(let r of Object.keys(this._values))t._values[r]=this._values[r].untransitioned();return t}}class El{constructor(t,r,s,l,u){this.property=t,this.value=r,this.begin=u+l.delay||0,this.end=this.begin+l.duration||0,t.specification.transition&&(l.delay||l.duration)&&(this.prior=s)}possiblyEvaluate(t,r,s){let l=t.now||0,u=this.value.possiblyEvaluate(t,r,s),d=this.prior;if(d){if(l>this.end)return this.prior=null,u;if(this.value.isDataDriven())return this.prior=null,u;if(l<this.begin)return d.possiblyEvaluate(t,r,s);{let f=(l-this.begin)/(this.end-this.begin);return this.property.interpolate(d.possiblyEvaluate(t,r,s),u,(function(g){if(g<=0)return 0;if(g>=1)return 1;let x=g*g,v=x*g;return 4*(g<.5?v:3*(g-x)+v-.75)})(f))}}return u}}class Ms{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,r,s){let l=new Es(this._properties);for(let u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(t,r,s);return l}hasTransition(){for(let t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class As{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return this._values[t].value!==void 0}getValue(t){return Ye(this._values[t].value)}setValue(t,r){this._values[t]=new qn(this._values[t].property,r===null?void 0:Ye(r))}serialize(){let t={};for(let r of Object.keys(this._values)){let s=this.getValue(r);s!==void 0&&(t[r]=s)}return t}possiblyEvaluate(t,r,s){let l=new Es(this._properties);for(let u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(t,r,s);return l}}class Ir{constructor(t,r,s){this.property=t,this.value=r,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,r,s,l){return this.property.evaluate(this.value,this.parameters,t,r,s,l)}}class Es{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class De{constructor(t){this.specification=t}possiblyEvaluate(t,r){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(r)}interpolate(t,r,s){let l=Ci[this.specification.type];return l?l(t,r,s):t}}class je{constructor(t,r){this.specification=t,this.overrides=r}possiblyEvaluate(t,r,s,l){return new Ir(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(r,null,{},s,l)}:t.expression,r)}interpolate(t,r,s){if(t.value.kind!=="constant"||r.value.kind!=="constant")return t;if(t.value.value===void 0||r.value.value===void 0)return new Ir(this,{kind:"constant",value:void 0},t.parameters);let l=Ci[this.specification.type];if(l){let u=l(t.value.value,r.value.value,s);return new Ir(this,{kind:"constant",value:u},t.parameters)}return t}evaluate(t,r,s,l,u,d){return t.kind==="constant"?t.value:t.evaluate(r,s,l,u,d)}}class _o extends je{possiblyEvaluate(t,r,s,l){if(t.value===void 0)return new Ir(this,{kind:"constant",value:void 0},r);if(t.expression.kind==="constant"){let u=t.expression.evaluate(r,null,{},s,l),d=t.property.specification.type==="resolvedImage"&&typeof u!="string"?u.name:u,f=this._calculate(d,d,d,r);return new Ir(this,{kind:"constant",value:f},r)}if(t.expression.kind==="camera"){let u=this._calculate(t.expression.evaluate({zoom:r.zoom-1}),t.expression.evaluate({zoom:r.zoom}),t.expression.evaluate({zoom:r.zoom+1}),r);return new Ir(this,{kind:"constant",value:u},r)}return new Ir(this,t.expression,r)}evaluate(t,r,s,l,u,d){if(t.kind==="source"){let f=t.evaluate(r,s,l,u,d);return this._calculate(f,f,f,r)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(r.zoom)-1},s,l),t.evaluate({zoom:Math.floor(r.zoom)},s,l),t.evaluate({zoom:Math.floor(r.zoom)+1},s,l),r):t.value}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class yo{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){if(t.value!==void 0){if(t.expression.kind==="constant"){let u=t.expression.evaluate(r,null,{},s,l);return this._calculate(u,u,u,r)}return this._calculate(t.expression.evaluate(new At(Math.floor(r.zoom-1),r)),t.expression.evaluate(new At(Math.floor(r.zoom),r)),t.expression.evaluate(new At(Math.floor(r.zoom+1),r)),r)}}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class Pa{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){return!!t.expression.evaluate(r,null,{},s,l)}interpolate(){return!1}}class h{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let r in t){let s=t[r];s.specification.overridable&&this.overridableProperties.push(r);let l=this.defaultPropertyValues[r]=new qn(s,void 0),u=this.defaultTransitionablePropertyValues[r]=new mo(s);this.defaultTransitioningPropertyValues[r]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}ke("DataDrivenProperty",je),ke("DataConstantProperty",De),ke("CrossFadedDataDrivenProperty",_o),ke("CrossFadedProperty",yo),ke("ColorRampProperty",Pa);let e="-transition";class n extends bn{constructor(t,r){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),r.layout&&(this._unevaluatedLayout=new As(r.layout)),r.paint)){this._transitionablePaint=new go(r.paint);for(let s in t.paint)this.setPaintProperty(s,t.paint[s],{validate:!1});for(let s in t.layout)this.setLayoutProperty(s,t.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Es(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,r,s={}){r!=null&&this._validate(Cl,`layers.${this.id}.layout.${t}`,t,r,s)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,r):this.visibility=r)}getPaintProperty(t){return t.endsWith(e)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,r,s={}){if(r!=null&&this._validate(Il,`layers.${this.id}.paint.${t}`,t,r,s))return!1;if(t.endsWith(e))return this._transitionablePaint.setTransition(t.slice(0,-11),r||void 0),!1;{let l=this._transitionablePaint._values[t],u=l.property.specification["property-type"]==="cross-faded-data-driven",d=l.value.isDataDriven(),f=l.value;this._transitionablePaint.setValue(t,r),this._handleSpecialPaintPropertyUpdate(t);let g=this._transitionablePaint._values[t].value;return g.isDataDriven()||d||u||this._handleOverridablePaintPropertyUpdate(t,f,g)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,r,s){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||this.visibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,r){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,r)}serialize(){let t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),yi(t,((r,s)=>!(r===void 0||s==="layout"&&!Object.keys(r).length||s==="paint"&&!Object.keys(r).length)))}_validate(t,r,s,l,u={}){return(!u||u.validate!==!1)&&va(this,t.call(pn,{key:r,layerType:this.type,objectKey:s,value:l,styleSpec:oe,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let t in this.paint._values){let r=this.paint.get(t);if(r instanceof Ir&&zn(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}let o={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class a{constructor(t,r){this._structArray=t,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class c{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,r){return t._trim(),r&&(t.isTransferred=!0,r.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){let r=Object.create(this.prototype);return r.arrayBuffer=t.arrayBuffer,r.length=t.length,r.capacity=t.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function m(i,t=1){let r=0,s=0;return{members:i.map((l=>{let u=o[l.type].BYTES_PER_ELEMENT,d=r=_(r,Math.max(t,u)),f=l.components||1;return s=Math.max(s,u),r+=u*f,{name:l.name,type:l.type,components:f,offset:d}})),size:_(r,Math.max(s,t)),alignment:t}}function _(i,t){return Math.ceil(i/t)*t}class y extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r){let s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){let l=2*t;return this.int16[l+0]=r,this.int16[l+1]=s,t}}y.prototype.bytesPerElement=4,ke("StructArrayLayout2i4",y);class b extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.int16[u+0]=r,this.int16[u+1]=s,this.int16[u+2]=l,t}}b.prototype.bytesPerElement=6,ke("StructArrayLayout3i6",b);class S extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,t,r,s,l)}emplace(t,r,s,l,u){let d=4*t;return this.int16[d+0]=r,this.int16[d+1]=s,this.int16[d+2]=l,this.int16[d+3]=u,t}}S.prototype.bytesPerElement=8,ke("StructArrayLayout4i8",S);class T extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){let g=6*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.int16[g+2]=l,this.int16[g+3]=u,this.int16[g+4]=d,this.int16[g+5]=f,t}}T.prototype.bytesPerElement=12,ke("StructArrayLayout2i4i12",T);class E extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){let g=4*t,x=8*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.uint8[x+4]=l,this.uint8[x+5]=u,this.uint8[x+6]=d,this.uint8[x+7]=f,t}}E.prototype.bytesPerElement=8,ke("StructArrayLayout2i4ub8",E);class L extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r){let s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){let l=2*t;return this.float32[l+0]=r,this.float32[l+1]=s,t}}L.prototype.bytesPerElement=8,ke("StructArrayLayout2f8",L);class B extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d,f,g,x,v){let w=this.length;return this.resize(w+1),this.emplace(w,t,r,s,l,u,d,f,g,x,v)}emplace(t,r,s,l,u,d,f,g,x,v,w){let C=10*t;return this.uint16[C+0]=r,this.uint16[C+1]=s,this.uint16[C+2]=l,this.uint16[C+3]=u,this.uint16[C+4]=d,this.uint16[C+5]=f,this.uint16[C+6]=g,this.uint16[C+7]=x,this.uint16[C+8]=v,this.uint16[C+9]=w,t}}B.prototype.bytesPerElement=20,ke("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(t,r,s,l,u,d,f,g,x,v,w,C){let A=this.length;return this.resize(A+1),this.emplace(A,t,r,s,l,u,d,f,g,x,v,w,C)}emplace(t,r,s,l,u,d,f,g,x,v,w,C,A){let k=12*t;return this.int16[k+0]=r,this.int16[k+1]=s,this.int16[k+2]=l,this.int16[k+3]=u,this.uint16[k+4]=d,this.uint16[k+5]=f,this.uint16[k+6]=g,this.uint16[k+7]=x,this.int16[k+8]=v,this.int16[k+9]=w,this.int16[k+10]=C,this.int16[k+11]=A,t}}V.prototype.bytesPerElement=24,ke("StructArrayLayout4i4ui4i24",V);class $ extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.float32[u+0]=r,this.float32[u+1]=s,this.float32[u+2]=l,t}}$.prototype.bytesPerElement=12,ke("StructArrayLayout3f12",$);class q extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint32[1*t+0]=r,t}}q.prototype.bytesPerElement=4,ke("StructArrayLayout1ul4",q);class G extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d,f,g,x){let v=this.length;return this.resize(v+1),this.emplace(v,t,r,s,l,u,d,f,g,x)}emplace(t,r,s,l,u,d,f,g,x,v){let w=10*t,C=5*t;return this.int16[w+0]=r,this.int16[w+1]=s,this.int16[w+2]=l,this.int16[w+3]=u,this.int16[w+4]=d,this.int16[w+5]=f,this.uint32[C+3]=g,this.uint16[w+8]=x,this.uint16[w+9]=v,t}}G.prototype.bytesPerElement=20,ke("StructArrayLayout6i1ul2ui20",G);class F extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){let g=6*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.int16[g+2]=l,this.int16[g+3]=u,this.int16[g+4]=d,this.int16[g+5]=f,t}}F.prototype.bytesPerElement=12,ke("StructArrayLayout2i2i2i12",F);class J extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u){let d=this.length;return this.resize(d+1),this.emplace(d,t,r,s,l,u)}emplace(t,r,s,l,u,d){let f=4*t,g=8*t;return this.float32[f+0]=r,this.float32[f+1]=s,this.float32[f+2]=l,this.int16[g+6]=u,this.int16[g+7]=d,t}}J.prototype.bytesPerElement=16,ke("StructArrayLayout2f1f2i16",J);class Q extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){let g=16*t,x=4*t,v=8*t;return this.uint8[g+0]=r,this.uint8[g+1]=s,this.float32[x+1]=l,this.float32[x+2]=u,this.int16[v+6]=d,this.int16[v+7]=f,t}}Q.prototype.bytesPerElement=16,ke("StructArrayLayout2ub2f2i16",Q);class ne extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.uint16[u+0]=r,this.uint16[u+1]=s,this.uint16[u+2]=l,t}}ne.prototype.bytesPerElement=6,ke("StructArrayLayout3ui6",ne);class ue extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d,f,g,x,v,w,C,A,k,z,O,j){let ie=this.length;return this.resize(ie+1),this.emplace(ie,t,r,s,l,u,d,f,g,x,v,w,C,A,k,z,O,j)}emplace(t,r,s,l,u,d,f,g,x,v,w,C,A,k,z,O,j,ie){let H=24*t,ee=12*t,ae=48*t;return this.int16[H+0]=r,this.int16[H+1]=s,this.uint16[H+2]=l,this.uint16[H+3]=u,this.uint32[ee+2]=d,this.uint32[ee+3]=f,this.uint32[ee+4]=g,this.uint16[H+10]=x,this.uint16[H+11]=v,this.uint16[H+12]=w,this.float32[ee+7]=C,this.float32[ee+8]=A,this.uint8[ae+36]=k,this.uint8[ae+37]=z,this.uint8[ae+38]=O,this.uint32[ee+10]=j,this.int16[H+22]=ie,t}}ue.prototype.bytesPerElement=48,ke("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ue);class me extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d,f,g,x,v,w,C,A,k,z,O,j,ie,H,ee,ae,fe,Me,Ue,Ie,we,Fe,Le){let Ee=this.length;return this.resize(Ee+1),this.emplace(Ee,t,r,s,l,u,d,f,g,x,v,w,C,A,k,z,O,j,ie,H,ee,ae,fe,Me,Ue,Ie,we,Fe,Le)}emplace(t,r,s,l,u,d,f,g,x,v,w,C,A,k,z,O,j,ie,H,ee,ae,fe,Me,Ue,Ie,we,Fe,Le,Ee){let he=32*t,Oe=16*t;return this.int16[he+0]=r,this.int16[he+1]=s,this.int16[he+2]=l,this.int16[he+3]=u,this.int16[he+4]=d,this.int16[he+5]=f,this.int16[he+6]=g,this.int16[he+7]=x,this.uint16[he+8]=v,this.uint16[he+9]=w,this.uint16[he+10]=C,this.uint16[he+11]=A,this.uint16[he+12]=k,this.uint16[he+13]=z,this.uint16[he+14]=O,this.uint16[he+15]=j,this.uint16[he+16]=ie,this.uint16[he+17]=H,this.uint16[he+18]=ee,this.uint16[he+19]=ae,this.uint16[he+20]=fe,this.uint16[he+21]=Me,this.uint16[he+22]=Ue,this.uint32[Oe+12]=Ie,this.float32[Oe+13]=we,this.float32[Oe+14]=Fe,this.uint16[he+30]=Le,this.uint16[he+31]=Ee,t}}me.prototype.bytesPerElement=64,ke("StructArrayLayout8i15ui1ul2f2ui64",me);class Te extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.float32[1*t+0]=r,t}}Te.prototype.bytesPerElement=4,ke("StructArrayLayout1f4",Te);class Ae extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.uint16[6*t+0]=r,this.float32[u+1]=s,this.float32[u+2]=l,t}}Ae.prototype.bytesPerElement=12,ke("StructArrayLayout1ui2f12",Ae);class xe extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=4*t;return this.uint32[2*t+0]=r,this.uint16[u+2]=s,this.uint16[u+3]=l,t}}xe.prototype.bytesPerElement=8,ke("StructArrayLayout1ul2ui8",xe);class ye extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r){let s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){let l=2*t;return this.uint16[l+0]=r,this.uint16[l+1]=s,t}}ye.prototype.bytesPerElement=4,ke("StructArrayLayout2ui4",ye);class Re extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint16[1*t+0]=r,t}}Re.prototype.bytesPerElement=2,ke("StructArrayLayout1ui2",Re);class We extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,t,r,s,l)}emplace(t,r,s,l,u){let d=4*t;return this.float32[d+0]=r,this.float32[d+1]=s,this.float32[d+2]=l,this.float32[d+3]=u,t}}We.prototype.bytesPerElement=16,ke("StructArrayLayout4f16",We);class be extends a{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 pe(this.anchorPointX,this.anchorPointY)}}be.prototype.size=20;class Pe extends G{get(t){return new be(this,t)}}ke("CollisionBoxArray",Pe);class Ze extends a{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Ze.prototype.size=48;class Et extends ue{get(t){return new Ze(this,t)}}ke("PlacedSymbolArray",Et);class Qe extends a{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Qe.prototype.size=64;class at extends me{get(t){return new Qe(this,t)}}ke("SymbolInstanceArray",at);class kt extends Te{getoffsetX(t){return this.float32[1*t+0]}}ke("GlyphOffsetArray",kt);class ui extends b{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}ke("SymbolLineVertexArray",ui);class cr extends a{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]}}cr.prototype.size=12;class zt extends Ae{get(t){return new cr(this,t)}}ke("TextAnchorOffsetArray",zt);class Mi extends a{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]}}Mi.prototype.size=8;class bi extends xe{get(t){return new Mi(this,t)}}ke("FeatureIndexArray",bi);class di extends y{}class wi extends y{}class Cr extends y{}class Zn extends T{}class xo extends E{}class Gn extends L{}class Xi extends B{}class vo extends V{}class Ma extends ${}class Ki extends q{}class Ji extends F{}class Gr extends Q{}class hr extends ne{}class oi extends ye{}let pi=m([{name:"a_pos",components:2,type:"Int16"}],4),{members:Vi}=pi;class ct{constructor(t=[]){this.segments=t}prepareSegment(t,r,s,l){let u=this.segments[this.segments.length-1];return t>ct.MAX_VERTEX_ARRAY_LENGTH&&ze(`Max vertices per segment is ${ct.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!u||u.vertexLength+t>ct.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==l)&&(u={vertexOffset:r.length,primitiveOffset:s.length,vertexLength:0,primitiveLength:0},l!==void 0&&(u.sortKey=l),this.segments.push(u)),u}get(){return this.segments}destroy(){for(let t of this.segments)for(let r in t.vaos)t.vaos[r].destroy()}static simpleSegment(t,r,s,l){return new ct([{vertexOffset:t,primitiveOffset:r,vertexLength:s,primitiveLength:l,vaos:{},sortKey:0}])}}function fn(i,t){return 256*(i=Je(Math.floor(i),0,255))+Je(Math.floor(t),0,255)}ct.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ke("SegmentVector",ct);let Hn=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 Wn={exports:{}},kl={exports:{}};kl.exports=function(i,t){var r,s,l,u,d,f,g,x;for(s=i.length-(r=3&i.length),l=t,d=3432918353,f=461845907,x=0;x<s;)g=255&i.charCodeAt(x)|(255&i.charCodeAt(++x))<<8|(255&i.charCodeAt(++x))<<16|(255&i.charCodeAt(++x))<<24,++x,l=27492+(65535&(u=5*(65535&(l=(l^=g=(65535&(g=(g=(65535&g)*d+(((g>>>16)*d&65535)<<16)&4294967295)<<15|g>>>17))*f+(((g>>>16)*f&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(g=0,r){case 3:g^=(255&i.charCodeAt(x+2))<<16;case 2:g^=(255&i.charCodeAt(x+1))<<8;case 1:l^=g=(65535&(g=(g=(65535&(g^=255&i.charCodeAt(x)))*d+(((g>>>16)*d&65535)<<16)&4294967295)<<15|g>>>17))*f+(((g>>>16)*f&65535)<<16)&4294967295}return l^=i.length,l=2246822507*(65535&(l^=l>>>16))+((2246822507*(l>>>16)&65535)<<16)&4294967295,l=3266489909*(65535&(l^=l>>>13))+((3266489909*(l>>>16)&65535)<<16)&4294967295,(l^=l>>>16)>>>0};var Bc=kl.exports,zl={exports:{}};zl.exports=function(i,t){for(var r,s=i.length,l=t^s,u=0;s>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(u)|(255&i.charCodeAt(++u))<<8|(255&i.charCodeAt(++u))<<16|(255&i.charCodeAt(++u))<<24))+((1540483477*(r>>>16)&65535)<<16),l=1540483477*(65535&l)+((1540483477*(l>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),s-=4,++u;switch(s){case 3:l^=(255&i.charCodeAt(u+2))<<16;case 2:l^=(255&i.charCodeAt(u+1))<<8;case 1:l=1540483477*(65535&(l^=255&i.charCodeAt(u)))+((1540483477*(l>>>16)&65535)<<16)}return l=1540483477*(65535&(l^=l>>>13))+((1540483477*(l>>>16)&65535)<<16),(l^=l>>>15)>>>0};var Hr=Bc,Ll=zl.exports;Wn.exports=Hr,Wn.exports.murmur3=Hr,Wn.exports.murmur2=Ll;var bo=Se(Wn.exports);class ks{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,r,s,l){this.ids.push(wo(t)),this.positions.push(r,s,l)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");let r=wo(t),s=0,l=this.ids.length-1;for(;s<l;){let d=s+l>>1;this.ids[d]>=r?l=d:s=d+1}let u=[];for(;this.ids[s]===r;)u.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return u}static serialize(t,r){let s=new Float64Array(t.ids),l=new Uint32Array(t.positions);return So(s,l,0,s.length-1),r&&r.push(s.buffer,l.buffer),{ids:s,positions:l}}static deserialize(t){let r=new ks;return r.ids=t.ids,r.positions=t.positions,r.indexed=!0,r}}function wo(i){let t=+i;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:bo(String(i))}function So(i,t,r,s){for(;r<s;){let l=i[r+s>>1],u=r-1,d=s+1;for(;;){do u++;while(i[u]<l);do d--;while(i[d]>l);if(u>=d)break;Xn(i,u,d),Xn(t,3*u,3*d),Xn(t,3*u+1,3*d+1),Xn(t,3*u+2,3*d+2)}d-r<s-d?(So(i,t,r,d),r=d+1):(So(i,t,d+1,s),s=d)}}function Xn(i,t,r){let s=i[t];i[t]=i[r],i[r]=s}ke("FeaturePositionMap",ks);class zs{constructor(t,r){this.gl=t.gl,this.location=r}}class Dl extends zs{constructor(t,r){super(t,r),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class jh extends zs{constructor(t,r){super(t,r),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class $h extends zs{constructor(t,r){super(t,r),this.current=vt.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}let rp=new Float32Array(16);function Fc(i){return[fn(255*i.r,255*i.g),fn(255*i.b,255*i.a)]}class Aa{constructor(t,r,s){this.value=t,this.uniformNames=r.map((l=>`u_${l}`)),this.type=s}setUniform(t,r,s){t.set(s.constantOr(this.value))}getBinding(t,r,s){return this.type==="color"?new $h(t,r):new Dl(t,r)}}class To{constructor(t,r){this.uniformNames=r.map((s=>`u_${s}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=t.tlbr}setUniform(t,r,s,l){let u=l==="u_pattern_to"?this.patternTo:l==="u_pattern_from"?this.patternFrom:l==="u_pixel_ratio_to"?this.pixelRatioTo:l==="u_pixel_ratio_from"?this.pixelRatioFrom:null;u&&t.set(u)}getBinding(t,r,s){return s.substr(0,9)==="u_pattern"?new jh(t,r):new Dl(t,r)}}class mn{constructor(t,r,s,l){this.expression=t,this.type=s,this.maxValue=0,this.paintVertexAttributes=r.map((u=>({name:`a_${u}`,type:"Float32",components:s==="color"?2:1,offset:0}))),this.paintVertexArray=new l}populatePaintArray(t,r,s,l,u){let d=this.paintVertexArray.length,f=this.expression.evaluate(new At(0),r,{},l,[],u);this.paintVertexArray.resize(t),this._setPaintValue(d,t,f)}updatePaintArray(t,r,s,l){let u=this.expression.evaluate({zoom:0},s,l);this._setPaintValue(t,r,u)}_setPaintValue(t,r,s){if(this.type==="color"){let l=Fc(s);for(let u=t;u<r;u++)this.paintVertexArray.emplace(u,l[0],l[1])}else{for(let l=t;l<r;l++)this.paintVertexArray.emplace(l,s);this.maxValue=Math.max(this.maxValue,Math.abs(s))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Rr{constructor(t,r,s,l,u,d){this.expression=t,this.uniformNames=r.map((f=>`u_${f}_t`)),this.type=s,this.useIntegerZoom=l,this.zoom=u,this.maxValue=0,this.paintVertexAttributes=r.map((f=>({name:`a_${f}`,type:"Float32",components:s==="color"?4:2,offset:0}))),this.paintVertexArray=new d}populatePaintArray(t,r,s,l,u){let d=this.expression.evaluate(new At(this.zoom),r,{},l,[],u),f=this.expression.evaluate(new At(this.zoom+1),r,{},l,[],u),g=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(g,t,d,f)}updatePaintArray(t,r,s,l){let u=this.expression.evaluate({zoom:this.zoom},s,l),d=this.expression.evaluate({zoom:this.zoom+1},s,l);this._setPaintValue(t,r,u,d)}_setPaintValue(t,r,s,l){if(this.type==="color"){let u=Fc(s),d=Fc(l);for(let f=t;f<r;f++)this.paintVertexArray.emplace(f,u[0],u[1],d[0],d[1])}else{for(let u=t;u<r;u++)this.paintVertexArray.emplace(u,s,l);this.maxValue=Math.max(this.maxValue,Math.abs(s),Math.abs(l))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,r){let s=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,l=Je(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);t.set(l)}getBinding(t,r,s){return new Dl(t,r)}}class Kn{constructor(t,r,s,l,u,d){this.expression=t,this.type=r,this.useIntegerZoom=s,this.zoom=l,this.layerId=d,this.zoomInPaintVertexArray=new u,this.zoomOutPaintVertexArray=new u}populatePaintArray(t,r,s){let l=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(l,t,r.patterns&&r.patterns[this.layerId],s)}updatePaintArray(t,r,s,l,u){this._setPaintValues(t,r,s.patterns&&s.patterns[this.layerId],u)}_setPaintValues(t,r,s,l){if(!l||!s)return;let{min:u,mid:d,max:f}=s,g=l[u],x=l[d],v=l[f];if(g&&x&&v)for(let w=t;w<r;w++)this.zoomInPaintVertexArray.emplace(w,x.tl[0],x.tl[1],x.br[0],x.br[1],g.tl[0],g.tl[1],g.br[0],g.br[1],x.pixelRatio,g.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(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,Hn.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,Hn.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class qh{constructor(t,r,s){this.binders={},this._buffers=[];let l=[];for(let u in t.paint._values){if(!s(u))continue;let d=t.paint.get(u);if(!(d instanceof Ir&&zn(d.property.specification)))continue;let f=np(u,t.type),g=d.value,x=d.property.specification.type,v=d.property.useIntegerZoom,w=d.property.specification["property-type"],C=w==="cross-faded"||w==="cross-faded-data-driven";if(g.kind==="constant")this.binders[u]=C?new To(g.value,f):new Aa(g.value,f,x),l.push(`/u_${u}`);else if(g.kind==="source"||C){let A=Zh(u,x,"source");this.binders[u]=C?new Kn(g,x,v,r,A,t.id):new mn(g,f,x,A),l.push(`/a_${u}`)}else{let A=Zh(u,x,"composite");this.binders[u]=new Rr(g,f,x,v,r,A),l.push(`/z_${u}`)}}this.cacheKey=l.sort().join("")}getMaxValue(t){let r=this.binders[t];return r instanceof mn||r instanceof Rr?r.maxValue:0}populatePaintArrays(t,r,s,l,u){for(let d in this.binders){let f=this.binders[d];(f instanceof mn||f instanceof Rr||f instanceof Kn)&&f.populatePaintArray(t,r,s,l,u)}}setConstantPatternPositions(t,r){for(let s in this.binders){let l=this.binders[s];l instanceof To&&l.setConstantPatternPositions(t,r)}}updatePaintArrays(t,r,s,l,u){let d=!1;for(let f in t){let g=r.getPositions(f);for(let x of g){let v=s.feature(x.index);for(let w in this.binders){let C=this.binders[w];if((C instanceof mn||C instanceof Rr||C instanceof Kn)&&C.expression.isStateDependent===!0){let A=l.paint.get(w);C.expression=A.value,C.updatePaintArray(x.start,x.end,v,t[f],u),d=!0}}}}return d}defines(){let t=[];for(let r in this.binders){let s=this.binders[r];(s instanceof Aa||s instanceof To)&&t.push(...s.uniformNames.map((l=>`#define HAS_UNIFORM_${l}`)))}return t}getBinderAttributes(){let t=[];for(let r in this.binders){let s=this.binders[r];if(s instanceof mn||s instanceof Rr)for(let l=0;l<s.paintVertexAttributes.length;l++)t.push(s.paintVertexAttributes[l].name);else if(s instanceof Kn)for(let l=0;l<Hn.members.length;l++)t.push(Hn.members[l].name)}return t}getBinderUniforms(){let t=[];for(let r in this.binders){let s=this.binders[r];if(s instanceof Aa||s instanceof To||s instanceof Rr)for(let l of s.uniformNames)t.push(l)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,r){let s=[];for(let l in this.binders){let u=this.binders[l];if(u instanceof Aa||u instanceof To||u instanceof Rr){for(let d of u.uniformNames)if(r[d]){let f=u.getBinding(t,r[d],d);s.push({name:d,property:l,binding:f})}}}return s}setUniforms(t,r,s,l){for(let{name:u,property:d,binding:f}of r)this.binders[d].setUniform(f,l,s.get(d),u)}updatePaintBuffers(t){this._buffers=[];for(let r in this.binders){let s=this.binders[r];if(t&&s instanceof Kn){let l=t.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;l&&this._buffers.push(l)}else(s instanceof mn||s instanceof Rr)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(t){for(let r in this.binders){let s=this.binders[r];(s instanceof mn||s instanceof Rr||s instanceof Kn)&&s.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let r=this.binders[t];(r instanceof mn||r instanceof Rr||r instanceof Kn)&&r.destroy()}}}class Ls{constructor(t,r,s=(()=>!0)){this.programConfigurations={};for(let l of t)this.programConfigurations[l.id]=new qh(l,r,s);this.needsUpload=!1,this._featureMap=new ks,this._bufferOffset=0}populatePaintArrays(t,r,s,l,u,d){for(let f in this.programConfigurations)this.programConfigurations[f].populatePaintArrays(t,r,l,u,d);r.id!==void 0&&this._featureMap.add(r.id,s,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,r,s,l){for(let u of s)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(t,this._featureMap,r,u,l)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(let r in this.programConfigurations)this.programConfigurations[r].upload(t);this.needsUpload=!1}}destroy(){for(let t in this.programConfigurations)this.programConfigurations[t].destroy()}}function np(i,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[i]||[i.replace(`${t}-`,"").replace(/-/g,"_")]}function Zh(i,t,r){let s={color:{source:L,composite:We},number:{source:Te,composite:L}},l=(function(u){return{"line-pattern":{source:Xi,composite:Xi},"fill-pattern":{source:Xi,composite:Xi},"fill-extrusion-pattern":{source:Xi,composite:Xi}}[u]})(i);return l&&l[r]||s[t][r]}ke("ConstantBinder",Aa),ke("CrossFadedConstantBinder",To),ke("SourceExpressionBinder",mn),ke("CrossFadedCompositeBinder",Kn),ke("CompositeExpressionBinder",Rr),ke("ProgramConfiguration",qh,{omit:["_buffers"]}),ke("ProgramConfigurationSet",Ls);let Kt=8192,Oc=Math.pow(2,14)-1,Gh=-Oc-1;function Ds(i){let t=Kt/i.extent,r=i.loadGeometry();for(let s=0;s<r.length;s++){let l=r[s];for(let u=0;u<l.length;u++){let d=l[u],f=Math.round(d.x*t),g=Math.round(d.y*t);d.x=Je(f,Gh,Oc),d.y=Je(g,Gh,Oc),(f<d.x||f>d.x+1||g<d.y||g>d.y+1)&&ze("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function Rs(i,t){return{type:i.type,id:i.id,properties:i.properties,geometry:t?Ds(i):[]}}function Rl(i,t,r,s,l){i.emplaceBack(2*t+(s+1)/2,2*r+(l+1)/2)}class Nc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new wi,this.indexArray=new hr,this.segments=new ct,this.programConfigurations=new Ls(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(t,r,s){let l=this.layers[0],u=[],d=null,f=!1;l.type==="circle"&&(d=l.layout.get("circle-sort-key"),f=!d.isConstant());for(let{feature:g,id:x,index:v,sourceLayerIndex:w}of t){let C=this.layers[0]._featureFilter.needGeometry,A=Rs(g,C);if(!this.layers[0]._featureFilter.filter(new At(this.zoom),A,s))continue;let k=f?d.evaluate(A,{},s):void 0,z={id:x,properties:g.properties,type:g.type,sourceLayerIndex:w,index:v,geometry:C?A.geometry:Ds(g),patterns:{},sortKey:k};u.push(z)}f&&u.sort(((g,x)=>g.sortKey-x.sortKey));for(let g of u){let{geometry:x,index:v,sourceLayerIndex:w}=g,C=t[v].feature;this.addFeature(g,x,v,s),r.featureIndex.insert(C,x,v,w,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Vi),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,r,s,l){for(let u of r)for(let d of u){let f=d.x,g=d.y;if(f<0||f>=Kt||g<0||g>=Kt)continue;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),v=x.vertexLength;Rl(this.layoutVertexArray,f,g,-1,-1),Rl(this.layoutVertexArray,f,g,1,-1),Rl(this.layoutVertexArray,f,g,1,1),Rl(this.layoutVertexArray,f,g,-1,1),this.indexArray.emplaceBack(v,v+1,v+2),this.indexArray.emplaceBack(v,v+3,v+2),x.vertexLength+=4,x.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{},l)}}function Hh(i,t){for(let r=0;r<i.length;r++)if(Io(t,i[r]))return!0;for(let r=0;r<t.length;r++)if(Io(i,t[r]))return!0;return!!Vc(i,t)}function sp(i,t,r){return!!Io(i,t)||!!Uc(t,i,r)}function Wh(i,t){if(i.length===1)return Kh(t,i[0]);for(let r=0;r<t.length;r++){let s=t[r];for(let l=0;l<s.length;l++)if(Io(i,s[l]))return!0}for(let r=0;r<i.length;r++)if(Kh(t,i[r]))return!0;for(let r=0;r<t.length;r++)if(Vc(i,t[r]))return!0;return!1}function op(i,t,r){if(i.length>1){if(Vc(i,t))return!0;for(let s=0;s<t.length;s++)if(Uc(t[s],i,r))return!0}for(let s=0;s<i.length;s++)if(Uc(i[s],t,r))return!0;return!1}function Vc(i,t){if(i.length===0||t.length===0)return!1;for(let r=0;r<i.length-1;r++){let s=i[r],l=i[r+1];for(let u=0;u<t.length-1;u++)if(ap(s,l,t[u],t[u+1]))return!0}return!1}function ap(i,t,r,s){return tt(i,r,s)!==tt(t,r,s)&&tt(i,t,r)!==tt(i,t,s)}function Uc(i,t,r){let s=r*r;if(t.length===1)return i.distSqr(t[0])<s;for(let l=1;l<t.length;l++)if(Xh(i,t[l-1],t[l])<s)return!0;return!1}function Xh(i,t,r){let s=t.distSqr(r);if(s===0)return i.distSqr(t);let l=((i.x-t.x)*(r.x-t.x)+(i.y-t.y)*(r.y-t.y))/s;return i.distSqr(l<0?t:l>1?r:r.sub(t)._mult(l)._add(t))}function Kh(i,t){let r,s,l,u=!1;for(let d=0;d<i.length;d++){r=i[d];for(let f=0,g=r.length-1;f<r.length;g=f++)s=r[f],l=r[g],s.y>t.y!=l.y>t.y&&t.x<(l.x-s.x)*(t.y-s.y)/(l.y-s.y)+s.x&&(u=!u)}return u}function Io(i,t){let r=!1;for(let s=0,l=i.length-1;s<i.length;l=s++){let u=i[s],d=i[l];u.y>t.y!=d.y>t.y&&t.x<(d.x-u.x)*(t.y-u.y)/(d.y-u.y)+u.x&&(r=!r)}return r}function lp(i,t,r){let s=r[0],l=r[2];if(i.x<s.x&&t.x<s.x||i.x>l.x&&t.x>l.x||i.y<s.y&&t.y<s.y||i.y>l.y&&t.y>l.y)return!1;let u=tt(i,t,r[0]);return u!==tt(i,t,r[1])||u!==tt(i,t,r[2])||u!==tt(i,t,r[3])}function Ea(i,t,r){let s=t.paint.get(i).value;return s.kind==="constant"?s.value:r.programConfigurations.get(t.id).getMaxValue(i)}function Bl(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Fl(i,t,r,s,l){if(!t[0]&&!t[1])return i;let u=pe.convert(t)._mult(l);r==="viewport"&&u._rotate(-s);let d=[];for(let f=0;f<i.length;f++)d.push(i[f].sub(u));return d}let Jh,Yh;ke("CircleBucket",Nc,{omit:["layers"]});var cp={get paint(){return Yh=Yh||new h({"circle-radius":new je(oe.paint_circle["circle-radius"]),"circle-color":new je(oe.paint_circle["circle-color"]),"circle-blur":new je(oe.paint_circle["circle-blur"]),"circle-opacity":new je(oe.paint_circle["circle-opacity"]),"circle-translate":new De(oe.paint_circle["circle-translate"]),"circle-translate-anchor":new De(oe.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new De(oe.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new De(oe.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new je(oe.paint_circle["circle-stroke-width"]),"circle-stroke-color":new je(oe.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new je(oe.paint_circle["circle-stroke-opacity"])})},get layout(){return Jh=Jh||new h({"circle-sort-key":new je(oe.layout_circle["circle-sort-key"])})}},Ai=1e-6,Co=typeof Float32Array<"u"?Float32Array:Array;function jc(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 Qh(i,t,r){var s=t[0],l=t[1],u=t[2],d=t[3],f=t[4],g=t[5],x=t[6],v=t[7],w=t[8],C=t[9],A=t[10],k=t[11],z=t[12],O=t[13],j=t[14],ie=t[15],H=r[0],ee=r[1],ae=r[2],fe=r[3];return i[0]=H*s+ee*f+ae*w+fe*z,i[1]=H*l+ee*g+ae*C+fe*O,i[2]=H*u+ee*x+ae*A+fe*j,i[3]=H*d+ee*v+ae*k+fe*ie,i[4]=(H=r[4])*s+(ee=r[5])*f+(ae=r[6])*w+(fe=r[7])*z,i[5]=H*l+ee*g+ae*C+fe*O,i[6]=H*u+ee*x+ae*A+fe*j,i[7]=H*d+ee*v+ae*k+fe*ie,i[8]=(H=r[8])*s+(ee=r[9])*f+(ae=r[10])*w+(fe=r[11])*z,i[9]=H*l+ee*g+ae*C+fe*O,i[10]=H*u+ee*x+ae*A+fe*j,i[11]=H*d+ee*v+ae*k+fe*ie,i[12]=(H=r[12])*s+(ee=r[13])*f+(ae=r[14])*w+(fe=r[15])*z,i[13]=H*l+ee*g+ae*C+fe*O,i[14]=H*u+ee*x+ae*A+fe*j,i[15]=H*d+ee*v+ae*k+fe*ie,i}Math.hypot||(Math.hypot=function(){for(var i=0,t=arguments.length;t--;)i+=arguments[t]*arguments[t];return Math.sqrt(i)});var ka,hp=Qh;function Ol(i,t,r){var s=t[0],l=t[1],u=t[2],d=t[3];return i[0]=r[0]*s+r[4]*l+r[8]*u+r[12]*d,i[1]=r[1]*s+r[5]*l+r[9]*u+r[13]*d,i[2]=r[2]*s+r[6]*l+r[10]*u+r[14]*d,i[3]=r[3]*s+r[7]*l+r[11]*u+r[15]*d,i}ka=new Co(4),Co!=Float32Array&&(ka[0]=0,ka[1]=0,ka[2]=0,ka[3]=0);class up extends n{constructor(t){super(t,cp)}createBucket(t){return new Nc(t)}queryRadius(t){let r=t;return Ea("circle-radius",this,r)+Ea("circle-stroke-width",this,r)+Bl(this.paint.get("circle-translate"))}queryIntersectsFeature(t,r,s,l,u,d,f,g){let x=Fl(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),d.angle,f),v=this.paint.get("circle-radius").evaluate(r,s)+this.paint.get("circle-stroke-width").evaluate(r,s),w=this.paint.get("circle-pitch-alignment")==="map",C=w?x:(function(k,z){return k.map((O=>eu(O,z)))})(x,g),A=w?v*f:v;for(let k of l)for(let z of k){let O=w?z:eu(z,g),j=A,ie=Ol([],[z.x,z.y,0,1],g);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?j*=ie[3]/d.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(j*=d.cameraToCenterDistance/ie[3]),sp(C,O,j))return!0}return!1}}function eu(i,t){let r=Ol([],[i.x,i.y,0,1],t);return new pe(r[0]/r[3],r[1]/r[3])}class tu extends Nc{}let iu;ke("HeatmapBucket",tu,{omit:["layers"]});var dp={get paint(){return iu=iu||new h({"heatmap-radius":new je(oe.paint_heatmap["heatmap-radius"]),"heatmap-weight":new je(oe.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new De(oe.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Pa(oe.paint_heatmap["heatmap-color"]),"heatmap-opacity":new De(oe.paint_heatmap["heatmap-opacity"])})}};function $c(i,{width:t,height:r},s,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==t*r*s)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${t*r*s}`)}else l=new Uint8Array(t*r*s);return i.width=t,i.height=r,i.data=l,i}function ru(i,{width:t,height:r},s){if(t===i.width&&r===i.height)return;let l=$c({},{width:t,height:r},s);qc(i,l,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,t),height:Math.min(i.height,r)},s),i.width=t,i.height=r,i.data=l.data}function qc(i,t,r,s,l,u){if(l.width===0||l.height===0)return t;if(l.width>i.width||l.height>i.height||r.x>i.width-l.width||r.y>i.height-l.height)throw new RangeError("out of range source coordinates for image copy");if(l.width>t.width||l.height>t.height||s.x>t.width-l.width||s.y>t.height-l.height)throw new RangeError("out of range destination coordinates for image copy");let d=i.data,f=t.data;if(d===f)throw new Error("srcData equals dstData, so image is already copied");for(let g=0;g<l.height;g++){let x=((r.y+g)*i.width+r.x)*u,v=((s.y+g)*t.width+s.x)*u;for(let w=0;w<l.width*u;w++)f[v+w]=d[x+w]}return t}class za{constructor(t,r){$c(this,t,1,r)}resize(t){ru(this,t,1)}clone(){return new za({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,r,s,l,u){qc(t,r,s,l,u,1)}}class ur{constructor(t,r){$c(this,t,4,r)}resize(t){ru(this,t,4)}replace(t,r){r?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new ur({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,r,s,l,u){qc(t,r,s,l,u,4)}}function nu(i){let t={},r=i.resolution||256,s=i.clips?i.clips.length:1,l=i.image||new ur({width:r,height:s});if(Math.log(r)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${r}`);let u=(d,f,g)=>{t[i.evaluationKey]=g;let x=i.expression.evaluate(t);l.data[d+f+0]=Math.floor(255*x.r/x.a),l.data[d+f+1]=Math.floor(255*x.g/x.a),l.data[d+f+2]=Math.floor(255*x.b/x.a),l.data[d+f+3]=Math.floor(255*x.a)};if(i.clips)for(let d=0,f=0;d<s;++d,f+=4*r)for(let g=0,x=0;g<r;g++,x+=4){let v=g/(r-1),{start:w,end:C}=i.clips[d];u(f,x,w*(1-v)+C*v)}else for(let d=0,f=0;d<r;d++,f+=4)u(0,f,d/(r-1));return l}ke("AlphaImage",za),ke("RGBAImage",ur);let Zc="big-fb";class pp extends n{createBucket(t){return new tu(t)}constructor(t){super(t,dp),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=nu({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Zc)&&this.heatmapFbos.delete(Zc)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}}let su;var fp={get paint(){return su=su||new h({"hillshade-illumination-direction":new De(oe.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new De(oe.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new De(oe.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new De(oe.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new De(oe.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new De(oe.paint_hillshade["hillshade-accent-color"])})}};class mp extends n{constructor(t){super(t,fp)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}let gp=m([{name:"a_pos",components:2,type:"Int16"}],4),{members:_p}=gp;function ou(i,t,r=2){let s=t&&t.length,l=s?t[0]*r:i.length,u=au(i,0,l,r,!0),d=[];if(!u||u.next===u.prev)return d;let f,g,x;if(s&&(u=(function(v,w,C,A){let k=[];for(let z=0,O=w.length;z<O;z++){let j=au(v,w[z]*A,z<O-1?w[z+1]*A:v.length,A,!1);j===j.next&&(j.steiner=!0),k.push(Ip(j))}k.sort(wp);for(let z=0;z<k.length;z++)C=Sp(k[z],C);return C})(i,t,u,r)),i.length>80*r){f=1/0,g=1/0;let v=-1/0,w=-1/0;for(let C=r;C<l;C+=r){let A=i[C],k=i[C+1];A<f&&(f=A),k<g&&(g=k),A>v&&(v=A),k>w&&(w=k)}x=Math.max(v-f,w-g),x=x!==0?32767/x:0}return La(u,d,r,f,g,x,0),d}function au(i,t,r,s,l){let u;if(l===(function(d,f,g,x){let v=0;for(let w=f,C=g-x;w<g;w+=x)v+=(d[C]-d[w])*(d[w+1]+d[C+1]),C=w;return v})(i,t,r,s)>0)for(let d=t;d<r;d+=s)u=hu(d/s|0,i[d],i[d+1],u);else for(let d=r-s;d>=t;d-=s)u=hu(d/s|0,i[d],i[d+1],u);return u&&Nl(u,u.next)&&(Ra(u),u=u.next),u}function Bs(i,t){if(!i)return i;t||(t=i);let r,s=i;do if(r=!1,s.steiner||!Nl(s,s.next)&&Ht(s.prev,s,s.next)!==0)s=s.next;else{if(Ra(s),s=t=s.prev,s===s.next)break;r=!0}while(r||s!==t);return t}function La(i,t,r,s,l,u,d){if(!i)return;!d&&u&&(function(g,x,v,w){let C=g;do C.z===0&&(C.z=Gc(C.x,C.y,x,v,w)),C.prevZ=C.prev,C.nextZ=C.next,C=C.next;while(C!==g);C.prevZ.nextZ=null,C.prevZ=null,(function(A){let k,z=1;do{let O,j=A;A=null;let ie=null;for(k=0;j;){k++;let H=j,ee=0;for(let fe=0;fe<z&&(ee++,H=H.nextZ,H);fe++);let ae=z;for(;ee>0||ae>0&&H;)ee!==0&&(ae===0||!H||j.z<=H.z)?(O=j,j=j.nextZ,ee--):(O=H,H=H.nextZ,ae--),ie?ie.nextZ=O:A=O,O.prevZ=ie,ie=O;j=H}ie.nextZ=null,z*=2}while(k>1)})(C)})(i,s,l,u);let f=i;for(;i.prev!==i.next;){let g=i.prev,x=i.next;if(u?xp(i,s,l,u):yp(i))t.push(g.i,i.i,x.i),Ra(i),i=x.next,f=x.next;else if((i=x)===f){d?d===1?La(i=vp(Bs(i),t),t,r,s,l,u,2):d===2&&bp(i,t,r,s,l,u):La(Bs(i),t,r,s,l,u,1);break}}}function yp(i){let t=i.prev,r=i,s=i.next;if(Ht(t,r,s)>=0)return!1;let l=t.x,u=r.x,d=s.x,f=t.y,g=r.y,x=s.y,v=l<u?l<d?l:d:u<d?u:d,w=f<g?f<x?f:x:g<x?g:x,C=l>u?l>d?l:d:u>d?u:d,A=f>g?f>x?f:x:g>x?g:x,k=s.next;for(;k!==t;){if(k.x>=v&&k.x<=C&&k.y>=w&&k.y<=A&&Po(l,f,u,g,d,x,k.x,k.y)&&Ht(k.prev,k,k.next)>=0)return!1;k=k.next}return!0}function xp(i,t,r,s){let l=i.prev,u=i,d=i.next;if(Ht(l,u,d)>=0)return!1;let f=l.x,g=u.x,x=d.x,v=l.y,w=u.y,C=d.y,A=f<g?f<x?f:x:g<x?g:x,k=v<w?v<C?v:C:w<C?w:C,z=f>g?f>x?f:x:g>x?g:x,O=v>w?v>C?v:C:w>C?w:C,j=Gc(A,k,t,r,s),ie=Gc(z,O,t,r,s),H=i.prevZ,ee=i.nextZ;for(;H&&H.z>=j&&ee&&ee.z<=ie;){if(H.x>=A&&H.x<=z&&H.y>=k&&H.y<=O&&H!==l&&H!==d&&Po(f,v,g,w,x,C,H.x,H.y)&&Ht(H.prev,H,H.next)>=0||(H=H.prevZ,ee.x>=A&&ee.x<=z&&ee.y>=k&&ee.y<=O&&ee!==l&&ee!==d&&Po(f,v,g,w,x,C,ee.x,ee.y)&&Ht(ee.prev,ee,ee.next)>=0))return!1;ee=ee.nextZ}for(;H&&H.z>=j;){if(H.x>=A&&H.x<=z&&H.y>=k&&H.y<=O&&H!==l&&H!==d&&Po(f,v,g,w,x,C,H.x,H.y)&&Ht(H.prev,H,H.next)>=0)return!1;H=H.prevZ}for(;ee&&ee.z<=ie;){if(ee.x>=A&&ee.x<=z&&ee.y>=k&&ee.y<=O&&ee!==l&&ee!==d&&Po(f,v,g,w,x,C,ee.x,ee.y)&&Ht(ee.prev,ee,ee.next)>=0)return!1;ee=ee.nextZ}return!0}function vp(i,t){let r=i;do{let s=r.prev,l=r.next.next;!Nl(s,l)&&lu(s,r,r.next,l)&&Da(s,l)&&Da(l,s)&&(t.push(s.i,r.i,l.i),Ra(r),Ra(r.next),r=i=l),r=r.next}while(r!==i);return Bs(r)}function bp(i,t,r,s,l,u){let d=i;do{let f=d.next.next;for(;f!==d.prev;){if(d.i!==f.i&&Cp(d,f)){let g=cu(d,f);return d=Bs(d,d.next),g=Bs(g,g.next),La(d,t,r,s,l,u,0),void La(g,t,r,s,l,u,0)}f=f.next}d=d.next}while(d!==i)}function wp(i,t){return i.x-t.x}function Sp(i,t){let r=(function(l,u){let d=u,f=l.x,g=l.y,x,v=-1/0;do{if(g<=d.y&&g>=d.next.y&&d.next.y!==d.y){let z=d.x+(g-d.y)*(d.next.x-d.x)/(d.next.y-d.y);if(z<=f&&z>v&&(v=z,x=d.x<d.next.x?d:d.next,z===f))return x}d=d.next}while(d!==u);if(!x)return null;let w=x,C=x.x,A=x.y,k=1/0;d=x;do{if(f>=d.x&&d.x>=C&&f!==d.x&&Po(g<A?f:v,g,C,A,g<A?v:f,g,d.x,d.y)){let z=Math.abs(g-d.y)/(f-d.x);Da(d,l)&&(z<k||z===k&&(d.x>x.x||d.x===x.x&&Tp(x,d)))&&(x=d,k=z)}d=d.next}while(d!==w);return x})(i,t);if(!r)return t;let s=cu(r,i);return Bs(s,s.next),Bs(r,r.next)}function Tp(i,t){return Ht(i.prev,i,t.prev)<0&&Ht(t.next,i,i.next)<0}function Gc(i,t,r,s,l){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*l|0)|i<<8))|i<<4))|i<<2))|i<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*l|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ip(i){let t=i,r=i;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==i);return r}function Po(i,t,r,s,l,u,d,f){return(l-d)*(t-f)>=(i-d)*(u-f)&&(i-d)*(s-f)>=(r-d)*(t-f)&&(r-d)*(u-f)>=(l-d)*(s-f)}function Cp(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!(function(r,s){let l=r;do{if(l.i!==r.i&&l.next.i!==r.i&&l.i!==s.i&&l.next.i!==s.i&&lu(l,l.next,r,s))return!0;l=l.next}while(l!==r);return!1})(i,t)&&(Da(i,t)&&Da(t,i)&&(function(r,s){let l=r,u=!1,d=(r.x+s.x)/2,f=(r.y+s.y)/2;do l.y>f!=l.next.y>f&&l.next.y!==l.y&&d<(l.next.x-l.x)*(f-l.y)/(l.next.y-l.y)+l.x&&(u=!u),l=l.next;while(l!==r);return u})(i,t)&&(Ht(i.prev,i,t.prev)||Ht(i,t.prev,t))||Nl(i,t)&&Ht(i.prev,i,i.next)>0&&Ht(t.prev,t,t.next)>0)}function Ht(i,t,r){return(t.y-i.y)*(r.x-t.x)-(t.x-i.x)*(r.y-t.y)}function Nl(i,t){return i.x===t.x&&i.y===t.y}function lu(i,t,r,s){let l=Ul(Ht(i,t,r)),u=Ul(Ht(i,t,s)),d=Ul(Ht(r,s,i)),f=Ul(Ht(r,s,t));return l!==u&&d!==f||!(l!==0||!Vl(i,r,t))||!(u!==0||!Vl(i,s,t))||!(d!==0||!Vl(r,i,s))||!(f!==0||!Vl(r,t,s))}function Vl(i,t,r){return t.x<=Math.max(i.x,r.x)&&t.x>=Math.min(i.x,r.x)&&t.y<=Math.max(i.y,r.y)&&t.y>=Math.min(i.y,r.y)}function Ul(i){return i>0?1:i<0?-1:0}function Da(i,t){return Ht(i.prev,i,i.next)<0?Ht(i,t,i.next)>=0&&Ht(i,i.prev,t)>=0:Ht(i,t,i.prev)<0||Ht(i,i.next,t)<0}function cu(i,t){let r=Hc(i.i,i.x,i.y),s=Hc(t.i,t.x,t.y),l=i.next,u=t.prev;return i.next=t,t.prev=i,r.next=l,l.prev=r,s.next=r,r.prev=s,u.next=s,s.prev=u,s}function hu(i,t,r,s){let l=Hc(i,t,r);return s?(l.next=s.next,l.prev=s,s.next.prev=l,s.next=l):(l.prev=l,l.next=l),l}function Ra(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 Hc(i,t,r){return{i,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Wc(i,t,r){let s=r.patternDependencies,l=!1;for(let u of t){let d=u.paint.get(`${i}-pattern`);d.isConstant()||(l=!0);let f=d.constantOr(null);f&&(l=!0,s[f.to]=!0,s[f.from]=!0)}return l}function Xc(i,t,r,s,l){let u=l.patternDependencies;for(let d of t){let f=d.paint.get(`${i}-pattern`).value;if(f.kind!=="constant"){let g=f.evaluate({zoom:s-1},r,{},l.availableImages),x=f.evaluate({zoom:s},r,{},l.availableImages),v=f.evaluate({zoom:s+1},r,{},l.availableImages);g=g&&g.name?g.name:g,x=x&&x.name?x.name:x,v=v&&v.name?v.name:v,u[g]=!0,u[x]=!0,u[v]=!0,r.patterns[d.id]={min:g,mid:x,max:v}}}return r}class Kc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Cr,this.indexArray=new hr,this.indexArray2=new oi,this.programConfigurations=new Ls(t.layers,t.zoom),this.segments=new ct,this.segments2=new ct,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(t,r,s){this.hasPattern=Wc("fill",this.layers,r);let l=this.layers[0].layout.get("fill-sort-key"),u=!l.isConstant(),d=[];for(let{feature:f,id:g,index:x,sourceLayerIndex:v}of t){let w=this.layers[0]._featureFilter.needGeometry,C=Rs(f,w);if(!this.layers[0]._featureFilter.filter(new At(this.zoom),C,s))continue;let A=u?l.evaluate(C,{},s,r.availableImages):void 0,k={id:g,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?C.geometry:Ds(f),patterns:{},sortKey:A};d.push(k)}u&&d.sort(((f,g)=>f.sortKey-g.sortKey));for(let f of d){let{geometry:g,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){let w=Xc("fill",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,g,x,s,{});r.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(let l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,_p),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,r,s,l,u){for(let d of Ks(r,500)){let f=0;for(let A of d)f+=A.length;let g=this.segments.prepareSegment(f,this.layoutVertexArray,this.indexArray),x=g.vertexLength,v=[],w=[];for(let A of d){if(A.length===0)continue;A!==d[0]&&w.push(v.length/2);let k=this.segments2.prepareSegment(A.length,this.layoutVertexArray,this.indexArray2),z=k.vertexLength;this.layoutVertexArray.emplaceBack(A[0].x,A[0].y),this.indexArray2.emplaceBack(z+A.length-1,z),v.push(A[0].x),v.push(A[0].y);for(let O=1;O<A.length;O++)this.layoutVertexArray.emplaceBack(A[O].x,A[O].y),this.indexArray2.emplaceBack(z+O-1,z+O),v.push(A[O].x),v.push(A[O].y);k.vertexLength+=A.length,k.primitiveLength+=A.length}let C=ou(v,w);for(let A=0;A<C.length;A+=3)this.indexArray.emplaceBack(x+C[A],x+C[A+1],x+C[A+2]);g.vertexLength+=f,g.primitiveLength+=C.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,u,l)}}let uu,du;ke("FillBucket",Kc,{omit:["layers","patternFeatures"]});var Pp={get paint(){return du=du||new h({"fill-antialias":new De(oe.paint_fill["fill-antialias"]),"fill-opacity":new je(oe.paint_fill["fill-opacity"]),"fill-color":new je(oe.paint_fill["fill-color"]),"fill-outline-color":new je(oe.paint_fill["fill-outline-color"]),"fill-translate":new De(oe.paint_fill["fill-translate"]),"fill-translate-anchor":new De(oe.paint_fill["fill-translate-anchor"]),"fill-pattern":new _o(oe.paint_fill["fill-pattern"])})},get layout(){return uu=uu||new h({"fill-sort-key":new je(oe.layout_fill["fill-sort-key"])})}};class Mp extends n{constructor(t){super(t,Pp)}recalculate(t,r){super.recalculate(t,r);let s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Kc(t)}queryRadius(){return Bl(this.paint.get("fill-translate"))}queryIntersectsFeature(t,r,s,l,u,d,f){return Wh(Fl(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),d.angle,f),l)}isTileClipped(){return!0}}let Ap=m([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Ep=m([{name:"a_centroid",components:2,type:"Int16"}],4),{members:kp}=Ap;var Jn={},zp=Ce,pu=Mo;function Mo(i,t,r,s,l){this.properties={},this.extent=r,this.type=0,this._pbf=i,this._geometry=-1,this._keys=s,this._values=l,i.readFields(Lp,this,t)}function Lp(i,t,r){i==1?t.id=r.readVarint():i==2?(function(s,l){for(var u=s.readVarint()+s.pos;s.pos<u;){var d=l._keys[s.readVarint()],f=l._values[s.readVarint()];l.properties[d]=f}})(r,t):i==3?t.type=r.readVarint():i==4&&(t._geometry=r.pos)}function Dp(i){for(var t,r,s=0,l=0,u=i.length,d=u-1;l<u;d=l++)s+=((r=i[d]).x-(t=i[l]).x)*(t.y+r.y);return s}Mo.types=["Unknown","Point","LineString","Polygon"],Mo.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var t,r=i.readVarint()+i.pos,s=1,l=0,u=0,d=0,f=[];i.pos<r;){if(l<=0){var g=i.readVarint();s=7&g,l=g>>3}if(l--,s===1||s===2)u+=i.readSVarint(),d+=i.readSVarint(),s===1&&(t&&f.push(t),t=[]),t.push(new zp(u,d));else{if(s!==7)throw new Error("unknown command "+s);t&&t.push(t[0].clone())}}return t&&f.push(t),f},Mo.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var t=i.readVarint()+i.pos,r=1,s=0,l=0,u=0,d=1/0,f=-1/0,g=1/0,x=-1/0;i.pos<t;){if(s<=0){var v=i.readVarint();r=7&v,s=v>>3}if(s--,r===1||r===2)(l+=i.readSVarint())<d&&(d=l),l>f&&(f=l),(u+=i.readSVarint())<g&&(g=u),u>x&&(x=u);else if(r!==7)throw new Error("unknown command "+r)}return[d,g,f,x]},Mo.prototype.toGeoJSON=function(i,t,r){var s,l,u=this.extent*Math.pow(2,r),d=this.extent*i,f=this.extent*t,g=this.loadGeometry(),x=Mo.types[this.type];function v(A){for(var k=0;k<A.length;k++){var z=A[k];A[k]=[360*(z.x+d)/u-180,360/Math.PI*Math.atan(Math.exp((180-360*(z.y+f)/u)*Math.PI/180))-90]}}switch(this.type){case 1:var w=[];for(s=0;s<g.length;s++)w[s]=g[s][0];v(g=w);break;case 2:for(s=0;s<g.length;s++)v(g[s]);break;case 3:for(g=(function(A){var k=A.length;if(k<=1)return[A];for(var z,O,j=[],ie=0;ie<k;ie++){var H=Dp(A[ie]);H!==0&&(O===void 0&&(O=H<0),O===H<0?(z&&j.push(z),z=[A[ie]]):z.push(A[ie]))}return z&&j.push(z),j})(g),s=0;s<g.length;s++)for(l=0;l<g[s].length;l++)v(g[s][l])}g.length===1?g=g[0]:x="Multi"+x;var C={type:"Feature",geometry:{type:x,coordinates:g},properties:this.properties};return"id"in this&&(C.id=this.id),C};var Rp=pu,fu=mu;function mu(i,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=i,this._keys=[],this._values=[],this._features=[],i.readFields(Bp,this,t),this.length=this._features.length}function Bp(i,t,r){i===15?t.version=r.readVarint():i===1?t.name=r.readString():i===5?t.extent=r.readVarint():i===2?t._features.push(r.pos):i===3?t._keys.push(r.readString()):i===4&&t._values.push((function(s){for(var l=null,u=s.readVarint()+s.pos;s.pos<u;){var d=s.readVarint()>>3;l=d===1?s.readString():d===2?s.readFloat():d===3?s.readDouble():d===4?s.readVarint64():d===5?s.readVarint():d===6?s.readSVarint():d===7?s.readBoolean():null}return l})(r))}mu.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var t=this._pbf.readVarint()+this._pbf.pos;return new Rp(this._pbf,t,this.extent,this._keys,this._values)};var Fp=fu;function Op(i,t,r){if(i===3){var s=new Fp(r,r.readVarint()+r.pos);s.length&&(t[s.name]=s)}}Jn.VectorTile=function(i,t){this.layers=i.readFields(Op,{},t)},Jn.VectorTileFeature=pu,Jn.VectorTileLayer=fu;let Np=Jn.VectorTileFeature.types,Jc=Math.pow(2,13);function Ba(i,t,r,s,l,u,d,f){i.emplaceBack(t,r,2*Math.floor(s*Jc)+d,l*Jc*2,u*Jc*2,Math.round(f))}class Yc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Zn,this.centroidVertexArray=new di,this.indexArray=new hr,this.programConfigurations=new Ls(t.layers,t.zoom),this.segments=new ct,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(t,r,s){this.features=[],this.hasPattern=Wc("fill-extrusion",this.layers,r);for(let{feature:l,id:u,index:d,sourceLayerIndex:f}of t){let g=this.layers[0]._featureFilter.needGeometry,x=Rs(l,g);if(!this.layers[0]._featureFilter.filter(new At(this.zoom),x,s))continue;let v={id:u,sourceLayerIndex:f,index:d,geometry:g?x.geometry:Ds(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(Xc("fill-extrusion",this.layers,v,this.zoom,r)):this.addFeature(v,v.geometry,d,s,{}),r.featureIndex.insert(l,v.geometry,d,f,this.index,!0)}}addFeatures(t,r,s){for(let l of this.features){let{geometry:u}=l;this.addFeature(l,u,l.index,r,s)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kp),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Ep.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,r,s,l,u){for(let d of Ks(r,500)){let f={x:0,y:0,vertexCount:0},g=0;for(let k of d)g+=k.length;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let k of d){if(k.length===0||Up(k))continue;let z=0;for(let O=0;O<k.length;O++){let j=k[O];if(O>=1){let ie=k[O-1];if(!Vp(j,ie)){x.vertexLength+4>ct.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let H=j.sub(ie)._perp()._unit(),ee=ie.dist(j);z+ee>32768&&(z=0),Ba(this.layoutVertexArray,j.x,j.y,H.x,H.y,0,0,z),Ba(this.layoutVertexArray,j.x,j.y,H.x,H.y,0,1,z),f.x+=2*j.x,f.y+=2*j.y,f.vertexCount+=2,z+=ee,Ba(this.layoutVertexArray,ie.x,ie.y,H.x,H.y,0,0,z),Ba(this.layoutVertexArray,ie.x,ie.y,H.x,H.y,0,1,z),f.x+=2*ie.x,f.y+=2*ie.y,f.vertexCount+=2;let ae=x.vertexLength;this.indexArray.emplaceBack(ae,ae+2,ae+1),this.indexArray.emplaceBack(ae+1,ae+2,ae+3),x.vertexLength+=4,x.primitiveLength+=2}}}}if(x.vertexLength+g>ct.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(g,this.layoutVertexArray,this.indexArray)),Np[t.type]!=="Polygon")continue;let v=[],w=[],C=x.vertexLength;for(let k of d)if(k.length!==0){k!==d[0]&&w.push(v.length/2);for(let z=0;z<k.length;z++){let O=k[z];Ba(this.layoutVertexArray,O.x,O.y,0,0,1,1,0),f.x+=O.x,f.y+=O.y,f.vertexCount+=1,v.push(O.x),v.push(O.y)}}let A=ou(v,w);for(let k=0;k<A.length;k+=3)this.indexArray.emplaceBack(C+A[k],C+A[k+2],C+A[k+1]);x.primitiveLength+=A.length/3,x.vertexLength+=g;for(let k=0;k<f.vertexCount;k++){let z=Math.floor(f.x/f.vertexCount),O=Math.floor(f.y/f.vertexCount);this.centroidVertexArray.emplaceBack(z,O)}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,u,l)}}function Vp(i,t){return i.x===t.x&&(i.x<0||i.x>Kt)||i.y===t.y&&(i.y<0||i.y>Kt)}function Up(i){return i.every((t=>t.x<0))||i.every((t=>t.x>Kt))||i.every((t=>t.y<0))||i.every((t=>t.y>Kt))}let gu;ke("FillExtrusionBucket",Yc,{omit:["layers","features"]});var jp={get paint(){return gu=gu||new h({"fill-extrusion-opacity":new De(oe["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new je(oe["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new De(oe["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new De(oe["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new _o(oe["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new je(oe["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new je(oe["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new De(oe["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class $p extends n{constructor(t){super(t,jp)}createBucket(t){return new Yc(t)}queryRadius(){return Bl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,r,s,l,u,d,f,g){let x=Fl(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),d.angle,f),v=this.paint.get("fill-extrusion-height").evaluate(r,s),w=this.paint.get("fill-extrusion-base").evaluate(r,s),C=(function(k,z,O,j){let ie=[];for(let H of k){let ee=[H.x,H.y,0,1];Ol(ee,ee,z),ie.push(new pe(ee[0]/ee[3],ee[1]/ee[3]))}return ie})(x,g),A=(function(k,z,O,j){let ie=[],H=[],ee=j[8]*z,ae=j[9]*z,fe=j[10]*z,Me=j[11]*z,Ue=j[8]*O,Ie=j[9]*O,we=j[10]*O,Fe=j[11]*O;for(let Le of k){let Ee=[],he=[];for(let Oe of Le){let Be=Oe.x,Ge=Oe.y,Tt=j[0]*Be+j[4]*Ge+j[12],St=j[1]*Be+j[5]*Ge+j[13],ii=j[2]*Be+j[6]*Ge+j[14],Pr=j[3]*Be+j[7]*Ge+j[15],mi=ii+fe,ri=Pr+Me,Ei=Tt+Ue,ki=St+Ie,zi=ii+we,$t=Pr+Fe,ni=new pe((Tt+ee)/ri,(St+ae)/ri);ni.z=mi/ri,Ee.push(ni);let Si=new pe(Ei/$t,ki/$t);Si.z=zi/$t,he.push(Si)}ie.push(Ee),H.push(he)}return[ie,H]})(l,w,v,g);return(function(k,z,O){let j=1/0;Wh(O,z)&&(j=_u(O,z[0]));for(let ie=0;ie<z.length;ie++){let H=z[ie],ee=k[ie];for(let ae=0;ae<H.length-1;ae++){let fe=H[ae],Me=[fe,H[ae+1],ee[ae+1],ee[ae],fe];Hh(O,Me)&&(j=Math.min(j,_u(O,Me)))}}return j!==1/0&&j})(A[0],A[1],C)}}function Fa(i,t){return i.x*t.x+i.y*t.y}function _u(i,t){if(i.length===1){let r=0,s=t[r++],l;for(;!l||s.equals(l);)if(l=t[r++],!l)return 1/0;for(;r<t.length;r++){let u=t[r],d=i[0],f=l.sub(s),g=u.sub(s),x=d.sub(s),v=Fa(f,f),w=Fa(f,g),C=Fa(g,g),A=Fa(x,f),k=Fa(x,g),z=v*C-w*w,O=(C*A-w*k)/z,j=(v*k-w*A)/z,ie=s.z*(1-O-j)+l.z*O+u.z*j;if(isFinite(ie))return ie}return 1/0}{let r=1/0;for(let s of t)r=Math.min(r,s.z);return r}}let qp=m([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:Zp}=qp,Gp=m([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:Hp}=Gp,Wp=Jn.VectorTileFeature.types,Xp=Math.cos(Math.PI/180*37.5),yu=Math.pow(2,14)/.5;class Qc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((r=>{this.gradients[r.id]={}})),this.layoutVertexArray=new xo,this.layoutVertexArray2=new Gn,this.indexArray=new hr,this.programConfigurations=new Ls(t.layers,t.zoom),this.segments=new ct,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(t,r,s){this.hasPattern=Wc("line",this.layers,r);let l=this.layers[0].layout.get("line-sort-key"),u=!l.isConstant(),d=[];for(let{feature:f,id:g,index:x,sourceLayerIndex:v}of t){let w=this.layers[0]._featureFilter.needGeometry,C=Rs(f,w);if(!this.layers[0]._featureFilter.filter(new At(this.zoom),C,s))continue;let A=u?l.evaluate(C,{},s):void 0,k={id:g,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?C.geometry:Ds(f),patterns:{},sortKey:A};d.push(k)}u&&d.sort(((f,g)=>f.sortKey-g.sortKey));for(let f of d){let{geometry:g,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){let w=Xc("line",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,g,x,s,{});r.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(let l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Hp)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Zp),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,r,s,l,u){let d=this.layers[0].layout,f=d.get("line-join").evaluate(t,{}),g=d.get("line-cap"),x=d.get("line-miter-limit"),v=d.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(let w of r)this.addLine(w,t,f,g,x,v);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,u,l)}addLine(t,r,s,l,u,d){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let j=0;j<t.length-1;j++)this.totalDistance+=t[j].dist(t[j+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let f=Wp[r.type]==="Polygon",g=t.length;for(;g>=2&&t[g-1].equals(t[g-2]);)g--;let x=0;for(;x<g-1&&t[x].equals(t[x+1]);)x++;if(g<(f?3:2))return;s==="bevel"&&(u=1.05);let v=this.overscaling<=16?15*Kt/(512*this.overscaling):0,w=this.segments.prepareSegment(10*g,this.layoutVertexArray,this.indexArray),C,A,k,z,O;this.e1=this.e2=-1,f&&(C=t[g-2],O=t[x].sub(C)._unit()._perp());for(let j=x;j<g;j++){if(k=j===g-1?f?t[x+1]:void 0:t[j+1],k&&t[j].equals(k))continue;O&&(z=O),C&&(A=C),C=t[j],O=k?k.sub(C)._unit()._perp():z,z=z||O;let ie=z.add(O);ie.x===0&&ie.y===0||ie._unit();let H=z.x*O.x+z.y*O.y,ee=ie.x*O.x+ie.y*O.y,ae=ee!==0?1/ee:1/0,fe=2*Math.sqrt(2-2*ee),Me=ee<Xp&&A&&k,Ue=z.x*O.y-z.y*O.x>0;if(Me&&j>x){let Fe=C.dist(A);if(Fe>2*v){let Le=C.sub(C.sub(A)._mult(v/Fe)._round());this.updateDistance(A,Le),this.addCurrentVertex(Le,z,0,0,w),A=Le}}let Ie=A&&k,we=Ie?s:f?"butt":l;if(Ie&&we==="round"&&(ae<d?we="miter":ae<=2&&(we="fakeround")),we==="miter"&&ae>u&&(we="bevel"),we==="bevel"&&(ae>2&&(we="flipbevel"),ae<u&&(we="miter")),A&&this.updateDistance(A,C),we==="miter")ie._mult(ae),this.addCurrentVertex(C,ie,0,0,w);else if(we==="flipbevel"){if(ae>100)ie=O.mult(-1);else{let Fe=ae*z.add(O).mag()/z.sub(O).mag();ie._perp()._mult(Fe*(Ue?-1:1))}this.addCurrentVertex(C,ie,0,0,w),this.addCurrentVertex(C,ie.mult(-1),0,0,w)}else if(we==="bevel"||we==="fakeround"){let Fe=-Math.sqrt(ae*ae-1),Le=Ue?Fe:0,Ee=Ue?0:Fe;if(A&&this.addCurrentVertex(C,z,Le,Ee,w),we==="fakeround"){let he=Math.round(180*fe/Math.PI/20);for(let Oe=1;Oe<he;Oe++){let Be=Oe/he;if(Be!==.5){let Tt=Be-.5;Be+=Be*Tt*(Be-1)*((1.0904+H*(H*(3.55645-1.43519*H)-3.2452))*Tt*Tt+(.848013+H*(.215638*H-1.06021)))}let Ge=O.sub(z)._mult(Be)._add(z)._unit()._mult(Ue?-1:1);this.addHalfVertex(C,Ge.x,Ge.y,!1,Ue,0,w)}}k&&this.addCurrentVertex(C,O,-Le,-Ee,w)}else if(we==="butt")this.addCurrentVertex(C,ie,0,0,w);else if(we==="square"){let Fe=A?1:-1;this.addCurrentVertex(C,ie,Fe,Fe,w)}else we==="round"&&(A&&(this.addCurrentVertex(C,z,0,0,w),this.addCurrentVertex(C,z,1,1,w,!0)),k&&(this.addCurrentVertex(C,O,-1,-1,w,!0),this.addCurrentVertex(C,O,0,0,w)));if(Me&&j<g-1){let Fe=C.dist(k);if(Fe>2*v){let Le=C.add(k.sub(C)._mult(v/Fe)._round());this.updateDistance(C,Le),this.addCurrentVertex(Le,O,0,0,w),C=Le}}}}addCurrentVertex(t,r,s,l,u,d=!1){let f=r.y*l-r.x,g=-r.y-r.x*l;this.addHalfVertex(t,r.x+r.y*s,r.y-r.x*s,d,!1,s,u),this.addHalfVertex(t,f,g,d,!0,-l,u),this.distance>yu/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,r,s,l,u,d))}addHalfVertex({x:t,y:r},s,l,u,d,f,g){let x=.5*(this.lineClips?this.scaledDistance*(yu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(u?1:0),(r<<1)+(d?1:0),Math.round(63*s)+128,Math.round(63*l)+128,1+(f===0?0:f<0?-1:1)|(63&x)<<2,x>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let v=g.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,v),g.primitiveLength++),d?this.e2=v:this.e1=v}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,r){this.distance+=t.dist(r),this.updateScaledDistance()}}let xu,vu;ke("LineBucket",Qc,{omit:["layers","patternFeatures"]});var bu={get paint(){return vu=vu||new h({"line-opacity":new je(oe.paint_line["line-opacity"]),"line-color":new je(oe.paint_line["line-color"]),"line-translate":new De(oe.paint_line["line-translate"]),"line-translate-anchor":new De(oe.paint_line["line-translate-anchor"]),"line-width":new je(oe.paint_line["line-width"]),"line-gap-width":new je(oe.paint_line["line-gap-width"]),"line-offset":new je(oe.paint_line["line-offset"]),"line-blur":new je(oe.paint_line["line-blur"]),"line-dasharray":new yo(oe.paint_line["line-dasharray"]),"line-pattern":new _o(oe.paint_line["line-pattern"]),"line-gradient":new Pa(oe.paint_line["line-gradient"])})},get layout(){return xu=xu||new h({"line-cap":new De(oe.layout_line["line-cap"]),"line-join":new je(oe.layout_line["line-join"]),"line-miter-limit":new De(oe.layout_line["line-miter-limit"]),"line-round-limit":new De(oe.layout_line["line-round-limit"]),"line-sort-key":new je(oe.layout_line["line-sort-key"])})}};class Kp extends je{possiblyEvaluate(t,r){return r=new At(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(t,r)}evaluate(t,r,s,l){return r=Mt({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(t,r,s,l)}}let jl;class Jp extends n{constructor(t){super(t,bu),this.gradientVersion=0,jl||(jl=new Kp(bu.paint.properties["line-width"].specification),jl.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){let r=this.gradientExpression();this.stepInterpolant=!!(function(s){return s._styleExpression!==void 0})(r)&&r._styleExpression.expression instanceof Cn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,r){super.recalculate(t,r),this.paint._values["line-floorwidth"]=jl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Qc(t)}queryRadius(t){let r=t,s=wu(Ea("line-width",this,r),Ea("line-gap-width",this,r)),l=Ea("line-offset",this,r);return s/2+Math.abs(l)+Bl(this.paint.get("line-translate"))}queryIntersectsFeature(t,r,s,l,u,d,f){let g=Fl(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),d.angle,f),x=f/2*wu(this.paint.get("line-width").evaluate(r,s),this.paint.get("line-gap-width").evaluate(r,s)),v=this.paint.get("line-offset").evaluate(r,s);return v&&(l=(function(w,C){let A=[];for(let k=0;k<w.length;k++){let z=w[k],O=[];for(let j=0;j<z.length;j++){let ie=z[j-1],H=z[j],ee=z[j+1],ae=j===0?new pe(0,0):H.sub(ie)._unit()._perp(),fe=j===z.length-1?new pe(0,0):ee.sub(H)._unit()._perp(),Me=ae._add(fe)._unit(),Ue=Me.x*fe.x+Me.y*fe.y;Ue!==0&&Me._mult(1/Ue),O.push(Me._mult(C)._add(H))}A.push(O)}return A})(l,v*f)),(function(w,C,A){for(let k=0;k<C.length;k++){let z=C[k];if(w.length>=3){for(let O=0;O<z.length;O++)if(Io(w,z[O]))return!0}if(op(w,z,A))return!0}return!1})(g,l,x)}isTileClipped(){return!0}}function wu(i,t){return t>0?t+2*i:i}let Yp=m([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Qp=m([{name:"a_projected_pos",components:3,type:"Float32"}],4);m([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);let ef=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"}]);let Su=m([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),tf=m([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function rf(i,t,r){return i.sections.forEach((s=>{s.text=(function(l,u,d){let f=u.layout.get("text-transform").evaluate(d,{});return f==="uppercase"?l=l.toLocaleUpperCase():f==="lowercase"&&(l=l.toLocaleLowerCase()),Ni.applyArabicShaping&&(l=Ni.applyArabicShaping(l)),l})(s.text,t,r)})),i}m([{name:"triangle",components:3,type:"Uint16"}]),m([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),m([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),m([{type:"Float32",name:"offsetX"}]),m([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),m([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);let Oa={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};var ei=24,Tu=wt,Iu=function(i,t,r,s,l){var u,d,f=8*l-s-1,g=(1<<f)-1,x=g>>1,v=-7,w=r?l-1:0,C=r?-1:1,A=i[t+w];for(w+=C,u=A&(1<<-v)-1,A>>=-v,v+=f;v>0;u=256*u+i[t+w],w+=C,v-=8);for(d=u&(1<<-v)-1,u>>=-v,v+=s;v>0;d=256*d+i[t+w],w+=C,v-=8);if(u===0)u=1-x;else{if(u===g)return d?NaN:1/0*(A?-1:1);d+=Math.pow(2,s),u-=x}return(A?-1:1)*d*Math.pow(2,u-s)},Cu=function(i,t,r,s,l,u){var d,f,g,x=8*u-l-1,v=(1<<x)-1,w=v>>1,C=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=s?0:u-1,k=s?1:-1,z=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,d=v):(d=Math.floor(Math.log(t)/Math.LN2),t*(g=Math.pow(2,-d))<1&&(d--,g*=2),(t+=d+w>=1?C/g:C*Math.pow(2,1-w))*g>=2&&(d++,g/=2),d+w>=v?(f=0,d=v):d+w>=1?(f=(t*g-1)*Math.pow(2,l),d+=w):(f=t*Math.pow(2,w-1)*Math.pow(2,l),d=0));l>=8;i[r+A]=255&f,A+=k,f/=256,l-=8);for(d=d<<l|f,x+=l;x>0;i[r+A]=255&d,A+=k,d/=256,x-=8);i[r+A-k]|=128*z};function wt(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}wt.Varint=0,wt.Fixed64=1,wt.Bytes=2,wt.Fixed32=5;var eh=4294967296,Pu=1/eh,Mu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function gn(i){return i.type===wt.Bytes?i.readVarint()+i.pos:i.pos+1}function Ao(i,t,r){return r?4294967296*t+(i>>>0):4294967296*(t>>>0)+(i>>>0)}function Au(i,t,r){var s=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(s);for(var l=r.pos-1;l>=i;l--)r.buf[l+s]=r.buf[l]}function nf(i,t){for(var r=0;r<i.length;r++)t.writeVarint(i[r])}function sf(i,t){for(var r=0;r<i.length;r++)t.writeSVarint(i[r])}function of(i,t){for(var r=0;r<i.length;r++)t.writeFloat(i[r])}function af(i,t){for(var r=0;r<i.length;r++)t.writeDouble(i[r])}function lf(i,t){for(var r=0;r<i.length;r++)t.writeBoolean(i[r])}function cf(i,t){for(var r=0;r<i.length;r++)t.writeFixed32(i[r])}function hf(i,t){for(var r=0;r<i.length;r++)t.writeSFixed32(i[r])}function uf(i,t){for(var r=0;r<i.length;r++)t.writeFixed64(i[r])}function df(i,t){for(var r=0;r<i.length;r++)t.writeSFixed64(i[r])}function $l(i,t){return(i[t]|i[t+1]<<8|i[t+2]<<16)+16777216*i[t+3]}function Eo(i,t,r){i[r]=t,i[r+1]=t>>>8,i[r+2]=t>>>16,i[r+3]=t>>>24}function Eu(i,t){return(i[t]|i[t+1]<<8|i[t+2]<<16)+(i[t+3]<<24)}wt.prototype={destroy:function(){this.buf=null},readFields:function(i,t,r){for(r=r||this.length;this.pos<r;){var s=this.readVarint(),l=s>>3,u=this.pos;this.type=7&s,i(l,t,this),this.pos===u&&this.skip(s)}return t},readMessage:function(i,t){return this.readFields(i,t,this.readVarint()+this.pos)},readFixed32:function(){var i=$l(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=Eu(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=$l(this.buf,this.pos)+$l(this.buf,this.pos+4)*eh;return this.pos+=8,i},readSFixed64:function(){var i=$l(this.buf,this.pos)+Eu(this.buf,this.pos+4)*eh;return this.pos+=8,i},readFloat:function(){var i=Iu(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=Iu(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var t,r,s=this.buf;return t=127&(r=s[this.pos++]),r<128?t:(t|=(127&(r=s[this.pos++]))<<7,r<128?t:(t|=(127&(r=s[this.pos++]))<<14,r<128?t:(t|=(127&(r=s[this.pos++]))<<21,r<128?t:(function(l,u,d){var f,g,x=d.buf;if(f=(112&(g=x[d.pos++]))>>4,g<128||(f|=(127&(g=x[d.pos++]))<<3,g<128)||(f|=(127&(g=x[d.pos++]))<<10,g<128)||(f|=(127&(g=x[d.pos++]))<<17,g<128)||(f|=(127&(g=x[d.pos++]))<<24,g<128)||(f|=(1&(g=x[d.pos++]))<<31,g<128))return Ao(l,f,u);throw new Error("Expected varint not more than 10 bytes")})(t|=(15&(r=s[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?(i+1)/-2:i/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var i=this.readVarint()+this.pos,t=this.pos;return this.pos=i,i-t>=12&&Mu?(function(r,s,l){return Mu.decode(r.subarray(s,l))})(this.buf,t,i):(function(r,s,l){for(var u="",d=s;d<l;){var f,g,x,v=r[d],w=null,C=v>239?4:v>223?3:v>191?2:1;if(d+C>l)break;C===1?v<128&&(w=v):C===2?(192&(f=r[d+1]))==128&&(w=(31&v)<<6|63&f)<=127&&(w=null):C===3?(g=r[d+2],(192&(f=r[d+1]))==128&&(192&g)==128&&((w=(15&v)<<12|(63&f)<<6|63&g)<=2047||w>=55296&&w<=57343)&&(w=null)):C===4&&(g=r[d+2],x=r[d+3],(192&(f=r[d+1]))==128&&(192&g)==128&&(192&x)==128&&((w=(15&v)<<18|(63&f)<<12|(63&g)<<6|63&x)<=65535||w>=1114112)&&(w=null)),w===null?(w=65533,C=1):w>65535&&(w-=65536,u+=String.fromCharCode(w>>>10&1023|55296),w=56320|1023&w),u+=String.fromCharCode(w),d+=C}return u})(this.buf,t,i)},readBytes:function(){var i=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,i);return this.pos=i,t},readPackedVarint:function(i,t){if(this.type!==wt.Bytes)return i.push(this.readVarint(t));var r=gn(this);for(i=i||[];this.pos<r;)i.push(this.readVarint(t));return i},readPackedSVarint:function(i){if(this.type!==wt.Bytes)return i.push(this.readSVarint());var t=gn(this);for(i=i||[];this.pos<t;)i.push(this.readSVarint());return i},readPackedBoolean:function(i){if(this.type!==wt.Bytes)return i.push(this.readBoolean());var t=gn(this);for(i=i||[];this.pos<t;)i.push(this.readBoolean());return i},readPackedFloat:function(i){if(this.type!==wt.Bytes)return i.push(this.readFloat());var t=gn(this);for(i=i||[];this.pos<t;)i.push(this.readFloat());return i},readPackedDouble:function(i){if(this.type!==wt.Bytes)return i.push(this.readDouble());var t=gn(this);for(i=i||[];this.pos<t;)i.push(this.readDouble());return i},readPackedFixed32:function(i){if(this.type!==wt.Bytes)return i.push(this.readFixed32());var t=gn(this);for(i=i||[];this.pos<t;)i.push(this.readFixed32());return i},readPackedSFixed32:function(i){if(this.type!==wt.Bytes)return i.push(this.readSFixed32());var t=gn(this);for(i=i||[];this.pos<t;)i.push(this.readSFixed32());return i},readPackedFixed64:function(i){if(this.type!==wt.Bytes)return i.push(this.readFixed64());var t=gn(this);for(i=i||[];this.pos<t;)i.push(this.readFixed64());return i},readPackedSFixed64:function(i){if(this.type!==wt.Bytes)return i.push(this.readSFixed64());var t=gn(this);for(i=i||[];this.pos<t;)i.push(this.readSFixed64());return i},skip:function(i){var t=7&i;if(t===wt.Varint)for(;this.buf[this.pos++]>127;);else if(t===wt.Bytes)this.pos=this.readVarint()+this.pos;else if(t===wt.Fixed32)this.pos+=4;else{if(t!==wt.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(i,t){this.writeVarint(i<<3|t)},realloc:function(i){for(var t=this.length||16;t<this.pos+i;)t*=2;if(t!==this.length){var r=new Uint8Array(t);r.set(this.buf),this.buf=r,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(i){this.realloc(4),Eo(this.buf,i,this.pos),this.pos+=4},writeSFixed32:function(i){this.realloc(4),Eo(this.buf,i,this.pos),this.pos+=4},writeFixed64:function(i){this.realloc(8),Eo(this.buf,-1&i,this.pos),Eo(this.buf,Math.floor(i*Pu),this.pos+4),this.pos+=8},writeSFixed64:function(i){this.realloc(8),Eo(this.buf,-1&i,this.pos),Eo(this.buf,Math.floor(i*Pu),this.pos+4),this.pos+=8},writeVarint:function(i){(i=+i||0)>268435455||i<0?(function(t,r){var s,l;if(t>=0?(s=t%4294967296|0,l=t/4294967296|0):(l=~(-t/4294967296),4294967295^(s=~(-t%4294967296))?s=s+1|0:(s=0,l=l+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),(function(u,d,f){f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,f.buf[f.pos]=127&(u>>>=7)})(s,0,r),(function(u,d){var f=(7&u)<<4;d.buf[d.pos++]|=f|((u>>>=3)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u)))))})(l,r)})(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(!!i)},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var t=this.pos;this.pos=(function(s,l,u){for(var d,f,g=0;g<l.length;g++){if((d=l.charCodeAt(g))>55295&&d<57344){if(!f){d>56319||g+1===l.length?(s[u++]=239,s[u++]=191,s[u++]=189):f=d;continue}if(d<56320){s[u++]=239,s[u++]=191,s[u++]=189,f=d;continue}d=f-55296<<10|d-56320|65536,f=null}else f&&(s[u++]=239,s[u++]=191,s[u++]=189,f=null);d<128?s[u++]=d:(d<2048?s[u++]=d>>6|192:(d<65536?s[u++]=d>>12|224:(s[u++]=d>>18|240,s[u++]=d>>12&63|128),s[u++]=d>>6&63|128),s[u++]=63&d|128)}return u})(this.buf,i,this.pos);var r=this.pos-t;r>=128&&Au(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),Cu(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),Cu(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var t=i.length;this.writeVarint(t),this.realloc(t);for(var r=0;r<t;r++)this.buf[this.pos++]=i[r]},writeRawMessage:function(i,t){this.pos++;var r=this.pos;i(t,this);var s=this.pos-r;s>=128&&Au(r,s,this),this.pos=r-1,this.writeVarint(s),this.pos+=s},writeMessage:function(i,t,r){this.writeTag(i,wt.Bytes),this.writeRawMessage(t,r)},writePackedVarint:function(i,t){t.length&&this.writeMessage(i,nf,t)},writePackedSVarint:function(i,t){t.length&&this.writeMessage(i,sf,t)},writePackedBoolean:function(i,t){t.length&&this.writeMessage(i,lf,t)},writePackedFloat:function(i,t){t.length&&this.writeMessage(i,of,t)},writePackedDouble:function(i,t){t.length&&this.writeMessage(i,af,t)},writePackedFixed32:function(i,t){t.length&&this.writeMessage(i,cf,t)},writePackedSFixed32:function(i,t){t.length&&this.writeMessage(i,hf,t)},writePackedFixed64:function(i,t){t.length&&this.writeMessage(i,uf,t)},writePackedSFixed64:function(i,t){t.length&&this.writeMessage(i,df,t)},writeBytesField:function(i,t){this.writeTag(i,wt.Bytes),this.writeBytes(t)},writeFixed32Field:function(i,t){this.writeTag(i,wt.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(i,t){this.writeTag(i,wt.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(i,t){this.writeTag(i,wt.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(i,t){this.writeTag(i,wt.Fixed64),this.writeSFixed64(t)},writeVarintField:function(i,t){this.writeTag(i,wt.Varint),this.writeVarint(t)},writeSVarintField:function(i,t){this.writeTag(i,wt.Varint),this.writeSVarint(t)},writeStringField:function(i,t){this.writeTag(i,wt.Bytes),this.writeString(t)},writeFloatField:function(i,t){this.writeTag(i,wt.Fixed32),this.writeFloat(t)},writeDoubleField:function(i,t){this.writeTag(i,wt.Fixed64),this.writeDouble(t)},writeBooleanField:function(i,t){this.writeVarintField(i,!!t)}};var th=Se(Tu);let ih=3;function pf(i,t,r){i===1&&r.readMessage(ff,t)}function ff(i,t,r){if(i===3){let{id:s,bitmap:l,width:u,height:d,left:f,top:g,advance:x}=r.readMessage(mf,{});t.push({id:s,bitmap:new za({width:u+2*ih,height:d+2*ih},l),metrics:{width:u,height:d,left:f,top:g,advance:x}})}}function mf(i,t,r){i===1?t.id=r.readVarint():i===2?t.bitmap=r.readBytes():i===3?t.width=r.readVarint():i===4?t.height=r.readVarint():i===5?t.left=r.readSVarint():i===6?t.top=r.readSVarint():i===7&&(t.advance=r.readVarint())}let ku=ih;function zu(i){let t=0,r=0;for(let d of i)t+=d.w*d.h,r=Math.max(r,d.w);i.sort(((d,f)=>f.h-d.h));let s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}],l=0,u=0;for(let d of i)for(let f=s.length-1;f>=0;f--){let g=s[f];if(!(d.w>g.w||d.h>g.h)){if(d.x=g.x,d.y=g.y,u=Math.max(u,d.y+d.h),l=Math.max(l,d.x+d.w),d.w===g.w&&d.h===g.h){let x=s.pop();f<s.length&&(s[f]=x)}else d.h===g.h?(g.x+=d.w,g.w-=d.w):d.w===g.w?(g.y+=d.h,g.h-=d.h):(s.push({x:g.x+d.w,y:g.y,w:g.w-d.w,h:d.h}),g.y+=d.h,g.h-=d.h);break}}return{w:l,h:u,fill:t/(l*u)||0}}let Ui=1;class rh{constructor(t,{pixelRatio:r,version:s,stretchX:l,stretchY:u,content:d,textFitWidth:f,textFitHeight:g}){this.paddedRect=t,this.pixelRatio=r,this.stretchX=l,this.stretchY=u,this.content=d,this.version=s,this.textFitWidth=f,this.textFitHeight=g}get tl(){return[this.paddedRect.x+Ui,this.paddedRect.y+Ui]}get br(){return[this.paddedRect.x+this.paddedRect.w-Ui,this.paddedRect.y+this.paddedRect.h-Ui]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2*Ui)/this.pixelRatio,(this.paddedRect.h-2*Ui)/this.pixelRatio]}}class Lu{constructor(t,r){let s={},l={};this.haveRenderCallbacks=[];let u=[];this.addImages(t,s,u),this.addImages(r,l,u);let{w:d,h:f}=zu(u),g=new ur({width:d||1,height:f||1});for(let x in t){let v=t[x],w=s[x].paddedRect;ur.copy(v.data,g,{x:0,y:0},{x:w.x+Ui,y:w.y+Ui},v.data)}for(let x in r){let v=r[x],w=l[x].paddedRect,C=w.x+Ui,A=w.y+Ui,k=v.data.width,z=v.data.height;ur.copy(v.data,g,{x:0,y:0},{x:C,y:A},v.data),ur.copy(v.data,g,{x:0,y:z-1},{x:C,y:A-1},{width:k,height:1}),ur.copy(v.data,g,{x:0,y:0},{x:C,y:A+z},{width:k,height:1}),ur.copy(v.data,g,{x:k-1,y:0},{x:C-1,y:A},{width:1,height:z}),ur.copy(v.data,g,{x:0,y:0},{x:C+k,y:A},{width:1,height:z})}this.image=g,this.iconPositions=s,this.patternPositions=l}addImages(t,r,s){for(let l in t){let u=t[l],d={x:0,y:0,w:u.data.width+2*Ui,h:u.data.height+2*Ui};s.push(d),r[l]=new rh(d,u),u.hasRenderCallback&&this.haveRenderCallbacks.push(l)}}patchUpdatedImages(t,r){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(let s in t.updatedImages)this.patchUpdatedImage(this.iconPositions[s],t.getImage(s),r),this.patchUpdatedImage(this.patternPositions[s],t.getImage(s),r)}patchUpdatedImage(t,r,s){if(!t||!r||t.version===r.version)return;t.version=r.version;let[l,u]=t.tl;s.update(r.data,void 0,{x:l,y:u})}}var Yn;ke("ImagePosition",rh),ke("ImageAtlas",Lu),I.ah=void 0,(Yn=I.ah||(I.ah={}))[Yn.none=0]="none",Yn[Yn.horizontal=1]="horizontal",Yn[Yn.vertical=2]="vertical",Yn[Yn.horizontalOnly=3]="horizontalOnly";let Na=-17;class Va{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,r){let s=new Va;return s.scale=t||1,s.fontStack=r,s}static forImage(t){let r=new Va;return r.imageName=t,r}}class ko{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,r){let s=new ko;for(let l=0;l<t.sections.length;l++){let u=t.sections[l];u.image?s.addImageSection(u):s.addTextSection(u,r)}return s}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}getCharCode(t){return this.text.charCodeAt(t)}verticalizePunctuation(){this.text=(function(t){let r="";for(let s=0;s<t.length;s++){let l=t.charCodeAt(s+1)||null,u=t.charCodeAt(s-1)||null;r+=l&&Al(l)&&!Oa[t[s+1]]||u&&Al(u)&&!Oa[t[s-1]]||!Oa[t[s]]?t[s]:Oa[t[s]]}return r})(this.text)}trim(){let t=0;for(let s=0;s<this.text.length&&Zl[this.text.charCodeAt(s)];s++)t++;let r=this.text.length;for(let s=this.text.length-1;s>=0&&s>=t&&Zl[this.text.charCodeAt(s)];s--)r--;this.text=this.text.substring(t,r),this.sectionIndex=this.sectionIndex.slice(t,r)}substring(t,r){let s=new ko;return s.text=this.text.substring(t,r),s.sectionIndex=this.sectionIndex.slice(t,r),s.sections=this.sections,s}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,r)=>Math.max(t,this.sections[r].scale)),0)}addTextSection(t,r){this.text+=t.text,this.sections.push(Va.forText(t.scale,t.fontStack||r));let s=this.sections.length-1;for(let l=0;l<t.text.length;++l)this.sectionIndex.push(s)}addImageSection(t){let r=t.image?t.image.name:"";if(r.length===0)return void ze("Can't add FormattedSection with an empty image.");let s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCharCode(s),this.sections.push(Va.forImage(r)),this.sectionIndex.push(this.sections.length-1)):ze("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ql(i,t,r,s,l,u,d,f,g,x,v,w,C,A,k){let z=ko.fromFeature(i,l),O;w===I.ah.vertical&&z.verticalizePunctuation();let{processBidirectionalText:j,processStyledBidirectionalText:ie}=Ni;if(j&&z.sections.length===1){O=[];let ae=j(z.toString(),nh(z,x,u,t,s,A));for(let fe of ae){let Me=new ko;Me.text=fe,Me.sections=z.sections;for(let Ue=0;Ue<fe.length;Ue++)Me.sectionIndex.push(0);O.push(Me)}}else if(ie){O=[];let ae=ie(z.text,z.sectionIndex,nh(z,x,u,t,s,A));for(let fe of ae){let Me=new ko;Me.text=fe[0],Me.sectionIndex=fe[1],Me.sections=z.sections,O.push(Me)}}else O=(function(ae,fe){let Me=[],Ue=ae.text,Ie=0;for(let we of fe)Me.push(ae.substring(Ie,we)),Ie=we;return Ie<Ue.length&&Me.push(ae.substring(Ie,Ue.length)),Me})(z,nh(z,x,u,t,s,A));let H=[],ee={positionedLines:H,text:z.toString(),top:v[1],bottom:v[1],left:v[0],right:v[0],writingMode:w,iconsInText:!1,verticalizable:!1};return(function(ae,fe,Me,Ue,Ie,we,Fe,Le,Ee,he,Oe,Be){let Ge=0,Tt=Na,St=0,ii=0,Pr=Le==="right"?1:Le==="left"?0:.5,mi=0;for(let $t of Ie){$t.trim();let ni=$t.getMaxScale(),Si=(ni-1)*ei,gi={positionedGlyphs:[],lineOffset:0};ae.positionedLines[mi]=gi;let Li=gi.positionedGlyphs,_i=0;if(!$t.length()){Tt+=we,++mi;continue}for(let ji=0;ji<$t.length();ji++){let ft=$t.getSection(ji),Ct=$t.getSectionIndex(ji),Lt=$t.getCharCode(ji),Yi=0,Ot=null,Ro=null,Xr=null,Kr=ei,Mr=!(Ee===I.ah.horizontal||!Oe&&!Ia(Lt)||Oe&&(Zl[Lt]||(ri=Lt,/\p{sc=Arab}/u.test(String.fromCodePoint(ri)))));if(ft.imageName){let fr=Ue[ft.imageName];if(!fr)continue;Xr=ft.imageName,ae.iconsInText=ae.iconsInText||!0,Ro=fr.paddedRect;let ai=fr.displaySize;ft.scale=ft.scale*ei/Be,Ot={width:ai[0],height:ai[1],left:Ui,top:-ku,advance:Mr?ai[1]:ai[0]},Yi=Si+(ei-ai[1]*ft.scale),Kr=Ot.advance;let _n=Mr?ai[0]*ft.scale-ei*ni:ai[1]*ft.scale-ei*ni;_n>0&&_n>_i&&(_i=_n)}else{let fr=Me[ft.fontStack],ai=fr&&fr[Lt];if(ai&&ai.rect)Ro=ai.rect,Ot=ai.metrics;else{let _n=fe[ft.fontStack],Ga=_n&&_n[Lt];if(!Ga)continue;Ot=Ga.metrics}Yi=(ni-ft.scale)*ei}Mr?(ae.verticalizable=!0,Li.push({glyph:Lt,imageName:Xr,x:Ge,y:Tt+Yi,vertical:Mr,scale:ft.scale,fontStack:ft.fontStack,sectionIndex:Ct,metrics:Ot,rect:Ro}),Ge+=Kr*ft.scale+he):(Li.push({glyph:Lt,imageName:Xr,x:Ge,y:Tt+Yi,vertical:Mr,scale:ft.scale,fontStack:ft.fontStack,sectionIndex:Ct,metrics:Ot,rect:Ro}),Ge+=Ot.advance*ft.scale+he)}Li.length!==0&&(St=Math.max(Ge-he,St),xf(Li,0,Li.length-1,Pr,_i)),Ge=0;let pr=we*ni+_i;gi.lineOffset=Math.max(_i,Si),Tt+=pr,ii=Math.max(pr,ii),++mi}var ri;let Ei=Tt-Na,{horizontalAlign:ki,verticalAlign:zi}=sh(Fe);(function($t,ni,Si,gi,Li,_i,pr,ji,ft){let Ct=(ni-Si)*Li,Lt=0;Lt=_i!==pr?-ji*gi-Na:(-gi*ft+.5)*pr;for(let Yi of $t)for(let Ot of Yi.positionedGlyphs)Ot.x+=Ct,Ot.y+=Lt})(ae.positionedLines,Pr,ki,zi,St,ii,we,Ei,Ie.length),ae.top+=-zi*Ei,ae.bottom=ae.top+Ei,ae.left+=-ki*St,ae.right=ae.left+St})(ee,t,r,s,O,d,f,g,w,x,C,k),!(function(ae){for(let fe of ae)if(fe.positionedGlyphs.length!==0)return!1;return!0})(H)&&ee}let Zl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},gf={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},_f={40:!0};function Du(i,t,r,s,l,u){if(t.imageName){let d=s[t.imageName];return d?d.displaySize[0]*t.scale*ei/u+l:0}{let d=r[t.fontStack],f=d&&d[i];return f?f.metrics.advance*t.scale+l:0}}function Ru(i,t,r,s){let l=Math.pow(i-t,2);return s?i<t?l/2:2*l:l+Math.abs(r)*r}function yf(i,t,r){let s=0;return i===10&&(s-=1e4),r&&(s+=150),i!==40&&i!==65288||(s+=50),t!==41&&t!==65289||(s+=50),s}function Bu(i,t,r,s,l,u){let d=null,f=Ru(t,r,l,u);for(let g of s){let x=Ru(t-g.x,r,l,u)+g.badness;x<=f&&(d=g,f=x)}return{index:i,x:t,priorBreak:d,badness:f}}function Fu(i){return i?Fu(i.priorBreak).concat(i.index):[]}function nh(i,t,r,s,l,u){if(!i)return[];let d=[],f=(function(w,C,A,k,z,O){let j=0;for(let ie=0;ie<w.length();ie++){let H=w.getSection(ie);j+=Du(w.getCharCode(ie),H,k,z,C,O)}return j/Math.max(1,Math.ceil(j/A))})(i,t,r,s,l,u),g=i.text.indexOf("\u200B")>=0,x=0;for(let w=0;w<i.length();w++){let C=i.getSection(w),A=i.getCharCode(w);if(Zl[A]||(x+=Du(A,C,s,l,t,u)),w<i.length()-1){let k=!((v=A)<11904)&&(!!lt["CJK Compatibility Forms"](v)||!!lt["CJK Compatibility"](v)||!!lt["CJK Strokes"](v)||!!lt["CJK Symbols and Punctuation"](v)||!!lt["Enclosed CJK Letters and Months"](v)||!!lt["Halfwidth and Fullwidth Forms"](v)||!!lt["Ideographic Description Characters"](v)||!!lt["Vertical Forms"](v)||Ml.test(String.fromCodePoint(v)));(gf[A]||k||C.imageName||w!==i.length()-2&&_f[i.getCharCode(w+1)])&&d.push(Bu(w+1,x,f,d,yf(A,i.getCharCode(w+1),k&&g),!1))}}var v;return Fu(Bu(i.length(),x,f,d,0,!0))}function sh(i){let t=.5,r=.5;switch(i){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=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:t,verticalAlign:r}}function xf(i,t,r,s,l){if(!s&&!l)return;let u=i[r],d=(i[r].x+u.metrics.advance*u.scale)*s;for(let f=t;f<=r;f++)i[f].x-=d,i[f].y+=l}function vf(i,t,r){let{horizontalAlign:s,verticalAlign:l}=sh(r),u=t[0]-i.displaySize[0]*s,d=t[1]-i.displaySize[1]*l;return{image:i,top:d,bottom:d+i.displaySize[1],left:u,right:u+i.displaySize[0]}}function Ou(i){var t,r;let s=i.left,l=i.top,u=i.right-s,d=i.bottom-l,f=(t=i.image.textFitWidth)!==null&&t!==void 0?t:"stretchOrShrink",g=(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(g==="proportional"){if(f==="stretchOnly"&&u/d<x||f==="proportional"){let v=Math.ceil(d*x);s*=v/u,u=v}}else if(f==="proportional"&&g==="stretchOnly"&&x!==0&&u/d>x){let v=Math.ceil(u/x);l*=v/d,d=v}return{x1:s,y1:l,x2:s+u,y2:l+d}}function Nu(i,t,r,s,l,u){let d=i.image,f;if(d.content){let O=d.content,j=d.pixelRatio||1;f=[O[0]/j,O[1]/j,d.displaySize[0]-O[2]/j,d.displaySize[1]-O[3]/j]}let g=t.left*u,x=t.right*u,v,w,C,A;r==="width"||r==="both"?(A=l[0]+g-s[3],w=l[0]+x+s[1]):(A=l[0]+(g+x-d.displaySize[0])/2,w=A+d.displaySize[0]);let k=t.top*u,z=t.bottom*u;return r==="height"||r==="both"?(v=l[1]+k-s[0],C=l[1]+z+s[2]):(v=l[1]+(k+z-d.displaySize[1])/2,C=v+d.displaySize[1]),{image:d,top:v,right:w,bottom:C,left:A,collisionPadding:f}}let Ua=255,Wr=128,Qn=Ua*Wr;function Vu(i,t){let{expression:r}=t;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new At(i+1))};if(r.kind==="source")return{kind:"source"};{let{zoomStops:s,interpolationType:l}=r,u=0;for(;u<s.length&&s[u]<=i;)u++;u=Math.max(0,u-1);let d=u;for(;d<s.length&&s[d]<i+1;)d++;d=Math.min(s.length-1,d);let f=s[u],g=s[d];return r.kind==="composite"?{kind:"composite",minZoom:f,maxZoom:g,interpolationType:l}:{kind:"camera",minZoom:f,maxZoom:g,minSize:r.evaluate(new At(f)),maxSize:r.evaluate(new At(g)),interpolationType:l}}}function oh(i,t,r){let s="never",l=i.get(t);return l?s=l:i.get(r)&&(s="always"),s}let bf=Jn.VectorTileFeature.types,wf=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Gl(i,t,r,s,l,u,d,f,g,x,v,w,C){let A=f?Math.min(Qn,Math.round(f[0])):0,k=f?Math.min(Qn,Math.round(f[1])):0;i.emplaceBack(t,r,Math.round(32*s),Math.round(32*l),u,d,(A<<1)+(g?1:0),k,16*x,16*v,256*w,256*C)}function ah(i,t,r){i.emplaceBack(t.x,t.y,r),i.emplaceBack(t.x,t.y,r),i.emplaceBack(t.x,t.y,r),i.emplaceBack(t.x,t.y,r)}function Sf(i){for(let t of i.sections)if(Rc(t.text))return!0;return!1}class lh{constructor(t){this.layoutVertexArray=new vo,this.indexArray=new hr,this.programConfigurations=t,this.segments=new ct,this.dynamicLayoutVertexArray=new Ma,this.opacityVertexArray=new Ki,this.hasVisibleVertices=!1,this.placedSymbolArray=new Et}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(t,r,s,l){this.isEmpty()||(s&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Yp.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Qp.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,wf,!0),this.opacityVertexBuffer.itemSize=1),(s||l)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}ke("SymbolBuffers",lh);class ch{constructor(t,r,s){this.layoutVertexArray=new t,this.layoutAttributes=r,this.indexArray=new s,this.segments=new ct,this.collisionVertexArray=new Gr}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,ef.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}ke("CollisionBuffers",ch);class zo{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((d=>d.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=jc([]),this.placementViewportMatrix=jc([]);let r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Vu(this.zoom,r["text-size"]),this.iconSizeData=Vu(this.zoom,r["icon-size"]);let s=this.layers[0].layout,l=s.get("symbol-sort-key"),u=s.get("symbol-z-order");this.canOverlap=oh(s,"text-overlap","text-allow-overlap")!=="never"||oh(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=u!=="viewport-y"&&!l.isConstant(),this.sortFeaturesByY=(u==="viewport-y"||u==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map((d=>I.ah[d]))),this.stateDependentLayerIds=this.layers.filter((d=>d.isStateDependent())).map((d=>d.id)),this.sourceID=t.sourceID}createArrays(){this.text=new lh(new Ls(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new lh(new Ls(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new kt,this.lineVertexArray=new ui,this.symbolInstances=new at,this.textAnchorOffsets=new zt}calculateGlyphDependencies(t,r,s,l,u){for(let d=0;d<t.length;d++)if(r[t.charCodeAt(d)]=!0,(s||l)&&u){let f=Oa[t.charAt(d)];f&&(r[f.charCodeAt(0)]=!0)}}populate(t,r,s){let l=this.layers[0],u=l.layout,d=u.get("text-font"),f=u.get("text-field"),g=u.get("icon-image"),x=(f.value.kind!=="constant"||f.value.value instanceof Ri&&!f.value.value.isEmpty()||f.value.value.toString().length>0)&&(d.value.kind!=="constant"||d.value.value.length>0),v=g.value.kind!=="constant"||!!g.value.value||Object.keys(g.parameters).length>0,w=u.get("symbol-sort-key");if(this.features=[],!x&&!v)return;let C=r.iconDependencies,A=r.glyphDependencies,k=r.availableImages,z=new At(this.zoom);for(let{feature:O,id:j,index:ie,sourceLayerIndex:H}of t){let ee=l._featureFilter.needGeometry,ae=Rs(O,ee);if(!l._featureFilter.filter(z,ae,s))continue;let fe,Me;if(ee||(ae.geometry=Ds(O)),x){let Ie=l.getValueAndResolveTokens("text-field",ae,s,k),we=Ri.factory(Ie),Fe=this.hasRTLText=this.hasRTLText||Sf(we);(!Fe||Ni.getRTLTextPluginStatus()==="unavailable"||Fe&&Ni.isParsed())&&(fe=rf(we,l,ae))}if(v){let Ie=l.getValueAndResolveTokens("icon-image",ae,s,k);Me=Ie instanceof Fi?Ie:Fi.fromString(Ie)}if(!fe&&!Me)continue;let Ue=this.sortFeaturesByKey?w.evaluate(ae,{},s):void 0;if(this.features.push({id:j,text:fe,icon:Me,index:ie,sourceLayerIndex:H,geometry:ae.geometry,properties:O.properties,type:bf[O.type],sortKey:Ue}),Me&&(C[Me.name]=!0),fe){let Ie=d.evaluate(ae,{},s).join(","),we=u.get("text-rotation-alignment")!=="viewport"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(I.ah.vertical)>=0;for(let Fe of fe.sections)if(Fe.image)C[Fe.image.name]=!0;else{let Le=Sa(fe.toString()),Ee=Fe.fontStack||Ie,he=A[Ee]=A[Ee]||{};this.calculateGlyphDependencies(Fe.text,he,we,this.allowVerticalPlacement,Le)}}}u.get("symbol-placement")==="line"&&(this.features=(function(O){let j={},ie={},H=[],ee=0;function ae(Ie){H.push(O[Ie]),ee++}function fe(Ie,we,Fe){let Le=ie[Ie];return delete ie[Ie],ie[we]=Le,H[Le].geometry[0].pop(),H[Le].geometry[0]=H[Le].geometry[0].concat(Fe[0]),Le}function Me(Ie,we,Fe){let Le=j[we];return delete j[we],j[Ie]=Le,H[Le].geometry[0].shift(),H[Le].geometry[0]=Fe[0].concat(H[Le].geometry[0]),Le}function Ue(Ie,we,Fe){let Le=Fe?we[0][we[0].length-1]:we[0][0];return`${Ie}:${Le.x}:${Le.y}`}for(let Ie=0;Ie<O.length;Ie++){let we=O[Ie],Fe=we.geometry,Le=we.text?we.text.toString():null;if(!Le){ae(Ie);continue}let Ee=Ue(Le,Fe),he=Ue(Le,Fe,!0);if(Ee in ie&&he in j&&ie[Ee]!==j[he]){let Oe=Me(Ee,he,Fe),Be=fe(Ee,he,H[Oe].geometry);delete j[Ee],delete ie[he],ie[Ue(Le,H[Be].geometry,!0)]=Be,H[Oe].geometry=null}else Ee in ie?fe(Ee,he,Fe):he in j?Me(Ee,he,Fe):(ae(Ie),j[Ee]=ee-1,ie[he]=ee-1)}return H.filter((Ie=>Ie.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((O,j)=>O.sortKey-j.sortKey))}update(t,r,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,r,this.layers,s),this.icon.programConfigurations.updatePaintArrays(t,r,this.layers,s))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,r){let s=this.lineVertexArray.length;if(t.segment!==void 0){let l=t.dist(r[t.segment+1]),u=t.dist(r[t.segment]),d={};for(let f=t.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=t.segment||0;f>=0;f--)d[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:u},f>0&&(u+=r[f-1].dist(r[f]));for(let f=0;f<r.length;f++){let g=d[f];this.lineVertexArray.emplaceBack(g.x,g.y,g.tileUnitDistanceFromAnchor)}}return{lineStartIndex:s,lineLength:this.lineVertexArray.length-s}}addSymbols(t,r,s,l,u,d,f,g,x,v,w,C){let A=t.indexArray,k=t.layoutVertexArray,z=t.segments.prepareSegment(4*r.length,k,A,this.canOverlap?d.sortKey:void 0),O=this.glyphOffsetArray.length,j=z.vertexLength,ie=this.allowVerticalPlacement&&f===I.ah.vertical?Math.PI/2:0,H=d.text&&d.text.sections;for(let ee=0;ee<r.length;ee++){let{tl:ae,tr:fe,bl:Me,br:Ue,tex:Ie,pixelOffsetTL:we,pixelOffsetBR:Fe,minFontScaleX:Le,minFontScaleY:Ee,glyphOffset:he,isSDF:Oe,sectionIndex:Be}=r[ee],Ge=z.vertexLength,Tt=he[1];Gl(k,g.x,g.y,ae.x,Tt+ae.y,Ie.x,Ie.y,s,Oe,we.x,we.y,Le,Ee),Gl(k,g.x,g.y,fe.x,Tt+fe.y,Ie.x+Ie.w,Ie.y,s,Oe,Fe.x,we.y,Le,Ee),Gl(k,g.x,g.y,Me.x,Tt+Me.y,Ie.x,Ie.y+Ie.h,s,Oe,we.x,Fe.y,Le,Ee),Gl(k,g.x,g.y,Ue.x,Tt+Ue.y,Ie.x+Ie.w,Ie.y+Ie.h,s,Oe,Fe.x,Fe.y,Le,Ee),ah(t.dynamicLayoutVertexArray,g,ie),A.emplaceBack(Ge,Ge+1,Ge+2),A.emplaceBack(Ge+1,Ge+2,Ge+3),z.vertexLength+=4,z.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(he[0]),ee!==r.length-1&&Be===r[ee+1].sectionIndex||t.programConfigurations.populatePaintArrays(k.length,d,d.index,{},C,H&&H[Be])}t.placedSymbolArray.emplaceBack(g.x,g.y,O,this.glyphOffsetArray.length-O,j,x,v,g.segment,s?s[0]:0,s?s[1]:0,l[0],l[1],f,0,!1,0,w)}_addCollisionDebugVertex(t,r,s,l,u,d){return r.emplaceBack(0,0),t.emplaceBack(s.x,s.y,l,u,Math.round(d.x),Math.round(d.y))}addCollisionDebugVertices(t,r,s,l,u,d,f){let g=u.segments.prepareSegment(4,u.layoutVertexArray,u.indexArray),x=g.vertexLength,v=u.layoutVertexArray,w=u.collisionVertexArray,C=f.anchorX,A=f.anchorY;this._addCollisionDebugVertex(v,w,d,C,A,new pe(t,r)),this._addCollisionDebugVertex(v,w,d,C,A,new pe(s,r)),this._addCollisionDebugVertex(v,w,d,C,A,new pe(s,l)),this._addCollisionDebugVertex(v,w,d,C,A,new pe(t,l)),g.vertexLength+=4;let k=u.indexArray;k.emplaceBack(x,x+1),k.emplaceBack(x+1,x+2),k.emplaceBack(x+2,x+3),k.emplaceBack(x+3,x),g.primitiveLength+=4}addDebugCollisionBoxes(t,r,s,l){for(let u=t;u<r;u++){let d=this.collisionBoxArray.get(u);this.addCollisionDebugVertices(d.x1,d.y1,d.x2,d.y2,l?this.textCollisionBox:this.iconCollisionBox,d.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new ch(Ji,Su.members,oi),this.iconCollisionBox=new ch(Ji,Su.members,oi);for(let t=0;t<this.symbolInstances.length;t++){let r=this.symbolInstances.get(t);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(t,r,s,l,u,d,f,g,x){let v={};for(let w=r;w<s;w++){let C=t.get(w);v.textBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},v.textFeatureIndex=C.featureIndex;break}for(let w=l;w<u;w++){let C=t.get(w);v.verticalTextBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},v.verticalTextFeatureIndex=C.featureIndex;break}for(let w=d;w<f;w++){let C=t.get(w);v.iconBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},v.iconFeatureIndex=C.featureIndex;break}for(let w=g;w<x;w++){let C=t.get(w);v.verticalIconBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},v.verticalIconFeatureIndex=C.featureIndex;break}return v}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){let s=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,s.textBoxStartIndex,s.textBoxEndIndex,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s.iconBoxStartIndex,s.iconBoxEndIndex,s.verticalIconBoxStartIndex,s.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(t,r){let s=t.placedSymbolArray.get(r),l=s.vertexStartIndex+4*s.numGlyphs;for(let u=s.vertexStartIndex;u<l;u+=4)t.indexArray.emplaceBack(u,u+1,u+2),t.indexArray.emplaceBack(u+1,u+2,u+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let r=Math.sin(t),s=Math.cos(t),l=[],u=[],d=[];for(let f=0;f<this.symbolInstances.length;++f){d.push(f);let g=this.symbolInstances.get(f);l.push(0|Math.round(r*g.anchorX+s*g.anchorY)),u.push(g.featureIndex)}return d.sort(((f,g)=>l[f]-l[g]||u[g]-u[f])),d}addToSortKeyRanges(t,r){let s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===r?s.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let r of this.symbolInstanceIndexes){let s=this.symbolInstances.get(r);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach(((l,u,d)=>{l>=0&&d.indexOf(l)===u&&this.addIndicesForPlacedSymbol(this.text,l)})),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Uu,ju;ke("SymbolBucket",zo,{omit:["layers","collisionBoxArray","features","compareText"]}),zo.MAX_GLYPHS=65535,zo.addDynamicAttributes=ah;var hh={get paint(){return ju=ju||new h({"icon-opacity":new je(oe.paint_symbol["icon-opacity"]),"icon-color":new je(oe.paint_symbol["icon-color"]),"icon-halo-color":new je(oe.paint_symbol["icon-halo-color"]),"icon-halo-width":new je(oe.paint_symbol["icon-halo-width"]),"icon-halo-blur":new je(oe.paint_symbol["icon-halo-blur"]),"icon-translate":new De(oe.paint_symbol["icon-translate"]),"icon-translate-anchor":new De(oe.paint_symbol["icon-translate-anchor"]),"text-opacity":new je(oe.paint_symbol["text-opacity"]),"text-color":new je(oe.paint_symbol["text-color"],{runtimeType:Ii,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new je(oe.paint_symbol["text-halo-color"]),"text-halo-width":new je(oe.paint_symbol["text-halo-width"]),"text-halo-blur":new je(oe.paint_symbol["text-halo-blur"]),"text-translate":new De(oe.paint_symbol["text-translate"]),"text-translate-anchor":new De(oe.paint_symbol["text-translate-anchor"])})},get layout(){return Uu=Uu||new h({"symbol-placement":new De(oe.layout_symbol["symbol-placement"]),"symbol-spacing":new De(oe.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new De(oe.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new je(oe.layout_symbol["symbol-sort-key"]),"symbol-z-order":new De(oe.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new De(oe.layout_symbol["icon-allow-overlap"]),"icon-overlap":new De(oe.layout_symbol["icon-overlap"]),"icon-ignore-placement":new De(oe.layout_symbol["icon-ignore-placement"]),"icon-optional":new De(oe.layout_symbol["icon-optional"]),"icon-rotation-alignment":new De(oe.layout_symbol["icon-rotation-alignment"]),"icon-size":new je(oe.layout_symbol["icon-size"]),"icon-text-fit":new De(oe.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new De(oe.layout_symbol["icon-text-fit-padding"]),"icon-image":new je(oe.layout_symbol["icon-image"]),"icon-rotate":new je(oe.layout_symbol["icon-rotate"]),"icon-padding":new je(oe.layout_symbol["icon-padding"]),"icon-keep-upright":new De(oe.layout_symbol["icon-keep-upright"]),"icon-offset":new je(oe.layout_symbol["icon-offset"]),"icon-anchor":new je(oe.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new De(oe.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new De(oe.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new De(oe.layout_symbol["text-rotation-alignment"]),"text-field":new je(oe.layout_symbol["text-field"]),"text-font":new je(oe.layout_symbol["text-font"]),"text-size":new je(oe.layout_symbol["text-size"]),"text-max-width":new je(oe.layout_symbol["text-max-width"]),"text-line-height":new De(oe.layout_symbol["text-line-height"]),"text-letter-spacing":new je(oe.layout_symbol["text-letter-spacing"]),"text-justify":new je(oe.layout_symbol["text-justify"]),"text-radial-offset":new je(oe.layout_symbol["text-radial-offset"]),"text-variable-anchor":new De(oe.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new je(oe.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new je(oe.layout_symbol["text-anchor"]),"text-max-angle":new De(oe.layout_symbol["text-max-angle"]),"text-writing-mode":new De(oe.layout_symbol["text-writing-mode"]),"text-rotate":new je(oe.layout_symbol["text-rotate"]),"text-padding":new De(oe.layout_symbol["text-padding"]),"text-keep-upright":new De(oe.layout_symbol["text-keep-upright"]),"text-transform":new je(oe.layout_symbol["text-transform"]),"text-offset":new je(oe.layout_symbol["text-offset"]),"text-allow-overlap":new De(oe.layout_symbol["text-allow-overlap"]),"text-overlap":new De(oe.layout_symbol["text-overlap"]),"text-ignore-placement":new De(oe.layout_symbol["text-ignore-placement"]),"text-optional":new De(oe.layout_symbol["text-optional"])})}};class $u{constructor(t){if(t.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:jr,this.defaultValue=t}evaluate(t){if(t.formattedSection){let r=this.defaultValue.property.overrides;if(r&&r.hasOverride(t.formattedSection))return r.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ke("FormatSectionOverride",$u,{omit:["defaultValue"]});class Hl extends n{constructor(t){super(t,hh)}recalculate(t,r){if(super.recalculate(t,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){let s=this.layout.get("text-writing-mode");if(s){let l=[];for(let u of s)l.indexOf(u)<0&&l.push(u);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,r,s,l){let u=this.layout.get(t).evaluate(r,{},s,l),d=this._unevaluatedLayout._values[t];return d.isDataDriven()||no(d.value)||!u?u:(function(f,g){return g.replace(/{([^{}]+)}/g,((x,v)=>f&&v in f?String(f[v]):""))})(r.properties,u)}createBucket(t){return new zo(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let t of hh.paint.overridableProperties){if(!Hl.hasPaintOverride(this.layout,t))continue;let r=this.paint.get(t),s=new $u(r),l=new ro(s,r.property.specification),u=null;u=r.value.kind==="constant"||r.value.kind==="source"?new Rn("source",l):new Bn("composite",l,r.value.zoomStops),this.paint._values[t]=new Ir(r.property,u,r.parameters)}}_handleOverridablePaintPropertyUpdate(t,r,s){return!(!this.layout||r.isDataDriven()||s.isDataDriven())&&Hl.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,r){let s=t.get("text-field"),l=hh.paint.properties[r],u=!1,d=f=>{for(let g of f)if(l.overrides&&l.overrides.hasOverride(g))return void(u=!0)};if(s.value.kind==="constant"&&s.value.value instanceof Ri)d(s.value.value.sections);else if(s.value.kind==="source"){let f=x=>{u||(x instanceof nr&&Xt(x.value)===zr?d(x.value.sections):x instanceof Ws?d(x.sections):x.eachChild(f))},g=s.value;g._styleExpression&&f(g._styleExpression.expression)}return u}}let qu;var Tf={get paint(){return qu=qu||new h({"background-color":new De(oe.paint_background["background-color"]),"background-pattern":new yo(oe.paint_background["background-pattern"]),"background-opacity":new De(oe.paint_background["background-opacity"])})}};class If extends n{constructor(t){super(t,Tf)}}let Zu;var Cf={get paint(){return Zu=Zu||new h({"raster-opacity":new De(oe.paint_raster["raster-opacity"]),"raster-hue-rotate":new De(oe.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new De(oe.paint_raster["raster-brightness-min"]),"raster-brightness-max":new De(oe.paint_raster["raster-brightness-max"]),"raster-saturation":new De(oe.paint_raster["raster-saturation"]),"raster-contrast":new De(oe.paint_raster["raster-contrast"]),"raster-resampling":new De(oe.paint_raster["raster-resampling"]),"raster-fade-duration":new De(oe.paint_raster["raster-fade-duration"])})}};class Pf extends n{constructor(t){super(t,Cf)}}class Mf extends n{constructor(t){super(t,{}),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=t}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Af{constructor(t){this._methodToThrottle=t,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}let uh=63710088e-1;class es{constructor(t,r){if(isNaN(t)||isNaN(r))throw new Error(`Invalid LngLat object: (${t}, ${r})`);if(this.lng=+t,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new es(Pt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let r=Math.PI/180,s=this.lat*r,l=t.lat*r,u=Math.sin(s)*Math.sin(l)+Math.cos(s)*Math.cos(l)*Math.cos((t.lng-this.lng)*r);return uh*Math.acos(Math.min(u,1))}static convert(t){if(t instanceof es)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new es(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new es(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}let Gu=2*Math.PI*uh;function Hu(i){return Gu*Math.cos(i*Math.PI/180)}function Wu(i){return(180+i)/360}function Xu(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function Ku(i,t){return i/Hu(t)}function dh(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class ja{constructor(t,r,s=0){this.x=+t,this.y=+r,this.z=+s}static fromLngLat(t,r=0){let s=es.convert(t);return new ja(Wu(s.lng),Xu(s.lat),Ku(r,s.lat))}toLngLat(){return new es(360*this.x-180,dh(this.y))}toAltitude(){return this.z*Hu(dh(this.y))}meterInMercatorCoordinateUnits(){return 1/Gu*(t=dh(this.y),1/Math.cos(t*Math.PI/180));var t}}function Ju(i,t,r){var s=2*Math.PI*6378137/256/Math.pow(2,r);return[i*s-2*Math.PI*6378137/2,t*s-2*Math.PI*6378137/2]}class ph{constructor(t,r,s){if(!(function(l,u,d){return!(l<0||l>25||d<0||d>=Math.pow(2,l)||u<0||u>=Math.pow(2,l))})(t,r,s))throw new Error(`x=${r}, y=${s}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=r,this.y=s,this.key=$a(0,t,t,r,s)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,r,s){let l=(d=this.y,f=this.z,g=Ju(256*(u=this.x),256*(d=Math.pow(2,f)-d-1),f),x=Ju(256*(u+1),256*(d+1),f),g[0]+","+g[1]+","+x[0]+","+x[1]);var u,d,f,g,x;let v=(function(w,C,A){let k,z="";for(let O=w;O>0;O--)k=1<<O-1,z+=(C&k?1:0)+(A&k?2:0);return z})(this.z,this.x,this.y);return t[(this.x+this.y)%t.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(s==="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(t){let r=this.z-t.z;return r>0&&t.x===this.x>>r&&t.y===this.y>>r}getTilePoint(t){let r=Math.pow(2,this.z);return new pe((t.x*r-this.x)*Kt,(t.y*r-this.y)*Kt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Yu{constructor(t,r){this.wrap=t,this.canonical=r,this.key=$a(t,r.z,r.z,r.x,r.y)}}class dr{constructor(t,r,s,l,u){if(t<s)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${s}`);this.overscaledZ=t,this.wrap=r,this.canonical=new ph(s,+l,+u),this.key=$a(r,t,s,l,u)}clone(){return new dr(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let r=this.canonical.z-t;return t>this.canonical.z?new dr(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new dr(t,this.wrap,t,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(t,r){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let s=this.canonical.z-t;return t>this.canonical.z?$a(this.wrap*+r,t,this.canonical.z,this.canonical.x,this.canonical.y):$a(this.wrap*+r,t,t,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(t){if(t.wrap!==this.wrap)return!1;let r=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>r&&t.canonical.y===this.canonical.y>>r}children(t){if(this.overscaledZ>=t)return[new dr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let r=this.canonical.z+1,s=2*this.canonical.x,l=2*this.canonical.y;return[new dr(r,this.wrap,r,s,l),new dr(r,this.wrap,r,s+1,l),new dr(r,this.wrap,r,s,l+1),new dr(r,this.wrap,r,s+1,l+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new dr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new dr(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Yu(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new ja(t.x-this.wrap,t.y))}}function $a(i,t,r,s,l){(i*=2)<0&&(i=-1*i-1);let u=1<<r;return(u*u*i+u*l+s).toString(36)+r.toString(36)+t.toString(36)}ke("CanonicalTileID",ph),ke("OverscaledTileID",dr,{omit:["posMatrix"]});class Qu{constructor(t,r,s,l=1,u=1,d=1,f=0){if(this.uid=t,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(s&&!["mapbox","terrarium","custom"].includes(s))return void ze(`"${s}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=r.height;let g=this.dim=r.height-2;switch(this.data=new Uint32Array(r.data.buffer),s){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=l,this.greenFactor=u,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<g;x++)this.data[this._idx(-1,x)]=this.data[this._idx(0,x)],this.data[this._idx(g,x)]=this.data[this._idx(g-1,x)],this.data[this._idx(x,-1)]=this.data[this._idx(x,0)],this.data[this._idx(x,g)]=this.data[this._idx(x,g-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(g,-1)]=this.data[this._idx(g-1,0)],this.data[this._idx(-1,g)]=this.data[this._idx(0,g-1)],this.data[this._idx(g,g)]=this.data[this._idx(g-1,g-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let x=0;x<g;x++)for(let v=0;v<g;v++){let w=this.get(x,v);w>this.max&&(this.max=w),w<this.min&&(this.min=w)}}get(t,r){let s=new Uint8Array(this.data.buffer),l=4*this._idx(t,r);return this.unpack(s[l],s[l+1],s[l+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,r){if(t<-1||t>=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(t+1)}unpack(t,r,s){return t*this.redFactor+r*this.greenFactor+s*this.blueFactor-this.baseShift}getPixels(){return new ur({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,r,s){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let l=r*this.dim,u=r*this.dim+this.dim,d=s*this.dim,f=s*this.dim+this.dim;switch(r){case-1:l=u-1;break;case 1:u=l+1}switch(s){case-1:d=f-1;break;case 1:f=d+1}let g=-r*this.dim,x=-s*this.dim;for(let v=d;v<f;v++)for(let w=l;w<u;w++)this.data[this._idx(w,v)]=t.data[this._idx(w+g,v+x)]}}ke("DEMData",Qu);class ed{constructor(t){this._stringToNumber={},this._numberToString=[];for(let r=0;r<t.length;r++){let s=t[r];this._stringToNumber[s]=r,this._numberToString[r]=s}}encode(t){return this._stringToNumber[t]}decode(t){if(t>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class td{constructor(t,r,s,l,u){this.type="Feature",this._vectorTileFeature=t,t._z=r,t._x=s,t._y=l,this.properties=t.properties,this.id=u}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){let t={geometry:this.geometry};for(let r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(t[r]=this[r]);return t}}class id{constructor(t,r){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Vn(Kt,16,0),this.grid3D=new Vn(Kt,16,0),this.featureIndexArray=new bi,this.promoteId=r}insert(t,r,s,l,u,d){let f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,l,u);let g=d?this.grid3D:this.grid;for(let x=0;x<r.length;x++){let v=r[x],w=[1/0,1/0,-1/0,-1/0];for(let C=0;C<v.length;C++){let A=v[C];w[0]=Math.min(w[0],A.x),w[1]=Math.min(w[1],A.y),w[2]=Math.max(w[2],A.x),w[3]=Math.max(w[3],A.y)}w[0]<Kt&&w[1]<Kt&&w[2]>=0&&w[3]>=0&&g.insert(f,w[0],w[1],w[2],w[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Jn.VectorTile(new th(this.rawTileData)).layers,this.sourceLayerCoder=new ed(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,r,s,l){this.loadVTLayers();let u=t.params||{},d=Kt/t.tileSize/t.scale,f=la(u.filter),g=t.queryGeometry,x=t.queryPadding*d,v=nd(g),w=this.grid.query(v.minX-x,v.minY-x,v.maxX+x,v.maxY+x),C=nd(t.cameraQueryGeometry),A=this.grid3D.query(C.minX-x,C.minY-x,C.maxX+x,C.maxY+x,((O,j,ie,H)=>(function(ee,ae,fe,Me,Ue){for(let we of ee)if(ae<=we.x&&fe<=we.y&&Me>=we.x&&Ue>=we.y)return!0;let Ie=[new pe(ae,fe),new pe(ae,Ue),new pe(Me,Ue),new pe(Me,fe)];if(ee.length>2){for(let we of Ie)if(Io(ee,we))return!0}for(let we=0;we<ee.length-1;we++)if(lp(ee[we],ee[we+1],Ie))return!0;return!1})(t.cameraQueryGeometry,O-x,j-x,ie+x,H+x)));for(let O of A)w.push(O);w.sort(Ef);let k={},z;for(let O=0;O<w.length;O++){let j=w[O];if(j===z)continue;z=j;let ie=this.featureIndexArray.get(j),H=null;this.loadMatchingFeature(k,ie.bucketIndex,ie.sourceLayerIndex,ie.featureIndex,f,u.layers,u.availableImages,r,s,l,((ee,ae,fe)=>(H||(H=Ds(ee)),ae.queryIntersectsFeature(g,ee,fe,H,this.z,t.transform,d,t.pixelPosMatrix))))}return k}loadMatchingFeature(t,r,s,l,u,d,f,g,x,v,w){let C=this.bucketLayerIDs[r];if(d&&!(function(O,j){for(let ie=0;ie<O.length;ie++)if(j.indexOf(O[ie])>=0)return!0;return!1})(d,C))return;let A=this.sourceLayerCoder.decode(s),k=this.vtLayers[A].feature(l);if(u.needGeometry){let O=Rs(k,!0);if(!u.filter(new At(this.tileID.overscaledZ),O,this.tileID.canonical))return}else if(!u.filter(new At(this.tileID.overscaledZ),k))return;let z=this.getId(k,A);for(let O=0;O<C.length;O++){let j=C[O];if(d&&d.indexOf(j)<0)continue;let ie=g[j];if(!ie)continue;let H={};z&&v&&(H=v.getState(ie.sourceLayer||"_geojsonTileLayer",z));let ee=Mt({},x[j]);ee.paint=rd(ee.paint,ie.paint,k,H,f),ee.layout=rd(ee.layout,ie.layout,k,H,f);let ae=!w||w(k,ie,H);if(!ae)continue;let fe=new td(k,this.z,this.x,this.y,z);fe.layer=ee;let Me=t[j];Me===void 0&&(Me=t[j]=[]),Me.push({featureIndex:l,feature:fe,intersectionZ:ae})}}lookupSymbolFeatures(t,r,s,l,u,d,f,g){let x={};this.loadVTLayers();let v=la(u);for(let w of t)this.loadMatchingFeature(x,s,l,w,v,d,f,g,r);return x}hasLayer(t){for(let r of this.bucketLayerIDs)for(let s of r)if(t===s)return!0;return!1}getId(t,r){let s=t.id;return this.promoteId&&(s=t.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof s=="boolean"&&(s=Number(s))),s}}function rd(i,t,r,s,l){return _t(i,((u,d)=>{let f=t instanceof Es?t.get(d):null;return f&&f.evaluate?f.evaluate(r,s,l):f}))}function nd(i){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(let u of i)t=Math.min(t,u.x),r=Math.min(r,u.y),s=Math.max(s,u.x),l=Math.max(l,u.y);return{minX:t,minY:r,maxX:s,maxY:l}}function Ef(i,t){return t-i}function sd(i,t,r,s,l){let u=[];for(let d=0;d<i.length;d++){let f=i[d],g;for(let x=0;x<f.length-1;x++){let v=f[x],w=f[x+1];v.x<t&&w.x<t||(v.x<t?v=new pe(t,v.y+(t-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x<t&&(w=new pe(t,v.y+(t-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y<r&&w.y<r||(v.y<r?v=new pe(v.x+(r-v.y)/(w.y-v.y)*(w.x-v.x),r)._round():w.y<r&&(w=new pe(v.x+(r-v.y)/(w.y-v.y)*(w.x-v.x),r)._round()),v.x>=s&&w.x>=s||(v.x>=s?v=new pe(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x>=s&&(w=new pe(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y>=l&&w.y>=l||(v.y>=l?v=new pe(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round():w.y>=l&&(w=new pe(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round()),g&&v.equals(g[g.length-1])||(g=[v],u.push(g)),g.push(w)))))}}return u}ke("FeatureIndex",id,{omit:["rawTileData","sourceLayerCoder"]});class ts extends pe{constructor(t,r,s,l){super(t,r),this.angle=s,l!==void 0&&(this.segment=l)}clone(){return new ts(this.x,this.y,this.angle,this.segment)}}function od(i,t,r,s,l){if(t.segment===void 0||r===0)return!0;let u=t,d=t.segment+1,f=0;for(;f>-r/2;){if(d--,d<0)return!1;f-=i[d].dist(u),u=i[d]}f+=i[d].dist(i[d+1]),d++;let g=[],x=0;for(;f<r/2;){let v=i[d],w=i[d+1];if(!w)return!1;let C=i[d-1].angleTo(v)-v.angleTo(w);for(C=Math.abs((C+3*Math.PI)%(2*Math.PI)-Math.PI),g.push({distance:f,angleDelta:C}),x+=C;f-g[0].distance>s;)x-=g.shift().angleDelta;if(x>l)return!1;d++,f+=v.dist(w)}return!0}function ad(i){let t=0;for(let r=0;r<i.length-1;r++)t+=i[r].dist(i[r+1]);return t}function ld(i,t,r){return i?.6*t*r:0}function cd(i,t){return Math.max(i?i.right-i.left:0,t?t.right-t.left:0)}function kf(i,t,r,s,l,u){let d=ld(r,l,u),f=cd(r,s)*u,g=0,x=ad(i)/2;for(let v=0;v<i.length-1;v++){let w=i[v],C=i[v+1],A=w.dist(C);if(g+A>x){let k=(x-g)/A,z=Ci.number(w.x,C.x,k),O=Ci.number(w.y,C.y,k),j=new ts(z,O,C.angleTo(w),v);return j._round(),!d||od(i,j,f,d,t)?j:void 0}g+=A}}function zf(i,t,r,s,l,u,d,f,g){let x=ld(s,u,d),v=cd(s,l),w=v*d,C=i[0].x===0||i[0].x===g||i[0].y===0||i[0].y===g;return t-w<t/4&&(t=w+t/4),hd(i,C?t/2*f%t:(v/2+2*u)*d*f%t,t,x,r,w,C,!1,g)}function hd(i,t,r,s,l,u,d,f,g){let x=u/2,v=ad(i),w=0,C=t-r,A=[];for(let k=0;k<i.length-1;k++){let z=i[k],O=i[k+1],j=z.dist(O),ie=O.angleTo(z);for(;C+r<w+j;){C+=r;let H=(C-w)/j,ee=Ci.number(z.x,O.x,H),ae=Ci.number(z.y,O.y,H);if(ee>=0&&ee<g&&ae>=0&&ae<g&&C-x>=0&&C+x<=v){let fe=new ts(ee,ae,ie,k);fe._round(),s&&!od(i,fe,u,s,l)||A.push(fe)}}w+=j}return f||A.length||d||(A=hd(i,w/2,r,s,l,u,d,!0,g)),A}ke("Anchor",ts);let Lo=Ui;function ud(i,t,r,s){let l=[],u=i.image,d=u.pixelRatio,f=u.paddedRect.w-2*Lo,g=u.paddedRect.h-2*Lo,x={x1:i.left,y1:i.top,x2:i.right,y2:i.bottom},v=u.stretchX||[[0,f]],w=u.stretchY||[[0,g]],C=(he,Oe)=>he+Oe[1]-Oe[0],A=v.reduce(C,0),k=w.reduce(C,0),z=f-A,O=g-k,j=0,ie=A,H=0,ee=k,ae=0,fe=z,Me=0,Ue=O;if(u.content&&s){let he=u.content,Oe=he[2]-he[0],Be=he[3]-he[1];(u.textFitWidth||u.textFitHeight)&&(x=Ou(i)),j=Wl(v,0,he[0]),H=Wl(w,0,he[1]),ie=Wl(v,he[0],he[2]),ee=Wl(w,he[1],he[3]),ae=he[0]-j,Me=he[1]-H,fe=Oe-ie,Ue=Be-ee}let Ie=x.x1,we=x.y1,Fe=x.x2-Ie,Le=x.y2-we,Ee=(he,Oe,Be,Ge)=>{let Tt=Xl(he.stretch-j,ie,Fe,Ie),St=Kl(he.fixed-ae,fe,he.stretch,A),ii=Xl(Oe.stretch-H,ee,Le,we),Pr=Kl(Oe.fixed-Me,Ue,Oe.stretch,k),mi=Xl(Be.stretch-j,ie,Fe,Ie),ri=Kl(Be.fixed-ae,fe,Be.stretch,A),Ei=Xl(Ge.stretch-H,ee,Le,we),ki=Kl(Ge.fixed-Me,Ue,Ge.stretch,k),zi=new pe(Tt,ii),$t=new pe(mi,ii),ni=new pe(mi,Ei),Si=new pe(Tt,Ei),gi=new pe(St/d,Pr/d),Li=new pe(ri/d,ki/d),_i=t*Math.PI/180;if(_i){let ft=Math.sin(_i),Ct=Math.cos(_i),Lt=[Ct,-ft,ft,Ct];zi._matMult(Lt),$t._matMult(Lt),Si._matMult(Lt),ni._matMult(Lt)}let pr=he.stretch+he.fixed,ji=Oe.stretch+Oe.fixed;return{tl:zi,tr:$t,bl:Si,br:ni,tex:{x:u.paddedRect.x+Lo+pr,y:u.paddedRect.y+Lo+ji,w:Be.stretch+Be.fixed-pr,h:Ge.stretch+Ge.fixed-ji},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:gi,pixelOffsetBR:Li,minFontScaleX:fe/d/Fe,minFontScaleY:Ue/d/Le,isSDF:r}};if(s&&(u.stretchX||u.stretchY)){let he=dd(v,z,A),Oe=dd(w,O,k);for(let Be=0;Be<he.length-1;Be++){let Ge=he[Be],Tt=he[Be+1];for(let St=0;St<Oe.length-1;St++)l.push(Ee(Ge,Oe[St],Tt,Oe[St+1]))}}else l.push(Ee({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:f+1},{fixed:0,stretch:g+1}));return l}function Wl(i,t,r){let s=0;for(let l of i)s+=Math.max(t,Math.min(r,l[1]))-Math.max(t,Math.min(r,l[0]));return s}function dd(i,t,r){let s=[{fixed:-Lo,stretch:0}];for(let[l,u]of i){let d=s[s.length-1];s.push({fixed:l-d.stretch,stretch:d.stretch}),s.push({fixed:l-d.stretch,stretch:d.stretch+(u-l)})}return s.push({fixed:t+Lo,stretch:r}),s}function Xl(i,t,r,s){return i/t*r+s}function Kl(i,t,r,s){return i-t*r/s}class Jl{constructor(t,r,s,l,u,d,f,g,x,v){var w;if(this.boxStartIndex=t.length,x){let C=d.top,A=d.bottom,k=d.collisionPadding;k&&(C-=k[1],A+=k[3]);let z=A-C;z>0&&(z=Math.max(10,z),this.circleDiameter=z)}else{let C=!((w=d.image)===null||w===void 0)&&w.content&&(d.image.textFitWidth||d.image.textFitHeight)?Ou(d):{x1:d.left,y1:d.top,x2:d.right,y2:d.bottom};C.y1=C.y1*f-g[0],C.y2=C.y2*f+g[2],C.x1=C.x1*f-g[3],C.x2=C.x2*f+g[1];let A=d.collisionPadding;if(A&&(C.x1-=A[0]*f,C.y1-=A[1]*f,C.x2+=A[2]*f,C.y2+=A[3]*f),v){let k=new pe(C.x1,C.y1),z=new pe(C.x2,C.y1),O=new pe(C.x1,C.y2),j=new pe(C.x2,C.y2),ie=v*Math.PI/180;k._rotate(ie),z._rotate(ie),O._rotate(ie),j._rotate(ie),C.x1=Math.min(k.x,z.x,O.x,j.x),C.x2=Math.max(k.x,z.x,O.x,j.x),C.y1=Math.min(k.y,z.y,O.y,j.y),C.y2=Math.max(k.y,z.y,O.y,j.y)}t.emplaceBack(r.x,r.y,C.x1,C.y1,C.x2,C.y2,s,l,u)}this.boxEndIndex=t.length}}class Lf{constructor(t=[],r=((s,l)=>s<l?-1:s>l?1:0)){if(this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:r,compare:s}=this,l=r[t];for(;t>0;){let u=t-1>>1,d=r[u];if(s(l,d)>=0)break;r[t]=d,t=u}r[t]=l}_down(t){let{data:r,compare:s}=this,l=this.length>>1,u=r[t];for(;t<l;){let d=1+(t<<1),f=d+1;if(f<this.length&&s(r[f],r[d])<0&&(d=f),s(r[d],u)>=0)break;r[t]=r[d],t=d}r[t]=u}}function Df(i,t=1,r=!1){let s=1/0,l=1/0,u=-1/0,d=-1/0,f=i[0];for(let A=0;A<f.length;A++){let k=f[A];(!A||k.x<s)&&(s=k.x),(!A||k.y<l)&&(l=k.y),(!A||k.x>u)&&(u=k.x),(!A||k.y>d)&&(d=k.y)}let g=Math.min(u-s,d-l),x=g/2,v=new Lf([],Rf);if(g===0)return new pe(s,l);for(let A=s;A<u;A+=g)for(let k=l;k<d;k+=g)v.push(new Do(A+x,k+x,x,i));let w=(function(A){let k=0,z=0,O=0,j=A[0];for(let ie=0,H=j.length,ee=H-1;ie<H;ee=ie++){let ae=j[ie],fe=j[ee],Me=ae.x*fe.y-fe.x*ae.y;z+=(ae.x+fe.x)*Me,O+=(ae.y+fe.y)*Me,k+=3*Me}return new Do(z/k,O/k,0,A)})(i),C=v.length;for(;v.length;){let A=v.pop();(A.d>w.d||!w.d)&&(w=A,r&&console.log("found best %d after %d probes",Math.round(1e4*A.d)/1e4,C)),A.max-w.d<=t||(x=A.h/2,v.push(new Do(A.p.x-x,A.p.y-x,x,i)),v.push(new Do(A.p.x+x,A.p.y-x,x,i)),v.push(new Do(A.p.x-x,A.p.y+x,x,i)),v.push(new Do(A.p.x+x,A.p.y+x,x,i)),C+=4)}return r&&(console.log(`num probes: ${C}`),console.log(`best distance: ${w.d}`)),w.p}function Rf(i,t){return t.max-i.max}function Do(i,t,r,s){this.p=new pe(i,t),this.h=r,this.d=(function(l,u){let d=!1,f=1/0;for(let g=0;g<u.length;g++){let x=u[g];for(let v=0,w=x.length,C=w-1;v<w;C=v++){let A=x[v],k=x[C];A.y>l.y!=k.y>l.y&&l.x<(k.x-A.x)*(l.y-A.y)/(k.y-A.y)+A.x&&(d=!d),f=Math.min(f,Xh(l,A,k))}}return(d?1:-1)*Math.sqrt(f)})(this.p,s),this.max=this.d+this.h*Math.SQRT2}var fi;I.aq=void 0,(fi=I.aq||(I.aq={}))[fi.center=1]="center",fi[fi.left=2]="left",fi[fi.right=3]="right",fi[fi.top=4]="top",fi[fi.bottom=5]="bottom",fi[fi["top-left"]=6]="top-left",fi[fi["top-right"]=7]="top-right",fi[fi["bottom-left"]=8]="bottom-left",fi[fi["bottom-right"]=9]="bottom-right";let is=7,fh=Number.POSITIVE_INFINITY;function pd(i,t){return t[1]!==fh?(function(r,s,l){let u=0,d=0;switch(s=Math.abs(s),l=Math.abs(l),r){case"top-right":case"top-left":case"top":d=l-is;break;case"bottom-right":case"bottom-left":case"bottom":d=-l+is}switch(r){case"top-right":case"bottom-right":case"right":u=-s;break;case"top-left":case"bottom-left":case"left":u=s}return[u,d]})(i,t[0],t[1]):(function(r,s){let l=0,u=0;s<0&&(s=0);let d=s/Math.SQRT2;switch(r){case"top-right":case"top-left":u=d-is;break;case"bottom-right":case"bottom-left":u=-d+is;break;case"bottom":u=-s+is;break;case"top":u=s-is}switch(r){case"top-right":case"bottom-right":l=-d;break;case"top-left":case"bottom-left":l=d;break;case"left":l=s;break;case"right":l=-s}return[l,u]})(i,t[0])}function fd(i,t,r){var s;let l=i.layout,u=(s=l.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(t,{},r);if(u){let f=u.values,g=[];for(let x=0;x<f.length;x+=2){let v=g[x]=f[x],w=f[x+1].map((C=>C*ei));v.startsWith("top")?w[1]-=is:v.startsWith("bottom")&&(w[1]+=is),g[x+1]=w}return new Zi(g)}let d=l.get("text-variable-anchor");if(d){let f;f=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[l.get("text-radial-offset").evaluate(t,{},r)*ei,fh]:l.get("text-offset").evaluate(t,{},r).map((x=>x*ei));let g=[];for(let x of d)g.push(x,pd(x,f));return new Zi(g)}return null}function mh(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 Bf(i,t,r,s,l,u,d,f,g,x,v){let w=u.textMaxSize.evaluate(t,{});w===void 0&&(w=d);let C=i.layers[0].layout,A=C.get("icon-offset").evaluate(t,{},v),k=gd(r.horizontal),z=d/24,O=i.tilePixelRatio*z,j=i.tilePixelRatio*w/24,ie=i.tilePixelRatio*f,H=i.tilePixelRatio*C.get("symbol-spacing"),ee=C.get("text-padding")*i.tilePixelRatio,ae=(function(he,Oe,Be,Ge=1){let Tt=he.get("icon-padding").evaluate(Oe,{},Be),St=Tt&&Tt.values;return[St[0]*Ge,St[1]*Ge,St[2]*Ge,St[3]*Ge]})(C,t,v,i.tilePixelRatio),fe=C.get("text-max-angle")/180*Math.PI,Me=C.get("text-rotation-alignment")!=="viewport"&&C.get("symbol-placement")!=="point",Ue=C.get("icon-rotation-alignment")==="map"&&C.get("symbol-placement")!=="point",Ie=C.get("symbol-placement"),we=H/2,Fe=C.get("icon-text-fit"),Le;s&&Fe!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(Le=Nu(s,r.vertical,Fe,C.get("icon-text-fit-padding"),A,z)),k&&(s=Nu(s,k,Fe,C.get("icon-text-fit-padding"),A,z)));let Ee=(he,Oe)=>{Oe.x<0||Oe.x>=Kt||Oe.y<0||Oe.y>=Kt||(function(Be,Ge,Tt,St,ii,Pr,mi,ri,Ei,ki,zi,$t,ni,Si,gi,Li,_i,pr,ji,ft,Ct,Lt,Yi,Ot,Ro){let Xr=Be.addToLineVertexArray(Ge,Tt),Kr,Mr,fr,ai,_n=0,Ga=0,vd=0,bd=0,Sh=-1,Th=-1,yn={},wd=bo("");if(Be.allowVerticalPlacement&&St.vertical){let Ti=ri.layout.get("text-rotate").evaluate(Ct,{},Ot)+90;fr=new Jl(Ei,Ge,ki,zi,$t,St.vertical,ni,Si,gi,Ti),mi&&(ai=new Jl(Ei,Ge,ki,zi,$t,mi,_i,pr,gi,Ti))}if(ii){let Ti=ri.layout.get("icon-rotate").evaluate(Ct,{}),mr=ri.layout.get("icon-text-fit")!=="none",Fs=ud(ii,Ti,Yi,mr),Fr=mi?ud(mi,Ti,Yi,mr):void 0;Mr=new Jl(Ei,Ge,ki,zi,$t,ii,_i,pr,!1,Ti),_n=4*Fs.length;let Os=Be.iconSizeData,Jr=null;Os.kind==="source"?(Jr=[Wr*ri.layout.get("icon-size").evaluate(Ct,{})],Jr[0]>Qn&&ze(`${Be.layerIds[0]}: Value for "icon-size" is >= ${Ua}. Reduce your "icon-size".`)):Os.kind==="composite"&&(Jr=[Wr*Lt.compositeIconSizes[0].evaluate(Ct,{},Ot),Wr*Lt.compositeIconSizes[1].evaluate(Ct,{},Ot)],(Jr[0]>Qn||Jr[1]>Qn)&&ze(`${Be.layerIds[0]}: Value for "icon-size" is >= ${Ua}. Reduce your "icon-size".`)),Be.addSymbols(Be.icon,Fs,Jr,ft,ji,Ct,I.ah.none,Ge,Xr.lineStartIndex,Xr.lineLength,-1,Ot),Sh=Be.icon.placedSymbolArray.length-1,Fr&&(Ga=4*Fr.length,Be.addSymbols(Be.icon,Fr,Jr,ft,ji,Ct,I.ah.vertical,Ge,Xr.lineStartIndex,Xr.lineLength,-1,Ot),Th=Be.icon.placedSymbolArray.length-1)}let Sd=Object.keys(St.horizontal);for(let Ti of Sd){let mr=St.horizontal[Ti];if(!Kr){wd=bo(mr.text);let Fr=ri.layout.get("text-rotate").evaluate(Ct,{},Ot);Kr=new Jl(Ei,Ge,ki,zi,$t,mr,ni,Si,gi,Fr)}let Fs=mr.positionedLines.length===1;if(vd+=md(Be,Ge,mr,Pr,ri,gi,Ct,Li,Xr,St.vertical?I.ah.horizontal:I.ah.horizontalOnly,Fs?Sd:[Ti],yn,Sh,Lt,Ot),Fs)break}St.vertical&&(bd+=md(Be,Ge,St.vertical,Pr,ri,gi,Ct,Li,Xr,I.ah.vertical,["vertical"],yn,Th,Lt,Ot));let Nf=Kr?Kr.boxStartIndex:Be.collisionBoxArray.length,Vf=Kr?Kr.boxEndIndex:Be.collisionBoxArray.length,Uf=fr?fr.boxStartIndex:Be.collisionBoxArray.length,jf=fr?fr.boxEndIndex:Be.collisionBoxArray.length,$f=Mr?Mr.boxStartIndex:Be.collisionBoxArray.length,qf=Mr?Mr.boxEndIndex:Be.collisionBoxArray.length,Zf=ai?ai.boxStartIndex:Be.collisionBoxArray.length,Gf=ai?ai.boxEndIndex:Be.collisionBoxArray.length,Br=-1,Ql=(Ti,mr)=>Ti&&Ti.circleDiameter?Math.max(Ti.circleDiameter,mr):mr;Br=Ql(Kr,Br),Br=Ql(fr,Br),Br=Ql(Mr,Br),Br=Ql(ai,Br);let Td=Br>-1?1:0;Td&&(Br*=Ro/ei),Be.glyphOffsetArray.length>=zo.MAX_GLYPHS&&ze("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Ct.sortKey!==void 0&&Be.addToSortKeyRanges(Be.symbolInstances.length,Ct.sortKey);let Hf=fd(ri,Ct,Ot),[Wf,Xf]=(function(Ti,mr){let Fs=Ti.length,Fr=mr?.values;if(Fr?.length>0)for(let Os=0;Os<Fr.length;Os+=2){let Jr=Fr[Os+1];Ti.emplaceBack(I.aq[Fr[Os]],Jr[0],Jr[1])}return[Fs,Ti.length]})(Be.textAnchorOffsets,Hf);Be.symbolInstances.emplaceBack(Ge.x,Ge.y,yn.right>=0?yn.right:-1,yn.center>=0?yn.center:-1,yn.left>=0?yn.left:-1,yn.vertical||-1,Sh,Th,wd,Nf,Vf,Uf,jf,$f,qf,Zf,Gf,ki,vd,bd,_n,Ga,Td,0,ni,Br,Wf,Xf)})(i,Oe,he,r,s,l,Le,i.layers[0],i.collisionBoxArray,t.index,t.sourceLayerIndex,i.index,O,[ee,ee,ee,ee],Me,g,ie,ae,Ue,A,t,u,x,v,d)};if(Ie==="line")for(let he of sd(t.geometry,0,0,Kt,Kt)){let Oe=zf(he,H,fe,r.vertical||k,s,24,j,i.overscaling,Kt);for(let Be of Oe)k&&Ff(i,k.text,we,Be)||Ee(he,Be)}else if(Ie==="line-center"){for(let he of t.geometry)if(he.length>1){let Oe=kf(he,fe,r.vertical||k,s,24,j);Oe&&Ee(he,Oe)}}else if(t.type==="Polygon")for(let he of Ks(t.geometry,0)){let Oe=Df(he,16);Ee(he[0],new ts(Oe.x,Oe.y,0))}else if(t.type==="LineString")for(let he of t.geometry)Ee(he,new ts(he[0].x,he[0].y,0));else if(t.type==="Point")for(let he of t.geometry)for(let Oe of he)Ee([Oe],new ts(Oe.x,Oe.y,0))}function md(i,t,r,s,l,u,d,f,g,x,v,w,C,A,k){let z=(function(ie,H,ee,ae,fe,Me,Ue,Ie){let we=ae.layout.get("text-rotate").evaluate(Me,{})*Math.PI/180,Fe=[];for(let Le of H.positionedLines)for(let Ee of Le.positionedGlyphs){if(!Ee.rect)continue;let he=Ee.rect||{},Oe=ku+1,Be=!0,Ge=1,Tt=0,St=(fe||Ie)&&Ee.vertical,ii=Ee.metrics.advance*Ee.scale/2;if(Ie&&H.verticalizable&&(Tt=Le.lineOffset/2-(Ee.imageName?-(ei-Ee.metrics.width*Ee.scale)/2:(Ee.scale-1)*ei)),Ee.imageName){let ft=Ue[Ee.imageName];Be=ft.sdf,Ge=ft.pixelRatio,Oe=Ui/Ge}let Pr=fe?[Ee.x+ii,Ee.y]:[0,0],mi=fe?[0,0]:[Ee.x+ii+ee[0],Ee.y+ee[1]-Tt],ri=[0,0];St&&(ri=mi,mi=[0,0]);let Ei=Ee.metrics.isDoubleResolution?2:1,ki=(Ee.metrics.left-Oe)*Ee.scale-ii+mi[0],zi=(-Ee.metrics.top-Oe)*Ee.scale+mi[1],$t=ki+he.w/Ei*Ee.scale/Ge,ni=zi+he.h/Ei*Ee.scale/Ge,Si=new pe(ki,zi),gi=new pe($t,zi),Li=new pe(ki,ni),_i=new pe($t,ni);if(St){let ft=new pe(-ii,ii-Na),Ct=-Math.PI/2,Lt=ei/2-ii,Yi=new pe(5-Na-Lt,-(Ee.imageName?Lt:0)),Ot=new pe(...ri);Si._rotateAround(Ct,ft)._add(Yi)._add(Ot),gi._rotateAround(Ct,ft)._add(Yi)._add(Ot),Li._rotateAround(Ct,ft)._add(Yi)._add(Ot),_i._rotateAround(Ct,ft)._add(Yi)._add(Ot)}if(we){let ft=Math.sin(we),Ct=Math.cos(we),Lt=[Ct,-ft,ft,Ct];Si._matMult(Lt),gi._matMult(Lt),Li._matMult(Lt),_i._matMult(Lt)}let pr=new pe(0,0),ji=new pe(0,0);Fe.push({tl:Si,tr:gi,bl:Li,br:_i,tex:he,writingMode:H.writingMode,glyphOffset:Pr,sectionIndex:Ee.sectionIndex,isSDF:Be,pixelOffsetTL:pr,pixelOffsetBR:ji,minFontScaleX:0,minFontScaleY:0})}return Fe})(0,r,f,l,u,d,s,i.allowVerticalPlacement),O=i.textSizeData,j=null;O.kind==="source"?(j=[Wr*l.layout.get("text-size").evaluate(d,{})],j[0]>Qn&&ze(`${i.layerIds[0]}: Value for "text-size" is >= ${Ua}. Reduce your "text-size".`)):O.kind==="composite"&&(j=[Wr*A.compositeTextSizes[0].evaluate(d,{},k),Wr*A.compositeTextSizes[1].evaluate(d,{},k)],(j[0]>Qn||j[1]>Qn)&&ze(`${i.layerIds[0]}: Value for "text-size" is >= ${Ua}. Reduce your "text-size".`)),i.addSymbols(i.text,z,j,f,u,d,x,t,g.lineStartIndex,g.lineLength,C,k);for(let ie of v)w[ie]=i.text.placedSymbolArray.length-1;return 4*z.length}function gd(i){for(let t in i)return i[t];return null}function Ff(i,t,r,s){let l=i.compareText;if(t in l){let u=l[t];for(let d=u.length-1;d>=0;d--)if(s.dist(u[d])<r)return!0}else l[t]=[];return l[t].push(s),!1}let _d=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class gh{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");let[r,s]=new Uint8Array(t,0,2);if(r!==219)throw new Error("Data does not appear to be in a KDBush format.");let l=s>>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);let u=_d[15&s];if(!u)throw new Error("Unrecognized array type.");let[d]=new Uint16Array(t,2,1),[f]=new Uint32Array(t,4,1);return new gh(f,d,u,t)}constructor(t,r=64,s=Float64Array,l){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=s,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let u=_d.indexOf(this.ArrayType),d=2*t*this.ArrayType.BYTES_PER_ELEMENT,f=t*this.IndexArrayType.BYTES_PER_ELEMENT,g=(8-f%8)%8;if(u<0)throw new Error(`Unexpected typed array class: ${s}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+g,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+d+f+g),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+g,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+u]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=t)}add(t,r){let s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=t,this.coords[this._pos++]=r,s}finish(){let t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return _h(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,r,s,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:u,coords:d,nodeSize:f}=this,g=[0,u.length-1,0],x=[];for(;g.length;){let v=g.pop()||0,w=g.pop()||0,C=g.pop()||0;if(w-C<=f){for(let O=C;O<=w;O++){let j=d[2*O],ie=d[2*O+1];j>=t&&j<=s&&ie>=r&&ie<=l&&x.push(u[O])}continue}let A=C+w>>1,k=d[2*A],z=d[2*A+1];k>=t&&k<=s&&z>=r&&z<=l&&x.push(u[A]),(v===0?t<=k:r<=z)&&(g.push(C),g.push(A-1),g.push(1-v)),(v===0?s>=k:l>=z)&&(g.push(A+1),g.push(w),g.push(1-v))}return x}within(t,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:l,coords:u,nodeSize:d}=this,f=[0,l.length-1,0],g=[],x=s*s;for(;f.length;){let v=f.pop()||0,w=f.pop()||0,C=f.pop()||0;if(w-C<=d){for(let O=C;O<=w;O++)xd(u[2*O],u[2*O+1],t,r)<=x&&g.push(l[O]);continue}let A=C+w>>1,k=u[2*A],z=u[2*A+1];xd(k,z,t,r)<=x&&g.push(l[A]),(v===0?t-s<=k:r-s<=z)&&(f.push(C),f.push(A-1),f.push(1-v)),(v===0?t+s>=k:r+s>=z)&&(f.push(A+1),f.push(w),f.push(1-v))}return g}}function _h(i,t,r,s,l,u){if(l-s<=r)return;let d=s+l>>1;yd(i,t,d,s,l,u),_h(i,t,r,s,d-1,1-u),_h(i,t,r,d+1,l,1-u)}function yd(i,t,r,s,l,u){for(;l>s;){if(l-s>600){let x=l-s+1,v=r-s+1,w=Math.log(x),C=.5*Math.exp(2*w/3),A=.5*Math.sqrt(w*C*(x-C)/x)*(v-x/2<0?-1:1);yd(i,t,r,Math.max(s,Math.floor(r-v*C/x+A)),Math.min(l,Math.floor(r+(x-v)*C/x+A)),u)}let d=t[2*r+u],f=s,g=l;for(qa(i,t,s,r),t[2*l+u]>d&&qa(i,t,s,l);f<g;){for(qa(i,t,f,g),f++,g--;t[2*f+u]<d;)f++;for(;t[2*g+u]>d;)g--}t[2*s+u]===d?qa(i,t,s,g):(g++,qa(i,t,g,l)),g<=r&&(s=g+1),r<=g&&(l=g-1)}}function qa(i,t,r,s){yh(i,r,s),yh(t,2*r,2*s),yh(t,2*r+1,2*s+1)}function yh(i,t,r){let s=i[t];i[t]=i[r],i[r]=s}function xd(i,t,r,s){let l=i-r,u=t-s;return l*l+u*u}var xh;I.bg=void 0,(xh=I.bg||(I.bg={})).create="create",xh.load="load",xh.fullLoad="fullLoad";let Yl=null,Za=[],vh=1e3/60,bh="loadTime",wh="fullLoadTime",Of={mark(i){performance.mark(i)},frame(i){let t=i;Yl!=null&&Za.push(t-Yl),Yl=t},clearMetrics(){Yl=null,Za=[],performance.clearMeasures(bh),performance.clearMeasures(wh);for(let i in I.bg)performance.clearMarks(I.bg[i])},getPerformanceMetrics(){performance.measure(bh,I.bg.create,I.bg.load),performance.measure(wh,I.bg.create,I.bg.fullLoad);let i=performance.getEntriesByName(bh)[0].duration,t=performance.getEntriesByName(wh)[0].duration,r=Za.length,s=1/(Za.reduce(((u,d)=>u+d),0)/r/1e3),l=Za.filter((u=>u>vh)).reduce(((u,d)=>u+(d-vh)/vh),0);return{loadTime:i,fullLoadTime:t,fps:s,percentDroppedFrames:l/(r+l)*100,totalFrames:r}}};I.$=class extends S{},I.A=Co,I.B=Ec,I.C=function(i){if(Qt==null){let t=i.navigator?i.navigator.userAgent:null;Qt=!!i.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Qt},I.D=De,I.E=bn,I.F=class{constructor(i,t){this.target=i,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Af((()=>this.process())),this.subscription=(function(r,s,l,u){return r.addEventListener(s,l,!1),{unsubscribe:()=>{r.removeEventListener(s,l,!1)}}})(this.target,"message",(r=>this.receive(r))),this.globalScope=st(self)?i:window}registerMessageHandler(i,t){this.messageHandlers[i]=t}sendAsync(i,t){return new Promise(((r,s)=>{let l=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[l]={resolve:r,reject:s},t&&t.signal.addEventListener("abort",(()=>{delete this.resolveRejects[l];let f={id:l,type:"<cancel>",origin:location.origin,targetMapId:i.targetMapId,sourceMapId:this.mapId};this.target.postMessage(f)}),{once:!0});let u=[],d=Object.assign(Object.assign({},i),{id:l,sourceMapId:this.mapId,origin:location.origin,data:Un(i.data,u)});this.target.postMessage(d,{transfer:u})}))}receive(i){let t=i.data,r=t.id;if(!(t.origin!=="file://"&&location.origin!=="file://"&&t.origin!=="resource://android"&&location.origin!=="resource://android"&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type==="<cancel>"){delete this.tasks[r];let s=this.abortControllers[r];return delete this.abortControllers[r],void(s&&s.abort())}if(st(self)||t.mustQueue)return this.tasks[r]=t,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,t)}}process(){if(this.taskQueue.length===0)return;let i=this.taskQueue.shift(),t=this.tasks[i];delete this.tasks[i],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(i,t)}processTask(i,t){return p(this,void 0,void 0,(function*(){if(t.type==="<response>"){let l=this.resolveRejects[i];return delete this.resolveRejects[i],l?void(t.error?l.reject(jn(t.error)):l.resolve(jn(t.data))):void 0}if(!this.messageHandlers[t.type])return void this.completeTask(i,new Error(`Could not find a registered handler for ${t.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));let r=jn(t.data),s=new AbortController;this.abortControllers[i]=s;try{let l=yield this.messageHandlers[t.type](t.sourceMapId,r,s);this.completeTask(i,null,l)}catch(l){this.completeTask(i,l)}}))}completeTask(i,t,r){let s=[];delete this.abortControllers[i];let l={id:i,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?Un(t):null,data:Un(r,s)};this.target.postMessage(l,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},I.G=vn,I.H=function(){var i=new Co(16);return Co!=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},I.I=rh,I.J=function(i,t,r){var s,l,u,d,f,g,x,v,w,C,A,k,z=r[0],O=r[1],j=r[2];return t===i?(i[12]=t[0]*z+t[4]*O+t[8]*j+t[12],i[13]=t[1]*z+t[5]*O+t[9]*j+t[13],i[14]=t[2]*z+t[6]*O+t[10]*j+t[14],i[15]=t[3]*z+t[7]*O+t[11]*j+t[15]):(l=t[1],u=t[2],d=t[3],f=t[4],g=t[5],x=t[6],v=t[7],w=t[8],C=t[9],A=t[10],k=t[11],i[0]=s=t[0],i[1]=l,i[2]=u,i[3]=d,i[4]=f,i[5]=g,i[6]=x,i[7]=v,i[8]=w,i[9]=C,i[10]=A,i[11]=k,i[12]=s*z+f*O+w*j+t[12],i[13]=l*z+g*O+C*j+t[13],i[14]=u*z+x*O+A*j+t[14],i[15]=d*z+v*O+k*j+t[15]),i},I.K=function(i,t,r){var s=r[0],l=r[1],u=r[2];return i[0]=t[0]*s,i[1]=t[1]*s,i[2]=t[2]*s,i[3]=t[3]*s,i[4]=t[4]*l,i[5]=t[5]*l,i[6]=t[6]*l,i[7]=t[7]*l,i[8]=t[8]*u,i[9]=t[9]*u,i[10]=t[10]*u,i[11]=t[11]*u,i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],i},I.L=Qh,I.M=function(i,t){let r={};for(let s=0;s<t.length;s++){let l=t[s];l in i&&(r[l]=i[l])}return r},I.N=es,I.O=Wu,I.P=pe,I.Q=Xu,I.R=ur,I.S=dr,I.T=go,I.U=li,I.V=$i,I.W=er,I.X=Kt,I.Y=m,I.Z=ja,I._=p,I.a=Or,I.a$=function(i,t){var r=i[0],s=i[1],l=i[2],u=i[3],d=i[4],f=i[5],g=i[6],x=i[7],v=i[8],w=i[9],C=i[10],A=i[11],k=i[12],z=i[13],O=i[14],j=i[15],ie=t[0],H=t[1],ee=t[2],ae=t[3],fe=t[4],Me=t[5],Ue=t[6],Ie=t[7],we=t[8],Fe=t[9],Le=t[10],Ee=t[11],he=t[12],Oe=t[13],Be=t[14],Ge=t[15];return Math.abs(r-ie)<=Ai*Math.max(1,Math.abs(r),Math.abs(ie))&&Math.abs(s-H)<=Ai*Math.max(1,Math.abs(s),Math.abs(H))&&Math.abs(l-ee)<=Ai*Math.max(1,Math.abs(l),Math.abs(ee))&&Math.abs(u-ae)<=Ai*Math.max(1,Math.abs(u),Math.abs(ae))&&Math.abs(d-fe)<=Ai*Math.max(1,Math.abs(d),Math.abs(fe))&&Math.abs(f-Me)<=Ai*Math.max(1,Math.abs(f),Math.abs(Me))&&Math.abs(g-Ue)<=Ai*Math.max(1,Math.abs(g),Math.abs(Ue))&&Math.abs(x-Ie)<=Ai*Math.max(1,Math.abs(x),Math.abs(Ie))&&Math.abs(v-we)<=Ai*Math.max(1,Math.abs(v),Math.abs(we))&&Math.abs(w-Fe)<=Ai*Math.max(1,Math.abs(w),Math.abs(Fe))&&Math.abs(C-Le)<=Ai*Math.max(1,Math.abs(C),Math.abs(Le))&&Math.abs(A-Ee)<=Ai*Math.max(1,Math.abs(A),Math.abs(Ee))&&Math.abs(k-he)<=Ai*Math.max(1,Math.abs(k),Math.abs(he))&&Math.abs(z-Oe)<=Ai*Math.max(1,Math.abs(z),Math.abs(Oe))&&Math.abs(O-Be)<=Ai*Math.max(1,Math.abs(O),Math.abs(Be))&&Math.abs(j-Ge)<=Ai*Math.max(1,Math.abs(j),Math.abs(Ge))},I.a0=ct,I.a1=ph,I.a2=ge,I.a3=i=>{let t=window.document.createElement("video");return t.muted=!0,new Promise((r=>{t.onloadstart=()=>{r(t)};for(let s of i){let l=window.document.createElement("source");Qr(s)||(t.crossOrigin="Anonymous"),l.src=s,t.appendChild(l)}}))},I.a4=function(){return Vt++},I.a5=Pe,I.a6=zo,I.a7=la,I.a8=Rs,I.a9=td,I.aA=function(i){if(i.type==="custom")return new Mf(i);switch(i.type){case"background":return new If(i);case"circle":return new up(i);case"fill":return new Mp(i);case"fill-extrusion":return new $p(i);case"heatmap":return new pp(i);case"hillshade":return new mp(i);case"line":return new Jp(i);case"raster":return new Pf(i);case"symbol":return new Hl(i)}},I.aB=Ye,I.aC=function(i,t){if(!i)return[{command:"setStyle",args:[t]}];let r=[];try{if(!mt(i.version,t.version))return[{command:"setStyle",args:[t]}];mt(i.center,t.center)||r.push({command:"setCenter",args:[t.center]}),mt(i.zoom,t.zoom)||r.push({command:"setZoom",args:[t.zoom]}),mt(i.bearing,t.bearing)||r.push({command:"setBearing",args:[t.bearing]}),mt(i.pitch,t.pitch)||r.push({command:"setPitch",args:[t.pitch]}),mt(i.sprite,t.sprite)||r.push({command:"setSprite",args:[t.sprite]}),mt(i.glyphs,t.glyphs)||r.push({command:"setGlyphs",args:[t.glyphs]}),mt(i.transition,t.transition)||r.push({command:"setTransition",args:[t.transition]}),mt(i.light,t.light)||r.push({command:"setLight",args:[t.light]}),mt(i.terrain,t.terrain)||r.push({command:"setTerrain",args:[t.terrain]}),mt(i.sky,t.sky)||r.push({command:"setSky",args:[t.sky]}),mt(i.projection,t.projection)||r.push({command:"setProjection",args:[t.projection]});let s={},l=[];(function(d,f,g,x){let v;for(v in f=f||{},d=d||{})Object.prototype.hasOwnProperty.call(d,v)&&(Object.prototype.hasOwnProperty.call(f,v)||Ur(v,g,x));for(v in f)Object.prototype.hasOwnProperty.call(f,v)&&(Object.prototype.hasOwnProperty.call(d,v)?mt(d[v],f[v])||(d[v].type==="geojson"&&f[v].type==="geojson"&&wn(d,f,v)?Bt(g,{command:"setGeoJSONSourceData",args:[v,f[v].data]}):kr(v,f,g,x)):hs(v,f,g))})(i.sources,t.sources,l,s);let u=[];i.layers&&i.layers.forEach((d=>{"source"in d&&s[d.source]?r.push({command:"removeLayer",args:[d.id]}):u.push(d)})),r=r.concat(l),(function(d,f,g){f=f||[];let x=(d=d||[]).map(us),v=f.map(us),w=d.reduce(ds,{}),C=f.reduce(ds,{}),A=x.slice(),k=Object.create(null),z,O,j,ie,H;for(let ee=0,ae=0;ee<x.length;ee++)z=x[ee],Object.prototype.hasOwnProperty.call(C,z)?ae++:(Bt(g,{command:"removeLayer",args:[z]}),A.splice(A.indexOf(z,ae),1));for(let ee=0,ae=0;ee<v.length;ee++)z=v[v.length-1-ee],A[A.length-1-ee]!==z&&(Object.prototype.hasOwnProperty.call(w,z)?(Bt(g,{command:"removeLayer",args:[z]}),A.splice(A.lastIndexOf(z,A.length-ae),1)):ae++,ie=A[A.length-ee],Bt(g,{command:"addLayer",args:[C[z],ie]}),A.splice(A.length-ee,0,z),k[z]=!0);for(let ee=0;ee<v.length;ee++)if(z=v[ee],O=w[z],j=C[z],!k[z]&&!mt(O,j))if(mt(O.source,j.source)&&mt(O["source-layer"],j["source-layer"])&&mt(O.type,j.type)){for(H in qi(O.layout,j.layout,g,z,null,"setLayoutProperty"),qi(O.paint,j.paint,g,z,null,"setPaintProperty"),mt(O.filter,j.filter)||Bt(g,{command:"setFilter",args:[z,j.filter]}),mt(O.minzoom,j.minzoom)&&mt(O.maxzoom,j.maxzoom)||Bt(g,{command:"setLayerZoomRange",args:[z,j.minzoom,j.maxzoom]}),O)Object.prototype.hasOwnProperty.call(O,H)&&H!=="layout"&&H!=="paint"&&H!=="filter"&&H!=="metadata"&&H!=="minzoom"&&H!=="maxzoom"&&(H.indexOf("paint.")===0?qi(O[H],j[H],g,z,H.slice(6),"setPaintProperty"):mt(O[H],j[H])||Bt(g,{command:"setLayerProperty",args:[z,H,j[H]]}));for(H in j)Object.prototype.hasOwnProperty.call(j,H)&&!Object.prototype.hasOwnProperty.call(O,H)&&H!=="layout"&&H!=="paint"&&H!=="filter"&&H!=="metadata"&&H!=="minzoom"&&H!=="maxzoom"&&(H.indexOf("paint.")===0?qi(O[H],j[H],g,z,H.slice(6),"setPaintProperty"):mt(O[H],j[H])||Bt(g,{command:"setLayerProperty",args:[z,H,j[H]]}))}else Bt(g,{command:"removeLayer",args:[z]}),ie=A[A.lastIndexOf(z)+1],Bt(g,{command:"addLayer",args:[j,ie]})})(u,t.layers,r)}catch(s){console.warn("Unable to compute style diff:",s),r=[{command:"setStyle",args:[t]}]}return r},I.aD=function(i){let t=[],r=i.id;return r===void 0&&t.push({message:`layers.${r}: missing required property "id"`}),i.render===void 0&&t.push({message:`layers.${r}: missing required method "render"`}),i.renderingMode&&i.renderingMode!=="2d"&&i.renderingMode!=="3d"&&t.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),t},I.aE=function i(t,r){if(Array.isArray(t)){if(!Array.isArray(r)||t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(!i(t[s],r[s]))return!1;return!0}if(typeof t=="object"&&t!==null&&r!==null){if(typeof r!="object"||Object.keys(t).length!==Object.keys(r).length)return!1;for(let s in t)if(!i(t[s],r[s]))return!1;return!0}return t===r},I.aF=_t,I.aG=yi,I.aH=class extends zs{constructor(i,t){super(i,t),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},I.aI=Dl,I.aJ=class extends zs{constructor(i,t){super(i,t),this.current=rp}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 t=1;t<16;t++)if(i[t]!==this.current[t]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},I.aK=jh,I.aL=$h,I.aM=vt,I.aN=class extends zs{constructor(i,t){super(i,t),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]))}},I.aO=class extends zs{constructor(i,t){super(i,t),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]))}},I.aP=function(i,t,r,s,l,u,d){var f=1/(t-r),g=1/(s-l),x=1/(u-d);return i[0]=-2*f,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*g,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*x,i[11]=0,i[12]=(t+r)*f,i[13]=(l+s)*g,i[14]=(d+u)*x,i[15]=1,i},I.aQ=hp,I.aR=class extends J{},I.aS=tf,I.aT=class extends ne{},I.aU=Zc,I.aV=function(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))},I.aW=nu,I.aX=di,I.aY=hr,I.aZ=class extends Re{},I.a_=function(i,t){return i[0]===t[0]&&i[1]===t[1]&&i[2]===t[2]&&i[3]===t[3]&&i[4]===t[4]&&i[5]===t[5]&&i[6]===t[6]&&i[7]===t[7]&&i[8]===t[8]&&i[9]===t[9]&&i[10]===t[10]&&i[11]===t[11]&&i[12]===t[12]&&i[13]===t[13]&&i[14]===t[14]&&i[15]===t[15]},I.aa=function(i){let t={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((r,s,l,u)=>{let d=l||u;return t[s]=!d||d.toLowerCase(),""})),t["max-age"]){let r=parseInt(t["max-age"],10);isNaN(r)?delete t["max-age"]:t["max-age"]=r}return t},I.ab=function(i,t){let r=[];for(let s in i)s in t||r.push(s);return r},I.ac=Je,I.ad=function(i,t,r){var s=Math.sin(r),l=Math.cos(r),u=t[0],d=t[1],f=t[2],g=t[3],x=t[4],v=t[5],w=t[6],C=t[7];return t!==i&&(i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15]),i[0]=u*l+x*s,i[1]=d*l+v*s,i[2]=f*l+w*s,i[3]=g*l+C*s,i[4]=x*l-u*s,i[5]=v*l-d*s,i[6]=w*l-f*s,i[7]=C*l-g*s,i},I.ae=function(i){var t=new Co(16);return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],t},I.af=Ol,I.ag=function(i,t){let r=0,s=0;if(i.kind==="constant")s=i.layoutSize;else if(i.kind!=="source"){let{interpolationType:l,minZoom:u,maxZoom:d}=i,f=l?Je(Pi.interpolationFactor(l,t,u,d),0,1):0;i.kind==="camera"?s=Ci.number(i.minSize,i.maxSize,f):r=f}return{uSizeT:r,uSize:s}},I.ai=function(i,{uSize:t,uSizeT:r},{lowerSize:s,upperSize:l}){return i.kind==="source"?s/Wr:i.kind==="composite"?Ci.number(s/Wr,l/Wr,r):t},I.aj=ah,I.ak=function(i,t,r,s){let l=t.y-i.y,u=t.x-i.x,d=s.y-r.y,f=s.x-r.x,g=d*u-f*l;if(g===0)return null;let x=(f*(i.y-r.y)-d*(i.x-r.x))/g;return new pe(i.x+x*u,i.y+x*l)},I.al=sd,I.am=Hh,I.an=jc,I.ao=function(i){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(let u of i)t=Math.min(t,u.x),r=Math.min(r,u.y),s=Math.max(s,u.x),l=Math.max(l,u.y);return[t,r,s,l]},I.ap=ei,I.ar=oh,I.as=function(i,t){var r=t[0],s=t[1],l=t[2],u=t[3],d=t[4],f=t[5],g=t[6],x=t[7],v=t[8],w=t[9],C=t[10],A=t[11],k=t[12],z=t[13],O=t[14],j=t[15],ie=r*f-s*d,H=r*g-l*d,ee=r*x-u*d,ae=s*g-l*f,fe=s*x-u*f,Me=l*x-u*g,Ue=v*z-w*k,Ie=v*O-C*k,we=v*j-A*k,Fe=w*O-C*z,Le=w*j-A*z,Ee=C*j-A*O,he=ie*Ee-H*Le+ee*Fe+ae*we-fe*Ie+Me*Ue;return he?(i[0]=(f*Ee-g*Le+x*Fe)*(he=1/he),i[1]=(l*Le-s*Ee-u*Fe)*he,i[2]=(z*Me-O*fe+j*ae)*he,i[3]=(C*fe-w*Me-A*ae)*he,i[4]=(g*we-d*Ee-x*Ie)*he,i[5]=(r*Ee-l*we+u*Ie)*he,i[6]=(O*ee-k*Me-j*H)*he,i[7]=(v*Me-C*ee+A*H)*he,i[8]=(d*Le-f*we+x*Ue)*he,i[9]=(s*we-r*Le-u*Ue)*he,i[10]=(k*fe-z*ee+j*ie)*he,i[11]=(w*ee-v*fe-A*ie)*he,i[12]=(f*Ie-d*Fe-g*Ue)*he,i[13]=(r*Fe-s*Ie+l*Ue)*he,i[14]=(z*H-k*ae-O*ie)*he,i[15]=(v*ae-w*H+C*ie)*he,i):null},I.at=mh,I.au=sh,I.av=gh,I.aw=function(){let i={},t=oe.$version;for(let r in oe.$root){let s=oe.$root[r];if(s.required){let l=null;l=r==="version"?t:s.type==="array"?[]:{},l!=null&&(i[r]=l)}}return i},I.ax=wa,I.ay=ir,I.az=function(i){i=i.slice();let t=Object.create(null);for(let r=0;r<i.length;r++)t[i[r].id]=i[r];for(let r=0;r<i.length;r++)"ref"in i[r]&&(i[r]=cs(i[r],t[i[r].ref]));return i},I.b=qt,I.b0=function(i,t){return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],i},I.b1=function(i,t,r){return i[0]=t[0]*r[0],i[1]=t[1]*r[1],i[2]=t[2]*r[2],i[3]=t[3]*r[3],i},I.b2=function(i,t){return i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+i[3]*t[3]},I.b3=Pt,I.b4=Yu,I.b5=Ku,I.b6=function(i,t,r,s,l){var u,d=1/Math.tan(t/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+s)*(u=1/(s-l)),i[14]=2*l*s*u):(i[10]=-1,i[14]=-2*s),i},I.b7=function(i,t,r){var s=Math.sin(r),l=Math.cos(r),u=t[4],d=t[5],f=t[6],g=t[7],x=t[8],v=t[9],w=t[10],C=t[11];return t!==i&&(i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15]),i[4]=u*l+x*s,i[5]=d*l+v*s,i[6]=f*l+w*s,i[7]=g*l+C*s,i[8]=x*l-u*s,i[9]=v*l-d*s,i[10]=w*l-f*s,i[11]=C*l-g*s,i},I.b8=et,I.b9=He,I.bA=Tu,I.bB=function(i){return i.message===tr},I.bC=Dn,I.bD=Ni,I.ba=function(i){return i*Math.PI/180},I.bb=function(i,t){let{x:r,y:s}=ja.fromLngLat(t);return!(i<0||i>25||s<0||s>=1||r<0||r>=1)},I.bc=function(i,t){return i[0]=t[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=t[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=t[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},I.bd=class extends b{},I.be=uh,I.bf=Of,I.bh=Di,I.bi=function(i,t){Or.REGISTERED_PROTOCOLS[i]=t},I.bj=function(i){delete Or.REGISTERED_PROTOCOLS[i]},I.bk=function(i,t){let r={};for(let l=0;l<i.length;l++){let u=t&&t[i[l].id]||wl(i[l]);t&&(t[i[l].id]=u);let d=r[u];d||(d=r[u]=[]),d.push(i[l])}let s=[];for(let l in r)s.push(r[l]);return s},I.bl=ke,I.bm=ed,I.bn=id,I.bo=Lu,I.bp=function(i){i.bucket.createArrays(),i.bucket.tilePixelRatio=Kt/(512*i.bucket.overscaling),i.bucket.compareText={},i.bucket.iconsNeedLinear=!1;let t=i.bucket.layers[0],r=t.layout,s=t._unevaluatedLayout._values,l={layoutIconSize:s["icon-size"].possiblyEvaluate(new At(i.bucket.zoom+1),i.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new At(i.bucket.zoom+1),i.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new At(18))};if(i.bucket.textSizeData.kind==="composite"){let{minZoom:x,maxZoom:v}=i.bucket.textSizeData;l.compositeTextSizes=[s["text-size"].possiblyEvaluate(new At(x),i.canonical),s["text-size"].possiblyEvaluate(new At(v),i.canonical)]}if(i.bucket.iconSizeData.kind==="composite"){let{minZoom:x,maxZoom:v}=i.bucket.iconSizeData;l.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new At(x),i.canonical),s["icon-size"].possiblyEvaluate(new At(v),i.canonical)]}let u=r.get("text-line-height")*ei,d=r.get("text-rotation-alignment")!=="viewport"&&r.get("symbol-placement")!=="point",f=r.get("text-keep-upright"),g=r.get("text-size");for(let x of i.bucket.features){let v=r.get("text-font").evaluate(x,{},i.canonical).join(","),w=g.evaluate(x,{},i.canonical),C=l.layoutTextSize.evaluate(x,{},i.canonical),A=l.layoutIconSize.evaluate(x,{},i.canonical),k={horizontal:{},vertical:void 0},z=x.text,O,j=[0,0];if(z){let ee=z.toString(),ae=r.get("text-letter-spacing").evaluate(x,{},i.canonical)*ei,fe=kc(ee)?ae:0,Me=r.get("text-anchor").evaluate(x,{},i.canonical),Ue=fd(t,x,i.canonical);if(!Ue){let Le=r.get("text-radial-offset").evaluate(x,{},i.canonical);j=Le?pd(Me,[Le*ei,fh]):r.get("text-offset").evaluate(x,{},i.canonical).map((Ee=>Ee*ei))}let Ie=d?"center":r.get("text-justify").evaluate(x,{},i.canonical),we=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(x,{},i.canonical)*ei:1/0,Fe=()=>{i.bucket.allowVerticalPlacement&&Sa(ee)&&(k.vertical=ql(z,i.glyphMap,i.glyphPositions,i.imagePositions,v,we,u,Me,"left",fe,j,I.ah.vertical,!0,C,w))};if(!d&&Ue){let Le=new Set;if(Ie==="auto")for(let he=0;he<Ue.values.length;he+=2)Le.add(mh(Ue.values[he]));else Le.add(Ie);let Ee=!1;for(let he of Le)if(!k.horizontal[he])if(Ee)k.horizontal[he]=k.horizontal[0];else{let Oe=ql(z,i.glyphMap,i.glyphPositions,i.imagePositions,v,we,u,"center",he,fe,j,I.ah.horizontal,!1,C,w);Oe&&(k.horizontal[he]=Oe,Ee=Oe.positionedLines.length===1)}Fe()}else{Ie==="auto"&&(Ie=mh(Me));let Le=ql(z,i.glyphMap,i.glyphPositions,i.imagePositions,v,we,u,Me,Ie,fe,j,I.ah.horizontal,!1,C,w);Le&&(k.horizontal[Ie]=Le),Fe(),Sa(ee)&&d&&f&&(k.vertical=ql(z,i.glyphMap,i.glyphPositions,i.imagePositions,v,we,u,Me,Ie,fe,j,I.ah.vertical,!1,C,w))}}let ie=!1;if(x.icon&&x.icon.name){let ee=i.imageMap[x.icon.name];ee&&(O=vf(i.imagePositions[x.icon.name],r.get("icon-offset").evaluate(x,{},i.canonical),r.get("icon-anchor").evaluate(x,{},i.canonical)),ie=!!ee.sdf,i.bucket.sdfIcons===void 0?i.bucket.sdfIcons=ie:i.bucket.sdfIcons!==ie&&ze("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(ee.pixelRatio!==i.bucket.pixelRatio||r.get("icon-rotate").constantOr(1)!==0)&&(i.bucket.iconsNeedLinear=!0))}let H=gd(k.horizontal)||k.vertical;i.bucket.iconsInText=!!H&&H.iconsInText,(H||O)&&Bf(i.bucket,x,k,O,i.imageMap,l,C,A,j,ie,i.canonical)}i.showCollisionBoxes&&i.bucket.generateCollisionDebugBuffers()},I.bq=Qc,I.br=Kc,I.bs=Yc,I.bt=Jn,I.bu=th,I.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}},I.bw=function(i,t,r,s,l){return p(this,void 0,void 0,(function*(){if($i())try{return yield er(i,t,r,s,l)}catch{}return(function(u,d,f,g,x){let v=u.width,w=u.height;ci&&Zt||(ci=new OffscreenCanvas(v,w),Zt=ci.getContext("2d",{willReadFrequently:!0})),ci.width=v,ci.height=w,Zt.drawImage(u,0,0,v,w);let C=Zt.getImageData(d,f,g,x);return Zt.clearRect(0,0,v,w),C.data})(i,t,r,s,l)}))},I.bx=Qu,I.by=Se,I.bz=Ce,I.c=xn,I.d=i=>p(void 0,void 0,void 0,(function*(){if(i.byteLength===0)return createImageBitmap(new ImageData(1,1));let t=new Blob([new Uint8Array(i)],{type:"image/png"});try{return createImageBitmap(t)}catch(r){throw new Error(`Could not load image because of ${r.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),I.e=Mt,I.f=i=>new Promise(((t,r)=>{let s=new Image;s.onload=()=>{t(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame((()=>{s.src=Qi}))},s.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));let l=new Blob([new Uint8Array(i)],{type:"image/png"});s.src=i.byteLength?URL.createObjectURL(l):Qi})),I.g=yr,I.h=(i,t)=>Yr(Mt(i,{type:"json"}),t),I.i=st,I.j=Vr,I.k=Nr,I.l=(i,t)=>Yr(Mt(i,{type:"arrayBuffer"}),t),I.m=Yr,I.n=function(i){return new th(i).readFields(pf,[])},I.o=za,I.p=zu,I.q=h,I.r=Ac,I.s=Qr,I.t=va,I.u=pn,I.v=oe,I.w=ze,I.x=function([i,t,r]){return t+=90,t*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(t)*Math.sin(r),y:i*Math.sin(t)*Math.sin(r),z:i*Math.cos(r)}},I.y=Ci,I.z=At})),re("worker",["./shared"],(function(I){"use strict";class p{constructor(M){this.keyCache={},M&&this.replace(M)}replace(M){this._layerConfigs={},this._layers={},this.update(M,[])}update(M,P){for(let N of M){this._layerConfigs[N.id]=N;let W=this._layers[N.id]=I.aA(N);W._featureFilter=I.a7(W.filter),this.keyCache[N.id]&&delete this.keyCache[N.id]}for(let N of P)delete this.keyCache[N],delete this._layerConfigs[N],delete this._layers[N];this.familiesBySource={};let D=I.bk(Object.values(this._layerConfigs),this.keyCache);for(let N of D){let W=N.map((se=>this._layers[se.id])),Y=W[0];if(Y.visibility==="none")continue;let te=Y.source||"",Z=this.familiesBySource[te];Z||(Z=this.familiesBySource[te]={});let le=Y.sourceLayer||"_geojsonTileLayer",de=Z[le];de||(de=Z[le]=[]),de.push(W)}}}class Se{constructor(M){let P={},D=[];for(let te in M){let Z=M[te],le=P[te]={};for(let de in Z){let se=Z[+de];if(!se||se.bitmap.width===0||se.bitmap.height===0)continue;let _e={x:0,y:0,w:se.bitmap.width+2,h:se.bitmap.height+2};D.push(_e),le[de]={rect:_e,metrics:se.metrics}}}let{w:N,h:W}=I.p(D),Y=new I.o({width:N||1,height:W||1});for(let te in M){let Z=M[te];for(let le in Z){let de=Z[+le];if(!de||de.bitmap.width===0||de.bitmap.height===0)continue;let se=P[te][le].rect;I.o.copy(de.bitmap,Y,{x:0,y:0},{x:se.x+1,y:se.y+1},de.bitmap)}}this.image=Y,this.positions=P}}I.bl("GlyphAtlas",Se);class Ce{constructor(M){this.tileID=new I.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,P,D,N){return I._(this,void 0,void 0,(function*(){this.status="parsing",this.data=M,this.collisionBoxArray=new I.a5;let W=new I.bm(Object.keys(M.layers).sort()),Y=new I.bn(this.tileID,this.promoteId);Y.bucketLayerIDs=[];let te={},Z={featureIndex:Y,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:D},le=P.familiesBySource[this.source];for(let rt in le){let xt=M.layers[rt];if(!xt)continue;xt.version===1&&I.w(`Vector tile source "${this.source}" layer "${rt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let Rt=W.encode(rt),ti=[];for(let si=0;si<xt.length;si++){let vi=xt.feature(si),Sn=Y.getId(vi,rt);ti.push({feature:vi,id:Sn,index:si,sourceLayerIndex:Rt})}for(let si of le[rt]){let vi=si[0];vi.source!==this.source&&I.w(`layer.source = ${vi.source} does not equal this.source = ${this.source}`),vi.minzoom&&this.zoom<Math.floor(vi.minzoom)||vi.maxzoom&&this.zoom>=vi.maxzoom||vi.visibility!=="none"&&($e(si,this.zoom,D),(te[vi.id]=vi.createBucket({index:Y.bucketLayerIDs.length,layers:si,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Rt,sourceID:this.source})).populate(ti,Z,this.tileID.canonical),Y.bucketLayerIDs.push(si.map((Sn=>Sn.id))))}}let de=I.aF(Z.glyphDependencies,(rt=>Object.keys(rt).map(Number)));this.inFlightDependencies.forEach((rt=>rt?.abort())),this.inFlightDependencies=[];let se=Promise.resolve({});if(Object.keys(de).length){let rt=new AbortController;this.inFlightDependencies.push(rt),se=N.sendAsync({type:"GG",data:{stacks:de,source:this.source,tileID:this.tileID,type:"glyphs"}},rt)}let _e=Object.keys(Z.iconDependencies),Ne=Promise.resolve({});if(_e.length){let rt=new AbortController;this.inFlightDependencies.push(rt),Ne=N.sendAsync({type:"GI",data:{icons:_e,source:this.source,tileID:this.tileID,type:"icons"}},rt)}let Ve=Object.keys(Z.patternDependencies),ut=Promise.resolve({});if(Ve.length){let rt=new AbortController;this.inFlightDependencies.push(rt),ut=N.sendAsync({type:"GI",data:{icons:Ve,source:this.source,tileID:this.tileID,type:"patterns"}},rt)}let[Ke,dt,ot]=yield Promise.all([se,Ne,ut]),Wt=new Se(Ke),Ft=new I.bo(dt,ot);for(let rt in te){let xt=te[rt];xt instanceof I.a6?($e(xt.layers,this.zoom,D),I.bp({bucket:xt,glyphMap:Ke,glyphPositions:Wt.positions,imageMap:dt,imagePositions:Ft.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):xt.hasPattern&&(xt instanceof I.bq||xt instanceof I.br||xt instanceof I.bs)&&($e(xt.layers,this.zoom,D),xt.addFeatures(Z,this.tileID.canonical,Ft.patternPositions))}return this.status="done",{buckets:Object.values(te).filter((rt=>!rt.isEmpty())),featureIndex:Y,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Wt.image,imageAtlas:Ft,glyphMap:this.returnDependencies?Ke:null,iconMap:this.returnDependencies?dt:null,glyphPositions:this.returnDependencies?Wt.positions:null}}))}}function $e(U,M,P){let D=new I.z(M);for(let N of U)N.recalculate(D,P)}class pe{constructor(M,P,D){this.actor=M,this.layerIndex=P,this.availableImages=D,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(M,P){return I._(this,void 0,void 0,(function*(){let D=yield I.l(M.request,P);try{return{vectorTile:new I.bt.VectorTile(new I.bu(D.data)),rawData:D.data,cacheControl:D.cacheControl,expires:D.expires}}catch(N){let W=new Uint8Array(D.data),Y=`Unable to parse the tile at ${M.request.url}, `;throw Y+=W[0]===31&&W[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${N.message}`,new Error(Y)}}))}loadTile(M){return I._(this,void 0,void 0,(function*(){let P=M.uid,D=!!(M&&M.request&&M.request.collectResourceTiming)&&new I.bv(M.request),N=new Ce(M);this.loading[P]=N;let W=new AbortController;N.abort=W;try{let Y=yield this.loadVectorTile(M,W);if(delete this.loading[P],!Y)return null;let te=Y.rawData,Z={};Y.expires&&(Z.expires=Y.expires),Y.cacheControl&&(Z.cacheControl=Y.cacheControl);let le={};if(D){let se=D.finish();se&&(le.resourceTiming=JSON.parse(JSON.stringify(se)))}N.vectorTile=Y.vectorTile;let de=N.parse(Y.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[P]=N,this.fetching[P]={rawTileData:te,cacheControl:Z,resourceTiming:le};try{let se=yield de;return I.e({rawTileData:te.slice(0)},se,Z,le)}finally{delete this.fetching[P]}}catch(Y){throw delete this.loading[P],N.status="done",this.loaded[P]=N,Y}}))}reloadTile(M){return I._(this,void 0,void 0,(function*(){let P=M.uid;if(!this.loaded||!this.loaded[P])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");let D=this.loaded[P];if(D.showCollisionBoxes=M.showCollisionBoxes,D.status==="parsing"){let N=yield D.parse(D.vectorTile,this.layerIndex,this.availableImages,this.actor),W;if(this.fetching[P]){let{rawTileData:Y,cacheControl:te,resourceTiming:Z}=this.fetching[P];delete this.fetching[P],W=I.e({rawTileData:Y.slice(0)},N,te,Z)}else W=N;return W}if(D.status==="done"&&D.vectorTile)return D.parse(D.vectorTile,this.layerIndex,this.availableImages,this.actor)}))}abortTile(M){return I._(this,void 0,void 0,(function*(){let P=this.loading,D=M.uid;P&&P[D]&&P[D].abort&&(P[D].abort.abort(),delete P[D])}))}removeTile(M){return I._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[M.uid]&&delete this.loaded[M.uid]}))}}class K{constructor(){this.loaded={}}loadTile(M){return I._(this,void 0,void 0,(function*(){let{uid:P,encoding:D,rawImageData:N,redFactor:W,greenFactor:Y,blueFactor:te,baseShift:Z}=M,le=N.width+2,de=N.height+2,se=I.b(N)?new I.R({width:le,height:de},yield I.bw(N,-1,-1,le,de)):N,_e=new I.bx(P,se,D,W,Y,te,Z);return this.loaded=this.loaded||{},this.loaded[P]=_e,_e}))}removeTile(M){let P=this.loaded,D=M.uid;P&&P[D]&&delete P[D]}}function ht(U,M){if(U.length!==0){Dt(U[0],M);for(var P=1;P<U.length;P++)Dt(U[P],!M)}}function Dt(U,M){for(var P=0,D=0,N=0,W=U.length,Y=W-1;N<W;Y=N++){var te=(U[N][0]-U[Y][0])*(U[Y][1]+U[N][1]),Z=P+te;D+=Math.abs(P)>=Math.abs(te)?P-Z+te:te-Z+P,P=Z}P+D>=0!=!!M&&U.reverse()}var Nt=I.by((function U(M,P){var D,N=M&&M.type;if(N==="FeatureCollection")for(D=0;D<M.features.length;D++)U(M.features[D],P);else if(N==="GeometryCollection")for(D=0;D<M.geometries.length;D++)U(M.geometries[D],P);else if(N==="Feature")U(M.geometry,P);else if(N==="Polygon")ht(M.coordinates,P);else if(N==="MultiPolygon")for(D=0;D<M.coordinates.length;D++)ht(M.coordinates[D],P);return M}));let Jt=I.bt.VectorTileFeature.prototype.toGeoJSON;var li={exports:{}},$i=I.bz,et=I.bt.VectorTileFeature,He=Je;function Je(U,M){this.options=M||{},this.features=U,this.length=U.length}function Pt(U,M){this.id=typeof U.id=="number"?U.id:void 0,this.type=U.type,this.rawGeometry=U.type===1?[U.geometry]:U.geometry,this.properties=U.tags,this.extent=M||4096}Je.prototype.feature=function(U){return new Pt(this.features[U],this.options.extent)},Pt.prototype.loadGeometry=function(){var U=this.rawGeometry;this.geometry=[];for(var M=0;M<U.length;M++){for(var P=U[M],D=[],N=0;N<P.length;N++)D.push(new $i(P[N][0],P[N][1]));this.geometry.push(D)}return this.geometry},Pt.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var U=this.geometry,M=1/0,P=-1/0,D=1/0,N=-1/0,W=0;W<U.length;W++)for(var Y=U[W],te=0;te<Y.length;te++){var Z=Y[te];M=Math.min(M,Z.x),P=Math.max(P,Z.x),D=Math.min(D,Z.y),N=Math.max(N,Z.y)}return[M,D,P,N]},Pt.prototype.toGeoJSON=et.prototype.toGeoJSON;var Mt=I.bA,Vt=He;function _t(U){var M=new Mt;return(function(P,D){for(var N in P.layers)D.writeMessage(3,yi,P.layers[N])})(U,M),M.finish()}function yi(U,M){var P;M.writeVarintField(15,U.version||1),M.writeStringField(1,U.name||""),M.writeVarintField(5,U.extent||4096);var D={keys:[],values:[],keycache:{},valuecache:{}};for(P=0;P<U.length;P++)D.feature=U.feature(P),M.writeMessage(2,Ye,D);var N=D.keys;for(P=0;P<N.length;P++)M.writeStringField(3,N[P]);var W=D.values;for(P=0;P<W.length;P++)M.writeMessage(4,Qt,W[P])}function Ye(U,M){var P=U.feature;P.id!==void 0&&M.writeVarintField(1,P.id),M.writeMessage(2,Yt,U),M.writeVarintField(3,P.type),M.writeMessage(4,st,P)}function Yt(U,M){var P=U.feature,D=U.keys,N=U.values,W=U.keycache,Y=U.valuecache;for(var te in P.properties){var Z=P.properties[te],le=W[te];if(Z!==null){le===void 0&&(D.push(te),W[te]=le=D.length-1),M.writeVarint(le);var de=typeof Z;de!=="string"&&de!=="boolean"&&de!=="number"&&(Z=JSON.stringify(Z));var se=de+":"+Z,_e=Y[se];_e===void 0&&(N.push(Z),Y[se]=_e=N.length-1),M.writeVarint(_e)}}}function ze(U,M){return(M<<3)+(7&U)}function tt(U){return U<<1^U>>31}function st(U,M){for(var P=U.loadGeometry(),D=U.type,N=0,W=0,Y=P.length,te=0;te<Y;te++){var Z=P[te],le=1;D===1&&(le=Z.length),M.writeVarint(ze(1,le));for(var de=D===3?Z.length-1:Z.length,se=0;se<de;se++){se===1&&D!==1&&M.writeVarint(ze(2,de-1));var _e=Z[se].x-N,Ne=Z[se].y-W;M.writeVarint(tt(_e)),M.writeVarint(tt(Ne)),N+=_e,W+=Ne}D===3&&M.writeVarint(ze(7,1))}}function Qt(U,M){var P=typeof U;P==="string"?M.writeStringField(1,U):P==="boolean"?M.writeBooleanField(7,U):P==="number"&&(U%1!=0?M.writeDoubleField(3,U):U<0?M.writeSVarintField(6,U):M.writeVarintField(5,U))}li.exports=_t,li.exports.fromVectorTileJs=_t,li.exports.fromGeojsonVt=function(U,M){M=M||{};var P={};for(var D in U)P[D]=new Vt(U[D].features,M),P[D].name=D,P[D].version=M.version,P[D].extent=M.extent;return _t({layers:P})},li.exports.GeoJSONWrapper=Vt;var qt=I.by(li.exports);let Qi={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:U=>U},er=Math.fround||(ci=new Float32Array(1),U=>(ci[0]=+U,ci[0]));var ci;let Zt=3,tr=5,xn=6;class Or{constructor(M){this.options=Object.assign(Object.create(Qi),M),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(M){let{log:P,minZoom:D,maxZoom:N}=this.options;P&&console.time("total time");let W=`prepare ${M.length} points`;P&&console.time(W),this.points=M;let Y=[];for(let Z=0;Z<M.length;Z++){let le=M[Z];if(!le.geometry)continue;let[de,se]=le.geometry.coordinates,_e=er(Di(de)),Ne=er(ir(se));Y.push(_e,Ne,1/0,Z,-1,1),this.options.reduce&&Y.push(0)}let te=this.trees[N+1]=this._createTree(Y);P&&console.timeEnd(W);for(let Z=N;Z>=D;Z--){let le=+Date.now();te=this.trees[Z]=this._createTree(this._cluster(te,Z)),P&&console.log("z%d: %d clusters in %dms",Z,te.numItems,+Date.now()-le)}return P&&console.timeEnd("total time"),this}getClusters(M,P){let D=((M[0]+180)%360+360)%360-180,N=Math.max(-90,Math.min(90,M[1])),W=M[2]===180?180:((M[2]+180)%360+360)%360-180,Y=Math.max(-90,Math.min(90,M[3]));if(M[2]-M[0]>=360)D=-180,W=180;else if(D>W){let se=this.getClusters([D,N,180,Y],P),_e=this.getClusters([-180,N,W,Y],P);return se.concat(_e)}let te=this.trees[this._limitZoom(P)],Z=te.range(Di(D),ir(Y),Di(W),ir(N)),le=te.data,de=[];for(let se of Z){let _e=this.stride*se;de.push(le[_e+tr]>1?yr(le,_e,this.clusterProps):this.points[le[_e+Zt]])}return de}getChildren(M){let P=this._getOriginId(M),D=this._getOriginZoom(M),N="No cluster with the specified id.",W=this.trees[D];if(!W)throw new Error(N);let Y=W.data;if(P*this.stride>=Y.length)throw new Error(N);let te=this.options.radius/(this.options.extent*Math.pow(2,D-1)),Z=W.within(Y[P*this.stride],Y[P*this.stride+1],te),le=[];for(let de of Z){let se=de*this.stride;Y[se+4]===M&&le.push(Y[se+tr]>1?yr(Y,se,this.clusterProps):this.points[Y[se+Zt]])}if(le.length===0)throw new Error(N);return le}getLeaves(M,P,D){let N=[];return this._appendLeaves(N,M,P=P||10,D=D||0,0),N}getTile(M,P,D){let N=this.trees[this._limitZoom(M)],W=Math.pow(2,M),{extent:Y,radius:te}=this.options,Z=te/Y,le=(D-Z)/W,de=(D+1+Z)/W,se={features:[]};return this._addTileFeatures(N.range((P-Z)/W,le,(P+1+Z)/W,de),N.data,P,D,W,se),P===0&&this._addTileFeatures(N.range(1-Z/W,le,1,de),N.data,W,D,W,se),P===W-1&&this._addTileFeatures(N.range(0,le,Z/W,de),N.data,-1,D,W,se),se.features.length?se:null}getClusterExpansionZoom(M){let P=this._getOriginZoom(M)-1;for(;P<=this.options.maxZoom;){let D=this.getChildren(M);if(P++,D.length!==1)break;M=D[0].properties.cluster_id}return P}_appendLeaves(M,P,D,N,W){let Y=this.getChildren(P);for(let te of Y){let Z=te.properties;if(Z&&Z.cluster?W+Z.point_count<=N?W+=Z.point_count:W=this._appendLeaves(M,Z.cluster_id,D,N,W):W<N?W++:M.push(te),M.length===D)break}return W}_createTree(M){let P=new I.av(M.length/this.stride|0,this.options.nodeSize,Float32Array);for(let D=0;D<M.length;D+=this.stride)P.add(M[D],M[D+1]);return P.finish(),P.data=M,P}_addTileFeatures(M,P,D,N,W,Y){for(let te of M){let Z=te*this.stride,le=P[Z+tr]>1,de,se,_e;if(le)de=vn(P,Z,this.clusterProps),se=P[Z],_e=P[Z+1];else{let ut=this.points[P[Z+Zt]];de=ut.properties;let[Ke,dt]=ut.geometry.coordinates;se=Di(Ke),_e=ir(dt)}let Ne={type:1,geometry:[[Math.round(this.options.extent*(se*W-D)),Math.round(this.options.extent*(_e*W-N))]],tags:de},Ve;Ve=le||this.options.generateId?P[Z+Zt]:this.points[P[Z+Zt]].id,Ve!==void 0&&(Ne.id=Ve),Y.features.push(Ne)}}_limitZoom(M){return Math.max(this.options.minZoom,Math.min(Math.floor(+M),this.options.maxZoom+1))}_cluster(M,P){let{radius:D,extent:N,reduce:W,minPoints:Y}=this.options,te=D/(N*Math.pow(2,P)),Z=M.data,le=[],de=this.stride;for(let se=0;se<Z.length;se+=de){if(Z[se+2]<=P)continue;Z[se+2]=P;let _e=Z[se],Ne=Z[se+1],Ve=M.within(Z[se],Z[se+1],te),ut=Z[se+tr],Ke=ut;for(let dt of Ve){let ot=dt*de;Z[ot+2]>P&&(Ke+=Z[ot+tr])}if(Ke>ut&&Ke>=Y){let dt,ot=_e*ut,Wt=Ne*ut,Ft=-1,rt=((se/de|0)<<5)+(P+1)+this.points.length;for(let xt of Ve){let Rt=xt*de;if(Z[Rt+2]<=P)continue;Z[Rt+2]=P;let ti=Z[Rt+tr];ot+=Z[Rt]*ti,Wt+=Z[Rt+1]*ti,Z[Rt+4]=rt,W&&(dt||(dt=this._map(Z,se,!0),Ft=this.clusterProps.length,this.clusterProps.push(dt)),W(dt,this._map(Z,Rt)))}Z[se+4]=rt,le.push(ot/Ke,Wt/Ke,1/0,rt,-1,Ke),W&&le.push(Ft)}else{for(let dt=0;dt<de;dt++)le.push(Z[se+dt]);if(Ke>1)for(let dt of Ve){let ot=dt*de;if(!(Z[ot+2]<=P)){Z[ot+2]=P;for(let Wt=0;Wt<de;Wt++)le.push(Z[ot+Wt])}}}}return le}_getOriginId(M){return M-this.points.length>>5}_getOriginZoom(M){return(M-this.points.length)%32}_map(M,P,D){if(M[P+tr]>1){let Y=this.clusterProps[M[P+xn]];return D?Object.assign({},Y):Y}let N=this.points[M[P+Zt]].properties,W=this.options.map(N);return D&&W===N?Object.assign({},W):W}}function yr(U,M,P){return{type:"Feature",id:U[M+Zt],properties:vn(U,M,P),geometry:{type:"Point",coordinates:[(D=U[M],360*(D-.5)),Yr(U[M+1])]}};var D}function vn(U,M,P){let D=U[M+tr],N=D>=1e4?`${Math.round(D/1e3)}k`:D>=1e3?Math.round(D/100)/10+"k":D,W=U[M+xn],Y=W===-1?{}:Object.assign({},P[W]);return Object.assign(Y,{cluster:!0,cluster_id:U[M+Zt],point_count:D,point_count_abbreviated:N})}function Di(U){return U/360+.5}function ir(U){let M=Math.sin(U*Math.PI/180),P=.5-.25*Math.log((1+M)/(1-M))/Math.PI;return P<0?0:P>1?1:P}function Yr(U){let M=(180-360*U)*Math.PI/180;return 360*Math.atan(Math.exp(M))/Math.PI-90}function Qr(U,M,P,D){let N=D,W=M+(P-M>>1),Y,te=P-M,Z=U[M],le=U[M+1],de=U[P],se=U[P+1];for(let _e=M+3;_e<P;_e+=3){let Ne=ls(U[_e],U[_e+1],Z,le,de,se);if(Ne>N)Y=_e,N=Ne;else if(Ne===N){let Ve=Math.abs(_e-W);Ve<te&&(Y=_e,te=Ve)}}N>D&&(Y-M>3&&Qr(U,M,Y,D),U[Y+2]=N,P-Y>3&&Qr(U,Y,P,D))}function ls(U,M,P,D,N,W){let Y=N-P,te=W-D;if(Y!==0||te!==0){let Z=((U-P)*Y+(M-D)*te)/(Y*Y+te*te);Z>1?(P=N,D=W):Z>0&&(P+=Y*Z,D+=te*Z)}return Y=U-P,te=M-D,Y*Y+te*te}function Er(U,M,P,D){let N={id:U??null,type:M,geometry:P,tags:D,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(M==="Point"||M==="MultiPoint"||M==="LineString")Nr(N,P);else if(M==="Polygon")Nr(N,P[0]);else if(M==="MultiLineString")for(let W of P)Nr(N,W);else if(M==="MultiPolygon")for(let W of P)Nr(N,W[0]);return N}function Nr(U,M){for(let P=0;P<M.length;P+=3)U.minX=Math.min(U.minX,M[P]),U.minY=Math.min(U.minY,M[P+1]),U.maxX=Math.max(U.maxX,M[P]),U.maxY=Math.max(U.maxY,M[P+1])}function Vr(U,M,P,D){if(!M.geometry)return;let N=M.geometry.coordinates;if(N&&N.length===0)return;let W=M.geometry.type,Y=Math.pow(P.tolerance/((1<<P.maxZoom)*P.extent),2),te=[],Z=M.id;if(P.promoteId?Z=M.properties[P.promoteId]:P.generateId&&(Z=D||0),W==="Point")bn(N,te);else if(W==="MultiPoint")for(let le of N)bn(le,te);else if(W==="LineString")oe(N,te,Y,!1);else if(W==="MultiLineString"){if(P.lineMetrics){for(let le of N)te=[],oe(le,te,Y,!1),U.push(Er(Z,"LineString",te,M.properties));return}en(N,te,Y,!1)}else if(W==="Polygon")en(N,te,Y,!0);else{if(W!=="MultiPolygon"){if(W==="GeometryCollection"){for(let le of M.geometry.geometries)Vr(U,{id:Z,geometry:le,properties:M.properties},P,D);return}throw new Error("Input data is not a valid GeoJSON object.")}for(let le of N){let de=[];en(le,de,Y,!0),te.push(de)}}U.push(Er(Z,W,te,M.properties))}function bn(U,M){M.push(cs(U[0]),mt(U[1]),0)}function oe(U,M,P,D){let N,W,Y=0;for(let Z=0;Z<U.length;Z++){let le=cs(U[Z][0]),de=mt(U[Z][1]);M.push(le,de,0),Z>0&&(Y+=D?(N*de-le*W)/2:Math.sqrt(Math.pow(le-N,2)+Math.pow(de-W,2))),N=le,W=de}let te=M.length-3;M[2]=1,Qr(M,0,te,P),M[te+2]=1,M.size=Math.abs(Y),M.start=0,M.end=M.size}function en(U,M,P,D){for(let N=0;N<U.length;N++){let W=[];oe(U[N],W,P,D),M.push(W)}}function cs(U){return U/360+.5}function mt(U){let M=Math.sin(U*Math.PI/180),P=.5-.25*Math.log((1+M)/(1-M))/Math.PI;return P<0?0:P>1?1:P}function Bt(U,M,P,D,N,W,Y,te){if(D/=M,W>=(P/=M)&&Y<D)return U;if(Y<P||W>=D)return null;let Z=[];for(let le of U){let de=le.geometry,se=le.type,_e=N===0?le.minX:le.minY,Ne=N===0?le.maxX:le.maxY;if(_e>=P&&Ne<D){Z.push(le);continue}if(Ne<P||_e>=D)continue;let Ve=[];if(se==="Point"||se==="MultiPoint")hs(de,Ve,P,D,N);else if(se==="LineString")Ur(de,Ve,P,D,N,!1,te.lineMetrics);else if(se==="MultiLineString")wn(de,Ve,P,D,N,!1);else if(se==="Polygon")wn(de,Ve,P,D,N,!0);else if(se==="MultiPolygon")for(let ut of de){let Ke=[];wn(ut,Ke,P,D,N,!0),Ke.length&&Ve.push(Ke)}if(Ve.length){if(te.lineMetrics&&se==="LineString"){for(let ut of Ve)Z.push(Er(le.id,se,ut,le.tags));continue}se!=="LineString"&&se!=="MultiLineString"||(Ve.length===1?(se="LineString",Ve=Ve[0]):se="MultiLineString"),se!=="Point"&&se!=="MultiPoint"||(se=Ve.length===3?"Point":"MultiPoint"),Z.push(Er(le.id,se,Ve,le.tags))}}return Z.length?Z:null}function hs(U,M,P,D,N){for(let W=0;W<U.length;W+=3){let Y=U[W+N];Y>=P&&Y<=D&&qi(M,U[W],U[W+1],U[W+2])}}function Ur(U,M,P,D,N,W,Y){let te=kr(U),Z=N===0?us:ds,le,de,se=U.start;for(let Ke=0;Ke<U.length-3;Ke+=3){let dt=U[Ke],ot=U[Ke+1],Wt=U[Ke+2],Ft=U[Ke+3],rt=U[Ke+4],xt=N===0?dt:ot,Rt=N===0?Ft:rt,ti=!1;Y&&(le=Math.sqrt(Math.pow(dt-Ft,2)+Math.pow(ot-rt,2))),xt<P?Rt>P&&(de=Z(te,dt,ot,Ft,rt,P),Y&&(te.start=se+le*de)):xt>D?Rt<D&&(de=Z(te,dt,ot,Ft,rt,D),Y&&(te.start=se+le*de)):qi(te,dt,ot,Wt),Rt<P&&xt>=P&&(de=Z(te,dt,ot,Ft,rt,P),ti=!0),Rt>D&&xt<=D&&(de=Z(te,dt,ot,Ft,rt,D),ti=!0),!W&&ti&&(Y&&(te.end=se+le*de),M.push(te),te=kr(U)),Y&&(se+=le)}let _e=U.length-3,Ne=U[_e],Ve=U[_e+1],ut=N===0?Ne:Ve;ut>=P&&ut<=D&&qi(te,Ne,Ve,U[_e+2]),_e=te.length-3,W&&_e>=3&&(te[_e]!==te[0]||te[_e+1]!==te[1])&&qi(te,te[0],te[1],te[2]),te.length&&M.push(te)}function kr(U){let M=[];return M.size=U.size,M.start=U.start,M.end=U.end,M}function wn(U,M,P,D,N,W){for(let Y of U)Ur(Y,M,P,D,N,W,!1)}function qi(U,M,P,D){U.push(M,P,D)}function us(U,M,P,D,N,W){let Y=(W-M)/(D-M);return qi(U,W,P+(N-P)*Y,1),Y}function ds(U,M,P,D,N,W){let Y=(W-P)/(N-P);return qi(U,M+(D-M)*Y,W,1),Y}function ge(U,M){let P=[];for(let D=0;D<U.length;D++){let N=U[D],W=N.type,Y;if(W==="Point"||W==="MultiPoint"||W==="LineString")Y=xr(N.geometry,M);else if(W==="MultiLineString"||W==="Polygon"){Y=[];for(let te of N.geometry)Y.push(xr(te,M))}else if(W==="MultiPolygon"){Y=[];for(let te of N.geometry){let Z=[];for(let le of te)Z.push(xr(le,M));Y.push(Z)}}P.push(Er(N.id,W,Y,N.tags))}return P}function xr(U,M){let P=[];P.size=U.size,U.start!==void 0&&(P.start=U.start,P.end=U.end);for(let D=0;D<U.length;D+=3)P.push(U[D]+M,U[D+1],U[D+2]);return P}function xi(U,M){if(U.transformed)return U;let P=1<<U.z,D=U.x,N=U.y;for(let W of U.features){let Y=W.geometry,te=W.type;if(W.geometry=[],te===1)for(let Z=0;Z<Y.length;Z+=2)W.geometry.push(vr(Y[Z],Y[Z+1],M,P,D,N));else for(let Z=0;Z<Y.length;Z++){let le=[];for(let de=0;de<Y[Z].length;de+=2)le.push(vr(Y[Z][de],Y[Z][de+1],M,P,D,N));W.geometry.push(le)}}return U.transformed=!0,U}function vr(U,M,P,D,N,W){return[Math.round(P*(U*D-N)),Math.round(P*(M*D-W))]}function jr(U,M,P,D,N){let W=M===N.maxZoom?0:N.tolerance/((1<<M)*N.extent),Y={features:[],numPoints:0,numSimplified:0,numFeatures:U.length,source:null,x:P,y:D,z:M,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(let te of U)ve(Y,te,W,N);return Y}function ve(U,M,P,D){let N=M.geometry,W=M.type,Y=[];if(U.minX=Math.min(U.minX,M.minX),U.minY=Math.min(U.minY,M.minY),U.maxX=Math.max(U.maxX,M.maxX),U.maxY=Math.max(U.maxY,M.maxY),W==="Point"||W==="MultiPoint")for(let te=0;te<N.length;te+=3)Y.push(N[te],N[te+1]),U.numPoints++,U.numSimplified++;else if(W==="LineString")it(Y,N,U,P,!1,!1);else if(W==="MultiLineString"||W==="Polygon")for(let te=0;te<N.length;te++)it(Y,N[te],U,P,W==="Polygon",te===0);else if(W==="MultiPolygon")for(let te=0;te<N.length;te++){let Z=N[te];for(let le=0;le<Z.length;le++)it(Y,Z[le],U,P,!0,le===0)}if(Y.length){let te=M.tags||null;if(W==="LineString"&&D.lineMetrics){te={};for(let le in M.tags)te[le]=M.tags[le];te.mapbox_clip_start=N.start/N.size,te.mapbox_clip_end=N.end/N.size}let Z={geometry:Y,type:W==="Polygon"||W==="MultiPolygon"?3:W==="LineString"||W==="MultiLineString"?2:1,tags:te};M.id!==null&&(Z.id=M.id),U.features.push(Z)}}function it(U,M,P,D,N,W){let Y=D*D;if(D>0&&M.size<(N?Y:D))return void(P.numPoints+=M.length/3);let te=[];for(let Z=0;Z<M.length;Z+=3)(D===0||M[Z+2]>Y)&&(P.numSimplified++,te.push(M[Z],M[Z+1])),P.numPoints++;N&&(function(Z,le){let de=0;for(let se=0,_e=Z.length,Ne=_e-2;se<_e;Ne=se,se+=2)de+=(Z[se]-Z[Ne])*(Z[se+1]+Z[Ne+1]);if(de>0===le)for(let se=0,_e=Z.length;se<_e/2;se+=2){let Ne=Z[se],Ve=Z[se+1];Z[se]=Z[_e-2-se],Z[se+1]=Z[_e-1-se],Z[_e-2-se]=Ne,Z[_e-1-se]=Ve}})(te,W),U.push(te)}let qe={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class Ii{constructor(M,P){let D=(P=this.options=(function(W,Y){for(let te in Y)W[te]=Y[te];return W})(Object.create(qe),P)).debug;if(D&&console.time("preprocess data"),P.maxZoom<0||P.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(P.promoteId&&P.generateId)throw new Error("promoteId and generateId cannot be used together.");let N=(function(W,Y){let te=[];if(W.type==="FeatureCollection")for(let Z=0;Z<W.features.length;Z++)Vr(te,W.features[Z],Y,Z);else Vr(te,W.type==="Feature"?W:{geometry:W},Y);return te})(M,P);this.tiles={},this.tileCoords=[],D&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",P.indexMaxZoom,P.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),N=(function(W,Y){let te=Y.buffer/Y.extent,Z=W,le=Bt(W,1,-1-te,te,0,-1,2,Y),de=Bt(W,1,1-te,2+te,0,-1,2,Y);return(le||de)&&(Z=Bt(W,1,-te,1+te,0,-1,2,Y)||[],le&&(Z=ge(le,1).concat(Z)),de&&(Z=Z.concat(ge(de,-1)))),Z})(N,P),N.length&&this.splitTile(N,0,0,0),D&&(N.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,P,D,N,W,Y,te){let Z=[M,P,D,N],le=this.options,de=le.debug;for(;Z.length;){N=Z.pop(),D=Z.pop(),P=Z.pop(),M=Z.pop();let se=1<<P,_e=rr(P,D,N),Ne=this.tiles[_e];if(!Ne&&(de>1&&console.time("creation"),Ne=this.tiles[_e]=jr(M,P,D,N,le),this.tileCoords.push({z:P,x:D,y:N}),de)){de>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",P,D,N,Ne.numFeatures,Ne.numPoints,Ne.numSimplified),console.timeEnd("creation"));let ti=`z${P}`;this.stats[ti]=(this.stats[ti]||0)+1,this.total++}if(Ne.source=M,W==null){if(P===le.indexMaxZoom||Ne.numPoints<=le.indexMaxPoints)continue}else{if(P===le.maxZoom||P===W)continue;if(W!=null){let ti=W-P;if(D!==Y>>ti||N!==te>>ti)continue}}if(Ne.source=null,M.length===0)continue;de>1&&console.time("clipping");let Ve=.5*le.buffer/le.extent,ut=.5-Ve,Ke=.5+Ve,dt=1+Ve,ot=null,Wt=null,Ft=null,rt=null,xt=Bt(M,se,D-Ve,D+Ke,0,Ne.minX,Ne.maxX,le),Rt=Bt(M,se,D+ut,D+dt,0,Ne.minX,Ne.maxX,le);M=null,xt&&(ot=Bt(xt,se,N-Ve,N+Ke,1,Ne.minY,Ne.maxY,le),Wt=Bt(xt,se,N+ut,N+dt,1,Ne.minY,Ne.maxY,le),xt=null),Rt&&(Ft=Bt(Rt,se,N-Ve,N+Ke,1,Ne.minY,Ne.maxY,le),rt=Bt(Rt,se,N+ut,N+dt,1,Ne.minY,Ne.maxY,le),Rt=null),de>1&&console.timeEnd("clipping"),Z.push(ot||[],P+1,2*D,2*N),Z.push(Wt||[],P+1,2*D,2*N+1),Z.push(Ft||[],P+1,2*D+1,2*N),Z.push(rt||[],P+1,2*D+1,2*N+1)}}getTile(M,P,D){M=+M,P=+P,D=+D;let N=this.options,{extent:W,debug:Y}=N;if(M<0||M>24)return null;let te=1<<M,Z=rr(M,P=P+te&te-1,D);if(this.tiles[Z])return xi(this.tiles[Z],W);Y>1&&console.log("drilling down to z%d-%d-%d",M,P,D);let le,de=M,se=P,_e=D;for(;!le&&de>0;)de--,se>>=1,_e>>=1,le=this.tiles[rr(de,se,_e)];return le&&le.source?(Y>1&&(console.log("found parent tile z%d-%d-%d",de,se,_e),console.time("drilling down")),this.splitTile(le.source,de,se,_e,M,P,D),Y>1&&console.timeEnd("drilling down"),this.tiles[Z]?xi(this.tiles[Z],W):null):null}}function rr(U,M,P){return 32*((1<<U)*P+M)+U}function Xe(U,M){return M?U.properties[M]:U.id}function br(U,M){if(U==null)return!0;if(U.type==="Feature")return Xe(U,M)!=null;if(U.type==="FeatureCollection"){let P=new Set;for(let D of U.features){let N=Xe(D,M);if(N==null||P.has(N))return!1;P.add(N)}return!0}return!1}function zr(U,M){let P=new Map;if(U!=null)if(U.type==="Feature")P.set(Xe(U,M),U);else for(let D of U.features)P.set(Xe(D,M),D);return P}class $r extends pe{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(M,P){return I._(this,void 0,void 0,(function*(){let D=M.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");let N=this._geoJSONIndex.getTile(D.z,D.x,D.y);if(!N)return null;let W=new class{constructor(te){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=I.X,this.length=te.length,this._features=te}feature(te){return new class{constructor(Z){this._feature=Z,this.extent=I.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){let Z=[];for(let le of this._feature.geometry)Z.push([new I.P(le[0],le[1])]);return Z}{let Z=[];for(let le of this._feature.geometry){let de=[];for(let se of le)de.push(new I.P(se[0],se[1]));Z.push(de)}return Z}}toGeoJSON(Z,le,de){return Jt.call(this,Z,le,de)}}(this._features[te])}}(N.features),Y=qt(W);return Y.byteOffset===0&&Y.byteLength===Y.buffer.byteLength||(Y=new Uint8Array(Y)),{vectorTile:W,rawData:Y.buffer}}))}loadData(M){return I._(this,void 0,void 0,(function*(){var P;(P=this._pendingRequest)===null||P===void 0||P.abort();let D=!!(M&&M.request&&M.request.collectResourceTiming)&&new I.bv(M.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(M,this._pendingRequest),this._geoJSONIndex=M.cluster?new Or((function({superclusterOptions:Y,clusterProperties:te}){if(!te||!Y)return Y;let Z={},le={},de={accumulated:null,zoom:0},se={properties:null},_e=Object.keys(te);for(let Ne of _e){let[Ve,ut]=te[Ne],Ke=I.bC(ut),dt=I.bC(typeof Ve=="string"?[Ve,["accumulated"],["get",Ne]]:Ve);Z[Ne]=Ke.value,le[Ne]=dt.value}return Y.map=Ne=>{se.properties=Ne;let Ve={};for(let ut of _e)Ve[ut]=Z[ut].evaluate(de,se);return Ve},Y.reduce=(Ne,Ve)=>{se.properties=Ve;for(let ut of _e)de.accumulated=Ne[ut],Ne[ut]=le[ut].evaluate(de,se)},Y})(M)).load((yield this._pendingData).features):(N=yield this._pendingData,new Ii(N,M.geojsonVtOptions)),this.loaded={};let W={};if(D){let Y=D.finish();Y&&(W.resourceTiming={},W.resourceTiming[M.source]=JSON.parse(JSON.stringify(Y)))}return W}catch(W){if(delete this._pendingRequest,I.bB(W))return{abandoned:!0};throw W}var N}))}getData(){return I._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(M){let P=this.loaded;return P&&P[M.uid]?super.reloadTile(M):this.loadTile(M)}loadAndProcessGeoJSON(M,P){return I._(this,void 0,void 0,(function*(){let D=yield this.loadGeoJSON(M,P);if(delete this._pendingRequest,typeof D!="object")throw new Error(`Input data given to '${M.source}' is not a valid GeoJSON object.`);if(Nt(D,!0),M.filter){let N=I.bC(M.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(N.result==="error")throw new Error(N.value.map((Y=>`${Y.key}: ${Y.message}`)).join(", "));D={type:"FeatureCollection",features:D.features.filter((Y=>N.value.evaluate({zoom:0},Y)))}}return D}))}loadGeoJSON(M,P){return I._(this,void 0,void 0,(function*(){let{promoteId:D}=M;if(M.request){let N=yield I.h(M.request,P);return this._dataUpdateable=br(N.data,D)?zr(N.data,D):void 0,N.data}if(typeof M.data=="string")try{let N=JSON.parse(M.data);return this._dataUpdateable=br(N,D)?zr(N,D):void 0,N}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(N,W,Y){var te,Z,le,de;if(W.removeAll&&N.clear(),W.remove)for(let se of W.remove)N.delete(se);if(W.add)for(let se of W.add){let _e=Xe(se,Y);_e!=null&&N.set(_e,se)}if(W.update)for(let se of W.update){let _e=N.get(se.id);if(_e==null)continue;let Ne=!se.removeAllProperties&&(((te=se.removeProperties)===null||te===void 0?void 0:te.length)>0||((Z=se.addOrUpdateProperties)===null||Z===void 0?void 0:Z.length)>0);if((se.newGeometry||se.removeAllProperties||Ne)&&(_e=Object.assign({},_e),N.set(se.id,_e),Ne&&(_e.properties=Object.assign({},_e.properties))),se.newGeometry&&(_e.geometry=se.newGeometry),se.removeAllProperties)_e.properties={};else if(((le=se.removeProperties)===null||le===void 0?void 0:le.length)>0)for(let Ve of se.removeProperties)Object.prototype.hasOwnProperty.call(_e.properties,Ve)&&delete _e.properties[Ve];if(((de=se.addOrUpdateProperties)===null||de===void 0?void 0:de.length)>0)for(let{key:Ve,value:ut}of se.addOrUpdateProperties)_e.properties[Ve]=ut}})(this._dataUpdateable,M.dataDiff,D),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(M){return I._(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 wr{constructor(M){this.self=M,this.actor=new I.F(M),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(P,D)=>{if(this.externalWorkerSourceTypes[P])throw new Error(`Worker source with name "${P}" already registered.`);this.externalWorkerSourceTypes[P]=D},this.self.addProtocol=I.bi,this.self.removeProtocol=I.bj,this.self.registerRTLTextPlugin=P=>{if(I.bD.isParsed())throw new Error("RTL text plugin already registered.");I.bD.setMethods(P)},this.actor.registerMessageHandler("LDT",((P,D)=>this._getDEMWorkerSource(P,D.source).loadTile(D))),this.actor.registerMessageHandler("RDT",((P,D)=>I._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(P,D.source).removeTile(D)})))),this.actor.registerMessageHandler("GCEZ",((P,D)=>I._(this,void 0,void 0,(function*(){return this._getWorkerSource(P,D.type,D.source).getClusterExpansionZoom(D)})))),this.actor.registerMessageHandler("GCC",((P,D)=>I._(this,void 0,void 0,(function*(){return this._getWorkerSource(P,D.type,D.source).getClusterChildren(D)})))),this.actor.registerMessageHandler("GCL",((P,D)=>I._(this,void 0,void 0,(function*(){return this._getWorkerSource(P,D.type,D.source).getClusterLeaves(D)})))),this.actor.registerMessageHandler("LD",((P,D)=>this._getWorkerSource(P,D.type,D.source).loadData(D))),this.actor.registerMessageHandler("GD",((P,D)=>this._getWorkerSource(P,D.type,D.source).getData())),this.actor.registerMessageHandler("LT",((P,D)=>this._getWorkerSource(P,D.type,D.source).loadTile(D))),this.actor.registerMessageHandler("RT",((P,D)=>this._getWorkerSource(P,D.type,D.source).reloadTile(D))),this.actor.registerMessageHandler("AT",((P,D)=>this._getWorkerSource(P,D.type,D.source).abortTile(D))),this.actor.registerMessageHandler("RMT",((P,D)=>this._getWorkerSource(P,D.type,D.source).removeTile(D))),this.actor.registerMessageHandler("RS",((P,D)=>I._(this,void 0,void 0,(function*(){if(!this.workerSources[P]||!this.workerSources[P][D.type]||!this.workerSources[P][D.type][D.source])return;let N=this.workerSources[P][D.type][D.source];delete this.workerSources[P][D.type][D.source],N.removeSource!==void 0&&N.removeSource(D)})))),this.actor.registerMessageHandler("RM",(P=>I._(this,void 0,void 0,(function*(){delete this.layerIndexes[P],delete this.availableImages[P],delete this.workerSources[P],delete this.demWorkerSources[P]})))),this.actor.registerMessageHandler("SR",((P,D)=>I._(this,void 0,void 0,(function*(){this.referrer=D})))),this.actor.registerMessageHandler("SRPS",((P,D)=>this._syncRTLPluginState(P,D))),this.actor.registerMessageHandler("IS",((P,D)=>I._(this,void 0,void 0,(function*(){this.self.importScripts(D)})))),this.actor.registerMessageHandler("SI",((P,D)=>this._setImages(P,D))),this.actor.registerMessageHandler("UL",((P,D)=>I._(this,void 0,void 0,(function*(){this._getLayerIndex(P).update(D.layers,D.removedIds)})))),this.actor.registerMessageHandler("SL",((P,D)=>I._(this,void 0,void 0,(function*(){this._getLayerIndex(P).replace(D)}))))}_setImages(M,P){return I._(this,void 0,void 0,(function*(){this.availableImages[M]=P;for(let D in this.workerSources[M]){let N=this.workerSources[M][D];for(let W in N)N[W].availableImages=P}}))}_syncRTLPluginState(M,P){return I._(this,void 0,void 0,(function*(){if(I.bD.isParsed())return I.bD.getState();if(P.pluginStatus!=="loading")return I.bD.setState(P),P;let D=P.pluginURL;if(this.self.importScripts(D),I.bD.isParsed()){let N={pluginStatus:"loaded",pluginURL:D};return I.bD.setState(N),N}throw I.bD.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${D}`)}))}_getAvailableImages(M){let P=this.availableImages[M];return P||(P=[]),P}_getLayerIndex(M){let P=this.layerIndexes[M];return P||(P=this.layerIndexes[M]=new p),P}_getWorkerSource(M,P,D){if(this.workerSources[M]||(this.workerSources[M]={}),this.workerSources[M][P]||(this.workerSources[M][P]={}),!this.workerSources[M][P][D]){let N={sendAsync:(W,Y)=>(W.targetMapId=M,this.actor.sendAsync(W,Y))};switch(P){case"vector":this.workerSources[M][P][D]=new pe(N,this._getLayerIndex(M),this._getAvailableImages(M));break;case"geojson":this.workerSources[M][P][D]=new $r(N,this._getLayerIndex(M),this._getAvailableImages(M));break;default:this.workerSources[M][P][D]=new this.externalWorkerSourceTypes[P](N,this._getLayerIndex(M),this._getAvailableImages(M))}}return this.workerSources[M][P][D]}_getDEMWorkerSource(M,P){return this.demWorkerSources[M]||(this.demWorkerSources[M]={}),this.demWorkerSources[M][P]||(this.demWorkerSources[M][P]=new K),this.demWorkerSources[M][P]}}return I.i(self)&&(self.worker=new wr(self)),wr})),re("index",["exports","./shared"],(function(I,p){"use strict";var Se="4.7.1";let Ce,$e,pe={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:h=>new Promise(((e,n)=>{let o=requestAnimationFrame(e);h.signal.addEventListener("abort",(()=>{cancelAnimationFrame(o),n(p.c())}))})),getImageData(h,e=0){return this.getImageCanvasContext(h).getImageData(-e,-e,h.width+2*e,h.height+2*e)},getImageCanvasContext(h){let e=window.document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return e.width=h.width,e.height=h.height,n.drawImage(h,0,0,h.width,h.height),n},resolveURL:h=>(Ce||(Ce=document.createElement("a")),Ce.href=h,Ce.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&($e==null&&($e=matchMedia("(prefers-reduced-motion: reduce)")),$e.matches)}};class K{static testProp(e){if(!K.docStyle)return e[0];for(let n=0;n<e.length;n++)if(e[n]in K.docStyle)return e[n];return e[0]}static create(e,n,o){let a=window.document.createElement(e);return n!==void 0&&(a.className=n),o&&o.appendChild(a),a}static createNS(e,n){return window.document.createElementNS(e,n)}static disableDrag(){K.docStyle&&K.selectProp&&(K.userSelect=K.docStyle[K.selectProp],K.docStyle[K.selectProp]="none")}static enableDrag(){K.docStyle&&K.selectProp&&(K.docStyle[K.selectProp]=K.userSelect)}static setTransform(e,n){e.style[K.transformProp]=n}static addEventListener(e,n,o,a={}){e.addEventListener(n,o,"passive"in a?a:a.capture)}static removeEventListener(e,n,o,a={}){e.removeEventListener(n,o,"passive"in a?a:a.capture)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",K.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",K.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",K.suppressClickInternal,!0)}),0)}static getScale(e){let n=e.getBoundingClientRect();return{x:n.width/e.offsetWidth||1,y:n.height/e.offsetHeight||1,boundingClientRect:n}}static getPoint(e,n,o){let a=n.boundingClientRect;return new p.P((o.clientX-a.left)/n.x-e.clientLeft,(o.clientY-a.top)/n.y-e.clientTop)}static mousePos(e,n){let o=K.getScale(e);return K.getPoint(e,o,n)}static touchPos(e,n){let o=[],a=K.getScale(e);for(let c=0;c<n.length;c++)o.push(K.getPoint(e,a,n[c]));return o}static mouseButton(e){return e.button}static remove(e){e.parentNode&&e.parentNode.removeChild(e)}}K.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,K.selectProp=K.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),K.transformProp=K.testProp(["transform","WebkitTransform"]);let ht={supported:!1,testSupport:function(h){!Jt&&Nt&&(li?$i(h):Dt=h)}},Dt,Nt,Jt=!1,li=!1;function $i(h){let e=h.createTexture();h.bindTexture(h.TEXTURE_2D,e);try{if(h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,Nt),h.isContextLost())return;ht.supported=!0}catch{}h.deleteTexture(e),Jt=!0}var et;typeof document<"u"&&(Nt=document.createElement("img"),Nt.onload=()=>{Dt&&$i(Dt),Dt=null,li=!0},Nt.onerror=()=>{Jt=!0,Dt=null},Nt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),(function(h){let e,n,o,a;h.resetRequestQueue=()=>{e=[],n=0,o=0,a={}},h.addThrottleControl=y=>{let b=o++;return a[b]=y,b},h.removeThrottleControl=y=>{delete a[y],m()},h.getImage=(y,b,S=!0)=>new Promise(((T,E)=>{ht.supported&&(y.headers||(y.headers={}),y.headers.accept="image/webp,*/*"),p.e(y,{type:"image"}),e.push({abortController:b,requestParameters:y,supportImageRefresh:S,state:"queued",onError:L=>{E(L)},onSuccess:L=>{T(L)}}),m()}));let c=y=>p._(this,void 0,void 0,(function*(){y.state="running";let{requestParameters:b,supportImageRefresh:S,onError:T,onSuccess:E,abortController:L}=y,B=S===!1&&!p.i(self)&&!p.g(b.url)&&(!b.headers||Object.keys(b.headers).reduce(((q,G)=>q&&G==="accept"),!0));n++;let V=B?_(b,L):p.m(b,L);try{let q=yield V;delete y.abortController,y.state="completed",q.data instanceof HTMLImageElement||p.b(q.data)?E(q):q.data&&E({data:yield($=q.data,typeof createImageBitmap=="function"?p.d($):p.f($)),cacheControl:q.cacheControl,expires:q.expires})}catch(q){delete y.abortController,T(q)}finally{n--,m()}var $})),m=()=>{let y=(()=>{for(let b of Object.keys(a))if(a[b]())return!0;return!1})()?p.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:p.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let b=n;b<y&&e.length>0;b++){let S=e.shift();S.abortController.signal.aborted?b--:c(S)}},_=(y,b)=>new Promise(((S,T)=>{let E=new Image,L=y.url,B=y.credentials;B&&B==="include"?E.crossOrigin="use-credentials":(B&&B==="same-origin"||!p.s(L))&&(E.crossOrigin="anonymous"),b.signal.addEventListener("abort",(()=>{E.src="",T(p.c())})),E.fetchPriority="high",E.onload=()=>{E.onerror=E.onload=null,S({data:E})},E.onerror=()=>{E.onerror=E.onload=null,b.signal.aborted||T(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."))},E.src=L}))})(et||(et={})),et.resetRequestQueue();class He{constructor(e){this._transformRequestFn=e}transformRequest(e,n){return this._transformRequestFn&&this._transformRequestFn(e,n)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function Je(h){var e=new p.A(3);return e[0]=h[0],e[1]=h[1],e[2]=h[2],e}var Pt,Mt=function(h,e,n){return h[0]=e[0]-n[0],h[1]=e[1]-n[1],h[2]=e[2]-n[2],h};Pt=new p.A(3),p.A!=Float32Array&&(Pt[0]=0,Pt[1]=0,Pt[2]=0);var Vt=function(h){var e=h[0],n=h[1];return e*e+n*n};function _t(h){let e=[];if(typeof h=="string")e.push({id:"default",url:h});else if(h&&h.length>0){let n=[];for(let{id:o,url:a}of h){let c=`${o}${a}`;n.indexOf(c)===-1&&(n.push(c),e.push({id:o,url:a}))}}return e}function yi(h,e,n){let o=h.split("?");return o[0]+=`${e}${n}`,o.join("?")}(function(){var h=new p.A(2);p.A!=Float32Array&&(h[0]=0,h[1]=0)})();class Ye{constructor(e,n,o,a){this.context=e,this.format=o,this.texture=e.gl.createTexture(),this.update(n,a)}update(e,n,o){let{width:a,height:c}=e,m=!(this.size&&this.size[0]===a&&this.size[1]===c||o),{context:_}=this,{gl:y}=_;if(this.useMipmap=!!(n&&n.useMipmap),y.bindTexture(y.TEXTURE_2D,this.texture),_.pixelStoreUnpackFlipY.set(!1),_.pixelStoreUnpack.set(1),_.pixelStoreUnpackPremultiplyAlpha.set(this.format===y.RGBA&&(!n||n.premultiply!==!1)),m)this.size=[a,c],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||p.b(e)?y.texImage2D(y.TEXTURE_2D,0,this.format,this.format,y.UNSIGNED_BYTE,e):y.texImage2D(y.TEXTURE_2D,0,this.format,a,c,0,this.format,y.UNSIGNED_BYTE,e.data);else{let{x:b,y:S}=o||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||p.b(e)?y.texSubImage2D(y.TEXTURE_2D,0,b,S,y.RGBA,y.UNSIGNED_BYTE,e):y.texSubImage2D(y.TEXTURE_2D,0,b,S,a,c,y.RGBA,y.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&y.generateMipmap(y.TEXTURE_2D)}bind(e,n,o){let{context:a}=this,{gl:c}=a;c.bindTexture(c.TEXTURE_2D,this.texture),o!==c.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(o=c.LINEAR),e!==this.filter&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,e),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,o||e),this.filter=e),n!==this.wrap&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,n),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,n),this.wrap=n)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}function Yt(h){let{userImage:e}=h;return!!(e&&e.render&&e.render())&&(h.data.replace(new Uint8Array(e.data.buffer)),!0)}class ze extends p.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new p.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:n,promiseResolve:o}of this.requestors)o(this._getImagesForIds(n));this.requestors=[]}}getImage(e){let n=this.images[e];if(n&&!n.data&&n.spriteData){let o=n.spriteData;n.data=new p.R({width:o.width,height:o.height},o.context.getImageData(o.x,o.y,o.width,o.height).data),n.spriteData=null}return n}addImage(e,n){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,n)&&(this.images[e]=n)}_validate(e,n){let o=!0,a=n.data||n.spriteData;return this._validateStretch(n.stretchX,a&&a.width)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,a&&a.height)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "content" value`))),o=!1),o}_validateStretch(e,n){if(!e)return!0;let o=0;for(let a of e){if(a[0]<o||a[1]<a[0]||n<a[1])return!1;o=a[1]}return!0}_validateContent(e,n){if(!e)return!0;if(e.length!==4)return!1;let o=n.spriteData,a=o&&o.width||n.data.width,c=o&&o.height||n.data.height;return!(e[0]<0||a<e[0]||e[1]<0||c<e[1]||e[2]<0||a<e[2]||e[3]<0||c<e[3]||e[2]<e[0]||e[3]<e[1])}updateImage(e,n,o=!0){let a=this.getImage(e);if(o&&(a.data.width!==n.data.width||a.data.height!==n.data.height))throw new Error(`size mismatch between old image (${a.data.width}x${a.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=a.version+1,this.images[e]=n,this.updatedImages[e]=!0}removeImage(e){let n=this.images[e];delete this.images[e],delete this.patterns[e],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise(((n,o)=>{let a=!0;if(!this.isLoaded())for(let c of e)this.images[c]||(a=!1);this.isLoaded()||a?n(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:n})}))}_getImagesForIds(e){let n={};for(let o of e){let a=this.getImage(o);a||(this.fire(new p.k("styleimagemissing",{id:o})),a=this.getImage(o)),a?n[o]={data:a.data.clone(),pixelRatio:a.pixelRatio,sdf:a.sdf,version:a.version,stretchX:a.stretchX,stretchY:a.stretchY,content:a.content,textFitWidth:a.textFitWidth,textFitHeight:a.textFitHeight,hasRenderCallback:!!(a.userImage&&a.userImage.render)}:p.w(`Image "${o}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){let{width:e,height:n}=this.atlasImage;return{width:e,height:n}}getPattern(e){let n=this.patterns[e],o=this.getImage(e);if(!o)return null;if(n&&n.position.version===o.version)return n.position;if(n)n.position.version=o.version;else{let a={w:o.data.width+2,h:o.data.height+2,x:0,y:0},c=new p.I(a,o);this.patterns[e]={bin:a,position:c}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){let n=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new Ye(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){let e=[];for(let c in this.patterns)e.push(this.patterns[c].bin);let{w:n,h:o}=p.p(e),a=this.atlasImage;a.resize({width:n||1,height:o||1});for(let c in this.patterns){let{bin:m}=this.patterns[c],_=m.x+1,y=m.y+1,b=this.getImage(c).data,S=b.width,T=b.height;p.R.copy(b,a,{x:0,y:0},{x:_,y},{width:S,height:T}),p.R.copy(b,a,{x:0,y:T-1},{x:_,y:y-1},{width:S,height:1}),p.R.copy(b,a,{x:0,y:0},{x:_,y:y+T},{width:S,height:1}),p.R.copy(b,a,{x:S-1,y:0},{x:_-1,y},{width:1,height:T}),p.R.copy(b,a,{x:0,y:0},{x:_+S,y},{width:1,height:T})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;let o=this.getImage(n);o||p.w(`Image with ID: "${n}" was not found`),Yt(o)&&this.updateImage(n,o)}}}let tt=1e20;function st(h,e,n,o,a,c,m,_,y){for(let b=e;b<e+o;b++)Qt(h,n*c+b,c,a,m,_,y);for(let b=n;b<n+a;b++)Qt(h,b*c+e,1,o,m,_,y)}function Qt(h,e,n,o,a,c,m){c[0]=0,m[0]=-tt,m[1]=tt,a[0]=h[e];for(let _=1,y=0,b=0;_<o;_++){a[_]=h[e+_*n];let S=_*_;do{let T=c[y];b=(a[_]-a[T]+S-T*T)/(_-T)/2}while(b<=m[y]&&--y>-1);y++,c[y]=_,m[y]=b,m[y+1]=tt}for(let _=0,y=0;_<o;_++){for(;m[y+1]<_;)y++;let b=c[y],S=_-b;h[e+_*n]=a[b]+S*S}}class qt{constructor(e,n){this.requestManager=e,this.localIdeographFontFamily=n,this.entries={}}setURL(e){this.url=e}getGlyphs(e){return p._(this,void 0,void 0,(function*(){let n=[];for(let c in e)for(let m of e[c])n.push(this._getAndCacheGlyphsPromise(c,m));let o=yield Promise.all(n),a={};for(let{stack:c,id:m,glyph:_}of o)a[c]||(a[c]={}),a[c][m]=_&&{id:_.id,bitmap:_.bitmap.clone(),metrics:_.metrics};return a}))}_getAndCacheGlyphsPromise(e,n){return p._(this,void 0,void 0,(function*(){let o=this.entries[e];o||(o=this.entries[e]={glyphs:{},requests:{},ranges:{}});let a=o.glyphs[n];if(a!==void 0)return{stack:e,id:n,glyph:a};if(a=this._tinySDF(o,e,n),a)return o.glyphs[n]=a,{stack:e,id:n,glyph:a};let c=Math.floor(n/256);if(256*c>65535)throw new Error("glyphs > 65535 not supported");if(o.ranges[c])return{stack:e,id:n,glyph:a};if(!this.url)throw new Error("glyphsUrl is not set");if(!o.requests[c]){let _=qt.loadGlyphRange(e,c,this.url,this.requestManager);o.requests[c]=_}let m=yield o.requests[c];for(let _ in m)this._doesCharSupportLocalGlyph(+_)||(o.glyphs[+_]=m[+_]);return o.ranges[c]=!0,{stack:e,id:n,glyph:m[n]||null}}))}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))}_tinySDF(e,n,o){let a=this.localIdeographFontFamily;if(!a||!this._doesCharSupportLocalGlyph(o))return;let c=e.tinySDF;if(!c){let _="400";/bold/i.test(n)?_="900":/medium/i.test(n)?_="500":/light/i.test(n)&&(_="200"),c=e.tinySDF=new qt.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:a,fontWeight:_})}let m=c.draw(String.fromCharCode(o));return{id:o,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}}}}qt.loadGlyphRange=function(h,e,n,o){return p._(this,void 0,void 0,(function*(){let a=256*e,c=a+255,m=o.transformRequest(n.replace("{fontstack}",h).replace("{range}",`${a}-${c}`),"Glyphs"),_=yield p.l(m,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${e}, ${a}-${c}`);let y={};for(let b of p.n(_.data))y[b.id]=b;return y}))},qt.TinySDF=class{constructor({fontSize:h=24,buffer:e=3,radius:n=8,cutoff:o=.25,fontFamily:a="sans-serif",fontWeight:c="normal",fontStyle:m="normal"}={}){this.buffer=e,this.cutoff=o,this.radius=n;let _=this.size=h+4*e,y=this._createCanvas(_),b=this.ctx=y.getContext("2d",{willReadFrequently:!0});b.font=`${m} ${c} ${h}px ${a}`,b.textBaseline="alphabetic",b.textAlign="left",b.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(h){let e=document.createElement("canvas");return e.width=e.height=h,e}draw(h){let{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:a,actualBoundingBoxRight:c}=this.ctx.measureText(h),m=Math.ceil(n),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(c-a))),y=Math.min(this.size-this.buffer,m+Math.ceil(o)),b=_+2*this.buffer,S=y+2*this.buffer,T=Math.max(b*S,0),E=new Uint8ClampedArray(T),L={data:E,width:b,height:S,glyphWidth:_,glyphHeight:y,glyphTop:m,glyphLeft:0,glyphAdvance:e};if(_===0||y===0)return L;let{ctx:B,buffer:V,gridInner:$,gridOuter:q}=this;B.clearRect(V,V,_,y),B.fillText(h,V,V+m);let G=B.getImageData(V,V,_,y);q.fill(tt,0,T),$.fill(0,0,T);for(let F=0;F<y;F++)for(let J=0;J<_;J++){let Q=G.data[4*(F*_+J)+3]/255;if(Q===0)continue;let ne=(F+V)*b+J+V;if(Q===1)q[ne]=0,$[ne]=tt;else{let ue=.5-Q;q[ne]=ue>0?ue*ue:0,$[ne]=ue<0?ue*ue:0}}st(q,0,0,b,S,b,this.f,this.v,this.z),st($,V,V,_,y,b,this.f,this.v,this.z);for(let F=0;F<T;F++){let J=Math.sqrt(q[F])-Math.sqrt($[F]);E[F]=Math.round(255-255*(J/this.radius+this.cutoff))}return L}};class Qi{constructor(){this.specification=p.v.light.position}possiblyEvaluate(e,n){return p.x(e.expression.evaluate(n))}interpolate(e,n,o){return{x:p.y.number(e.x,n.x,o),y:p.y.number(e.y,n.y,o),z:p.y.number(e.z,n.z,o)}}}let er;class ci extends p.E{constructor(e){super(),er=er||new p.q({anchor:new p.D(p.v.light.anchor),position:new Qi,color:new p.D(p.v.light.color),intensity:new p.D(p.v.light.intensity)}),this._transitionable=new p.T(er),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,n={}){if(!this._validate(p.r,e,n))for(let o in e){let a=e[o];o.endsWith("-transition")?this._transitionable.setTransition(o.slice(0,-11),a):this._transitionable.setValue(o,a)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,o){return(!o||o.validate!==!1)&&p.t(this,e.call(p.u,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:p.v}))}}let Zt=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 tr extends p.E{constructor(e){super(),this._transitionable=new p.T(Zt),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new p.z(0))}setSky(e,n={}){if(!this._validate(p.B,e,n)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(let o in e){let a=e[o];o.endsWith("-transition")?this._transitionable.setTransition(o.slice(0,-11),a):this._transitionable.setValue(o,a)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,o={}){return o?.validate!==!1&&p.t(this,e.call(p.u,p.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:p.v})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class xn{constructor(e,n){this.width=e,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,n){let o=e.join(",")+String(n);return this.dashEntry[o]||(this.dashEntry[o]=this.addDash(e,n)),this.dashEntry[o]}getDashRanges(e,n,o){let a=[],c=e.length%2==1?-e[e.length-1]*o:0,m=e[0]*o,_=!0;a.push({left:c,right:m,isDash:_,zeroLength:e[0]===0});let y=e[0];for(let b=1;b<e.length;b++){_=!_;let S=e[b];c=y*o,y+=S,m=y*o,a.push({left:c,right:m,isDash:_,zeroLength:S===0})}return a}addRoundDash(e,n,o){let a=n/2;for(let c=-o;c<=o;c++){let m=this.width*(this.nextRow+o+c),_=0,y=e[_];for(let b=0;b<this.width;b++){b/y.right>1&&(y=e[++_]);let S=Math.abs(b-y.left),T=Math.abs(b-y.right),E=Math.min(S,T),L,B=c/o*(a+1);if(y.isDash){let V=a-Math.abs(B);L=Math.sqrt(E*E+V*V)}else L=a-Math.sqrt(E*E+B*B);this.data[m+b]=Math.max(0,Math.min(255,L+128))}}}addRegularDash(e){for(let _=e.length-1;_>=0;--_){let y=e[_],b=e[_+1];y.zeroLength?e.splice(_,1):b&&b.isDash===y.isDash&&(b.left=y.left,e.splice(_,1))}let n=e[0],o=e[e.length-1];n.isDash===o.isDash&&(n.left=o.left-this.width,o.right=n.right+this.width);let a=this.width*this.nextRow,c=0,m=e[c];for(let _=0;_<this.width;_++){_/m.right>1&&(m=e[++c]);let y=Math.abs(_-m.left),b=Math.abs(_-m.right),S=Math.min(y,b);this.data[a+_]=Math.max(0,Math.min(255,(m.isDash?S:-S)+128))}}addDash(e,n){let o=n?7:0,a=2*o+1;if(this.nextRow+a>this.height)return p.w("LineAtlas out of space"),null;let c=0;for(let _=0;_<e.length;_++)c+=e[_];if(c!==0){let _=this.width/c,y=this.getDashRanges(e,this.width,_);n?this.addRoundDash(y,_,o):this.addRegularDash(y)}let m={y:(this.nextRow+o+.5)/this.height,height:2*o/this.height,width:c};return this.nextRow+=a,this.dirty=!0,m}bind(e){let n=e.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}let Or="maplibre_preloaded_worker_pool";class yr{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<yr.workerCount;)this.workers.push(new Worker(p.a.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.numActive()===0&&(this.workers.forEach((n=>{n.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Or]}numActive(){return Object.keys(this.active).length}}let vn=Math.floor(pe.hardwareConcurrency/2),Di,ir;function Yr(){return Di||(Di=new yr),Di}yr.workerCount=p.C(globalThis)?Math.max(Math.min(vn,3),1):1;class Qr{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;let o=this.workerPool.acquire(n);for(let a=0;a<o.length;a++){let c=new p.F(o[a],n);c.name=`Worker ${a}`,this.actors.push(c)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,n){let o=[];for(let a of this.actors)o.push(a.sendAsync({type:e,data:n}));return Promise.all(o)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.actors.forEach((n=>{n.remove()})),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,n){for(let o of this.actors)o.registerMessageHandler(e,n)}}function ls(){return ir||(ir=new Qr(Yr(),p.G),ir.registerMessageHandler("GR",((h,e,n)=>p.m(e,n)))),ir}function Er(h,e){let n=p.H();return p.J(n,n,[1,1,0]),p.K(n,n,[.5*h.width,.5*h.height,1]),p.L(n,n,h.calculatePosMatrix(e.toUnwrapped()))}function Nr(h,e,n,o,a,c){let m=(function(T,E,L){if(T)for(let B of T){let V=E[B];if(V&&V.source===L&&V.type==="fill-extrusion")return!0}else for(let B in E){let V=E[B];if(V.source===L&&V.type==="fill-extrusion")return!0}return!1})(a&&a.layers,e,h.id),_=c.maxPitchScaleFactor(),y=h.tilesIn(o,_,m);y.sort(Vr);let b=[];for(let T of y)b.push({wrappedTileID:T.tileID.wrapped().key,queryResults:T.tile.queryRenderedFeatures(e,n,h._state,T.queryGeometry,T.cameraQueryGeometry,T.scale,a,c,_,Er(h.transform,T.tileID))});let S=(function(T){let E={},L={};for(let B of T){let V=B.queryResults,$=B.wrappedTileID,q=L[$]=L[$]||{};for(let G in V){let F=V[G],J=q[G]=q[G]||{},Q=E[G]=E[G]||[];for(let ne of F)J[ne.featureIndex]||(J[ne.featureIndex]=!0,Q.push(ne))}}return E})(b);for(let T in S)S[T].forEach((E=>{let L=E.feature,B=h.getFeatureState(L.layer["source-layer"],L.id);L.source=L.layer.source,L.layer["source-layer"]&&(L.sourceLayer=L.layer["source-layer"]),L.state=B}));return S}function Vr(h,e){let n=h.tileID,o=e.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function bn(h,e,n){return p._(this,void 0,void 0,(function*(){let o=h;if(h.url?o=(yield p.h(e.transformRequest(h.url,"Source"),n)).data:yield pe.frameAsync(n),!o)return null;let a=p.M(p.e(o,h),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in o&&o.vector_layers&&(a.vectorLayerIds=o.vector_layers.map((c=>c.id))),a}))}class oe{constructor(e,n){e&&(n?this.setSouthWest(e).setNorthEast(n):Array.isArray(e)&&(e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof p.N?new p.N(e.lng,e.lat):p.N.convert(e),this}setSouthWest(e){return this._sw=e instanceof p.N?new p.N(e.lng,e.lat):p.N.convert(e),this}extend(e){let n=this._sw,o=this._ne,a,c;if(e instanceof p.N)a=e,c=e;else{if(!(e instanceof oe))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(oe.convert(e)):this.extend(p.N.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(p.N.convert(e)):this;if(a=e._sw,c=e._ne,!a||!c)return this}return n||o?(n.lng=Math.min(a.lng,n.lng),n.lat=Math.min(a.lat,n.lat),o.lng=Math.max(c.lng,o.lng),o.lat=Math.max(c.lat,o.lat)):(this._sw=new p.N(a.lng,a.lat),this._ne=new p.N(c.lng,c.lat)),this}getCenter(){return new p.N((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new p.N(this.getWest(),this.getNorth())}getSouthEast(){return new p.N(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){let{lng:n,lat:o}=p.N.convert(e),a=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=o&&o<=this._ne.lat&&a}static convert(e){return e instanceof oe?e:e&&new oe(e)}static fromLngLat(e,n=0){let o=360*n/40075017,a=o/Math.cos(Math.PI/180*e.lat);return new oe(new p.N(e.lng-a,e.lat-o),new p.N(e.lng+a,e.lat+o))}adjustAntiMeridian(){let e=new p.N(this._sw.lng,this._sw.lat),n=new p.N(this._ne.lng,this._ne.lat);return new oe(e,e.lng>n.lng?new p.N(n.lng+360,n.lat):n)}}class en{constructor(e,n,o){this.bounds=oe.convert(this.validateBounds(e)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){let n=Math.pow(2,e.z),o=Math.floor(p.O(this.bounds.getWest())*n),a=Math.floor(p.Q(this.bounds.getNorth())*n),c=Math.ceil(p.O(this.bounds.getEast())*n),m=Math.ceil(p.Q(this.bounds.getSouth())*n);return e.x>=o&&e.x<c&&e.y>=a&&e.y<m}}class cs extends p.E{constructor(e,n,o,a){if(super(),this.id=e,this.dispatcher=o,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(n,["url","scheme","tileSize","promoteId"])),this._options=p.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(a)}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{let e=yield bn(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),e&&(p.e(this,e),e.bounds&&(this.tileBounds=new en(e.bounds,this.minzoom,this.maxzoom)),this.fire(new p.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new p.k("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this.fire(new p.j(e))}}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load()}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return p.e({},this._options)}loadTile(e){return p._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o={request:this.map._requestManager.transformRequest(n,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};o.request.collectResourceTiming=this._collectResourceTiming;let a="RT";if(e.actor&&e.state!=="expired"){if(e.state==="loading")return new Promise(((c,m)=>{e.reloadPromise={resolve:c,reject:m}}))}else e.actor=this.dispatcher.getActor(),a="LT";e.abortController=new AbortController;try{let c=yield e.actor.sendAsync({type:a,data:o},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,c)}catch(c){if(delete e.abortController,e.aborted)return;if(c&&c.status!==404)throw c;this._afterTileLoadWorkerResponse(e,null)}}))}_afterTileLoadWorkerResponse(e,n){if(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),e.reloadPromise){let o=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(o.resolve).catch(o.reject)}}abortTile(e){return p._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}unloadTile(e){return p._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class mt extends p.E{constructor(e,n,o,a){super(),this.id=e,this.dispatcher=o,this.setEventedParent(a),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=p.e({type:"raster"},n),p.e(this,p.M(n,["url","scheme","tileSize"]))}load(){return p._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new p.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{let e=yield bn(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,e&&(p.e(this,e),e.bounds&&(this.tileBounds=new en(e.bounds,this.minzoom,this.maxzoom)),this.fire(new p.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new p.k("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this.fire(new p.j(e))}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load()}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}serialize(){return p.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return p._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{let o=yield et.getImage(this.map._requestManager.transformRequest(n,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(o&&o.data){this.map._refreshExpiredTiles&&o.cacheControl&&o.expires&&e.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});let a=this.map.painter.context,c=a.gl,m=o.data;e.texture=this.map.painter.getTileTexture(m.width),e.texture?e.texture.update(m,{useMipmap:!0}):(e.texture=new Ye(a,m,c.RGBA,{useMipmap:!0}),e.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE,c.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(o){if(delete e.abortController,e.aborted)e.state="unloaded";else if(o)throw e.state="errored",o}}))}abortTile(e){return p._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return p._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class Bt extends mt{constructor(e,n,o,a){super(e,n,o,a),this.type="raster-dem",this.maxzoom=22,this._options=p.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(e){return p._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o=this.map._requestManager.transformRequest(n,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let a=yield et.getImage(o,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(a&&a.data){let c=a.data;this.map._refreshExpiredTiles&&a.cacheControl&&a.expires&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});let m=p.b(c)&&p.U()?c:yield this.readImageNow(c),_={type:this.type,uid:e.uid,source:this.id,rawImageData:m,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||e.state==="expired"){e.actor=this.dispatcher.getActor();let y=yield e.actor.sendAsync({type:"LDT",data:_});e.dem=y,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(a){if(delete e.abortController,e.aborted)e.state="unloaded";else if(a)throw e.state="errored",a}}))}readImageNow(e){return p._(this,void 0,void 0,(function*(){if(typeof VideoFrame<"u"&&p.V()){let n=e.width+2,o=e.height+2;try{return new p.R({width:n,height:o},yield p.W(e,-1,-1,n,o))}catch{}}return pe.getImageData(e,1)}))}_getNeighboringTiles(e){let n=e.canonical,o=Math.pow(2,n.z),a=(n.x-1+o)%o,c=n.x===0?e.wrap-1:e.wrap,m=(n.x+1+o)%o,_=n.x+1===o?e.wrap+1:e.wrap,y={};return y[new p.S(e.overscaledZ,c,n.z,a,n.y).key]={backfilled:!1},y[new p.S(e.overscaledZ,_,n.z,m,n.y).key]={backfilled:!1},n.y>0&&(y[new p.S(e.overscaledZ,c,n.z,a,n.y-1).key]={backfilled:!1},y[new p.S(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},y[new p.S(e.overscaledZ,_,n.z,m,n.y-1).key]={backfilled:!1}),n.y+1<o&&(y[new p.S(e.overscaledZ,c,n.z,a,n.y+1).key]={backfilled:!1},y[new p.S(e.overscaledZ,e.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},y[new p.S(e.overscaledZ,_,n.z,m,n.y+1).key]={backfilled:!1}),y}unloadTile(e){return p._(this,void 0,void 0,(function*(){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&(yield e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}}))}))}}class hs extends p.E{constructor(e,n,o,a){super(),this.id=e,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=o.getActor(),this.setEventedParent(a),this._data=n.data,this._options=p.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId;let c=p.X/this.tileSize;n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&p.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=p.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:(n.buffer!==void 0?n.buffer:128)*c,tolerance:(n.tolerance!==void 0?n.tolerance:.375)*c,extent:p.X,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:n.clusterMaxZoom!==void 0?n.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,n.clusterMinPoints||2),extent:p.X,radius:(n.clusterRadius||50)*c,log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}load(){return p._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(e){this.map=e,this.load()}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(e){return this._updateWorkerData(e),this}getData(){return p._(this,void 0,void 0,(function*(){let e=p.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:e})}))}setClusterOptions(e){return this.workerOptions.cluster=e.cluster,e&&(e.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=e.clusterRadius),e.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=e.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,n,o){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:n,offset:o}})}_updateWorkerData(e){return p._(this,void 0,void 0,(function*(){let n=p.e({type:this.type},this.workerOptions);e?n.dataDiff=e:typeof this._data=="string"?(n.request=this.map._requestManager.transformRequest(pe.resolveURL(this._data),"Source"),n.request.collectResourceTiming=this._collectResourceTiming):n.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new p.k("dataloading",{dataType:"source"}));try{let o=yield this.actor.sendAsync({type:"LD",data:n});if(this._pendingLoads--,this._removed||o.abandoned)return void this.fire(new p.k("dataabort",{dataType:"source"}));let a=null;o.resourceTiming&&o.resourceTiming[this.id]&&(a=o.resourceTiming[this.id].slice(0));let c={dataType:"source"};this._collectResourceTiming&&a&&a.length>0&&p.e(c,{resourceTiming:a}),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(o){if(this._pendingLoads--,this._removed)return void this.fire(new p.k("dataabort",{dataType:"source"}));this.fire(new p.j(o))}}))}loaded(){return this._pendingLoads===0}loadTile(e){return p._(this,void 0,void 0,(function*(){let n=e.actor?"RT":"LT";e.actor=this.actor;let o={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};e.abortController=new AbortController;let a=yield this.actor.sendAsync({type:n,data:o},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(a,this.map.painter,n==="RT")}))}abortTile(e){return p._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return p._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return p.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var Ur=p.Y([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class kr extends p.E{constructor(e,n,o,a){super(),this.id=e,this.dispatcher=o,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(a),this.options=n}load(e){return p._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new p.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{let n=yield et.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,e&&(this.coordinates=e),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,this.fire(new p.j(n))}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new p.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;let n=e.map(p.Z.fromLngLat);this.tileID=(function(a){let c=1/0,m=1/0,_=-1/0,y=-1/0;for(let E of a)c=Math.min(c,E.x),m=Math.min(m,E.y),_=Math.max(_,E.x),y=Math.max(y,E.y);let b=Math.max(_-c,y-m),S=Math.max(0,Math.floor(-Math.log(b)/Math.LN2)),T=Math.pow(2,S);return new p.a1(S,Math.floor((c+_)/2*T),Math.floor((m+y)/2*T))})(n),this.minzoom=this.maxzoom=this.tileID.z;let o=n.map((a=>this.tileID.getTilePoint(a)._round()));return this._boundsArray=new p.$,this._boundsArray.emplaceBack(o[0].x,o[0].y,0,0),this._boundsArray.emplaceBack(o[1].x,o[1].y,p.X,0),this._boundsArray.emplaceBack(o[3].x,o[3].y,0,p.X),this._boundsArray.emplaceBack(o[2].x,o[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;let e=this.map.painter.context,n=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,Ur.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture||(this.texture=new Ye(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(let a in this.tiles){let c=this.tiles[a];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,o=!0)}o&&this.fire(new p.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return p._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class wn extends kr{constructor(e,n,o,a){super(e,n,o,a),this.roundZoom=!0,this.type="video",this.options=n}load(){return p._(this,void 0,void 0,(function*(){this._loaded=!1;let e=this.options;this.urls=[];for(let n of e.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{let n=yield p.a3(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new p.j(n))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let n=this.video.seekable;e<n.start(0)||e>n.end(0)?this.fire(new p.j(new p.a2(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let e=this.map.painter.context,n=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,Ur.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new Ye(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(let a in this.tiles){let c=this.tiles[a];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,o=!0)}o&&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 qi extends kr{constructor(e,n,o,a){super(e,n,o,a),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some((c=>!Array.isArray(c)||c.length!==2||c.some((m=>typeof m!="number"))))||this.fire(new p.j(new p.a2(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new p.j(new p.a2(`sources.${e}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new p.j(new p.a2(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new p.j(new p.a2(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new p.j(new p.a2(`sources.${e}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return p._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new p.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let n=this.map.painter.context,o=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,Ur.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Ye(n,this.canvas,o.RGBA,{premultiply:!0});let a=!1;for(let c in this.tiles){let m=this.tiles[c];m.state!=="loaded"&&(m.state="loaded",m.texture=this.texture,a=!0)}a&&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(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}let us={},ds=h=>{switch(h){case"geojson":return hs;case"image":return kr;case"raster":return mt;case"raster-dem":return Bt;case"vector":return cs;case"video":return wn;case"canvas":return qi}return us[h]},ge="RTLPluginLoaded";class xr extends p.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=ls()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((n=>{throw this.status="error",n}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return p._(this,arguments,void 0,(function*(n,o=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=pe.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!o)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(ge))}))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let xi=null;function vr(){return xi||(xi=new xr),xi}class jr{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=p.a4(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){let n=e+this.timeAdded;n<this.fadeEndTime||(this.fadeEndTime=n)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,n,o){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=(function(a,c){let m={};if(!c)return m;for(let _ of a){let y=_.layerIds.map((b=>c.getLayer(b))).filter(Boolean);if(y.length!==0){_.layers=y,_.stateDependentLayerIds&&(_.stateDependentLayers=_.stateDependentLayerIds.map((b=>y.filter((S=>S.id===b))[0])));for(let b of y)m[b.id]=_}}return m})(e.buckets,n.style),this.hasSymbolBuckets=!1;for(let a in this.buckets){let c=this.buckets[a];if(c instanceof p.a6){if(this.hasSymbolBuckets=!0,!o)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let a in this.buckets){let c=this.buckets[a];if(c instanceof p.a6&&c.hasRTLText){this.hasRTLText=!0,vr().lazyLoad();break}}this.queryPadding=0;for(let a in this.buckets){let c=this.buckets[a];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(a).queryRadius(c))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new p.a5}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(let o in this.buckets){let a=this.buckets[o];a.uploadPending()&&a.upload(e)}let n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Ye(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Ye(e,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,n,o,a,c,m,_,y,b,S){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:a,cameraQueryGeometry:c,scale:m,tileSize:this.tileSize,pixelPosMatrix:S,transform:y,params:_,queryPadding:this.queryPadding*b},e,n,o):{}}querySourceFeatures(e,n){let o=this.latestFeatureIndex;if(!o||!o.rawTileData)return;let a=o.loadVTLayers(),c=n&&n.sourceLayer?n.sourceLayer:"",m=a._geojsonTileLayer||a[c];if(!m)return;let _=p.a7(n&&n.filter),{z:y,x:b,y:S}=this.tileID.canonical,T={z:y,x:b,y:S};for(let E=0;E<m.length;E++){let L=m.feature(E);if(_.needGeometry){let $=p.a8(L,!0);if(!_.filter(new p.z(this.tileID.overscaledZ),$,this.tileID.canonical))continue}else if(!_.filter(new p.z(this.tileID.overscaledZ),L))continue;let B=o.getId(L,c),V=new p.a9(L,y,b,S,B);V.tile=T,e.push(V)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let n=this.expirationTime;if(e.cacheControl){let o=p.aa(e.cacheControl);o["max-age"]&&(this.expirationTime=Date.now()+1e3*o["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let o=Date.now(),a=!1;if(this.expirationTime>o)a=!1;else if(n)if(this.expirationTime<n)a=!0;else{let c=this.expirationTime-n;c?this.expirationTime=o+Math.max(c,3e4):a=!0}else a=!0;a?(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(e,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(e).length===0)return;let o=this.latestFeatureIndex.loadVTLayers();for(let a in this.buckets){if(!n.style.hasLayer(a))continue;let c=this.buckets[a],m=c.layers[0].sourceLayer||"_geojsonTileLayer",_=o[m],y=e[m];if(!_||!y||Object.keys(y).length===0)continue;c.update(y,_,this.imageAtlas&&this.imageAtlas.patternPositions||{});let b=n&&n.style&&n.style.getLayer(a);b&&(this.queryPadding=Math.max(this.queryPadding,b.queryRadius(c)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<pe.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=pe.now()+e}setDependencies(e,n){let o={};for(let a of n)o[a]=!0;this.dependencies[e]=o}hasDependency(e,n){for(let o of e){let a=this.dependencies[o];if(a){for(let c of n)if(a[c])return!0}}return!1}}class ve{constructor(e,n){this.max=e,this.onRemove=n,this.reset()}reset(){for(let e in this.data)for(let n of this.data[e])n.timeout&&clearTimeout(n.timeout),this.onRemove(n.value);return this.data={},this.order=[],this}add(e,n,o){let a=e.wrapped().key;this.data[a]===void 0&&(this.data[a]=[]);let c={value:n,timeout:void 0};if(o!==void 0&&(c.timeout=setTimeout((()=>{this.remove(e,c)}),o)),this.data[a].push(c),this.order.push(a),this.order.length>this.max){let m=this._getAndRemoveByKey(this.order[0]);m&&this.onRemove(m)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){let n=this.data[e].shift();return n.timeout&&clearTimeout(n.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),n.value}getByKey(e){let n=this.data[e];return n?n[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,n){if(!this.has(e))return this;let o=e.wrapped().key,a=n===void 0?0:this.data[o].indexOf(n),c=this.data[o][a];return this.data[o].splice(a,1),c.timeout&&clearTimeout(c.timeout),this.data[o].length===0&&delete this.data[o],this.onRemove(c.value),this.order.splice(this.order.indexOf(o),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(e){let n=[];for(let o in this.data)for(let a of this.data[o])e(a.value)||n.push(a);for(let o of n)this.remove(o.value.tileID,o)}}class it{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,n,o){let a=String(n);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][a]=this.stateChanges[e][a]||{},p.e(this.stateChanges[e][a],o),this.deletedStates[e]===null){this.deletedStates[e]={};for(let c in this.state[e])c!==a&&(this.deletedStates[e][c]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][a]===null){this.deletedStates[e][a]={};for(let c in this.state[e][a])o[c]||(this.deletedStates[e][a][c]=null)}else for(let c in o)this.deletedStates[e]&&this.deletedStates[e][a]&&this.deletedStates[e][a][c]===null&&delete this.deletedStates[e][a][c]}removeFeatureState(e,n,o){if(this.deletedStates[e]===null)return;let a=String(n);if(this.deletedStates[e]=this.deletedStates[e]||{},o&&n!==void 0)this.deletedStates[e][a]!==null&&(this.deletedStates[e][a]=this.deletedStates[e][a]||{},this.deletedStates[e][a][o]=null);else if(n!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][a])for(o in this.deletedStates[e][a]={},this.stateChanges[e][a])this.deletedStates[e][a][o]=null;else this.deletedStates[e][a]=null;else this.deletedStates[e]=null}getState(e,n){let o=String(n),a=p.e({},(this.state[e]||{})[o],(this.stateChanges[e]||{})[o]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let c=this.deletedStates[e][n];if(c===null)return{};for(let m in c)delete a[m]}return a}initializeTileState(e,n){e.setFeatureState(this.state,n)}coalesceChanges(e,n){let o={};for(let a in this.stateChanges){this.state[a]=this.state[a]||{};let c={};for(let m in this.stateChanges[a])this.state[a][m]||(this.state[a][m]={}),p.e(this.state[a][m],this.stateChanges[a][m]),c[m]=this.state[a][m];o[a]=c}for(let a in this.deletedStates){this.state[a]=this.state[a]||{};let c={};if(this.deletedStates[a]===null)for(let m in this.state[a])c[m]={},this.state[a][m]={};else for(let m in this.deletedStates[a]){if(this.deletedStates[a][m]===null)this.state[a][m]={};else for(let _ of Object.keys(this.deletedStates[a][m]))delete this.state[a][m][_];c[m]=this.state[a][m]}o[a]=o[a]||{},p.e(o[a],c)}if(this.stateChanges={},this.deletedStates={},Object.keys(o).length!==0)for(let a in e)e[a].setFeatureState(o,n)}}class qe extends p.E{constructor(e,n,o){super(),this.id=e,this.dispatcher=o,this.on("data",(a=>this._dataHandler(a))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((a,c,m,_)=>{let y=new(ds(c.type))(a,c,m,_);if(y.id!==a)throw new Error(`Expected Source id to be ${a} instead of ${y.id}`);return y})(e,n,o,this),this._tiles={},this._cache=new ve(0,(a=>this._unloadTile(a))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new it,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(let e in this._tiles){let n=this._tiles[e];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;let e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,n,o){return p._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,n,o)}catch(a){e.state="errored",a.status!==404?this._source.fire(new p.j(a,{tile:e})):this.update(this.transform,this.terrain)}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new p.k("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(let n in this._tiles){let o=this._tiles[n];o.upload(e),o.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(Ii).map((e=>e.key))}getRenderableIds(e){let n=[];for(let o in this._tiles)this._isIdRenderable(o,e)&&n.push(this._tiles[o]);return e?n.sort(((o,a)=>{let c=o.tileID,m=a.tileID,_=new p.P(c.canonical.x,c.canonical.y)._rotate(this.transform.angle),y=new p.P(m.canonical.x,m.canonical.y)._rotate(this.transform.angle);return c.overscaledZ-m.overscaledZ||y.y-_.y||y.x-_.x})).map((o=>o.tileID.key)):n.map((o=>o.tileID)).sort(Ii).map((o=>o.key))}hasRenderableParent(e){let n=this.findLoadedParent(e,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(e,n){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(n||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(let e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(e,"reloading")}}_reloadTile(e,n){return p._(this,void 0,void 0,(function*(){let o=this._tiles[e];o&&(o.state!=="loading"&&(o.state=n),yield this._loadTile(o,e,n))}))}_tileLoaded(e,n,o){e.timeAdded=pe.now(),o==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),this.getSource().type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new p.k("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){let n=this.getRenderableIds();for(let a=0;a<n.length;a++){let c=n[a];if(e.neighboringTiles&&e.neighboringTiles[c]){let m=this.getTileByID(c);o(e,m),o(m,e)}}function o(a,c){a.needsHillshadePrepare=!0,a.needsTerrainPrepare=!0;let m=c.tileID.canonical.x-a.tileID.canonical.x,_=c.tileID.canonical.y-a.tileID.canonical.y,y=Math.pow(2,a.tileID.canonical.z),b=c.tileID.key;m===0&&_===0||Math.abs(_)>1||(Math.abs(m)>1&&(Math.abs(m+y)===1?m+=y:Math.abs(m-y)===1&&(m-=y)),c.dem&&a.dem&&(a.dem.backfillBorder(c.dem,m,_),a.neighboringTiles&&a.neighboringTiles[b]&&(a.neighboringTiles[b].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,n,o,a){for(let c in this._tiles){let m=this._tiles[c];if(a[c]||!m.hasData()||m.tileID.overscaledZ<=n||m.tileID.overscaledZ>o)continue;let _=m.tileID;for(;m&&m.tileID.overscaledZ>n+1;){let b=m.tileID.scaledTo(m.tileID.overscaledZ-1);m=this._tiles[b.key],m&&m.hasData()&&(_=b)}let y=_;for(;y.overscaledZ>n;)if(y=y.scaledTo(y.overscaledZ-1),e[y.key]){a[_.key]=_;break}}}findLoadedParent(e,n){if(e.key in this._loadedParentTiles){let o=this._loadedParentTiles[e.key];return o&&o.tileID.overscaledZ>=n?o:null}for(let o=e.overscaledZ-1;o>=n;o--){let a=e.scaledTo(o),c=this._getLoadedTile(a);if(c)return c}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){let n=this._tiles[e.key];return n&&n.hasData()?n:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){let n=Math.ceil(e.width/this._source.tileSize)+1,o=Math.ceil(e.height/this._source.tileSize)+1,a=Math.floor(n*o*(this._maxTileCacheZoomLevels===null?p.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),c=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(c)}handleWrapJump(e){let n=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,n){let o={};for(let a in this._tiles){let c=this._tiles[a];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+n),o[c.tileID.key]=c}this._tiles=o;for(let a in this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(let a in this._tiles)this._setTileReloadTimer(a,this._tiles[a])}}_updateCoveredAndRetainedTiles(e,n,o,a,c,m){let _={},y={},b=Object.keys(e),S=pe.now();for(let T of b){let E=e[T],L=this._tiles[T];if(!L||L.fadeEndTime!==0&&L.fadeEndTime<=S)continue;let B=this.findLoadedParent(E,n),V=this.findLoadedSibling(E),$=B||V||null;$&&(this._addTile($.tileID),_[$.tileID.key]=$.tileID),y[T]=E}this._retainLoadedChildren(y,a,o,e);for(let T in _)e[T]||(this._coveredTiles[T]=!0,e[T]=_[T]);if(m){let T={},E={};for(let L of c)this._tiles[L.key].hasData()?T[L.key]=L:E[L.key]=L;for(let L in E){let B=E[L].children(this._source.maxzoom);this._tiles[B[0].key]&&this._tiles[B[1].key]&&this._tiles[B[2].key]&&this._tiles[B[3].key]&&(T[B[0].key]=e[B[0].key]=B[0],T[B[1].key]=e[B[1].key]=B[1],T[B[2].key]=e[B[2].key]=B[2],T[B[3].key]=e[B[3].key]=B[3],delete E[L])}for(let L in E){let B=E[L],V=this.findLoadedParent(B,this._source.minzoom),$=this.findLoadedSibling(B),q=V||$||null;if(q){T[q.tileID.key]=e[q.tileID.key]=q.tileID;for(let G in T)T[G].isChildOf(q.tileID)&&delete T[G]}}for(let L in this._tiles)T[L]||(this._coveredTiles[L]=!0)}}update(e,n){if(!this._sourceLoaded||this._paused)return;let o;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((S=>new p.S(S.canonical.z,S.wrap,S.canonical.z,S.canonical.x,S.canonical.y))):(o=e.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n}),this._source.hasTile&&(o=o.filter((S=>this._source.hasTile(S))))):o=[];let a=e.coveringZoomLevel(this._source),c=Math.max(a-qe.maxOverzooming,this._source.minzoom),m=Math.max(a+qe.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){let S={};for(let T of o)if(T.canonical.z>this._source.minzoom){let E=T.scaledTo(T.canonical.z-1);S[E.key]=E;let L=T.scaledTo(Math.max(this._source.minzoom,Math.min(T.canonical.z,5)));S[L.key]=L}o=o.concat(Object.values(S))}let _=o.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,_&&this.fire(new p.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));let y=this._updateRetainedTiles(o,a);rr(this._source.type)&&this._updateCoveredAndRetainedTiles(y,c,m,a,o,n);for(let S in y)this._tiles[S].clearFadeHold();let b=p.ab(this._tiles,y);for(let S of b){let T=this._tiles[S];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(S)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(let e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,n){var o;let a={},c={},m=Math.max(n-qe.maxOverzooming,this._source.minzoom),_=Math.max(n+qe.maxUnderzooming,this._source.minzoom),y={};for(let b of e){let S=this._addTile(b);a[b.key]=b,S.hasData()||n<this._source.maxzoom&&(y[b.key]=b)}this._retainLoadedChildren(y,n,_,a);for(let b of e){let S=this._tiles[b.key];if(S.hasData())continue;if(n+1>this._source.maxzoom){let E=b.children(this._source.maxzoom)[0],L=this.getTile(E);if(L&&L.hasData()){a[E.key]=E;continue}}else{let E=b.children(this._source.maxzoom);if(a[E[0].key]&&a[E[1].key]&&a[E[2].key]&&a[E[3].key])continue}let T=S.wasRequested();for(let E=b.overscaledZ-1;E>=m;--E){let L=b.scaledTo(E);if(c[L.key])break;if(c[L.key]=!0,S=this.getTile(L),!S&&T&&(S=this._addTile(L)),S){let B=S.hasData();if((B||!(!((o=this.map)===null||o===void 0)&&o.cancelPendingTileRequestsWhileZooming)||T)&&(a[L.key]=L),T=S.wasRequested(),B)break}}}return a}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(let e in this._tiles){let n=[],o,a=this._tiles[e].tileID;for(;a.overscaledZ>0;){if(a.key in this._loadedParentTiles){o=this._loadedParentTiles[a.key];break}n.push(a.key);let c=a.scaledTo(a.overscaledZ-1);if(o=this._getLoadedTile(c),o)break;a=c}for(let c of n)this._loadedParentTiles[c]=o}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(let e in this._tiles){let n=this._tiles[e].tileID,o=this._getLoadedTile(n);this._loadedSiblingTiles[n.key]=o}}_addTile(e){let n=this._tiles[e.key];if(n)return n;n=this._cache.getAndRemove(e),n&&(this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,n)));let o=n;return n||(n=new jr(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._tiles[e.key]=n,o||this._source.fire(new p.k("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(e,n){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);let o=n.getExpiryTimeout();o&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),o))}_removeTile(e){let n=this._tiles[e];n&&(n.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(e){let n=e.sourceDataType;e.dataType==="source"&&n==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&e.dataType==="source"&&n==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,n,o){let a=[],c=this.transform;if(!c)return a;let m=o?c.getCameraQueryGeometry(e):e,_=e.map((B=>c.pointCoordinate(B,this.terrain))),y=m.map((B=>c.pointCoordinate(B,this.terrain))),b=this.getIds(),S=1/0,T=1/0,E=-1/0,L=-1/0;for(let B of y)S=Math.min(S,B.x),T=Math.min(T,B.y),E=Math.max(E,B.x),L=Math.max(L,B.y);for(let B=0;B<b.length;B++){let V=this._tiles[b[B]];if(V.holdingForFade())continue;let $=V.tileID,q=Math.pow(2,c.zoom-V.tileID.overscaledZ),G=n*V.queryPadding*p.X/V.tileSize/q,F=[$.getTilePoint(new p.Z(S,T)),$.getTilePoint(new p.Z(E,L))];if(F[0].x-G<p.X&&F[0].y-G<p.X&&F[1].x+G>=0&&F[1].y+G>=0){let J=_.map((ne=>$.getTilePoint(ne))),Q=y.map((ne=>$.getTilePoint(ne)));a.push({tile:V,tileID:$,queryGeometry:J,cameraQueryGeometry:Q,scale:q})}}return a}getVisibleCoordinates(e){let n=this.getRenderableIds(e).map((o=>this._tiles[o].tileID));for(let o of n)o.posMatrix=this.transform.calculatePosMatrix(o.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(rr(this._source.type)){let e=pe.now();for(let n in this._tiles)if(this._tiles[n].fadeEndTime>=e)return!0}return!1}setFeatureState(e,n,o){this._state.updateState(e=e||"_geojsonTileLayer",n,o)}removeFeatureState(e,n,o){this._state.removeFeatureState(e=e||"_geojsonTileLayer",n,o)}getFeatureState(e,n){return this._state.getState(e=e||"_geojsonTileLayer",n)}setDependencies(e,n,o){let a=this._tiles[e];a&&a.setDependencies(n,o)}reloadTilesForDependencies(e,n){for(let o in this._tiles)this._tiles[o].hasDependency(e,n)&&this._reloadTile(o,"reloading");this._cache.filter((o=>!o.hasDependency(e,n)))}}function Ii(h,e){let n=Math.abs(2*h.wrap)-+(h.wrap<0),o=Math.abs(2*e.wrap)-+(e.wrap<0);return h.overscaledZ-e.overscaledZ||o-n||e.canonical.y-h.canonical.y||e.canonical.x-h.canonical.x}function rr(h){return h==="raster"||h==="image"||h==="video"}qe.maxOverzooming=10,qe.maxUnderzooming=3;class Xe{constructor(e,n){this.reset(e,n)}reset(e,n){this.points=e||[],this._distances=[0];for(let o=1;o<this.points.length;o++)this._distances[o]=this._distances[o-1]+this.points[o].dist(this.points[o-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(this.points.length===1)return this.points[0];e=p.ac(e,0,1);let n=1,o=this._distances[n],a=e*this.paddedLength+this.padding;for(;o<a&&n<this._distances.length;)o=this._distances[++n];let c=n-1,m=this._distances[c],_=o-m,y=_>0?(a-m)/_:0;return this.points[c].mult(1-y).add(this.points[n].mult(y))}}function br(h,e){let n=!0;return h==="always"||h!=="never"&&e!=="never"||(n=!1),n}class zr{constructor(e,n,o){let a=this.boxCells=[],c=this.circleCells=[];this.xCellCount=Math.ceil(e/o),this.yCellCount=Math.ceil(n/o);for(let m=0;m<this.xCellCount*this.yCellCount;m++)a.push([]),c.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=n,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,n,o,a,c){this._forEachCell(n,o,a,c,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(n),this.bboxes.push(o),this.bboxes.push(a),this.bboxes.push(c)}insertCircle(e,n,o,a){this._forEachCell(n-a,o-a,n+a,o+a,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(n),this.circles.push(o),this.circles.push(a)}_insertBoxCell(e,n,o,a,c,m){this.boxCells[c].push(m)}_insertCircleCell(e,n,o,a,c,m){this.circleCells[c].push(m)}_query(e,n,o,a,c,m,_){if(o<0||e>this.width||a<0||n>this.height)return[];let y=[];if(e<=0&&n<=0&&this.width<=o&&this.height<=a){if(c)return[{key:null,x1:e,y1:n,x2:o,y2:a}];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++){let S=this.circles[3*b],T=this.circles[3*b+1],E=this.circles[3*b+2];y.push({key:this.circleKeys[b],x1:S-E,y1:T-E,x2:S+E,y2:T+E})}}else this._forEachCell(e,n,o,a,this._queryCell,y,{hitTest:c,overlapMode:m,seenUids:{box:{},circle:{}}},_);return y}query(e,n,o,a){return this._query(e,n,o,a,!1,null)}hitTest(e,n,o,a,c,m){return this._query(e,n,o,a,!0,c,m).length>0}hitTestCircle(e,n,o,a,c){let m=e-o,_=e+o,y=n-o,b=n+o;if(_<0||m>this.width||b<0||y>this.height)return!1;let S=[];return this._forEachCell(m,y,_,b,this._queryCellCircle,S,{hitTest:!0,overlapMode:a,circle:{x:e,y:n,radius:o},seenUids:{box:{},circle:{}}},c),S.length>0}_queryCell(e,n,o,a,c,m,_,y){let{seenUids:b,hitTest:S,overlapMode:T}=_,E=this.boxCells[c];if(E!==null){let B=this.bboxes;for(let V of E)if(!b.box[V]){b.box[V]=!0;let $=4*V,q=this.boxKeys[V];if(e<=B[$+2]&&n<=B[$+3]&&o>=B[$+0]&&a>=B[$+1]&&(!y||y(q))&&(!S||!br(T,q.overlapMode))&&(m.push({key:q,x1:B[$],y1:B[$+1],x2:B[$+2],y2:B[$+3]}),S))return!0}}let L=this.circleCells[c];if(L!==null){let B=this.circles;for(let V of L)if(!b.circle[V]){b.circle[V]=!0;let $=3*V,q=this.circleKeys[V];if(this._circleAndRectCollide(B[$],B[$+1],B[$+2],e,n,o,a)&&(!y||y(q))&&(!S||!br(T,q.overlapMode))){let G=B[$],F=B[$+1],J=B[$+2];if(m.push({key:q,x1:G-J,y1:F-J,x2:G+J,y2:F+J}),S)return!0}}}return!1}_queryCellCircle(e,n,o,a,c,m,_,y){let{circle:b,seenUids:S,overlapMode:T}=_,E=this.boxCells[c];if(E!==null){let B=this.bboxes;for(let V of E)if(!S.box[V]){S.box[V]=!0;let $=4*V,q=this.boxKeys[V];if(this._circleAndRectCollide(b.x,b.y,b.radius,B[$+0],B[$+1],B[$+2],B[$+3])&&(!y||y(q))&&!br(T,q.overlapMode))return m.push(!0),!0}}let L=this.circleCells[c];if(L!==null){let B=this.circles;for(let V of L)if(!S.circle[V]){S.circle[V]=!0;let $=3*V,q=this.circleKeys[V];if(this._circlesCollide(B[$],B[$+1],B[$+2],b.x,b.y,b.radius)&&(!y||y(q))&&!br(T,q.overlapMode))return m.push(!0),!0}}}_forEachCell(e,n,o,a,c,m,_,y){let b=this._convertToXCellCoord(e),S=this._convertToYCellCoord(n),T=this._convertToXCellCoord(o),E=this._convertToYCellCoord(a);for(let L=b;L<=T;L++)for(let B=S;B<=E;B++)if(c.call(this,e,n,o,a,this.xCellCount*B+L,m,_,y))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,n,o,a,c,m){let _=a-e,y=c-n,b=o+m;return b*b>_*_+y*y}_circleAndRectCollide(e,n,o,a,c,m,_){let y=(m-a)/2,b=Math.abs(e-(a+y));if(b>y+o)return!1;let S=(_-c)/2,T=Math.abs(n-(c+S));if(T>S+o)return!1;if(b<=y||T<=S)return!0;let E=b-y,L=T-S;return E*E+L*L<=o*o}}function $r(h,e,n,o,a){let c=p.H();return e?(p.K(c,c,[1/a,1/a,1]),n||p.ad(c,c,o.angle)):p.L(c,o.labelPlaneMatrix,h),c}function wr(h,e,n,o,a){if(e){let c=p.ae(h);return p.K(c,c,[a,a,1]),n||p.ad(c,c,-o.angle),c}return o.glCoordMatrix}function U(h,e,n,o){let a;o?(a=[h,e,o(h,e),1],p.af(a,a,n)):(a=[h,e,0,1],ut(a,a,n));let c=a[3];return{point:new p.P(a[0]/c,a[1]/c),signedDistanceFromCamera:c,isOccluded:!1}}function M(h,e){return .5+h/e*.5}function P(h,e){return h.x>=-e[0]&&h.x<=e[0]&&h.y>=-e[1]&&h.y<=e[1]}function D(h,e,n,o,a,c,m,_,y,b,S,T,E,L,B){let V=o?h.textSizeData:h.iconSizeData,$=p.ag(V,n.transform.zoom),q=[256/n.width*2+1,256/n.height*2+1],G=o?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;G.clear();let F=h.lineVertexArray,J=o?h.text.placedSymbolArray:h.icon.placedSymbolArray,Q=n.transform.width/n.transform.height,ne=!1;for(let ue=0;ue<J.length;ue++){let me=J.get(ue);if(me.hidden||me.writingMode===p.ah.vertical&&!ne){Ve(me.numGlyphs,G);continue}ne=!1;let Te=U(me.anchorX,me.anchorY,e,B);if(!P(Te.point,q)){Ve(me.numGlyphs,G);continue}let Ae=M(n.transform.cameraToCenterDistance,Te.signedDistanceFromCamera),xe=p.ai(V,$,me),ye=m?xe/Ae:xe*Ae,Re={getElevation:B,labelPlaneMatrix:a,lineVertexArray:F,pitchWithMap:m,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},projection:b,tileAnchorPoint:new p.P(me.anchorX,me.anchorY),unwrappedTileID:S,width:T,height:E,translation:L},We=Y(Re,me,ye,!1,_,e,c,h.glyphOffsetArray,G,Q,y);ne=We.useVertical,(We.notEnoughRoom||ne||We.needsFlipping&&Y(Re,me,ye,!0,_,e,c,h.glyphOffsetArray,G,Q,y).notEnoughRoom)&&Ve(me.numGlyphs,G)}o?h.text.dynamicLayoutVertexBuffer.updateData(G):h.icon.dynamicLayoutVertexBuffer.updateData(G)}function N(h,e,n,o,a,c,m,_){let y=c.glyphStartIndex+c.numGlyphs,b=c.lineStartIndex,S=c.lineStartIndex+c.lineLength,T=e.getoffsetX(c.glyphStartIndex),E=e.getoffsetX(y-1),L=_e(h*T,n,o,a,c.segment,b,S,_,m);if(!L)return null;let B=_e(h*E,n,o,a,c.segment,b,S,_,m);return B?_.projectionCache.anyProjectionOccluded?null:{first:L,last:B}:null}function W(h,e,n,o){return h===p.ah.horizontal&&Math.abs(n.y-e.y)>Math.abs(n.x-e.x)*o?{useVertical:!0}:(h===p.ah.vertical?e.y<n.y:e.x>n.x)?{needsFlipping:!0}:null}function Y(h,e,n,o,a,c,m,_,y,b,S){let T=n/24,E=e.lineOffsetX*T,L=e.lineOffsetY*T,B;if(e.numGlyphs>1){let V=e.glyphStartIndex+e.numGlyphs,$=e.lineStartIndex,q=e.lineStartIndex+e.lineLength,G=N(T,_,E,L,o,e,S,h);if(!G)return{notEnoughRoom:!0};let F=U(G.first.point.x,G.first.point.y,m,h.getElevation).point,J=U(G.last.point.x,G.last.point.y,m,h.getElevation).point;if(a&&!o){let Q=W(e.writingMode,F,J,b);if(Q)return Q}B=[G.first];for(let Q=e.glyphStartIndex+1;Q<V-1;Q++)B.push(_e(T*_.getoffsetX(Q),E,L,o,e.segment,$,q,h,S));B.push(G.last)}else{if(a&&!o){let $=U(h.tileAnchorPoint.x,h.tileAnchorPoint.y,c,h.getElevation).point,q=e.lineStartIndex+e.segment+1,G=new p.P(h.lineVertexArray.getx(q),h.lineVertexArray.gety(q)),F=U(G.x,G.y,c,h.getElevation),J=F.signedDistanceFromCamera>0?F.point:(function(ne,ue,me,Te,Ae,xe){return te(ne,ue,me,1,Ae,xe)})(h.tileAnchorPoint,G,$,0,c,h),Q=W(e.writingMode,$,J,b);if(Q)return Q}let V=_e(T*_.getoffsetX(e.glyphStartIndex),E,L,o,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,h,S);if(!V||h.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};B=[V]}for(let V of B)p.aj(y,V.point,V.angle);return{}}function te(h,e,n,o,a,c){let m=h.add(h.sub(e)._unit()),_=a!==void 0?U(m.x,m.y,a,c.getElevation).point:le(m.x,m.y,c).point,y=n.sub(_);return n.add(y._mult(o/y.mag()))}function Z(h,e,n){let o=e.projectionCache;if(o.projections[h])return o.projections[h];let a=new p.P(e.lineVertexArray.getx(h),e.lineVertexArray.gety(h)),c=le(a.x,a.y,e);if(c.signedDistanceFromCamera>0)return o.projections[h]=c.point,o.anyProjectionOccluded=o.anyProjectionOccluded||c.isOccluded,c.point;let m=h-n.direction;return(function(_,y,b,S,T){return te(_,y,b,S,void 0,T)})(n.distanceFromAnchor===0?e.tileAnchorPoint:new p.P(e.lineVertexArray.getx(m),e.lineVertexArray.gety(m)),a,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,e)}function le(h,e,n){let o=h+n.translation[0],a=e+n.translation[1],c;return!n.pitchWithMap&&n.projection.useSpecialProjectionForSymbols?(c=n.projection.projectTileCoordinates(o,a,n.unwrappedTileID,n.getElevation),c.point.x=(.5*c.point.x+.5)*n.width,c.point.y=(.5*-c.point.y+.5)*n.height):(c=U(o,a,n.labelPlaneMatrix,n.getElevation),c.isOccluded=!1),c}function de(h,e,n){return h._unit()._perp()._mult(e*n)}function se(h,e,n,o,a,c,m,_,y){if(_.projectionCache.offsets[h])return _.projectionCache.offsets[h];let b=n.add(e);if(h+y.direction<o||h+y.direction>=a)return _.projectionCache.offsets[h]=b,b;let S=Z(h+y.direction,_,y),T=de(S.sub(n),m,y.direction),E=n.add(T),L=S.add(T);return _.projectionCache.offsets[h]=p.ak(c,b,E,L)||b,_.projectionCache.offsets[h]}function _e(h,e,n,o,a,c,m,_,y){let b=o?h-e:h+e,S=b>0?1:-1,T=0;o&&(S*=-1,T=Math.PI),S<0&&(T+=Math.PI);let E,L=S>0?c+a:c+a+1;_.projectionCache.cachedAnchorPoint?E=_.projectionCache.cachedAnchorPoint:(E=le(_.tileAnchorPoint.x,_.tileAnchorPoint.y,_).point,_.projectionCache.cachedAnchorPoint=E);let B,V,$=E,q=E,G=0,F=0,J=Math.abs(b),Q=[],ne;for(;G+F<=J;){if(L+=S,L<c||L>=m)return null;G+=F,q=$,V=B;let Te={absOffsetX:J,direction:S,distanceFromAnchor:G,previousVertex:q};if($=Z(L,_,Te),n===0)Q.push(q),ne=$.sub(q);else{let Ae,xe=$.sub(q);Ae=xe.mag()===0?de(Z(L+S,_,Te).sub($),n,S):de(xe,n,S),V||(V=q.add(Ae)),B=se(L,Ae,$,c,m,V,n,_,Te),Q.push(V),ne=B.sub(V)}F=ne.mag()}let ue=ne._mult((J-G)/F)._add(V||q),me=T+Math.atan2($.y-q.y,$.x-q.x);return Q.push(ue),{point:ue,angle:y?me:0,path:Q}}let Ne=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Ve(h,e){for(let n=0;n<h;n++){let o=e.length;e.resize(o+4),e.float32.set(Ne,3*o)}}function ut(h,e,n){let o=e[0],a=e[1];return h[0]=n[0]*o+n[4]*a+n[12],h[1]=n[1]*o+n[5]*a+n[13],h[3]=n[3]*o+n[7]*a+n[15],h}let Ke=100;class dt{constructor(e,n,o=new zr(e.width+200,e.height+200,25),a=new zr(e.width+200,e.height+200,25)){this.transform=e,this.mapProjection=n,this.grid=o,this.ignoredGrid=a,this.pitchFactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Ke,this.screenBottomBoundary=e.height+Ke,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,n,o,a,c,m,_,y,b,S,T){let E=e.anchorPointX+y[0],L=e.anchorPointY+y[1],B=this.projectAndGetPerspectiveRatio(a,E,L,c,S),V=o*B.perspectiveRatio,$;if(m||_)$=this._projectCollisionBox(e,V,a,c,m,_,y,B,S,T);else{let Q=B.point.x+(T?T.x*V:0),ne=B.point.y+(T?T.y*V:0);$={allPointsOccluded:!1,box:[Q+e.x1*V,ne+e.y1*V,Q+e.x2*V,ne+e.y2*V]}}let[q,G,F,J]=$.box;return this.mapProjection.useSpecialProjectionForSymbols&&(m?$.allPointsOccluded:this.mapProjection.isOccluded(E,L,c))||B.perspectiveRatio<this.perspectiveRatioCutoff||!this.isInsideGrid(q,G,F,J)||n!=="always"&&this.grid.hitTest(q,G,F,J,n,b)?{box:[q,G,F,J],placeable:!1,offscreen:!1}:{box:[q,G,F,J],placeable:!0,offscreen:this.isOffscreen(q,G,F,J)}}placeCollisionCircles(e,n,o,a,c,m,_,y,b,S,T,E,L,B,V,$){let q=[],G=new p.P(n.anchorX,n.anchorY),F=this.getPerspectiveRatio(m,G.x,G.y,_,$),J=(T?c/F:c*F)/p.ap,Q={getElevation:$,labelPlaneMatrix:y,lineVertexArray:o,pitchWithMap:T,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},projection:this.mapProjection,tileAnchorPoint:G,unwrappedTileID:_,width:this.transform.width,height:this.transform.height,translation:V},ne=N(J,a,n.lineOffsetX*J,n.lineOffsetY*J,!1,n,!1,Q),ue=!1,me=!1,Te=!0;if(ne){let Ae=.5*L*F+B,xe=new p.P(-100,-100),ye=new p.P(this.screenRightBoundary,this.screenBottomBoundary),Re=new Xe,We=ne.first,be=ne.last,Pe=[];for(let Qe=We.path.length-1;Qe>=1;Qe--)Pe.push(We.path[Qe]);for(let Qe=1;Qe<be.path.length;Qe++)Pe.push(be.path[Qe]);let Ze=2.5*Ae;if(b){let Qe=this.projectPathToScreenSpace(Pe,Q,b);Pe=Qe.some((at=>at.signedDistanceFromCamera<=0))?[]:Qe.map((at=>at.point))}let Et=[];if(Pe.length>0){let Qe=Pe[0].clone(),at=Pe[0].clone();for(let kt=1;kt<Pe.length;kt++)Qe.x=Math.min(Qe.x,Pe[kt].x),Qe.y=Math.min(Qe.y,Pe[kt].y),at.x=Math.max(at.x,Pe[kt].x),at.y=Math.max(at.y,Pe[kt].y);Et=Qe.x>=xe.x&&at.x<=ye.x&&Qe.y>=xe.y&&at.y<=ye.y?[Pe]:at.x<xe.x||Qe.x>ye.x||at.y<xe.y||Qe.y>ye.y?[]:p.al([Pe],xe.x,xe.y,ye.x,ye.y)}for(let Qe of Et){Re.reset(Qe,.25*Ae);let at=0;at=Re.length<=.5*Ae?1:Math.ceil(Re.paddedLength/Ze)+1;for(let kt=0;kt<at;kt++){let ui=kt/Math.max(at-1,1),cr=Re.lerp(ui),zt=cr.x+Ke,Mi=cr.y+Ke;q.push(zt,Mi,Ae,0);let bi=zt-Ae,di=Mi-Ae,wi=zt+Ae,Cr=Mi+Ae;if(Te=Te&&this.isOffscreen(bi,di,wi,Cr),me=me||this.isInsideGrid(bi,di,wi,Cr),e!=="always"&&this.grid.hitTestCircle(zt,Mi,Ae,e,E)&&(ue=!0,!S))return{circles:[],offscreen:!1,collisionDetected:ue}}}}return{circles:!S&&ue||!me||F<this.perspectiveRatioCutoff?[]:q,offscreen:Te,collisionDetected:ue}}projectPathToScreenSpace(e,n,o){return e.map((a=>U(a.x,a.y,o,n.getElevation)))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let n=[],o=1/0,a=1/0,c=-1/0,m=-1/0;for(let S of e){let T=new p.P(S.x+Ke,S.y+Ke);o=Math.min(o,T.x),a=Math.min(a,T.y),c=Math.max(c,T.x),m=Math.max(m,T.y),n.push(T)}let _=this.grid.query(o,a,c,m).concat(this.ignoredGrid.query(o,a,c,m)),y={},b={};for(let S of _){let T=S.key;if(y[T.bucketInstanceId]===void 0&&(y[T.bucketInstanceId]={}),y[T.bucketInstanceId][T.featureIndex])continue;let E=[new p.P(S.x1,S.y1),new p.P(S.x2,S.y1),new p.P(S.x2,S.y2),new p.P(S.x1,S.y2)];p.am(n,E)&&(y[T.bucketInstanceId][T.featureIndex]=!0,b[T.bucketInstanceId]===void 0&&(b[T.bucketInstanceId]=[]),b[T.bucketInstanceId].push(T.featureIndex))}return b}insertCollisionBox(e,n,o,a,c,m){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:a,featureIndex:c,collisionGroupID:m,overlapMode:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,n,o,a,c,m){let _=o?this.ignoredGrid:this.grid,y={bucketInstanceId:a,featureIndex:c,collisionGroupID:m,overlapMode:n};for(let b=0;b<e.length;b+=4)_.insertCircle(y,e[b],e[b+1],e[b+2])}projectAndGetPerspectiveRatio(e,n,o,a,c){let m;c?(m=[n,o,c(n,o),1],p.af(m,m,e)):(m=[n,o,0,1],ut(m,m,e));let _=m[3];return{point:new p.P((m[0]/_+1)/2*this.transform.width+Ke,(-m[1]/_+1)/2*this.transform.height+Ke),perspectiveRatio:.5+this.transform.cameraToCenterDistance/_*.5,isOccluded:!1,signedDistanceFromCamera:_}}getPerspectiveRatio(e,n,o,a,c){let m=this.mapProjection.useSpecialProjectionForSymbols?this.mapProjection.projectTileCoordinates(n,o,a,c):U(n,o,e,c);return .5+this.transform.cameraToCenterDistance/m.signedDistanceFromCamera*.5}isOffscreen(e,n,o,a){return o<Ke||e>=this.screenRightBoundary||a<Ke||n>this.screenBottomBoundary}isInsideGrid(e,n,o,a){return o>=0&&e<this.gridRightBoundary&&a>=0&&n<this.gridBottomBoundary}getViewportMatrix(){let e=p.an([]);return p.J(e,e,[-100,-100,0]),e}_projectCollisionBox(e,n,o,a,c,m,_,y,b,S){let T=new p.P(1,0),E=new p.P(0,1),L=new p.P(e.anchorPointX+_[0],e.anchorPointY+_[1]);if(m&&!c){let Te=this.projectAndGetPerspectiveRatio(o,L.x+1,L.y,a,b).point.sub(y.point).unit(),Ae=Math.atan(Te.y/Te.x)+(Te.x<0?Math.PI:0),xe=Math.sin(Ae),ye=Math.cos(Ae);T=new p.P(ye,xe),E=new p.P(-xe,ye)}else if(!m&&c){let Te=-this.transform.angle,Ae=Math.sin(Te),xe=Math.cos(Te);T=new p.P(xe,Ae),E=new p.P(-Ae,xe)}let B=y.point,V=n;if(c){B=L;let Te=this.transform.zoom-Math.floor(this.transform.zoom);V=Math.pow(2,-Te),V*=this.mapProjection.getPitchedTextCorrection(this.transform,L,a),S||(V*=p.ac(.5+y.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))}S&&(B=B.add(T.mult(S.x*V)).add(E.mult(S.y*V)));let $=e.x1*V,q=e.x2*V,G=($+q)/2,F=e.y1*V,J=e.y2*V,Q=(F+J)/2,ne=[{offsetX:$,offsetY:F},{offsetX:G,offsetY:F},{offsetX:q,offsetY:F},{offsetX:q,offsetY:Q},{offsetX:q,offsetY:J},{offsetX:G,offsetY:J},{offsetX:$,offsetY:J},{offsetX:$,offsetY:Q}],ue=[];for(let{offsetX:Te,offsetY:Ae}of ne)ue.push(new p.P(B.x+T.x*Te+E.x*Ae,B.y+T.y*Te+E.y*Ae));let me=!1;if(c){let Te=ue.map((Ae=>this.projectAndGetPerspectiveRatio(o,Ae.x,Ae.y,a,b)));me=Te.some((Ae=>!Ae.isOccluded)),ue=Te.map((Ae=>Ae.point))}else me=!0;return{box:p.ao(ue),allPointsOccluded:!me}}}function ot(h,e,n){return e*(p.X/(h.tileSize*Math.pow(2,n-h.tileID.overscaledZ)))}class Wt{constructor(e,n,o,a){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?n:-n))):a&&o?1:0,this.placed=o}isHidden(){return this.opacity===0&&!this.placed}}class Ft{constructor(e,n,o,a,c){this.text=new Wt(e?e.text:null,n,o,c),this.icon=new Wt(e?e.icon:null,n,a,c)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class rt{constructor(e,n,o){this.text=e,this.icon=n,this.skipFade=o}}class xt{constructor(){this.invProjMatrix=p.H(),this.viewportMatrix=p.H(),this.circles=[]}}class Rt{constructor(e,n,o,a,c){this.bucketInstanceId=e,this.featureIndex=n,this.sourceLayerIndex=o,this.bucketIndex=a,this.tileID=c}}class ti{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){let n=++this.maxGroupID;this.collisionGroups[e]={ID:n,predicate:o=>o.collisionGroupID===n}}return this.collisionGroups[e]}}function si(h,e,n,o,a){let{horizontalAlign:c,verticalAlign:m}=p.au(h);return new p.P(-(c-.5)*e+o[0]*a,-(m-.5)*n+o[1]*a)}class vi{constructor(e,n,o,a,c,m){this.transform=e.clone(),this.terrain=o,this.collisionIndex=new dt(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new ti(c),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=m,m&&(m.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let n=this.terrain;return n?(o,a)=>n.getElevation(e,o,a):null}getBucketParts(e,n,o,a){let c=o.getBucket(n),m=o.latestFeatureIndex;if(!c||!m||n.id!==c.layerIds[0])return;let _=o.collisionBoxArray,y=c.layers[0].layout,b=c.layers[0].paint,S=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),T=o.tileSize/p.X,E=o.tileID.toUnwrapped(),L=this.transform.calculatePosMatrix(E),B=y.get("text-pitch-alignment")==="map",V=y.get("text-rotation-alignment")==="map",$=ot(o,1,this.transform.zoom),q=this.collisionIndex.mapProjection.translatePosition(this.transform,o,b.get("text-translate"),b.get("text-translate-anchor")),G=this.collisionIndex.mapProjection.translatePosition(this.transform,o,b.get("icon-translate"),b.get("icon-translate-anchor")),F=$r(L,B,V,this.transform,$),J=null;if(B){let ne=wr(L,B,V,this.transform,$);J=p.L([],this.transform.labelPlaneMatrix,ne)}this.retainedQueryData[c.bucketInstanceId]=new Rt(c.bucketInstanceId,m,c.sourceLayerIndex,c.index,o.tileID);let Q={bucket:c,layout:y,translationText:q,translationIcon:G,posMatrix:L,unwrappedTileID:E,textLabelPlaneMatrix:F,labelToScreenMatrix:J,scale:S,textPixelRatio:T,holdingForFade:o.holdingForFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:p.ag(c.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(c.sourceID)};if(a)for(let ne of c.sortKeyRanges){let{sortKey:ue,symbolInstanceStart:me,symbolInstanceEnd:Te}=ne;e.push({sortKey:ue,symbolInstanceStart:me,symbolInstanceEnd:Te,parameters:Q})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:c.symbolInstances.length,parameters:Q})}attemptAnchorPlacement(e,n,o,a,c,m,_,y,b,S,T,E,L,B,V,$,q,G,F){let J=p.aq[e.textAnchor],Q=[e.textOffset0,e.textOffset1],ne=si(J,o,a,Q,c),ue=this.collisionIndex.placeCollisionBox(n,E,y,b,S,_,m,$,T.predicate,F,ne);if((!G||this.collisionIndex.placeCollisionBox(G,E,y,b,S,_,m,q,T.predicate,F,ne).placeable)&&ue.placeable){let me;if(this.prevPlacement&&this.prevPlacement.variableOffsets[L.crossTileID]&&this.prevPlacement.placements[L.crossTileID]&&this.prevPlacement.placements[L.crossTileID].text&&(me=this.prevPlacement.variableOffsets[L.crossTileID].anchor),L.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[L.crossTileID]={textOffset:Q,width:o,height:a,anchor:J,textBoxScale:c,prevAnchor:me},this.markUsedJustification(B,J,L,V),B.allowVerticalPlacement&&(this.markUsedOrientation(B,V,L),this.placedOrientations[L.crossTileID]=V),{shift:ne,placedGlyphBoxes:ue}}}placeLayerBucketPart(e,n,o){let{bucket:a,layout:c,translationText:m,translationIcon:_,posMatrix:y,unwrappedTileID:b,textLabelPlaneMatrix:S,labelToScreenMatrix:T,textPixelRatio:E,holdingForFade:L,collisionBoxArray:B,partiallyEvaluatedTextSize:V,collisionGroup:$}=e.parameters,q=c.get("text-optional"),G=c.get("icon-optional"),F=p.ar(c,"text-overlap","text-allow-overlap"),J=F==="always",Q=p.ar(c,"icon-overlap","icon-allow-overlap"),ne=Q==="always",ue=c.get("text-rotation-alignment")==="map",me=c.get("text-pitch-alignment")==="map",Te=c.get("icon-text-fit")!=="none",Ae=c.get("symbol-z-order")==="viewport-y",xe=J&&(ne||!a.hasIconData()||G),ye=ne&&(J||!a.hasTextData()||q);!a.collisionArrays&&B&&a.deserializeCollisionBoxes(B);let Re=this._getTerrainElevationFunc(this.retainedQueryData[a.bucketInstanceId].tileID),We=(be,Pe,Ze)=>{var Et,Qe;if(n[be.crossTileID])return;if(L)return void(this.placements[be.crossTileID]=new rt(!1,!1,!1));let at=!1,kt=!1,ui=!0,cr=null,zt={box:null,placeable:!1,offscreen:null},Mi={box:null,placeable:!1,offscreen:null},bi=null,di=null,wi=null,Cr=0,Zn=0,xo=0;Pe.textFeatureIndex?Cr=Pe.textFeatureIndex:be.useRuntimeCollisionCircles&&(Cr=be.featureIndex),Pe.verticalTextFeatureIndex&&(Zn=Pe.verticalTextFeatureIndex);let Gn=Pe.textBox;if(Gn){let Ki=oi=>{let pi=p.ah.horizontal;if(a.allowVerticalPlacement&&!oi&&this.prevPlacement){let Vi=this.prevPlacement.placedOrientations[be.crossTileID];Vi&&(this.placedOrientations[be.crossTileID]=Vi,pi=Vi,this.markUsedOrientation(a,pi,be))}return pi},Ji=(oi,pi)=>{if(a.allowVerticalPlacement&&be.numVerticalGlyphVertices>0&&Pe.verticalTextBox){for(let Vi of a.writingModes)if(Vi===p.ah.vertical?(zt=pi(),Mi=zt):zt=oi(),zt&&zt.placeable)break}else zt=oi()},Gr=be.textAnchorOffsetStartIndex,hr=be.textAnchorOffsetEndIndex;if(hr===Gr){let oi=(pi,Vi)=>{let ct=this.collisionIndex.placeCollisionBox(pi,F,E,y,b,me,ue,m,$.predicate,Re);return ct&&ct.placeable&&(this.markUsedOrientation(a,Vi,be),this.placedOrientations[be.crossTileID]=Vi),ct};Ji((()=>oi(Gn,p.ah.horizontal)),(()=>{let pi=Pe.verticalTextBox;return a.allowVerticalPlacement&&be.numVerticalGlyphVertices>0&&pi?oi(pi,p.ah.vertical):{box:null,offscreen:null}})),Ki(zt&&zt.placeable)}else{let oi=p.aq[(Qe=(Et=this.prevPlacement)===null||Et===void 0?void 0:Et.variableOffsets[be.crossTileID])===null||Qe===void 0?void 0:Qe.anchor],pi=(ct,fn,Hn)=>{let Wn=ct.x2-ct.x1,kl=ct.y2-ct.y1,Bc=be.textBoxScale,zl=Te&&Q==="never"?fn:null,Hr=null,Ll=F==="never"?1:2,bo="never";oi&&Ll++;for(let ks=0;ks<Ll;ks++){for(let wo=Gr;wo<hr;wo++){let So=a.textAnchorOffsets.get(wo);if(oi&&So.textAnchor!==oi)continue;let Xn=this.attemptAnchorPlacement(So,ct,Wn,kl,Bc,ue,me,E,y,b,$,bo,be,a,Hn,m,_,zl,Re);if(Xn&&(Hr=Xn.placedGlyphBoxes,Hr&&Hr.placeable))return at=!0,cr=Xn.shift,Hr}oi?oi=null:bo=F}return o&&!Hr&&(Hr={box:this.collisionIndex.placeCollisionBox(Gn,"always",E,y,b,me,ue,m,$.predicate,Re,new p.P(0,0)).box,offscreen:!1,placeable:!1}),Hr};Ji((()=>pi(Gn,Pe.iconBox,p.ah.horizontal)),(()=>{let ct=Pe.verticalTextBox;return a.allowVerticalPlacement&&(!zt||!zt.placeable)&&be.numVerticalGlyphVertices>0&&ct?pi(ct,Pe.verticalIconBox,p.ah.vertical):{box:null,occluded:!0,offscreen:null}})),zt&&(at=zt.placeable,ui=zt.offscreen);let Vi=Ki(zt&&zt.placeable);if(!at&&this.prevPlacement){let ct=this.prevPlacement.variableOffsets[be.crossTileID];ct&&(this.variableOffsets[be.crossTileID]=ct,this.markUsedJustification(a,ct.anchor,be,Vi))}}}if(bi=zt,at=bi&&bi.placeable,ui=bi&&bi.offscreen,be.useRuntimeCollisionCircles){let Ki=a.text.placedSymbolArray.get(be.centerJustifiedTextSymbolIndex),Ji=p.ai(a.textSizeData,V,Ki),Gr=c.get("text-padding");di=this.collisionIndex.placeCollisionCircles(F,Ki,a.lineVertexArray,a.glyphOffsetArray,Ji,y,b,S,T,o,me,$.predicate,be.collisionCircleDiameter,Gr,m,Re),di.circles.length&&di.collisionDetected&&!o&&p.w("Collisions detected, but collision boxes are not shown"),at=J||di.circles.length>0&&!di.collisionDetected,ui=ui&&di.offscreen}if(Pe.iconFeatureIndex&&(xo=Pe.iconFeatureIndex),Pe.iconBox){let Ki=Ji=>this.collisionIndex.placeCollisionBox(Ji,Q,E,y,b,me,ue,_,$.predicate,Re,Te&&cr?cr:void 0);Mi&&Mi.placeable&&Pe.verticalIconBox?(wi=Ki(Pe.verticalIconBox),kt=wi.placeable):(wi=Ki(Pe.iconBox),kt=wi.placeable),ui=ui&&wi.offscreen}let Xi=q||be.numHorizontalGlyphVertices===0&&be.numVerticalGlyphVertices===0,vo=G||be.numIconVertices===0;Xi||vo?vo?Xi||(kt=kt&&at):at=kt&&at:kt=at=kt&&at;let Ma=kt&&wi.placeable;if(at&&bi.placeable&&this.collisionIndex.insertCollisionBox(bi.box,F,c.get("text-ignore-placement"),a.bucketInstanceId,Mi&&Mi.placeable&&Zn?Zn:Cr,$.ID),Ma&&this.collisionIndex.insertCollisionBox(wi.box,Q,c.get("icon-ignore-placement"),a.bucketInstanceId,xo,$.ID),di&&at&&this.collisionIndex.insertCollisionCircles(di.circles,F,c.get("text-ignore-placement"),a.bucketInstanceId,Cr,$.ID),o&&this.storeCollisionData(a.bucketInstanceId,Ze,Pe,bi,wi,di),be.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(a.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[be.crossTileID]=new rt(at||xe,kt||ye,ui||a.justReloaded),n[be.crossTileID]=!0};if(Ae){if(e.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");let be=a.getSortedSymbolIndexes(this.transform.angle);for(let Pe=be.length-1;Pe>=0;--Pe){let Ze=be[Pe];We(a.symbolInstances.get(Ze),a.collisionArrays[Ze],Ze)}}else for(let be=e.symbolInstanceStart;be<e.symbolInstanceEnd;be++)We(a.symbolInstances.get(be),a.collisionArrays[be],be);if(o&&a.bucketInstanceId in this.collisionCircleArrays){let be=this.collisionCircleArrays[a.bucketInstanceId];p.as(be.invProjMatrix,y),be.viewportMatrix=this.collisionIndex.getViewportMatrix()}a.justReloaded=!1}storeCollisionData(e,n,o,a,c,m){if(o.textBox||o.iconBox){let _,y;this.collisionBoxArrays.has(e)?_=this.collisionBoxArrays.get(e):(_=new Map,this.collisionBoxArrays.set(e,_)),_.has(n)?y=_.get(n):(y={text:null,icon:null},_.set(n,y)),o.textBox&&(y.text=a.box),o.iconBox&&(y.icon=c.box)}if(m){let _=this.collisionCircleArrays[e];_===void 0&&(_=this.collisionCircleArrays[e]=new xt);for(let y=0;y<m.circles.length;y+=4)_.circles.push(m.circles[y+0]),_.circles.push(m.circles[y+1]),_.circles.push(m.circles[y+2]),_.circles.push(m.collisionDetected?1:0)}}markUsedJustification(e,n,o,a){let c;c=a===p.ah.vertical?o.verticalPlacedTextSymbolIndex:{left:o.leftJustifiedTextSymbolIndex,center:o.centerJustifiedTextSymbolIndex,right:o.rightJustifiedTextSymbolIndex}[p.at(n)];let m=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex,o.verticalPlacedTextSymbolIndex];for(let _ of m)_>=0&&(e.text.placedSymbolArray.get(_).crossTileID=c>=0&&_!==c?0:o.crossTileID)}markUsedOrientation(e,n,o){let a=n===p.ah.horizontal||n===p.ah.horizontalOnly?n:0,c=n===p.ah.vertical?n:0,m=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(let _ of m)e.text.placedSymbolArray.get(_).placedOrientation=a;o.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=c)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let n=this.prevPlacement,o=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;let a=n?n.symbolFadeChange(e):1,c=n?n.opacities:{},m=n?n.variableOffsets:{},_=n?n.placedOrientations:{};for(let y in this.placements){let b=this.placements[y],S=c[y];S?(this.opacities[y]=new Ft(S,a,b.text,b.icon),o=o||b.text!==S.text.placed||b.icon!==S.icon.placed):(this.opacities[y]=new Ft(null,a,b.text,b.icon,b.skipFade),o=o||b.text||b.icon)}for(let y in c){let b=c[y];if(!this.opacities[y]){let S=new Ft(b,a,!1,!1);S.isHidden()||(this.opacities[y]=S,o=o||b.text.placed||b.icon.placed)}}for(let y in m)this.variableOffsets[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.variableOffsets[y]=m[y]);for(let y in _)this.placedOrientations[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.placedOrientations[y]=_[y]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");o?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:e)}updateLayerOpacities(e,n){let o={};for(let a of n){let c=a.getBucket(e);c&&a.latestFeatureIndex&&e.id===c.layerIds[0]&&this.updateBucketOpacities(c,a.tileID,o,a.collisionBoxArray)}}updateBucketOpacities(e,n,o,a){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let c=e.layers[0],m=c.layout,_=new Ft(null,0,!1,!1,!0),y=m.get("text-allow-overlap"),b=m.get("icon-allow-overlap"),S=c._unevaluatedLayout.hasValue("text-variable-anchor")||c._unevaluatedLayout.hasValue("text-variable-anchor-offset"),T=m.get("text-rotation-alignment")==="map",E=m.get("text-pitch-alignment")==="map",L=m.get("icon-text-fit")!=="none",B=new Ft(null,0,y&&(b||!e.hasIconData()||m.get("icon-optional")),b&&(y||!e.hasTextData()||m.get("text-optional")),!0);!e.collisionArrays&&a&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(a);let V=(q,G,F)=>{for(let J=0;J<G/4;J++)q.opacityVertexArray.emplaceBack(F);q.hasVisibleVertices=q.hasVisibleVertices||F!==Tn},$=this.collisionBoxArrays.get(e.bucketInstanceId);for(let q=0;q<e.symbolInstances.length;q++){let G=e.symbolInstances.get(q),{numHorizontalGlyphVertices:F,numVerticalGlyphVertices:J,crossTileID:Q}=G,ne=this.opacities[Q];o[Q]?ne=_:ne||(ne=B,this.opacities[Q]=ne),o[Q]=!0;let ue=G.numIconVertices>0,me=this.placedOrientations[G.crossTileID],Te=me===p.ah.vertical,Ae=me===p.ah.horizontal||me===p.ah.horizontalOnly;if(F>0||J>0){let ye=Fi(ne.text);V(e.text,F,Te?Tn:ye),V(e.text,J,Ae?Tn:ye);let Re=ne.text.isHidden();[G.rightJustifiedTextSymbolIndex,G.centerJustifiedTextSymbolIndex,G.leftJustifiedTextSymbolIndex].forEach((Pe=>{Pe>=0&&(e.text.placedSymbolArray.get(Pe).hidden=Re||Te?1:0)})),G.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(G.verticalPlacedTextSymbolIndex).hidden=Re||Ae?1:0);let We=this.variableOffsets[G.crossTileID];We&&this.markUsedJustification(e,We.anchor,G,me);let be=this.placedOrientations[G.crossTileID];be&&(this.markUsedJustification(e,"left",G,be),this.markUsedOrientation(e,be,G))}if(ue){let ye=Fi(ne.icon),Re=!(L&&G.verticalPlacedIconSymbolIndex&&Te);G.placedIconSymbolIndex>=0&&(V(e.icon,G.numIconVertices,Re?ye:Tn),e.icon.placedSymbolArray.get(G.placedIconSymbolIndex).hidden=ne.icon.isHidden()),G.verticalPlacedIconSymbolIndex>=0&&(V(e.icon,G.numVerticalIconVertices,Re?Tn:ye),e.icon.placedSymbolArray.get(G.verticalPlacedIconSymbolIndex).hidden=ne.icon.isHidden())}let xe=$&&$.has(q)?$.get(q):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let ye=e.collisionArrays[q];if(ye){let Re=new p.P(0,0);if(ye.textBox||ye.verticalTextBox){let We=!0;if(S){let be=this.variableOffsets[Q];be?(Re=si(be.anchor,be.width,be.height,be.textOffset,be.textBoxScale),T&&Re._rotate(E?this.transform.angle:-this.transform.angle)):We=!1}if(ye.textBox||ye.verticalTextBox){let be;ye.textBox&&(be=Te),ye.verticalTextBox&&(be=Ae),Sn(e.textCollisionBox.collisionVertexArray,ne.text.placed,!We||be,xe.text,Re.x,Re.y)}}if(ye.iconBox||ye.verticalIconBox){let We=!!(!Ae&&ye.verticalIconBox),be;ye.iconBox&&(be=We),ye.verticalIconBox&&(be=!We),Sn(e.iconCollisionBox.collisionVertexArray,ne.icon.placed,be,xe.icon,L?Re.x:0,L?Re.y:0)}}}}if(e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);if(e.bucketInstanceId in this.collisionCircleArrays){let q=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=q.invProjMatrix,e.placementViewportMatrix=q.viewportMatrix,e.collisionCircleArray=q.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(e){return this.fadeDuration===0?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,n){let o=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*o>e}setStale(){this.stale=!0}}function Sn(h,e,n,o,a,c){o&&o.length!==0||(o=[0,0,0,0]);let m=o[0]-Ke,_=o[1]-Ke,y=o[2]-Ke,b=o[3]-Ke;h.emplaceBack(e?1:0,n?1:0,a||0,c||0,m,_),h.emplaceBack(e?1:0,n?1:0,a||0,c||0,y,_),h.emplaceBack(e?1:0,n?1:0,a||0,c||0,y,b),h.emplaceBack(e?1:0,n?1:0,a||0,c||0,m,b)}let vt=Math.pow(2,25),No=Math.pow(2,24),Vo=Math.pow(2,17),Ri=Math.pow(2,16),Bi=Math.pow(2,9),hc=Math.pow(2,8),Zi=Math.pow(2,1);function Fi(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;let e=h.placed?1:0,n=Math.floor(127*h.opacity);return n*vt+e*No+n*Vo+e*Ri+n*Bi+e*hc+n*Zi+e}let Tn=0;function tn(){return{isOccluded:(h,e,n)=>!1,getPitchedTextCorrection:(h,e,n)=>1,get useSpecialProjectionForSymbols(){return!1},projectTileCoordinates(h,e,n,o){throw new Error("Not implemented.")},translatePosition:(h,e,n,o)=>(function(a,c,m,_,y=!1){if(!m[0]&&!m[1])return[0,0];let b=y?_==="map"?a.angle:0:_==="viewport"?-a.angle:0;if(b){let S=Math.sin(b),T=Math.cos(b);m=[m[0]*T-m[1]*S,m[0]*S+m[1]*T]}return[y?m[0]:ot(c,m[0],a.zoom),y?m[1]:ot(c,m[1],a.zoom)]})(h,e,n,o),getCircleRadiusCorrection:h=>1}}class Xt{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,n,o,a,c){let m=this._bucketParts;for(;this._currentTileIndex<e.length;)if(n.getBucketParts(m,a,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,c())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,m.sort(((_,y)=>_.sortKey-y.sortKey)));this._currentPartIndex<m.length;)if(n.placeLayerBucketPart(m[this._currentPartIndex],this._seenCrossTileIDs,o),this._currentPartIndex++,c())return!0;return!1}}class ps{constructor(e,n,o,a,c,m,_,y){this.placement=new vi(e,tn(),n,m,_,y),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=a,this._showCollisionBoxes=c,this._done=!1}isDone(){return this._done}continuePlacement(e,n,o){let a=pe.now(),c=()=>!this._forceFullPlacement&&pe.now()-a>2;for(;this._currentPlacementIndex>=0;){let m=n[e[this._currentPlacementIndex]],_=this.placement.collisionIndex.transform.zoom;if(m.type==="symbol"&&(!m.minzoom||m.minzoom<=_)&&(!m.maxzoom||m.maxzoom>_)){if(this._inProgressLayer||(this._inProgressLayer=new Xt(m)),this._inProgressLayer.continuePlacement(o[m.source],this.placement,this._showCollisionBoxes,m,c))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}let nr=512/p.X/2;class Gt{constructor(e,n,o){this.tileID=e,this.bucketInstanceId=o,this._symbolsByKey={};let a=new Map;for(let c=0;c<n.length;c++){let m=n.get(c),_=m.key,y=a.get(_);y?y.push(m):a.set(_,[m])}for(let[c,m]of a){let _={positions:m.map((y=>({x:Math.floor(y.anchorX*nr),y:Math.floor(y.anchorY*nr)}))),crossTileIDs:m.map((y=>y.crossTileID))};if(_.positions.length>128){let y=new p.av(_.positions.length,16,Uint16Array);for(let{x:b,y:S}of _.positions)y.add(b,S);y.finish(),delete _.positions,_.index=y}this._symbolsByKey[c]=_}}getScaledCoordinates(e,n){let{x:o,y:a,z:c}=this.tileID.canonical,{x:m,y:_,z:y}=n.canonical,b=nr/Math.pow(2,y-c),S=(_*p.X+e.anchorY)*b,T=a*p.X*nr;return{x:Math.floor((m*p.X+e.anchorX)*b-o*p.X*nr),y:Math.floor(S-T)}}findMatches(e,n,o){let a=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let c=0;c<e.length;c++){let m=e.get(c);if(m.crossTileID)continue;let _=this._symbolsByKey[m.key];if(!_)continue;let y=this.getScaledCoordinates(m,n);if(_.index){let b=_.index.range(y.x-a,y.y-a,y.x+a,y.y+a).sort();for(let S of b){let T=_.crossTileIDs[S];if(!o[T]){o[T]=!0,m.crossTileID=T;break}}}else if(_.positions)for(let b=0;b<_.positions.length;b++){let S=_.positions[b],T=_.crossTileIDs[b];if(Math.abs(S.x-y.x)<=a&&Math.abs(S.y-y.y)<=a&&!o[T]){o[T]=!0,m.crossTileID=T;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:e})=>e))}}class Us{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class sr{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let n=Math.round((e-this.lng)/360);if(n!==0)for(let o in this.indexes){let a=this.indexes[o],c={};for(let m in a){let _=a[m];_.tileID=_.tileID.unwrapTo(_.tileID.wrap+n),c[_.tileID.key]=_}this.indexes[o]=c}this.lng=e}addBucket(e,n,o){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let c=0;c<n.symbolInstances.length;c++)n.symbolInstances.get(c).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});let a=this.usedCrossTileIDs[e.overscaledZ];for(let c in this.indexes){let m=this.indexes[c];if(Number(c)>e.overscaledZ)for(let _ in m){let y=m[_];y.tileID.isChildOf(e)&&y.findMatches(n.symbolInstances,e,a)}else{let _=m[e.scaledTo(Number(c)).key];_&&_.findMatches(n.symbolInstances,e,a)}}for(let c=0;c<n.symbolInstances.length;c++){let m=n.symbolInstances.get(c);m.crossTileID||(m.crossTileID=o.generate(),a[m.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Gt(e,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(e,n){for(let o of n.getCrossTileIDsLists())for(let a of o)delete this.usedCrossTileIDs[e][a]}removeStaleBuckets(e){let n=!1;for(let o in this.indexes){let a=this.indexes[o];for(let c in a)e[a[c].bucketInstanceId]||(this.removeBucketCrossTileIDs(o,a[c]),delete a[c],n=!0)}return n}}class Uo{constructor(){this.layerIndexes={},this.crossTileIDs=new Us,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,n,o){let a=this.layerIndexes[e.id];a===void 0&&(a=this.layerIndexes[e.id]=new sr);let c=!1,m={};a.handleWrapJump(o);for(let _ of n){let y=_.getBucket(e);y&&e.id===y.layerIds[0]&&(y.bucketInstanceId||(y.bucketInstanceId=++this.maxBucketInstanceId),a.addBucket(_.tileID,y,this.crossTileIDs)&&(c=!0),m[y.bucketInstanceId]=!0)}return a.removeStaleBuckets(m)&&(c=!0),c}pruneUnusedLayers(e){let n={};e.forEach((o=>{n[o]=!0}));for(let o in this.layerIndexes)n[o]||delete this.layerIndexes[o]}}let or=(h,e)=>p.t(h,e&&e.filter((n=>n.identifier!=="source.canvas"))),uc=p.aw();class js extends p.E{constructor(e,n={}){super(),this._rtlPluginLoaded=()=>{for(let o in this.sourceCaches){let a=this.sourceCaches[o].getSource().type;a!=="vector"&&a!=="geojson"||this.sourceCaches[o].reload()}},this.map=e,this.dispatcher=new Qr(Yr(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((o,a)=>this.getGlyphs(o,a))),this.dispatcher.registerMessageHandler("GI",((o,a)=>this.getImages(o,a))),this.imageManager=new ze,this.imageManager.setEventedParent(this),this.glyphManager=new qt(e._requestManager,n.localIdeographFontFamily),this.lineAtlas=new xn(256,512),this.crossTileSymbolIndex=new Uo,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()),vr().on(ge,this._rtlPluginLoaded),this.on("data",(o=>{if(o.dataType!=="source"||o.sourceDataType!=="metadata")return;let a=this.sourceCaches[o.sourceId];if(!a)return;let c=a.getSource();if(c&&c.vectorLayerIds)for(let m in this._layers){let _=this._layers[m];_.source===c.id&&this._validateLayer(_)}}))}loadURL(e,n={},o){this.fire(new p.k("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;let a=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;let c=this._loadStyleRequest;p.h(a,this._loadStyleRequest).then((m=>{this._loadStyleRequest=null,this._load(m.data,n,o)})).catch((m=>{this._loadStyleRequest=null,m&&!c.signal.aborted&&this.fire(new p.j(m))}))}loadJSON(e,n={},o){this.fire(new p.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,pe.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(e,n,o)})).catch((()=>{}))}loadEmpty(){this.fire(new p.k("dataloading",{dataType:"style"})),this._load(uc,{validate:!1})}_load(e,n,o){var a;let c=n.transformStyle?n.transformStyle(o,e):e;if(!n.validate||!or(this,p.u(c))){this._loaded=!0,this.stylesheet=c;for(let 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 ci(this.stylesheet.light),this.sky=new tr(this.stylesheet.sky),this.map.setTerrain((a=this.stylesheet.terrain)!==null&&a!==void 0?a:null),this.fire(new p.k("data",{dataType:"style"})),this.fire(new p.k("style.load"))}}_createLayers(){let e=p.az(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map((n=>n.id)),this._layers={},this._serializedLayers=null;for(let n of e){let o=p.aA(n);o.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=o}}_loadSprite(e,n=!1,o=void 0){let a;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,(function(c,m,_,y){return p._(this,void 0,void 0,(function*(){let b=_t(c),S=_>1?"@2x":"",T={},E={};for(let{id:L,url:B}of b){let V=m.transformRequest(yi(B,S,".json"),"SpriteJSON");T[L]=p.h(V,y);let $=m.transformRequest(yi(B,S,".png"),"SpriteImage");E[L]=et.getImage($,y)}return yield Promise.all([...Object.values(T),...Object.values(E)]),(function(L,B){return p._(this,void 0,void 0,(function*(){let V={};for(let $ in L){V[$]={};let q=pe.getImageCanvasContext((yield B[$]).data),G=(yield L[$]).data;for(let F in G){let{width:J,height:Q,x:ne,y:ue,sdf:me,pixelRatio:Te,stretchX:Ae,stretchY:xe,content:ye,textFitWidth:Re,textFitHeight:We}=G[F];V[$][F]={data:null,pixelRatio:Te,sdf:me,stretchX:Ae,stretchY:xe,content:ye,textFitWidth:Re,textFitHeight:We,spriteData:{width:J,height:Q,x:ne,y:ue,context:q}}}}return V}))})(T,E)}))})(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((c=>{if(this._spriteRequest=null,c)for(let m in c){this._spritesImagesIds[m]=[];let _=this._spritesImagesIds[m]?this._spritesImagesIds[m].filter((y=>!(y in c))):[];for(let y of _)this.imageManager.removeImage(y),this._changedImages[y]=!0;for(let y in c[m]){let b=m==="default"?y:`${m}:${y}`;this._spritesImagesIds[m].push(b),b in this.imageManager.images?this.imageManager.updateImage(b,c[m][y],!1):this.imageManager.addImage(b,c[m][y]),n&&(this._changedImages[b]=!0)}}})).catch((c=>{this._spriteRequest=null,a=c,this.fire(new p.j(a))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"})),o&&o(a)}))}_unloadSprite(){for(let e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"}))}_validateLayer(e){let n=this.sourceCaches[e.source];if(!n)return;let o=e.sourceLayer;if(!o)return;let a=n.getSource();(a.type==="geojson"||a.vectorLayerIds&&a.vectorLayerIds.indexOf(o)===-1)&&this.fire(new p.j(new Error(`Source layer "${o}" does not exist on source "${a.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,n=!1){let o=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?p.aB(o):o);let a=[];for(let c of e)if(o[c]){let m=n?p.aB(o[c]):o[c];a.push(m)}return a}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let n=Object.keys(this._layers);for(let o of n){let a=this._layers[o];a.type!=="custom"&&(e[o]=a.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition()||this.sky&&this.sky.hasTransition())return!0;for(let e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;let n=this._changed;if(n){let a=Object.keys(this._updatedLayers),c=Object.keys(this._removedLayers);(a.length||c.length)&&this._updateWorkerLayers(a,c);for(let m in this._updatedSources){let _=this._updatedSources[m];if(_==="reload")this._reloadSource(m);else{if(_!=="clear")throw new Error(`Invalid action ${_}`);this._clearSource(m)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let m in this._updatedPaintProps)this._layers[m].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}let o={};for(let a in this.sourceCaches){let c=this.sourceCaches[a];o[a]=c.used,c.used=!1}for(let a of this._order){let c=this._layers[a];c.recalculate(e,this._availableImages),!c.isHidden(e.zoom)&&c.source&&(this.sourceCaches[c.source].used=!0)}for(let a in o){let c=this.sourceCaches[a];!!o[a]!=!!c.used&&c.fire(new p.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:a}))}this.light.recalculate(e),this.sky.recalculate(e),this.z=e.zoom,n&&this.fire(new p.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var o;this._checkLoaded();let a=this.serialize();if(e=n.transformStyle?n.transformStyle(a,e):e,((o=n.validate)===null||o===void 0||o)&&or(this,p.u(e)))return!1;(e=p.aB(e)).layers=p.az(e.layers);let c=p.aC(a,e),m=this._getOperationsToPerform(c);if(m.unimplemented.length>0)throw new Error(`Unimplemented: ${m.unimplemented.join(", ")}.`);if(m.operations.length===0)return!1;for(let _ of m.operations)_();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){let n=[],o=[];for(let a of e)switch(a.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":n.push((()=>this.addLayer.apply(this,a.args)));break;case"removeLayer":n.push((()=>this.removeLayer.apply(this,a.args)));break;case"setPaintProperty":n.push((()=>this.setPaintProperty.apply(this,a.args)));break;case"setLayoutProperty":n.push((()=>this.setLayoutProperty.apply(this,a.args)));break;case"setFilter":n.push((()=>this.setFilter.apply(this,a.args)));break;case"addSource":n.push((()=>this.addSource.apply(this,a.args)));break;case"removeSource":n.push((()=>this.removeSource.apply(this,a.args)));break;case"setLayerZoomRange":n.push((()=>this.setLayerZoomRange.apply(this,a.args)));break;case"setLight":n.push((()=>this.setLight.apply(this,a.args)));break;case"setGeoJSONSourceData":n.push((()=>this.setGeoJSONSourceData.apply(this,a.args)));break;case"setGlyphs":n.push((()=>this.setGlyphs.apply(this,a.args)));break;case"setSprite":n.push((()=>this.setSprite.apply(this,a.args)));break;case"setSky":n.push((()=>this.setSky.apply(this,a.args)));break;case"setTerrain":n.push((()=>this.map.setTerrain.apply(this,a.args)));break;case"setTransition":n.push((()=>{}));break;default:o.push(a.command)}return{operations:n,unimplemented:o}}addImage(e,n){if(this.getImage(e))return this.fire(new p.j(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,n),this._afterImageUpdated(e)}updateImage(e,n){this.imageManager.updateImage(e,n)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new p.j(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,o={}){if(this._checkLoaded(),this.sourceCaches[e]!==void 0)throw new Error(`Source "${e}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(p.u.source,`sources.${e}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);let a=this.sourceCaches[e]=new qe(e,n,this.dispatcher);a.style=this,a.setEventedParent(this,(()=>({isSourceLoaded:a.loaded(),source:a.serialize(),sourceId:e}))),a.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error("There is no source with this ID");for(let o in this._layers)if(this._layers[o].source===e)return this.fire(new p.j(new Error(`Source "${e}" cannot be removed while layer "${o}" is using it.`)));let n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new p.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,n){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error(`There is no source with this ID=${e}`);let o=this.sourceCaches[e].getSource();if(o.type!=="geojson")throw new Error(`geojsonSource.type is ${o.type}, which is !== 'geojson`);o.setData(n),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,n,o={}){this._checkLoaded();let a=e.id;if(this.getLayer(a))return void this.fire(new p.j(new Error(`Layer "${a}" already exists on this map.`)));let c;if(e.type==="custom"){if(or(this,p.aD(e)))return;c=p.aA(e)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(a,e.source),e=p.aB(e),e=p.e(e,{source:a})),this._validate(p.u.layer,`layers.${a}`,e,{arrayIndex:-1},o))return;c=p.aA(e),this._validateLayer(c),c.setEventedParent(this,{layer:{id:a}})}let m=n?this._order.indexOf(n):this._order.length;if(n&&m===-1)this.fire(new p.j(new Error(`Cannot add layer "${a}" before non-existing layer "${n}".`)));else{if(this._order.splice(m,0,a),this._layerOrderChanged=!0,this._layers[a]=c,this._removedLayers[a]&&c.source&&c.type!=="custom"){let _=this._removedLayers[a];delete this._removedLayers[a],_.type!==c.type?this._updatedSources[c.source]="clear":(this._updatedSources[c.source]="reload",this.sourceCaches[c.source].pause())}this._updateLayer(c),c.onAdd&&c.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new p.j(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;let o=this._order.indexOf(e);this._order.splice(o,1);let a=n?this._order.indexOf(n):this._order.length;n&&a===-1?this.fire(new p.j(new Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(a,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();let n=this._layers[e];if(!n)return void this.fire(new p.j(new Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);let o=this._order.indexOf(e);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,o){this._checkLoaded();let a=this.getLayer(e);a?a.minzoom===n&&a.maxzoom===o||(n!=null&&(a.minzoom=n),o!=null&&(a.maxzoom=o),this._updateLayer(a)):this.fire(new p.j(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,o={}){this._checkLoaded();let a=this.getLayer(e);if(a){if(!p.aE(a.filter,n))return n==null?(a.filter=void 0,void this._updateLayer(a)):void(this._validate(p.u.filter,`layers.${a.id}.filter`,n,null,o)||(a.filter=p.aB(n),this._updateLayer(a)))}else this.fire(new p.j(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return p.aB(this.getLayer(e).filter)}setLayoutProperty(e,n,o,a={}){this._checkLoaded();let c=this.getLayer(e);c?p.aE(c.getLayoutProperty(n),o)||(c.setLayoutProperty(n,o,a),this._updateLayer(c)):this.fire(new p.j(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){let o=this.getLayer(e);if(o)return o.getLayoutProperty(n);this.fire(new p.j(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,o,a={}){this._checkLoaded();let c=this.getLayer(e);c?p.aE(c.getPaintProperty(n),o)||(c.setPaintProperty(n,o,a)&&this._updateLayer(c),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new p.j(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(e,n){return this.getLayer(e).getPaintProperty(n)}setFeatureState(e,n){this._checkLoaded();let o=e.source,a=e.sourceLayer,c=this.sourceCaches[o];if(c===void 0)return void this.fire(new p.j(new Error(`The source '${o}' does not exist in the map's style.`)));let m=c.getSource().type;m==="geojson"&&a?this.fire(new p.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):m!=="vector"||a?(e.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),c.setFeatureState(a,e.id,n)):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,n){this._checkLoaded();let o=e.source,a=this.sourceCaches[o];if(a===void 0)return void this.fire(new p.j(new Error(`The source '${o}' does not exist in the map's style.`)));let c=a.getSource().type,m=c==="vector"?e.sourceLayer:void 0;c!=="vector"||m?n&&typeof e.id!="string"&&typeof e.id!="number"?this.fire(new p.j(new Error("A feature id is required to remove its specific state property."))):a.removeFeatureState(m,e.id,n):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();let n=e.source,o=e.sourceLayer,a=this.sourceCaches[n];if(a!==void 0)return a.getSource().type!=="vector"||o?(e.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),a.getFeatureState(o,e.id)):void this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new p.j(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return p.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;let e=p.aF(this.sourceCaches,(c=>c.serialize())),n=this._serializeByIds(this._order,!0),o=this.map.getTerrain()||void 0,a=this.stylesheet;return p.aG({version:a.version,name:a.name,metadata:a.metadata,light:a.light,sky:a.sky,center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch,sprite:a.sprite,glyphs:a.glyphs,transition:a.transition,sources:e,layers:n,terrain:o},(c=>c!==void 0))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.sourceCaches[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let n=m=>this._layers[m].type==="fill-extrusion",o={},a=[];for(let m=this._order.length-1;m>=0;m--){let _=this._order[m];if(n(_)){o[_]=m;for(let y of e){let b=y[_];if(b)for(let S of b)a.push(S)}}}a.sort(((m,_)=>_.intersectionZ-m.intersectionZ));let c=[];for(let m=this._order.length-1;m>=0;m--){let _=this._order[m];if(n(_))for(let y=a.length-1;y>=0;y--){let b=a[y].feature;if(o[b.layer.id]<m)break;c.push(b),a.pop()}else for(let y of e){let b=y[_];if(b)for(let S of b)c.push(S.feature)}}return c}queryRenderedFeatures(e,n,o){n&&n.filter&&this._validate(p.u.filter,"queryRenderedFeatures.filter",n.filter,null,n);let a={};if(n&&n.layers){if(!Array.isArray(n.layers))return this.fire(new p.j(new Error("parameters.layers must be an Array."))),[];for(let _ of n.layers){let y=this._layers[_];if(!y)return this.fire(new p.j(new Error(`The layer '${_}' does not exist in the map's style and cannot be queried for features.`))),[];a[y.source]=!0}}let c=[];n.availableImages=this._availableImages;let m=this._serializedAllLayers();for(let _ in this.sourceCaches)n.layers&&!a[_]||c.push(Nr(this.sourceCaches[_],this._layers,m,e,n,o));return this.placement&&c.push((function(_,y,b,S,T,E,L){let B={},V=E.queryRenderedSymbols(S),$=[];for(let q of Object.keys(V).map(Number))$.push(L[q]);$.sort(Vr);for(let q of $){let G=q.featureIndex.lookupSymbolFeatures(V[q.bucketInstanceId],y,q.bucketIndex,q.sourceLayerIndex,T.filter,T.layers,T.availableImages,_);for(let F in G){let J=B[F]=B[F]||[],Q=G[F];Q.sort(((ne,ue)=>{let me=q.featureSortOrder;if(me){let Te=me.indexOf(ne.featureIndex);return me.indexOf(ue.featureIndex)-Te}return ue.featureIndex-ne.featureIndex}));for(let ne of Q)J.push(ne)}}for(let q in B)B[q].forEach((G=>{let F=G.feature,J=b[_[q].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=J}));return B})(this._layers,m,this.sourceCaches,e,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(e,n){n&&n.filter&&this._validate(p.u.filter,"querySourceFeatures.filter",n.filter,null,n);let o=this.sourceCaches[e];return o?(function(a,c){let m=a.getRenderableIds().map((b=>a.getTileByID(b))),_=[],y={};for(let b=0;b<m.length;b++){let S=m[b],T=S.tileID.canonical.key;y[T]||(y[T]=!0,S.querySourceFeatures(_,c))}return _})(o,n):[]}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();let o=this.light.getLight(),a=!1;for(let m in e)if(!p.aE(e[m],o[m])){a=!0;break}if(!a)return;let c={now:pe.now(),transition:p.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,n),this.light.updateTransitions(c)}getSky(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.sky}setSky(e,n={}){let o=this.getSky(),a=!1;if(!e&&!o)return;if(e&&!o)a=!0;else if(!e&&o)a=!0;else for(let m in e)if(!p.aE(e[m],o[m])){a=!0;break}if(!a)return;let c={now:pe.now(),transition:p.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,n),this.sky.updateTransitions(c)}_validate(e,n,o,a,c={}){return(!c||c.validate!==!1)&&or(this,e.call(p.u,p.e({key:n,style:this.serialize(),value:o,styleSpec:p.v},a)))}_remove(e=!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),vr().off(ge,this._rtlPluginLoaded);for(let n in this._layers)this._layers[n].setEventedParent(null);for(let n in this.sourceCaches){let o=this.sourceCaches[n];o.setEventedParent(null),o.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.sourceCaches[e].clearTiles()}_reloadSource(e){this.sourceCaches[e].resume(),this.sourceCaches[e].reload()}_updateSources(e){for(let n in this.sourceCaches)this.sourceCaches[n].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.sourceCaches)this._reloadSource(e)}_updatePlacement(e,n,o,a,c=!1){let m=!1,_=!1,y={};for(let b of this._order){let S=this._layers[b];if(S.type!=="symbol")continue;if(!y[S.source]){let E=this.sourceCaches[S.source];y[S.source]=E.getRenderableIds(!0).map((L=>E.getTileByID(L))).sort(((L,B)=>B.tileID.overscaledZ-L.tileID.overscaledZ||(L.tileID.isLessThan(B.tileID)?-1:1)))}let T=this.crossTileSymbolIndex.addLayer(S,y[S.source],e.center.lng);m=m||T}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((c=c||this._layerOrderChanged||o===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(pe.now(),e.zoom))&&(this.pauseablePlacement=new ps(e,this.map.terrain,this._order,c,n,o,a,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(pe.now()),_=!0),m&&this.pauseablePlacement.placement.setStale()),_||m)for(let b of this._order){let S=this._layers[b];S.type==="symbol"&&this.placement.updateLayerOpacities(S,y[S.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(pe.now())}_releaseSymbolFadeTiles(){for(let e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,n){return p._(this,void 0,void 0,(function*(){let o=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();let a=this.sourceCaches[n.source];return a&&a.setDependencies(n.tileID.key,n.type,n.icons),o}))}getGlyphs(e,n){return p._(this,void 0,void 0,(function*(){let o=yield this.glyphManager.getGlyphs(n.stacks),a=this.sourceCaches[n.source];return a&&a.setDependencies(n.tileID.key,n.type,[""]),o}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(p.u.glyphs,"glyphs",e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,n,o={},a){this._checkLoaded();let c=[{id:e,url:n}],m=[..._t(this.stylesheet.sprite),...c];this._validate(p.u.sprite,"sprite",m,null,o)||(this.stylesheet.sprite=m,this._loadSprite(c,!0,a))}removeSprite(e){this._checkLoaded();let n=_t(this.stylesheet.sprite);if(n.find((o=>o.id===e))){if(this._spritesImagesIds[e])for(let o of this._spritesImagesIds[e])this.imageManager.removeImage(o),this._changedImages[o]=!0;n.splice(n.findIndex((o=>o.id===e)),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"}))}else this.fire(new p.j(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return _t(this.stylesheet.sprite)}setSprite(e,n={},o){this._checkLoaded(),e&&this._validate(p.u.sprite,"sprite",e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,o):(this._unloadSprite(),o&&o(null)))}}var rn=p.Y([{name:"a_pos",type:"Int16",components:2}]);let qr={prelude:gt(`#ifdef GL_ES
1
+ "use strict";var RcpchImdMap=(()=>{var Yf=Object.create;var Ql=Object.defineProperty;var Qf=Object.getOwnPropertyDescriptor;var em=Object.getOwnPropertyNames;var tm=Object.getPrototypeOf,im=Object.prototype.hasOwnProperty;var rm=(z,K)=>()=>(K||z((K={exports:{}}).exports,K),K.exports),nm=(z,K)=>{for(var Q in K)Ql(z,Q,{get:K[Q],enumerable:!0})},Id=(z,K,Q,oe)=>{if(K&&typeof K=="object"||typeof K=="function")for(let I of em(K))!im.call(z,I)&&I!==Q&&Ql(z,I,{get:()=>K[I],enumerable:!(oe=Qf(K,I))||oe.enumerable});return z};var ec=(z,K,Q)=>(Q=z!=null?Yf(tm(z)):{},Id(K||!z||!z.__esModule?Ql(Q,"default",{value:z,enumerable:!0}):Q,z)),sm=z=>Id(Ql({},"__esModule",{value:!0}),z);var Ga=rm((Th,Ih)=>{"use strict";(function(z,K){typeof Th=="object"&&typeof Ih<"u"?Ih.exports=K():typeof define=="function"&&define.amd?define(K):(z=typeof globalThis<"u"?globalThis:z||self,z.maplibregl=K())})(Th,(function(){"use strict";var z={},K={};function Q(I,d,me){if(K[I]=me,I==="index"){var _e="var sharedModule = {}; ("+K.shared+")(sharedModule); ("+K.worker+")(sharedModule);",Ve={};return K.shared(Ve),K.index(z,Ve),typeof window<"u"&&z.setWorkerUrl(window.URL.createObjectURL(new Blob([_e],{type:"text/javascript"}))),z}}Q("shared",["exports"],(function(I){"use strict";function d(i,t,r,s){return new(r||(r=Promise))((function(l,u){function p(x){try{g(s.next(x))}catch(v){u(v)}}function f(x){try{g(s.throw(x))}catch(v){u(v)}}function g(x){var v;x.done?l(x.value):(v=x.value,v instanceof r?v:new r((function(w){w(v)}))).then(p,f)}g((s=s.apply(i,t||[])).next())}))}function me(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var _e=Ve;function Ve(i,t){this.x=i,this.y=t}Ve.prototype={clone:function(){return new Ve(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,t){return this.clone()._rotateAround(i,t)},matMult:function(i){return this.clone()._matMult(i)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var t=i.x-this.x,r=i.y-this.y;return t*t+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,t){return Math.atan2(this.x*t-this.y*i,this.x*i+this.y*t)},_matMult:function(i){var t=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=t,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var t=Math.cos(i),r=Math.sin(i),s=r*this.x+t*this.y;return this.x=t*this.x-r*this.y,this.y=s,this},_rotateAround:function(i,t){var r=Math.cos(i),s=Math.sin(i),l=t.y+s*(this.x-t.x)+r*(this.y-t.y);return this.x=t.x+r*(this.x-t.x)-s*(this.y-t.y),this.y=l,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Ve.convert=function(i){return i instanceof Ve?i:Array.isArray(i)?new Ve(i[0],i[1]):i};var ue=me(_e),H=Xe;function Xe(i,t,r,s){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(s-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=t,this.p2x=r,this.p2y=s}Xe.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,t){if(t===void 0&&(t=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,s=0;s<8;s++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)<t)return r;var u=this.sampleCurveDerivativeX(r);if(Math.abs(u)<1e-6)break;r-=l/u}var p=0,f=1;for(r=i,s=0;s<20&&(l=this.sampleCurveX(r),!(Math.abs(l-i)<t));s++)i>l?p=r:f=r,r=.5*(f-p)+p;return r},solve:function(i,t){return this.sampleCurveY(this.solveCurveX(i,t))}};var wt=me(H);let Ct,Bt;function $t(){return Ct==null&&(Ct=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Ct}function ri(){if(Bt==null&&(Bt=!1,$t())){let t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let s=0;s<25;s++){let l=4*s;t.fillStyle=`rgb(${l},${l+1},${l+2})`,t.fillRect(s%5,Math.floor(s/5),1,1)}let r=t.getImageData(0,0,5,5).data;for(let s=0;s<100;s++)if(s%4!=3&&r[s]!==s){Bt=!0;break}}}return Bt||!1}function Ke(i,t,r,s){let l=new wt(i,t,r,s);return u=>l.solve(u)}let $e=Ke(.25,.1,.25,1);function Ye(i,t,r){return Math.min(r,Math.max(t,i))}function Pt(i,t,r){let s=r-t,l=((i-t)%s+s)%s+t;return l===t?r:l}function Mt(i,...t){for(let r of t)for(let s in r)i[s]=r[s];return i}let Nt=1;function ft(i,t,r){let s={};for(let l in i)s[l]=t.call(this,i[l],l,i);return s}function vi(i,t,r){let s={};for(let l in i)t.call(this,i[l],l,i)&&(s[l]=i[l]);return s}function et(i){return Array.isArray(i)?i.map(et):typeof i=="object"&&i?ft(i,et):i}let ei={};function ze(i){ei[i]||(typeof console<"u"&&console.warn(i),ei[i]=!0)}function it(i,t,r){return(r.y-i.y)*(t.x-i.x)>(t.y-i.y)*(r.x-i.x)}function ot(i){return typeof WorkerGlobalScope<"u"&&i!==void 0&&i instanceof WorkerGlobalScope}let ti=null;function Ht(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}let tr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function ir(i,t,r,s,l){return d(this,void 0,void 0,(function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");let u=new VideoFrame(i,{timestamp:0});try{let p=u?.format;if(!p||!p.startsWith("BGR")&&!p.startsWith("RGB"))throw new Error(`Unrecognized format ${p}`);let f=p.startsWith("BGR"),g=new Uint8ClampedArray(s*l*4);if(yield u.copyTo(g,(function(x,v,w,C,A){let k=4*Math.max(-v,0),L=(Math.max(0,w)-w)*C*4+k,O=4*C,j=Math.max(0,v),re=Math.max(0,w);return{rect:{x:j,y:re,width:Math.min(x.width,v+C)-j,height:Math.min(x.height,w+A)-re},layout:[{offset:L,stride:O}]}})(i,t,r,s,l)),f)for(let x=0;x<g.length;x+=4){let v=g[x];g[x]=g[x+2],g[x+2]=v}return g}finally{u.close()}}))}let ui,Wt,rr="AbortError";function vn(){return new Error(rr)}let Nr={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function xr(i){return Nr.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))]}let bn="global-dispatcher";class Fi extends Error{constructor(t,r,s,l){super(`AJAXError: ${r} (${t}): ${s}`),this.status=t,this.statusText=r,this.url=s,this.body=l}}let nr=()=>ot(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,Qr=function(i,t){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){let s=xr(i.url);if(s)return s(i,t);if(ot(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,targetMapId:bn},t)}if(!(/^file:/.test(r=i.url)||/^file:/.test(nr())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return(function(s,l){return d(this,void 0,void 0,(function*(){let u=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:nr(),signal:l.signal});s.type!=="json"||u.headers.has("Accept")||u.headers.set("Accept","application/json");let p=yield fetch(u);if(!p.ok){let x=yield p.blob();throw new Fi(p.status,p.statusText,s.url,x)}let f;f=s.type==="arrayBuffer"||s.type==="image"?p.arrayBuffer():s.type==="json"?p.json():p.text();let g=yield f;if(l.signal.aborted)throw vn();return{data:g,cacheControl:p.headers.get("Cache-Control"),expires:p.headers.get("Expires")}}))})(i,t);if(ot(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,mustQueue:!0,targetMapId:bn},t)}var r;return(function(s,l){return new Promise(((u,p)=>{var f;let g=new XMLHttpRequest;g.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(g.responseType="arraybuffer");for(let x in s.headers)g.setRequestHeader(x,s.headers[x]);s.type==="json"&&(g.responseType="text",!((f=s.headers)===null||f===void 0)&&f.Accept||g.setRequestHeader("Accept","application/json")),g.withCredentials=s.credentials==="include",g.onerror=()=>{p(new Error(g.statusText))},g.onload=()=>{if(!l.signal.aborted)if((g.status>=200&&g.status<300||g.status===0)&&g.response!==null){let x=g.response;if(s.type==="json")try{x=JSON.parse(g.response)}catch(v){return void p(v)}u({data:x,cacheControl:g.getResponseHeader("Cache-Control"),expires:g.getResponseHeader("Expires")})}else{let x=new Blob([g.response],{type:g.getResponseHeader("Content-Type")});p(new Fi(g.status,g.statusText,s.url,x))}},l.signal.addEventListener("abort",(()=>{g.abort(),p(vn())})),g.send(s.body)}))})(i,t)};function en(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;let t=new URL(i),r=window.location;return t.protocol===r.protocol&&t.host===r.host}function ls(i,t,r){r[i]&&r[i].indexOf(t)!==-1||(r[i]=r[i]||[],r[i].push(t))}function kr(i,t,r){if(r&&r[i]){let s=r[i].indexOf(t);s!==-1&&r[i].splice(s,1)}}class Vr{constructor(t,r={}){Mt(this,r),this.type=t}}class Ur extends Vr{constructor(t,r={}){super("error",Mt({error:t},r))}}class wn{on(t,r){return this._listeners=this._listeners||{},ls(t,r,this._listeners),this}off(t,r){return kr(t,r,this._listeners),kr(t,r,this._oneTimeListeners),this}once(t,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},ls(t,r,this._oneTimeListeners),this):new Promise((s=>this.once(t,s)))}fire(t,r){typeof t=="string"&&(t=new Vr(t,r||{}));let s=t.type;if(this.listens(s)){t.target=this;let l=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(let f of l)f.call(this,t);let u=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(let f of u)kr(s,f,this._oneTimeListeners),f.call(this,t);let p=this._eventedParent;p&&(Mt(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),p.fire(t))}else t instanceof Ur&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,r){return this._eventedParent=t,this._eventedParentData=r,this}}var ae={$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"}}};let tn=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function cs(i,t){let r={};for(let s in i)s!=="ref"&&(r[s]=i[s]);return tn.forEach((s=>{s in t&&(r[s]=t[s])})),r}function _t(i,t){if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(let r=0;r<i.length;r++)if(!_t(i[r],t[r]))return!1;return!0}if(typeof i=="object"&&i!==null&&t!==null){if(typeof t!="object"||Object.keys(i).length!==Object.keys(t).length)return!1;for(let r in i)if(!_t(i[r],t[r]))return!1;return!0}return i===t}function Vt(i,t){i.push(t)}function hs(i,t,r){Vt(r,{command:"addSource",args:[i,t[i]]})}function jr(i,t,r){Vt(t,{command:"removeSource",args:[i]}),r[i]=!0}function zr(i,t,r,s){jr(i,r,s),hs(i,t,r)}function Sn(i,t,r){let s;for(s in i[r])if(Object.prototype.hasOwnProperty.call(i[r],s)&&s!=="data"&&!_t(i[r][s],t[r][s]))return!1;for(s in t[r])if(Object.prototype.hasOwnProperty.call(t[r],s)&&s!=="data"&&!_t(i[r][s],t[r][s]))return!1;return!0}function Zi(i,t,r,s,l,u){i=i||{},t=t||{};for(let p in i)Object.prototype.hasOwnProperty.call(i,p)&&(_t(i[p],t[p])||r.push({command:u,args:[s,p,t[p],l]}));for(let p in t)Object.prototype.hasOwnProperty.call(t,p)&&!Object.prototype.hasOwnProperty.call(i,p)&&(_t(i[p],t[p])||r.push({command:u,args:[s,p,t[p],l]}))}function us(i){return i.id}function ds(i,t){return i[t.id]=t,i}class ye{constructor(t,r,s,l){this.message=(t?`${t}: `:"")+s,l&&(this.identifier=l),r!=null&&r.__line__&&(this.line=r.__line__)}}function vr(i,...t){for(let r of t)for(let s in r)i[s]=r[s];return i}class bi extends Error{constructor(t,r){super(r),this.message=r,this.key=t}}class br{constructor(t,r=[]){this.parent=t,this.bindings={};for(let[s,l]of r)this.bindings[s]=l}concat(t){return new br(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}let $r={kind:"null"},we={kind:"number"},rt={kind:"string"},Ze={kind:"boolean"},Pi={kind:"color"},sr={kind:"object"},Je={kind:"value"},wr={kind:"collator"},Lr={kind:"formatted"},qr={kind:"padding"},Sr={kind:"resolvedImage"},U={kind:"variableAnchorOffsetCollection"};function M(i,t){return{kind:"array",itemType:i,N:t}}function P(i){if(i.kind==="array"){let t=P(i.itemType);return typeof i.N=="number"?`array<${t}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${t}>`}return i.kind}let R=[$r,we,rt,Ze,Pi,Lr,sr,M(Je),qr,Sr,U];function N(i,t){if(t.kind==="error")return null;if(i.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!N(i.itemType,t.itemType))&&(typeof i.N!="number"||i.N===t.N))return null}else{if(i.kind===t.kind)return null;if(i.kind==="value"){for(let r of R)if(!N(r,t))return null}}return`Expected ${P(i)} but found ${P(t)} instead.`}function X(i,t){return t.some((r=>r.kind===i.kind))}function Y(i,t){return t.some((r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i))}function ie(i,t){return i.kind==="array"&&t.kind==="array"?i.itemType.kind===t.itemType.kind&&typeof i.N=="number":i.kind===t.kind}let Z=.96422,ce=.82521,pe=4/29,se=6/29,xe=3*se*se,Ne=se*se*se,Ue=Math.PI/180,dt=180/Math.PI;function Qe(i){return(i%=360)<0&&(i+=360),i}function pt([i,t,r,s]){let l,u,p=Jt((.2225045*(i=at(i))+.7168786*(t=at(t))+.0606169*(r=at(r)))/1);i===t&&t===r?l=u=p:(l=Jt((.4360747*i+.3850649*t+.1430804*r)/Z),u=Jt((.0139322*i+.0971045*t+.7141733*r)/ce));let f=116*p-16;return[f<0?0:f,500*(l-p),200*(p-u),s]}function at(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function Jt(i){return i>Ne?Math.pow(i,1/3):i/xe+pe}function Ut([i,t,r,s]){let l=(i+16)/116,u=isNaN(t)?l:l+t/500,p=isNaN(r)?l:l-r/200;return l=1*vt(l),u=Z*vt(u),p=ce*vt(p),[nt(3.1338561*u-1.6168667*l-.4906146*p),nt(-.9787684*u+1.9161415*l+.033454*p),nt(.0719453*u-.2289914*l+1.4052427*p),s]}function nt(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function vt(i){return i>se?i*i*i:xe*(i-pe)}function Ot(i){return parseInt(i.padEnd(2,i),16)/255}function ni(i,t){return li(t?i/100:i,0,1)}function li(i,t,r){return Math.min(Math.max(t,i),r)}function wi(i){return!i.some(Number.isNaN)}let Tn={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 bt{constructor(t,r,s,l=1,u=!0){this.r=t,this.g=r,this.b=s,this.a=l,u||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[t,r,s,l]))}static parse(t){if(t instanceof bt)return t;if(typeof t!="string")return;let r=(function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];let l=Tn[s];if(l){let[p,f,g]=l;return[p/255,f/255,g/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){let p=s.length<6?1:2,f=1;return[Ot(s.slice(f,f+=p)),Ot(s.slice(f,f+=p)),Ot(s.slice(f,f+=p)),Ot(s.slice(f,f+p)||"ff")]}if(s.startsWith("rgb")){let p=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(p){let[f,g,x,v,w,C,A,k,L,O,j,re]=p,W=[v||" ",A||" ",O].join("");if(W===" "||W===" /"||W===",,"||W===",,,"){let te=[x,C,L].join(""),le=te==="%%%"?100:te===""?255:0;if(le){let fe=[li(+g/le,0,1),li(+w/le,0,1),li(+k/le,0,1),j?ni(+j,re):1];if(wi(fe))return fe}}return}}let u=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(u){let[p,f,g,x,v,w,C,A,k]=u,L=[g||" ",v||" ",C].join("");if(L===" "||L===" /"||L===",,"||L===",,,"){let O=[+f,li(+x,0,100),li(+w,0,100),A?ni(+A,k):1];if(wi(O))return(function([j,re,W,te]){function le(fe){let Me=(fe+j/30)%12,je=re*Math.min(W,1-W);return W-je*Math.max(-1,Math.min(Me-3,9-Me,1))}return j=Qe(j),re/=100,W/=100,[le(0),le(8),le(4),te]})(O)}}})(t);return r?new bt(...r,!1):void 0}get rgb(){let{r:t,g:r,b:s,a:l}=this,u=l||1/0;return this.overwriteGetter("rgb",[t/u,r/u,s/u,l])}get hcl(){return this.overwriteGetter("hcl",(function(t){let[r,s,l,u]=pt(t),p=Math.sqrt(s*s+l*l);return[Math.round(1e4*p)?Qe(Math.atan2(l,s)*dt):NaN,p,r,u]})(this.rgb))}get lab(){return this.overwriteGetter("lab",pt(this.rgb))}overwriteGetter(t,r){return Object.defineProperty(this,t,{value:r}),r}toString(){let[t,r,s,l]=this.rgb;return`rgba(${[t,r,s].map((u=>Math.round(255*u))).join(",")},${l})`}}bt.black=new bt(0,0,0,1),bt.white=new bt(1,1,1,1),bt.transparent=new bt(0,0,0,0),bt.red=new bt(1,0,0,1);class Oo{constructor(t,r,s){this.sensitivity=t?r?"variant":"case":r?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,r){return this.collator.compare(t,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class No{constructor(t,r,s,l,u){this.text=t,this.image=r,this.scale=s,this.fontStack=l,this.textColor=u}}class Bi{constructor(t){this.sections=t}static fromString(t){return new Bi([new No(t,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some((t=>t.text.length!==0||t.image&&t.image.name.length!==0))}static factory(t){return t instanceof Bi?t:Bi.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map((t=>t.text)).join("")}}class Oi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Oi)return t;if(typeof t=="number")return new Oi([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let r of t)if(typeof r!="number")return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new Oi(t)}}toString(){return JSON.stringify(this.values)}}let cc=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Gi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Gi)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let r=0;r<t.length;r+=2){let s=t[r],l=t[r+1];if(typeof s!="string"||!cc.has(s)||!Array.isArray(l)||l.length!==2||typeof l[0]!="number"||typeof l[1]!="number")return}return new Gi(t)}}toString(){return JSON.stringify(this.values)}}class Ni{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Ni({name:t,available:!1}):null}}function In(i,t,r,s){return typeof i=="number"&&i>=0&&i<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof r=="number"&&r>=0&&r<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[i,t,r,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[i,t,r,s]:[i,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function rn(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof bt||i instanceof Oo||i instanceof Bi||i instanceof Oi||i instanceof Gi||i instanceof Ni)return!0;if(Array.isArray(i)){for(let t of i)if(!rn(t))return!1;return!0}if(typeof i=="object"){for(let t in i)if(!rn(i[t]))return!1;return!0}return!1}function Yt(i){if(i===null)return $r;if(typeof i=="string")return rt;if(typeof i=="boolean")return Ze;if(typeof i=="number")return we;if(i instanceof bt)return Pi;if(i instanceof Oo)return wr;if(i instanceof Bi)return Lr;if(i instanceof Oi)return qr;if(i instanceof Gi)return U;if(i instanceof Ni)return Sr;if(Array.isArray(i)){let t=i.length,r;for(let s of i){let l=Yt(s);if(r){if(r===l)continue;r=Je;break}r=l}return M(r||Je,t)}return sr}function ps(i){let t=typeof i;return i===null?"":t==="string"||t==="number"||t==="boolean"?String(i):i instanceof bt||i instanceof Bi||i instanceof Oi||i instanceof Gi||i instanceof Ni?i.toString():JSON.stringify(i)}class or{constructor(t,r){this.type=t,this.value=r}static parse(t,r){if(t.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!rn(t[1]))return r.error("invalid value");let s=t[1],l=Yt(s),u=r.expectedType;return l.kind!=="array"||l.N!==0||!u||u.kind!=="array"||typeof u.N=="number"&&u.N!==0||(l=u),new or(l,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Xt{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}let Vs={string:rt,number:we,boolean:Ze,object:sr};class ar{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s,l=1,u=t[0];if(u==="array"){let f,g;if(t.length>2){let x=t[1];if(typeof x!="string"||!(x in Vs)||x==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);f=Vs[x],l++}else f=Je;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return r.error('The length argument to "array" must be a positive integer literal',2);g=t[2],l++}s=M(f,g)}else{if(!Vs[u])throw new Error(`Types doesn't contain name = ${u}`);s=Vs[u]}let p=[];for(;l<t.length;l++){let f=r.parse(t[l],l,Je);if(!f)return null;p.push(f)}return new ar(s,p)}evaluate(t){for(let r=0;r<this.args.length;r++){let s=this.args[r].evaluate(t);if(!N(this.type,Yt(s)))return s;if(r===this.args.length-1)throw new Xt(`Expected value to be of type ${P(this.type)}, but found ${P(Yt(s))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}let Vo={"to-boolean":Ze,"to-color":Pi,"to-number":we,"to-string":rt};class lr{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s=t[0];if(!Vo[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&t.length!==2)return r.error("Expected one argument.");let l=Vo[s],u=[];for(let p=1;p<t.length;p++){let f=r.parse(t[p],p,Je);if(!f)return null;u.push(f)}return new lr(l,u)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let r,s;for(let l of this.args){if(r=l.evaluate(t),s=null,r instanceof bt)return r;if(typeof r=="string"){let u=t.parseColor(r);if(u)return u}else if(Array.isArray(r)&&(s=r.length<3||r.length>4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:In(r[0],r[1],r[2],r[3]),!s))return new bt(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Xt(s||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(let s of this.args){r=s.evaluate(t);let l=Oi.parse(r);if(l)return l}throw new Xt(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(let s of this.args){r=s.evaluate(t);let l=Gi.parse(r);if(l)return l}throw new Xt(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(let s of this.args){if(r=s.evaluate(t),r===null)return 0;let l=Number(r);if(!isNaN(l))return l}throw new Xt(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return Bi.fromString(ps(this.args[0].evaluate(t)));case"resolvedImage":return Ni.fromString(ps(this.args[0].evaluate(t)));default:return ps(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}let hc=["Unknown","Point","LineString","Polygon"];class Us{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"?hc[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let r=this._parseColorCache[t];return r||(r=this._parseColorCache[t]=bt.parse(t)),r}}class nn{constructor(t,r,s=[],l,u=new br,p=[]){this.registry=t,this.path=s,this.key=s.map((f=>`[${f}]`)).join(""),this.scope=u,this.errors=p,this.expectedType=l,this._isConstant=r}parse(t,r,s,l,u={}){return r?this.concat(r,s,l)._parse(t,u):this._parse(t,u)}_parse(t,r){function s(l,u,p){return p==="assert"?new ar(u,[l]):p==="coerce"?new lr(u,[l]):l}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let l=t[0];if(typeof l!="string")return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let u=this.registry[l];if(u){let p=u.parse(t,this);if(!p)return null;if(this.expectedType){let f=this.expectedType,g=p.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||g.kind!=="value")if(f.kind!=="color"&&f.kind!=="formatted"&&f.kind!=="resolvedImage"||g.kind!=="value"&&g.kind!=="string")if(f.kind!=="padding"||g.kind!=="value"&&g.kind!=="number"&&g.kind!=="array")if(f.kind!=="variableAnchorOffsetCollection"||g.kind!=="value"&&g.kind!=="array"){if(this.checkSubtype(f,g))return null}else p=s(p,f,r.typeAnnotation||"coerce");else p=s(p,f,r.typeAnnotation||"coerce");else p=s(p,f,r.typeAnnotation||"coerce");else p=s(p,f,r.typeAnnotation||"assert")}if(!(p instanceof or)&&p.type.kind!=="resolvedImage"&&this._isConstant(p)){let f=new Us;try{p=new or(p.type,p.evaluate(f))}catch(g){return this.error(g.message),null}}return p}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(t===void 0?"'undefined' value invalid. Use null instead.":typeof t=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,r,s){let l=typeof t=="number"?this.path.concat(t):this.path,u=s?this.scope.concat(s):this.scope;return new nn(this.registry,this._isConstant,l,r||null,u,this.errors)}error(t,...r){let s=`${this.key}${r.map((l=>`[${l}]`)).join("")}`;this.errors.push(new bi(s,t))}checkSubtype(t,r){let s=N(t,r);return s&&this.error(s),s}}class Zr{constructor(t,r){this.type=r.type,this.bindings=[].concat(t),this.result=r}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let r of this.bindings)t(r[1]);t(this.result)}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let s=[];for(let u=1;u<t.length-1;u+=2){let p=t[u];if(typeof p!="string")return r.error(`Expected string, but found ${typeof p} instead.`,u);if(/[^a-zA-Z0-9_]/.test(p))return r.error("Variable names must contain only alphanumeric characters or '_'.",u);let f=r.parse(t[u+1],u+1);if(!f)return null;s.push([p,f])}let l=r.parse(t[t.length-1],t.length-1,r.expectedType,s);return l?new Zr(s,l):null}outputDefined(){return this.result.outputDefined()}}class yt{constructor(t,r){this.type=r.type,this.name=t,this.boundExpression=r}static parse(t,r){if(t.length!==2||typeof t[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");let s=t[1];return r.scope.has(s)?new yt(s,r.scope.get(s)):r.error(`Unknown variable "${s}". Make sure "${s}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}}class Uo{constructor(t,r,s){this.type=t,this.index=r,this.input=s}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let s=r.parse(t[1],1,we),l=r.parse(t[2],2,M(r.expectedType||Je));return s&&l?new Uo(l.type.itemType,s,l):null}evaluate(t){let r=this.index.evaluate(t),s=this.input.evaluate(t);if(r<0)throw new Xt(`Array index out of bounds: ${r} < 0.`);if(r>=s.length)throw new Xt(`Array index out of bounds: ${r} > ${s.length-1}.`);if(r!==Math.floor(r))throw new Xt(`Array index must be an integer, but found ${r} instead.`);return s[r]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class jo{constructor(t,r){this.type=Ze,this.needle=t,this.haystack=r}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let s=r.parse(t[1],1,Je),l=r.parse(t[2],2,Je);return s&&l?X(s.type,[Ze,rt,we,$r,Je])?new jo(s,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`):null}evaluate(t){let r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!s)return!1;if(!Y(r,["boolean","string","number","null"]))throw new Xt(`Expected first argument to be of type boolean, string, number or null, but found ${P(Yt(r))} instead.`);if(!Y(s,["string","array"]))throw new Xt(`Expected second argument to be of type array or string, but found ${P(Yt(s))} instead.`);return s.indexOf(r)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class Cn{constructor(t,r,s){this.type=we,this.needle=t,this.haystack=r,this.fromIndex=s}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);let s=r.parse(t[1],1,Je),l=r.parse(t[2],2,Je);if(!s||!l)return null;if(!X(s.type,[Ze,rt,we,$r,Je]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`);if(t.length===4){let u=r.parse(t[3],3,we);return u?new Cn(s,l,u):null}return new Cn(s,l)}evaluate(t){let r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!Y(r,["boolean","string","number","null"]))throw new Xt(`Expected first argument to be of type boolean, string, number or null, but found ${P(Yt(r))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(t)),Y(s,["string"])){let u=s.indexOf(r,l);return u===-1?-1:[...s.slice(0,u)].length}if(Y(s,["array"]))return s.indexOf(r,l);throw new Xt(`Expected second argument to be of type array or string, but found ${P(Yt(s))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class $o{constructor(t,r,s,l,u,p){this.inputType=t,this.type=r,this.input=s,this.cases=l,this.outputs=u,this.otherwise=p}static parse(t,r){if(t.length<5)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return r.error("Expected an even number of arguments.");let s,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);let u={},p=[];for(let x=2;x<t.length-1;x+=2){let v=t[x],w=t[x+1];Array.isArray(v)||(v=[v]);let C=r.concat(x);if(v.length===0)return C.error("Expected at least one branch label.");for(let k of v){if(typeof k!="number"&&typeof k!="string")return C.error("Branch labels must be numbers or strings.");if(typeof k=="number"&&Math.abs(k)>Number.MAX_SAFE_INTEGER)return C.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof k=="number"&&Math.floor(k)!==k)return C.error("Numeric branch labels must be integer values.");if(s){if(C.checkSubtype(s,Yt(k)))return null}else s=Yt(k);if(u[String(k)]!==void 0)return C.error("Branch labels must be unique.");u[String(k)]=p.length}let A=r.parse(w,x,l);if(!A)return null;l=l||A.type,p.push(A)}let f=r.parse(t[1],1,Je);if(!f)return null;let g=r.parse(t[t.length-1],t.length-1,l);return g?f.type.kind!=="value"&&r.concat(1).checkSubtype(s,f.type)?null:new $o(s,l,f,u,p,g):null}evaluate(t){let r=this.input.evaluate(t);return(Yt(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class js{constructor(t,r,s){this.type=t,this.branches=r,this.otherwise=s}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return r.error("Expected an odd number of arguments.");let s;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);let l=[];for(let p=1;p<t.length-1;p+=2){let f=r.parse(t[p],p,Ze);if(!f)return null;let g=r.parse(t[p+1],p+1,s);if(!g)return null;l.push([f,g]),s=s||g.type}let u=r.parse(t[t.length-1],t.length-1,s);if(!u)return null;if(!s)throw new Error("Can't infer output type");return new js(s,l,u)}evaluate(t){for(let[r,s]of this.branches)if(r.evaluate(t))return s.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(let[r,s]of this.branches)t(r),t(s);t(this.otherwise)}outputDefined(){return this.branches.every((([t,r])=>r.outputDefined()))&&this.otherwise.outputDefined()}}class fs{constructor(t,r,s,l){this.type=t,this.input=r,this.beginIndex=s,this.endIndex=l}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);let s=r.parse(t[1],1,Je),l=r.parse(t[2],2,we);if(!s||!l)return null;if(!X(s.type,[M(Je),rt,Je]))return r.error(`Expected first argument to be of type array or string, but found ${P(s.type)} instead`);if(t.length===4){let u=r.parse(t[3],3,we);return u?new fs(s.type,s,l,u):null}return new fs(s.type,s,l)}evaluate(t){let r=this.input.evaluate(t),s=this.beginIndex.evaluate(t),l;if(this.endIndex&&(l=this.endIndex.evaluate(t)),Y(r,["string"]))return[...r].slice(s,l).join("");if(Y(r,["array"]))return r.slice(s,l);throw new Xt(`Expected first argument to be of type array or string, but found ${P(Yt(r))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function $s(i,t){let r=i.length-1,s,l,u=0,p=r,f=0;for(;u<=p;)if(f=Math.floor((u+p)/2),s=i[f],l=i[f+1],s<=t){if(f===r||t<l)return f;u=f+1}else{if(!(s>t))throw new Xt("Input is not a number.");p=f-1}return 0}class Pn{constructor(t,r,s){this.type=t,this.input=r,this.labels=[],this.outputs=[];for(let[l,u]of s)this.labels.push(l),this.outputs.push(u)}static parse(t,r){if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");let s=r.parse(t[1],1,we);if(!s)return null;let l=[],u=null;r.expectedType&&r.expectedType.kind!=="value"&&(u=r.expectedType);for(let p=1;p<t.length;p+=2){let f=p===1?-1/0:t[p],g=t[p+1],x=p,v=p+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);let w=r.parse(g,v,u);if(!w)return null;u=u||w.type,l.push([f,w])}return new Pn(u,s,l)}evaluate(t){let r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);let l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);let u=r.length;return l>=r[u-1]?s[u-1].evaluate(t):s[$s(r,l)].evaluate(t)}eachChild(t){t(this.input);for(let r of this.outputs)t(r)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Ja(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var uc=Ya;function Ya(i,t,r,s){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(s-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=t,this.p2x=r,this.p2y=s}Ya.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,t){if(t===void 0&&(t=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,s=0;s<8;s++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)<t)return r;var u=this.sampleCurveDerivativeX(r);if(Math.abs(u)<1e-6)break;r-=l/u}var p=0,f=1;for(r=i,s=0;s<20&&(l=this.sampleCurveX(r),!(Math.abs(l-i)<t));s++)i>l?p=r:f=r,r=.5*(f-p)+p;return r},solve:function(i,t){return this.sampleCurveY(this.solveCurveX(i,t))}};var dc=Ja(uc);function sn(i,t,r){return i+r*(t-i)}function ms(i,t,r){return i.map(((s,l)=>sn(s,t[l],r)))}let Mi={number:sn,color:function(i,t,r,s="rgb"){switch(s){case"rgb":{let[l,u,p,f]=ms(i.rgb,t.rgb,r);return new bt(l,u,p,f,!1)}case"hcl":{let[l,u,p,f]=i.hcl,[g,x,v,w]=t.hcl,C,A;if(isNaN(l)||isNaN(g))isNaN(l)?isNaN(g)?C=NaN:(C=g,p!==1&&p!==0||(A=x)):(C=l,v!==1&&v!==0||(A=u));else{let re=g-l;g>l&&re>180?re-=360:g<l&&l-g>180&&(re+=360),C=l+r*re}let[k,L,O,j]=(function([re,W,te,le]){return re=isNaN(re)?0:re*Ue,Ut([te,Math.cos(re)*W,Math.sin(re)*W,le])})([C,A??sn(u,x,r),sn(p,v,r),sn(f,w,r)]);return new bt(k,L,O,j,!1)}case"lab":{let[l,u,p,f]=Ut(ms(i.lab,t.lab,r));return new bt(l,u,p,f,!1)}}},array:ms,padding:function(i,t,r){return new Oi(ms(i.values,t.values,r))},variableAnchorOffsetCollection:function(i,t,r){let s=i.values,l=t.values;if(s.length!==l.length)throw new Xt(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${t.toString()}`);let u=[];for(let p=0;p<s.length;p+=2){if(s[p]!==l[p])throw new Xt(`Cannot interpolate values containing mismatched anchors. from[${p}]: ${s[p]}, to[${p}]: ${l[p]}`);u.push(s[p]);let[f,g]=s[p+1],[x,v]=l[p+1];u.push([sn(f,x,r),sn(g,v,r)])}return new Gi(u)}};class Ai{constructor(t,r,s,l,u){this.type=t,this.operator=r,this.interpolation=s,this.input=l,this.labels=[],this.outputs=[];for(let[p,f]of u)this.labels.push(p),this.outputs.push(f)}static interpolationFactor(t,r,s,l){let u=0;if(t.name==="exponential")u=qs(r,t.base,s,l);else if(t.name==="linear")u=qs(r,1,s,l);else if(t.name==="cubic-bezier"){let p=t.controlPoints;u=new dc(p[0],p[1],p[2],p[3]).solve(qs(r,1,s,l))}return u}static parse(t,r){let[s,l,u,...p]=t;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"){let 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);{let 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(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(u=r.parse(u,2,we),!u)return null;let f=[],g=null;s==="interpolate-hcl"||s==="interpolate-lab"?g=Pi:r.expectedType&&r.expectedType.kind!=="value"&&(g=r.expectedType);for(let x=0;x<p.length;x+=2){let v=p[x],w=p[x+1],C=x+3,A=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.',C);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.',C);let k=r.parse(w,A,g);if(!k)return null;g=g||k.type,f.push([v,k])}return ie(g,we)||ie(g,Pi)||ie(g,qr)||ie(g,U)||ie(g,M(we))?new Ai(g,s,l,u,f):r.error(`Type ${P(g)} is not interpolatable.`)}evaluate(t){let r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);let l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);let u=r.length;if(l>=r[u-1])return s[u-1].evaluate(t);let p=$s(r,l),f=Ai.interpolationFactor(this.interpolation,l,r[p],r[p+1]),g=s[p].evaluate(t),x=s[p+1].evaluate(t);switch(this.operator){case"interpolate":return Mi[this.type.kind](g,x,f);case"interpolate-hcl":return Mi.color(g,x,f,"hcl");case"interpolate-lab":return Mi.color(g,x,f,"lab")}}eachChild(t){t(this.input);for(let r of this.outputs)t(r)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function qs(i,t,r,s){let l=s-r,u=i-r;return l===0?0:t===1?u/l:(Math.pow(t,u)-1)/(Math.pow(t,l)-1)}class Zs{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expectected at least one argument.");let s=null,l=r.expectedType;l&&l.kind!=="value"&&(s=l);let u=[];for(let f of t.slice(1)){let g=r.parse(f,1+u.length,s,void 0,{typeAnnotation:"omit"});if(!g)return null;s=s||g.type,u.push(g)}if(!s)throw new Error("No output type");let p=l&&u.some((f=>N(l,f.type)));return new Zs(p?Je:s,u)}evaluate(t){let r,s=null,l=0;for(let u of this.args)if(l++,s=u.evaluate(t),s&&s instanceof Ni&&!s.available&&(r||(r=s.name),s=null,l===this.args.length&&(s=r)),s!==null)break;return s}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function Gs(i,t){return i==="=="||i==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function Qa(i,t,r,s){return s.compare(t,r)===0}function Mn(i,t,r){let s=i!=="=="&&i!=="!=";return class Cd{constructor(u,p,f){this.type=Ze,this.lhs=u,this.rhs=p,this.collator=f,this.hasUntypedArgument=u.type.kind==="value"||p.type.kind==="value"}static parse(u,p){if(u.length!==3&&u.length!==4)return p.error("Expected two or three arguments.");let f=u[0],g=p.parse(u[1],1,Je);if(!g)return null;if(!Gs(f,g.type))return p.concat(1).error(`"${f}" comparisons are not supported for type '${P(g.type)}'.`);let x=p.parse(u[2],2,Je);if(!x)return null;if(!Gs(f,x.type))return p.concat(2).error(`"${f}" comparisons are not supported for type '${P(x.type)}'.`);if(g.type.kind!==x.type.kind&&g.type.kind!=="value"&&x.type.kind!=="value")return p.error(`Cannot compare types '${P(g.type)}' and '${P(x.type)}'.`);s&&(g.type.kind==="value"&&x.type.kind!=="value"?g=new ar(x.type,[g]):g.type.kind!=="value"&&x.type.kind==="value"&&(x=new ar(g.type,[x])));let v=null;if(u.length===4){if(g.type.kind!=="string"&&x.type.kind!=="string"&&g.type.kind!=="value"&&x.type.kind!=="value")return p.error("Cannot use collator to compare non-string types.");if(v=p.parse(u[3],3,wr),!v)return null}return new Cd(g,x,v)}evaluate(u){let p=this.lhs.evaluate(u),f=this.rhs.evaluate(u);if(s&&this.hasUntypedArgument){let g=Yt(p),x=Yt(f);if(g.kind!==x.kind||g.kind!=="string"&&g.kind!=="number")throw new Xt(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${g.kind}, ${x.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){let g=Yt(p),x=Yt(f);if(g.kind!=="string"||x.kind!=="string")return t(u,p,f)}return this.collator?r(u,p,f,this.collator.evaluate(u)):t(u,p,f)}eachChild(u){u(this.lhs),u(this.rhs),this.collator&&u(this.collator)}outputDefined(){return!0}}}let pc=Mn("==",(function(i,t,r){return t===r}),Qa),el=Mn("!=",(function(i,t,r){return t!==r}),(function(i,t,r,s){return!Qa(0,t,r,s)})),tl=Mn("<",(function(i,t,r){return t<r}),(function(i,t,r,s){return s.compare(t,r)<0})),fc=Mn(">",(function(i,t,r){return t>r}),(function(i,t,r,s){return s.compare(t,r)>0})),mc=Mn("<=",(function(i,t,r){return t<=r}),(function(i,t,r,s){return s.compare(t,r)<=0})),il=Mn(">=",(function(i,t,r){return t>=r}),(function(i,t,r,s){return s.compare(t,r)>=0}));class gs{constructor(t,r,s){this.type=wr,this.locale=s,this.caseSensitive=t,this.diacriticSensitive=r}static parse(t,r){if(t.length!==2)return r.error("Expected one argument.");let s=t[1];if(typeof s!="object"||Array.isArray(s))return r.error("Collator options argument must be an object.");let l=r.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,Ze);if(!l)return null;let u=r.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,Ze);if(!u)return null;let p=null;return s.locale&&(p=r.parse(s.locale,1,rt),!p)?null:new gs(l,u,p)}evaluate(t){return new Oo(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class qo{constructor(t,r,s,l,u){this.type=rt,this.number=t,this.locale=r,this.currency=s,this.minFractionDigits=l,this.maxFractionDigits=u}static parse(t,r){if(t.length!==3)return r.error("Expected two arguments.");let s=r.parse(t[1],1,we);if(!s)return null;let l=t[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let u=null;if(l.locale&&(u=r.parse(l.locale,1,rt),!u))return null;let p=null;if(l.currency&&(p=r.parse(l.currency,1,rt),!p))return null;let f=null;if(l["min-fraction-digits"]&&(f=r.parse(l["min-fraction-digits"],1,we),!f))return null;let g=null;return l["max-fraction-digits"]&&(g=r.parse(l["max-fraction-digits"],1,we),!g)?null:new qo(s,u,p,f,g)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class Hs{constructor(t){this.type=Lr,this.sections=t}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s=t[1];if(!Array.isArray(s)&&typeof s=="object")return r.error("First argument must be an image or text section.");let l=[],u=!1;for(let p=1;p<=t.length-1;++p){let f=t[p];if(u&&typeof f=="object"&&!Array.isArray(f)){u=!1;let g=null;if(f["font-scale"]&&(g=r.parse(f["font-scale"],1,we),!g))return null;let x=null;if(f["text-font"]&&(x=r.parse(f["text-font"],1,M(rt)),!x))return null;let v=null;if(f["text-color"]&&(v=r.parse(f["text-color"],1,Pi),!v))return null;let w=l[l.length-1];w.scale=g,w.font=x,w.textColor=v}else{let g=r.parse(t[p],1,Je);if(!g)return null;let x=g.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");u=!0,l.push({content:g,scale:null,font:null,textColor:null})}}return new Hs(l)}evaluate(t){return new Bi(this.sections.map((r=>{let s=r.content.evaluate(t);return Yt(s)===Sr?new No("",s,null,null,null):new No(ps(s),null,r.scale?r.scale.evaluate(t):null,r.font?r.font.evaluate(t).join(","):null,r.textColor?r.textColor.evaluate(t):null)})))}eachChild(t){for(let r of this.sections)t(r.content),r.scale&&t(r.scale),r.font&&t(r.font),r.textColor&&t(r.textColor)}outputDefined(){return!1}}class Zo{constructor(t){this.type=Sr,this.input=t}static parse(t,r){if(t.length!==2)return r.error("Expected two arguments.");let s=r.parse(t[1],1,rt);return s?new Zo(s):r.error("No image name provided.")}evaluate(t){let r=this.input.evaluate(t),s=Ni.fromString(r);return s&&t.availableImages&&(s.available=t.availableImages.indexOf(r)>-1),s}eachChild(t){t(this.input)}outputDefined(){return!1}}class Go{constructor(t){this.type=we,this.input=t}static parse(t,r){if(t.length!==2)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);let s=r.parse(t[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${P(s.type)} instead.`):new Go(s):null}evaluate(t){let r=this.input.evaluate(t);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new Xt(`Expected value to be of type string or array, but found ${P(Yt(r))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}let Tr=8192;function gc(i,t){let r=(180+i[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,l=Math.pow(2,t.z);return[Math.round(r*l*Tr),Math.round(s*l*Tr)]}function Ho(i,t){let r=Math.pow(2,t.z);return[(l=(i[0]/Tr+t.x)/r,360*l-180),(s=(i[1]/Tr+t.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,l}function on(i,t){i[0]=Math.min(i[0],t[0]),i[1]=Math.min(i[1],t[1]),i[2]=Math.max(i[2],t[0]),i[3]=Math.max(i[3],t[1])}function Gr(i,t){return!(i[0]<=t[0]||i[2]>=t[2]||i[1]<=t[1]||i[3]>=t[3])}function xt(i,t,r){let s=i[0]-t[0],l=i[1]-t[1],u=i[0]-r[0],p=i[1]-r[1];return s*p-u*l==0&&s*u<=0&&l*p<=0}function Ws(i,t,r,s){return(l=[s[0]-r[0],s[1]-r[1]])[0]*(u=[t[0]-i[0],t[1]-i[1]])[1]-l[1]*u[0]!=0&&!(!nl(i,t,r,s)||!nl(r,s,i,t));var l,u}function _c(i,t,r){for(let s of r)for(let l=0;l<s.length-1;++l)if(Ws(i,t,s[l],s[l+1]))return!0;return!1}function An(i,t,r=!1){let s=!1;for(let f of t)for(let g=0;g<f.length-1;g++){if(xt(i,f[g],f[g+1]))return r;(u=f[g])[1]>(l=i)[1]!=(p=f[g+1])[1]>l[1]&&l[0]<(p[0]-u[0])*(l[1]-u[1])/(p[1]-u[1])+u[0]&&(s=!s)}var l,u,p;return s}function yc(i,t){for(let r of t)if(An(i,r))return!0;return!1}function rl(i,t){for(let r of i)if(!An(r,t))return!1;for(let r=0;r<i.length-1;++r)if(_c(i[r],i[r+1],t))return!1;return!0}function xc(i,t){for(let r of t)if(rl(i,r))return!0;return!1}function nl(i,t,r,s){let l=s[0]-r[0],u=s[1]-r[1],p=(i[0]-r[0])*u-l*(i[1]-r[1]),f=(t[0]-r[0])*u-l*(t[1]-r[1]);return p>0&&f<0||p<0&&f>0}function Wo(i,t,r){let s=[];for(let l=0;l<i.length;l++){let u=[];for(let p=0;p<i[l].length;p++){let f=gc(i[l][p],r);on(t,f),u.push(f)}s.push(u)}return s}function sl(i,t,r){let s=[];for(let l=0;l<i.length;l++){let u=Wo(i[l],t,r);s.push(u)}return s}function ol(i,t,r,s){if(i[0]<r[0]||i[0]>r[2]){let l=.5*s,u=i[0]-r[0]>l?-s:r[0]-i[0]>l?s:0;u===0&&(u=i[0]-r[2]>l?-s:r[2]-i[0]>l?s:0),i[0]+=u}on(t,i)}function al(i,t,r,s){let l=Math.pow(2,s.z)*Tr,u=[s.x*Tr,s.y*Tr],p=[];for(let f of i)for(let g of f){let x=[g.x+u[0],g.y+u[1]];ol(x,t,r,l),p.push(x)}return p}function ll(i,t,r,s){let l=Math.pow(2,s.z)*Tr,u=[s.x*Tr,s.y*Tr],p=[];for(let g of i){let x=[];for(let v of g){let w=[v.x+u[0],v.y+u[1]];on(t,w),x.push(w)}p.push(x)}if(t[2]-t[0]<=l/2){(f=t)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(let g of p)for(let x of g)ol(x,t,r,l)}var f;return p}class an{constructor(t,r){this.type=Ze,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(rn(t[1])){let s=t[1];if(s.type==="FeatureCollection"){let l=[];for(let u of s.features){let{type:p,coordinates:f}=u.geometry;p==="Polygon"&&l.push(f),p==="MultiPolygon"&&l.push(...f)}if(l.length)return new an(s,{type:"MultiPolygon",coordinates:l})}else if(s.type==="Feature"){let l=s.geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new an(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new an(s,s)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return(function(r,s){let l=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],p=r.canonicalID();if(s.type==="Polygon"){let f=Wo(s.coordinates,u,p),g=al(r.geometry(),l,u,p);if(!Gr(l,u))return!1;for(let x of g)if(!An(x,f))return!1}if(s.type==="MultiPolygon"){let f=sl(s.coordinates,u,p),g=al(r.geometry(),l,u,p);if(!Gr(l,u))return!1;for(let x of g)if(!yc(x,f))return!1}return!0})(t,this.geometries);if(t.geometryType()==="LineString")return(function(r,s){let l=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],p=r.canonicalID();if(s.type==="Polygon"){let f=Wo(s.coordinates,u,p),g=ll(r.geometry(),l,u,p);if(!Gr(l,u))return!1;for(let x of g)if(!rl(x,f))return!1}if(s.type==="MultiPolygon"){let f=sl(s.coordinates,u,p),g=ll(r.geometry(),l,u,p);if(!Gr(l,u))return!1;for(let x of g)if(!xc(x,f))return!1}return!0})(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let cl=class{constructor(i=[],t=((r,s)=>r<s?-1:r>s?1:0)){if(this.data=i,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(i){this.data.push(i),this._up(this.length++)}pop(){if(this.length===0)return;let i=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),i}peek(){return this.data[0]}_up(i){let{data:t,compare:r}=this,s=t[i];for(;i>0;){let l=i-1>>1,u=t[l];if(r(s,u)>=0)break;t[i]=u,i=l}t[i]=s}_down(i){let{data:t,compare:r}=this,s=this.length>>1,l=t[i];for(;i<s;){let u=1+(i<<1),p=u+1;if(p<this.length&&r(t[p],t[u])<0&&(u=p),r(t[u],l)>=0)break;t[i]=t[u],i=u}t[i]=l}};function vc(i,t,r,s,l){hl(i,t,r,s||i.length-1,l||bc)}function hl(i,t,r,s,l){for(;s>r;){if(s-r>600){var u=s-r+1,p=t-r+1,f=Math.log(u),g=.5*Math.exp(2*f/3),x=.5*Math.sqrt(f*g*(u-g)/u)*(p-u/2<0?-1:1);hl(i,t,Math.max(r,Math.floor(t-p*g/u+x)),Math.min(s,Math.floor(t+(u-p)*g/u+x)),l)}var v=i[t],w=r,C=s;for(_s(i,r,t),l(i[s],v)>0&&_s(i,r,s);w<C;){for(_s(i,w,C),w++,C--;l(i[w],v)<0;)w++;for(;l(i[C],v)>0;)C--}l(i[r],v)===0?_s(i,r,C):_s(i,++C,s),C<=t&&(r=C+1),t<=C&&(s=C-1)}}function _s(i,t,r){var s=i[t];i[t]=i[r],i[r]=s}function bc(i,t){return i<t?-1:i>t?1:0}function Xs(i,t){if(i.length<=1)return[i];let r=[],s,l;for(let u of i){let p=Sc(u);p!==0&&(u.area=Math.abs(p),l===void 0&&(l=p<0),l===p<0?(s&&r.push(s),s=[u]):s.push(u))}if(s&&r.push(s),t>1)for(let u=0;u<r.length;u++)r[u].length<=t||(vc(r[u],t,1,r[u].length-1,wc),r[u]=r[u].slice(0,t));return r}function wc(i,t){return t.area-i.area}function Sc(i){let t=0;for(let r,s,l=0,u=i.length,p=u-1;l<u;p=l++)r=i[l],s=i[p],t+=(s.x-r.x)*(r.y+s.y);return t}let ul=1/298.257223563,dl=ul*(2-ul),pl=Math.PI/180;class Xo{constructor(t){let r=6378.137*pl*1e3,s=Math.cos(t*pl),l=1/(1-dl*(1-s*s)),u=Math.sqrt(l);this.kx=r*u*s,this.ky=r*u*l*(1-dl)}distance(t,r){let s=this.wrap(t[0]-r[0])*this.kx,l=(t[1]-r[1])*this.ky;return Math.sqrt(s*s+l*l)}pointOnLine(t,r){let s,l,u,p,f=1/0;for(let g=0;g<t.length-1;g++){let x=t[g][0],v=t[g][1],w=this.wrap(t[g+1][0]-x)*this.kx,C=(t[g+1][1]-v)*this.ky,A=0;w===0&&C===0||(A=(this.wrap(r[0]-x)*this.kx*w+(r[1]-v)*this.ky*C)/(w*w+C*C),A>1?(x=t[g+1][0],v=t[g+1][1]):A>0&&(x+=w/this.kx*A,v+=C/this.ky*A)),w=this.wrap(r[0]-x)*this.kx,C=(r[1]-v)*this.ky;let k=w*w+C*C;k<f&&(f=k,s=x,l=v,u=g,p=A)}return{point:[s,l],index:u,t:Math.max(0,Math.min(1,p))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function fl(i,t){return t[0]-i[0]}function Ks(i){return i[1]-i[0]+1}function Dr(i,t){return i[1]>=i[0]&&i[1]<t}function Ko(i,t){if(i[0]>i[1])return[null,null];let r=Ks(i);if(t){if(r===2)return[i,null];let l=Math.floor(r/2);return[[i[0],i[0]+l],[i[0]+l,i[1]]]}if(r===1)return[i,null];let s=Math.floor(r/2)-1;return[[i[0],i[0]+s],[i[0]+s+1,i[1]]]}function Jo(i,t){if(!Dr(t,i.length))return[1/0,1/0,-1/0,-1/0];let r=[1/0,1/0,-1/0,-1/0];for(let s=t[0];s<=t[1];++s)on(r,i[s]);return r}function Yo(i){let t=[1/0,1/0,-1/0,-1/0];for(let r of i)for(let s of r)on(t,s);return t}function Js(i){return i[0]!==-1/0&&i[1]!==-1/0&&i[2]!==1/0&&i[3]!==1/0}function Qo(i,t,r){if(!Js(i)||!Js(t))return NaN;let s=0,l=0;return i[2]<t[0]&&(s=t[0]-i[2]),i[0]>t[2]&&(s=i[0]-t[2]),i[1]>t[3]&&(l=i[1]-t[3]),i[3]<t[1]&&(l=t[1]-i[3]),r.distance([0,0],[s,l])}function ln(i,t,r){let s=r.pointOnLine(t,i);return r.distance(i,s.point)}function ea(i,t,r,s,l){let u=Math.min(ln(i,[r,s],l),ln(t,[r,s],l)),p=Math.min(ln(r,[i,t],l),ln(s,[i,t],l));return Math.min(u,p)}function Tc(i,t,r,s,l){if(!Dr(t,i.length)||!Dr(s,r.length))return 1/0;let u=1/0;for(let p=t[0];p<t[1];++p){let f=i[p],g=i[p+1];for(let x=s[0];x<s[1];++x){let v=r[x],w=r[x+1];if(Ws(f,g,v,w))return 0;u=Math.min(u,ea(f,g,v,w,l))}}return u}function qt(i,t,r,s,l){if(!Dr(t,i.length)||!Dr(s,r.length))return NaN;let u=1/0;for(let p=t[0];p<=t[1];++p)for(let f=s[0];f<=s[1];++f)if(u=Math.min(u,l.distance(i[p],r[f])),u===0)return u;return u}function Ic(i,t,r){if(An(i,t,!0))return 0;let s=1/0;for(let l of t){let u=l[0],p=l[l.length-1];if(u!==p&&(s=Math.min(s,ln(i,[p,u],r)),s===0))return s;let f=r.pointOnLine(l,i);if(s=Math.min(s,r.distance(i,f.point)),s===0)return s}return s}function st(i,t,r,s){if(!Dr(t,i.length))return NaN;for(let u=t[0];u<=t[1];++u)if(An(i[u],r,!0))return 0;let l=1/0;for(let u=t[0];u<t[1];++u){let p=i[u],f=i[u+1];for(let g of r)for(let x=0,v=g.length,w=v-1;x<v;w=x++){let C=g[w],A=g[x];if(Ws(p,f,C,A))return 0;l=Math.min(l,ea(p,f,C,A,s))}}return l}function Ys(i,t){for(let r of i)for(let s of r)if(An(s,t,!0))return!0;return!1}function Et(i,t,r,s=1/0){let l=Yo(i),u=Yo(t);if(s!==1/0&&Qo(l,u,r)>=s)return s;if(Gr(l,u)){if(Ys(i,t))return 0}else if(Ys(t,i))return 0;let p=1/0;for(let f of i)for(let g=0,x=f.length,v=x-1;g<x;v=g++){let w=f[v],C=f[g];for(let A of t)for(let k=0,L=A.length,O=L-1;k<L;O=k++){let j=A[O],re=A[k];if(Ws(w,C,j,re))return 0;p=Math.min(p,ea(w,C,j,re,r))}}return p}function St(i,t,r,s,l,u){if(!u)return;let p=Qo(Jo(s,u),l,r);p<t&&i.push([p,u,[0,0]])}function cn(i,t,r,s,l,u,p){if(!u||!p)return;let f=Qo(Jo(s,u),Jo(l,p),r);f<t&&i.push([f,u,p])}function ys(i,t,r,s,l=1/0){let u=Math.min(s.distance(i[0],r[0][0]),l);if(u===0)return u;let p=new cl([[0,[0,i.length-1],[0,0]]],fl),f=Yo(r);for(;p.length>0;){let g=p.pop();if(g[0]>=u)continue;let x=g[1],v=t?50:100;if(Ks(x)<=v){if(!Dr(x,i.length))return NaN;if(t){let w=st(i,x,r,s);if(isNaN(w)||w===0)return w;u=Math.min(u,w)}else for(let w=x[0];w<=x[1];++w){let C=Ic(i[w],r,s);if(u=Math.min(u,C),u===0)return 0}}else{let w=Ko(x,t);St(p,u,s,i,f,w[0]),St(p,u,s,i,f,w[1])}}return u}function xs(i,t,r,s,l,u=1/0){let p=Math.min(u,l.distance(i[0],r[0]));if(p===0)return p;let f=new cl([[0,[0,i.length-1],[0,r.length-1]]],fl);for(;f.length>0;){let g=f.pop();if(g[0]>=p)continue;let x=g[1],v=g[2],w=t?50:100,C=s?50:100;if(Ks(x)<=w&&Ks(v)<=C){if(!Dr(x,i.length)&&Dr(v,r.length))return NaN;let A;if(t&&s)A=Tc(i,x,r,v,l),p=Math.min(p,A);else if(t&&!s){let k=i.slice(x[0],x[1]+1);for(let L=v[0];L<=v[1];++L)if(A=ln(r[L],k,l),p=Math.min(p,A),p===0)return p}else if(!t&&s){let k=r.slice(v[0],v[1]+1);for(let L=x[0];L<=x[1];++L)if(A=ln(i[L],k,l),p=Math.min(p,A),p===0)return p}else A=qt(i,x,r,v,l),p=Math.min(p,A)}else{let A=Ko(x,t),k=Ko(v,s);cn(f,p,l,i,r,A[0],k[0]),cn(f,p,l,i,r,A[0],k[1]),cn(f,p,l,i,r,A[1],k[0]),cn(f,p,l,i,r,A[1],k[1])}}return p}function ta(i){return i.type==="MultiPolygon"?i.coordinates.map((t=>({type:"Polygon",coordinates:t}))):i.type==="MultiLineString"?i.coordinates.map((t=>({type:"LineString",coordinates:t}))):i.type==="MultiPoint"?i.coordinates.map((t=>({type:"Point",coordinates:t}))):[i]}class hn{constructor(t,r){this.type=we,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(rn(t[1])){let s=t[1];if(s.type==="FeatureCollection")return new hn(s,s.features.map((l=>ta(l.geometry))).flat());if(s.type==="Feature")return new hn(s,ta(s.geometry));if("type"in s&&"coordinates"in s)return new hn(s,ta(s))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return(function(r,s){let l=r.geometry(),u=l.flat().map((g=>Ho([g.x,g.y],r.canonical)));if(l.length===0)return NaN;let p=new Xo(u[0][1]),f=1/0;for(let g of s){switch(g.type){case"Point":f=Math.min(f,xs(u,!1,[g.coordinates],!1,p,f));break;case"LineString":f=Math.min(f,xs(u,!1,g.coordinates,!0,p,f));break;case"Polygon":f=Math.min(f,ys(u,!1,g.coordinates,p,f))}if(f===0)return f}return f})(t,this.geometries);if(t.geometryType()==="LineString")return(function(r,s){let l=r.geometry(),u=l.flat().map((g=>Ho([g.x,g.y],r.canonical)));if(l.length===0)return NaN;let p=new Xo(u[0][1]),f=1/0;for(let g of s){switch(g.type){case"Point":f=Math.min(f,xs(u,!0,[g.coordinates],!1,p,f));break;case"LineString":f=Math.min(f,xs(u,!0,g.coordinates,!0,p,f));break;case"Polygon":f=Math.min(f,ys(u,!0,g.coordinates,p,f))}if(f===0)return f}return f})(t,this.geometries);if(t.geometryType()==="Polygon")return(function(r,s){let l=r.geometry();if(l.length===0||l[0].length===0)return NaN;let u=Xs(l,0).map((g=>g.map((x=>x.map((v=>Ho([v.x,v.y],r.canonical))))))),p=new Xo(u[0][0][0][1]),f=1/0;for(let g of s)for(let x of u){switch(g.type){case"Point":f=Math.min(f,ys([g.coordinates],!1,x,p,f));break;case"LineString":f=Math.min(f,ys(g.coordinates,!0,x,p,f));break;case"Polygon":f=Math.min(f,Et(x,g.coordinates,p,f))}if(f===0)return f}return f})(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}let En={"==":pc,"!=":el,">":fc,"<":tl,">=":il,"<=":mc,array:ar,at:Uo,boolean:ar,case:js,coalesce:Zs,collator:gs,format:Hs,image:Zo,in:jo,"index-of":Cn,interpolate:Ai,"interpolate-hcl":Ai,"interpolate-lab":Ai,length:Go,let:Zr,literal:or,match:$o,number:ar,"number-format":qo,object:ar,slice:fs,step:Pn,string:ar,"to-boolean":lr,"to-color":lr,"to-number":lr,"to-string":lr,var:yt,within:an,distance:hn};class Hi{constructor(t,r,s,l){this.name=t,this.type=r,this._evaluate=s,this.args=l}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,r){let s=t[0],l=Hi.definitions[s];if(!l)return r.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);let u=Array.isArray(l)?l[0]:l.type,p=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,f=p.filter((([x])=>!Array.isArray(x)||x.length===t.length-1)),g=null;for(let[x,v]of f){g=new nn(r.registry,vs,r.path,null,r.scope);let w=[],C=!1;for(let A=1;A<t.length;A++){let k=t[A],L=Array.isArray(x)?x[A-1]:x.type,O=g.parse(k,1+w.length,L);if(!O){C=!0;break}w.push(O)}if(!C)if(Array.isArray(x)&&x.length!==w.length)g.error(`Expected ${x.length} arguments, but found ${w.length} instead.`);else{for(let A=0;A<w.length;A++){let k=Array.isArray(x)?x[A]:x.type,L=w[A];g.concat(A+1).checkSubtype(k,L.type)}if(g.errors.length===0)return new Hi(s,u,v,w)}}if(f.length===1)r.errors.push(...g.errors);else{let x=(f.length?f:p).map((([w])=>{return C=w,Array.isArray(C)?`(${C.map(P).join(", ")})`:`(${P(C.type)}...)`;var C})).join(" | "),v=[];for(let w=1;w<t.length;w++){let C=r.parse(t[w],1+v.length);if(!C)return null;v.push(P(C.type))}r.error(`Expected arguments of type ${x}, but found (${v.join(", ")}) instead.`)}return null}static register(t,r){Hi.definitions=r;for(let s in r)t[s]=Hi}}function ia(i,[t,r,s,l]){t=t.evaluate(i),r=r.evaluate(i),s=s.evaluate(i);let u=l?l.evaluate(i):1,p=In(t,r,s,u);if(p)throw new Xt(p);return new bt(t/255,r/255,s/255,u,!1)}function ra(i,t){return i in t}function na(i,t){let r=t[i];return r===void 0?null:r}function un(i){return{type:i}}function vs(i){if(i instanceof yt)return vs(i.boundExpression);if(i instanceof Hi&&i.name==="error"||i instanceof gs||i instanceof an||i instanceof hn)return!1;let t=i instanceof lr||i instanceof ar,r=!0;return i.eachChild((s=>{r=t?r&&vs(s):r&&s instanceof or})),!!r&&bs(i)&&ws(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function bs(i){if(i instanceof Hi&&(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 an||i instanceof hn)return!1;let t=!0;return i.eachChild((r=>{t&&!bs(r)&&(t=!1)})),t}function kn(i){if(i instanceof Hi&&i.name==="feature-state")return!1;let t=!0;return i.eachChild((r=>{t&&!kn(r)&&(t=!1)})),t}function ws(i,t){if(i instanceof Hi&&t.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild((s=>{r&&!ws(s,t)&&(r=!1)})),r}function Qs(i){return{result:"success",value:i}}function zn(i){return{result:"error",value:i}}function Ln(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function ml(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function sa(i){return!!i.expression&&i.expression.interpolated}function mt(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function eo(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function Cc(i){return i}function gl(i,t){let r=t.type==="color",s=i.stops&&typeof i.stops[0][0]=="object",l=s||!(s||i.property!==void 0),u=i.type||(sa(t)?"exponential":"interval");if(r||t.type==="padding"){let v=r?bt.parse:Oi.parse;(i=vr({},i)).stops&&(i.stops=i.stops.map((w=>[w[0],v(w[1])]))),i.default=v(i.default?i.default:t.default)}if(i.colorSpace&&(p=i.colorSpace)!=="rgb"&&p!=="hcl"&&p!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var p;let f,g,x;if(u==="exponential")f=yl;else if(u==="interval")f=to;else if(u==="categorical"){f=_l,g=Object.create(null);for(let v of i.stops)g[v[0]]=v[1];x=typeof i.stops[0][0]}else{if(u!=="identity")throw new Error(`Unknown function type "${u}"`);f=xl}if(s){let v={},w=[];for(let k=0;k<i.stops.length;k++){let L=i.stops[k],O=L[0].zoom;v[O]===void 0&&(v[O]={zoom:O,type:i.type,property:i.property,default:i.default,stops:[]},w.push(O)),v[O].stops.push([L[0].value,L[1]])}let C=[];for(let k of w)C.push([v[k].zoom,gl(v[k],t)]);let A={name:"linear"};return{kind:"composite",interpolationType:A,interpolationFactor:Ai.interpolationFactor.bind(void 0,A),zoomStops:C.map((k=>k[0])),evaluate:({zoom:k},L)=>yl({stops:C,base:i.base},t,k).evaluate(k,L)}}if(l){let v=u==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:Ai.interpolationFactor.bind(void 0,v),zoomStops:i.stops.map((w=>w[0])),evaluate:({zoom:w})=>f(i,t,w,g,x)}}return{kind:"source",evaluate(v,w){let C=w&&w.properties?w.properties[i.property]:void 0;return C===void 0?Dn(i.default,t.default):f(i,t,C,g,x)}}}function Dn(i,t,r){return i!==void 0?i:t!==void 0?t:r!==void 0?r:void 0}function _l(i,t,r,s,l){return Dn(typeof r===l?s[r]:void 0,i.default,t.default)}function to(i,t,r){if(mt(r)!=="number")return Dn(i.default,t.default);let s=i.stops.length;if(s===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[s-1][0])return i.stops[s-1][1];let l=$s(i.stops.map((u=>u[0])),r);return i.stops[l][1]}function yl(i,t,r){let s=i.base!==void 0?i.base:1;if(mt(r)!=="number")return Dn(i.default,t.default);let 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];let u=$s(i.stops.map((v=>v[0])),r),p=(function(v,w,C,A){let k=A-C,L=v-C;return k===0?0:w===1?L/k:(Math.pow(w,L)-1)/(Math.pow(w,k)-1)})(r,s,i.stops[u][0],i.stops[u+1][0]),f=i.stops[u][1],g=i.stops[u+1][1],x=Mi[t.type]||Cc;return typeof f.evaluate=="function"?{evaluate(...v){let w=f.evaluate.apply(void 0,v),C=g.evaluate.apply(void 0,v);if(w!==void 0&&C!==void 0)return x(w,C,p,i.colorSpace)}}:x(f,g,p,i.colorSpace)}function xl(i,t,r){switch(t.type){case"color":r=bt.parse(r);break;case"formatted":r=Bi.fromString(r.toString());break;case"resolvedImage":r=Ni.fromString(r.toString());break;case"padding":r=Oi.parse(r);break;default:mt(r)===t.type||t.type==="enum"&&t.values[r]||(r=void 0)}return Dn(r,i.default,t.default)}Hi.register(En,{error:[{kind:"error"},[rt],(i,[t])=>{throw new Xt(t.evaluate(i))}],typeof:[rt,[Je],(i,[t])=>P(Yt(t.evaluate(i)))],"to-rgba":[M(we,4),[Pi],(i,[t])=>{let[r,s,l,u]=t.evaluate(i).rgb;return[255*r,255*s,255*l,u]}],rgb:[Pi,[we,we,we],ia],rgba:[Pi,[we,we,we,we],ia],has:{type:Ze,overloads:[[[rt],(i,[t])=>ra(t.evaluate(i),i.properties())],[[rt,sr],(i,[t,r])=>ra(t.evaluate(i),r.evaluate(i))]]},get:{type:Je,overloads:[[[rt],(i,[t])=>na(t.evaluate(i),i.properties())],[[rt,sr],(i,[t,r])=>na(t.evaluate(i),r.evaluate(i))]]},"feature-state":[Je,[rt],(i,[t])=>na(t.evaluate(i),i.featureState||{})],properties:[sr,[],i=>i.properties()],"geometry-type":[rt,[],i=>i.geometryType()],id:[Je,[],i=>i.id()],zoom:[we,[],i=>i.globals.zoom],"heatmap-density":[we,[],i=>i.globals.heatmapDensity||0],"line-progress":[we,[],i=>i.globals.lineProgress||0],accumulated:[Je,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[we,un(we),(i,t)=>{let r=0;for(let s of t)r+=s.evaluate(i);return r}],"*":[we,un(we),(i,t)=>{let r=1;for(let s of t)r*=s.evaluate(i);return r}],"-":{type:we,overloads:[[[we,we],(i,[t,r])=>t.evaluate(i)-r.evaluate(i)],[[we],(i,[t])=>-t.evaluate(i)]]},"/":[we,[we,we],(i,[t,r])=>t.evaluate(i)/r.evaluate(i)],"%":[we,[we,we],(i,[t,r])=>t.evaluate(i)%r.evaluate(i)],ln2:[we,[],()=>Math.LN2],pi:[we,[],()=>Math.PI],e:[we,[],()=>Math.E],"^":[we,[we,we],(i,[t,r])=>Math.pow(t.evaluate(i),r.evaluate(i))],sqrt:[we,[we],(i,[t])=>Math.sqrt(t.evaluate(i))],log10:[we,[we],(i,[t])=>Math.log(t.evaluate(i))/Math.LN10],ln:[we,[we],(i,[t])=>Math.log(t.evaluate(i))],log2:[we,[we],(i,[t])=>Math.log(t.evaluate(i))/Math.LN2],sin:[we,[we],(i,[t])=>Math.sin(t.evaluate(i))],cos:[we,[we],(i,[t])=>Math.cos(t.evaluate(i))],tan:[we,[we],(i,[t])=>Math.tan(t.evaluate(i))],asin:[we,[we],(i,[t])=>Math.asin(t.evaluate(i))],acos:[we,[we],(i,[t])=>Math.acos(t.evaluate(i))],atan:[we,[we],(i,[t])=>Math.atan(t.evaluate(i))],min:[we,un(we),(i,t)=>Math.min(...t.map((r=>r.evaluate(i))))],max:[we,un(we),(i,t)=>Math.max(...t.map((r=>r.evaluate(i))))],abs:[we,[we],(i,[t])=>Math.abs(t.evaluate(i))],round:[we,[we],(i,[t])=>{let r=t.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[we,[we],(i,[t])=>Math.floor(t.evaluate(i))],ceil:[we,[we],(i,[t])=>Math.ceil(t.evaluate(i))],"filter-==":[Ze,[rt,Je],(i,[t,r])=>i.properties()[t.value]===r.value],"filter-id-==":[Ze,[Je],(i,[t])=>i.id()===t.value],"filter-type-==":[Ze,[rt],(i,[t])=>i.geometryType()===t.value],"filter-<":[Ze,[rt,Je],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s<l}],"filter-id-<":[Ze,[Je],(i,[t])=>{let r=i.id(),s=t.value;return typeof r==typeof s&&r<s}],"filter->":[Ze,[rt,Je],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s>l}],"filter-id->":[Ze,[Je],(i,[t])=>{let r=i.id(),s=t.value;return typeof r==typeof s&&r>s}],"filter-<=":[Ze,[rt,Je],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s<=l}],"filter-id-<=":[Ze,[Je],(i,[t])=>{let r=i.id(),s=t.value;return typeof r==typeof s&&r<=s}],"filter->=":[Ze,[rt,Je],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s>=l}],"filter-id->=":[Ze,[Je],(i,[t])=>{let r=i.id(),s=t.value;return typeof r==typeof s&&r>=s}],"filter-has":[Ze,[Je],(i,[t])=>t.value in i.properties()],"filter-has-id":[Ze,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[Ze,[M(rt)],(i,[t])=>t.value.indexOf(i.geometryType())>=0],"filter-id-in":[Ze,[M(Je)],(i,[t])=>t.value.indexOf(i.id())>=0],"filter-in-small":[Ze,[rt,M(Je)],(i,[t,r])=>r.value.indexOf(i.properties()[t.value])>=0],"filter-in-large":[Ze,[rt,M(Je)],(i,[t,r])=>(function(s,l,u,p){for(;u<=p;){let f=u+p>>1;if(l[f]===s)return!0;l[f]>s?p=f-1:u=f+1}return!1})(i.properties()[t.value],r.value,0,r.value.length-1)],all:{type:Ze,overloads:[[[Ze,Ze],(i,[t,r])=>t.evaluate(i)&&r.evaluate(i)],[un(Ze),(i,t)=>{for(let r of t)if(!r.evaluate(i))return!1;return!0}]]},any:{type:Ze,overloads:[[[Ze,Ze],(i,[t,r])=>t.evaluate(i)||r.evaluate(i)],[un(Ze),(i,t)=>{for(let r of t)if(r.evaluate(i))return!0;return!1}]]},"!":[Ze,[Ze],(i,[t])=>!t.evaluate(i)],"is-supported-script":[Ze,[rt],(i,[t])=>{let r=i.globals&&i.globals.isSupportedScript;return!r||r(t.evaluate(i))}],upcase:[rt,[rt],(i,[t])=>t.evaluate(i).toUpperCase()],downcase:[rt,[rt],(i,[t])=>t.evaluate(i).toLowerCase()],concat:[rt,un(Je),(i,t)=>t.map((r=>ps(r.evaluate(i)))).join("")],"resolved-locale":[rt,[wr],(i,[t])=>t.evaluate(i).resolvedLocale()]});class io{constructor(t,r){var s;this.expression=t,this._warningHistory={},this._evaluator=new Us,this._defaultValue=r?(s=r).type==="color"&&eo(s.default)?new bt(0,0,0,0):s.type==="color"?bt.parse(s.default)||null:s.type==="padding"?Oi.parse(s.default)||null:s.type==="variableAnchorOffsetCollection"?Gi.parse(s.default)||null:s.default===void 0?null:s.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(t,r,s,l,u,p){return this._evaluator.globals=t,this._evaluator.feature=r,this._evaluator.featureState=s,this._evaluator.canonical=l,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(t,r,s,l,u,p){this._evaluator.globals=t,this._evaluator.feature=r||null,this._evaluator.featureState=s||null,this._evaluator.canonical=l,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=p||null;try{let 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 Xt(`Expected value to be one of ${Object.keys(this._enumValues).map((g=>JSON.stringify(g))).join(", ")}, but found ${JSON.stringify(f)} instead.`);return f}catch(f){return this._warningHistory[f.message]||(this._warningHistory[f.message]=!0,typeof console<"u"&&console.warn(f.message)),this._defaultValue}}}function ro(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in En}function Rn(i,t){let r=new nn(En,vs,[],t?(function(l){let u={color:Pi,string:rt,number:we,enum:rt,boolean:Ze,formatted:Lr,padding:qr,resolvedImage:Sr,variableAnchorOffsetCollection:U};return l.type==="array"?M(u[l.value]||Je,l.length):u[l.type]})(t):void 0),s=r.parse(i,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return s?Qs(new io(s,t)):zn(r.errors)}class Fn{constructor(t,r){this.kind=t,this._styleExpression=r,this.isStateDependent=t!=="constant"&&!kn(r.expression)}evaluateWithoutErrorHandling(t,r,s,l,u,p){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,u,p)}evaluate(t,r,s,l,u,p){return this._styleExpression.evaluate(t,r,s,l,u,p)}}class Bn{constructor(t,r,s,l){this.kind=t,this.zoomStops=s,this._styleExpression=r,this.isStateDependent=t!=="camera"&&!kn(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(t,r,s,l,u,p){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,u,p)}evaluate(t,r,s,l,u,p){return this._styleExpression.evaluate(t,r,s,l,u,p)}interpolationFactor(t,r,s){return this.interpolationType?Ai.interpolationFactor(this.interpolationType,t,r,s):0}}function oa(i,t){let r=Rn(i,t);if(r.result==="error")return r;let s=r.value.expression,l=bs(s);if(!l&&!Ln(t))return zn([new bi("","data expressions not supported")]);let u=ws(s,["zoom"]);if(!u&&!ml(t))return zn([new bi("","zoom expressions not supported")]);let p=Ss(s);return p||u?p instanceof bi?zn([p]):p instanceof Ai&&!sa(t)?zn([new bi("",'"interpolate" expressions cannot be used with this property')]):Qs(p?new Bn(l?"camera":"composite",r.value,p.labels,p instanceof Ai?p.interpolation:void 0):new Fn(l?"constant":"source",r.value)):zn([new bi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class On{constructor(t,r){this._parameters=t,this._specification=r,vr(this,gl(this._parameters,this._specification))}static deserialize(t){return new On(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Ss(i){let t=null;if(i instanceof Zr)t=Ss(i.result);else if(i instanceof Zs){for(let r of i.args)if(t=Ss(r),t)break}else(i instanceof Pn||i instanceof Ai)&&i.input instanceof Hi&&i.input.name==="zoom"&&(t=i);return t instanceof bi||i.eachChild((r=>{let s=Ss(r);s instanceof bi?t=s:!t&&s?t=new bi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&s&&t!==s&&(t=new bi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}function no(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(let t of i.slice(1))if(!no(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}let so={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function aa(i){if(i==null)return{filter:()=>!0,needGeometry:!1};no(i)||(i=oo(i));let t=Rn(i,so);if(t.result==="error")throw new Error(t.value.map((r=>`${r.key}: ${r.message}`)).join(", "));return{filter:(r,s,l)=>t.value.evaluate(r,s,{},l),needGeometry:vl(i)}}function Pc(i,t){return i<t?-1:i>t?1:0}function vl(i){if(!Array.isArray(i))return!1;if(i[0]==="within"||i[0]==="distance")return!0;for(let t=1;t<i.length;t++)if(vl(i[t]))return!0;return!1}function oo(i){if(!i)return!0;let t=i[0];return i.length<=1?t!=="any":t==="=="?la(i[1],i[2],"=="):t==="!="?di(la(i[1],i[2],"==")):t==="<"||t===">"||t==="<="||t===">="?la(i[1],i[2],t):t==="any"?(r=i.slice(1),["any"].concat(r.map(oo))):t==="all"?["all"].concat(i.slice(1).map(oo)):t==="none"?["all"].concat(i.slice(1).map(oo).map(di)):t==="in"?Ts(i[1],i.slice(2)):t==="!in"?di(Ts(i[1],i.slice(2))):t==="has"?Is(i[1]):t!=="!has"||di(Is(i[1]));var r}function la(i,t,r){switch(i){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,i,t]}}function Ts(i,t){if(t.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((r=>typeof r!=typeof t[0]))?["filter-in-large",i,["literal",t.sort(Pc)]]:["filter-in-small",i,["literal",t]]}}function Is(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function di(i){return["!",i]}function dn(i){let t=typeof i;if(t==="number"||t==="boolean"||t==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let l="[";for(let u of i)l+=`${dn(u)},`;return`${l}]`}let r=Object.keys(i).sort(),s="{";for(let l=0;l<r.length;l++)s+=`${JSON.stringify(r[l])}:${dn(i[r[l]])},`;return`${s}}`}function bl(i){let t="";for(let r of tn)t+=`/${dn(i[r])}`;return t}function wl(i){let t=i.value;return t?[new ye(i.key,t,"constants have been deprecated as of v8")]:[]}function Zt(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function cr(i){if(Array.isArray(i))return i.map(cr);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){let t={};for(let r in i)t[r]=cr(i[r]);return t}return Zt(i)}function Vi(i){let t=i.key,r=i.value,s=i.valueSpec||{},l=i.objectElementValidators||{},u=i.style,p=i.styleSpec,f=i.validateSpec,g=[],x=mt(r);if(x!=="object")return[new ye(t,r,`object expected, ${x} found`)];for(let v in r){let w=v.split(".")[0],C=s[w]||s["*"],A;if(l[w])A=l[w];else if(s[w])A=f;else if(l["*"])A=l["*"];else{if(!s["*"]){g.push(new ye(t,r[v],`unknown property "${v}"`));continue}A=f}g=g.concat(A({key:(t&&`${t}.`)+v,value:r[v],valueSpec:C,style:u,styleSpec:p,object:r,objectKey:v,validateSpec:f},r))}for(let v in s)l[v]||s[v].required&&s[v].default===void 0&&r[v]===void 0&&g.push(new ye(t,r,`missing required property "${v}"`));return g}function Cs(i){let t=i.value,r=i.valueSpec,s=i.style,l=i.styleSpec,u=i.key,p=i.arrayElementValidator||i.validateSpec;if(mt(t)!=="array")return[new ye(u,t,`array expected, ${mt(t)} found`)];if(r.length&&t.length!==r.length)return[new ye(u,t,`array length ${r.length} expected, length ${t.length} found`)];if(r["min-length"]&&t.length<r["min-length"])return[new ye(u,t,`array length at least ${r["min-length"]} expected, length ${t.length} found`)];let f={type:r.value,values:r.values};l.$version<7&&(f.function=r.function),mt(r.value)==="object"&&(f=r.value);let g=[];for(let x=0;x<t.length;x++)g=g.concat(p({array:t,arrayIndex:x,value:t[x],valueSpec:f,validateSpec:i.validateSpec,style:s,styleSpec:l,key:`${u}[${x}]`}));return g}function ca(i){let t=i.key,r=i.value,s=i.valueSpec,l=mt(r);return l==="number"&&r!=r&&(l="NaN"),l!=="number"?[new ye(t,r,`number expected, ${l} found`)]:"minimum"in s&&r<s.minimum?[new ye(t,r,`${r} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&r>s.maximum?[new ye(t,r,`${r} is greater than the maximum value ${s.maximum}`)]:[]}function ao(i){let t=i.valueSpec,r=Zt(i.value.type),s,l,u,p={},f=r!=="categorical"&&i.value.property===void 0,g=!f,x=mt(i.value.stops)==="array"&&mt(i.value.stops[0])==="array"&&mt(i.value.stops[0][0])==="object",v=Vi({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(A){if(r==="identity")return[new ye(A.key,A.value,'identity function may not have a "stops" property')];let k=[],L=A.value;return k=k.concat(Cs({key:A.key,value:L,valueSpec:A.valueSpec,validateSpec:A.validateSpec,style:A.style,styleSpec:A.styleSpec,arrayElementValidator:w})),mt(L)==="array"&&L.length===0&&k.push(new ye(A.key,L,"array must have at least one stop")),k},default:function(A){return A.validateSpec({key:A.key,value:A.value,valueSpec:t,validateSpec:A.validateSpec,style:A.style,styleSpec:A.styleSpec})}}});return r==="identity"&&f&&v.push(new ye(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||v.push(new ye(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!sa(i.valueSpec)&&v.push(new ye(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(g&&!Ln(i.valueSpec)?v.push(new ye(i.key,i.value,"property functions not supported")):f&&!ml(i.valueSpec)&&v.push(new ye(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!x||i.value.property!==void 0||v.push(new ye(i.key,i.value,'"property" property is required')),v;function w(A){let k=[],L=A.value,O=A.key;if(mt(L)!=="array")return[new ye(O,L,`array expected, ${mt(L)} found`)];if(L.length!==2)return[new ye(O,L,`array length 2 expected, length ${L.length} found`)];if(x){if(mt(L[0])!=="object")return[new ye(O,L,`object expected, ${mt(L[0])} found`)];if(L[0].zoom===void 0)return[new ye(O,L,"object stop key must have zoom")];if(L[0].value===void 0)return[new ye(O,L,"object stop key must have value")];if(u&&u>Zt(L[0].zoom))return[new ye(O,L[0].zoom,"stop zoom values must appear in ascending order")];Zt(L[0].zoom)!==u&&(u=Zt(L[0].zoom),l=void 0,p={}),k=k.concat(Vi({key:`${O}[0]`,value:L[0],valueSpec:{zoom:{}},validateSpec:A.validateSpec,style:A.style,styleSpec:A.styleSpec,objectElementValidators:{zoom:ca,value:C}}))}else k=k.concat(C({key:`${O}[0]`,value:L[0],valueSpec:{},validateSpec:A.validateSpec,style:A.style,styleSpec:A.styleSpec},L));return ro(cr(L[1]))?k.concat([new ye(`${O}[1]`,L[1],"expressions are not allowed in function stops.")]):k.concat(A.validateSpec({key:`${O}[1]`,value:L[1],valueSpec:t,validateSpec:A.validateSpec,style:A.style,styleSpec:A.styleSpec}))}function C(A,k){let L=mt(A.value),O=Zt(A.value),j=A.value!==null?A.value:k;if(s){if(L!==s)return[new ye(A.key,j,`${L} stop domain type must match previous stop domain type ${s}`)]}else s=L;if(L!=="number"&&L!=="string"&&L!=="boolean")return[new ye(A.key,j,"stop domain value must be a number, string, or boolean")];if(L!=="number"&&r!=="categorical"){let re=`number expected, ${L} found`;return Ln(t)&&r===void 0&&(re+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ye(A.key,j,re)]}return r!=="categorical"||L!=="number"||isFinite(O)&&Math.floor(O)===O?r!=="categorical"&&L==="number"&&l!==void 0&&O<l?[new ye(A.key,j,"stop domain values must appear in ascending order")]:(l=O,r==="categorical"&&O in p?[new ye(A.key,j,"stop domain values must be unique")]:(p[O]=!0,[])):[new ye(A.key,j,`integer expected, found ${O}`)]}}function Nn(i){let t=(i.expressionContext==="property"?oa:Rn)(cr(i.value),i.valueSpec);if(t.result==="error")return t.value.map((s=>new ye(`${i.key}${s.key}`,i.value,s.message)));let r=t.value.expression||t.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new ye(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"&&!kn(r))return[new ye(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!kn(r))return[new ye(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!ws(r,["zoom","feature-state"]))return[new ye(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!bs(r))return[new ye(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Rr(i){let t=i.key,r=i.value,s=i.valueSpec,l=[];return Array.isArray(s.values)?s.values.indexOf(Zt(r))===-1&&l.push(new ye(t,r,`expected one of [${s.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(s.values).indexOf(Zt(r))===-1&&l.push(new ye(t,r,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function ha(i){return no(cr(i.value))?Nn(vr({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):lo(i)}function lo(i){let t=i.value,r=i.key;if(mt(t)!=="array")return[new ye(r,t,`array expected, ${mt(t)} found`)];let s=i.styleSpec,l,u=[];if(t.length<1)return[new ye(r,t,"filter array must have at least 1 element")];switch(u=u.concat(Rr({key:`${r}[0]`,value:t[0],valueSpec:s.filter_operator,style:i.style,styleSpec:i.styleSpec})),Zt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&Zt(t[1])==="$type"&&u.push(new ye(r,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&u.push(new ye(r,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(l=mt(t[1]),l!=="string"&&u.push(new ye(`${r}[1]`,t[1],`string expected, ${l} found`)));for(let p=2;p<t.length;p++)l=mt(t[p]),Zt(t[1])==="$type"?u=u.concat(Rr({key:`${r}[${p}]`,value:t[p],valueSpec:s.geometry_type,style:i.style,styleSpec:i.styleSpec})):l!=="string"&&l!=="number"&&l!=="boolean"&&u.push(new ye(`${r}[${p}]`,t[p],`string, number, or boolean expected, ${l} found`));break;case"any":case"all":case"none":for(let p=1;p<t.length;p++)u=u.concat(lo({key:`${r}[${p}]`,value:t[p],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":l=mt(t[1]),t.length!==2?u.push(new ye(r,t,`filter array for "${t[0]}" operator must have 2 elements`)):l!=="string"&&u.push(new ye(`${r}[1]`,t[1],`string expected, ${l} found`))}return u}function ua(i,t){let r=i.key,s=i.validateSpec,l=i.style,u=i.styleSpec,p=i.value,f=i.objectKey,g=u[`${t}_${i.layerType}`];if(!g)return[];let x=f.match(/^(.*)-transition$/);if(t==="paint"&&x&&g[x[1]]&&g[x[1]].transition)return s({key:r,value:p,valueSpec:u.transition,style:l,styleSpec:u});let v=i.valueSpec||g[f];if(!v)return[new ye(r,p,`unknown property "${f}"`)];let w;if(mt(p)==="string"&&Ln(v)&&!v.tokens&&(w=/^{([^}]+)}$/.exec(p)))return[new ye(r,p,`"${f}" does not support interpolation syntax
2
+ Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(w[1])} }\`.`)];let C=[];return i.layerType==="symbol"&&(f==="text-field"&&l&&!l.glyphs&&C.push(new ye(r,p,'use of "text-field" requires a style "glyphs" property')),f==="text-font"&&eo(cr(p))&&Zt(p.type)==="identity"&&C.push(new ye(r,p,'"text-font" does not support identity functions'))),C.concat(s({key:i.key,value:p,valueSpec:v,style:l,styleSpec:u,expressionContext:"property",propertyType:t,propertyKey:f}))}function co(i){return ua(i,"paint")}function da(i){return ua(i,"layout")}function pa(i){let t=[],r=i.value,s=i.key,l=i.style,u=i.styleSpec;r.type||r.ref||t.push(new ye(s,r,'either "type" or "ref" is required'));let p=Zt(r.type),f=Zt(r.ref);if(r.id){let g=Zt(r.id);for(let x=0;x<i.arrayIndex;x++){let v=l.layers[x];Zt(v.id)===g&&t.push(new ye(s,r.id,`duplicate layer id "${r.id}", previously used at line ${v.id.__line__}`))}}if("ref"in r){let g;["type","source","source-layer","filter","layout"].forEach((x=>{x in r&&t.push(new ye(s,r[x],`"${x}" is prohibited for ref layers`))})),l.layers.forEach((x=>{Zt(x.id)===f&&(g=x)})),g?g.ref?t.push(new ye(s,r.ref,"ref cannot reference another ref layer")):p=Zt(g.type):t.push(new ye(s,r.ref,`ref layer "${f}" not found`))}else if(p!=="background")if(r.source){let g=l.sources&&l.sources[r.source],x=g&&Zt(g.type);g?x==="vector"&&p==="raster"?t.push(new ye(s,r.source,`layer "${r.id}" requires a raster source`)):x!=="raster-dem"&&p==="hillshade"?t.push(new ye(s,r.source,`layer "${r.id}" requires a raster-dem source`)):x==="raster"&&p!=="raster"?t.push(new ye(s,r.source,`layer "${r.id}" requires a vector source`)):x!=="vector"||r["source-layer"]?x==="raster-dem"&&p!=="hillshade"?t.push(new ye(s,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):p!=="line"||!r.paint||!r.paint["line-gradient"]||x==="geojson"&&g.lineMetrics||t.push(new ye(s,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new ye(s,r,`layer "${r.id}" must specify a "source-layer"`)):t.push(new ye(s,r.source,`source "${r.source}" not found`))}else t.push(new ye(s,r,'missing required property "source"'));return t=t.concat(Vi({key:s,value:r,valueSpec:u.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${s}.type`,value:r.type,valueSpec:u.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:ha,layout:g=>Vi({layer:r,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>da(vr({layerType:p},x))}}),paint:g=>Vi({layer:r,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>co(vr({layerType:p},x))}})}})),t}function pn(i){let t=i.value,r=i.key,s=mt(t);return s!=="string"?[new ye(r,t,`string expected, ${s} found`)]:[]}let ho={promoteId:function({key:i,value:t}){if(mt(t)==="string")return pn({key:i,value:t});{let r=[];for(let s in t)r.push(...pn({key:`${i}.${s}`,value:t[s]}));return r}}};function Ps(i){let t=i.value,r=i.key,s=i.styleSpec,l=i.style,u=i.validateSpec;if(!t.type)return[new ye(r,t,'"type" is required')];let p=Zt(t.type),f;switch(p){case"vector":case"raster":return f=Vi({key:r,value:t,valueSpec:s[`source_${p.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:ho,validateSpec:u}),f;case"raster-dem":return f=(function(g){var x;let v=(x=g.sourceName)!==null&&x!==void 0?x:"",w=g.value,C=g.styleSpec,A=C.source_raster_dem,k=g.style,L=[],O=mt(w);if(w===void 0)return L;if(O!=="object")return L.push(new ye("source_raster_dem",w,`object expected, ${O} found`)),L;let j=Zt(w.encoding)==="custom",re=["redFactor","greenFactor","blueFactor","baseShift"],W=g.value.encoding?`"${g.value.encoding}"`:"Default";for(let te in w)!j&&re.includes(te)?L.push(new ye(te,w[te],`In "${v}": "${te}" is only valid when "encoding" is set to "custom". ${W} encoding found`)):A[te]?L=L.concat(g.validateSpec({key:te,value:w[te],valueSpec:A[te],validateSpec:g.validateSpec,style:k,styleSpec:C})):L.push(new ye(te,w[te],`unknown property "${te}"`));return L})({sourceName:r,value:t,style:i.style,styleSpec:s,validateSpec:u}),f;case"geojson":if(f=Vi({key:r,value:t,valueSpec:s.source_geojson,style:l,styleSpec:s,validateSpec:u,objectElementValidators:ho}),t.cluster)for(let g in t.clusterProperties){let[x,v]=t.clusterProperties[g],w=typeof x=="string"?[x,["accumulated"],["get",g]]:x;f.push(...Nn({key:`${r}.${g}.map`,value:v,validateSpec:u,expressionContext:"cluster-map"})),f.push(...Nn({key:`${r}.${g}.reduce`,value:w,validateSpec:u,expressionContext:"cluster-reduce"}))}return f;case"video":return Vi({key:r,value:t,valueSpec:s.source_video,style:l,validateSpec:u,styleSpec:s});case"image":return Vi({key:r,value:t,valueSpec:s.source_image,style:l,validateSpec:u,styleSpec:s});case"canvas":return[new ye(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Rr({key:`${r}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:l,validateSpec:u,styleSpec:s})}}function fa(i){let t=i.value,r=i.styleSpec,s=r.light,l=i.style,u=[],p=mt(t);if(t===void 0)return u;if(p!=="object")return u=u.concat([new ye("light",t,`object expected, ${p} found`)]),u;for(let f in t){let g=f.match(/^(.*)-transition$/);u=u.concat(g&&s[g[1]]&&s[g[1]].transition?i.validateSpec({key:f,value:t[f],valueSpec:r.transition,validateSpec:i.validateSpec,style:l,styleSpec:r}):s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new ye(f,t[f],`unknown property "${f}"`)])}return u}function ma(i){let t=i.value,r=i.styleSpec,s=r.sky,l=i.style,u=mt(t);if(t===void 0)return[];if(u!=="object")return[new ye("sky",t,`object expected, ${u} found`)];let p=[];for(let f in t)p=p.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],style:l,styleSpec:r}):[new ye(f,t[f],`unknown property "${f}"`)]);return p}function ga(i){let t=i.value,r=i.styleSpec,s=r.terrain,l=i.style,u=[],p=mt(t);if(t===void 0)return u;if(p!=="object")return u=u.concat([new ye("terrain",t,`object expected, ${p} found`)]),u;for(let f in t)u=u.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new ye(f,t[f],`unknown property "${f}"`)]);return u}function _a(i){let t=[],r=i.value,s=i.key;if(Array.isArray(r)){let l=[],u=[];for(let p in r)r[p].id&&l.includes(r[p].id)&&t.push(new ye(s,r,`all the sprites' ids must be unique, but ${r[p].id} is duplicated`)),l.push(r[p].id),r[p].url&&u.includes(r[p].url)&&t.push(new ye(s,r,`all the sprites' URLs must be unique, but ${r[p].url} is duplicated`)),u.push(r[p].url),t=t.concat(Vi({key:`${s}[${p}]`,value:r[p],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return t}return pn({key:s,value:r})}let uo={"*":()=>[],array:Cs,boolean:function(i){let t=i.value,r=i.key,s=mt(t);return s!=="boolean"?[new ye(r,t,`boolean expected, ${s} found`)]:[]},number:ca,color:function(i){let t=i.key,r=i.value,s=mt(r);return s!=="string"?[new ye(t,r,`color expected, ${s} found`)]:bt.parse(String(r))?[]:[new ye(t,r,`color expected, "${r}" found`)]},constants:wl,enum:Rr,filter:ha,function:ao,layer:pa,object:Vi,source:Ps,light:fa,sky:ma,terrain:ga,projection:function(i){let t=i.value,r=i.styleSpec,s=r.projection,l=i.style,u=mt(t);if(t===void 0)return[];if(u!=="object")return[new ye("projection",t,`object expected, ${u} found`)];let p=[];for(let f in t)p=p.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],style:l,styleSpec:r}):[new ye(f,t[f],`unknown property "${f}"`)]);return p},string:pn,formatted:function(i){return pn(i).length===0?[]:Nn(i)},resolvedImage:function(i){return pn(i).length===0?[]:Nn(i)},padding:function(i){let t=i.key,r=i.value;if(mt(r)==="array"){if(r.length<1||r.length>4)return[new ye(t,r,`padding requires 1 to 4 values; ${r.length} values found`)];let s={type:"number"},l=[];for(let u=0;u<r.length;u++)l=l.concat(i.validateSpec({key:`${t}[${u}]`,value:r[u],validateSpec:i.validateSpec,valueSpec:s}));return l}return ca({key:t,value:r,valueSpec:{}})},variableAnchorOffsetCollection:function(i){let t=i.key,r=i.value,s=mt(r),l=i.styleSpec;if(s!=="array"||r.length<1||r.length%2!=0)return[new ye(t,r,"variableAnchorOffsetCollection requires a non-empty array of even length")];let u=[];for(let p=0;p<r.length;p+=2)u=u.concat(Rr({key:`${t}[${p}]`,value:r[p],valueSpec:l.layout_symbol["text-anchor"]})),u=u.concat(Cs({key:`${t}[${p+1}]`,value:r[p+1],valueSpec:{length:2,value:"number"},validateSpec:i.validateSpec,style:i.style,styleSpec:l}));return u},sprite:_a};function Vn(i){let t=i.value,r=i.valueSpec,s=i.styleSpec;return i.validateSpec=Vn,r.expression&&eo(Zt(t))?ao(i):r.expression&&ro(cr(t))?Nn(i):r.type&&uo[r.type]?uo[r.type](i):Vi(vr({},i,{valueSpec:r.type?s[r.type]:r}))}function Sl(i){let t=i.value,r=i.key,s=pn(i);return s.length||(t.indexOf("{fontstack}")===-1&&s.push(new ye(r,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&s.push(new ye(r,t,'"glyphs" url must include a "{range}" token'))),s}function Wi(i,t=ae){let r=[];return r=r.concat(Vn({key:"",value:i,valueSpec:t.$root,styleSpec:t,style:i,validateSpec:Vn,objectElementValidators:{glyphs:Sl,"*":()=>[]}})),i.constants&&(r=r.concat(wl({key:"constants",value:i.constants,style:i,styleSpec:t,validateSpec:Vn}))),ya(r)}function Ir(i){return function(t){return i({...t,validateSpec:Vn})}}function ya(i){return[].concat(i).sort(((t,r)=>t.line-r.line))}function hr(i){return function(...t){return ya(i.apply(this,t))}}Wi.source=hr(Ir(Ps)),Wi.sprite=hr(Ir(_a)),Wi.glyphs=hr(Ir(Sl)),Wi.light=hr(Ir(fa)),Wi.sky=hr(Ir(ma)),Wi.terrain=hr(Ir(ga)),Wi.layer=hr(Ir(pa)),Wi.filter=hr(Ir(ha)),Wi.paintProperty=hr(Ir(co)),Wi.layoutProperty=hr(Ir(da));let fn=Wi,Mc=fn.light,Ac=fn.sky,Tl=fn.paintProperty,Il=fn.layoutProperty;function xa(i,t){let r=!1;if(t&&t.length)for(let s of t)i.fire(new Ur(new Error(s.message))),r=!0;return r}class Un{constructor(t,r,s){let l=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;let p=new Int32Array(this.arrayBuffer);t=p[0],this.d=(r=p[1])+2*(s=p[2]);for(let g=0;g<this.d*this.d;g++){let x=p[3+g],v=p[3+g+1];l.push(x===v?null:p.subarray(x,v))}let f=p[3+l.length+1];this.keys=p.subarray(p[3+l.length],f),this.bboxes=p.subarray(f),this.insert=this._insertReadonly}else{this.d=r+2*s;for(let p=0;p<this.d*this.d;p++)l.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=t,this.padding=s,this.scale=r/t,this.uid=0;let u=s/r*t;this.min=-u,this.max=t+u}insert(t,r,s,l,u){this._forEachCell(r,s,l,u,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(r),this.bboxes.push(s),this.bboxes.push(l),this.bboxes.push(u)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,r,s,l,u,p){this.cells[u].push(p)}query(t,r,s,l,u){let p=this.min,f=this.max;if(t<=p&&r<=p&&f<=s&&f<=l&&!u)return Array.prototype.slice.call(this.keys);{let g=[];return this._forEachCell(t,r,s,l,this._queryCell,g,{},u),g}}_queryCell(t,r,s,l,u,p,f,g){let x=this.cells[u];if(x!==null){let v=this.keys,w=this.bboxes;for(let C=0;C<x.length;C++){let A=x[C];if(f[A]===void 0){let k=4*A;(g?g(w[k+0],w[k+1],w[k+2],w[k+3]):t<=w[k+2]&&r<=w[k+3]&&s>=w[k+0]&&l>=w[k+1])?(f[A]=!0,p.push(v[A])):f[A]=!1}}}}_forEachCell(t,r,s,l,u,p,f,g){let x=this._convertToCellCoord(t),v=this._convertToCellCoord(r),w=this._convertToCellCoord(s),C=this._convertToCellCoord(l);for(let A=x;A<=w;A++)for(let k=v;k<=C;k++){let L=this.d*k+A;if((!g||g(this._convertFromCellCoord(A),this._convertFromCellCoord(k),this._convertFromCellCoord(A+1),this._convertFromCellCoord(k+1)))&&u.call(this,t,r,s,l,L,p,f,g))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let t=this.cells,r=3+this.cells.length+1+1,s=0;for(let p=0;p<this.cells.length;p++)s+=this.cells[p].length;let l=new Int32Array(r+s+this.keys.length+this.bboxes.length);l[0]=this.extent,l[1]=this.n,l[2]=this.padding;let u=r;for(let p=0;p<t.length;p++){let f=t[p];l[3+p]=u,l.set(f,u),u+=f.length}return l[3+t.length]=u,l.set(this.keys,u),u+=this.keys.length,l[3+t.length+1]=u,l.set(this.bboxes,u),u+=this.bboxes.length,l.buffer}static serialize(t,r){let s=t.toArrayBuffer();return r&&r.push(s),{buffer:s}}static deserialize(t){return new Un(t.buffer)}}let Xi={};function ke(i,t,r={}){if(Xi[i])throw new Error(`${i} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:i,writeable:!1}),Xi[i]={klass:t,omit:r.omit||[],shallow:r.shallow||[]}}ke("Object",Object),ke("TransferableGridIndex",Un),ke("Color",bt),ke("Error",Error),ke("AJAXError",Fi),ke("ResolvedImage",Ni),ke("StylePropertyFunction",On),ke("StyleExpression",io,{omit:["_evaluator"]}),ke("ZoomDependentExpression",Bn),ke("ZoomConstantExpression",Fn),ke("CompoundExpression",Hi,{omit:["_evaluate"]});for(let i in En)En[i]._classRegistryKey||ke(`Expression_${i}`,En[i]);function po(i){return i&&typeof ArrayBuffer<"u"&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}function va(i){return i.$name||i.constructor._classRegistryKey}function Cl(i){return!(function(t){if(t===null||typeof t!="object")return!1;let r=va(t);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||po(i)||Ht(i)||ArrayBuffer.isView(i)||i instanceof ImageData)}function jn(i,t){if(Cl(i))return(po(i)||Ht(i))&&t&&t.push(i),ArrayBuffer.isView(i)&&t&&t.push(i.buffer),i instanceof ImageData&&t&&t.push(i.data.buffer),i;if(Array.isArray(i)){let u=[];for(let p of i)u.push(jn(p,t));return u}if(typeof i!="object")throw new Error("can't serialize object of type "+typeof i);let r=va(i);if(!r)throw new Error(`can't serialize object of unregistered class ${i.constructor.name}`);if(!Xi[r])throw new Error(`${r} is not registered.`);let{klass:s}=Xi[r],l=s.serialize?s.serialize(i,t):{};if(s.serialize){if(t&&l===t[t.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(let u in i){if(!i.hasOwnProperty(u)||Xi[r].omit.indexOf(u)>=0)continue;let p=i[u];l[u]=Xi[r].shallow.indexOf(u)>=0?p:jn(p,t)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(l.$name=r),l}function $n(i){if(Cl(i))return i;if(Array.isArray(i))return i.map($n);if(typeof i!="object")throw new Error("can't deserialize object of type "+typeof i);let t=va(i)||"Object";if(!Xi[t])throw new Error(`can't deserialize unregistered class ${t}`);let{klass:r}=Xi[t];if(!r)throw new Error(`can't deserialize unregistered class ${t}`);if(r.deserialize)return r.deserialize(i);let s=Object.create(r.prototype);for(let l of Object.keys(i)){if(l==="$name")continue;let u=i[l];s[l]=Xi[t].shallow.indexOf(l)>=0?u:$n(u)}return s}class ba{constructor(){this.first=!0}update(t,r){let s=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<s&&(this.lastIntegerZoom=s,this.lastIntegerZoomTime=r),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=s,!0))}}let 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 wa(i){for(let t of i)if(Ta(t.charCodeAt(0)))return!0;return!1}function Ec(i){for(let t of i)if(!qn(t.charCodeAt(0)))return!1;return!0}function Sa(i){let t=i.map((r=>{try{return new RegExp(`\\p{sc=${r}}`,"u").source}catch{return null}})).filter((r=>r));return new RegExp(t.join("|"),"u")}let kc=Sa(["Arab","Dupl","Mong","Ougr","Syrc"]);function qn(i){return!kc.test(String.fromCodePoint(i))}let Pl=Sa(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function Ta(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)||/\p{sc=Cans}/u.test(String.fromCodePoint(i))||/\p{sc=Hang}/u.test(String.fromCodePoint(i))||Pl.test(String.fromCodePoint(i)))))}function Ml(i){return!(Ta(i)||(function(t){return!!(ht["Latin-1 Supplement"](t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||ht["General Punctuation"](t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||ht["Letterlike Symbols"](t)||ht["Number Forms"](t)||ht["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||ht["Control Pictures"](t)&&t!==9251||ht["Optical Character Recognition"](t)||ht["Enclosed Alphanumerics"](t)||ht["Geometric Shapes"](t)||ht["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||ht["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||ht["CJK Symbols and Punctuation"](t)||ht.Katakana(t)||ht["Private Use Area"](t)||ht["CJK Compatibility Forms"](t)||ht["Small Form Variants"](t)||ht["Halfwidth and Fullwidth Forms"](t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)})(i))}let zc=Sa(["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 Ia(i){return zc.test(String.fromCodePoint(i))}function Lc(i,t){return!(!t&&Ia(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||ht.Khmer(i))}function Dc(i){for(let t of i)if(Ia(t.charCodeAt(0)))return!0;return!1}let Ui=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 zt{constructor(t,r){this.zoom=t,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ba,this.transition={})}isSupportedScript(t){return(function(r,s){for(let l of r)if(!Lc(l.charCodeAt(0),s))return!1;return!0})(t,Ui.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let t=this.zoom,r=t-Math.floor(t),s=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*r}}}class Zn{constructor(t,r){this.property=t,this.value=r,this.expression=(function(s,l){if(eo(s))return new On(s,l);if(ro(s)){let u=oa(s,l);if(u.result==="error")throw new Error(u.value.map((p=>`${p.key}: ${p.message}`)).join(", "));return u.value}{let u=s;return l.type==="color"&&typeof s=="string"?u=bt.parse(s):l.type!=="padding"||typeof s!="number"&&!Array.isArray(s)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(s)&&(u=Gi.parse(s)):u=Oi.parse(s),{kind:"constant",evaluate:()=>u}}})(r===void 0?t.specification.default:r,t.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(t,r,s){return this.property.possiblyEvaluate(this,t,r,s)}}class fo{constructor(t){this.property=t,this.value=new Zn(t,void 0)}transitioned(t,r){return new Al(this.property,this.value,r,Mt({},t.transition,this.transition),t.now)}untransitioned(){return new Al(this.property,this.value,null,{},0)}}class mo{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return et(this._values[t].value.value)}setValue(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new fo(this._values[t].property)),this._values[t].value=new Zn(this._values[t].property,r===null?void 0:et(r))}getTransition(t){return et(this._values[t].transition)}setTransition(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new fo(this._values[t].property)),this._values[t].transition=et(r)||void 0}serialize(){let t={};for(let r of Object.keys(this._values)){let s=this.getValue(r);s!==void 0&&(t[r]=s);let l=this.getTransition(r);l!==void 0&&(t[`${r}-transition`]=l)}return t}transitioned(t,r){let s=new Ms(this._properties);for(let l of Object.keys(this._values))s._values[l]=this._values[l].transitioned(t,r._values[l]);return s}untransitioned(){let t=new Ms(this._properties);for(let r of Object.keys(this._values))t._values[r]=this._values[r].untransitioned();return t}}class Al{constructor(t,r,s,l,u){this.property=t,this.value=r,this.begin=u+l.delay||0,this.end=this.begin+l.duration||0,t.specification.transition&&(l.delay||l.duration)&&(this.prior=s)}possiblyEvaluate(t,r,s){let l=t.now||0,u=this.value.possiblyEvaluate(t,r,s),p=this.prior;if(p){if(l>this.end)return this.prior=null,u;if(this.value.isDataDriven())return this.prior=null,u;if(l<this.begin)return p.possiblyEvaluate(t,r,s);{let f=(l-this.begin)/(this.end-this.begin);return this.property.interpolate(p.possiblyEvaluate(t,r,s),u,(function(g){if(g<=0)return 0;if(g>=1)return 1;let x=g*g,v=x*g;return 4*(g<.5?v:3*(g-x)+v-.75)})(f))}}return u}}class Ms{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,r,s){let l=new Es(this._properties);for(let u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(t,r,s);return l}hasTransition(){for(let t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class As{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return this._values[t].value!==void 0}getValue(t){return et(this._values[t].value)}setValue(t,r){this._values[t]=new Zn(this._values[t].property,r===null?void 0:et(r))}serialize(){let t={};for(let r of Object.keys(this._values)){let s=this.getValue(r);s!==void 0&&(t[r]=s)}return t}possiblyEvaluate(t,r,s){let l=new Es(this._properties);for(let u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(t,r,s);return l}}class Cr{constructor(t,r,s){this.property=t,this.value=r,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,r,s,l){return this.property.evaluate(this.value,this.parameters,t,r,s,l)}}class Es{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class De{constructor(t){this.specification=t}possiblyEvaluate(t,r){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(r)}interpolate(t,r,s){let l=Mi[this.specification.type];return l?l(t,r,s):t}}class qe{constructor(t,r){this.specification=t,this.overrides=r}possiblyEvaluate(t,r,s,l){return new Cr(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(r,null,{},s,l)}:t.expression,r)}interpolate(t,r,s){if(t.value.kind!=="constant"||r.value.kind!=="constant")return t;if(t.value.value===void 0||r.value.value===void 0)return new Cr(this,{kind:"constant",value:void 0},t.parameters);let l=Mi[this.specification.type];if(l){let u=l(t.value.value,r.value.value,s);return new Cr(this,{kind:"constant",value:u},t.parameters)}return t}evaluate(t,r,s,l,u,p){return t.kind==="constant"?t.value:t.evaluate(r,s,l,u,p)}}class go extends qe{possiblyEvaluate(t,r,s,l){if(t.value===void 0)return new Cr(this,{kind:"constant",value:void 0},r);if(t.expression.kind==="constant"){let u=t.expression.evaluate(r,null,{},s,l),p=t.property.specification.type==="resolvedImage"&&typeof u!="string"?u.name:u,f=this._calculate(p,p,p,r);return new Cr(this,{kind:"constant",value:f},r)}if(t.expression.kind==="camera"){let u=this._calculate(t.expression.evaluate({zoom:r.zoom-1}),t.expression.evaluate({zoom:r.zoom}),t.expression.evaluate({zoom:r.zoom+1}),r);return new Cr(this,{kind:"constant",value:u},r)}return new Cr(this,t.expression,r)}evaluate(t,r,s,l,u,p){if(t.kind==="source"){let f=t.evaluate(r,s,l,u,p);return this._calculate(f,f,f,r)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(r.zoom)-1},s,l),t.evaluate({zoom:Math.floor(r.zoom)},s,l),t.evaluate({zoom:Math.floor(r.zoom)+1},s,l),r):t.value}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class _o{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){if(t.value!==void 0){if(t.expression.kind==="constant"){let u=t.expression.evaluate(r,null,{},s,l);return this._calculate(u,u,u,r)}return this._calculate(t.expression.evaluate(new zt(Math.floor(r.zoom-1),r)),t.expression.evaluate(new zt(Math.floor(r.zoom),r)),t.expression.evaluate(new zt(Math.floor(r.zoom+1),r)),r)}}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class Ca{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){return!!t.expression.evaluate(r,null,{},s,l)}interpolate(){return!1}}class h{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let r in t){let s=t[r];s.specification.overridable&&this.overridableProperties.push(r);let l=this.defaultPropertyValues[r]=new Zn(s,void 0),u=this.defaultTransitionablePropertyValues[r]=new fo(s);this.defaultTransitioningPropertyValues[r]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}ke("DataDrivenProperty",qe),ke("DataConstantProperty",De),ke("CrossFadedDataDrivenProperty",go),ke("CrossFadedProperty",_o),ke("ColorRampProperty",Ca);let e="-transition";class n extends wn{constructor(t,r){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),r.layout&&(this._unevaluatedLayout=new As(r.layout)),r.paint)){this._transitionablePaint=new mo(r.paint);for(let s in t.paint)this.setPaintProperty(s,t.paint[s],{validate:!1});for(let s in t.layout)this.setLayoutProperty(s,t.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Es(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,r,s={}){r!=null&&this._validate(Il,`layers.${this.id}.layout.${t}`,t,r,s)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,r):this.visibility=r)}getPaintProperty(t){return t.endsWith(e)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,r,s={}){if(r!=null&&this._validate(Tl,`layers.${this.id}.paint.${t}`,t,r,s))return!1;if(t.endsWith(e))return this._transitionablePaint.setTransition(t.slice(0,-11),r||void 0),!1;{let l=this._transitionablePaint._values[t],u=l.property.specification["property-type"]==="cross-faded-data-driven",p=l.value.isDataDriven(),f=l.value;this._transitionablePaint.setValue(t,r),this._handleSpecialPaintPropertyUpdate(t);let g=this._transitionablePaint._values[t].value;return g.isDataDriven()||p||u||this._handleOverridablePaintPropertyUpdate(t,f,g)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,r,s){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||this.visibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,r){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,r)}serialize(){let t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),vi(t,((r,s)=>!(r===void 0||s==="layout"&&!Object.keys(r).length||s==="paint"&&!Object.keys(r).length)))}_validate(t,r,s,l,u={}){return(!u||u.validate!==!1)&&xa(this,t.call(fn,{key:r,layerType:this.type,objectKey:s,value:l,styleSpec:ae,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let t in this.paint._values){let r=this.paint.get(t);if(r instanceof Cr&&Ln(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}let o={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class a{constructor(t,r){this._structArray=t,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class c{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,r){return t._trim(),r&&(t.isTransferred=!0,r.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){let r=Object.create(this.prototype);return r.arrayBuffer=t.arrayBuffer,r.length=t.length,r.capacity=t.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function m(i,t=1){let r=0,s=0;return{members:i.map((l=>{let u=o[l.type].BYTES_PER_ELEMENT,p=r=_(r,Math.max(t,u)),f=l.components||1;return s=Math.max(s,u),r+=u*f,{name:l.name,type:l.type,components:f,offset:p}})),size:_(r,Math.max(s,t)),alignment:t}}function _(i,t){return Math.ceil(i/t)*t}class y extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r){let s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){let l=2*t;return this.int16[l+0]=r,this.int16[l+1]=s,t}}y.prototype.bytesPerElement=4,ke("StructArrayLayout2i4",y);class b extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.int16[u+0]=r,this.int16[u+1]=s,this.int16[u+2]=l,t}}b.prototype.bytesPerElement=6,ke("StructArrayLayout3i6",b);class S extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,t,r,s,l)}emplace(t,r,s,l,u){let p=4*t;return this.int16[p+0]=r,this.int16[p+1]=s,this.int16[p+2]=l,this.int16[p+3]=u,t}}S.prototype.bytesPerElement=8,ke("StructArrayLayout4i8",S);class T extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,p)}emplace(t,r,s,l,u,p,f){let g=6*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.int16[g+2]=l,this.int16[g+3]=u,this.int16[g+4]=p,this.int16[g+5]=f,t}}T.prototype.bytesPerElement=12,ke("StructArrayLayout2i4i12",T);class E extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,p)}emplace(t,r,s,l,u,p,f){let g=4*t,x=8*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.uint8[x+4]=l,this.uint8[x+5]=u,this.uint8[x+6]=p,this.uint8[x+7]=f,t}}E.prototype.bytesPerElement=8,ke("StructArrayLayout2i4ub8",E);class D extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r){let s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){let l=2*t;return this.float32[l+0]=r,this.float32[l+1]=s,t}}D.prototype.bytesPerElement=8,ke("StructArrayLayout2f8",D);class F extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,p,f,g,x,v){let w=this.length;return this.resize(w+1),this.emplace(w,t,r,s,l,u,p,f,g,x,v)}emplace(t,r,s,l,u,p,f,g,x,v,w){let C=10*t;return this.uint16[C+0]=r,this.uint16[C+1]=s,this.uint16[C+2]=l,this.uint16[C+3]=u,this.uint16[C+4]=p,this.uint16[C+5]=f,this.uint16[C+6]=g,this.uint16[C+7]=x,this.uint16[C+8]=v,this.uint16[C+9]=w,t}}F.prototype.bytesPerElement=20,ke("StructArrayLayout10ui20",F);class V extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,p,f,g,x,v,w,C){let A=this.length;return this.resize(A+1),this.emplace(A,t,r,s,l,u,p,f,g,x,v,w,C)}emplace(t,r,s,l,u,p,f,g,x,v,w,C,A){let k=12*t;return this.int16[k+0]=r,this.int16[k+1]=s,this.int16[k+2]=l,this.int16[k+3]=u,this.uint16[k+4]=p,this.uint16[k+5]=f,this.uint16[k+6]=g,this.uint16[k+7]=x,this.int16[k+8]=v,this.int16[k+9]=w,this.int16[k+10]=C,this.int16[k+11]=A,t}}V.prototype.bytesPerElement=24,ke("StructArrayLayout4i4ui4i24",V);class $ extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.float32[u+0]=r,this.float32[u+1]=s,this.float32[u+2]=l,t}}$.prototype.bytesPerElement=12,ke("StructArrayLayout3f12",$);class q extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint32[1*t+0]=r,t}}q.prototype.bytesPerElement=4,ke("StructArrayLayout1ul4",q);class G extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,p,f,g,x){let v=this.length;return this.resize(v+1),this.emplace(v,t,r,s,l,u,p,f,g,x)}emplace(t,r,s,l,u,p,f,g,x,v){let w=10*t,C=5*t;return this.int16[w+0]=r,this.int16[w+1]=s,this.int16[w+2]=l,this.int16[w+3]=u,this.int16[w+4]=p,this.int16[w+5]=f,this.uint32[C+3]=g,this.uint16[w+8]=x,this.uint16[w+9]=v,t}}G.prototype.bytesPerElement=20,ke("StructArrayLayout6i1ul2ui20",G);class B extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,p)}emplace(t,r,s,l,u,p,f){let g=6*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.int16[g+2]=l,this.int16[g+3]=u,this.int16[g+4]=p,this.int16[g+5]=f,t}}B.prototype.bytesPerElement=12,ke("StructArrayLayout2i2i2i12",B);class J extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u){let p=this.length;return this.resize(p+1),this.emplace(p,t,r,s,l,u)}emplace(t,r,s,l,u,p){let f=4*t,g=8*t;return this.float32[f+0]=r,this.float32[f+1]=s,this.float32[f+2]=l,this.int16[g+6]=u,this.int16[g+7]=p,t}}J.prototype.bytesPerElement=16,ke("StructArrayLayout2f1f2i16",J);class ee extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,p)}emplace(t,r,s,l,u,p,f){let g=16*t,x=4*t,v=8*t;return this.uint8[g+0]=r,this.uint8[g+1]=s,this.float32[x+1]=l,this.float32[x+2]=u,this.int16[v+6]=p,this.int16[v+7]=f,t}}ee.prototype.bytesPerElement=16,ke("StructArrayLayout2ub2f2i16",ee);class ne extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.uint16[u+0]=r,this.uint16[u+1]=s,this.uint16[u+2]=l,t}}ne.prototype.bytesPerElement=6,ke("StructArrayLayout3ui6",ne);class de extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,p,f,g,x,v,w,C,A,k,L,O,j){let re=this.length;return this.resize(re+1),this.emplace(re,t,r,s,l,u,p,f,g,x,v,w,C,A,k,L,O,j)}emplace(t,r,s,l,u,p,f,g,x,v,w,C,A,k,L,O,j,re){let W=24*t,te=12*t,le=48*t;return this.int16[W+0]=r,this.int16[W+1]=s,this.uint16[W+2]=l,this.uint16[W+3]=u,this.uint32[te+2]=p,this.uint32[te+3]=f,this.uint32[te+4]=g,this.uint16[W+10]=x,this.uint16[W+11]=v,this.uint16[W+12]=w,this.float32[te+7]=C,this.float32[te+8]=A,this.uint8[le+36]=k,this.uint8[le+37]=L,this.uint8[le+38]=O,this.uint32[te+10]=j,this.int16[W+22]=re,t}}de.prototype.bytesPerElement=48,ke("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",de);class ge extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,p,f,g,x,v,w,C,A,k,L,O,j,re,W,te,le,fe,Me,je,Ce,Te,Be,Le){let Ee=this.length;return this.resize(Ee+1),this.emplace(Ee,t,r,s,l,u,p,f,g,x,v,w,C,A,k,L,O,j,re,W,te,le,fe,Me,je,Ce,Te,Be,Le)}emplace(t,r,s,l,u,p,f,g,x,v,w,C,A,k,L,O,j,re,W,te,le,fe,Me,je,Ce,Te,Be,Le,Ee){let he=32*t,Oe=16*t;return this.int16[he+0]=r,this.int16[he+1]=s,this.int16[he+2]=l,this.int16[he+3]=u,this.int16[he+4]=p,this.int16[he+5]=f,this.int16[he+6]=g,this.int16[he+7]=x,this.uint16[he+8]=v,this.uint16[he+9]=w,this.uint16[he+10]=C,this.uint16[he+11]=A,this.uint16[he+12]=k,this.uint16[he+13]=L,this.uint16[he+14]=O,this.uint16[he+15]=j,this.uint16[he+16]=re,this.uint16[he+17]=W,this.uint16[he+18]=te,this.uint16[he+19]=le,this.uint16[he+20]=fe,this.uint16[he+21]=Me,this.uint16[he+22]=je,this.uint32[Oe+12]=Ce,this.float32[Oe+13]=Te,this.float32[Oe+14]=Be,this.uint16[he+30]=Le,this.uint16[he+31]=Ee,t}}ge.prototype.bytesPerElement=64,ke("StructArrayLayout8i15ui1ul2f2ui64",ge);class Ie extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.float32[1*t+0]=r,t}}Ie.prototype.bytesPerElement=4,ke("StructArrayLayout1f4",Ie);class Ae extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.uint16[6*t+0]=r,this.float32[u+1]=s,this.float32[u+2]=l,t}}Ae.prototype.bytesPerElement=12,ke("StructArrayLayout1ui2f12",Ae);class be extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=4*t;return this.uint32[2*t+0]=r,this.uint16[u+2]=s,this.uint16[u+3]=l,t}}be.prototype.bytesPerElement=8,ke("StructArrayLayout1ul2ui8",be);class ve extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r){let s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){let l=2*t;return this.uint16[l+0]=r,this.uint16[l+1]=s,t}}ve.prototype.bytesPerElement=4,ke("StructArrayLayout2ui4",ve);class Re extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint16[1*t+0]=r,t}}Re.prototype.bytesPerElement=2,ke("StructArrayLayout1ui2",Re);class We extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,t,r,s,l)}emplace(t,r,s,l,u){let p=4*t;return this.float32[p+0]=r,this.float32[p+1]=s,this.float32[p+2]=l,this.float32[p+3]=u,t}}We.prototype.bytesPerElement=16,ke("StructArrayLayout4f16",We);class Se extends a{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new ue(this.anchorPointX,this.anchorPointY)}}Se.prototype.size=20;class Pe extends G{get(t){return new Se(this,t)}}ke("CollisionBoxArray",Pe);class Ge extends a{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Ge.prototype.size=48;class Lt extends de{get(t){return new Ge(this,t)}}ke("PlacedSymbolArray",Lt);class tt extends a{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}tt.prototype.size=64;class lt extends ge{get(t){return new tt(this,t)}}ke("SymbolInstanceArray",lt);class Dt extends Ie{getoffsetX(t){return this.float32[1*t+0]}}ke("GlyphOffsetArray",Dt);class pi extends b{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}ke("SymbolLineVertexArray",pi);class ur extends a{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]}}ur.prototype.size=12;class Rt extends Ae{get(t){return new ur(this,t)}}ke("TextAnchorOffsetArray",Rt);class Ei extends a{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}Ei.prototype.size=8;class Si extends be{get(t){return new Ei(this,t)}}ke("FeatureIndexArray",Si);class fi extends y{}class Ti extends y{}class Pr extends y{}class Gn extends T{}class yo extends E{}class Hn extends D{}class Ki extends F{}class xo extends V{}class Pa extends ${}class Ji extends q{}class Yi extends B{}class Hr extends ee{}class dr extends ne{}class ci extends ve{}let mi=m([{name:"a_pos",components:2,type:"Int16"}],4),{members:ji}=mi;class ut{constructor(t=[]){this.segments=t}prepareSegment(t,r,s,l){let u=this.segments[this.segments.length-1];return t>ut.MAX_VERTEX_ARRAY_LENGTH&&ze(`Max vertices per segment is ${ut.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!u||u.vertexLength+t>ut.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==l)&&(u={vertexOffset:r.length,primitiveOffset:s.length,vertexLength:0,primitiveLength:0},l!==void 0&&(u.sortKey=l),this.segments.push(u)),u}get(){return this.segments}destroy(){for(let t of this.segments)for(let r in t.vaos)t.vaos[r].destroy()}static simpleSegment(t,r,s,l){return new ut([{vertexOffset:t,primitiveOffset:r,vertexLength:s,primitiveLength:l,vaos:{},sortKey:0}])}}function mn(i,t){return 256*(i=Ye(Math.floor(i),0,255))+Ye(Math.floor(t),0,255)}ut.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ke("SegmentVector",ut);let Wn=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 Xn={exports:{}},El={exports:{}};El.exports=function(i,t){var r,s,l,u,p,f,g,x;for(s=i.length-(r=3&i.length),l=t,p=3432918353,f=461845907,x=0;x<s;)g=255&i.charCodeAt(x)|(255&i.charCodeAt(++x))<<8|(255&i.charCodeAt(++x))<<16|(255&i.charCodeAt(++x))<<24,++x,l=27492+(65535&(u=5*(65535&(l=(l^=g=(65535&(g=(g=(65535&g)*p+(((g>>>16)*p&65535)<<16)&4294967295)<<15|g>>>17))*f+(((g>>>16)*f&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(g=0,r){case 3:g^=(255&i.charCodeAt(x+2))<<16;case 2:g^=(255&i.charCodeAt(x+1))<<8;case 1:l^=g=(65535&(g=(g=(65535&(g^=255&i.charCodeAt(x)))*p+(((g>>>16)*p&65535)<<16)&4294967295)<<15|g>>>17))*f+(((g>>>16)*f&65535)<<16)&4294967295}return l^=i.length,l=2246822507*(65535&(l^=l>>>16))+((2246822507*(l>>>16)&65535)<<16)&4294967295,l=3266489909*(65535&(l^=l>>>13))+((3266489909*(l>>>16)&65535)<<16)&4294967295,(l^=l>>>16)>>>0};var Rc=El.exports,kl={exports:{}};kl.exports=function(i,t){for(var r,s=i.length,l=t^s,u=0;s>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(u)|(255&i.charCodeAt(++u))<<8|(255&i.charCodeAt(++u))<<16|(255&i.charCodeAt(++u))<<24))+((1540483477*(r>>>16)&65535)<<16),l=1540483477*(65535&l)+((1540483477*(l>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),s-=4,++u;switch(s){case 3:l^=(255&i.charCodeAt(u+2))<<16;case 2:l^=(255&i.charCodeAt(u+1))<<8;case 1:l=1540483477*(65535&(l^=255&i.charCodeAt(u)))+((1540483477*(l>>>16)&65535)<<16)}return l=1540483477*(65535&(l^=l>>>13))+((1540483477*(l>>>16)&65535)<<16),(l^=l>>>15)>>>0};var Wr=Rc,zl=kl.exports;Xn.exports=Wr,Xn.exports.murmur3=Wr,Xn.exports.murmur2=zl;var vo=me(Xn.exports);class ks{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,r,s,l){this.ids.push(bo(t)),this.positions.push(r,s,l)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");let r=bo(t),s=0,l=this.ids.length-1;for(;s<l;){let p=s+l>>1;this.ids[p]>=r?l=p:s=p+1}let u=[];for(;this.ids[s]===r;)u.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return u}static serialize(t,r){let s=new Float64Array(t.ids),l=new Uint32Array(t.positions);return wo(s,l,0,s.length-1),r&&r.push(s.buffer,l.buffer),{ids:s,positions:l}}static deserialize(t){let r=new ks;return r.ids=t.ids,r.positions=t.positions,r.indexed=!0,r}}function bo(i){let t=+i;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:vo(String(i))}function wo(i,t,r,s){for(;r<s;){let l=i[r+s>>1],u=r-1,p=s+1;for(;;){do u++;while(i[u]<l);do p--;while(i[p]>l);if(u>=p)break;Kn(i,u,p),Kn(t,3*u,3*p),Kn(t,3*u+1,3*p+1),Kn(t,3*u+2,3*p+2)}p-r<s-p?(wo(i,t,r,p),r=p+1):(wo(i,t,p+1,s),s=p)}}function Kn(i,t,r){let s=i[t];i[t]=i[r],i[r]=s}ke("FeaturePositionMap",ks);class zs{constructor(t,r){this.gl=t.gl,this.location=r}}class Ll extends zs{constructor(t,r){super(t,r),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class jh extends zs{constructor(t,r){super(t,r),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class $h extends zs{constructor(t,r){super(t,r),this.current=bt.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}let sp=new Float32Array(16);function Fc(i){return[mn(255*i.r,255*i.g),mn(255*i.b,255*i.a)]}class Ma{constructor(t,r,s){this.value=t,this.uniformNames=r.map((l=>`u_${l}`)),this.type=s}setUniform(t,r,s){t.set(s.constantOr(this.value))}getBinding(t,r,s){return this.type==="color"?new $h(t,r):new Ll(t,r)}}class So{constructor(t,r){this.uniformNames=r.map((s=>`u_${s}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=t.tlbr}setUniform(t,r,s,l){let u=l==="u_pattern_to"?this.patternTo:l==="u_pattern_from"?this.patternFrom:l==="u_pixel_ratio_to"?this.pixelRatioTo:l==="u_pixel_ratio_from"?this.pixelRatioFrom:null;u&&t.set(u)}getBinding(t,r,s){return s.substr(0,9)==="u_pattern"?new jh(t,r):new Ll(t,r)}}class gn{constructor(t,r,s,l){this.expression=t,this.type=s,this.maxValue=0,this.paintVertexAttributes=r.map((u=>({name:`a_${u}`,type:"Float32",components:s==="color"?2:1,offset:0}))),this.paintVertexArray=new l}populatePaintArray(t,r,s,l,u){let p=this.paintVertexArray.length,f=this.expression.evaluate(new zt(0),r,{},l,[],u);this.paintVertexArray.resize(t),this._setPaintValue(p,t,f)}updatePaintArray(t,r,s,l){let u=this.expression.evaluate({zoom:0},s,l);this._setPaintValue(t,r,u)}_setPaintValue(t,r,s){if(this.type==="color"){let l=Fc(s);for(let u=t;u<r;u++)this.paintVertexArray.emplace(u,l[0],l[1])}else{for(let l=t;l<r;l++)this.paintVertexArray.emplace(l,s);this.maxValue=Math.max(this.maxValue,Math.abs(s))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Fr{constructor(t,r,s,l,u,p){this.expression=t,this.uniformNames=r.map((f=>`u_${f}_t`)),this.type=s,this.useIntegerZoom=l,this.zoom=u,this.maxValue=0,this.paintVertexAttributes=r.map((f=>({name:`a_${f}`,type:"Float32",components:s==="color"?4:2,offset:0}))),this.paintVertexArray=new p}populatePaintArray(t,r,s,l,u){let p=this.expression.evaluate(new zt(this.zoom),r,{},l,[],u),f=this.expression.evaluate(new zt(this.zoom+1),r,{},l,[],u),g=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(g,t,p,f)}updatePaintArray(t,r,s,l){let u=this.expression.evaluate({zoom:this.zoom},s,l),p=this.expression.evaluate({zoom:this.zoom+1},s,l);this._setPaintValue(t,r,u,p)}_setPaintValue(t,r,s,l){if(this.type==="color"){let u=Fc(s),p=Fc(l);for(let f=t;f<r;f++)this.paintVertexArray.emplace(f,u[0],u[1],p[0],p[1])}else{for(let u=t;u<r;u++)this.paintVertexArray.emplace(u,s,l);this.maxValue=Math.max(this.maxValue,Math.abs(s),Math.abs(l))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,r){let s=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,l=Ye(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);t.set(l)}getBinding(t,r,s){return new Ll(t,r)}}class Jn{constructor(t,r,s,l,u,p){this.expression=t,this.type=r,this.useIntegerZoom=s,this.zoom=l,this.layerId=p,this.zoomInPaintVertexArray=new u,this.zoomOutPaintVertexArray=new u}populatePaintArray(t,r,s){let l=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(l,t,r.patterns&&r.patterns[this.layerId],s)}updatePaintArray(t,r,s,l,u){this._setPaintValues(t,r,s.patterns&&s.patterns[this.layerId],u)}_setPaintValues(t,r,s,l){if(!l||!s)return;let{min:u,mid:p,max:f}=s,g=l[u],x=l[p],v=l[f];if(g&&x&&v)for(let w=t;w<r;w++)this.zoomInPaintVertexArray.emplace(w,x.tl[0],x.tl[1],x.br[0],x.br[1],g.tl[0],g.tl[1],g.br[0],g.br[1],x.pixelRatio,g.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(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,Wn.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,Wn.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class qh{constructor(t,r,s){this.binders={},this._buffers=[];let l=[];for(let u in t.paint._values){if(!s(u))continue;let p=t.paint.get(u);if(!(p instanceof Cr&&Ln(p.property.specification)))continue;let f=op(u,t.type),g=p.value,x=p.property.specification.type,v=p.property.useIntegerZoom,w=p.property.specification["property-type"],C=w==="cross-faded"||w==="cross-faded-data-driven";if(g.kind==="constant")this.binders[u]=C?new So(g.value,f):new Ma(g.value,f,x),l.push(`/u_${u}`);else if(g.kind==="source"||C){let A=Zh(u,x,"source");this.binders[u]=C?new Jn(g,x,v,r,A,t.id):new gn(g,f,x,A),l.push(`/a_${u}`)}else{let A=Zh(u,x,"composite");this.binders[u]=new Fr(g,f,x,v,r,A),l.push(`/z_${u}`)}}this.cacheKey=l.sort().join("")}getMaxValue(t){let r=this.binders[t];return r instanceof gn||r instanceof Fr?r.maxValue:0}populatePaintArrays(t,r,s,l,u){for(let p in this.binders){let f=this.binders[p];(f instanceof gn||f instanceof Fr||f instanceof Jn)&&f.populatePaintArray(t,r,s,l,u)}}setConstantPatternPositions(t,r){for(let s in this.binders){let l=this.binders[s];l instanceof So&&l.setConstantPatternPositions(t,r)}}updatePaintArrays(t,r,s,l,u){let p=!1;for(let f in t){let g=r.getPositions(f);for(let x of g){let v=s.feature(x.index);for(let w in this.binders){let C=this.binders[w];if((C instanceof gn||C instanceof Fr||C instanceof Jn)&&C.expression.isStateDependent===!0){let A=l.paint.get(w);C.expression=A.value,C.updatePaintArray(x.start,x.end,v,t[f],u),p=!0}}}}return p}defines(){let t=[];for(let r in this.binders){let s=this.binders[r];(s instanceof Ma||s instanceof So)&&t.push(...s.uniformNames.map((l=>`#define HAS_UNIFORM_${l}`)))}return t}getBinderAttributes(){let t=[];for(let r in this.binders){let s=this.binders[r];if(s instanceof gn||s instanceof Fr)for(let l=0;l<s.paintVertexAttributes.length;l++)t.push(s.paintVertexAttributes[l].name);else if(s instanceof Jn)for(let l=0;l<Wn.members.length;l++)t.push(Wn.members[l].name)}return t}getBinderUniforms(){let t=[];for(let r in this.binders){let s=this.binders[r];if(s instanceof Ma||s instanceof So||s instanceof Fr)for(let l of s.uniformNames)t.push(l)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,r){let s=[];for(let l in this.binders){let u=this.binders[l];if(u instanceof Ma||u instanceof So||u instanceof Fr){for(let p of u.uniformNames)if(r[p]){let f=u.getBinding(t,r[p],p);s.push({name:p,property:l,binding:f})}}}return s}setUniforms(t,r,s,l){for(let{name:u,property:p,binding:f}of r)this.binders[p].setUniform(f,l,s.get(p),u)}updatePaintBuffers(t){this._buffers=[];for(let r in this.binders){let s=this.binders[r];if(t&&s instanceof Jn){let l=t.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;l&&this._buffers.push(l)}else(s instanceof gn||s instanceof Fr)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(t){for(let r in this.binders){let s=this.binders[r];(s instanceof gn||s instanceof Fr||s instanceof Jn)&&s.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let r=this.binders[t];(r instanceof gn||r instanceof Fr||r instanceof Jn)&&r.destroy()}}}class Ls{constructor(t,r,s=(()=>!0)){this.programConfigurations={};for(let l of t)this.programConfigurations[l.id]=new qh(l,r,s);this.needsUpload=!1,this._featureMap=new ks,this._bufferOffset=0}populatePaintArrays(t,r,s,l,u,p){for(let f in this.programConfigurations)this.programConfigurations[f].populatePaintArrays(t,r,l,u,p);r.id!==void 0&&this._featureMap.add(r.id,s,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,r,s,l){for(let u of s)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(t,this._featureMap,r,u,l)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(let r in this.programConfigurations)this.programConfigurations[r].upload(t);this.needsUpload=!1}}destroy(){for(let t in this.programConfigurations)this.programConfigurations[t].destroy()}}function op(i,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[i]||[i.replace(`${t}-`,"").replace(/-/g,"_")]}function Zh(i,t,r){let s={color:{source:D,composite:We},number:{source:Ie,composite:D}},l=(function(u){return{"line-pattern":{source:Ki,composite:Ki},"fill-pattern":{source:Ki,composite:Ki},"fill-extrusion-pattern":{source:Ki,composite:Ki}}[u]})(i);return l&&l[r]||s[t][r]}ke("ConstantBinder",Ma),ke("CrossFadedConstantBinder",So),ke("SourceExpressionBinder",gn),ke("CrossFadedCompositeBinder",Jn),ke("CompositeExpressionBinder",Fr),ke("ProgramConfiguration",qh,{omit:["_buffers"]}),ke("ProgramConfigurationSet",Ls);let Qt=8192,Bc=Math.pow(2,14)-1,Gh=-Bc-1;function Ds(i){let t=Qt/i.extent,r=i.loadGeometry();for(let s=0;s<r.length;s++){let l=r[s];for(let u=0;u<l.length;u++){let p=l[u],f=Math.round(p.x*t),g=Math.round(p.y*t);p.x=Ye(f,Gh,Bc),p.y=Ye(g,Gh,Bc),(f<p.x||f>p.x+1||g<p.y||g>p.y+1)&&ze("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function Rs(i,t){return{type:i.type,id:i.id,properties:i.properties,geometry:t?Ds(i):[]}}function Dl(i,t,r,s,l){i.emplaceBack(2*t+(s+1)/2,2*r+(l+1)/2)}class Oc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Ti,this.indexArray=new dr,this.segments=new ut,this.programConfigurations=new Ls(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(t,r,s){let l=this.layers[0],u=[],p=null,f=!1;l.type==="circle"&&(p=l.layout.get("circle-sort-key"),f=!p.isConstant());for(let{feature:g,id:x,index:v,sourceLayerIndex:w}of t){let C=this.layers[0]._featureFilter.needGeometry,A=Rs(g,C);if(!this.layers[0]._featureFilter.filter(new zt(this.zoom),A,s))continue;let k=f?p.evaluate(A,{},s):void 0,L={id:x,properties:g.properties,type:g.type,sourceLayerIndex:w,index:v,geometry:C?A.geometry:Ds(g),patterns:{},sortKey:k};u.push(L)}f&&u.sort(((g,x)=>g.sortKey-x.sortKey));for(let g of u){let{geometry:x,index:v,sourceLayerIndex:w}=g,C=t[v].feature;this.addFeature(g,x,v,s),r.featureIndex.insert(C,x,v,w,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ji),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,r,s,l){for(let u of r)for(let p of u){let f=p.x,g=p.y;if(f<0||f>=Qt||g<0||g>=Qt)continue;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),v=x.vertexLength;Dl(this.layoutVertexArray,f,g,-1,-1),Dl(this.layoutVertexArray,f,g,1,-1),Dl(this.layoutVertexArray,f,g,1,1),Dl(this.layoutVertexArray,f,g,-1,1),this.indexArray.emplaceBack(v,v+1,v+2),this.indexArray.emplaceBack(v,v+3,v+2),x.vertexLength+=4,x.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{},l)}}function Hh(i,t){for(let r=0;r<i.length;r++)if(To(t,i[r]))return!0;for(let r=0;r<t.length;r++)if(To(i,t[r]))return!0;return!!Nc(i,t)}function ap(i,t,r){return!!To(i,t)||!!Vc(t,i,r)}function Wh(i,t){if(i.length===1)return Kh(t,i[0]);for(let r=0;r<t.length;r++){let s=t[r];for(let l=0;l<s.length;l++)if(To(i,s[l]))return!0}for(let r=0;r<i.length;r++)if(Kh(t,i[r]))return!0;for(let r=0;r<t.length;r++)if(Nc(i,t[r]))return!0;return!1}function lp(i,t,r){if(i.length>1){if(Nc(i,t))return!0;for(let s=0;s<t.length;s++)if(Vc(t[s],i,r))return!0}for(let s=0;s<i.length;s++)if(Vc(i[s],t,r))return!0;return!1}function Nc(i,t){if(i.length===0||t.length===0)return!1;for(let r=0;r<i.length-1;r++){let s=i[r],l=i[r+1];for(let u=0;u<t.length-1;u++)if(cp(s,l,t[u],t[u+1]))return!0}return!1}function cp(i,t,r,s){return it(i,r,s)!==it(t,r,s)&&it(i,t,r)!==it(i,t,s)}function Vc(i,t,r){let s=r*r;if(t.length===1)return i.distSqr(t[0])<s;for(let l=1;l<t.length;l++)if(Xh(i,t[l-1],t[l])<s)return!0;return!1}function Xh(i,t,r){let s=t.distSqr(r);if(s===0)return i.distSqr(t);let l=((i.x-t.x)*(r.x-t.x)+(i.y-t.y)*(r.y-t.y))/s;return i.distSqr(l<0?t:l>1?r:r.sub(t)._mult(l)._add(t))}function Kh(i,t){let r,s,l,u=!1;for(let p=0;p<i.length;p++){r=i[p];for(let f=0,g=r.length-1;f<r.length;g=f++)s=r[f],l=r[g],s.y>t.y!=l.y>t.y&&t.x<(l.x-s.x)*(t.y-s.y)/(l.y-s.y)+s.x&&(u=!u)}return u}function To(i,t){let r=!1;for(let s=0,l=i.length-1;s<i.length;l=s++){let u=i[s],p=i[l];u.y>t.y!=p.y>t.y&&t.x<(p.x-u.x)*(t.y-u.y)/(p.y-u.y)+u.x&&(r=!r)}return r}function hp(i,t,r){let s=r[0],l=r[2];if(i.x<s.x&&t.x<s.x||i.x>l.x&&t.x>l.x||i.y<s.y&&t.y<s.y||i.y>l.y&&t.y>l.y)return!1;let u=it(i,t,r[0]);return u!==it(i,t,r[1])||u!==it(i,t,r[2])||u!==it(i,t,r[3])}function Aa(i,t,r){let s=t.paint.get(i).value;return s.kind==="constant"?s.value:r.programConfigurations.get(t.id).getMaxValue(i)}function Rl(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Fl(i,t,r,s,l){if(!t[0]&&!t[1])return i;let u=ue.convert(t)._mult(l);r==="viewport"&&u._rotate(-s);let p=[];for(let f=0;f<i.length;f++)p.push(i[f].sub(u));return p}let Jh,Yh;ke("CircleBucket",Oc,{omit:["layers"]});var up={get paint(){return Yh=Yh||new h({"circle-radius":new qe(ae.paint_circle["circle-radius"]),"circle-color":new qe(ae.paint_circle["circle-color"]),"circle-blur":new qe(ae.paint_circle["circle-blur"]),"circle-opacity":new qe(ae.paint_circle["circle-opacity"]),"circle-translate":new De(ae.paint_circle["circle-translate"]),"circle-translate-anchor":new De(ae.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new De(ae.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new De(ae.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new qe(ae.paint_circle["circle-stroke-width"]),"circle-stroke-color":new qe(ae.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new qe(ae.paint_circle["circle-stroke-opacity"])})},get layout(){return Jh=Jh||new h({"circle-sort-key":new qe(ae.layout_circle["circle-sort-key"])})}},ki=1e-6,Io=typeof Float32Array<"u"?Float32Array:Array;function Uc(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 Qh(i,t,r){var s=t[0],l=t[1],u=t[2],p=t[3],f=t[4],g=t[5],x=t[6],v=t[7],w=t[8],C=t[9],A=t[10],k=t[11],L=t[12],O=t[13],j=t[14],re=t[15],W=r[0],te=r[1],le=r[2],fe=r[3];return i[0]=W*s+te*f+le*w+fe*L,i[1]=W*l+te*g+le*C+fe*O,i[2]=W*u+te*x+le*A+fe*j,i[3]=W*p+te*v+le*k+fe*re,i[4]=(W=r[4])*s+(te=r[5])*f+(le=r[6])*w+(fe=r[7])*L,i[5]=W*l+te*g+le*C+fe*O,i[6]=W*u+te*x+le*A+fe*j,i[7]=W*p+te*v+le*k+fe*re,i[8]=(W=r[8])*s+(te=r[9])*f+(le=r[10])*w+(fe=r[11])*L,i[9]=W*l+te*g+le*C+fe*O,i[10]=W*u+te*x+le*A+fe*j,i[11]=W*p+te*v+le*k+fe*re,i[12]=(W=r[12])*s+(te=r[13])*f+(le=r[14])*w+(fe=r[15])*L,i[13]=W*l+te*g+le*C+fe*O,i[14]=W*u+te*x+le*A+fe*j,i[15]=W*p+te*v+le*k+fe*re,i}Math.hypot||(Math.hypot=function(){for(var i=0,t=arguments.length;t--;)i+=arguments[t]*arguments[t];return Math.sqrt(i)});var Ea,dp=Qh;function Bl(i,t,r){var s=t[0],l=t[1],u=t[2],p=t[3];return i[0]=r[0]*s+r[4]*l+r[8]*u+r[12]*p,i[1]=r[1]*s+r[5]*l+r[9]*u+r[13]*p,i[2]=r[2]*s+r[6]*l+r[10]*u+r[14]*p,i[3]=r[3]*s+r[7]*l+r[11]*u+r[15]*p,i}Ea=new Io(4),Io!=Float32Array&&(Ea[0]=0,Ea[1]=0,Ea[2]=0,Ea[3]=0);class pp extends n{constructor(t){super(t,up)}createBucket(t){return new Oc(t)}queryRadius(t){let r=t;return Aa("circle-radius",this,r)+Aa("circle-stroke-width",this,r)+Rl(this.paint.get("circle-translate"))}queryIntersectsFeature(t,r,s,l,u,p,f,g){let x=Fl(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),p.angle,f),v=this.paint.get("circle-radius").evaluate(r,s)+this.paint.get("circle-stroke-width").evaluate(r,s),w=this.paint.get("circle-pitch-alignment")==="map",C=w?x:(function(k,L){return k.map((O=>eu(O,L)))})(x,g),A=w?v*f:v;for(let k of l)for(let L of k){let O=w?L:eu(L,g),j=A,re=Bl([],[L.x,L.y,0,1],g);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?j*=re[3]/p.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(j*=p.cameraToCenterDistance/re[3]),ap(C,O,j))return!0}return!1}}function eu(i,t){let r=Bl([],[i.x,i.y,0,1],t);return new ue(r[0]/r[3],r[1]/r[3])}class tu extends Oc{}let iu;ke("HeatmapBucket",tu,{omit:["layers"]});var fp={get paint(){return iu=iu||new h({"heatmap-radius":new qe(ae.paint_heatmap["heatmap-radius"]),"heatmap-weight":new qe(ae.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new De(ae.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Ca(ae.paint_heatmap["heatmap-color"]),"heatmap-opacity":new De(ae.paint_heatmap["heatmap-opacity"])})}};function jc(i,{width:t,height:r},s,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==t*r*s)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${t*r*s}`)}else l=new Uint8Array(t*r*s);return i.width=t,i.height=r,i.data=l,i}function ru(i,{width:t,height:r},s){if(t===i.width&&r===i.height)return;let l=jc({},{width:t,height:r},s);$c(i,l,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,t),height:Math.min(i.height,r)},s),i.width=t,i.height=r,i.data=l.data}function $c(i,t,r,s,l,u){if(l.width===0||l.height===0)return t;if(l.width>i.width||l.height>i.height||r.x>i.width-l.width||r.y>i.height-l.height)throw new RangeError("out of range source coordinates for image copy");if(l.width>t.width||l.height>t.height||s.x>t.width-l.width||s.y>t.height-l.height)throw new RangeError("out of range destination coordinates for image copy");let p=i.data,f=t.data;if(p===f)throw new Error("srcData equals dstData, so image is already copied");for(let g=0;g<l.height;g++){let x=((r.y+g)*i.width+r.x)*u,v=((s.y+g)*t.width+s.x)*u;for(let w=0;w<l.width*u;w++)f[v+w]=p[x+w]}return t}class ka{constructor(t,r){jc(this,t,1,r)}resize(t){ru(this,t,1)}clone(){return new ka({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,r,s,l,u){$c(t,r,s,l,u,1)}}class pr{constructor(t,r){jc(this,t,4,r)}resize(t){ru(this,t,4)}replace(t,r){r?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new pr({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,r,s,l,u){$c(t,r,s,l,u,4)}}function nu(i){let t={},r=i.resolution||256,s=i.clips?i.clips.length:1,l=i.image||new pr({width:r,height:s});if(Math.log(r)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${r}`);let u=(p,f,g)=>{t[i.evaluationKey]=g;let x=i.expression.evaluate(t);l.data[p+f+0]=Math.floor(255*x.r/x.a),l.data[p+f+1]=Math.floor(255*x.g/x.a),l.data[p+f+2]=Math.floor(255*x.b/x.a),l.data[p+f+3]=Math.floor(255*x.a)};if(i.clips)for(let p=0,f=0;p<s;++p,f+=4*r)for(let g=0,x=0;g<r;g++,x+=4){let v=g/(r-1),{start:w,end:C}=i.clips[p];u(f,x,w*(1-v)+C*v)}else for(let p=0,f=0;p<r;p++,f+=4)u(0,f,p/(r-1));return l}ke("AlphaImage",ka),ke("RGBAImage",pr);let qc="big-fb";class mp extends n{createBucket(t){return new tu(t)}constructor(t){super(t,fp),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=nu({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(qc)&&this.heatmapFbos.delete(qc)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}}let su;var gp={get paint(){return su=su||new h({"hillshade-illumination-direction":new De(ae.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new De(ae.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new De(ae.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new De(ae.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new De(ae.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new De(ae.paint_hillshade["hillshade-accent-color"])})}};class _p extends n{constructor(t){super(t,gp)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}let yp=m([{name:"a_pos",components:2,type:"Int16"}],4),{members:xp}=yp;function ou(i,t,r=2){let s=t&&t.length,l=s?t[0]*r:i.length,u=au(i,0,l,r,!0),p=[];if(!u||u.next===u.prev)return p;let f,g,x;if(s&&(u=(function(v,w,C,A){let k=[];for(let L=0,O=w.length;L<O;L++){let j=au(v,w[L]*A,L<O-1?w[L+1]*A:v.length,A,!1);j===j.next&&(j.steiner=!0),k.push(Pp(j))}k.sort(Tp);for(let L=0;L<k.length;L++)C=Ip(k[L],C);return C})(i,t,u,r)),i.length>80*r){f=1/0,g=1/0;let v=-1/0,w=-1/0;for(let C=r;C<l;C+=r){let A=i[C],k=i[C+1];A<f&&(f=A),k<g&&(g=k),A>v&&(v=A),k>w&&(w=k)}x=Math.max(v-f,w-g),x=x!==0?32767/x:0}return za(u,p,r,f,g,x,0),p}function au(i,t,r,s,l){let u;if(l===(function(p,f,g,x){let v=0;for(let w=f,C=g-x;w<g;w+=x)v+=(p[C]-p[w])*(p[w+1]+p[C+1]),C=w;return v})(i,t,r,s)>0)for(let p=t;p<r;p+=s)u=hu(p/s|0,i[p],i[p+1],u);else for(let p=r-s;p>=t;p-=s)u=hu(p/s|0,i[p],i[p+1],u);return u&&Ol(u,u.next)&&(Da(u),u=u.next),u}function Fs(i,t){if(!i)return i;t||(t=i);let r,s=i;do if(r=!1,s.steiner||!Ol(s,s.next)&&Kt(s.prev,s,s.next)!==0)s=s.next;else{if(Da(s),s=t=s.prev,s===s.next)break;r=!0}while(r||s!==t);return t}function za(i,t,r,s,l,u,p){if(!i)return;!p&&u&&(function(g,x,v,w){let C=g;do C.z===0&&(C.z=Zc(C.x,C.y,x,v,w)),C.prevZ=C.prev,C.nextZ=C.next,C=C.next;while(C!==g);C.prevZ.nextZ=null,C.prevZ=null,(function(A){let k,L=1;do{let O,j=A;A=null;let re=null;for(k=0;j;){k++;let W=j,te=0;for(let fe=0;fe<L&&(te++,W=W.nextZ,W);fe++);let le=L;for(;te>0||le>0&&W;)te!==0&&(le===0||!W||j.z<=W.z)?(O=j,j=j.nextZ,te--):(O=W,W=W.nextZ,le--),re?re.nextZ=O:A=O,O.prevZ=re,re=O;j=W}re.nextZ=null,L*=2}while(k>1)})(C)})(i,s,l,u);let f=i;for(;i.prev!==i.next;){let g=i.prev,x=i.next;if(u?bp(i,s,l,u):vp(i))t.push(g.i,i.i,x.i),Da(i),i=x.next,f=x.next;else if((i=x)===f){p?p===1?za(i=wp(Fs(i),t),t,r,s,l,u,2):p===2&&Sp(i,t,r,s,l,u):za(Fs(i),t,r,s,l,u,1);break}}}function vp(i){let t=i.prev,r=i,s=i.next;if(Kt(t,r,s)>=0)return!1;let l=t.x,u=r.x,p=s.x,f=t.y,g=r.y,x=s.y,v=l<u?l<p?l:p:u<p?u:p,w=f<g?f<x?f:x:g<x?g:x,C=l>u?l>p?l:p:u>p?u:p,A=f>g?f>x?f:x:g>x?g:x,k=s.next;for(;k!==t;){if(k.x>=v&&k.x<=C&&k.y>=w&&k.y<=A&&Co(l,f,u,g,p,x,k.x,k.y)&&Kt(k.prev,k,k.next)>=0)return!1;k=k.next}return!0}function bp(i,t,r,s){let l=i.prev,u=i,p=i.next;if(Kt(l,u,p)>=0)return!1;let f=l.x,g=u.x,x=p.x,v=l.y,w=u.y,C=p.y,A=f<g?f<x?f:x:g<x?g:x,k=v<w?v<C?v:C:w<C?w:C,L=f>g?f>x?f:x:g>x?g:x,O=v>w?v>C?v:C:w>C?w:C,j=Zc(A,k,t,r,s),re=Zc(L,O,t,r,s),W=i.prevZ,te=i.nextZ;for(;W&&W.z>=j&&te&&te.z<=re;){if(W.x>=A&&W.x<=L&&W.y>=k&&W.y<=O&&W!==l&&W!==p&&Co(f,v,g,w,x,C,W.x,W.y)&&Kt(W.prev,W,W.next)>=0||(W=W.prevZ,te.x>=A&&te.x<=L&&te.y>=k&&te.y<=O&&te!==l&&te!==p&&Co(f,v,g,w,x,C,te.x,te.y)&&Kt(te.prev,te,te.next)>=0))return!1;te=te.nextZ}for(;W&&W.z>=j;){if(W.x>=A&&W.x<=L&&W.y>=k&&W.y<=O&&W!==l&&W!==p&&Co(f,v,g,w,x,C,W.x,W.y)&&Kt(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;te&&te.z<=re;){if(te.x>=A&&te.x<=L&&te.y>=k&&te.y<=O&&te!==l&&te!==p&&Co(f,v,g,w,x,C,te.x,te.y)&&Kt(te.prev,te,te.next)>=0)return!1;te=te.nextZ}return!0}function wp(i,t){let r=i;do{let s=r.prev,l=r.next.next;!Ol(s,l)&&lu(s,r,r.next,l)&&La(s,l)&&La(l,s)&&(t.push(s.i,r.i,l.i),Da(r),Da(r.next),r=i=l),r=r.next}while(r!==i);return Fs(r)}function Sp(i,t,r,s,l,u){let p=i;do{let f=p.next.next;for(;f!==p.prev;){if(p.i!==f.i&&Mp(p,f)){let g=cu(p,f);return p=Fs(p,p.next),g=Fs(g,g.next),za(p,t,r,s,l,u,0),void za(g,t,r,s,l,u,0)}f=f.next}p=p.next}while(p!==i)}function Tp(i,t){return i.x-t.x}function Ip(i,t){let r=(function(l,u){let p=u,f=l.x,g=l.y,x,v=-1/0;do{if(g<=p.y&&g>=p.next.y&&p.next.y!==p.y){let L=p.x+(g-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(L<=f&&L>v&&(v=L,x=p.x<p.next.x?p:p.next,L===f))return x}p=p.next}while(p!==u);if(!x)return null;let w=x,C=x.x,A=x.y,k=1/0;p=x;do{if(f>=p.x&&p.x>=C&&f!==p.x&&Co(g<A?f:v,g,C,A,g<A?v:f,g,p.x,p.y)){let L=Math.abs(g-p.y)/(f-p.x);La(p,l)&&(L<k||L===k&&(p.x>x.x||p.x===x.x&&Cp(x,p)))&&(x=p,k=L)}p=p.next}while(p!==w);return x})(i,t);if(!r)return t;let s=cu(r,i);return Fs(s,s.next),Fs(r,r.next)}function Cp(i,t){return Kt(i.prev,i,t.prev)<0&&Kt(t.next,i,i.next)<0}function Zc(i,t,r,s,l){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*l|0)|i<<8))|i<<4))|i<<2))|i<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*l|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Pp(i){let t=i,r=i;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==i);return r}function Co(i,t,r,s,l,u,p,f){return(l-p)*(t-f)>=(i-p)*(u-f)&&(i-p)*(s-f)>=(r-p)*(t-f)&&(r-p)*(u-f)>=(l-p)*(s-f)}function Mp(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!(function(r,s){let l=r;do{if(l.i!==r.i&&l.next.i!==r.i&&l.i!==s.i&&l.next.i!==s.i&&lu(l,l.next,r,s))return!0;l=l.next}while(l!==r);return!1})(i,t)&&(La(i,t)&&La(t,i)&&(function(r,s){let l=r,u=!1,p=(r.x+s.x)/2,f=(r.y+s.y)/2;do l.y>f!=l.next.y>f&&l.next.y!==l.y&&p<(l.next.x-l.x)*(f-l.y)/(l.next.y-l.y)+l.x&&(u=!u),l=l.next;while(l!==r);return u})(i,t)&&(Kt(i.prev,i,t.prev)||Kt(i,t.prev,t))||Ol(i,t)&&Kt(i.prev,i,i.next)>0&&Kt(t.prev,t,t.next)>0)}function Kt(i,t,r){return(t.y-i.y)*(r.x-t.x)-(t.x-i.x)*(r.y-t.y)}function Ol(i,t){return i.x===t.x&&i.y===t.y}function lu(i,t,r,s){let l=Vl(Kt(i,t,r)),u=Vl(Kt(i,t,s)),p=Vl(Kt(r,s,i)),f=Vl(Kt(r,s,t));return l!==u&&p!==f||!(l!==0||!Nl(i,r,t))||!(u!==0||!Nl(i,s,t))||!(p!==0||!Nl(r,i,s))||!(f!==0||!Nl(r,t,s))}function Nl(i,t,r){return t.x<=Math.max(i.x,r.x)&&t.x>=Math.min(i.x,r.x)&&t.y<=Math.max(i.y,r.y)&&t.y>=Math.min(i.y,r.y)}function Vl(i){return i>0?1:i<0?-1:0}function La(i,t){return Kt(i.prev,i,i.next)<0?Kt(i,t,i.next)>=0&&Kt(i,i.prev,t)>=0:Kt(i,t,i.prev)<0||Kt(i,i.next,t)<0}function cu(i,t){let r=Gc(i.i,i.x,i.y),s=Gc(t.i,t.x,t.y),l=i.next,u=t.prev;return i.next=t,t.prev=i,r.next=l,l.prev=r,s.next=r,r.prev=s,u.next=s,s.prev=u,s}function hu(i,t,r,s){let l=Gc(i,t,r);return s?(l.next=s.next,l.prev=s,s.next.prev=l,s.next=l):(l.prev=l,l.next=l),l}function Da(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 Gc(i,t,r){return{i,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Hc(i,t,r){let s=r.patternDependencies,l=!1;for(let u of t){let p=u.paint.get(`${i}-pattern`);p.isConstant()||(l=!0);let f=p.constantOr(null);f&&(l=!0,s[f.to]=!0,s[f.from]=!0)}return l}function Wc(i,t,r,s,l){let u=l.patternDependencies;for(let p of t){let f=p.paint.get(`${i}-pattern`).value;if(f.kind!=="constant"){let g=f.evaluate({zoom:s-1},r,{},l.availableImages),x=f.evaluate({zoom:s},r,{},l.availableImages),v=f.evaluate({zoom:s+1},r,{},l.availableImages);g=g&&g.name?g.name:g,x=x&&x.name?x.name:x,v=v&&v.name?v.name:v,u[g]=!0,u[x]=!0,u[v]=!0,r.patterns[p.id]={min:g,mid:x,max:v}}}return r}class Xc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Pr,this.indexArray=new dr,this.indexArray2=new ci,this.programConfigurations=new Ls(t.layers,t.zoom),this.segments=new ut,this.segments2=new ut,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(t,r,s){this.hasPattern=Hc("fill",this.layers,r);let l=this.layers[0].layout.get("fill-sort-key"),u=!l.isConstant(),p=[];for(let{feature:f,id:g,index:x,sourceLayerIndex:v}of t){let w=this.layers[0]._featureFilter.needGeometry,C=Rs(f,w);if(!this.layers[0]._featureFilter.filter(new zt(this.zoom),C,s))continue;let A=u?l.evaluate(C,{},s,r.availableImages):void 0,k={id:g,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?C.geometry:Ds(f),patterns:{},sortKey:A};p.push(k)}u&&p.sort(((f,g)=>f.sortKey-g.sortKey));for(let f of p){let{geometry:g,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){let w=Wc("fill",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,g,x,s,{});r.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(let l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,xp),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,r,s,l,u){for(let p of Xs(r,500)){let f=0;for(let A of p)f+=A.length;let g=this.segments.prepareSegment(f,this.layoutVertexArray,this.indexArray),x=g.vertexLength,v=[],w=[];for(let A of p){if(A.length===0)continue;A!==p[0]&&w.push(v.length/2);let k=this.segments2.prepareSegment(A.length,this.layoutVertexArray,this.indexArray2),L=k.vertexLength;this.layoutVertexArray.emplaceBack(A[0].x,A[0].y),this.indexArray2.emplaceBack(L+A.length-1,L),v.push(A[0].x),v.push(A[0].y);for(let O=1;O<A.length;O++)this.layoutVertexArray.emplaceBack(A[O].x,A[O].y),this.indexArray2.emplaceBack(L+O-1,L+O),v.push(A[O].x),v.push(A[O].y);k.vertexLength+=A.length,k.primitiveLength+=A.length}let C=ou(v,w);for(let A=0;A<C.length;A+=3)this.indexArray.emplaceBack(x+C[A],x+C[A+1],x+C[A+2]);g.vertexLength+=f,g.primitiveLength+=C.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,u,l)}}let uu,du;ke("FillBucket",Xc,{omit:["layers","patternFeatures"]});var Ap={get paint(){return du=du||new h({"fill-antialias":new De(ae.paint_fill["fill-antialias"]),"fill-opacity":new qe(ae.paint_fill["fill-opacity"]),"fill-color":new qe(ae.paint_fill["fill-color"]),"fill-outline-color":new qe(ae.paint_fill["fill-outline-color"]),"fill-translate":new De(ae.paint_fill["fill-translate"]),"fill-translate-anchor":new De(ae.paint_fill["fill-translate-anchor"]),"fill-pattern":new go(ae.paint_fill["fill-pattern"])})},get layout(){return uu=uu||new h({"fill-sort-key":new qe(ae.layout_fill["fill-sort-key"])})}};class Ep extends n{constructor(t){super(t,Ap)}recalculate(t,r){super.recalculate(t,r);let s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Xc(t)}queryRadius(){return Rl(this.paint.get("fill-translate"))}queryIntersectsFeature(t,r,s,l,u,p,f){return Wh(Fl(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),p.angle,f),l)}isTileClipped(){return!0}}let kp=m([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),zp=m([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Lp}=kp;var Yn={},Dp=_e,pu=Po;function Po(i,t,r,s,l){this.properties={},this.extent=r,this.type=0,this._pbf=i,this._geometry=-1,this._keys=s,this._values=l,i.readFields(Rp,this,t)}function Rp(i,t,r){i==1?t.id=r.readVarint():i==2?(function(s,l){for(var u=s.readVarint()+s.pos;s.pos<u;){var p=l._keys[s.readVarint()],f=l._values[s.readVarint()];l.properties[p]=f}})(r,t):i==3?t.type=r.readVarint():i==4&&(t._geometry=r.pos)}function Fp(i){for(var t,r,s=0,l=0,u=i.length,p=u-1;l<u;p=l++)s+=((r=i[p]).x-(t=i[l]).x)*(t.y+r.y);return s}Po.types=["Unknown","Point","LineString","Polygon"],Po.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var t,r=i.readVarint()+i.pos,s=1,l=0,u=0,p=0,f=[];i.pos<r;){if(l<=0){var g=i.readVarint();s=7&g,l=g>>3}if(l--,s===1||s===2)u+=i.readSVarint(),p+=i.readSVarint(),s===1&&(t&&f.push(t),t=[]),t.push(new Dp(u,p));else{if(s!==7)throw new Error("unknown command "+s);t&&t.push(t[0].clone())}}return t&&f.push(t),f},Po.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var t=i.readVarint()+i.pos,r=1,s=0,l=0,u=0,p=1/0,f=-1/0,g=1/0,x=-1/0;i.pos<t;){if(s<=0){var v=i.readVarint();r=7&v,s=v>>3}if(s--,r===1||r===2)(l+=i.readSVarint())<p&&(p=l),l>f&&(f=l),(u+=i.readSVarint())<g&&(g=u),u>x&&(x=u);else if(r!==7)throw new Error("unknown command "+r)}return[p,g,f,x]},Po.prototype.toGeoJSON=function(i,t,r){var s,l,u=this.extent*Math.pow(2,r),p=this.extent*i,f=this.extent*t,g=this.loadGeometry(),x=Po.types[this.type];function v(A){for(var k=0;k<A.length;k++){var L=A[k];A[k]=[360*(L.x+p)/u-180,360/Math.PI*Math.atan(Math.exp((180-360*(L.y+f)/u)*Math.PI/180))-90]}}switch(this.type){case 1:var w=[];for(s=0;s<g.length;s++)w[s]=g[s][0];v(g=w);break;case 2:for(s=0;s<g.length;s++)v(g[s]);break;case 3:for(g=(function(A){var k=A.length;if(k<=1)return[A];for(var L,O,j=[],re=0;re<k;re++){var W=Fp(A[re]);W!==0&&(O===void 0&&(O=W<0),O===W<0?(L&&j.push(L),L=[A[re]]):L.push(A[re]))}return L&&j.push(L),j})(g),s=0;s<g.length;s++)for(l=0;l<g[s].length;l++)v(g[s][l])}g.length===1?g=g[0]:x="Multi"+x;var C={type:"Feature",geometry:{type:x,coordinates:g},properties:this.properties};return"id"in this&&(C.id=this.id),C};var Bp=pu,fu=mu;function mu(i,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=i,this._keys=[],this._values=[],this._features=[],i.readFields(Op,this,t),this.length=this._features.length}function Op(i,t,r){i===15?t.version=r.readVarint():i===1?t.name=r.readString():i===5?t.extent=r.readVarint():i===2?t._features.push(r.pos):i===3?t._keys.push(r.readString()):i===4&&t._values.push((function(s){for(var l=null,u=s.readVarint()+s.pos;s.pos<u;){var p=s.readVarint()>>3;l=p===1?s.readString():p===2?s.readFloat():p===3?s.readDouble():p===4?s.readVarint64():p===5?s.readVarint():p===6?s.readSVarint():p===7?s.readBoolean():null}return l})(r))}mu.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var t=this._pbf.readVarint()+this._pbf.pos;return new Bp(this._pbf,t,this.extent,this._keys,this._values)};var Np=fu;function Vp(i,t,r){if(i===3){var s=new Np(r,r.readVarint()+r.pos);s.length&&(t[s.name]=s)}}Yn.VectorTile=function(i,t){this.layers=i.readFields(Vp,{},t)},Yn.VectorTileFeature=pu,Yn.VectorTileLayer=fu;let Up=Yn.VectorTileFeature.types,Kc=Math.pow(2,13);function Ra(i,t,r,s,l,u,p,f){i.emplaceBack(t,r,2*Math.floor(s*Kc)+p,l*Kc*2,u*Kc*2,Math.round(f))}class Jc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Gn,this.centroidVertexArray=new fi,this.indexArray=new dr,this.programConfigurations=new Ls(t.layers,t.zoom),this.segments=new ut,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(t,r,s){this.features=[],this.hasPattern=Hc("fill-extrusion",this.layers,r);for(let{feature:l,id:u,index:p,sourceLayerIndex:f}of t){let g=this.layers[0]._featureFilter.needGeometry,x=Rs(l,g);if(!this.layers[0]._featureFilter.filter(new zt(this.zoom),x,s))continue;let v={id:u,sourceLayerIndex:f,index:p,geometry:g?x.geometry:Ds(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(Wc("fill-extrusion",this.layers,v,this.zoom,r)):this.addFeature(v,v.geometry,p,s,{}),r.featureIndex.insert(l,v.geometry,p,f,this.index,!0)}}addFeatures(t,r,s){for(let l of this.features){let{geometry:u}=l;this.addFeature(l,u,l.index,r,s)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Lp),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,zp.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,r,s,l,u){for(let p of Xs(r,500)){let f={x:0,y:0,vertexCount:0},g=0;for(let k of p)g+=k.length;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let k of p){if(k.length===0||$p(k))continue;let L=0;for(let O=0;O<k.length;O++){let j=k[O];if(O>=1){let re=k[O-1];if(!jp(j,re)){x.vertexLength+4>ut.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let W=j.sub(re)._perp()._unit(),te=re.dist(j);L+te>32768&&(L=0),Ra(this.layoutVertexArray,j.x,j.y,W.x,W.y,0,0,L),Ra(this.layoutVertexArray,j.x,j.y,W.x,W.y,0,1,L),f.x+=2*j.x,f.y+=2*j.y,f.vertexCount+=2,L+=te,Ra(this.layoutVertexArray,re.x,re.y,W.x,W.y,0,0,L),Ra(this.layoutVertexArray,re.x,re.y,W.x,W.y,0,1,L),f.x+=2*re.x,f.y+=2*re.y,f.vertexCount+=2;let le=x.vertexLength;this.indexArray.emplaceBack(le,le+2,le+1),this.indexArray.emplaceBack(le+1,le+2,le+3),x.vertexLength+=4,x.primitiveLength+=2}}}}if(x.vertexLength+g>ut.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(g,this.layoutVertexArray,this.indexArray)),Up[t.type]!=="Polygon")continue;let v=[],w=[],C=x.vertexLength;for(let k of p)if(k.length!==0){k!==p[0]&&w.push(v.length/2);for(let L=0;L<k.length;L++){let O=k[L];Ra(this.layoutVertexArray,O.x,O.y,0,0,1,1,0),f.x+=O.x,f.y+=O.y,f.vertexCount+=1,v.push(O.x),v.push(O.y)}}let A=ou(v,w);for(let k=0;k<A.length;k+=3)this.indexArray.emplaceBack(C+A[k],C+A[k+2],C+A[k+1]);x.primitiveLength+=A.length/3,x.vertexLength+=g;for(let k=0;k<f.vertexCount;k++){let L=Math.floor(f.x/f.vertexCount),O=Math.floor(f.y/f.vertexCount);this.centroidVertexArray.emplaceBack(L,O)}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,u,l)}}function jp(i,t){return i.x===t.x&&(i.x<0||i.x>Qt)||i.y===t.y&&(i.y<0||i.y>Qt)}function $p(i){return i.every((t=>t.x<0))||i.every((t=>t.x>Qt))||i.every((t=>t.y<0))||i.every((t=>t.y>Qt))}let gu;ke("FillExtrusionBucket",Jc,{omit:["layers","features"]});var qp={get paint(){return gu=gu||new h({"fill-extrusion-opacity":new De(ae["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new qe(ae["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new De(ae["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new De(ae["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new go(ae["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new qe(ae["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new qe(ae["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new De(ae["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Zp extends n{constructor(t){super(t,qp)}createBucket(t){return new Jc(t)}queryRadius(){return Rl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,r,s,l,u,p,f,g){let x=Fl(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),p.angle,f),v=this.paint.get("fill-extrusion-height").evaluate(r,s),w=this.paint.get("fill-extrusion-base").evaluate(r,s),C=(function(k,L,O,j){let re=[];for(let W of k){let te=[W.x,W.y,0,1];Bl(te,te,L),re.push(new ue(te[0]/te[3],te[1]/te[3]))}return re})(x,g),A=(function(k,L,O,j){let re=[],W=[],te=j[8]*L,le=j[9]*L,fe=j[10]*L,Me=j[11]*L,je=j[8]*O,Ce=j[9]*O,Te=j[10]*O,Be=j[11]*O;for(let Le of k){let Ee=[],he=[];for(let Oe of Le){let Fe=Oe.x,He=Oe.y,At=j[0]*Fe+j[4]*He+j[12],It=j[1]*Fe+j[5]*He+j[13],si=j[2]*Fe+j[6]*He+j[14],Mr=j[3]*Fe+j[7]*He+j[15],_i=si+fe,oi=Mr+Me,zi=At+je,Li=It+Ce,Di=si+Te,Gt=Mr+Be,ai=new ue((At+te)/oi,(It+le)/oi);ai.z=_i/oi,Ee.push(ai);let Ii=new ue(zi/Gt,Li/Gt);Ii.z=Di/Gt,he.push(Ii)}re.push(Ee),W.push(he)}return[re,W]})(l,w,v,g);return(function(k,L,O){let j=1/0;Wh(O,L)&&(j=_u(O,L[0]));for(let re=0;re<L.length;re++){let W=L[re],te=k[re];for(let le=0;le<W.length-1;le++){let fe=W[le],Me=[fe,W[le+1],te[le+1],te[le],fe];Hh(O,Me)&&(j=Math.min(j,_u(O,Me)))}}return j!==1/0&&j})(A[0],A[1],C)}}function Fa(i,t){return i.x*t.x+i.y*t.y}function _u(i,t){if(i.length===1){let r=0,s=t[r++],l;for(;!l||s.equals(l);)if(l=t[r++],!l)return 1/0;for(;r<t.length;r++){let u=t[r],p=i[0],f=l.sub(s),g=u.sub(s),x=p.sub(s),v=Fa(f,f),w=Fa(f,g),C=Fa(g,g),A=Fa(x,f),k=Fa(x,g),L=v*C-w*w,O=(C*A-w*k)/L,j=(v*k-w*A)/L,re=s.z*(1-O-j)+l.z*O+u.z*j;if(isFinite(re))return re}return 1/0}{let r=1/0;for(let s of t)r=Math.min(r,s.z);return r}}let Gp=m([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:Hp}=Gp,Wp=m([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:Xp}=Wp,Kp=Yn.VectorTileFeature.types,Jp=Math.cos(Math.PI/180*37.5),yu=Math.pow(2,14)/.5;class Yc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((r=>{this.gradients[r.id]={}})),this.layoutVertexArray=new yo,this.layoutVertexArray2=new Hn,this.indexArray=new dr,this.programConfigurations=new Ls(t.layers,t.zoom),this.segments=new ut,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(t,r,s){this.hasPattern=Hc("line",this.layers,r);let l=this.layers[0].layout.get("line-sort-key"),u=!l.isConstant(),p=[];for(let{feature:f,id:g,index:x,sourceLayerIndex:v}of t){let w=this.layers[0]._featureFilter.needGeometry,C=Rs(f,w);if(!this.layers[0]._featureFilter.filter(new zt(this.zoom),C,s))continue;let A=u?l.evaluate(C,{},s):void 0,k={id:g,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?C.geometry:Ds(f),patterns:{},sortKey:A};p.push(k)}u&&p.sort(((f,g)=>f.sortKey-g.sortKey));for(let f of p){let{geometry:g,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){let w=Wc("line",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,g,x,s,{});r.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(let l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Xp)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hp),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,r,s,l,u){let p=this.layers[0].layout,f=p.get("line-join").evaluate(t,{}),g=p.get("line-cap"),x=p.get("line-miter-limit"),v=p.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(let w of r)this.addLine(w,t,f,g,x,v);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,u,l)}addLine(t,r,s,l,u,p){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let j=0;j<t.length-1;j++)this.totalDistance+=t[j].dist(t[j+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let f=Kp[r.type]==="Polygon",g=t.length;for(;g>=2&&t[g-1].equals(t[g-2]);)g--;let x=0;for(;x<g-1&&t[x].equals(t[x+1]);)x++;if(g<(f?3:2))return;s==="bevel"&&(u=1.05);let v=this.overscaling<=16?15*Qt/(512*this.overscaling):0,w=this.segments.prepareSegment(10*g,this.layoutVertexArray,this.indexArray),C,A,k,L,O;this.e1=this.e2=-1,f&&(C=t[g-2],O=t[x].sub(C)._unit()._perp());for(let j=x;j<g;j++){if(k=j===g-1?f?t[x+1]:void 0:t[j+1],k&&t[j].equals(k))continue;O&&(L=O),C&&(A=C),C=t[j],O=k?k.sub(C)._unit()._perp():L,L=L||O;let re=L.add(O);re.x===0&&re.y===0||re._unit();let W=L.x*O.x+L.y*O.y,te=re.x*O.x+re.y*O.y,le=te!==0?1/te:1/0,fe=2*Math.sqrt(2-2*te),Me=te<Jp&&A&&k,je=L.x*O.y-L.y*O.x>0;if(Me&&j>x){let Be=C.dist(A);if(Be>2*v){let Le=C.sub(C.sub(A)._mult(v/Be)._round());this.updateDistance(A,Le),this.addCurrentVertex(Le,L,0,0,w),A=Le}}let Ce=A&&k,Te=Ce?s:f?"butt":l;if(Ce&&Te==="round"&&(le<p?Te="miter":le<=2&&(Te="fakeround")),Te==="miter"&&le>u&&(Te="bevel"),Te==="bevel"&&(le>2&&(Te="flipbevel"),le<u&&(Te="miter")),A&&this.updateDistance(A,C),Te==="miter")re._mult(le),this.addCurrentVertex(C,re,0,0,w);else if(Te==="flipbevel"){if(le>100)re=O.mult(-1);else{let Be=le*L.add(O).mag()/L.sub(O).mag();re._perp()._mult(Be*(je?-1:1))}this.addCurrentVertex(C,re,0,0,w),this.addCurrentVertex(C,re.mult(-1),0,0,w)}else if(Te==="bevel"||Te==="fakeround"){let Be=-Math.sqrt(le*le-1),Le=je?Be:0,Ee=je?0:Be;if(A&&this.addCurrentVertex(C,L,Le,Ee,w),Te==="fakeround"){let he=Math.round(180*fe/Math.PI/20);for(let Oe=1;Oe<he;Oe++){let Fe=Oe/he;if(Fe!==.5){let At=Fe-.5;Fe+=Fe*At*(Fe-1)*((1.0904+W*(W*(3.55645-1.43519*W)-3.2452))*At*At+(.848013+W*(.215638*W-1.06021)))}let He=O.sub(L)._mult(Fe)._add(L)._unit()._mult(je?-1:1);this.addHalfVertex(C,He.x,He.y,!1,je,0,w)}}k&&this.addCurrentVertex(C,O,-Le,-Ee,w)}else if(Te==="butt")this.addCurrentVertex(C,re,0,0,w);else if(Te==="square"){let Be=A?1:-1;this.addCurrentVertex(C,re,Be,Be,w)}else Te==="round"&&(A&&(this.addCurrentVertex(C,L,0,0,w),this.addCurrentVertex(C,L,1,1,w,!0)),k&&(this.addCurrentVertex(C,O,-1,-1,w,!0),this.addCurrentVertex(C,O,0,0,w)));if(Me&&j<g-1){let Be=C.dist(k);if(Be>2*v){let Le=C.add(k.sub(C)._mult(v/Be)._round());this.updateDistance(C,Le),this.addCurrentVertex(Le,O,0,0,w),C=Le}}}}addCurrentVertex(t,r,s,l,u,p=!1){let f=r.y*l-r.x,g=-r.y-r.x*l;this.addHalfVertex(t,r.x+r.y*s,r.y-r.x*s,p,!1,s,u),this.addHalfVertex(t,f,g,p,!0,-l,u),this.distance>yu/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,r,s,l,u,p))}addHalfVertex({x:t,y:r},s,l,u,p,f,g){let x=.5*(this.lineClips?this.scaledDistance*(yu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(u?1:0),(r<<1)+(p?1:0),Math.round(63*s)+128,Math.round(63*l)+128,1+(f===0?0:f<0?-1:1)|(63&x)<<2,x>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let v=g.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,v),g.primitiveLength++),p?this.e2=v:this.e1=v}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,r){this.distance+=t.dist(r),this.updateScaledDistance()}}let xu,vu;ke("LineBucket",Yc,{omit:["layers","patternFeatures"]});var bu={get paint(){return vu=vu||new h({"line-opacity":new qe(ae.paint_line["line-opacity"]),"line-color":new qe(ae.paint_line["line-color"]),"line-translate":new De(ae.paint_line["line-translate"]),"line-translate-anchor":new De(ae.paint_line["line-translate-anchor"]),"line-width":new qe(ae.paint_line["line-width"]),"line-gap-width":new qe(ae.paint_line["line-gap-width"]),"line-offset":new qe(ae.paint_line["line-offset"]),"line-blur":new qe(ae.paint_line["line-blur"]),"line-dasharray":new _o(ae.paint_line["line-dasharray"]),"line-pattern":new go(ae.paint_line["line-pattern"]),"line-gradient":new Ca(ae.paint_line["line-gradient"])})},get layout(){return xu=xu||new h({"line-cap":new De(ae.layout_line["line-cap"]),"line-join":new qe(ae.layout_line["line-join"]),"line-miter-limit":new De(ae.layout_line["line-miter-limit"]),"line-round-limit":new De(ae.layout_line["line-round-limit"]),"line-sort-key":new qe(ae.layout_line["line-sort-key"])})}};class Yp extends qe{possiblyEvaluate(t,r){return r=new zt(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(t,r)}evaluate(t,r,s,l){return r=Mt({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(t,r,s,l)}}let Ul;class Qp extends n{constructor(t){super(t,bu),this.gradientVersion=0,Ul||(Ul=new Yp(bu.paint.properties["line-width"].specification),Ul.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){let r=this.gradientExpression();this.stepInterpolant=!!(function(s){return s._styleExpression!==void 0})(r)&&r._styleExpression.expression instanceof Pn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,r){super.recalculate(t,r),this.paint._values["line-floorwidth"]=Ul.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Yc(t)}queryRadius(t){let r=t,s=wu(Aa("line-width",this,r),Aa("line-gap-width",this,r)),l=Aa("line-offset",this,r);return s/2+Math.abs(l)+Rl(this.paint.get("line-translate"))}queryIntersectsFeature(t,r,s,l,u,p,f){let g=Fl(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),p.angle,f),x=f/2*wu(this.paint.get("line-width").evaluate(r,s),this.paint.get("line-gap-width").evaluate(r,s)),v=this.paint.get("line-offset").evaluate(r,s);return v&&(l=(function(w,C){let A=[];for(let k=0;k<w.length;k++){let L=w[k],O=[];for(let j=0;j<L.length;j++){let re=L[j-1],W=L[j],te=L[j+1],le=j===0?new ue(0,0):W.sub(re)._unit()._perp(),fe=j===L.length-1?new ue(0,0):te.sub(W)._unit()._perp(),Me=le._add(fe)._unit(),je=Me.x*fe.x+Me.y*fe.y;je!==0&&Me._mult(1/je),O.push(Me._mult(C)._add(W))}A.push(O)}return A})(l,v*f)),(function(w,C,A){for(let k=0;k<C.length;k++){let L=C[k];if(w.length>=3){for(let O=0;O<L.length;O++)if(To(w,L[O]))return!0}if(lp(w,L,A))return!0}return!1})(g,l,x)}isTileClipped(){return!0}}function wu(i,t){return t>0?t+2*i:i}let ef=m([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),tf=m([{name:"a_projected_pos",components:3,type:"Float32"}],4);m([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);let rf=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"}]);let Su=m([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),nf=m([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function sf(i,t,r){return i.sections.forEach((s=>{s.text=(function(l,u,p){let f=u.layout.get("text-transform").evaluate(p,{});return f==="uppercase"?l=l.toLocaleUpperCase():f==="lowercase"&&(l=l.toLocaleLowerCase()),Ui.applyArabicShaping&&(l=Ui.applyArabicShaping(l)),l})(s.text,t,r)})),i}m([{name:"triangle",components:3,type:"Uint16"}]),m([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),m([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),m([{type:"Float32",name:"offsetX"}]),m([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),m([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);let Ba={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};var ii=24,Tu=Tt,Iu=function(i,t,r,s,l){var u,p,f=8*l-s-1,g=(1<<f)-1,x=g>>1,v=-7,w=r?l-1:0,C=r?-1:1,A=i[t+w];for(w+=C,u=A&(1<<-v)-1,A>>=-v,v+=f;v>0;u=256*u+i[t+w],w+=C,v-=8);for(p=u&(1<<-v)-1,u>>=-v,v+=s;v>0;p=256*p+i[t+w],w+=C,v-=8);if(u===0)u=1-x;else{if(u===g)return p?NaN:1/0*(A?-1:1);p+=Math.pow(2,s),u-=x}return(A?-1:1)*p*Math.pow(2,u-s)},Cu=function(i,t,r,s,l,u){var p,f,g,x=8*u-l-1,v=(1<<x)-1,w=v>>1,C=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=s?0:u-1,k=s?1:-1,L=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,p=v):(p=Math.floor(Math.log(t)/Math.LN2),t*(g=Math.pow(2,-p))<1&&(p--,g*=2),(t+=p+w>=1?C/g:C*Math.pow(2,1-w))*g>=2&&(p++,g/=2),p+w>=v?(f=0,p=v):p+w>=1?(f=(t*g-1)*Math.pow(2,l),p+=w):(f=t*Math.pow(2,w-1)*Math.pow(2,l),p=0));l>=8;i[r+A]=255&f,A+=k,f/=256,l-=8);for(p=p<<l|f,x+=l;x>0;i[r+A]=255&p,A+=k,p/=256,x-=8);i[r+A-k]|=128*L};function Tt(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}Tt.Varint=0,Tt.Fixed64=1,Tt.Bytes=2,Tt.Fixed32=5;var Qc=4294967296,Pu=1/Qc,Mu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function _n(i){return i.type===Tt.Bytes?i.readVarint()+i.pos:i.pos+1}function Mo(i,t,r){return r?4294967296*t+(i>>>0):4294967296*(t>>>0)+(i>>>0)}function Au(i,t,r){var s=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(s);for(var l=r.pos-1;l>=i;l--)r.buf[l+s]=r.buf[l]}function of(i,t){for(var r=0;r<i.length;r++)t.writeVarint(i[r])}function af(i,t){for(var r=0;r<i.length;r++)t.writeSVarint(i[r])}function lf(i,t){for(var r=0;r<i.length;r++)t.writeFloat(i[r])}function cf(i,t){for(var r=0;r<i.length;r++)t.writeDouble(i[r])}function hf(i,t){for(var r=0;r<i.length;r++)t.writeBoolean(i[r])}function uf(i,t){for(var r=0;r<i.length;r++)t.writeFixed32(i[r])}function df(i,t){for(var r=0;r<i.length;r++)t.writeSFixed32(i[r])}function pf(i,t){for(var r=0;r<i.length;r++)t.writeFixed64(i[r])}function ff(i,t){for(var r=0;r<i.length;r++)t.writeSFixed64(i[r])}function jl(i,t){return(i[t]|i[t+1]<<8|i[t+2]<<16)+16777216*i[t+3]}function Ao(i,t,r){i[r]=t,i[r+1]=t>>>8,i[r+2]=t>>>16,i[r+3]=t>>>24}function Eu(i,t){return(i[t]|i[t+1]<<8|i[t+2]<<16)+(i[t+3]<<24)}Tt.prototype={destroy:function(){this.buf=null},readFields:function(i,t,r){for(r=r||this.length;this.pos<r;){var s=this.readVarint(),l=s>>3,u=this.pos;this.type=7&s,i(l,t,this),this.pos===u&&this.skip(s)}return t},readMessage:function(i,t){return this.readFields(i,t,this.readVarint()+this.pos)},readFixed32:function(){var i=jl(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=Eu(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=jl(this.buf,this.pos)+jl(this.buf,this.pos+4)*Qc;return this.pos+=8,i},readSFixed64:function(){var i=jl(this.buf,this.pos)+Eu(this.buf,this.pos+4)*Qc;return this.pos+=8,i},readFloat:function(){var i=Iu(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=Iu(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var t,r,s=this.buf;return t=127&(r=s[this.pos++]),r<128?t:(t|=(127&(r=s[this.pos++]))<<7,r<128?t:(t|=(127&(r=s[this.pos++]))<<14,r<128?t:(t|=(127&(r=s[this.pos++]))<<21,r<128?t:(function(l,u,p){var f,g,x=p.buf;if(f=(112&(g=x[p.pos++]))>>4,g<128||(f|=(127&(g=x[p.pos++]))<<3,g<128)||(f|=(127&(g=x[p.pos++]))<<10,g<128)||(f|=(127&(g=x[p.pos++]))<<17,g<128)||(f|=(127&(g=x[p.pos++]))<<24,g<128)||(f|=(1&(g=x[p.pos++]))<<31,g<128))return Mo(l,f,u);throw new Error("Expected varint not more than 10 bytes")})(t|=(15&(r=s[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?(i+1)/-2:i/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var i=this.readVarint()+this.pos,t=this.pos;return this.pos=i,i-t>=12&&Mu?(function(r,s,l){return Mu.decode(r.subarray(s,l))})(this.buf,t,i):(function(r,s,l){for(var u="",p=s;p<l;){var f,g,x,v=r[p],w=null,C=v>239?4:v>223?3:v>191?2:1;if(p+C>l)break;C===1?v<128&&(w=v):C===2?(192&(f=r[p+1]))==128&&(w=(31&v)<<6|63&f)<=127&&(w=null):C===3?(g=r[p+2],(192&(f=r[p+1]))==128&&(192&g)==128&&((w=(15&v)<<12|(63&f)<<6|63&g)<=2047||w>=55296&&w<=57343)&&(w=null)):C===4&&(g=r[p+2],x=r[p+3],(192&(f=r[p+1]))==128&&(192&g)==128&&(192&x)==128&&((w=(15&v)<<18|(63&f)<<12|(63&g)<<6|63&x)<=65535||w>=1114112)&&(w=null)),w===null?(w=65533,C=1):w>65535&&(w-=65536,u+=String.fromCharCode(w>>>10&1023|55296),w=56320|1023&w),u+=String.fromCharCode(w),p+=C}return u})(this.buf,t,i)},readBytes:function(){var i=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,i);return this.pos=i,t},readPackedVarint:function(i,t){if(this.type!==Tt.Bytes)return i.push(this.readVarint(t));var r=_n(this);for(i=i||[];this.pos<r;)i.push(this.readVarint(t));return i},readPackedSVarint:function(i){if(this.type!==Tt.Bytes)return i.push(this.readSVarint());var t=_n(this);for(i=i||[];this.pos<t;)i.push(this.readSVarint());return i},readPackedBoolean:function(i){if(this.type!==Tt.Bytes)return i.push(this.readBoolean());var t=_n(this);for(i=i||[];this.pos<t;)i.push(this.readBoolean());return i},readPackedFloat:function(i){if(this.type!==Tt.Bytes)return i.push(this.readFloat());var t=_n(this);for(i=i||[];this.pos<t;)i.push(this.readFloat());return i},readPackedDouble:function(i){if(this.type!==Tt.Bytes)return i.push(this.readDouble());var t=_n(this);for(i=i||[];this.pos<t;)i.push(this.readDouble());return i},readPackedFixed32:function(i){if(this.type!==Tt.Bytes)return i.push(this.readFixed32());var t=_n(this);for(i=i||[];this.pos<t;)i.push(this.readFixed32());return i},readPackedSFixed32:function(i){if(this.type!==Tt.Bytes)return i.push(this.readSFixed32());var t=_n(this);for(i=i||[];this.pos<t;)i.push(this.readSFixed32());return i},readPackedFixed64:function(i){if(this.type!==Tt.Bytes)return i.push(this.readFixed64());var t=_n(this);for(i=i||[];this.pos<t;)i.push(this.readFixed64());return i},readPackedSFixed64:function(i){if(this.type!==Tt.Bytes)return i.push(this.readSFixed64());var t=_n(this);for(i=i||[];this.pos<t;)i.push(this.readSFixed64());return i},skip:function(i){var t=7&i;if(t===Tt.Varint)for(;this.buf[this.pos++]>127;);else if(t===Tt.Bytes)this.pos=this.readVarint()+this.pos;else if(t===Tt.Fixed32)this.pos+=4;else{if(t!==Tt.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(i,t){this.writeVarint(i<<3|t)},realloc:function(i){for(var t=this.length||16;t<this.pos+i;)t*=2;if(t!==this.length){var r=new Uint8Array(t);r.set(this.buf),this.buf=r,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(i){this.realloc(4),Ao(this.buf,i,this.pos),this.pos+=4},writeSFixed32:function(i){this.realloc(4),Ao(this.buf,i,this.pos),this.pos+=4},writeFixed64:function(i){this.realloc(8),Ao(this.buf,-1&i,this.pos),Ao(this.buf,Math.floor(i*Pu),this.pos+4),this.pos+=8},writeSFixed64:function(i){this.realloc(8),Ao(this.buf,-1&i,this.pos),Ao(this.buf,Math.floor(i*Pu),this.pos+4),this.pos+=8},writeVarint:function(i){(i=+i||0)>268435455||i<0?(function(t,r){var s,l;if(t>=0?(s=t%4294967296|0,l=t/4294967296|0):(l=~(-t/4294967296),4294967295^(s=~(-t%4294967296))?s=s+1|0:(s=0,l=l+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),(function(u,p,f){f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,f.buf[f.pos]=127&(u>>>=7)})(s,0,r),(function(u,p){var f=(7&u)<<4;p.buf[p.pos++]|=f|((u>>>=3)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u)))))})(l,r)})(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(!!i)},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var t=this.pos;this.pos=(function(s,l,u){for(var p,f,g=0;g<l.length;g++){if((p=l.charCodeAt(g))>55295&&p<57344){if(!f){p>56319||g+1===l.length?(s[u++]=239,s[u++]=191,s[u++]=189):f=p;continue}if(p<56320){s[u++]=239,s[u++]=191,s[u++]=189,f=p;continue}p=f-55296<<10|p-56320|65536,f=null}else f&&(s[u++]=239,s[u++]=191,s[u++]=189,f=null);p<128?s[u++]=p:(p<2048?s[u++]=p>>6|192:(p<65536?s[u++]=p>>12|224:(s[u++]=p>>18|240,s[u++]=p>>12&63|128),s[u++]=p>>6&63|128),s[u++]=63&p|128)}return u})(this.buf,i,this.pos);var r=this.pos-t;r>=128&&Au(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),Cu(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),Cu(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var t=i.length;this.writeVarint(t),this.realloc(t);for(var r=0;r<t;r++)this.buf[this.pos++]=i[r]},writeRawMessage:function(i,t){this.pos++;var r=this.pos;i(t,this);var s=this.pos-r;s>=128&&Au(r,s,this),this.pos=r-1,this.writeVarint(s),this.pos+=s},writeMessage:function(i,t,r){this.writeTag(i,Tt.Bytes),this.writeRawMessage(t,r)},writePackedVarint:function(i,t){t.length&&this.writeMessage(i,of,t)},writePackedSVarint:function(i,t){t.length&&this.writeMessage(i,af,t)},writePackedBoolean:function(i,t){t.length&&this.writeMessage(i,hf,t)},writePackedFloat:function(i,t){t.length&&this.writeMessage(i,lf,t)},writePackedDouble:function(i,t){t.length&&this.writeMessage(i,cf,t)},writePackedFixed32:function(i,t){t.length&&this.writeMessage(i,uf,t)},writePackedSFixed32:function(i,t){t.length&&this.writeMessage(i,df,t)},writePackedFixed64:function(i,t){t.length&&this.writeMessage(i,pf,t)},writePackedSFixed64:function(i,t){t.length&&this.writeMessage(i,ff,t)},writeBytesField:function(i,t){this.writeTag(i,Tt.Bytes),this.writeBytes(t)},writeFixed32Field:function(i,t){this.writeTag(i,Tt.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(i,t){this.writeTag(i,Tt.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(i,t){this.writeTag(i,Tt.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(i,t){this.writeTag(i,Tt.Fixed64),this.writeSFixed64(t)},writeVarintField:function(i,t){this.writeTag(i,Tt.Varint),this.writeVarint(t)},writeSVarintField:function(i,t){this.writeTag(i,Tt.Varint),this.writeSVarint(t)},writeStringField:function(i,t){this.writeTag(i,Tt.Bytes),this.writeString(t)},writeFloatField:function(i,t){this.writeTag(i,Tt.Fixed32),this.writeFloat(t)},writeDoubleField:function(i,t){this.writeTag(i,Tt.Fixed64),this.writeDouble(t)},writeBooleanField:function(i,t){this.writeVarintField(i,!!t)}};var eh=me(Tu);let th=3;function mf(i,t,r){i===1&&r.readMessage(gf,t)}function gf(i,t,r){if(i===3){let{id:s,bitmap:l,width:u,height:p,left:f,top:g,advance:x}=r.readMessage(_f,{});t.push({id:s,bitmap:new ka({width:u+2*th,height:p+2*th},l),metrics:{width:u,height:p,left:f,top:g,advance:x}})}}function _f(i,t,r){i===1?t.id=r.readVarint():i===2?t.bitmap=r.readBytes():i===3?t.width=r.readVarint():i===4?t.height=r.readVarint():i===5?t.left=r.readSVarint():i===6?t.top=r.readSVarint():i===7&&(t.advance=r.readVarint())}let ku=th;function zu(i){let t=0,r=0;for(let p of i)t+=p.w*p.h,r=Math.max(r,p.w);i.sort(((p,f)=>f.h-p.h));let s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}],l=0,u=0;for(let p of i)for(let f=s.length-1;f>=0;f--){let g=s[f];if(!(p.w>g.w||p.h>g.h)){if(p.x=g.x,p.y=g.y,u=Math.max(u,p.y+p.h),l=Math.max(l,p.x+p.w),p.w===g.w&&p.h===g.h){let x=s.pop();f<s.length&&(s[f]=x)}else p.h===g.h?(g.x+=p.w,g.w-=p.w):p.w===g.w?(g.y+=p.h,g.h-=p.h):(s.push({x:g.x+p.w,y:g.y,w:g.w-p.w,h:p.h}),g.y+=p.h,g.h-=p.h);break}}return{w:l,h:u,fill:t/(l*u)||0}}let $i=1;class ih{constructor(t,{pixelRatio:r,version:s,stretchX:l,stretchY:u,content:p,textFitWidth:f,textFitHeight:g}){this.paddedRect=t,this.pixelRatio=r,this.stretchX=l,this.stretchY=u,this.content=p,this.version=s,this.textFitWidth=f,this.textFitHeight=g}get tl(){return[this.paddedRect.x+$i,this.paddedRect.y+$i]}get br(){return[this.paddedRect.x+this.paddedRect.w-$i,this.paddedRect.y+this.paddedRect.h-$i]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2*$i)/this.pixelRatio,(this.paddedRect.h-2*$i)/this.pixelRatio]}}class Lu{constructor(t,r){let s={},l={};this.haveRenderCallbacks=[];let u=[];this.addImages(t,s,u),this.addImages(r,l,u);let{w:p,h:f}=zu(u),g=new pr({width:p||1,height:f||1});for(let x in t){let v=t[x],w=s[x].paddedRect;pr.copy(v.data,g,{x:0,y:0},{x:w.x+$i,y:w.y+$i},v.data)}for(let x in r){let v=r[x],w=l[x].paddedRect,C=w.x+$i,A=w.y+$i,k=v.data.width,L=v.data.height;pr.copy(v.data,g,{x:0,y:0},{x:C,y:A},v.data),pr.copy(v.data,g,{x:0,y:L-1},{x:C,y:A-1},{width:k,height:1}),pr.copy(v.data,g,{x:0,y:0},{x:C,y:A+L},{width:k,height:1}),pr.copy(v.data,g,{x:k-1,y:0},{x:C-1,y:A},{width:1,height:L}),pr.copy(v.data,g,{x:0,y:0},{x:C+k,y:A},{width:1,height:L})}this.image=g,this.iconPositions=s,this.patternPositions=l}addImages(t,r,s){for(let l in t){let u=t[l],p={x:0,y:0,w:u.data.width+2*$i,h:u.data.height+2*$i};s.push(p),r[l]=new ih(p,u),u.hasRenderCallback&&this.haveRenderCallbacks.push(l)}}patchUpdatedImages(t,r){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(let s in t.updatedImages)this.patchUpdatedImage(this.iconPositions[s],t.getImage(s),r),this.patchUpdatedImage(this.patternPositions[s],t.getImage(s),r)}patchUpdatedImage(t,r,s){if(!t||!r||t.version===r.version)return;t.version=r.version;let[l,u]=t.tl;s.update(r.data,void 0,{x:l,y:u})}}var Qn;ke("ImagePosition",ih),ke("ImageAtlas",Lu),I.ah=void 0,(Qn=I.ah||(I.ah={}))[Qn.none=0]="none",Qn[Qn.horizontal=1]="horizontal",Qn[Qn.vertical=2]="vertical",Qn[Qn.horizontalOnly=3]="horizontalOnly";let Oa=-17;class Na{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,r){let s=new Na;return s.scale=t||1,s.fontStack=r,s}static forImage(t){let r=new Na;return r.imageName=t,r}}class Eo{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,r){let s=new Eo;for(let l=0;l<t.sections.length;l++){let u=t.sections[l];u.image?s.addImageSection(u):s.addTextSection(u,r)}return s}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}getCharCode(t){return this.text.charCodeAt(t)}verticalizePunctuation(){this.text=(function(t){let r="";for(let s=0;s<t.length;s++){let l=t.charCodeAt(s+1)||null,u=t.charCodeAt(s-1)||null;r+=l&&Ml(l)&&!Ba[t[s+1]]||u&&Ml(u)&&!Ba[t[s-1]]||!Ba[t[s]]?t[s]:Ba[t[s]]}return r})(this.text)}trim(){let t=0;for(let s=0;s<this.text.length&&ql[this.text.charCodeAt(s)];s++)t++;let r=this.text.length;for(let s=this.text.length-1;s>=0&&s>=t&&ql[this.text.charCodeAt(s)];s--)r--;this.text=this.text.substring(t,r),this.sectionIndex=this.sectionIndex.slice(t,r)}substring(t,r){let s=new Eo;return s.text=this.text.substring(t,r),s.sectionIndex=this.sectionIndex.slice(t,r),s.sections=this.sections,s}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,r)=>Math.max(t,this.sections[r].scale)),0)}addTextSection(t,r){this.text+=t.text,this.sections.push(Na.forText(t.scale,t.fontStack||r));let s=this.sections.length-1;for(let l=0;l<t.text.length;++l)this.sectionIndex.push(s)}addImageSection(t){let r=t.image?t.image.name:"";if(r.length===0)return void ze("Can't add FormattedSection with an empty image.");let s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCharCode(s),this.sections.push(Na.forImage(r)),this.sectionIndex.push(this.sections.length-1)):ze("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function $l(i,t,r,s,l,u,p,f,g,x,v,w,C,A,k){let L=Eo.fromFeature(i,l),O;w===I.ah.vertical&&L.verticalizePunctuation();let{processBidirectionalText:j,processStyledBidirectionalText:re}=Ui;if(j&&L.sections.length===1){O=[];let le=j(L.toString(),rh(L,x,u,t,s,A));for(let fe of le){let Me=new Eo;Me.text=fe,Me.sections=L.sections;for(let je=0;je<fe.length;je++)Me.sectionIndex.push(0);O.push(Me)}}else if(re){O=[];let le=re(L.text,L.sectionIndex,rh(L,x,u,t,s,A));for(let fe of le){let Me=new Eo;Me.text=fe[0],Me.sectionIndex=fe[1],Me.sections=L.sections,O.push(Me)}}else O=(function(le,fe){let Me=[],je=le.text,Ce=0;for(let Te of fe)Me.push(le.substring(Ce,Te)),Ce=Te;return Ce<je.length&&Me.push(le.substring(Ce,je.length)),Me})(L,rh(L,x,u,t,s,A));let W=[],te={positionedLines:W,text:L.toString(),top:v[1],bottom:v[1],left:v[0],right:v[0],writingMode:w,iconsInText:!1,verticalizable:!1};return(function(le,fe,Me,je,Ce,Te,Be,Le,Ee,he,Oe,Fe){let He=0,At=Oa,It=0,si=0,Mr=Le==="right"?1:Le==="left"?0:.5,_i=0;for(let Gt of Ce){Gt.trim();let ai=Gt.getMaxScale(),Ii=(ai-1)*ii,yi={positionedGlyphs:[],lineOffset:0};le.positionedLines[_i]=yi;let Ri=yi.positionedGlyphs,xi=0;if(!Gt.length()){At+=Te,++_i;continue}for(let qi=0;qi<Gt.length();qi++){let gt=Gt.getSection(qi),kt=Gt.getSectionIndex(qi),Ft=Gt.getCharCode(qi),Qi=0,jt=null,Do=null,Kr=null,Jr=ii,Ar=!(Ee===I.ah.horizontal||!Oe&&!Ta(Ft)||Oe&&(ql[Ft]||(oi=Ft,/\p{sc=Arab}/u.test(String.fromCodePoint(oi)))));if(gt.imageName){let gr=je[gt.imageName];if(!gr)continue;Kr=gt.imageName,le.iconsInText=le.iconsInText||!0,Do=gr.paddedRect;let hi=gr.displaySize;gt.scale=gt.scale*ii/Fe,jt={width:hi[0],height:hi[1],left:$i,top:-ku,advance:Ar?hi[1]:hi[0]},Qi=Ii+(ii-hi[1]*gt.scale),Jr=jt.advance;let yn=Ar?hi[0]*gt.scale-ii*ai:hi[1]*gt.scale-ii*ai;yn>0&&yn>xi&&(xi=yn)}else{let gr=Me[gt.fontStack],hi=gr&&gr[Ft];if(hi&&hi.rect)Do=hi.rect,jt=hi.metrics;else{let yn=fe[gt.fontStack],Za=yn&&yn[Ft];if(!Za)continue;jt=Za.metrics}Qi=(ai-gt.scale)*ii}Ar?(le.verticalizable=!0,Ri.push({glyph:Ft,imageName:Kr,x:He,y:At+Qi,vertical:Ar,scale:gt.scale,fontStack:gt.fontStack,sectionIndex:kt,metrics:jt,rect:Do}),He+=Jr*gt.scale+he):(Ri.push({glyph:Ft,imageName:Kr,x:He,y:At+Qi,vertical:Ar,scale:gt.scale,fontStack:gt.fontStack,sectionIndex:kt,metrics:jt,rect:Do}),He+=jt.advance*gt.scale+he)}Ri.length!==0&&(It=Math.max(He-he,It),bf(Ri,0,Ri.length-1,Mr,xi)),He=0;let mr=Te*ai+xi;yi.lineOffset=Math.max(xi,Ii),At+=mr,si=Math.max(mr,si),++_i}var oi;let zi=At-Oa,{horizontalAlign:Li,verticalAlign:Di}=nh(Be);(function(Gt,ai,Ii,yi,Ri,xi,mr,qi,gt){let kt=(ai-Ii)*Ri,Ft=0;Ft=xi!==mr?-qi*yi-Oa:(-yi*gt+.5)*mr;for(let Qi of Gt)for(let jt of Qi.positionedGlyphs)jt.x+=kt,jt.y+=Ft})(le.positionedLines,Mr,Li,Di,It,si,Te,zi,Ce.length),le.top+=-Di*zi,le.bottom=le.top+zi,le.left+=-Li*It,le.right=le.left+It})(te,t,r,s,O,p,f,g,w,x,C,k),!(function(le){for(let fe of le)if(fe.positionedGlyphs.length!==0)return!1;return!0})(W)&&te}let ql={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},yf={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},xf={40:!0};function Du(i,t,r,s,l,u){if(t.imageName){let p=s[t.imageName];return p?p.displaySize[0]*t.scale*ii/u+l:0}{let p=r[t.fontStack],f=p&&p[i];return f?f.metrics.advance*t.scale+l:0}}function Ru(i,t,r,s){let l=Math.pow(i-t,2);return s?i<t?l/2:2*l:l+Math.abs(r)*r}function vf(i,t,r){let s=0;return i===10&&(s-=1e4),r&&(s+=150),i!==40&&i!==65288||(s+=50),t!==41&&t!==65289||(s+=50),s}function Fu(i,t,r,s,l,u){let p=null,f=Ru(t,r,l,u);for(let g of s){let x=Ru(t-g.x,r,l,u)+g.badness;x<=f&&(p=g,f=x)}return{index:i,x:t,priorBreak:p,badness:f}}function Bu(i){return i?Bu(i.priorBreak).concat(i.index):[]}function rh(i,t,r,s,l,u){if(!i)return[];let p=[],f=(function(w,C,A,k,L,O){let j=0;for(let re=0;re<w.length();re++){let W=w.getSection(re);j+=Du(w.getCharCode(re),W,k,L,C,O)}return j/Math.max(1,Math.ceil(j/A))})(i,t,r,s,l,u),g=i.text.indexOf("\u200B")>=0,x=0;for(let w=0;w<i.length();w++){let C=i.getSection(w),A=i.getCharCode(w);if(ql[A]||(x+=Du(A,C,s,l,t,u)),w<i.length()-1){let k=!((v=A)<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)||Pl.test(String.fromCodePoint(v)));(yf[A]||k||C.imageName||w!==i.length()-2&&xf[i.getCharCode(w+1)])&&p.push(Fu(w+1,x,f,p,vf(A,i.getCharCode(w+1),k&&g),!1))}}var v;return Bu(Fu(i.length(),x,f,p,0,!0))}function nh(i){let t=.5,r=.5;switch(i){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=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:t,verticalAlign:r}}function bf(i,t,r,s,l){if(!s&&!l)return;let u=i[r],p=(i[r].x+u.metrics.advance*u.scale)*s;for(let f=t;f<=r;f++)i[f].x-=p,i[f].y+=l}function wf(i,t,r){let{horizontalAlign:s,verticalAlign:l}=nh(r),u=t[0]-i.displaySize[0]*s,p=t[1]-i.displaySize[1]*l;return{image:i,top:p,bottom:p+i.displaySize[1],left:u,right:u+i.displaySize[0]}}function Ou(i){var t,r;let s=i.left,l=i.top,u=i.right-s,p=i.bottom-l,f=(t=i.image.textFitWidth)!==null&&t!==void 0?t:"stretchOrShrink",g=(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(g==="proportional"){if(f==="stretchOnly"&&u/p<x||f==="proportional"){let v=Math.ceil(p*x);s*=v/u,u=v}}else if(f==="proportional"&&g==="stretchOnly"&&x!==0&&u/p>x){let v=Math.ceil(u/x);l*=v/p,p=v}return{x1:s,y1:l,x2:s+u,y2:l+p}}function Nu(i,t,r,s,l,u){let p=i.image,f;if(p.content){let O=p.content,j=p.pixelRatio||1;f=[O[0]/j,O[1]/j,p.displaySize[0]-O[2]/j,p.displaySize[1]-O[3]/j]}let g=t.left*u,x=t.right*u,v,w,C,A;r==="width"||r==="both"?(A=l[0]+g-s[3],w=l[0]+x+s[1]):(A=l[0]+(g+x-p.displaySize[0])/2,w=A+p.displaySize[0]);let k=t.top*u,L=t.bottom*u;return r==="height"||r==="both"?(v=l[1]+k-s[0],C=l[1]+L+s[2]):(v=l[1]+(k+L-p.displaySize[1])/2,C=v+p.displaySize[1]),{image:p,top:v,right:w,bottom:C,left:A,collisionPadding:f}}let Va=255,Xr=128,es=Va*Xr;function Vu(i,t){let{expression:r}=t;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new zt(i+1))};if(r.kind==="source")return{kind:"source"};{let{zoomStops:s,interpolationType:l}=r,u=0;for(;u<s.length&&s[u]<=i;)u++;u=Math.max(0,u-1);let p=u;for(;p<s.length&&s[p]<i+1;)p++;p=Math.min(s.length-1,p);let f=s[u],g=s[p];return r.kind==="composite"?{kind:"composite",minZoom:f,maxZoom:g,interpolationType:l}:{kind:"camera",minZoom:f,maxZoom:g,minSize:r.evaluate(new zt(f)),maxSize:r.evaluate(new zt(g)),interpolationType:l}}}function sh(i,t,r){let s="never",l=i.get(t);return l?s=l:i.get(r)&&(s="always"),s}let Sf=Yn.VectorTileFeature.types,Tf=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Zl(i,t,r,s,l,u,p,f,g,x,v,w,C){let A=f?Math.min(es,Math.round(f[0])):0,k=f?Math.min(es,Math.round(f[1])):0;i.emplaceBack(t,r,Math.round(32*s),Math.round(32*l),u,p,(A<<1)+(g?1:0),k,16*x,16*v,256*w,256*C)}function oh(i,t,r){i.emplaceBack(t.x,t.y,r),i.emplaceBack(t.x,t.y,r),i.emplaceBack(t.x,t.y,r),i.emplaceBack(t.x,t.y,r)}function If(i){for(let t of i.sections)if(Dc(t.text))return!0;return!1}class ah{constructor(t){this.layoutVertexArray=new xo,this.indexArray=new dr,this.programConfigurations=t,this.segments=new ut,this.dynamicLayoutVertexArray=new Pa,this.opacityVertexArray=new Ji,this.hasVisibleVertices=!1,this.placedSymbolArray=new Lt}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(t,r,s,l){this.isEmpty()||(s&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ef.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,tf.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Tf,!0),this.opacityVertexBuffer.itemSize=1),(s||l)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}ke("SymbolBuffers",ah);class lh{constructor(t,r,s){this.layoutVertexArray=new t,this.layoutAttributes=r,this.indexArray=new s,this.segments=new ut,this.collisionVertexArray=new Hr}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,rf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}ke("CollisionBuffers",lh);class ko{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((p=>p.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Uc([]),this.placementViewportMatrix=Uc([]);let r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Vu(this.zoom,r["text-size"]),this.iconSizeData=Vu(this.zoom,r["icon-size"]);let s=this.layers[0].layout,l=s.get("symbol-sort-key"),u=s.get("symbol-z-order");this.canOverlap=sh(s,"text-overlap","text-allow-overlap")!=="never"||sh(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=u!=="viewport-y"&&!l.isConstant(),this.sortFeaturesByY=(u==="viewport-y"||u==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map((p=>I.ah[p]))),this.stateDependentLayerIds=this.layers.filter((p=>p.isStateDependent())).map((p=>p.id)),this.sourceID=t.sourceID}createArrays(){this.text=new ah(new Ls(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new ah(new Ls(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Dt,this.lineVertexArray=new pi,this.symbolInstances=new lt,this.textAnchorOffsets=new Rt}calculateGlyphDependencies(t,r,s,l,u){for(let p=0;p<t.length;p++)if(r[t.charCodeAt(p)]=!0,(s||l)&&u){let f=Ba[t.charAt(p)];f&&(r[f.charCodeAt(0)]=!0)}}populate(t,r,s){let l=this.layers[0],u=l.layout,p=u.get("text-font"),f=u.get("text-field"),g=u.get("icon-image"),x=(f.value.kind!=="constant"||f.value.value instanceof Bi&&!f.value.value.isEmpty()||f.value.value.toString().length>0)&&(p.value.kind!=="constant"||p.value.value.length>0),v=g.value.kind!=="constant"||!!g.value.value||Object.keys(g.parameters).length>0,w=u.get("symbol-sort-key");if(this.features=[],!x&&!v)return;let C=r.iconDependencies,A=r.glyphDependencies,k=r.availableImages,L=new zt(this.zoom);for(let{feature:O,id:j,index:re,sourceLayerIndex:W}of t){let te=l._featureFilter.needGeometry,le=Rs(O,te);if(!l._featureFilter.filter(L,le,s))continue;let fe,Me;if(te||(le.geometry=Ds(O)),x){let Ce=l.getValueAndResolveTokens("text-field",le,s,k),Te=Bi.factory(Ce),Be=this.hasRTLText=this.hasRTLText||If(Te);(!Be||Ui.getRTLTextPluginStatus()==="unavailable"||Be&&Ui.isParsed())&&(fe=sf(Te,l,le))}if(v){let Ce=l.getValueAndResolveTokens("icon-image",le,s,k);Me=Ce instanceof Ni?Ce:Ni.fromString(Ce)}if(!fe&&!Me)continue;let je=this.sortFeaturesByKey?w.evaluate(le,{},s):void 0;if(this.features.push({id:j,text:fe,icon:Me,index:re,sourceLayerIndex:W,geometry:le.geometry,properties:O.properties,type:Sf[O.type],sortKey:je}),Me&&(C[Me.name]=!0),fe){let Ce=p.evaluate(le,{},s).join(","),Te=u.get("text-rotation-alignment")!=="viewport"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(I.ah.vertical)>=0;for(let Be of fe.sections)if(Be.image)C[Be.image.name]=!0;else{let Le=wa(fe.toString()),Ee=Be.fontStack||Ce,he=A[Ee]=A[Ee]||{};this.calculateGlyphDependencies(Be.text,he,Te,this.allowVerticalPlacement,Le)}}}u.get("symbol-placement")==="line"&&(this.features=(function(O){let j={},re={},W=[],te=0;function le(Ce){W.push(O[Ce]),te++}function fe(Ce,Te,Be){let Le=re[Ce];return delete re[Ce],re[Te]=Le,W[Le].geometry[0].pop(),W[Le].geometry[0]=W[Le].geometry[0].concat(Be[0]),Le}function Me(Ce,Te,Be){let Le=j[Te];return delete j[Te],j[Ce]=Le,W[Le].geometry[0].shift(),W[Le].geometry[0]=Be[0].concat(W[Le].geometry[0]),Le}function je(Ce,Te,Be){let Le=Be?Te[0][Te[0].length-1]:Te[0][0];return`${Ce}:${Le.x}:${Le.y}`}for(let Ce=0;Ce<O.length;Ce++){let Te=O[Ce],Be=Te.geometry,Le=Te.text?Te.text.toString():null;if(!Le){le(Ce);continue}let Ee=je(Le,Be),he=je(Le,Be,!0);if(Ee in re&&he in j&&re[Ee]!==j[he]){let Oe=Me(Ee,he,Be),Fe=fe(Ee,he,W[Oe].geometry);delete j[Ee],delete re[he],re[je(Le,W[Fe].geometry,!0)]=Fe,W[Oe].geometry=null}else Ee in re?fe(Ee,he,Be):he in j?Me(Ee,he,Be):(le(Ce),j[Ee]=te-1,re[he]=te-1)}return W.filter((Ce=>Ce.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((O,j)=>O.sortKey-j.sortKey))}update(t,r,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,r,this.layers,s),this.icon.programConfigurations.updatePaintArrays(t,r,this.layers,s))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,r){let s=this.lineVertexArray.length;if(t.segment!==void 0){let l=t.dist(r[t.segment+1]),u=t.dist(r[t.segment]),p={};for(let f=t.segment+1;f<r.length;f++)p[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=t.segment||0;f>=0;f--)p[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:u},f>0&&(u+=r[f-1].dist(r[f]));for(let f=0;f<r.length;f++){let g=p[f];this.lineVertexArray.emplaceBack(g.x,g.y,g.tileUnitDistanceFromAnchor)}}return{lineStartIndex:s,lineLength:this.lineVertexArray.length-s}}addSymbols(t,r,s,l,u,p,f,g,x,v,w,C){let A=t.indexArray,k=t.layoutVertexArray,L=t.segments.prepareSegment(4*r.length,k,A,this.canOverlap?p.sortKey:void 0),O=this.glyphOffsetArray.length,j=L.vertexLength,re=this.allowVerticalPlacement&&f===I.ah.vertical?Math.PI/2:0,W=p.text&&p.text.sections;for(let te=0;te<r.length;te++){let{tl:le,tr:fe,bl:Me,br:je,tex:Ce,pixelOffsetTL:Te,pixelOffsetBR:Be,minFontScaleX:Le,minFontScaleY:Ee,glyphOffset:he,isSDF:Oe,sectionIndex:Fe}=r[te],He=L.vertexLength,At=he[1];Zl(k,g.x,g.y,le.x,At+le.y,Ce.x,Ce.y,s,Oe,Te.x,Te.y,Le,Ee),Zl(k,g.x,g.y,fe.x,At+fe.y,Ce.x+Ce.w,Ce.y,s,Oe,Be.x,Te.y,Le,Ee),Zl(k,g.x,g.y,Me.x,At+Me.y,Ce.x,Ce.y+Ce.h,s,Oe,Te.x,Be.y,Le,Ee),Zl(k,g.x,g.y,je.x,At+je.y,Ce.x+Ce.w,Ce.y+Ce.h,s,Oe,Be.x,Be.y,Le,Ee),oh(t.dynamicLayoutVertexArray,g,re),A.emplaceBack(He,He+1,He+2),A.emplaceBack(He+1,He+2,He+3),L.vertexLength+=4,L.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(he[0]),te!==r.length-1&&Fe===r[te+1].sectionIndex||t.programConfigurations.populatePaintArrays(k.length,p,p.index,{},C,W&&W[Fe])}t.placedSymbolArray.emplaceBack(g.x,g.y,O,this.glyphOffsetArray.length-O,j,x,v,g.segment,s?s[0]:0,s?s[1]:0,l[0],l[1],f,0,!1,0,w)}_addCollisionDebugVertex(t,r,s,l,u,p){return r.emplaceBack(0,0),t.emplaceBack(s.x,s.y,l,u,Math.round(p.x),Math.round(p.y))}addCollisionDebugVertices(t,r,s,l,u,p,f){let g=u.segments.prepareSegment(4,u.layoutVertexArray,u.indexArray),x=g.vertexLength,v=u.layoutVertexArray,w=u.collisionVertexArray,C=f.anchorX,A=f.anchorY;this._addCollisionDebugVertex(v,w,p,C,A,new ue(t,r)),this._addCollisionDebugVertex(v,w,p,C,A,new ue(s,r)),this._addCollisionDebugVertex(v,w,p,C,A,new ue(s,l)),this._addCollisionDebugVertex(v,w,p,C,A,new ue(t,l)),g.vertexLength+=4;let k=u.indexArray;k.emplaceBack(x,x+1),k.emplaceBack(x+1,x+2),k.emplaceBack(x+2,x+3),k.emplaceBack(x+3,x),g.primitiveLength+=4}addDebugCollisionBoxes(t,r,s,l){for(let u=t;u<r;u++){let p=this.collisionBoxArray.get(u);this.addCollisionDebugVertices(p.x1,p.y1,p.x2,p.y2,l?this.textCollisionBox:this.iconCollisionBox,p.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new lh(Yi,Su.members,ci),this.iconCollisionBox=new lh(Yi,Su.members,ci);for(let t=0;t<this.symbolInstances.length;t++){let r=this.symbolInstances.get(t);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(t,r,s,l,u,p,f,g,x){let v={};for(let w=r;w<s;w++){let C=t.get(w);v.textBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},v.textFeatureIndex=C.featureIndex;break}for(let w=l;w<u;w++){let C=t.get(w);v.verticalTextBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},v.verticalTextFeatureIndex=C.featureIndex;break}for(let w=p;w<f;w++){let C=t.get(w);v.iconBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},v.iconFeatureIndex=C.featureIndex;break}for(let w=g;w<x;w++){let C=t.get(w);v.verticalIconBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},v.verticalIconFeatureIndex=C.featureIndex;break}return v}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){let s=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,s.textBoxStartIndex,s.textBoxEndIndex,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s.iconBoxStartIndex,s.iconBoxEndIndex,s.verticalIconBoxStartIndex,s.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(t,r){let s=t.placedSymbolArray.get(r),l=s.vertexStartIndex+4*s.numGlyphs;for(let u=s.vertexStartIndex;u<l;u+=4)t.indexArray.emplaceBack(u,u+1,u+2),t.indexArray.emplaceBack(u+1,u+2,u+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let r=Math.sin(t),s=Math.cos(t),l=[],u=[],p=[];for(let f=0;f<this.symbolInstances.length;++f){p.push(f);let g=this.symbolInstances.get(f);l.push(0|Math.round(r*g.anchorX+s*g.anchorY)),u.push(g.featureIndex)}return p.sort(((f,g)=>l[f]-l[g]||u[g]-u[f])),p}addToSortKeyRanges(t,r){let s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===r?s.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let r of this.symbolInstanceIndexes){let s=this.symbolInstances.get(r);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach(((l,u,p)=>{l>=0&&p.indexOf(l)===u&&this.addIndicesForPlacedSymbol(this.text,l)})),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Uu,ju;ke("SymbolBucket",ko,{omit:["layers","collisionBoxArray","features","compareText"]}),ko.MAX_GLYPHS=65535,ko.addDynamicAttributes=oh;var ch={get paint(){return ju=ju||new h({"icon-opacity":new qe(ae.paint_symbol["icon-opacity"]),"icon-color":new qe(ae.paint_symbol["icon-color"]),"icon-halo-color":new qe(ae.paint_symbol["icon-halo-color"]),"icon-halo-width":new qe(ae.paint_symbol["icon-halo-width"]),"icon-halo-blur":new qe(ae.paint_symbol["icon-halo-blur"]),"icon-translate":new De(ae.paint_symbol["icon-translate"]),"icon-translate-anchor":new De(ae.paint_symbol["icon-translate-anchor"]),"text-opacity":new qe(ae.paint_symbol["text-opacity"]),"text-color":new qe(ae.paint_symbol["text-color"],{runtimeType:Pi,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new qe(ae.paint_symbol["text-halo-color"]),"text-halo-width":new qe(ae.paint_symbol["text-halo-width"]),"text-halo-blur":new qe(ae.paint_symbol["text-halo-blur"]),"text-translate":new De(ae.paint_symbol["text-translate"]),"text-translate-anchor":new De(ae.paint_symbol["text-translate-anchor"])})},get layout(){return Uu=Uu||new h({"symbol-placement":new De(ae.layout_symbol["symbol-placement"]),"symbol-spacing":new De(ae.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new De(ae.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new qe(ae.layout_symbol["symbol-sort-key"]),"symbol-z-order":new De(ae.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new De(ae.layout_symbol["icon-allow-overlap"]),"icon-overlap":new De(ae.layout_symbol["icon-overlap"]),"icon-ignore-placement":new De(ae.layout_symbol["icon-ignore-placement"]),"icon-optional":new De(ae.layout_symbol["icon-optional"]),"icon-rotation-alignment":new De(ae.layout_symbol["icon-rotation-alignment"]),"icon-size":new qe(ae.layout_symbol["icon-size"]),"icon-text-fit":new De(ae.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new De(ae.layout_symbol["icon-text-fit-padding"]),"icon-image":new qe(ae.layout_symbol["icon-image"]),"icon-rotate":new qe(ae.layout_symbol["icon-rotate"]),"icon-padding":new qe(ae.layout_symbol["icon-padding"]),"icon-keep-upright":new De(ae.layout_symbol["icon-keep-upright"]),"icon-offset":new qe(ae.layout_symbol["icon-offset"]),"icon-anchor":new qe(ae.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new De(ae.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new De(ae.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new De(ae.layout_symbol["text-rotation-alignment"]),"text-field":new qe(ae.layout_symbol["text-field"]),"text-font":new qe(ae.layout_symbol["text-font"]),"text-size":new qe(ae.layout_symbol["text-size"]),"text-max-width":new qe(ae.layout_symbol["text-max-width"]),"text-line-height":new De(ae.layout_symbol["text-line-height"]),"text-letter-spacing":new qe(ae.layout_symbol["text-letter-spacing"]),"text-justify":new qe(ae.layout_symbol["text-justify"]),"text-radial-offset":new qe(ae.layout_symbol["text-radial-offset"]),"text-variable-anchor":new De(ae.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new qe(ae.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new qe(ae.layout_symbol["text-anchor"]),"text-max-angle":new De(ae.layout_symbol["text-max-angle"]),"text-writing-mode":new De(ae.layout_symbol["text-writing-mode"]),"text-rotate":new qe(ae.layout_symbol["text-rotate"]),"text-padding":new De(ae.layout_symbol["text-padding"]),"text-keep-upright":new De(ae.layout_symbol["text-keep-upright"]),"text-transform":new qe(ae.layout_symbol["text-transform"]),"text-offset":new qe(ae.layout_symbol["text-offset"]),"text-allow-overlap":new De(ae.layout_symbol["text-allow-overlap"]),"text-overlap":new De(ae.layout_symbol["text-overlap"]),"text-ignore-placement":new De(ae.layout_symbol["text-ignore-placement"]),"text-optional":new De(ae.layout_symbol["text-optional"])})}};class $u{constructor(t){if(t.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:$r,this.defaultValue=t}evaluate(t){if(t.formattedSection){let r=this.defaultValue.property.overrides;if(r&&r.hasOverride(t.formattedSection))return r.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ke("FormatSectionOverride",$u,{omit:["defaultValue"]});class Gl extends n{constructor(t){super(t,ch)}recalculate(t,r){if(super.recalculate(t,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){let s=this.layout.get("text-writing-mode");if(s){let l=[];for(let u of s)l.indexOf(u)<0&&l.push(u);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,r,s,l){let u=this.layout.get(t).evaluate(r,{},s,l),p=this._unevaluatedLayout._values[t];return p.isDataDriven()||ro(p.value)||!u?u:(function(f,g){return g.replace(/{([^{}]+)}/g,((x,v)=>f&&v in f?String(f[v]):""))})(r.properties,u)}createBucket(t){return new ko(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let t of ch.paint.overridableProperties){if(!Gl.hasPaintOverride(this.layout,t))continue;let r=this.paint.get(t),s=new $u(r),l=new io(s,r.property.specification),u=null;u=r.value.kind==="constant"||r.value.kind==="source"?new Fn("source",l):new Bn("composite",l,r.value.zoomStops),this.paint._values[t]=new Cr(r.property,u,r.parameters)}}_handleOverridablePaintPropertyUpdate(t,r,s){return!(!this.layout||r.isDataDriven()||s.isDataDriven())&&Gl.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,r){let s=t.get("text-field"),l=ch.paint.properties[r],u=!1,p=f=>{for(let g of f)if(l.overrides&&l.overrides.hasOverride(g))return void(u=!0)};if(s.value.kind==="constant"&&s.value.value instanceof Bi)p(s.value.value.sections);else if(s.value.kind==="source"){let f=x=>{u||(x instanceof or&&Yt(x.value)===Lr?p(x.value.sections):x instanceof Hs?p(x.sections):x.eachChild(f))},g=s.value;g._styleExpression&&f(g._styleExpression.expression)}return u}}let qu;var Cf={get paint(){return qu=qu||new h({"background-color":new De(ae.paint_background["background-color"]),"background-pattern":new _o(ae.paint_background["background-pattern"]),"background-opacity":new De(ae.paint_background["background-opacity"])})}};class Pf extends n{constructor(t){super(t,Cf)}}let Zu;var Mf={get paint(){return Zu=Zu||new h({"raster-opacity":new De(ae.paint_raster["raster-opacity"]),"raster-hue-rotate":new De(ae.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new De(ae.paint_raster["raster-brightness-min"]),"raster-brightness-max":new De(ae.paint_raster["raster-brightness-max"]),"raster-saturation":new De(ae.paint_raster["raster-saturation"]),"raster-contrast":new De(ae.paint_raster["raster-contrast"]),"raster-resampling":new De(ae.paint_raster["raster-resampling"]),"raster-fade-duration":new De(ae.paint_raster["raster-fade-duration"])})}};class Af extends n{constructor(t){super(t,Mf)}}class Ef extends n{constructor(t){super(t,{}),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=t}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class kf{constructor(t){this._methodToThrottle=t,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}let hh=63710088e-1;class ts{constructor(t,r){if(isNaN(t)||isNaN(r))throw new Error(`Invalid LngLat object: (${t}, ${r})`);if(this.lng=+t,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ts(Pt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let r=Math.PI/180,s=this.lat*r,l=t.lat*r,u=Math.sin(s)*Math.sin(l)+Math.cos(s)*Math.cos(l)*Math.cos((t.lng-this.lng)*r);return hh*Math.acos(Math.min(u,1))}static convert(t){if(t instanceof ts)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new ts(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new ts(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}let Gu=2*Math.PI*hh;function Hu(i){return Gu*Math.cos(i*Math.PI/180)}function Wu(i){return(180+i)/360}function Xu(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function Ku(i,t){return i/Hu(t)}function uh(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class Ua{constructor(t,r,s=0){this.x=+t,this.y=+r,this.z=+s}static fromLngLat(t,r=0){let s=ts.convert(t);return new Ua(Wu(s.lng),Xu(s.lat),Ku(r,s.lat))}toLngLat(){return new ts(360*this.x-180,uh(this.y))}toAltitude(){return this.z*Hu(uh(this.y))}meterInMercatorCoordinateUnits(){return 1/Gu*(t=uh(this.y),1/Math.cos(t*Math.PI/180));var t}}function Ju(i,t,r){var s=2*Math.PI*6378137/256/Math.pow(2,r);return[i*s-2*Math.PI*6378137/2,t*s-2*Math.PI*6378137/2]}class dh{constructor(t,r,s){if(!(function(l,u,p){return!(l<0||l>25||p<0||p>=Math.pow(2,l)||u<0||u>=Math.pow(2,l))})(t,r,s))throw new Error(`x=${r}, y=${s}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=r,this.y=s,this.key=ja(0,t,t,r,s)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,r,s){let l=(p=this.y,f=this.z,g=Ju(256*(u=this.x),256*(p=Math.pow(2,f)-p-1),f),x=Ju(256*(u+1),256*(p+1),f),g[0]+","+g[1]+","+x[0]+","+x[1]);var u,p,f,g,x;let v=(function(w,C,A){let k,L="";for(let O=w;O>0;O--)k=1<<O-1,L+=(C&k?1:0)+(A&k?2:0);return L})(this.z,this.x,this.y);return t[(this.x+this.y)%t.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(s==="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(t){let r=this.z-t.z;return r>0&&t.x===this.x>>r&&t.y===this.y>>r}getTilePoint(t){let r=Math.pow(2,this.z);return new ue((t.x*r-this.x)*Qt,(t.y*r-this.y)*Qt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Yu{constructor(t,r){this.wrap=t,this.canonical=r,this.key=ja(t,r.z,r.z,r.x,r.y)}}class fr{constructor(t,r,s,l,u){if(t<s)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${s}`);this.overscaledZ=t,this.wrap=r,this.canonical=new dh(s,+l,+u),this.key=ja(r,t,s,l,u)}clone(){return new fr(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let r=this.canonical.z-t;return t>this.canonical.z?new fr(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new fr(t,this.wrap,t,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(t,r){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let s=this.canonical.z-t;return t>this.canonical.z?ja(this.wrap*+r,t,this.canonical.z,this.canonical.x,this.canonical.y):ja(this.wrap*+r,t,t,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(t){if(t.wrap!==this.wrap)return!1;let r=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>r&&t.canonical.y===this.canonical.y>>r}children(t){if(this.overscaledZ>=t)return[new fr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let r=this.canonical.z+1,s=2*this.canonical.x,l=2*this.canonical.y;return[new fr(r,this.wrap,r,s,l),new fr(r,this.wrap,r,s+1,l),new fr(r,this.wrap,r,s,l+1),new fr(r,this.wrap,r,s+1,l+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new fr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new fr(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Yu(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new Ua(t.x-this.wrap,t.y))}}function ja(i,t,r,s,l){(i*=2)<0&&(i=-1*i-1);let u=1<<r;return(u*u*i+u*l+s).toString(36)+r.toString(36)+t.toString(36)}ke("CanonicalTileID",dh),ke("OverscaledTileID",fr,{omit:["posMatrix"]});class Qu{constructor(t,r,s,l=1,u=1,p=1,f=0){if(this.uid=t,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(s&&!["mapbox","terrarium","custom"].includes(s))return void ze(`"${s}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=r.height;let g=this.dim=r.height-2;switch(this.data=new Uint32Array(r.data.buffer),s){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=l,this.greenFactor=u,this.blueFactor=p,this.baseShift=f;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let x=0;x<g;x++)this.data[this._idx(-1,x)]=this.data[this._idx(0,x)],this.data[this._idx(g,x)]=this.data[this._idx(g-1,x)],this.data[this._idx(x,-1)]=this.data[this._idx(x,0)],this.data[this._idx(x,g)]=this.data[this._idx(x,g-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(g,-1)]=this.data[this._idx(g-1,0)],this.data[this._idx(-1,g)]=this.data[this._idx(0,g-1)],this.data[this._idx(g,g)]=this.data[this._idx(g-1,g-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let x=0;x<g;x++)for(let v=0;v<g;v++){let w=this.get(x,v);w>this.max&&(this.max=w),w<this.min&&(this.min=w)}}get(t,r){let s=new Uint8Array(this.data.buffer),l=4*this._idx(t,r);return this.unpack(s[l],s[l+1],s[l+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,r){if(t<-1||t>=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(t+1)}unpack(t,r,s){return t*this.redFactor+r*this.greenFactor+s*this.blueFactor-this.baseShift}getPixels(){return new pr({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,r,s){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let l=r*this.dim,u=r*this.dim+this.dim,p=s*this.dim,f=s*this.dim+this.dim;switch(r){case-1:l=u-1;break;case 1:u=l+1}switch(s){case-1:p=f-1;break;case 1:f=p+1}let g=-r*this.dim,x=-s*this.dim;for(let v=p;v<f;v++)for(let w=l;w<u;w++)this.data[this._idx(w,v)]=t.data[this._idx(w+g,v+x)]}}ke("DEMData",Qu);class ed{constructor(t){this._stringToNumber={},this._numberToString=[];for(let r=0;r<t.length;r++){let s=t[r];this._stringToNumber[s]=r,this._numberToString[r]=s}}encode(t){return this._stringToNumber[t]}decode(t){if(t>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class td{constructor(t,r,s,l,u){this.type="Feature",this._vectorTileFeature=t,t._z=r,t._x=s,t._y=l,this.properties=t.properties,this.id=u}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){let t={geometry:this.geometry};for(let r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(t[r]=this[r]);return t}}class id{constructor(t,r){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Un(Qt,16,0),this.grid3D=new Un(Qt,16,0),this.featureIndexArray=new Si,this.promoteId=r}insert(t,r,s,l,u,p){let f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,l,u);let g=p?this.grid3D:this.grid;for(let x=0;x<r.length;x++){let v=r[x],w=[1/0,1/0,-1/0,-1/0];for(let C=0;C<v.length;C++){let A=v[C];w[0]=Math.min(w[0],A.x),w[1]=Math.min(w[1],A.y),w[2]=Math.max(w[2],A.x),w[3]=Math.max(w[3],A.y)}w[0]<Qt&&w[1]<Qt&&w[2]>=0&&w[3]>=0&&g.insert(f,w[0],w[1],w[2],w[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Yn.VectorTile(new eh(this.rawTileData)).layers,this.sourceLayerCoder=new ed(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,r,s,l){this.loadVTLayers();let u=t.params||{},p=Qt/t.tileSize/t.scale,f=aa(u.filter),g=t.queryGeometry,x=t.queryPadding*p,v=nd(g),w=this.grid.query(v.minX-x,v.minY-x,v.maxX+x,v.maxY+x),C=nd(t.cameraQueryGeometry),A=this.grid3D.query(C.minX-x,C.minY-x,C.maxX+x,C.maxY+x,((O,j,re,W)=>(function(te,le,fe,Me,je){for(let Te of te)if(le<=Te.x&&fe<=Te.y&&Me>=Te.x&&je>=Te.y)return!0;let Ce=[new ue(le,fe),new ue(le,je),new ue(Me,je),new ue(Me,fe)];if(te.length>2){for(let Te of Ce)if(To(te,Te))return!0}for(let Te=0;Te<te.length-1;Te++)if(hp(te[Te],te[Te+1],Ce))return!0;return!1})(t.cameraQueryGeometry,O-x,j-x,re+x,W+x)));for(let O of A)w.push(O);w.sort(zf);let k={},L;for(let O=0;O<w.length;O++){let j=w[O];if(j===L)continue;L=j;let re=this.featureIndexArray.get(j),W=null;this.loadMatchingFeature(k,re.bucketIndex,re.sourceLayerIndex,re.featureIndex,f,u.layers,u.availableImages,r,s,l,((te,le,fe)=>(W||(W=Ds(te)),le.queryIntersectsFeature(g,te,fe,W,this.z,t.transform,p,t.pixelPosMatrix))))}return k}loadMatchingFeature(t,r,s,l,u,p,f,g,x,v,w){let C=this.bucketLayerIDs[r];if(p&&!(function(O,j){for(let re=0;re<O.length;re++)if(j.indexOf(O[re])>=0)return!0;return!1})(p,C))return;let A=this.sourceLayerCoder.decode(s),k=this.vtLayers[A].feature(l);if(u.needGeometry){let O=Rs(k,!0);if(!u.filter(new zt(this.tileID.overscaledZ),O,this.tileID.canonical))return}else if(!u.filter(new zt(this.tileID.overscaledZ),k))return;let L=this.getId(k,A);for(let O=0;O<C.length;O++){let j=C[O];if(p&&p.indexOf(j)<0)continue;let re=g[j];if(!re)continue;let W={};L&&v&&(W=v.getState(re.sourceLayer||"_geojsonTileLayer",L));let te=Mt({},x[j]);te.paint=rd(te.paint,re.paint,k,W,f),te.layout=rd(te.layout,re.layout,k,W,f);let le=!w||w(k,re,W);if(!le)continue;let fe=new td(k,this.z,this.x,this.y,L);fe.layer=te;let Me=t[j];Me===void 0&&(Me=t[j]=[]),Me.push({featureIndex:l,feature:fe,intersectionZ:le})}}lookupSymbolFeatures(t,r,s,l,u,p,f,g){let x={};this.loadVTLayers();let v=aa(u);for(let w of t)this.loadMatchingFeature(x,s,l,w,v,p,f,g,r);return x}hasLayer(t){for(let r of this.bucketLayerIDs)for(let s of r)if(t===s)return!0;return!1}getId(t,r){let s=t.id;return this.promoteId&&(s=t.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof s=="boolean"&&(s=Number(s))),s}}function rd(i,t,r,s,l){return ft(i,((u,p)=>{let f=t instanceof Es?t.get(p):null;return f&&f.evaluate?f.evaluate(r,s,l):f}))}function nd(i){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(let u of i)t=Math.min(t,u.x),r=Math.min(r,u.y),s=Math.max(s,u.x),l=Math.max(l,u.y);return{minX:t,minY:r,maxX:s,maxY:l}}function zf(i,t){return t-i}function sd(i,t,r,s,l){let u=[];for(let p=0;p<i.length;p++){let f=i[p],g;for(let x=0;x<f.length-1;x++){let v=f[x],w=f[x+1];v.x<t&&w.x<t||(v.x<t?v=new ue(t,v.y+(t-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x<t&&(w=new ue(t,v.y+(t-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y<r&&w.y<r||(v.y<r?v=new ue(v.x+(r-v.y)/(w.y-v.y)*(w.x-v.x),r)._round():w.y<r&&(w=new ue(v.x+(r-v.y)/(w.y-v.y)*(w.x-v.x),r)._round()),v.x>=s&&w.x>=s||(v.x>=s?v=new ue(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x>=s&&(w=new ue(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y>=l&&w.y>=l||(v.y>=l?v=new ue(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round():w.y>=l&&(w=new ue(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round()),g&&v.equals(g[g.length-1])||(g=[v],u.push(g)),g.push(w)))))}}return u}ke("FeatureIndex",id,{omit:["rawTileData","sourceLayerCoder"]});class is extends ue{constructor(t,r,s,l){super(t,r),this.angle=s,l!==void 0&&(this.segment=l)}clone(){return new is(this.x,this.y,this.angle,this.segment)}}function od(i,t,r,s,l){if(t.segment===void 0||r===0)return!0;let u=t,p=t.segment+1,f=0;for(;f>-r/2;){if(p--,p<0)return!1;f-=i[p].dist(u),u=i[p]}f+=i[p].dist(i[p+1]),p++;let g=[],x=0;for(;f<r/2;){let v=i[p],w=i[p+1];if(!w)return!1;let C=i[p-1].angleTo(v)-v.angleTo(w);for(C=Math.abs((C+3*Math.PI)%(2*Math.PI)-Math.PI),g.push({distance:f,angleDelta:C}),x+=C;f-g[0].distance>s;)x-=g.shift().angleDelta;if(x>l)return!1;p++,f+=v.dist(w)}return!0}function ad(i){let t=0;for(let r=0;r<i.length-1;r++)t+=i[r].dist(i[r+1]);return t}function ld(i,t,r){return i?.6*t*r:0}function cd(i,t){return Math.max(i?i.right-i.left:0,t?t.right-t.left:0)}function Lf(i,t,r,s,l,u){let p=ld(r,l,u),f=cd(r,s)*u,g=0,x=ad(i)/2;for(let v=0;v<i.length-1;v++){let w=i[v],C=i[v+1],A=w.dist(C);if(g+A>x){let k=(x-g)/A,L=Mi.number(w.x,C.x,k),O=Mi.number(w.y,C.y,k),j=new is(L,O,C.angleTo(w),v);return j._round(),!p||od(i,j,f,p,t)?j:void 0}g+=A}}function Df(i,t,r,s,l,u,p,f,g){let x=ld(s,u,p),v=cd(s,l),w=v*p,C=i[0].x===0||i[0].x===g||i[0].y===0||i[0].y===g;return t-w<t/4&&(t=w+t/4),hd(i,C?t/2*f%t:(v/2+2*u)*p*f%t,t,x,r,w,C,!1,g)}function hd(i,t,r,s,l,u,p,f,g){let x=u/2,v=ad(i),w=0,C=t-r,A=[];for(let k=0;k<i.length-1;k++){let L=i[k],O=i[k+1],j=L.dist(O),re=O.angleTo(L);for(;C+r<w+j;){C+=r;let W=(C-w)/j,te=Mi.number(L.x,O.x,W),le=Mi.number(L.y,O.y,W);if(te>=0&&te<g&&le>=0&&le<g&&C-x>=0&&C+x<=v){let fe=new is(te,le,re,k);fe._round(),s&&!od(i,fe,u,s,l)||A.push(fe)}}w+=j}return f||A.length||p||(A=hd(i,w/2,r,s,l,u,p,!0,g)),A}ke("Anchor",is);let zo=$i;function ud(i,t,r,s){let l=[],u=i.image,p=u.pixelRatio,f=u.paddedRect.w-2*zo,g=u.paddedRect.h-2*zo,x={x1:i.left,y1:i.top,x2:i.right,y2:i.bottom},v=u.stretchX||[[0,f]],w=u.stretchY||[[0,g]],C=(he,Oe)=>he+Oe[1]-Oe[0],A=v.reduce(C,0),k=w.reduce(C,0),L=f-A,O=g-k,j=0,re=A,W=0,te=k,le=0,fe=L,Me=0,je=O;if(u.content&&s){let he=u.content,Oe=he[2]-he[0],Fe=he[3]-he[1];(u.textFitWidth||u.textFitHeight)&&(x=Ou(i)),j=Hl(v,0,he[0]),W=Hl(w,0,he[1]),re=Hl(v,he[0],he[2]),te=Hl(w,he[1],he[3]),le=he[0]-j,Me=he[1]-W,fe=Oe-re,je=Fe-te}let Ce=x.x1,Te=x.y1,Be=x.x2-Ce,Le=x.y2-Te,Ee=(he,Oe,Fe,He)=>{let At=Wl(he.stretch-j,re,Be,Ce),It=Xl(he.fixed-le,fe,he.stretch,A),si=Wl(Oe.stretch-W,te,Le,Te),Mr=Xl(Oe.fixed-Me,je,Oe.stretch,k),_i=Wl(Fe.stretch-j,re,Be,Ce),oi=Xl(Fe.fixed-le,fe,Fe.stretch,A),zi=Wl(He.stretch-W,te,Le,Te),Li=Xl(He.fixed-Me,je,He.stretch,k),Di=new ue(At,si),Gt=new ue(_i,si),ai=new ue(_i,zi),Ii=new ue(At,zi),yi=new ue(It/p,Mr/p),Ri=new ue(oi/p,Li/p),xi=t*Math.PI/180;if(xi){let gt=Math.sin(xi),kt=Math.cos(xi),Ft=[kt,-gt,gt,kt];Di._matMult(Ft),Gt._matMult(Ft),Ii._matMult(Ft),ai._matMult(Ft)}let mr=he.stretch+he.fixed,qi=Oe.stretch+Oe.fixed;return{tl:Di,tr:Gt,bl:Ii,br:ai,tex:{x:u.paddedRect.x+zo+mr,y:u.paddedRect.y+zo+qi,w:Fe.stretch+Fe.fixed-mr,h:He.stretch+He.fixed-qi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:yi,pixelOffsetBR:Ri,minFontScaleX:fe/p/Be,minFontScaleY:je/p/Le,isSDF:r}};if(s&&(u.stretchX||u.stretchY)){let he=dd(v,L,A),Oe=dd(w,O,k);for(let Fe=0;Fe<he.length-1;Fe++){let He=he[Fe],At=he[Fe+1];for(let It=0;It<Oe.length-1;It++)l.push(Ee(He,Oe[It],At,Oe[It+1]))}}else l.push(Ee({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:f+1},{fixed:0,stretch:g+1}));return l}function Hl(i,t,r){let s=0;for(let l of i)s+=Math.max(t,Math.min(r,l[1]))-Math.max(t,Math.min(r,l[0]));return s}function dd(i,t,r){let s=[{fixed:-zo,stretch:0}];for(let[l,u]of i){let p=s[s.length-1];s.push({fixed:l-p.stretch,stretch:p.stretch}),s.push({fixed:l-p.stretch,stretch:p.stretch+(u-l)})}return s.push({fixed:t+zo,stretch:r}),s}function Wl(i,t,r,s){return i/t*r+s}function Xl(i,t,r,s){return i-t*r/s}class Kl{constructor(t,r,s,l,u,p,f,g,x,v){var w;if(this.boxStartIndex=t.length,x){let C=p.top,A=p.bottom,k=p.collisionPadding;k&&(C-=k[1],A+=k[3]);let L=A-C;L>0&&(L=Math.max(10,L),this.circleDiameter=L)}else{let C=!((w=p.image)===null||w===void 0)&&w.content&&(p.image.textFitWidth||p.image.textFitHeight)?Ou(p):{x1:p.left,y1:p.top,x2:p.right,y2:p.bottom};C.y1=C.y1*f-g[0],C.y2=C.y2*f+g[2],C.x1=C.x1*f-g[3],C.x2=C.x2*f+g[1];let A=p.collisionPadding;if(A&&(C.x1-=A[0]*f,C.y1-=A[1]*f,C.x2+=A[2]*f,C.y2+=A[3]*f),v){let k=new ue(C.x1,C.y1),L=new ue(C.x2,C.y1),O=new ue(C.x1,C.y2),j=new ue(C.x2,C.y2),re=v*Math.PI/180;k._rotate(re),L._rotate(re),O._rotate(re),j._rotate(re),C.x1=Math.min(k.x,L.x,O.x,j.x),C.x2=Math.max(k.x,L.x,O.x,j.x),C.y1=Math.min(k.y,L.y,O.y,j.y),C.y2=Math.max(k.y,L.y,O.y,j.y)}t.emplaceBack(r.x,r.y,C.x1,C.y1,C.x2,C.y2,s,l,u)}this.boxEndIndex=t.length}}class Rf{constructor(t=[],r=((s,l)=>s<l?-1:s>l?1:0)){if(this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:r,compare:s}=this,l=r[t];for(;t>0;){let u=t-1>>1,p=r[u];if(s(l,p)>=0)break;r[t]=p,t=u}r[t]=l}_down(t){let{data:r,compare:s}=this,l=this.length>>1,u=r[t];for(;t<l;){let p=1+(t<<1),f=p+1;if(f<this.length&&s(r[f],r[p])<0&&(p=f),s(r[p],u)>=0)break;r[t]=r[p],t=p}r[t]=u}}function Ff(i,t=1,r=!1){let s=1/0,l=1/0,u=-1/0,p=-1/0,f=i[0];for(let A=0;A<f.length;A++){let k=f[A];(!A||k.x<s)&&(s=k.x),(!A||k.y<l)&&(l=k.y),(!A||k.x>u)&&(u=k.x),(!A||k.y>p)&&(p=k.y)}let g=Math.min(u-s,p-l),x=g/2,v=new Rf([],Bf);if(g===0)return new ue(s,l);for(let A=s;A<u;A+=g)for(let k=l;k<p;k+=g)v.push(new Lo(A+x,k+x,x,i));let w=(function(A){let k=0,L=0,O=0,j=A[0];for(let re=0,W=j.length,te=W-1;re<W;te=re++){let le=j[re],fe=j[te],Me=le.x*fe.y-fe.x*le.y;L+=(le.x+fe.x)*Me,O+=(le.y+fe.y)*Me,k+=3*Me}return new Lo(L/k,O/k,0,A)})(i),C=v.length;for(;v.length;){let A=v.pop();(A.d>w.d||!w.d)&&(w=A,r&&console.log("found best %d after %d probes",Math.round(1e4*A.d)/1e4,C)),A.max-w.d<=t||(x=A.h/2,v.push(new Lo(A.p.x-x,A.p.y-x,x,i)),v.push(new Lo(A.p.x+x,A.p.y-x,x,i)),v.push(new Lo(A.p.x-x,A.p.y+x,x,i)),v.push(new Lo(A.p.x+x,A.p.y+x,x,i)),C+=4)}return r&&(console.log(`num probes: ${C}`),console.log(`best distance: ${w.d}`)),w.p}function Bf(i,t){return t.max-i.max}function Lo(i,t,r,s){this.p=new ue(i,t),this.h=r,this.d=(function(l,u){let p=!1,f=1/0;for(let g=0;g<u.length;g++){let x=u[g];for(let v=0,w=x.length,C=w-1;v<w;C=v++){let A=x[v],k=x[C];A.y>l.y!=k.y>l.y&&l.x<(k.x-A.x)*(l.y-A.y)/(k.y-A.y)+A.x&&(p=!p),f=Math.min(f,Xh(l,A,k))}}return(p?1:-1)*Math.sqrt(f)})(this.p,s),this.max=this.d+this.h*Math.SQRT2}var gi;I.aq=void 0,(gi=I.aq||(I.aq={}))[gi.center=1]="center",gi[gi.left=2]="left",gi[gi.right=3]="right",gi[gi.top=4]="top",gi[gi.bottom=5]="bottom",gi[gi["top-left"]=6]="top-left",gi[gi["top-right"]=7]="top-right",gi[gi["bottom-left"]=8]="bottom-left",gi[gi["bottom-right"]=9]="bottom-right";let rs=7,ph=Number.POSITIVE_INFINITY;function pd(i,t){return t[1]!==ph?(function(r,s,l){let u=0,p=0;switch(s=Math.abs(s),l=Math.abs(l),r){case"top-right":case"top-left":case"top":p=l-rs;break;case"bottom-right":case"bottom-left":case"bottom":p=-l+rs}switch(r){case"top-right":case"bottom-right":case"right":u=-s;break;case"top-left":case"bottom-left":case"left":u=s}return[u,p]})(i,t[0],t[1]):(function(r,s){let l=0,u=0;s<0&&(s=0);let p=s/Math.SQRT2;switch(r){case"top-right":case"top-left":u=p-rs;break;case"bottom-right":case"bottom-left":u=-p+rs;break;case"bottom":u=-s+rs;break;case"top":u=s-rs}switch(r){case"top-right":case"bottom-right":l=-p;break;case"top-left":case"bottom-left":l=p;break;case"left":l=s;break;case"right":l=-s}return[l,u]})(i,t[0])}function fd(i,t,r){var s;let l=i.layout,u=(s=l.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(t,{},r);if(u){let f=u.values,g=[];for(let x=0;x<f.length;x+=2){let v=g[x]=f[x],w=f[x+1].map((C=>C*ii));v.startsWith("top")?w[1]-=rs:v.startsWith("bottom")&&(w[1]+=rs),g[x+1]=w}return new Gi(g)}let p=l.get("text-variable-anchor");if(p){let f;f=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[l.get("text-radial-offset").evaluate(t,{},r)*ii,ph]:l.get("text-offset").evaluate(t,{},r).map((x=>x*ii));let g=[];for(let x of p)g.push(x,pd(x,f));return new Gi(g)}return null}function fh(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 Of(i,t,r,s,l,u,p,f,g,x,v){let w=u.textMaxSize.evaluate(t,{});w===void 0&&(w=p);let C=i.layers[0].layout,A=C.get("icon-offset").evaluate(t,{},v),k=gd(r.horizontal),L=p/24,O=i.tilePixelRatio*L,j=i.tilePixelRatio*w/24,re=i.tilePixelRatio*f,W=i.tilePixelRatio*C.get("symbol-spacing"),te=C.get("text-padding")*i.tilePixelRatio,le=(function(he,Oe,Fe,He=1){let At=he.get("icon-padding").evaluate(Oe,{},Fe),It=At&&At.values;return[It[0]*He,It[1]*He,It[2]*He,It[3]*He]})(C,t,v,i.tilePixelRatio),fe=C.get("text-max-angle")/180*Math.PI,Me=C.get("text-rotation-alignment")!=="viewport"&&C.get("symbol-placement")!=="point",je=C.get("icon-rotation-alignment")==="map"&&C.get("symbol-placement")!=="point",Ce=C.get("symbol-placement"),Te=W/2,Be=C.get("icon-text-fit"),Le;s&&Be!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(Le=Nu(s,r.vertical,Be,C.get("icon-text-fit-padding"),A,L)),k&&(s=Nu(s,k,Be,C.get("icon-text-fit-padding"),A,L)));let Ee=(he,Oe)=>{Oe.x<0||Oe.x>=Qt||Oe.y<0||Oe.y>=Qt||(function(Fe,He,At,It,si,Mr,_i,oi,zi,Li,Di,Gt,ai,Ii,yi,Ri,xi,mr,qi,gt,kt,Ft,Qi,jt,Do){let Kr=Fe.addToLineVertexArray(He,At),Jr,Ar,gr,hi,yn=0,Za=0,vd=0,bd=0,wh=-1,Sh=-1,xn={},wd=vo("");if(Fe.allowVerticalPlacement&&It.vertical){let Ci=oi.layout.get("text-rotate").evaluate(kt,{},jt)+90;gr=new Kl(zi,He,Li,Di,Gt,It.vertical,ai,Ii,yi,Ci),_i&&(hi=new Kl(zi,He,Li,Di,Gt,_i,xi,mr,yi,Ci))}if(si){let Ci=oi.layout.get("icon-rotate").evaluate(kt,{}),_r=oi.layout.get("icon-text-fit")!=="none",Bs=ud(si,Ci,Qi,_r),Or=_i?ud(_i,Ci,Qi,_r):void 0;Ar=new Kl(zi,He,Li,Di,Gt,si,xi,mr,!1,Ci),yn=4*Bs.length;let Os=Fe.iconSizeData,Yr=null;Os.kind==="source"?(Yr=[Xr*oi.layout.get("icon-size").evaluate(kt,{})],Yr[0]>es&&ze(`${Fe.layerIds[0]}: Value for "icon-size" is >= ${Va}. Reduce your "icon-size".`)):Os.kind==="composite"&&(Yr=[Xr*Ft.compositeIconSizes[0].evaluate(kt,{},jt),Xr*Ft.compositeIconSizes[1].evaluate(kt,{},jt)],(Yr[0]>es||Yr[1]>es)&&ze(`${Fe.layerIds[0]}: Value for "icon-size" is >= ${Va}. Reduce your "icon-size".`)),Fe.addSymbols(Fe.icon,Bs,Yr,gt,qi,kt,I.ah.none,He,Kr.lineStartIndex,Kr.lineLength,-1,jt),wh=Fe.icon.placedSymbolArray.length-1,Or&&(Za=4*Or.length,Fe.addSymbols(Fe.icon,Or,Yr,gt,qi,kt,I.ah.vertical,He,Kr.lineStartIndex,Kr.lineLength,-1,jt),Sh=Fe.icon.placedSymbolArray.length-1)}let Sd=Object.keys(It.horizontal);for(let Ci of Sd){let _r=It.horizontal[Ci];if(!Jr){wd=vo(_r.text);let Or=oi.layout.get("text-rotate").evaluate(kt,{},jt);Jr=new Kl(zi,He,Li,Di,Gt,_r,ai,Ii,yi,Or)}let Bs=_r.positionedLines.length===1;if(vd+=md(Fe,He,_r,Mr,oi,yi,kt,Ri,Kr,It.vertical?I.ah.horizontal:I.ah.horizontalOnly,Bs?Sd:[Ci],xn,wh,Ft,jt),Bs)break}It.vertical&&(bd+=md(Fe,He,It.vertical,Mr,oi,yi,kt,Ri,Kr,I.ah.vertical,["vertical"],xn,Sh,Ft,jt));let Uf=Jr?Jr.boxStartIndex:Fe.collisionBoxArray.length,jf=Jr?Jr.boxEndIndex:Fe.collisionBoxArray.length,$f=gr?gr.boxStartIndex:Fe.collisionBoxArray.length,qf=gr?gr.boxEndIndex:Fe.collisionBoxArray.length,Zf=Ar?Ar.boxStartIndex:Fe.collisionBoxArray.length,Gf=Ar?Ar.boxEndIndex:Fe.collisionBoxArray.length,Hf=hi?hi.boxStartIndex:Fe.collisionBoxArray.length,Wf=hi?hi.boxEndIndex:Fe.collisionBoxArray.length,Br=-1,Yl=(Ci,_r)=>Ci&&Ci.circleDiameter?Math.max(Ci.circleDiameter,_r):_r;Br=Yl(Jr,Br),Br=Yl(gr,Br),Br=Yl(Ar,Br),Br=Yl(hi,Br);let Td=Br>-1?1:0;Td&&(Br*=Do/ii),Fe.glyphOffsetArray.length>=ko.MAX_GLYPHS&&ze("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),kt.sortKey!==void 0&&Fe.addToSortKeyRanges(Fe.symbolInstances.length,kt.sortKey);let Xf=fd(oi,kt,jt),[Kf,Jf]=(function(Ci,_r){let Bs=Ci.length,Or=_r?.values;if(Or?.length>0)for(let Os=0;Os<Or.length;Os+=2){let Yr=Or[Os+1];Ci.emplaceBack(I.aq[Or[Os]],Yr[0],Yr[1])}return[Bs,Ci.length]})(Fe.textAnchorOffsets,Xf);Fe.symbolInstances.emplaceBack(He.x,He.y,xn.right>=0?xn.right:-1,xn.center>=0?xn.center:-1,xn.left>=0?xn.left:-1,xn.vertical||-1,wh,Sh,wd,Uf,jf,$f,qf,Zf,Gf,Hf,Wf,Li,vd,bd,yn,Za,Td,0,ai,Br,Kf,Jf)})(i,Oe,he,r,s,l,Le,i.layers[0],i.collisionBoxArray,t.index,t.sourceLayerIndex,i.index,O,[te,te,te,te],Me,g,re,le,je,A,t,u,x,v,p)};if(Ce==="line")for(let he of sd(t.geometry,0,0,Qt,Qt)){let Oe=Df(he,W,fe,r.vertical||k,s,24,j,i.overscaling,Qt);for(let Fe of Oe)k&&Nf(i,k.text,Te,Fe)||Ee(he,Fe)}else if(Ce==="line-center"){for(let he of t.geometry)if(he.length>1){let Oe=Lf(he,fe,r.vertical||k,s,24,j);Oe&&Ee(he,Oe)}}else if(t.type==="Polygon")for(let he of Xs(t.geometry,0)){let Oe=Ff(he,16);Ee(he[0],new is(Oe.x,Oe.y,0))}else if(t.type==="LineString")for(let he of t.geometry)Ee(he,new is(he[0].x,he[0].y,0));else if(t.type==="Point")for(let he of t.geometry)for(let Oe of he)Ee([Oe],new is(Oe.x,Oe.y,0))}function md(i,t,r,s,l,u,p,f,g,x,v,w,C,A,k){let L=(function(re,W,te,le,fe,Me,je,Ce){let Te=le.layout.get("text-rotate").evaluate(Me,{})*Math.PI/180,Be=[];for(let Le of W.positionedLines)for(let Ee of Le.positionedGlyphs){if(!Ee.rect)continue;let he=Ee.rect||{},Oe=ku+1,Fe=!0,He=1,At=0,It=(fe||Ce)&&Ee.vertical,si=Ee.metrics.advance*Ee.scale/2;if(Ce&&W.verticalizable&&(At=Le.lineOffset/2-(Ee.imageName?-(ii-Ee.metrics.width*Ee.scale)/2:(Ee.scale-1)*ii)),Ee.imageName){let gt=je[Ee.imageName];Fe=gt.sdf,He=gt.pixelRatio,Oe=$i/He}let Mr=fe?[Ee.x+si,Ee.y]:[0,0],_i=fe?[0,0]:[Ee.x+si+te[0],Ee.y+te[1]-At],oi=[0,0];It&&(oi=_i,_i=[0,0]);let zi=Ee.metrics.isDoubleResolution?2:1,Li=(Ee.metrics.left-Oe)*Ee.scale-si+_i[0],Di=(-Ee.metrics.top-Oe)*Ee.scale+_i[1],Gt=Li+he.w/zi*Ee.scale/He,ai=Di+he.h/zi*Ee.scale/He,Ii=new ue(Li,Di),yi=new ue(Gt,Di),Ri=new ue(Li,ai),xi=new ue(Gt,ai);if(It){let gt=new ue(-si,si-Oa),kt=-Math.PI/2,Ft=ii/2-si,Qi=new ue(5-Oa-Ft,-(Ee.imageName?Ft:0)),jt=new ue(...oi);Ii._rotateAround(kt,gt)._add(Qi)._add(jt),yi._rotateAround(kt,gt)._add(Qi)._add(jt),Ri._rotateAround(kt,gt)._add(Qi)._add(jt),xi._rotateAround(kt,gt)._add(Qi)._add(jt)}if(Te){let gt=Math.sin(Te),kt=Math.cos(Te),Ft=[kt,-gt,gt,kt];Ii._matMult(Ft),yi._matMult(Ft),Ri._matMult(Ft),xi._matMult(Ft)}let mr=new ue(0,0),qi=new ue(0,0);Be.push({tl:Ii,tr:yi,bl:Ri,br:xi,tex:he,writingMode:W.writingMode,glyphOffset:Mr,sectionIndex:Ee.sectionIndex,isSDF:Fe,pixelOffsetTL:mr,pixelOffsetBR:qi,minFontScaleX:0,minFontScaleY:0})}return Be})(0,r,f,l,u,p,s,i.allowVerticalPlacement),O=i.textSizeData,j=null;O.kind==="source"?(j=[Xr*l.layout.get("text-size").evaluate(p,{})],j[0]>es&&ze(`${i.layerIds[0]}: Value for "text-size" is >= ${Va}. Reduce your "text-size".`)):O.kind==="composite"&&(j=[Xr*A.compositeTextSizes[0].evaluate(p,{},k),Xr*A.compositeTextSizes[1].evaluate(p,{},k)],(j[0]>es||j[1]>es)&&ze(`${i.layerIds[0]}: Value for "text-size" is >= ${Va}. Reduce your "text-size".`)),i.addSymbols(i.text,L,j,f,u,p,x,t,g.lineStartIndex,g.lineLength,C,k);for(let re of v)w[re]=i.text.placedSymbolArray.length-1;return 4*L.length}function gd(i){for(let t in i)return i[t];return null}function Nf(i,t,r,s){let l=i.compareText;if(t in l){let u=l[t];for(let p=u.length-1;p>=0;p--)if(s.dist(u[p])<r)return!0}else l[t]=[];return l[t].push(s),!1}let _d=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class mh{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");let[r,s]=new Uint8Array(t,0,2);if(r!==219)throw new Error("Data does not appear to be in a KDBush format.");let l=s>>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);let u=_d[15&s];if(!u)throw new Error("Unrecognized array type.");let[p]=new Uint16Array(t,2,1),[f]=new Uint32Array(t,4,1);return new mh(f,p,u,t)}constructor(t,r=64,s=Float64Array,l){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=s,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let u=_d.indexOf(this.ArrayType),p=2*t*this.ArrayType.BYTES_PER_ELEMENT,f=t*this.IndexArrayType.BYTES_PER_ELEMENT,g=(8-f%8)%8;if(u<0)throw new Error(`Unexpected typed array class: ${s}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+g,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+p+f+g),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+g,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+u]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=t)}add(t,r){let s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=t,this.coords[this._pos++]=r,s}finish(){let t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return gh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,r,s,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:u,coords:p,nodeSize:f}=this,g=[0,u.length-1,0],x=[];for(;g.length;){let v=g.pop()||0,w=g.pop()||0,C=g.pop()||0;if(w-C<=f){for(let O=C;O<=w;O++){let j=p[2*O],re=p[2*O+1];j>=t&&j<=s&&re>=r&&re<=l&&x.push(u[O])}continue}let A=C+w>>1,k=p[2*A],L=p[2*A+1];k>=t&&k<=s&&L>=r&&L<=l&&x.push(u[A]),(v===0?t<=k:r<=L)&&(g.push(C),g.push(A-1),g.push(1-v)),(v===0?s>=k:l>=L)&&(g.push(A+1),g.push(w),g.push(1-v))}return x}within(t,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:l,coords:u,nodeSize:p}=this,f=[0,l.length-1,0],g=[],x=s*s;for(;f.length;){let v=f.pop()||0,w=f.pop()||0,C=f.pop()||0;if(w-C<=p){for(let O=C;O<=w;O++)xd(u[2*O],u[2*O+1],t,r)<=x&&g.push(l[O]);continue}let A=C+w>>1,k=u[2*A],L=u[2*A+1];xd(k,L,t,r)<=x&&g.push(l[A]),(v===0?t-s<=k:r-s<=L)&&(f.push(C),f.push(A-1),f.push(1-v)),(v===0?t+s>=k:r+s>=L)&&(f.push(A+1),f.push(w),f.push(1-v))}return g}}function gh(i,t,r,s,l,u){if(l-s<=r)return;let p=s+l>>1;yd(i,t,p,s,l,u),gh(i,t,r,s,p-1,1-u),gh(i,t,r,p+1,l,1-u)}function yd(i,t,r,s,l,u){for(;l>s;){if(l-s>600){let x=l-s+1,v=r-s+1,w=Math.log(x),C=.5*Math.exp(2*w/3),A=.5*Math.sqrt(w*C*(x-C)/x)*(v-x/2<0?-1:1);yd(i,t,r,Math.max(s,Math.floor(r-v*C/x+A)),Math.min(l,Math.floor(r+(x-v)*C/x+A)),u)}let p=t[2*r+u],f=s,g=l;for($a(i,t,s,r),t[2*l+u]>p&&$a(i,t,s,l);f<g;){for($a(i,t,f,g),f++,g--;t[2*f+u]<p;)f++;for(;t[2*g+u]>p;)g--}t[2*s+u]===p?$a(i,t,s,g):(g++,$a(i,t,g,l)),g<=r&&(s=g+1),r<=g&&(l=g-1)}}function $a(i,t,r,s){_h(i,r,s),_h(t,2*r,2*s),_h(t,2*r+1,2*s+1)}function _h(i,t,r){let s=i[t];i[t]=i[r],i[r]=s}function xd(i,t,r,s){let l=i-r,u=t-s;return l*l+u*u}var yh;I.bg=void 0,(yh=I.bg||(I.bg={})).create="create",yh.load="load",yh.fullLoad="fullLoad";let Jl=null,qa=[],xh=1e3/60,vh="loadTime",bh="fullLoadTime",Vf={mark(i){performance.mark(i)},frame(i){let t=i;Jl!=null&&qa.push(t-Jl),Jl=t},clearMetrics(){Jl=null,qa=[],performance.clearMeasures(vh),performance.clearMeasures(bh);for(let i in I.bg)performance.clearMarks(I.bg[i])},getPerformanceMetrics(){performance.measure(vh,I.bg.create,I.bg.load),performance.measure(bh,I.bg.create,I.bg.fullLoad);let i=performance.getEntriesByName(vh)[0].duration,t=performance.getEntriesByName(bh)[0].duration,r=qa.length,s=1/(qa.reduce(((u,p)=>u+p),0)/r/1e3),l=qa.filter((u=>u>xh)).reduce(((u,p)=>u+(p-xh)/xh),0);return{loadTime:i,fullLoadTime:t,fps:s,percentDroppedFrames:l/(r+l)*100,totalFrames:r}}};I.$=class extends S{},I.A=Io,I.B=Ac,I.C=function(i){if(ti==null){let t=i.navigator?i.navigator.userAgent:null;ti=!!i.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return ti},I.D=De,I.E=wn,I.F=class{constructor(i,t){this.target=i,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new kf((()=>this.process())),this.subscription=(function(r,s,l,u){return r.addEventListener(s,l,!1),{unsubscribe:()=>{r.removeEventListener(s,l,!1)}}})(this.target,"message",(r=>this.receive(r))),this.globalScope=ot(self)?i:window}registerMessageHandler(i,t){this.messageHandlers[i]=t}sendAsync(i,t){return new Promise(((r,s)=>{let l=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[l]={resolve:r,reject:s},t&&t.signal.addEventListener("abort",(()=>{delete this.resolveRejects[l];let f={id:l,type:"<cancel>",origin:location.origin,targetMapId:i.targetMapId,sourceMapId:this.mapId};this.target.postMessage(f)}),{once:!0});let u=[],p=Object.assign(Object.assign({},i),{id:l,sourceMapId:this.mapId,origin:location.origin,data:jn(i.data,u)});this.target.postMessage(p,{transfer:u})}))}receive(i){let t=i.data,r=t.id;if(!(t.origin!=="file://"&&location.origin!=="file://"&&t.origin!=="resource://android"&&location.origin!=="resource://android"&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type==="<cancel>"){delete this.tasks[r];let s=this.abortControllers[r];return delete this.abortControllers[r],void(s&&s.abort())}if(ot(self)||t.mustQueue)return this.tasks[r]=t,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,t)}}process(){if(this.taskQueue.length===0)return;let i=this.taskQueue.shift(),t=this.tasks[i];delete this.tasks[i],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(i,t)}processTask(i,t){return d(this,void 0,void 0,(function*(){if(t.type==="<response>"){let l=this.resolveRejects[i];return delete this.resolveRejects[i],l?void(t.error?l.reject($n(t.error)):l.resolve($n(t.data))):void 0}if(!this.messageHandlers[t.type])return void this.completeTask(i,new Error(`Could not find a registered handler for ${t.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));let r=$n(t.data),s=new AbortController;this.abortControllers[i]=s;try{let l=yield this.messageHandlers[t.type](t.sourceMapId,r,s);this.completeTask(i,null,l)}catch(l){this.completeTask(i,l)}}))}completeTask(i,t,r){let s=[];delete this.abortControllers[i];let l={id:i,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?jn(t):null,data:jn(r,s)};this.target.postMessage(l,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},I.G=bn,I.H=function(){var i=new Io(16);return Io!=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},I.I=ih,I.J=function(i,t,r){var s,l,u,p,f,g,x,v,w,C,A,k,L=r[0],O=r[1],j=r[2];return t===i?(i[12]=t[0]*L+t[4]*O+t[8]*j+t[12],i[13]=t[1]*L+t[5]*O+t[9]*j+t[13],i[14]=t[2]*L+t[6]*O+t[10]*j+t[14],i[15]=t[3]*L+t[7]*O+t[11]*j+t[15]):(l=t[1],u=t[2],p=t[3],f=t[4],g=t[5],x=t[6],v=t[7],w=t[8],C=t[9],A=t[10],k=t[11],i[0]=s=t[0],i[1]=l,i[2]=u,i[3]=p,i[4]=f,i[5]=g,i[6]=x,i[7]=v,i[8]=w,i[9]=C,i[10]=A,i[11]=k,i[12]=s*L+f*O+w*j+t[12],i[13]=l*L+g*O+C*j+t[13],i[14]=u*L+x*O+A*j+t[14],i[15]=p*L+v*O+k*j+t[15]),i},I.K=function(i,t,r){var s=r[0],l=r[1],u=r[2];return i[0]=t[0]*s,i[1]=t[1]*s,i[2]=t[2]*s,i[3]=t[3]*s,i[4]=t[4]*l,i[5]=t[5]*l,i[6]=t[6]*l,i[7]=t[7]*l,i[8]=t[8]*u,i[9]=t[9]*u,i[10]=t[10]*u,i[11]=t[11]*u,i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],i},I.L=Qh,I.M=function(i,t){let r={};for(let s=0;s<t.length;s++){let l=t[s];l in i&&(r[l]=i[l])}return r},I.N=ts,I.O=Wu,I.P=ue,I.Q=Xu,I.R=pr,I.S=fr,I.T=mo,I.U=$t,I.V=ri,I.W=ir,I.X=Qt,I.Y=m,I.Z=Ua,I._=d,I.a=Nr,I.a$=function(i,t){var r=i[0],s=i[1],l=i[2],u=i[3],p=i[4],f=i[5],g=i[6],x=i[7],v=i[8],w=i[9],C=i[10],A=i[11],k=i[12],L=i[13],O=i[14],j=i[15],re=t[0],W=t[1],te=t[2],le=t[3],fe=t[4],Me=t[5],je=t[6],Ce=t[7],Te=t[8],Be=t[9],Le=t[10],Ee=t[11],he=t[12],Oe=t[13],Fe=t[14],He=t[15];return Math.abs(r-re)<=ki*Math.max(1,Math.abs(r),Math.abs(re))&&Math.abs(s-W)<=ki*Math.max(1,Math.abs(s),Math.abs(W))&&Math.abs(l-te)<=ki*Math.max(1,Math.abs(l),Math.abs(te))&&Math.abs(u-le)<=ki*Math.max(1,Math.abs(u),Math.abs(le))&&Math.abs(p-fe)<=ki*Math.max(1,Math.abs(p),Math.abs(fe))&&Math.abs(f-Me)<=ki*Math.max(1,Math.abs(f),Math.abs(Me))&&Math.abs(g-je)<=ki*Math.max(1,Math.abs(g),Math.abs(je))&&Math.abs(x-Ce)<=ki*Math.max(1,Math.abs(x),Math.abs(Ce))&&Math.abs(v-Te)<=ki*Math.max(1,Math.abs(v),Math.abs(Te))&&Math.abs(w-Be)<=ki*Math.max(1,Math.abs(w),Math.abs(Be))&&Math.abs(C-Le)<=ki*Math.max(1,Math.abs(C),Math.abs(Le))&&Math.abs(A-Ee)<=ki*Math.max(1,Math.abs(A),Math.abs(Ee))&&Math.abs(k-he)<=ki*Math.max(1,Math.abs(k),Math.abs(he))&&Math.abs(L-Oe)<=ki*Math.max(1,Math.abs(L),Math.abs(Oe))&&Math.abs(O-Fe)<=ki*Math.max(1,Math.abs(O),Math.abs(Fe))&&Math.abs(j-He)<=ki*Math.max(1,Math.abs(j),Math.abs(He))},I.a0=ut,I.a1=dh,I.a2=ye,I.a3=i=>{let t=window.document.createElement("video");return t.muted=!0,new Promise((r=>{t.onloadstart=()=>{r(t)};for(let s of i){let l=window.document.createElement("source");en(s)||(t.crossOrigin="Anonymous"),l.src=s,t.appendChild(l)}}))},I.a4=function(){return Nt++},I.a5=Pe,I.a6=ko,I.a7=aa,I.a8=Rs,I.a9=td,I.aA=function(i){if(i.type==="custom")return new Ef(i);switch(i.type){case"background":return new Pf(i);case"circle":return new pp(i);case"fill":return new Ep(i);case"fill-extrusion":return new Zp(i);case"heatmap":return new mp(i);case"hillshade":return new _p(i);case"line":return new Qp(i);case"raster":return new Af(i);case"symbol":return new Gl(i)}},I.aB=et,I.aC=function(i,t){if(!i)return[{command:"setStyle",args:[t]}];let r=[];try{if(!_t(i.version,t.version))return[{command:"setStyle",args:[t]}];_t(i.center,t.center)||r.push({command:"setCenter",args:[t.center]}),_t(i.zoom,t.zoom)||r.push({command:"setZoom",args:[t.zoom]}),_t(i.bearing,t.bearing)||r.push({command:"setBearing",args:[t.bearing]}),_t(i.pitch,t.pitch)||r.push({command:"setPitch",args:[t.pitch]}),_t(i.sprite,t.sprite)||r.push({command:"setSprite",args:[t.sprite]}),_t(i.glyphs,t.glyphs)||r.push({command:"setGlyphs",args:[t.glyphs]}),_t(i.transition,t.transition)||r.push({command:"setTransition",args:[t.transition]}),_t(i.light,t.light)||r.push({command:"setLight",args:[t.light]}),_t(i.terrain,t.terrain)||r.push({command:"setTerrain",args:[t.terrain]}),_t(i.sky,t.sky)||r.push({command:"setSky",args:[t.sky]}),_t(i.projection,t.projection)||r.push({command:"setProjection",args:[t.projection]});let s={},l=[];(function(p,f,g,x){let v;for(v in f=f||{},p=p||{})Object.prototype.hasOwnProperty.call(p,v)&&(Object.prototype.hasOwnProperty.call(f,v)||jr(v,g,x));for(v in f)Object.prototype.hasOwnProperty.call(f,v)&&(Object.prototype.hasOwnProperty.call(p,v)?_t(p[v],f[v])||(p[v].type==="geojson"&&f[v].type==="geojson"&&Sn(p,f,v)?Vt(g,{command:"setGeoJSONSourceData",args:[v,f[v].data]}):zr(v,f,g,x)):hs(v,f,g))})(i.sources,t.sources,l,s);let u=[];i.layers&&i.layers.forEach((p=>{"source"in p&&s[p.source]?r.push({command:"removeLayer",args:[p.id]}):u.push(p)})),r=r.concat(l),(function(p,f,g){f=f||[];let x=(p=p||[]).map(us),v=f.map(us),w=p.reduce(ds,{}),C=f.reduce(ds,{}),A=x.slice(),k=Object.create(null),L,O,j,re,W;for(let te=0,le=0;te<x.length;te++)L=x[te],Object.prototype.hasOwnProperty.call(C,L)?le++:(Vt(g,{command:"removeLayer",args:[L]}),A.splice(A.indexOf(L,le),1));for(let te=0,le=0;te<v.length;te++)L=v[v.length-1-te],A[A.length-1-te]!==L&&(Object.prototype.hasOwnProperty.call(w,L)?(Vt(g,{command:"removeLayer",args:[L]}),A.splice(A.lastIndexOf(L,A.length-le),1)):le++,re=A[A.length-te],Vt(g,{command:"addLayer",args:[C[L],re]}),A.splice(A.length-te,0,L),k[L]=!0);for(let te=0;te<v.length;te++)if(L=v[te],O=w[L],j=C[L],!k[L]&&!_t(O,j))if(_t(O.source,j.source)&&_t(O["source-layer"],j["source-layer"])&&_t(O.type,j.type)){for(W in Zi(O.layout,j.layout,g,L,null,"setLayoutProperty"),Zi(O.paint,j.paint,g,L,null,"setPaintProperty"),_t(O.filter,j.filter)||Vt(g,{command:"setFilter",args:[L,j.filter]}),_t(O.minzoom,j.minzoom)&&_t(O.maxzoom,j.maxzoom)||Vt(g,{command:"setLayerZoomRange",args:[L,j.minzoom,j.maxzoom]}),O)Object.prototype.hasOwnProperty.call(O,W)&&W!=="layout"&&W!=="paint"&&W!=="filter"&&W!=="metadata"&&W!=="minzoom"&&W!=="maxzoom"&&(W.indexOf("paint.")===0?Zi(O[W],j[W],g,L,W.slice(6),"setPaintProperty"):_t(O[W],j[W])||Vt(g,{command:"setLayerProperty",args:[L,W,j[W]]}));for(W in j)Object.prototype.hasOwnProperty.call(j,W)&&!Object.prototype.hasOwnProperty.call(O,W)&&W!=="layout"&&W!=="paint"&&W!=="filter"&&W!=="metadata"&&W!=="minzoom"&&W!=="maxzoom"&&(W.indexOf("paint.")===0?Zi(O[W],j[W],g,L,W.slice(6),"setPaintProperty"):_t(O[W],j[W])||Vt(g,{command:"setLayerProperty",args:[L,W,j[W]]}))}else Vt(g,{command:"removeLayer",args:[L]}),re=A[A.lastIndexOf(L)+1],Vt(g,{command:"addLayer",args:[j,re]})})(u,t.layers,r)}catch(s){console.warn("Unable to compute style diff:",s),r=[{command:"setStyle",args:[t]}]}return r},I.aD=function(i){let t=[],r=i.id;return r===void 0&&t.push({message:`layers.${r}: missing required property "id"`}),i.render===void 0&&t.push({message:`layers.${r}: missing required method "render"`}),i.renderingMode&&i.renderingMode!=="2d"&&i.renderingMode!=="3d"&&t.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),t},I.aE=function i(t,r){if(Array.isArray(t)){if(!Array.isArray(r)||t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(!i(t[s],r[s]))return!1;return!0}if(typeof t=="object"&&t!==null&&r!==null){if(typeof r!="object"||Object.keys(t).length!==Object.keys(r).length)return!1;for(let s in t)if(!i(t[s],r[s]))return!1;return!0}return t===r},I.aF=ft,I.aG=vi,I.aH=class extends zs{constructor(i,t){super(i,t),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},I.aI=Ll,I.aJ=class extends zs{constructor(i,t){super(i,t),this.current=sp}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 t=1;t<16;t++)if(i[t]!==this.current[t]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},I.aK=jh,I.aL=$h,I.aM=bt,I.aN=class extends zs{constructor(i,t){super(i,t),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]))}},I.aO=class extends zs{constructor(i,t){super(i,t),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]))}},I.aP=function(i,t,r,s,l,u,p){var f=1/(t-r),g=1/(s-l),x=1/(u-p);return i[0]=-2*f,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*g,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*x,i[11]=0,i[12]=(t+r)*f,i[13]=(l+s)*g,i[14]=(p+u)*x,i[15]=1,i},I.aQ=dp,I.aR=class extends J{},I.aS=nf,I.aT=class extends ne{},I.aU=qc,I.aV=function(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))},I.aW=nu,I.aX=fi,I.aY=dr,I.aZ=class extends Re{},I.a_=function(i,t){return i[0]===t[0]&&i[1]===t[1]&&i[2]===t[2]&&i[3]===t[3]&&i[4]===t[4]&&i[5]===t[5]&&i[6]===t[6]&&i[7]===t[7]&&i[8]===t[8]&&i[9]===t[9]&&i[10]===t[10]&&i[11]===t[11]&&i[12]===t[12]&&i[13]===t[13]&&i[14]===t[14]&&i[15]===t[15]},I.aa=function(i){let t={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((r,s,l,u)=>{let p=l||u;return t[s]=!p||p.toLowerCase(),""})),t["max-age"]){let r=parseInt(t["max-age"],10);isNaN(r)?delete t["max-age"]:t["max-age"]=r}return t},I.ab=function(i,t){let r=[];for(let s in i)s in t||r.push(s);return r},I.ac=Ye,I.ad=function(i,t,r){var s=Math.sin(r),l=Math.cos(r),u=t[0],p=t[1],f=t[2],g=t[3],x=t[4],v=t[5],w=t[6],C=t[7];return t!==i&&(i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15]),i[0]=u*l+x*s,i[1]=p*l+v*s,i[2]=f*l+w*s,i[3]=g*l+C*s,i[4]=x*l-u*s,i[5]=v*l-p*s,i[6]=w*l-f*s,i[7]=C*l-g*s,i},I.ae=function(i){var t=new Io(16);return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],t},I.af=Bl,I.ag=function(i,t){let r=0,s=0;if(i.kind==="constant")s=i.layoutSize;else if(i.kind!=="source"){let{interpolationType:l,minZoom:u,maxZoom:p}=i,f=l?Ye(Ai.interpolationFactor(l,t,u,p),0,1):0;i.kind==="camera"?s=Mi.number(i.minSize,i.maxSize,f):r=f}return{uSizeT:r,uSize:s}},I.ai=function(i,{uSize:t,uSizeT:r},{lowerSize:s,upperSize:l}){return i.kind==="source"?s/Xr:i.kind==="composite"?Mi.number(s/Xr,l/Xr,r):t},I.aj=oh,I.ak=function(i,t,r,s){let l=t.y-i.y,u=t.x-i.x,p=s.y-r.y,f=s.x-r.x,g=p*u-f*l;if(g===0)return null;let x=(f*(i.y-r.y)-p*(i.x-r.x))/g;return new ue(i.x+x*u,i.y+x*l)},I.al=sd,I.am=Hh,I.an=Uc,I.ao=function(i){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(let u of i)t=Math.min(t,u.x),r=Math.min(r,u.y),s=Math.max(s,u.x),l=Math.max(l,u.y);return[t,r,s,l]},I.ap=ii,I.ar=sh,I.as=function(i,t){var r=t[0],s=t[1],l=t[2],u=t[3],p=t[4],f=t[5],g=t[6],x=t[7],v=t[8],w=t[9],C=t[10],A=t[11],k=t[12],L=t[13],O=t[14],j=t[15],re=r*f-s*p,W=r*g-l*p,te=r*x-u*p,le=s*g-l*f,fe=s*x-u*f,Me=l*x-u*g,je=v*L-w*k,Ce=v*O-C*k,Te=v*j-A*k,Be=w*O-C*L,Le=w*j-A*L,Ee=C*j-A*O,he=re*Ee-W*Le+te*Be+le*Te-fe*Ce+Me*je;return he?(i[0]=(f*Ee-g*Le+x*Be)*(he=1/he),i[1]=(l*Le-s*Ee-u*Be)*he,i[2]=(L*Me-O*fe+j*le)*he,i[3]=(C*fe-w*Me-A*le)*he,i[4]=(g*Te-p*Ee-x*Ce)*he,i[5]=(r*Ee-l*Te+u*Ce)*he,i[6]=(O*te-k*Me-j*W)*he,i[7]=(v*Me-C*te+A*W)*he,i[8]=(p*Le-f*Te+x*je)*he,i[9]=(s*Te-r*Le-u*je)*he,i[10]=(k*fe-L*te+j*re)*he,i[11]=(w*te-v*fe-A*re)*he,i[12]=(f*Ce-p*Be-g*je)*he,i[13]=(r*Be-s*Ce+l*je)*he,i[14]=(L*W-k*le-O*re)*he,i[15]=(v*le-w*W+C*re)*he,i):null},I.at=fh,I.au=nh,I.av=mh,I.aw=function(){let i={},t=ae.$version;for(let r in ae.$root){let s=ae.$root[r];if(s.required){let l=null;l=r==="version"?t:s.type==="array"?[]:{},l!=null&&(i[r]=l)}}return i},I.ax=ba,I.ay=nr,I.az=function(i){i=i.slice();let t=Object.create(null);for(let r=0;r<i.length;r++)t[i[r].id]=i[r];for(let r=0;r<i.length;r++)"ref"in i[r]&&(i[r]=cs(i[r],t[i[r].ref]));return i},I.b=Ht,I.b0=function(i,t){return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],i},I.b1=function(i,t,r){return i[0]=t[0]*r[0],i[1]=t[1]*r[1],i[2]=t[2]*r[2],i[3]=t[3]*r[3],i},I.b2=function(i,t){return i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+i[3]*t[3]},I.b3=Pt,I.b4=Yu,I.b5=Ku,I.b6=function(i,t,r,s,l){var u,p=1/Math.tan(t/2);return i[0]=p/r,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=p,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+s)*(u=1/(s-l)),i[14]=2*l*s*u):(i[10]=-1,i[14]=-2*s),i},I.b7=function(i,t,r){var s=Math.sin(r),l=Math.cos(r),u=t[4],p=t[5],f=t[6],g=t[7],x=t[8],v=t[9],w=t[10],C=t[11];return t!==i&&(i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15]),i[4]=u*l+x*s,i[5]=p*l+v*s,i[6]=f*l+w*s,i[7]=g*l+C*s,i[8]=x*l-u*s,i[9]=v*l-p*s,i[10]=w*l-f*s,i[11]=C*l-g*s,i},I.b8=Ke,I.b9=$e,I.bA=Tu,I.bB=function(i){return i.message===rr},I.bC=Rn,I.bD=Ui,I.ba=function(i){return i*Math.PI/180},I.bb=function(i,t){let{x:r,y:s}=Ua.fromLngLat(t);return!(i<0||i>25||s<0||s>=1||r<0||r>=1)},I.bc=function(i,t){return i[0]=t[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=t[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=t[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},I.bd=class extends b{},I.be=hh,I.bf=Vf,I.bh=Fi,I.bi=function(i,t){Nr.REGISTERED_PROTOCOLS[i]=t},I.bj=function(i){delete Nr.REGISTERED_PROTOCOLS[i]},I.bk=function(i,t){let r={};for(let l=0;l<i.length;l++){let u=t&&t[i[l].id]||bl(i[l]);t&&(t[i[l].id]=u);let p=r[u];p||(p=r[u]=[]),p.push(i[l])}let s=[];for(let l in r)s.push(r[l]);return s},I.bl=ke,I.bm=ed,I.bn=id,I.bo=Lu,I.bp=function(i){i.bucket.createArrays(),i.bucket.tilePixelRatio=Qt/(512*i.bucket.overscaling),i.bucket.compareText={},i.bucket.iconsNeedLinear=!1;let t=i.bucket.layers[0],r=t.layout,s=t._unevaluatedLayout._values,l={layoutIconSize:s["icon-size"].possiblyEvaluate(new zt(i.bucket.zoom+1),i.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new zt(i.bucket.zoom+1),i.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new zt(18))};if(i.bucket.textSizeData.kind==="composite"){let{minZoom:x,maxZoom:v}=i.bucket.textSizeData;l.compositeTextSizes=[s["text-size"].possiblyEvaluate(new zt(x),i.canonical),s["text-size"].possiblyEvaluate(new zt(v),i.canonical)]}if(i.bucket.iconSizeData.kind==="composite"){let{minZoom:x,maxZoom:v}=i.bucket.iconSizeData;l.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new zt(x),i.canonical),s["icon-size"].possiblyEvaluate(new zt(v),i.canonical)]}let u=r.get("text-line-height")*ii,p=r.get("text-rotation-alignment")!=="viewport"&&r.get("symbol-placement")!=="point",f=r.get("text-keep-upright"),g=r.get("text-size");for(let x of i.bucket.features){let v=r.get("text-font").evaluate(x,{},i.canonical).join(","),w=g.evaluate(x,{},i.canonical),C=l.layoutTextSize.evaluate(x,{},i.canonical),A=l.layoutIconSize.evaluate(x,{},i.canonical),k={horizontal:{},vertical:void 0},L=x.text,O,j=[0,0];if(L){let te=L.toString(),le=r.get("text-letter-spacing").evaluate(x,{},i.canonical)*ii,fe=Ec(te)?le:0,Me=r.get("text-anchor").evaluate(x,{},i.canonical),je=fd(t,x,i.canonical);if(!je){let Le=r.get("text-radial-offset").evaluate(x,{},i.canonical);j=Le?pd(Me,[Le*ii,ph]):r.get("text-offset").evaluate(x,{},i.canonical).map((Ee=>Ee*ii))}let Ce=p?"center":r.get("text-justify").evaluate(x,{},i.canonical),Te=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(x,{},i.canonical)*ii:1/0,Be=()=>{i.bucket.allowVerticalPlacement&&wa(te)&&(k.vertical=$l(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Te,u,Me,"left",fe,j,I.ah.vertical,!0,C,w))};if(!p&&je){let Le=new Set;if(Ce==="auto")for(let he=0;he<je.values.length;he+=2)Le.add(fh(je.values[he]));else Le.add(Ce);let Ee=!1;for(let he of Le)if(!k.horizontal[he])if(Ee)k.horizontal[he]=k.horizontal[0];else{let Oe=$l(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Te,u,"center",he,fe,j,I.ah.horizontal,!1,C,w);Oe&&(k.horizontal[he]=Oe,Ee=Oe.positionedLines.length===1)}Be()}else{Ce==="auto"&&(Ce=fh(Me));let Le=$l(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Te,u,Me,Ce,fe,j,I.ah.horizontal,!1,C,w);Le&&(k.horizontal[Ce]=Le),Be(),wa(te)&&p&&f&&(k.vertical=$l(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Te,u,Me,Ce,fe,j,I.ah.vertical,!1,C,w))}}let re=!1;if(x.icon&&x.icon.name){let te=i.imageMap[x.icon.name];te&&(O=wf(i.imagePositions[x.icon.name],r.get("icon-offset").evaluate(x,{},i.canonical),r.get("icon-anchor").evaluate(x,{},i.canonical)),re=!!te.sdf,i.bucket.sdfIcons===void 0?i.bucket.sdfIcons=re:i.bucket.sdfIcons!==re&&ze("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(te.pixelRatio!==i.bucket.pixelRatio||r.get("icon-rotate").constantOr(1)!==0)&&(i.bucket.iconsNeedLinear=!0))}let W=gd(k.horizontal)||k.vertical;i.bucket.iconsInText=!!W&&W.iconsInText,(W||O)&&Of(i.bucket,x,k,O,i.imageMap,l,C,A,j,re,i.canonical)}i.showCollisionBoxes&&i.bucket.generateCollisionDebugBuffers()},I.bq=Yc,I.br=Xc,I.bs=Jc,I.bt=Yn,I.bu=eh,I.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}},I.bw=function(i,t,r,s,l){return d(this,void 0,void 0,(function*(){if(ri())try{return yield ir(i,t,r,s,l)}catch{}return(function(u,p,f,g,x){let v=u.width,w=u.height;ui&&Wt||(ui=new OffscreenCanvas(v,w),Wt=ui.getContext("2d",{willReadFrequently:!0})),ui.width=v,ui.height=w,Wt.drawImage(u,0,0,v,w);let C=Wt.getImageData(p,f,g,x);return Wt.clearRect(0,0,v,w),C.data})(i,t,r,s,l)}))},I.bx=Qu,I.by=me,I.bz=_e,I.c=vn,I.d=i=>d(void 0,void 0,void 0,(function*(){if(i.byteLength===0)return createImageBitmap(new ImageData(1,1));let t=new Blob([new Uint8Array(i)],{type:"image/png"});try{return createImageBitmap(t)}catch(r){throw new Error(`Could not load image because of ${r.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),I.e=Mt,I.f=i=>new Promise(((t,r)=>{let s=new Image;s.onload=()=>{t(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame((()=>{s.src=tr}))},s.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));let l=new Blob([new Uint8Array(i)],{type:"image/png"});s.src=i.byteLength?URL.createObjectURL(l):tr})),I.g=xr,I.h=(i,t)=>Qr(Mt(i,{type:"json"}),t),I.i=ot,I.j=Ur,I.k=Vr,I.l=(i,t)=>Qr(Mt(i,{type:"arrayBuffer"}),t),I.m=Qr,I.n=function(i){return new eh(i).readFields(mf,[])},I.o=ka,I.p=zu,I.q=h,I.r=Mc,I.s=en,I.t=xa,I.u=fn,I.v=ae,I.w=ze,I.x=function([i,t,r]){return t+=90,t*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(t)*Math.sin(r),y:i*Math.sin(t)*Math.sin(r),z:i*Math.cos(r)}},I.y=Mi,I.z=zt})),Q("worker",["./shared"],(function(I){"use strict";class d{constructor(M){this.keyCache={},M&&this.replace(M)}replace(M){this._layerConfigs={},this._layers={},this.update(M,[])}update(M,P){for(let N of M){this._layerConfigs[N.id]=N;let X=this._layers[N.id]=I.aA(N);X._featureFilter=I.a7(X.filter),this.keyCache[N.id]&&delete this.keyCache[N.id]}for(let N of P)delete this.keyCache[N],delete this._layerConfigs[N],delete this._layers[N];this.familiesBySource={};let R=I.bk(Object.values(this._layerConfigs),this.keyCache);for(let N of R){let X=N.map((se=>this._layers[se.id])),Y=X[0];if(Y.visibility==="none")continue;let ie=Y.source||"",Z=this.familiesBySource[ie];Z||(Z=this.familiesBySource[ie]={});let ce=Y.sourceLayer||"_geojsonTileLayer",pe=Z[ce];pe||(pe=Z[ce]=[]),pe.push(X)}}}class me{constructor(M){let P={},R=[];for(let ie in M){let Z=M[ie],ce=P[ie]={};for(let pe in Z){let se=Z[+pe];if(!se||se.bitmap.width===0||se.bitmap.height===0)continue;let xe={x:0,y:0,w:se.bitmap.width+2,h:se.bitmap.height+2};R.push(xe),ce[pe]={rect:xe,metrics:se.metrics}}}let{w:N,h:X}=I.p(R),Y=new I.o({width:N||1,height:X||1});for(let ie in M){let Z=M[ie];for(let ce in Z){let pe=Z[+ce];if(!pe||pe.bitmap.width===0||pe.bitmap.height===0)continue;let se=P[ie][ce].rect;I.o.copy(pe.bitmap,Y,{x:0,y:0},{x:se.x+1,y:se.y+1},pe.bitmap)}}this.image=Y,this.positions=P}}I.bl("GlyphAtlas",me);class _e{constructor(M){this.tileID=new I.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,P,R,N){return I._(this,void 0,void 0,(function*(){this.status="parsing",this.data=M,this.collisionBoxArray=new I.a5;let X=new I.bm(Object.keys(M.layers).sort()),Y=new I.bn(this.tileID,this.promoteId);Y.bucketLayerIDs=[];let ie={},Z={featureIndex:Y,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:R},ce=P.familiesBySource[this.source];for(let nt in ce){let vt=M.layers[nt];if(!vt)continue;vt.version===1&&I.w(`Vector tile source "${this.source}" layer "${nt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let Ot=X.encode(nt),ni=[];for(let li=0;li<vt.length;li++){let wi=vt.feature(li),Tn=Y.getId(wi,nt);ni.push({feature:wi,id:Tn,index:li,sourceLayerIndex:Ot})}for(let li of ce[nt]){let wi=li[0];wi.source!==this.source&&I.w(`layer.source = ${wi.source} does not equal this.source = ${this.source}`),wi.minzoom&&this.zoom<Math.floor(wi.minzoom)||wi.maxzoom&&this.zoom>=wi.maxzoom||wi.visibility!=="none"&&(Ve(li,this.zoom,R),(ie[wi.id]=wi.createBucket({index:Y.bucketLayerIDs.length,layers:li,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ot,sourceID:this.source})).populate(ni,Z,this.tileID.canonical),Y.bucketLayerIDs.push(li.map((Tn=>Tn.id))))}}let pe=I.aF(Z.glyphDependencies,(nt=>Object.keys(nt).map(Number)));this.inFlightDependencies.forEach((nt=>nt?.abort())),this.inFlightDependencies=[];let se=Promise.resolve({});if(Object.keys(pe).length){let nt=new AbortController;this.inFlightDependencies.push(nt),se=N.sendAsync({type:"GG",data:{stacks:pe,source:this.source,tileID:this.tileID,type:"glyphs"}},nt)}let xe=Object.keys(Z.iconDependencies),Ne=Promise.resolve({});if(xe.length){let nt=new AbortController;this.inFlightDependencies.push(nt),Ne=N.sendAsync({type:"GI",data:{icons:xe,source:this.source,tileID:this.tileID,type:"icons"}},nt)}let Ue=Object.keys(Z.patternDependencies),dt=Promise.resolve({});if(Ue.length){let nt=new AbortController;this.inFlightDependencies.push(nt),dt=N.sendAsync({type:"GI",data:{icons:Ue,source:this.source,tileID:this.tileID,type:"patterns"}},nt)}let[Qe,pt,at]=yield Promise.all([se,Ne,dt]),Jt=new me(Qe),Ut=new I.bo(pt,at);for(let nt in ie){let vt=ie[nt];vt instanceof I.a6?(Ve(vt.layers,this.zoom,R),I.bp({bucket:vt,glyphMap:Qe,glyphPositions:Jt.positions,imageMap:pt,imagePositions:Ut.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):vt.hasPattern&&(vt instanceof I.bq||vt instanceof I.br||vt instanceof I.bs)&&(Ve(vt.layers,this.zoom,R),vt.addFeatures(Z,this.tileID.canonical,Ut.patternPositions))}return this.status="done",{buckets:Object.values(ie).filter((nt=>!nt.isEmpty())),featureIndex:Y,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Jt.image,imageAtlas:Ut,glyphMap:this.returnDependencies?Qe:null,iconMap:this.returnDependencies?pt:null,glyphPositions:this.returnDependencies?Jt.positions:null}}))}}function Ve(U,M,P){let R=new I.z(M);for(let N of U)N.recalculate(R,P)}class ue{constructor(M,P,R){this.actor=M,this.layerIndex=P,this.availableImages=R,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(M,P){return I._(this,void 0,void 0,(function*(){let R=yield I.l(M.request,P);try{return{vectorTile:new I.bt.VectorTile(new I.bu(R.data)),rawData:R.data,cacheControl:R.cacheControl,expires:R.expires}}catch(N){let X=new Uint8Array(R.data),Y=`Unable to parse the tile at ${M.request.url}, `;throw Y+=X[0]===31&&X[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${N.message}`,new Error(Y)}}))}loadTile(M){return I._(this,void 0,void 0,(function*(){let P=M.uid,R=!!(M&&M.request&&M.request.collectResourceTiming)&&new I.bv(M.request),N=new _e(M);this.loading[P]=N;let X=new AbortController;N.abort=X;try{let Y=yield this.loadVectorTile(M,X);if(delete this.loading[P],!Y)return null;let ie=Y.rawData,Z={};Y.expires&&(Z.expires=Y.expires),Y.cacheControl&&(Z.cacheControl=Y.cacheControl);let ce={};if(R){let se=R.finish();se&&(ce.resourceTiming=JSON.parse(JSON.stringify(se)))}N.vectorTile=Y.vectorTile;let pe=N.parse(Y.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[P]=N,this.fetching[P]={rawTileData:ie,cacheControl:Z,resourceTiming:ce};try{let se=yield pe;return I.e({rawTileData:ie.slice(0)},se,Z,ce)}finally{delete this.fetching[P]}}catch(Y){throw delete this.loading[P],N.status="done",this.loaded[P]=N,Y}}))}reloadTile(M){return I._(this,void 0,void 0,(function*(){let P=M.uid;if(!this.loaded||!this.loaded[P])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");let R=this.loaded[P];if(R.showCollisionBoxes=M.showCollisionBoxes,R.status==="parsing"){let N=yield R.parse(R.vectorTile,this.layerIndex,this.availableImages,this.actor),X;if(this.fetching[P]){let{rawTileData:Y,cacheControl:ie,resourceTiming:Z}=this.fetching[P];delete this.fetching[P],X=I.e({rawTileData:Y.slice(0)},N,ie,Z)}else X=N;return X}if(R.status==="done"&&R.vectorTile)return R.parse(R.vectorTile,this.layerIndex,this.availableImages,this.actor)}))}abortTile(M){return I._(this,void 0,void 0,(function*(){let P=this.loading,R=M.uid;P&&P[R]&&P[R].abort&&(P[R].abort.abort(),delete P[R])}))}removeTile(M){return I._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[M.uid]&&delete this.loaded[M.uid]}))}}class H{constructor(){this.loaded={}}loadTile(M){return I._(this,void 0,void 0,(function*(){let{uid:P,encoding:R,rawImageData:N,redFactor:X,greenFactor:Y,blueFactor:ie,baseShift:Z}=M,ce=N.width+2,pe=N.height+2,se=I.b(N)?new I.R({width:ce,height:pe},yield I.bw(N,-1,-1,ce,pe)):N,xe=new I.bx(P,se,R,X,Y,ie,Z);return this.loaded=this.loaded||{},this.loaded[P]=xe,xe}))}removeTile(M){let P=this.loaded,R=M.uid;P&&P[R]&&delete P[R]}}function Xe(U,M){if(U.length!==0){wt(U[0],M);for(var P=1;P<U.length;P++)wt(U[P],!M)}}function wt(U,M){for(var P=0,R=0,N=0,X=U.length,Y=X-1;N<X;Y=N++){var ie=(U[N][0]-U[Y][0])*(U[Y][1]+U[N][1]),Z=P+ie;R+=Math.abs(P)>=Math.abs(ie)?P-Z+ie:ie-Z+P,P=Z}P+R>=0!=!!M&&U.reverse()}var Ct=I.by((function U(M,P){var R,N=M&&M.type;if(N==="FeatureCollection")for(R=0;R<M.features.length;R++)U(M.features[R],P);else if(N==="GeometryCollection")for(R=0;R<M.geometries.length;R++)U(M.geometries[R],P);else if(N==="Feature")U(M.geometry,P);else if(N==="Polygon")Xe(M.coordinates,P);else if(N==="MultiPolygon")for(R=0;R<M.coordinates.length;R++)Xe(M.coordinates[R],P);return M}));let Bt=I.bt.VectorTileFeature.prototype.toGeoJSON;var $t={exports:{}},ri=I.bz,Ke=I.bt.VectorTileFeature,$e=Ye;function Ye(U,M){this.options=M||{},this.features=U,this.length=U.length}function Pt(U,M){this.id=typeof U.id=="number"?U.id:void 0,this.type=U.type,this.rawGeometry=U.type===1?[U.geometry]:U.geometry,this.properties=U.tags,this.extent=M||4096}Ye.prototype.feature=function(U){return new Pt(this.features[U],this.options.extent)},Pt.prototype.loadGeometry=function(){var U=this.rawGeometry;this.geometry=[];for(var M=0;M<U.length;M++){for(var P=U[M],R=[],N=0;N<P.length;N++)R.push(new ri(P[N][0],P[N][1]));this.geometry.push(R)}return this.geometry},Pt.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var U=this.geometry,M=1/0,P=-1/0,R=1/0,N=-1/0,X=0;X<U.length;X++)for(var Y=U[X],ie=0;ie<Y.length;ie++){var Z=Y[ie];M=Math.min(M,Z.x),P=Math.max(P,Z.x),R=Math.min(R,Z.y),N=Math.max(N,Z.y)}return[M,R,P,N]},Pt.prototype.toGeoJSON=Ke.prototype.toGeoJSON;var Mt=I.bA,Nt=$e;function ft(U){var M=new Mt;return(function(P,R){for(var N in P.layers)R.writeMessage(3,vi,P.layers[N])})(U,M),M.finish()}function vi(U,M){var P;M.writeVarintField(15,U.version||1),M.writeStringField(1,U.name||""),M.writeVarintField(5,U.extent||4096);var R={keys:[],values:[],keycache:{},valuecache:{}};for(P=0;P<U.length;P++)R.feature=U.feature(P),M.writeMessage(2,et,R);var N=R.keys;for(P=0;P<N.length;P++)M.writeStringField(3,N[P]);var X=R.values;for(P=0;P<X.length;P++)M.writeMessage(4,ti,X[P])}function et(U,M){var P=U.feature;P.id!==void 0&&M.writeVarintField(1,P.id),M.writeMessage(2,ei,U),M.writeVarintField(3,P.type),M.writeMessage(4,ot,P)}function ei(U,M){var P=U.feature,R=U.keys,N=U.values,X=U.keycache,Y=U.valuecache;for(var ie in P.properties){var Z=P.properties[ie],ce=X[ie];if(Z!==null){ce===void 0&&(R.push(ie),X[ie]=ce=R.length-1),M.writeVarint(ce);var pe=typeof Z;pe!=="string"&&pe!=="boolean"&&pe!=="number"&&(Z=JSON.stringify(Z));var se=pe+":"+Z,xe=Y[se];xe===void 0&&(N.push(Z),Y[se]=xe=N.length-1),M.writeVarint(xe)}}}function ze(U,M){return(M<<3)+(7&U)}function it(U){return U<<1^U>>31}function ot(U,M){for(var P=U.loadGeometry(),R=U.type,N=0,X=0,Y=P.length,ie=0;ie<Y;ie++){var Z=P[ie],ce=1;R===1&&(ce=Z.length),M.writeVarint(ze(1,ce));for(var pe=R===3?Z.length-1:Z.length,se=0;se<pe;se++){se===1&&R!==1&&M.writeVarint(ze(2,pe-1));var xe=Z[se].x-N,Ne=Z[se].y-X;M.writeVarint(it(xe)),M.writeVarint(it(Ne)),N+=xe,X+=Ne}R===3&&M.writeVarint(ze(7,1))}}function ti(U,M){var P=typeof U;P==="string"?M.writeStringField(1,U):P==="boolean"?M.writeBooleanField(7,U):P==="number"&&(U%1!=0?M.writeDoubleField(3,U):U<0?M.writeSVarintField(6,U):M.writeVarintField(5,U))}$t.exports=ft,$t.exports.fromVectorTileJs=ft,$t.exports.fromGeojsonVt=function(U,M){M=M||{};var P={};for(var R in U)P[R]=new Nt(U[R].features,M),P[R].name=R,P[R].version=M.version,P[R].extent=M.extent;return ft({layers:P})},$t.exports.GeoJSONWrapper=Nt;var Ht=I.by($t.exports);let tr={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:U=>U},ir=Math.fround||(ui=new Float32Array(1),U=>(ui[0]=+U,ui[0]));var ui;let Wt=3,rr=5,vn=6;class Nr{constructor(M){this.options=Object.assign(Object.create(tr),M),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(M){let{log:P,minZoom:R,maxZoom:N}=this.options;P&&console.time("total time");let X=`prepare ${M.length} points`;P&&console.time(X),this.points=M;let Y=[];for(let Z=0;Z<M.length;Z++){let ce=M[Z];if(!ce.geometry)continue;let[pe,se]=ce.geometry.coordinates,xe=ir(Fi(pe)),Ne=ir(nr(se));Y.push(xe,Ne,1/0,Z,-1,1),this.options.reduce&&Y.push(0)}let ie=this.trees[N+1]=this._createTree(Y);P&&console.timeEnd(X);for(let Z=N;Z>=R;Z--){let ce=+Date.now();ie=this.trees[Z]=this._createTree(this._cluster(ie,Z)),P&&console.log("z%d: %d clusters in %dms",Z,ie.numItems,+Date.now()-ce)}return P&&console.timeEnd("total time"),this}getClusters(M,P){let R=((M[0]+180)%360+360)%360-180,N=Math.max(-90,Math.min(90,M[1])),X=M[2]===180?180:((M[2]+180)%360+360)%360-180,Y=Math.max(-90,Math.min(90,M[3]));if(M[2]-M[0]>=360)R=-180,X=180;else if(R>X){let se=this.getClusters([R,N,180,Y],P),xe=this.getClusters([-180,N,X,Y],P);return se.concat(xe)}let ie=this.trees[this._limitZoom(P)],Z=ie.range(Fi(R),nr(Y),Fi(X),nr(N)),ce=ie.data,pe=[];for(let se of Z){let xe=this.stride*se;pe.push(ce[xe+rr]>1?xr(ce,xe,this.clusterProps):this.points[ce[xe+Wt]])}return pe}getChildren(M){let P=this._getOriginId(M),R=this._getOriginZoom(M),N="No cluster with the specified id.",X=this.trees[R];if(!X)throw new Error(N);let Y=X.data;if(P*this.stride>=Y.length)throw new Error(N);let ie=this.options.radius/(this.options.extent*Math.pow(2,R-1)),Z=X.within(Y[P*this.stride],Y[P*this.stride+1],ie),ce=[];for(let pe of Z){let se=pe*this.stride;Y[se+4]===M&&ce.push(Y[se+rr]>1?xr(Y,se,this.clusterProps):this.points[Y[se+Wt]])}if(ce.length===0)throw new Error(N);return ce}getLeaves(M,P,R){let N=[];return this._appendLeaves(N,M,P=P||10,R=R||0,0),N}getTile(M,P,R){let N=this.trees[this._limitZoom(M)],X=Math.pow(2,M),{extent:Y,radius:ie}=this.options,Z=ie/Y,ce=(R-Z)/X,pe=(R+1+Z)/X,se={features:[]};return this._addTileFeatures(N.range((P-Z)/X,ce,(P+1+Z)/X,pe),N.data,P,R,X,se),P===0&&this._addTileFeatures(N.range(1-Z/X,ce,1,pe),N.data,X,R,X,se),P===X-1&&this._addTileFeatures(N.range(0,ce,Z/X,pe),N.data,-1,R,X,se),se.features.length?se:null}getClusterExpansionZoom(M){let P=this._getOriginZoom(M)-1;for(;P<=this.options.maxZoom;){let R=this.getChildren(M);if(P++,R.length!==1)break;M=R[0].properties.cluster_id}return P}_appendLeaves(M,P,R,N,X){let Y=this.getChildren(P);for(let ie of Y){let Z=ie.properties;if(Z&&Z.cluster?X+Z.point_count<=N?X+=Z.point_count:X=this._appendLeaves(M,Z.cluster_id,R,N,X):X<N?X++:M.push(ie),M.length===R)break}return X}_createTree(M){let P=new I.av(M.length/this.stride|0,this.options.nodeSize,Float32Array);for(let R=0;R<M.length;R+=this.stride)P.add(M[R],M[R+1]);return P.finish(),P.data=M,P}_addTileFeatures(M,P,R,N,X,Y){for(let ie of M){let Z=ie*this.stride,ce=P[Z+rr]>1,pe,se,xe;if(ce)pe=bn(P,Z,this.clusterProps),se=P[Z],xe=P[Z+1];else{let dt=this.points[P[Z+Wt]];pe=dt.properties;let[Qe,pt]=dt.geometry.coordinates;se=Fi(Qe),xe=nr(pt)}let Ne={type:1,geometry:[[Math.round(this.options.extent*(se*X-R)),Math.round(this.options.extent*(xe*X-N))]],tags:pe},Ue;Ue=ce||this.options.generateId?P[Z+Wt]:this.points[P[Z+Wt]].id,Ue!==void 0&&(Ne.id=Ue),Y.features.push(Ne)}}_limitZoom(M){return Math.max(this.options.minZoom,Math.min(Math.floor(+M),this.options.maxZoom+1))}_cluster(M,P){let{radius:R,extent:N,reduce:X,minPoints:Y}=this.options,ie=R/(N*Math.pow(2,P)),Z=M.data,ce=[],pe=this.stride;for(let se=0;se<Z.length;se+=pe){if(Z[se+2]<=P)continue;Z[se+2]=P;let xe=Z[se],Ne=Z[se+1],Ue=M.within(Z[se],Z[se+1],ie),dt=Z[se+rr],Qe=dt;for(let pt of Ue){let at=pt*pe;Z[at+2]>P&&(Qe+=Z[at+rr])}if(Qe>dt&&Qe>=Y){let pt,at=xe*dt,Jt=Ne*dt,Ut=-1,nt=((se/pe|0)<<5)+(P+1)+this.points.length;for(let vt of Ue){let Ot=vt*pe;if(Z[Ot+2]<=P)continue;Z[Ot+2]=P;let ni=Z[Ot+rr];at+=Z[Ot]*ni,Jt+=Z[Ot+1]*ni,Z[Ot+4]=nt,X&&(pt||(pt=this._map(Z,se,!0),Ut=this.clusterProps.length,this.clusterProps.push(pt)),X(pt,this._map(Z,Ot)))}Z[se+4]=nt,ce.push(at/Qe,Jt/Qe,1/0,nt,-1,Qe),X&&ce.push(Ut)}else{for(let pt=0;pt<pe;pt++)ce.push(Z[se+pt]);if(Qe>1)for(let pt of Ue){let at=pt*pe;if(!(Z[at+2]<=P)){Z[at+2]=P;for(let Jt=0;Jt<pe;Jt++)ce.push(Z[at+Jt])}}}}return ce}_getOriginId(M){return M-this.points.length>>5}_getOriginZoom(M){return(M-this.points.length)%32}_map(M,P,R){if(M[P+rr]>1){let Y=this.clusterProps[M[P+vn]];return R?Object.assign({},Y):Y}let N=this.points[M[P+Wt]].properties,X=this.options.map(N);return R&&X===N?Object.assign({},X):X}}function xr(U,M,P){return{type:"Feature",id:U[M+Wt],properties:bn(U,M,P),geometry:{type:"Point",coordinates:[(R=U[M],360*(R-.5)),Qr(U[M+1])]}};var R}function bn(U,M,P){let R=U[M+rr],N=R>=1e4?`${Math.round(R/1e3)}k`:R>=1e3?Math.round(R/100)/10+"k":R,X=U[M+vn],Y=X===-1?{}:Object.assign({},P[X]);return Object.assign(Y,{cluster:!0,cluster_id:U[M+Wt],point_count:R,point_count_abbreviated:N})}function Fi(U){return U/360+.5}function nr(U){let M=Math.sin(U*Math.PI/180),P=.5-.25*Math.log((1+M)/(1-M))/Math.PI;return P<0?0:P>1?1:P}function Qr(U){let M=(180-360*U)*Math.PI/180;return 360*Math.atan(Math.exp(M))/Math.PI-90}function en(U,M,P,R){let N=R,X=M+(P-M>>1),Y,ie=P-M,Z=U[M],ce=U[M+1],pe=U[P],se=U[P+1];for(let xe=M+3;xe<P;xe+=3){let Ne=ls(U[xe],U[xe+1],Z,ce,pe,se);if(Ne>N)Y=xe,N=Ne;else if(Ne===N){let Ue=Math.abs(xe-X);Ue<ie&&(Y=xe,ie=Ue)}}N>R&&(Y-M>3&&en(U,M,Y,R),U[Y+2]=N,P-Y>3&&en(U,Y,P,R))}function ls(U,M,P,R,N,X){let Y=N-P,ie=X-R;if(Y!==0||ie!==0){let Z=((U-P)*Y+(M-R)*ie)/(Y*Y+ie*ie);Z>1?(P=N,R=X):Z>0&&(P+=Y*Z,R+=ie*Z)}return Y=U-P,ie=M-R,Y*Y+ie*ie}function kr(U,M,P,R){let N={id:U??null,type:M,geometry:P,tags:R,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(M==="Point"||M==="MultiPoint"||M==="LineString")Vr(N,P);else if(M==="Polygon")Vr(N,P[0]);else if(M==="MultiLineString")for(let X of P)Vr(N,X);else if(M==="MultiPolygon")for(let X of P)Vr(N,X[0]);return N}function Vr(U,M){for(let P=0;P<M.length;P+=3)U.minX=Math.min(U.minX,M[P]),U.minY=Math.min(U.minY,M[P+1]),U.maxX=Math.max(U.maxX,M[P]),U.maxY=Math.max(U.maxY,M[P+1])}function Ur(U,M,P,R){if(!M.geometry)return;let N=M.geometry.coordinates;if(N&&N.length===0)return;let X=M.geometry.type,Y=Math.pow(P.tolerance/((1<<P.maxZoom)*P.extent),2),ie=[],Z=M.id;if(P.promoteId?Z=M.properties[P.promoteId]:P.generateId&&(Z=R||0),X==="Point")wn(N,ie);else if(X==="MultiPoint")for(let ce of N)wn(ce,ie);else if(X==="LineString")ae(N,ie,Y,!1);else if(X==="MultiLineString"){if(P.lineMetrics){for(let ce of N)ie=[],ae(ce,ie,Y,!1),U.push(kr(Z,"LineString",ie,M.properties));return}tn(N,ie,Y,!1)}else if(X==="Polygon")tn(N,ie,Y,!0);else{if(X!=="MultiPolygon"){if(X==="GeometryCollection"){for(let ce of M.geometry.geometries)Ur(U,{id:Z,geometry:ce,properties:M.properties},P,R);return}throw new Error("Input data is not a valid GeoJSON object.")}for(let ce of N){let pe=[];tn(ce,pe,Y,!0),ie.push(pe)}}U.push(kr(Z,X,ie,M.properties))}function wn(U,M){M.push(cs(U[0]),_t(U[1]),0)}function ae(U,M,P,R){let N,X,Y=0;for(let Z=0;Z<U.length;Z++){let ce=cs(U[Z][0]),pe=_t(U[Z][1]);M.push(ce,pe,0),Z>0&&(Y+=R?(N*pe-ce*X)/2:Math.sqrt(Math.pow(ce-N,2)+Math.pow(pe-X,2))),N=ce,X=pe}let ie=M.length-3;M[2]=1,en(M,0,ie,P),M[ie+2]=1,M.size=Math.abs(Y),M.start=0,M.end=M.size}function tn(U,M,P,R){for(let N=0;N<U.length;N++){let X=[];ae(U[N],X,P,R),M.push(X)}}function cs(U){return U/360+.5}function _t(U){let M=Math.sin(U*Math.PI/180),P=.5-.25*Math.log((1+M)/(1-M))/Math.PI;return P<0?0:P>1?1:P}function Vt(U,M,P,R,N,X,Y,ie){if(R/=M,X>=(P/=M)&&Y<R)return U;if(Y<P||X>=R)return null;let Z=[];for(let ce of U){let pe=ce.geometry,se=ce.type,xe=N===0?ce.minX:ce.minY,Ne=N===0?ce.maxX:ce.maxY;if(xe>=P&&Ne<R){Z.push(ce);continue}if(Ne<P||xe>=R)continue;let Ue=[];if(se==="Point"||se==="MultiPoint")hs(pe,Ue,P,R,N);else if(se==="LineString")jr(pe,Ue,P,R,N,!1,ie.lineMetrics);else if(se==="MultiLineString")Sn(pe,Ue,P,R,N,!1);else if(se==="Polygon")Sn(pe,Ue,P,R,N,!0);else if(se==="MultiPolygon")for(let dt of pe){let Qe=[];Sn(dt,Qe,P,R,N,!0),Qe.length&&Ue.push(Qe)}if(Ue.length){if(ie.lineMetrics&&se==="LineString"){for(let dt of Ue)Z.push(kr(ce.id,se,dt,ce.tags));continue}se!=="LineString"&&se!=="MultiLineString"||(Ue.length===1?(se="LineString",Ue=Ue[0]):se="MultiLineString"),se!=="Point"&&se!=="MultiPoint"||(se=Ue.length===3?"Point":"MultiPoint"),Z.push(kr(ce.id,se,Ue,ce.tags))}}return Z.length?Z:null}function hs(U,M,P,R,N){for(let X=0;X<U.length;X+=3){let Y=U[X+N];Y>=P&&Y<=R&&Zi(M,U[X],U[X+1],U[X+2])}}function jr(U,M,P,R,N,X,Y){let ie=zr(U),Z=N===0?us:ds,ce,pe,se=U.start;for(let Qe=0;Qe<U.length-3;Qe+=3){let pt=U[Qe],at=U[Qe+1],Jt=U[Qe+2],Ut=U[Qe+3],nt=U[Qe+4],vt=N===0?pt:at,Ot=N===0?Ut:nt,ni=!1;Y&&(ce=Math.sqrt(Math.pow(pt-Ut,2)+Math.pow(at-nt,2))),vt<P?Ot>P&&(pe=Z(ie,pt,at,Ut,nt,P),Y&&(ie.start=se+ce*pe)):vt>R?Ot<R&&(pe=Z(ie,pt,at,Ut,nt,R),Y&&(ie.start=se+ce*pe)):Zi(ie,pt,at,Jt),Ot<P&&vt>=P&&(pe=Z(ie,pt,at,Ut,nt,P),ni=!0),Ot>R&&vt<=R&&(pe=Z(ie,pt,at,Ut,nt,R),ni=!0),!X&&ni&&(Y&&(ie.end=se+ce*pe),M.push(ie),ie=zr(U)),Y&&(se+=ce)}let xe=U.length-3,Ne=U[xe],Ue=U[xe+1],dt=N===0?Ne:Ue;dt>=P&&dt<=R&&Zi(ie,Ne,Ue,U[xe+2]),xe=ie.length-3,X&&xe>=3&&(ie[xe]!==ie[0]||ie[xe+1]!==ie[1])&&Zi(ie,ie[0],ie[1],ie[2]),ie.length&&M.push(ie)}function zr(U){let M=[];return M.size=U.size,M.start=U.start,M.end=U.end,M}function Sn(U,M,P,R,N,X){for(let Y of U)jr(Y,M,P,R,N,X,!1)}function Zi(U,M,P,R){U.push(M,P,R)}function us(U,M,P,R,N,X){let Y=(X-M)/(R-M);return Zi(U,X,P+(N-P)*Y,1),Y}function ds(U,M,P,R,N,X){let Y=(X-P)/(N-P);return Zi(U,M+(R-M)*Y,X,1),Y}function ye(U,M){let P=[];for(let R=0;R<U.length;R++){let N=U[R],X=N.type,Y;if(X==="Point"||X==="MultiPoint"||X==="LineString")Y=vr(N.geometry,M);else if(X==="MultiLineString"||X==="Polygon"){Y=[];for(let ie of N.geometry)Y.push(vr(ie,M))}else if(X==="MultiPolygon"){Y=[];for(let ie of N.geometry){let Z=[];for(let ce of ie)Z.push(vr(ce,M));Y.push(Z)}}P.push(kr(N.id,X,Y,N.tags))}return P}function vr(U,M){let P=[];P.size=U.size,U.start!==void 0&&(P.start=U.start,P.end=U.end);for(let R=0;R<U.length;R+=3)P.push(U[R]+M,U[R+1],U[R+2]);return P}function bi(U,M){if(U.transformed)return U;let P=1<<U.z,R=U.x,N=U.y;for(let X of U.features){let Y=X.geometry,ie=X.type;if(X.geometry=[],ie===1)for(let Z=0;Z<Y.length;Z+=2)X.geometry.push(br(Y[Z],Y[Z+1],M,P,R,N));else for(let Z=0;Z<Y.length;Z++){let ce=[];for(let pe=0;pe<Y[Z].length;pe+=2)ce.push(br(Y[Z][pe],Y[Z][pe+1],M,P,R,N));X.geometry.push(ce)}}return U.transformed=!0,U}function br(U,M,P,R,N,X){return[Math.round(P*(U*R-N)),Math.round(P*(M*R-X))]}function $r(U,M,P,R,N){let X=M===N.maxZoom?0:N.tolerance/((1<<M)*N.extent),Y={features:[],numPoints:0,numSimplified:0,numFeatures:U.length,source:null,x:P,y:R,z:M,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(let ie of U)we(Y,ie,X,N);return Y}function we(U,M,P,R){let N=M.geometry,X=M.type,Y=[];if(U.minX=Math.min(U.minX,M.minX),U.minY=Math.min(U.minY,M.minY),U.maxX=Math.max(U.maxX,M.maxX),U.maxY=Math.max(U.maxY,M.maxY),X==="Point"||X==="MultiPoint")for(let ie=0;ie<N.length;ie+=3)Y.push(N[ie],N[ie+1]),U.numPoints++,U.numSimplified++;else if(X==="LineString")rt(Y,N,U,P,!1,!1);else if(X==="MultiLineString"||X==="Polygon")for(let ie=0;ie<N.length;ie++)rt(Y,N[ie],U,P,X==="Polygon",ie===0);else if(X==="MultiPolygon")for(let ie=0;ie<N.length;ie++){let Z=N[ie];for(let ce=0;ce<Z.length;ce++)rt(Y,Z[ce],U,P,!0,ce===0)}if(Y.length){let ie=M.tags||null;if(X==="LineString"&&R.lineMetrics){ie={};for(let ce in M.tags)ie[ce]=M.tags[ce];ie.mapbox_clip_start=N.start/N.size,ie.mapbox_clip_end=N.end/N.size}let Z={geometry:Y,type:X==="Polygon"||X==="MultiPolygon"?3:X==="LineString"||X==="MultiLineString"?2:1,tags:ie};M.id!==null&&(Z.id=M.id),U.features.push(Z)}}function rt(U,M,P,R,N,X){let Y=R*R;if(R>0&&M.size<(N?Y:R))return void(P.numPoints+=M.length/3);let ie=[];for(let Z=0;Z<M.length;Z+=3)(R===0||M[Z+2]>Y)&&(P.numSimplified++,ie.push(M[Z],M[Z+1])),P.numPoints++;N&&(function(Z,ce){let pe=0;for(let se=0,xe=Z.length,Ne=xe-2;se<xe;Ne=se,se+=2)pe+=(Z[se]-Z[Ne])*(Z[se+1]+Z[Ne+1]);if(pe>0===ce)for(let se=0,xe=Z.length;se<xe/2;se+=2){let Ne=Z[se],Ue=Z[se+1];Z[se]=Z[xe-2-se],Z[se+1]=Z[xe-1-se],Z[xe-2-se]=Ne,Z[xe-1-se]=Ue}})(ie,X),U.push(ie)}let Ze={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class Pi{constructor(M,P){let R=(P=this.options=(function(X,Y){for(let ie in Y)X[ie]=Y[ie];return X})(Object.create(Ze),P)).debug;if(R&&console.time("preprocess data"),P.maxZoom<0||P.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(P.promoteId&&P.generateId)throw new Error("promoteId and generateId cannot be used together.");let N=(function(X,Y){let ie=[];if(X.type==="FeatureCollection")for(let Z=0;Z<X.features.length;Z++)Ur(ie,X.features[Z],Y,Z);else Ur(ie,X.type==="Feature"?X:{geometry:X},Y);return ie})(M,P);this.tiles={},this.tileCoords=[],R&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",P.indexMaxZoom,P.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),N=(function(X,Y){let ie=Y.buffer/Y.extent,Z=X,ce=Vt(X,1,-1-ie,ie,0,-1,2,Y),pe=Vt(X,1,1-ie,2+ie,0,-1,2,Y);return(ce||pe)&&(Z=Vt(X,1,-ie,1+ie,0,-1,2,Y)||[],ce&&(Z=ye(ce,1).concat(Z)),pe&&(Z=Z.concat(ye(pe,-1)))),Z})(N,P),N.length&&this.splitTile(N,0,0,0),R&&(N.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,P,R,N,X,Y,ie){let Z=[M,P,R,N],ce=this.options,pe=ce.debug;for(;Z.length;){N=Z.pop(),R=Z.pop(),P=Z.pop(),M=Z.pop();let se=1<<P,xe=sr(P,R,N),Ne=this.tiles[xe];if(!Ne&&(pe>1&&console.time("creation"),Ne=this.tiles[xe]=$r(M,P,R,N,ce),this.tileCoords.push({z:P,x:R,y:N}),pe)){pe>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",P,R,N,Ne.numFeatures,Ne.numPoints,Ne.numSimplified),console.timeEnd("creation"));let ni=`z${P}`;this.stats[ni]=(this.stats[ni]||0)+1,this.total++}if(Ne.source=M,X==null){if(P===ce.indexMaxZoom||Ne.numPoints<=ce.indexMaxPoints)continue}else{if(P===ce.maxZoom||P===X)continue;if(X!=null){let ni=X-P;if(R!==Y>>ni||N!==ie>>ni)continue}}if(Ne.source=null,M.length===0)continue;pe>1&&console.time("clipping");let Ue=.5*ce.buffer/ce.extent,dt=.5-Ue,Qe=.5+Ue,pt=1+Ue,at=null,Jt=null,Ut=null,nt=null,vt=Vt(M,se,R-Ue,R+Qe,0,Ne.minX,Ne.maxX,ce),Ot=Vt(M,se,R+dt,R+pt,0,Ne.minX,Ne.maxX,ce);M=null,vt&&(at=Vt(vt,se,N-Ue,N+Qe,1,Ne.minY,Ne.maxY,ce),Jt=Vt(vt,se,N+dt,N+pt,1,Ne.minY,Ne.maxY,ce),vt=null),Ot&&(Ut=Vt(Ot,se,N-Ue,N+Qe,1,Ne.minY,Ne.maxY,ce),nt=Vt(Ot,se,N+dt,N+pt,1,Ne.minY,Ne.maxY,ce),Ot=null),pe>1&&console.timeEnd("clipping"),Z.push(at||[],P+1,2*R,2*N),Z.push(Jt||[],P+1,2*R,2*N+1),Z.push(Ut||[],P+1,2*R+1,2*N),Z.push(nt||[],P+1,2*R+1,2*N+1)}}getTile(M,P,R){M=+M,P=+P,R=+R;let N=this.options,{extent:X,debug:Y}=N;if(M<0||M>24)return null;let ie=1<<M,Z=sr(M,P=P+ie&ie-1,R);if(this.tiles[Z])return bi(this.tiles[Z],X);Y>1&&console.log("drilling down to z%d-%d-%d",M,P,R);let ce,pe=M,se=P,xe=R;for(;!ce&&pe>0;)pe--,se>>=1,xe>>=1,ce=this.tiles[sr(pe,se,xe)];return ce&&ce.source?(Y>1&&(console.log("found parent tile z%d-%d-%d",pe,se,xe),console.time("drilling down")),this.splitTile(ce.source,pe,se,xe,M,P,R),Y>1&&console.timeEnd("drilling down"),this.tiles[Z]?bi(this.tiles[Z],X):null):null}}function sr(U,M,P){return 32*((1<<U)*P+M)+U}function Je(U,M){return M?U.properties[M]:U.id}function wr(U,M){if(U==null)return!0;if(U.type==="Feature")return Je(U,M)!=null;if(U.type==="FeatureCollection"){let P=new Set;for(let R of U.features){let N=Je(R,M);if(N==null||P.has(N))return!1;P.add(N)}return!0}return!1}function Lr(U,M){let P=new Map;if(U!=null)if(U.type==="Feature")P.set(Je(U,M),U);else for(let R of U.features)P.set(Je(R,M),R);return P}class qr extends ue{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(M,P){return I._(this,void 0,void 0,(function*(){let R=M.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");let N=this._geoJSONIndex.getTile(R.z,R.x,R.y);if(!N)return null;let X=new class{constructor(ie){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=I.X,this.length=ie.length,this._features=ie}feature(ie){return new class{constructor(Z){this._feature=Z,this.extent=I.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){let Z=[];for(let ce of this._feature.geometry)Z.push([new I.P(ce[0],ce[1])]);return Z}{let Z=[];for(let ce of this._feature.geometry){let pe=[];for(let se of ce)pe.push(new I.P(se[0],se[1]));Z.push(pe)}return Z}}toGeoJSON(Z,ce,pe){return Bt.call(this,Z,ce,pe)}}(this._features[ie])}}(N.features),Y=Ht(X);return Y.byteOffset===0&&Y.byteLength===Y.buffer.byteLength||(Y=new Uint8Array(Y)),{vectorTile:X,rawData:Y.buffer}}))}loadData(M){return I._(this,void 0,void 0,(function*(){var P;(P=this._pendingRequest)===null||P===void 0||P.abort();let R=!!(M&&M.request&&M.request.collectResourceTiming)&&new I.bv(M.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(M,this._pendingRequest),this._geoJSONIndex=M.cluster?new Nr((function({superclusterOptions:Y,clusterProperties:ie}){if(!ie||!Y)return Y;let Z={},ce={},pe={accumulated:null,zoom:0},se={properties:null},xe=Object.keys(ie);for(let Ne of xe){let[Ue,dt]=ie[Ne],Qe=I.bC(dt),pt=I.bC(typeof Ue=="string"?[Ue,["accumulated"],["get",Ne]]:Ue);Z[Ne]=Qe.value,ce[Ne]=pt.value}return Y.map=Ne=>{se.properties=Ne;let Ue={};for(let dt of xe)Ue[dt]=Z[dt].evaluate(pe,se);return Ue},Y.reduce=(Ne,Ue)=>{se.properties=Ue;for(let dt of xe)pe.accumulated=Ne[dt],Ne[dt]=ce[dt].evaluate(pe,se)},Y})(M)).load((yield this._pendingData).features):(N=yield this._pendingData,new Pi(N,M.geojsonVtOptions)),this.loaded={};let X={};if(R){let Y=R.finish();Y&&(X.resourceTiming={},X.resourceTiming[M.source]=JSON.parse(JSON.stringify(Y)))}return X}catch(X){if(delete this._pendingRequest,I.bB(X))return{abandoned:!0};throw X}var N}))}getData(){return I._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(M){let P=this.loaded;return P&&P[M.uid]?super.reloadTile(M):this.loadTile(M)}loadAndProcessGeoJSON(M,P){return I._(this,void 0,void 0,(function*(){let R=yield this.loadGeoJSON(M,P);if(delete this._pendingRequest,typeof R!="object")throw new Error(`Input data given to '${M.source}' is not a valid GeoJSON object.`);if(Ct(R,!0),M.filter){let N=I.bC(M.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(N.result==="error")throw new Error(N.value.map((Y=>`${Y.key}: ${Y.message}`)).join(", "));R={type:"FeatureCollection",features:R.features.filter((Y=>N.value.evaluate({zoom:0},Y)))}}return R}))}loadGeoJSON(M,P){return I._(this,void 0,void 0,(function*(){let{promoteId:R}=M;if(M.request){let N=yield I.h(M.request,P);return this._dataUpdateable=wr(N.data,R)?Lr(N.data,R):void 0,N.data}if(typeof M.data=="string")try{let N=JSON.parse(M.data);return this._dataUpdateable=wr(N,R)?Lr(N,R):void 0,N}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(N,X,Y){var ie,Z,ce,pe;if(X.removeAll&&N.clear(),X.remove)for(let se of X.remove)N.delete(se);if(X.add)for(let se of X.add){let xe=Je(se,Y);xe!=null&&N.set(xe,se)}if(X.update)for(let se of X.update){let xe=N.get(se.id);if(xe==null)continue;let Ne=!se.removeAllProperties&&(((ie=se.removeProperties)===null||ie===void 0?void 0:ie.length)>0||((Z=se.addOrUpdateProperties)===null||Z===void 0?void 0:Z.length)>0);if((se.newGeometry||se.removeAllProperties||Ne)&&(xe=Object.assign({},xe),N.set(se.id,xe),Ne&&(xe.properties=Object.assign({},xe.properties))),se.newGeometry&&(xe.geometry=se.newGeometry),se.removeAllProperties)xe.properties={};else if(((ce=se.removeProperties)===null||ce===void 0?void 0:ce.length)>0)for(let Ue of se.removeProperties)Object.prototype.hasOwnProperty.call(xe.properties,Ue)&&delete xe.properties[Ue];if(((pe=se.addOrUpdateProperties)===null||pe===void 0?void 0:pe.length)>0)for(let{key:Ue,value:dt}of se.addOrUpdateProperties)xe.properties[Ue]=dt}})(this._dataUpdateable,M.dataDiff,R),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(M){return I._(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 Sr{constructor(M){this.self=M,this.actor=new I.F(M),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(P,R)=>{if(this.externalWorkerSourceTypes[P])throw new Error(`Worker source with name "${P}" already registered.`);this.externalWorkerSourceTypes[P]=R},this.self.addProtocol=I.bi,this.self.removeProtocol=I.bj,this.self.registerRTLTextPlugin=P=>{if(I.bD.isParsed())throw new Error("RTL text plugin already registered.");I.bD.setMethods(P)},this.actor.registerMessageHandler("LDT",((P,R)=>this._getDEMWorkerSource(P,R.source).loadTile(R))),this.actor.registerMessageHandler("RDT",((P,R)=>I._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(P,R.source).removeTile(R)})))),this.actor.registerMessageHandler("GCEZ",((P,R)=>I._(this,void 0,void 0,(function*(){return this._getWorkerSource(P,R.type,R.source).getClusterExpansionZoom(R)})))),this.actor.registerMessageHandler("GCC",((P,R)=>I._(this,void 0,void 0,(function*(){return this._getWorkerSource(P,R.type,R.source).getClusterChildren(R)})))),this.actor.registerMessageHandler("GCL",((P,R)=>I._(this,void 0,void 0,(function*(){return this._getWorkerSource(P,R.type,R.source).getClusterLeaves(R)})))),this.actor.registerMessageHandler("LD",((P,R)=>this._getWorkerSource(P,R.type,R.source).loadData(R))),this.actor.registerMessageHandler("GD",((P,R)=>this._getWorkerSource(P,R.type,R.source).getData())),this.actor.registerMessageHandler("LT",((P,R)=>this._getWorkerSource(P,R.type,R.source).loadTile(R))),this.actor.registerMessageHandler("RT",((P,R)=>this._getWorkerSource(P,R.type,R.source).reloadTile(R))),this.actor.registerMessageHandler("AT",((P,R)=>this._getWorkerSource(P,R.type,R.source).abortTile(R))),this.actor.registerMessageHandler("RMT",((P,R)=>this._getWorkerSource(P,R.type,R.source).removeTile(R))),this.actor.registerMessageHandler("RS",((P,R)=>I._(this,void 0,void 0,(function*(){if(!this.workerSources[P]||!this.workerSources[P][R.type]||!this.workerSources[P][R.type][R.source])return;let N=this.workerSources[P][R.type][R.source];delete this.workerSources[P][R.type][R.source],N.removeSource!==void 0&&N.removeSource(R)})))),this.actor.registerMessageHandler("RM",(P=>I._(this,void 0,void 0,(function*(){delete this.layerIndexes[P],delete this.availableImages[P],delete this.workerSources[P],delete this.demWorkerSources[P]})))),this.actor.registerMessageHandler("SR",((P,R)=>I._(this,void 0,void 0,(function*(){this.referrer=R})))),this.actor.registerMessageHandler("SRPS",((P,R)=>this._syncRTLPluginState(P,R))),this.actor.registerMessageHandler("IS",((P,R)=>I._(this,void 0,void 0,(function*(){this.self.importScripts(R)})))),this.actor.registerMessageHandler("SI",((P,R)=>this._setImages(P,R))),this.actor.registerMessageHandler("UL",((P,R)=>I._(this,void 0,void 0,(function*(){this._getLayerIndex(P).update(R.layers,R.removedIds)})))),this.actor.registerMessageHandler("SL",((P,R)=>I._(this,void 0,void 0,(function*(){this._getLayerIndex(P).replace(R)}))))}_setImages(M,P){return I._(this,void 0,void 0,(function*(){this.availableImages[M]=P;for(let R in this.workerSources[M]){let N=this.workerSources[M][R];for(let X in N)N[X].availableImages=P}}))}_syncRTLPluginState(M,P){return I._(this,void 0,void 0,(function*(){if(I.bD.isParsed())return I.bD.getState();if(P.pluginStatus!=="loading")return I.bD.setState(P),P;let R=P.pluginURL;if(this.self.importScripts(R),I.bD.isParsed()){let N={pluginStatus:"loaded",pluginURL:R};return I.bD.setState(N),N}throw I.bD.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${R}`)}))}_getAvailableImages(M){let P=this.availableImages[M];return P||(P=[]),P}_getLayerIndex(M){let P=this.layerIndexes[M];return P||(P=this.layerIndexes[M]=new d),P}_getWorkerSource(M,P,R){if(this.workerSources[M]||(this.workerSources[M]={}),this.workerSources[M][P]||(this.workerSources[M][P]={}),!this.workerSources[M][P][R]){let N={sendAsync:(X,Y)=>(X.targetMapId=M,this.actor.sendAsync(X,Y))};switch(P){case"vector":this.workerSources[M][P][R]=new ue(N,this._getLayerIndex(M),this._getAvailableImages(M));break;case"geojson":this.workerSources[M][P][R]=new qr(N,this._getLayerIndex(M),this._getAvailableImages(M));break;default:this.workerSources[M][P][R]=new this.externalWorkerSourceTypes[P](N,this._getLayerIndex(M),this._getAvailableImages(M))}}return this.workerSources[M][P][R]}_getDEMWorkerSource(M,P){return this.demWorkerSources[M]||(this.demWorkerSources[M]={}),this.demWorkerSources[M][P]||(this.demWorkerSources[M][P]=new H),this.demWorkerSources[M][P]}}return I.i(self)&&(self.worker=new Sr(self)),Sr})),Q("index",["exports","./shared"],(function(I,d){"use strict";var me="4.7.1";let _e,Ve,ue={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:h=>new Promise(((e,n)=>{let o=requestAnimationFrame(e);h.signal.addEventListener("abort",(()=>{cancelAnimationFrame(o),n(d.c())}))})),getImageData(h,e=0){return this.getImageCanvasContext(h).getImageData(-e,-e,h.width+2*e,h.height+2*e)},getImageCanvasContext(h){let e=window.document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return e.width=h.width,e.height=h.height,n.drawImage(h,0,0,h.width,h.height),n},resolveURL:h=>(_e||(_e=document.createElement("a")),_e.href=h,_e.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(Ve==null&&(Ve=matchMedia("(prefers-reduced-motion: reduce)")),Ve.matches)}};class H{static testProp(e){if(!H.docStyle)return e[0];for(let n=0;n<e.length;n++)if(e[n]in H.docStyle)return e[n];return e[0]}static create(e,n,o){let a=window.document.createElement(e);return n!==void 0&&(a.className=n),o&&o.appendChild(a),a}static createNS(e,n){return window.document.createElementNS(e,n)}static disableDrag(){H.docStyle&&H.selectProp&&(H.userSelect=H.docStyle[H.selectProp],H.docStyle[H.selectProp]="none")}static enableDrag(){H.docStyle&&H.selectProp&&(H.docStyle[H.selectProp]=H.userSelect)}static setTransform(e,n){e.style[H.transformProp]=n}static addEventListener(e,n,o,a={}){e.addEventListener(n,o,"passive"in a?a:a.capture)}static removeEventListener(e,n,o,a={}){e.removeEventListener(n,o,"passive"in a?a:a.capture)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",H.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",H.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",H.suppressClickInternal,!0)}),0)}static getScale(e){let n=e.getBoundingClientRect();return{x:n.width/e.offsetWidth||1,y:n.height/e.offsetHeight||1,boundingClientRect:n}}static getPoint(e,n,o){let a=n.boundingClientRect;return new d.P((o.clientX-a.left)/n.x-e.clientLeft,(o.clientY-a.top)/n.y-e.clientTop)}static mousePos(e,n){let o=H.getScale(e);return H.getPoint(e,o,n)}static touchPos(e,n){let o=[],a=H.getScale(e);for(let c=0;c<n.length;c++)o.push(H.getPoint(e,a,n[c]));return o}static mouseButton(e){return e.button}static remove(e){e.parentNode&&e.parentNode.removeChild(e)}}H.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,H.selectProp=H.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),H.transformProp=H.testProp(["transform","WebkitTransform"]);let Xe={supported:!1,testSupport:function(h){!Bt&&Ct&&($t?ri(h):wt=h)}},wt,Ct,Bt=!1,$t=!1;function ri(h){let e=h.createTexture();h.bindTexture(h.TEXTURE_2D,e);try{if(h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,Ct),h.isContextLost())return;Xe.supported=!0}catch{}h.deleteTexture(e),Bt=!0}var Ke;typeof document<"u"&&(Ct=document.createElement("img"),Ct.onload=()=>{wt&&ri(wt),wt=null,$t=!0},Ct.onerror=()=>{Bt=!0,wt=null},Ct.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),(function(h){let e,n,o,a;h.resetRequestQueue=()=>{e=[],n=0,o=0,a={}},h.addThrottleControl=y=>{let b=o++;return a[b]=y,b},h.removeThrottleControl=y=>{delete a[y],m()},h.getImage=(y,b,S=!0)=>new Promise(((T,E)=>{Xe.supported&&(y.headers||(y.headers={}),y.headers.accept="image/webp,*/*"),d.e(y,{type:"image"}),e.push({abortController:b,requestParameters:y,supportImageRefresh:S,state:"queued",onError:D=>{E(D)},onSuccess:D=>{T(D)}}),m()}));let c=y=>d._(this,void 0,void 0,(function*(){y.state="running";let{requestParameters:b,supportImageRefresh:S,onError:T,onSuccess:E,abortController:D}=y,F=S===!1&&!d.i(self)&&!d.g(b.url)&&(!b.headers||Object.keys(b.headers).reduce(((q,G)=>q&&G==="accept"),!0));n++;let V=F?_(b,D):d.m(b,D);try{let q=yield V;delete y.abortController,y.state="completed",q.data instanceof HTMLImageElement||d.b(q.data)?E(q):q.data&&E({data:yield($=q.data,typeof createImageBitmap=="function"?d.d($):d.f($)),cacheControl:q.cacheControl,expires:q.expires})}catch(q){delete y.abortController,T(q)}finally{n--,m()}var $})),m=()=>{let y=(()=>{for(let b of Object.keys(a))if(a[b]())return!0;return!1})()?d.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:d.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let b=n;b<y&&e.length>0;b++){let S=e.shift();S.abortController.signal.aborted?b--:c(S)}},_=(y,b)=>new Promise(((S,T)=>{let E=new Image,D=y.url,F=y.credentials;F&&F==="include"?E.crossOrigin="use-credentials":(F&&F==="same-origin"||!d.s(D))&&(E.crossOrigin="anonymous"),b.signal.addEventListener("abort",(()=>{E.src="",T(d.c())})),E.fetchPriority="high",E.onload=()=>{E.onerror=E.onload=null,S({data:E})},E.onerror=()=>{E.onerror=E.onload=null,b.signal.aborted||T(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."))},E.src=D}))})(Ke||(Ke={})),Ke.resetRequestQueue();class $e{constructor(e){this._transformRequestFn=e}transformRequest(e,n){return this._transformRequestFn&&this._transformRequestFn(e,n)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function Ye(h){var e=new d.A(3);return e[0]=h[0],e[1]=h[1],e[2]=h[2],e}var Pt,Mt=function(h,e,n){return h[0]=e[0]-n[0],h[1]=e[1]-n[1],h[2]=e[2]-n[2],h};Pt=new d.A(3),d.A!=Float32Array&&(Pt[0]=0,Pt[1]=0,Pt[2]=0);var Nt=function(h){var e=h[0],n=h[1];return e*e+n*n};function ft(h){let e=[];if(typeof h=="string")e.push({id:"default",url:h});else if(h&&h.length>0){let n=[];for(let{id:o,url:a}of h){let c=`${o}${a}`;n.indexOf(c)===-1&&(n.push(c),e.push({id:o,url:a}))}}return e}function vi(h,e,n){let o=h.split("?");return o[0]+=`${e}${n}`,o.join("?")}(function(){var h=new d.A(2);d.A!=Float32Array&&(h[0]=0,h[1]=0)})();class et{constructor(e,n,o,a){this.context=e,this.format=o,this.texture=e.gl.createTexture(),this.update(n,a)}update(e,n,o){let{width:a,height:c}=e,m=!(this.size&&this.size[0]===a&&this.size[1]===c||o),{context:_}=this,{gl:y}=_;if(this.useMipmap=!!(n&&n.useMipmap),y.bindTexture(y.TEXTURE_2D,this.texture),_.pixelStoreUnpackFlipY.set(!1),_.pixelStoreUnpack.set(1),_.pixelStoreUnpackPremultiplyAlpha.set(this.format===y.RGBA&&(!n||n.premultiply!==!1)),m)this.size=[a,c],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||d.b(e)?y.texImage2D(y.TEXTURE_2D,0,this.format,this.format,y.UNSIGNED_BYTE,e):y.texImage2D(y.TEXTURE_2D,0,this.format,a,c,0,this.format,y.UNSIGNED_BYTE,e.data);else{let{x:b,y:S}=o||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||d.b(e)?y.texSubImage2D(y.TEXTURE_2D,0,b,S,y.RGBA,y.UNSIGNED_BYTE,e):y.texSubImage2D(y.TEXTURE_2D,0,b,S,a,c,y.RGBA,y.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&y.generateMipmap(y.TEXTURE_2D)}bind(e,n,o){let{context:a}=this,{gl:c}=a;c.bindTexture(c.TEXTURE_2D,this.texture),o!==c.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(o=c.LINEAR),e!==this.filter&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,e),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,o||e),this.filter=e),n!==this.wrap&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,n),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,n),this.wrap=n)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}function ei(h){let{userImage:e}=h;return!!(e&&e.render&&e.render())&&(h.data.replace(new Uint8Array(e.data.buffer)),!0)}class ze extends d.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new d.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:n,promiseResolve:o}of this.requestors)o(this._getImagesForIds(n));this.requestors=[]}}getImage(e){let n=this.images[e];if(n&&!n.data&&n.spriteData){let o=n.spriteData;n.data=new d.R({width:o.width,height:o.height},o.context.getImageData(o.x,o.y,o.width,o.height).data),n.spriteData=null}return n}addImage(e,n){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,n)&&(this.images[e]=n)}_validate(e,n){let o=!0,a=n.data||n.spriteData;return this._validateStretch(n.stretchX,a&&a.width)||(this.fire(new d.j(new Error(`Image "${e}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,a&&a.height)||(this.fire(new d.j(new Error(`Image "${e}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new d.j(new Error(`Image "${e}" has invalid "content" value`))),o=!1),o}_validateStretch(e,n){if(!e)return!0;let o=0;for(let a of e){if(a[0]<o||a[1]<a[0]||n<a[1])return!1;o=a[1]}return!0}_validateContent(e,n){if(!e)return!0;if(e.length!==4)return!1;let o=n.spriteData,a=o&&o.width||n.data.width,c=o&&o.height||n.data.height;return!(e[0]<0||a<e[0]||e[1]<0||c<e[1]||e[2]<0||a<e[2]||e[3]<0||c<e[3]||e[2]<e[0]||e[3]<e[1])}updateImage(e,n,o=!0){let a=this.getImage(e);if(o&&(a.data.width!==n.data.width||a.data.height!==n.data.height))throw new Error(`size mismatch between old image (${a.data.width}x${a.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=a.version+1,this.images[e]=n,this.updatedImages[e]=!0}removeImage(e){let n=this.images[e];delete this.images[e],delete this.patterns[e],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise(((n,o)=>{let a=!0;if(!this.isLoaded())for(let c of e)this.images[c]||(a=!1);this.isLoaded()||a?n(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:n})}))}_getImagesForIds(e){let n={};for(let o of e){let a=this.getImage(o);a||(this.fire(new d.k("styleimagemissing",{id:o})),a=this.getImage(o)),a?n[o]={data:a.data.clone(),pixelRatio:a.pixelRatio,sdf:a.sdf,version:a.version,stretchX:a.stretchX,stretchY:a.stretchY,content:a.content,textFitWidth:a.textFitWidth,textFitHeight:a.textFitHeight,hasRenderCallback:!!(a.userImage&&a.userImage.render)}:d.w(`Image "${o}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){let{width:e,height:n}=this.atlasImage;return{width:e,height:n}}getPattern(e){let n=this.patterns[e],o=this.getImage(e);if(!o)return null;if(n&&n.position.version===o.version)return n.position;if(n)n.position.version=o.version;else{let a={w:o.data.width+2,h:o.data.height+2,x:0,y:0},c=new d.I(a,o);this.patterns[e]={bin:a,position:c}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){let n=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new et(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){let e=[];for(let c in this.patterns)e.push(this.patterns[c].bin);let{w:n,h:o}=d.p(e),a=this.atlasImage;a.resize({width:n||1,height:o||1});for(let c in this.patterns){let{bin:m}=this.patterns[c],_=m.x+1,y=m.y+1,b=this.getImage(c).data,S=b.width,T=b.height;d.R.copy(b,a,{x:0,y:0},{x:_,y},{width:S,height:T}),d.R.copy(b,a,{x:0,y:T-1},{x:_,y:y-1},{width:S,height:1}),d.R.copy(b,a,{x:0,y:0},{x:_,y:y+T},{width:S,height:1}),d.R.copy(b,a,{x:S-1,y:0},{x:_-1,y},{width:1,height:T}),d.R.copy(b,a,{x:0,y:0},{x:_+S,y},{width:1,height:T})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;let o=this.getImage(n);o||d.w(`Image with ID: "${n}" was not found`),ei(o)&&this.updateImage(n,o)}}}let it=1e20;function ot(h,e,n,o,a,c,m,_,y){for(let b=e;b<e+o;b++)ti(h,n*c+b,c,a,m,_,y);for(let b=n;b<n+a;b++)ti(h,b*c+e,1,o,m,_,y)}function ti(h,e,n,o,a,c,m){c[0]=0,m[0]=-it,m[1]=it,a[0]=h[e];for(let _=1,y=0,b=0;_<o;_++){a[_]=h[e+_*n];let S=_*_;do{let T=c[y];b=(a[_]-a[T]+S-T*T)/(_-T)/2}while(b<=m[y]&&--y>-1);y++,c[y]=_,m[y]=b,m[y+1]=it}for(let _=0,y=0;_<o;_++){for(;m[y+1]<_;)y++;let b=c[y],S=_-b;h[e+_*n]=a[b]+S*S}}class Ht{constructor(e,n){this.requestManager=e,this.localIdeographFontFamily=n,this.entries={}}setURL(e){this.url=e}getGlyphs(e){return d._(this,void 0,void 0,(function*(){let n=[];for(let c in e)for(let m of e[c])n.push(this._getAndCacheGlyphsPromise(c,m));let o=yield Promise.all(n),a={};for(let{stack:c,id:m,glyph:_}of o)a[c]||(a[c]={}),a[c][m]=_&&{id:_.id,bitmap:_.bitmap.clone(),metrics:_.metrics};return a}))}_getAndCacheGlyphsPromise(e,n){return d._(this,void 0,void 0,(function*(){let o=this.entries[e];o||(o=this.entries[e]={glyphs:{},requests:{},ranges:{}});let a=o.glyphs[n];if(a!==void 0)return{stack:e,id:n,glyph:a};if(a=this._tinySDF(o,e,n),a)return o.glyphs[n]=a,{stack:e,id:n,glyph:a};let c=Math.floor(n/256);if(256*c>65535)throw new Error("glyphs > 65535 not supported");if(o.ranges[c])return{stack:e,id:n,glyph:a};if(!this.url)throw new Error("glyphsUrl is not set");if(!o.requests[c]){let _=Ht.loadGlyphRange(e,c,this.url,this.requestManager);o.requests[c]=_}let m=yield o.requests[c];for(let _ in m)this._doesCharSupportLocalGlyph(+_)||(o.glyphs[+_]=m[+_]);return o.ranges[c]=!0,{stack:e,id:n,glyph:m[n]||null}}))}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))}_tinySDF(e,n,o){let a=this.localIdeographFontFamily;if(!a||!this._doesCharSupportLocalGlyph(o))return;let c=e.tinySDF;if(!c){let _="400";/bold/i.test(n)?_="900":/medium/i.test(n)?_="500":/light/i.test(n)&&(_="200"),c=e.tinySDF=new Ht.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:a,fontWeight:_})}let m=c.draw(String.fromCharCode(o));return{id:o,bitmap:new d.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}}}}Ht.loadGlyphRange=function(h,e,n,o){return d._(this,void 0,void 0,(function*(){let a=256*e,c=a+255,m=o.transformRequest(n.replace("{fontstack}",h).replace("{range}",`${a}-${c}`),"Glyphs"),_=yield d.l(m,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${e}, ${a}-${c}`);let y={};for(let b of d.n(_.data))y[b.id]=b;return y}))},Ht.TinySDF=class{constructor({fontSize:h=24,buffer:e=3,radius:n=8,cutoff:o=.25,fontFamily:a="sans-serif",fontWeight:c="normal",fontStyle:m="normal"}={}){this.buffer=e,this.cutoff=o,this.radius=n;let _=this.size=h+4*e,y=this._createCanvas(_),b=this.ctx=y.getContext("2d",{willReadFrequently:!0});b.font=`${m} ${c} ${h}px ${a}`,b.textBaseline="alphabetic",b.textAlign="left",b.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(h){let e=document.createElement("canvas");return e.width=e.height=h,e}draw(h){let{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:a,actualBoundingBoxRight:c}=this.ctx.measureText(h),m=Math.ceil(n),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(c-a))),y=Math.min(this.size-this.buffer,m+Math.ceil(o)),b=_+2*this.buffer,S=y+2*this.buffer,T=Math.max(b*S,0),E=new Uint8ClampedArray(T),D={data:E,width:b,height:S,glyphWidth:_,glyphHeight:y,glyphTop:m,glyphLeft:0,glyphAdvance:e};if(_===0||y===0)return D;let{ctx:F,buffer:V,gridInner:$,gridOuter:q}=this;F.clearRect(V,V,_,y),F.fillText(h,V,V+m);let G=F.getImageData(V,V,_,y);q.fill(it,0,T),$.fill(0,0,T);for(let B=0;B<y;B++)for(let J=0;J<_;J++){let ee=G.data[4*(B*_+J)+3]/255;if(ee===0)continue;let ne=(B+V)*b+J+V;if(ee===1)q[ne]=0,$[ne]=it;else{let de=.5-ee;q[ne]=de>0?de*de:0,$[ne]=de<0?de*de:0}}ot(q,0,0,b,S,b,this.f,this.v,this.z),ot($,V,V,_,y,b,this.f,this.v,this.z);for(let B=0;B<T;B++){let J=Math.sqrt(q[B])-Math.sqrt($[B]);E[B]=Math.round(255-255*(J/this.radius+this.cutoff))}return D}};class tr{constructor(){this.specification=d.v.light.position}possiblyEvaluate(e,n){return d.x(e.expression.evaluate(n))}interpolate(e,n,o){return{x:d.y.number(e.x,n.x,o),y:d.y.number(e.y,n.y,o),z:d.y.number(e.z,n.z,o)}}}let ir;class ui extends d.E{constructor(e){super(),ir=ir||new d.q({anchor:new d.D(d.v.light.anchor),position:new tr,color:new d.D(d.v.light.color),intensity:new d.D(d.v.light.intensity)}),this._transitionable=new d.T(ir),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,n={}){if(!this._validate(d.r,e,n))for(let o in e){let a=e[o];o.endsWith("-transition")?this._transitionable.setTransition(o.slice(0,-11),a):this._transitionable.setValue(o,a)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,o){return(!o||o.validate!==!1)&&d.t(this,e.call(d.u,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:d.v}))}}let Wt=new d.q({"sky-color":new d.D(d.v.sky["sky-color"]),"horizon-color":new d.D(d.v.sky["horizon-color"]),"fog-color":new d.D(d.v.sky["fog-color"]),"fog-ground-blend":new d.D(d.v.sky["fog-ground-blend"]),"horizon-fog-blend":new d.D(d.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new d.D(d.v.sky["sky-horizon-blend"]),"atmosphere-blend":new d.D(d.v.sky["atmosphere-blend"])});class rr extends d.E{constructor(e){super(),this._transitionable=new d.T(Wt),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new d.z(0))}setSky(e,n={}){if(!this._validate(d.B,e,n)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(let o in e){let a=e[o];o.endsWith("-transition")?this._transitionable.setTransition(o.slice(0,-11),a):this._transitionable.setValue(o,a)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,o={}){return o?.validate!==!1&&d.t(this,e.call(d.u,d.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:d.v})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class vn{constructor(e,n){this.width=e,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,n){let o=e.join(",")+String(n);return this.dashEntry[o]||(this.dashEntry[o]=this.addDash(e,n)),this.dashEntry[o]}getDashRanges(e,n,o){let a=[],c=e.length%2==1?-e[e.length-1]*o:0,m=e[0]*o,_=!0;a.push({left:c,right:m,isDash:_,zeroLength:e[0]===0});let y=e[0];for(let b=1;b<e.length;b++){_=!_;let S=e[b];c=y*o,y+=S,m=y*o,a.push({left:c,right:m,isDash:_,zeroLength:S===0})}return a}addRoundDash(e,n,o){let a=n/2;for(let c=-o;c<=o;c++){let m=this.width*(this.nextRow+o+c),_=0,y=e[_];for(let b=0;b<this.width;b++){b/y.right>1&&(y=e[++_]);let S=Math.abs(b-y.left),T=Math.abs(b-y.right),E=Math.min(S,T),D,F=c/o*(a+1);if(y.isDash){let V=a-Math.abs(F);D=Math.sqrt(E*E+V*V)}else D=a-Math.sqrt(E*E+F*F);this.data[m+b]=Math.max(0,Math.min(255,D+128))}}}addRegularDash(e){for(let _=e.length-1;_>=0;--_){let y=e[_],b=e[_+1];y.zeroLength?e.splice(_,1):b&&b.isDash===y.isDash&&(b.left=y.left,e.splice(_,1))}let n=e[0],o=e[e.length-1];n.isDash===o.isDash&&(n.left=o.left-this.width,o.right=n.right+this.width);let a=this.width*this.nextRow,c=0,m=e[c];for(let _=0;_<this.width;_++){_/m.right>1&&(m=e[++c]);let y=Math.abs(_-m.left),b=Math.abs(_-m.right),S=Math.min(y,b);this.data[a+_]=Math.max(0,Math.min(255,(m.isDash?S:-S)+128))}}addDash(e,n){let o=n?7:0,a=2*o+1;if(this.nextRow+a>this.height)return d.w("LineAtlas out of space"),null;let c=0;for(let _=0;_<e.length;_++)c+=e[_];if(c!==0){let _=this.width/c,y=this.getDashRanges(e,this.width,_);n?this.addRoundDash(y,_,o):this.addRegularDash(y)}let m={y:(this.nextRow+o+.5)/this.height,height:2*o/this.height,width:c};return this.nextRow+=a,this.dirty=!0,m}bind(e){let n=e.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}let Nr="maplibre_preloaded_worker_pool";class xr{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<xr.workerCount;)this.workers.push(new Worker(d.a.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.numActive()===0&&(this.workers.forEach((n=>{n.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Nr]}numActive(){return Object.keys(this.active).length}}let bn=Math.floor(ue.hardwareConcurrency/2),Fi,nr;function Qr(){return Fi||(Fi=new xr),Fi}xr.workerCount=d.C(globalThis)?Math.max(Math.min(bn,3),1):1;class en{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;let o=this.workerPool.acquire(n);for(let a=0;a<o.length;a++){let c=new d.F(o[a],n);c.name=`Worker ${a}`,this.actors.push(c)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,n){let o=[];for(let a of this.actors)o.push(a.sendAsync({type:e,data:n}));return Promise.all(o)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.actors.forEach((n=>{n.remove()})),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,n){for(let o of this.actors)o.registerMessageHandler(e,n)}}function ls(){return nr||(nr=new en(Qr(),d.G),nr.registerMessageHandler("GR",((h,e,n)=>d.m(e,n)))),nr}function kr(h,e){let n=d.H();return d.J(n,n,[1,1,0]),d.K(n,n,[.5*h.width,.5*h.height,1]),d.L(n,n,h.calculatePosMatrix(e.toUnwrapped()))}function Vr(h,e,n,o,a,c){let m=(function(T,E,D){if(T)for(let F of T){let V=E[F];if(V&&V.source===D&&V.type==="fill-extrusion")return!0}else for(let F in E){let V=E[F];if(V.source===D&&V.type==="fill-extrusion")return!0}return!1})(a&&a.layers,e,h.id),_=c.maxPitchScaleFactor(),y=h.tilesIn(o,_,m);y.sort(Ur);let b=[];for(let T of y)b.push({wrappedTileID:T.tileID.wrapped().key,queryResults:T.tile.queryRenderedFeatures(e,n,h._state,T.queryGeometry,T.cameraQueryGeometry,T.scale,a,c,_,kr(h.transform,T.tileID))});let S=(function(T){let E={},D={};for(let F of T){let V=F.queryResults,$=F.wrappedTileID,q=D[$]=D[$]||{};for(let G in V){let B=V[G],J=q[G]=q[G]||{},ee=E[G]=E[G]||[];for(let ne of B)J[ne.featureIndex]||(J[ne.featureIndex]=!0,ee.push(ne))}}return E})(b);for(let T in S)S[T].forEach((E=>{let D=E.feature,F=h.getFeatureState(D.layer["source-layer"],D.id);D.source=D.layer.source,D.layer["source-layer"]&&(D.sourceLayer=D.layer["source-layer"]),D.state=F}));return S}function Ur(h,e){let n=h.tileID,o=e.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function wn(h,e,n){return d._(this,void 0,void 0,(function*(){let o=h;if(h.url?o=(yield d.h(e.transformRequest(h.url,"Source"),n)).data:yield ue.frameAsync(n),!o)return null;let a=d.M(d.e(o,h),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in o&&o.vector_layers&&(a.vectorLayerIds=o.vector_layers.map((c=>c.id))),a}))}class ae{constructor(e,n){e&&(n?this.setSouthWest(e).setNorthEast(n):Array.isArray(e)&&(e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof d.N?new d.N(e.lng,e.lat):d.N.convert(e),this}setSouthWest(e){return this._sw=e instanceof d.N?new d.N(e.lng,e.lat):d.N.convert(e),this}extend(e){let n=this._sw,o=this._ne,a,c;if(e instanceof d.N)a=e,c=e;else{if(!(e instanceof ae))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(ae.convert(e)):this.extend(d.N.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(d.N.convert(e)):this;if(a=e._sw,c=e._ne,!a||!c)return this}return n||o?(n.lng=Math.min(a.lng,n.lng),n.lat=Math.min(a.lat,n.lat),o.lng=Math.max(c.lng,o.lng),o.lat=Math.max(c.lat,o.lat)):(this._sw=new d.N(a.lng,a.lat),this._ne=new d.N(c.lng,c.lat)),this}getCenter(){return new d.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 d.N(this.getWest(),this.getNorth())}getSouthEast(){return new d.N(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){let{lng:n,lat:o}=d.N.convert(e),a=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=o&&o<=this._ne.lat&&a}static convert(e){return e instanceof ae?e:e&&new ae(e)}static fromLngLat(e,n=0){let o=360*n/40075017,a=o/Math.cos(Math.PI/180*e.lat);return new ae(new d.N(e.lng-a,e.lat-o),new d.N(e.lng+a,e.lat+o))}adjustAntiMeridian(){let e=new d.N(this._sw.lng,this._sw.lat),n=new d.N(this._ne.lng,this._ne.lat);return new ae(e,e.lng>n.lng?new d.N(n.lng+360,n.lat):n)}}class tn{constructor(e,n,o){this.bounds=ae.convert(this.validateBounds(e)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){let n=Math.pow(2,e.z),o=Math.floor(d.O(this.bounds.getWest())*n),a=Math.floor(d.Q(this.bounds.getNorth())*n),c=Math.ceil(d.O(this.bounds.getEast())*n),m=Math.ceil(d.Q(this.bounds.getSouth())*n);return e.x>=o&&e.x<c&&e.y>=a&&e.y<m}}class cs extends d.E{constructor(e,n,o,a){if(super(),this.id=e,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,d.e(this,d.M(n,["url","scheme","tileSize","promoteId"])),this._options=d.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(a)}load(){return d._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new d.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{let e=yield wn(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),e&&(d.e(this,e),e.bounds&&(this.tileBounds=new tn(e.bounds,this.minzoom,this.maxzoom)),this.fire(new d.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new d.k("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this.fire(new d.j(e))}}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load()}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return d.e({},this._options)}loadTile(e){return d._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o={request:this.map._requestManager.transformRequest(n,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};o.request.collectResourceTiming=this._collectResourceTiming;let a="RT";if(e.actor&&e.state!=="expired"){if(e.state==="loading")return new Promise(((c,m)=>{e.reloadPromise={resolve:c,reject:m}}))}else e.actor=this.dispatcher.getActor(),a="LT";e.abortController=new AbortController;try{let c=yield e.actor.sendAsync({type:a,data:o},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,c)}catch(c){if(delete e.abortController,e.aborted)return;if(c&&c.status!==404)throw c;this._afterTileLoadWorkerResponse(e,null)}}))}_afterTileLoadWorkerResponse(e,n){if(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),e.reloadPromise){let o=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(o.resolve).catch(o.reject)}}abortTile(e){return d._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}unloadTile(e){return d._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class _t extends d.E{constructor(e,n,o,a){super(),this.id=e,this.dispatcher=o,this.setEventedParent(a),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=d.e({type:"raster"},n),d.e(this,d.M(n,["url","scheme","tileSize"]))}load(){return d._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new d.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{let e=yield wn(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,e&&(d.e(this,e),e.bounds&&(this.tileBounds=new tn(e.bounds,this.minzoom,this.maxzoom)),this.fire(new d.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new d.k("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this.fire(new d.j(e))}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load()}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}serialize(){return d.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return d._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{let o=yield Ke.getImage(this.map._requestManager.transformRequest(n,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(o&&o.data){this.map._refreshExpiredTiles&&o.cacheControl&&o.expires&&e.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});let a=this.map.painter.context,c=a.gl,m=o.data;e.texture=this.map.painter.getTileTexture(m.width),e.texture?e.texture.update(m,{useMipmap:!0}):(e.texture=new et(a,m,c.RGBA,{useMipmap:!0}),e.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE,c.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(o){if(delete e.abortController,e.aborted)e.state="unloaded";else if(o)throw e.state="errored",o}}))}abortTile(e){return d._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return d._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class Vt extends _t{constructor(e,n,o,a){super(e,n,o,a),this.type="raster-dem",this.maxzoom=22,this._options=d.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(e){return d._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o=this.map._requestManager.transformRequest(n,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let a=yield Ke.getImage(o,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(a&&a.data){let c=a.data;this.map._refreshExpiredTiles&&a.cacheControl&&a.expires&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});let m=d.b(c)&&d.U()?c:yield this.readImageNow(c),_={type:this.type,uid:e.uid,source:this.id,rawImageData:m,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||e.state==="expired"){e.actor=this.dispatcher.getActor();let y=yield e.actor.sendAsync({type:"LDT",data:_});e.dem=y,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(a){if(delete e.abortController,e.aborted)e.state="unloaded";else if(a)throw e.state="errored",a}}))}readImageNow(e){return d._(this,void 0,void 0,(function*(){if(typeof VideoFrame<"u"&&d.V()){let n=e.width+2,o=e.height+2;try{return new d.R({width:n,height:o},yield d.W(e,-1,-1,n,o))}catch{}}return ue.getImageData(e,1)}))}_getNeighboringTiles(e){let n=e.canonical,o=Math.pow(2,n.z),a=(n.x-1+o)%o,c=n.x===0?e.wrap-1:e.wrap,m=(n.x+1+o)%o,_=n.x+1===o?e.wrap+1:e.wrap,y={};return y[new d.S(e.overscaledZ,c,n.z,a,n.y).key]={backfilled:!1},y[new d.S(e.overscaledZ,_,n.z,m,n.y).key]={backfilled:!1},n.y>0&&(y[new d.S(e.overscaledZ,c,n.z,a,n.y-1).key]={backfilled:!1},y[new d.S(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},y[new d.S(e.overscaledZ,_,n.z,m,n.y-1).key]={backfilled:!1}),n.y+1<o&&(y[new d.S(e.overscaledZ,c,n.z,a,n.y+1).key]={backfilled:!1},y[new d.S(e.overscaledZ,e.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},y[new d.S(e.overscaledZ,_,n.z,m,n.y+1).key]={backfilled:!1}),y}unloadTile(e){return d._(this,void 0,void 0,(function*(){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&(yield e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}}))}))}}class hs extends d.E{constructor(e,n,o,a){super(),this.id=e,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=o.getActor(),this.setEventedParent(a),this._data=n.data,this._options=d.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId;let c=d.X/this.tileSize;n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&d.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=d.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:(n.buffer!==void 0?n.buffer:128)*c,tolerance:(n.tolerance!==void 0?n.tolerance:.375)*c,extent:d.X,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:n.clusterMaxZoom!==void 0?n.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,n.clusterMinPoints||2),extent:d.X,radius:(n.clusterRadius||50)*c,log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}load(){return d._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(e){this.map=e,this.load()}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(e){return this._updateWorkerData(e),this}getData(){return d._(this,void 0,void 0,(function*(){let e=d.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:e})}))}setClusterOptions(e){return this.workerOptions.cluster=e.cluster,e&&(e.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=e.clusterRadius),e.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=e.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,n,o){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:n,offset:o}})}_updateWorkerData(e){return d._(this,void 0,void 0,(function*(){let n=d.e({type:this.type},this.workerOptions);e?n.dataDiff=e:typeof this._data=="string"?(n.request=this.map._requestManager.transformRequest(ue.resolveURL(this._data),"Source"),n.request.collectResourceTiming=this._collectResourceTiming):n.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new d.k("dataloading",{dataType:"source"}));try{let o=yield this.actor.sendAsync({type:"LD",data:n});if(this._pendingLoads--,this._removed||o.abandoned)return void this.fire(new d.k("dataabort",{dataType:"source"}));let a=null;o.resourceTiming&&o.resourceTiming[this.id]&&(a=o.resourceTiming[this.id].slice(0));let c={dataType:"source"};this._collectResourceTiming&&a&&a.length>0&&d.e(c,{resourceTiming:a}),this.fire(new d.k("data",Object.assign(Object.assign({},c),{sourceDataType:"metadata"}))),this.fire(new d.k("data",Object.assign(Object.assign({},c),{sourceDataType:"content"})))}catch(o){if(this._pendingLoads--,this._removed)return void this.fire(new d.k("dataabort",{dataType:"source"}));this.fire(new d.j(o))}}))}loaded(){return this._pendingLoads===0}loadTile(e){return d._(this,void 0,void 0,(function*(){let n=e.actor?"RT":"LT";e.actor=this.actor;let o={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};e.abortController=new AbortController;let a=yield this.actor.sendAsync({type:n,data:o},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(a,this.map.painter,n==="RT")}))}abortTile(e){return d._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return d._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return d.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var jr=d.Y([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class zr extends d.E{constructor(e,n,o,a){super(),this.id=e,this.dispatcher=o,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(a),this.options=n}load(e){return d._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new d.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{let n=yield Ke.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,e&&(this.coordinates=e),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,this.fire(new d.j(n))}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new d.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;let n=e.map(d.Z.fromLngLat);this.tileID=(function(a){let c=1/0,m=1/0,_=-1/0,y=-1/0;for(let E of a)c=Math.min(c,E.x),m=Math.min(m,E.y),_=Math.max(_,E.x),y=Math.max(y,E.y);let b=Math.max(_-c,y-m),S=Math.max(0,Math.floor(-Math.log(b)/Math.LN2)),T=Math.pow(2,S);return new d.a1(S,Math.floor((c+_)/2*T),Math.floor((m+y)/2*T))})(n),this.minzoom=this.maxzoom=this.tileID.z;let o=n.map((a=>this.tileID.getTilePoint(a)._round()));return this._boundsArray=new d.$,this._boundsArray.emplaceBack(o[0].x,o[0].y,0,0),this._boundsArray.emplaceBack(o[1].x,o[1].y,d.X,0),this._boundsArray.emplaceBack(o[3].x,o[3].y,0,d.X),this._boundsArray.emplaceBack(o[2].x,o[2].y,d.X,d.X),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new d.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let e=this.map.painter.context,n=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,jr.members)),this.boundsSegments||(this.boundsSegments=d.a0.simpleSegment(0,0,4,2)),this.texture||(this.texture=new et(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(let a in this.tiles){let c=this.tiles[a];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,o=!0)}o&&this.fire(new d.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return d._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class Sn extends zr{constructor(e,n,o,a){super(e,n,o,a),this.roundZoom=!0,this.type="video",this.options=n}load(){return d._(this,void 0,void 0,(function*(){this._loaded=!1;let e=this.options;this.urls=[];for(let n of e.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{let n=yield d.a3(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new d.j(n))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let n=this.video.seekable;e<n.start(0)||e>n.end(0)?this.fire(new d.j(new d.a2(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let e=this.map.painter.context,n=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,jr.members)),this.boundsSegments||(this.boundsSegments=d.a0.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new et(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(let a in this.tiles){let c=this.tiles[a];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,o=!0)}o&&this.fire(new d.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 Zi extends zr{constructor(e,n,o,a){super(e,n,o,a),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some((c=>!Array.isArray(c)||c.length!==2||c.some((m=>typeof m!="number"))))||this.fire(new d.j(new d.a2(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new d.j(new d.a2(`sources.${e}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new d.j(new d.a2(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new d.j(new d.a2(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new d.j(new d.a2(`sources.${e}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return d._(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 d.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let n=this.map.painter.context,o=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,jr.members)),this.boundsSegments||(this.boundsSegments=d.a0.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new et(n,this.canvas,o.RGBA,{premultiply:!0});let a=!1;for(let c in this.tiles){let m=this.tiles[c];m.state!=="loaded"&&(m.state="loaded",m.texture=this.texture,a=!0)}a&&this.fire(new d.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}let us={},ds=h=>{switch(h){case"geojson":return hs;case"image":return zr;case"raster":return _t;case"raster-dem":return Vt;case"vector":return cs;case"video":return Sn;case"canvas":return Zi}return us[h]},ye="RTLPluginLoaded";class vr extends d.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=ls()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((n=>{throw this.status="error",n}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return d._(this,arguments,void 0,(function*(n,o=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=ue.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!o)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()}))}_requestImport(){return d._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new d.k(ye))}))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let bi=null;function br(){return bi||(bi=new vr),bi}class $r{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=d.a4(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){let n=e+this.timeAdded;n<this.fadeEndTime||(this.fadeEndTime=n)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,n,o){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=(function(a,c){let m={};if(!c)return m;for(let _ of a){let y=_.layerIds.map((b=>c.getLayer(b))).filter(Boolean);if(y.length!==0){_.layers=y,_.stateDependentLayerIds&&(_.stateDependentLayers=_.stateDependentLayerIds.map((b=>y.filter((S=>S.id===b))[0])));for(let b of y)m[b.id]=_}}return m})(e.buckets,n.style),this.hasSymbolBuckets=!1;for(let a in this.buckets){let c=this.buckets[a];if(c instanceof d.a6){if(this.hasSymbolBuckets=!0,!o)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let a in this.buckets){let c=this.buckets[a];if(c instanceof d.a6&&c.hasRTLText){this.hasRTLText=!0,br().lazyLoad();break}}this.queryPadding=0;for(let a in this.buckets){let c=this.buckets[a];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(a).queryRadius(c))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new d.a5}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(let o in this.buckets){let a=this.buckets[o];a.uploadPending()&&a.upload(e)}let n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new et(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new et(e,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,n,o,a,c,m,_,y,b,S){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:a,cameraQueryGeometry:c,scale:m,tileSize:this.tileSize,pixelPosMatrix:S,transform:y,params:_,queryPadding:this.queryPadding*b},e,n,o):{}}querySourceFeatures(e,n){let o=this.latestFeatureIndex;if(!o||!o.rawTileData)return;let a=o.loadVTLayers(),c=n&&n.sourceLayer?n.sourceLayer:"",m=a._geojsonTileLayer||a[c];if(!m)return;let _=d.a7(n&&n.filter),{z:y,x:b,y:S}=this.tileID.canonical,T={z:y,x:b,y:S};for(let E=0;E<m.length;E++){let D=m.feature(E);if(_.needGeometry){let $=d.a8(D,!0);if(!_.filter(new d.z(this.tileID.overscaledZ),$,this.tileID.canonical))continue}else if(!_.filter(new d.z(this.tileID.overscaledZ),D))continue;let F=o.getId(D,c),V=new d.a9(D,y,b,S,F);V.tile=T,e.push(V)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let n=this.expirationTime;if(e.cacheControl){let o=d.aa(e.cacheControl);o["max-age"]&&(this.expirationTime=Date.now()+1e3*o["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let o=Date.now(),a=!1;if(this.expirationTime>o)a=!1;else if(n)if(this.expirationTime<n)a=!0;else{let c=this.expirationTime-n;c?this.expirationTime=o+Math.max(c,3e4):a=!0}else a=!0;a?(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(e,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(e).length===0)return;let o=this.latestFeatureIndex.loadVTLayers();for(let a in this.buckets){if(!n.style.hasLayer(a))continue;let c=this.buckets[a],m=c.layers[0].sourceLayer||"_geojsonTileLayer",_=o[m],y=e[m];if(!_||!y||Object.keys(y).length===0)continue;c.update(y,_,this.imageAtlas&&this.imageAtlas.patternPositions||{});let b=n&&n.style&&n.style.getLayer(a);b&&(this.queryPadding=Math.max(this.queryPadding,b.queryRadius(c)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<ue.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=ue.now()+e}setDependencies(e,n){let o={};for(let a of n)o[a]=!0;this.dependencies[e]=o}hasDependency(e,n){for(let o of e){let a=this.dependencies[o];if(a){for(let c of n)if(a[c])return!0}}return!1}}class we{constructor(e,n){this.max=e,this.onRemove=n,this.reset()}reset(){for(let e in this.data)for(let n of this.data[e])n.timeout&&clearTimeout(n.timeout),this.onRemove(n.value);return this.data={},this.order=[],this}add(e,n,o){let a=e.wrapped().key;this.data[a]===void 0&&(this.data[a]=[]);let c={value:n,timeout:void 0};if(o!==void 0&&(c.timeout=setTimeout((()=>{this.remove(e,c)}),o)),this.data[a].push(c),this.order.push(a),this.order.length>this.max){let m=this._getAndRemoveByKey(this.order[0]);m&&this.onRemove(m)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){let n=this.data[e].shift();return n.timeout&&clearTimeout(n.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),n.value}getByKey(e){let n=this.data[e];return n?n[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,n){if(!this.has(e))return this;let o=e.wrapped().key,a=n===void 0?0:this.data[o].indexOf(n),c=this.data[o][a];return this.data[o].splice(a,1),c.timeout&&clearTimeout(c.timeout),this.data[o].length===0&&delete this.data[o],this.onRemove(c.value),this.order.splice(this.order.indexOf(o),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(e){let n=[];for(let o in this.data)for(let a of this.data[o])e(a.value)||n.push(a);for(let o of n)this.remove(o.value.tileID,o)}}class rt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,n,o){let a=String(n);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][a]=this.stateChanges[e][a]||{},d.e(this.stateChanges[e][a],o),this.deletedStates[e]===null){this.deletedStates[e]={};for(let c in this.state[e])c!==a&&(this.deletedStates[e][c]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][a]===null){this.deletedStates[e][a]={};for(let c in this.state[e][a])o[c]||(this.deletedStates[e][a][c]=null)}else for(let c in o)this.deletedStates[e]&&this.deletedStates[e][a]&&this.deletedStates[e][a][c]===null&&delete this.deletedStates[e][a][c]}removeFeatureState(e,n,o){if(this.deletedStates[e]===null)return;let a=String(n);if(this.deletedStates[e]=this.deletedStates[e]||{},o&&n!==void 0)this.deletedStates[e][a]!==null&&(this.deletedStates[e][a]=this.deletedStates[e][a]||{},this.deletedStates[e][a][o]=null);else if(n!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][a])for(o in this.deletedStates[e][a]={},this.stateChanges[e][a])this.deletedStates[e][a][o]=null;else this.deletedStates[e][a]=null;else this.deletedStates[e]=null}getState(e,n){let o=String(n),a=d.e({},(this.state[e]||{})[o],(this.stateChanges[e]||{})[o]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let c=this.deletedStates[e][n];if(c===null)return{};for(let m in c)delete a[m]}return a}initializeTileState(e,n){e.setFeatureState(this.state,n)}coalesceChanges(e,n){let o={};for(let a in this.stateChanges){this.state[a]=this.state[a]||{};let c={};for(let m in this.stateChanges[a])this.state[a][m]||(this.state[a][m]={}),d.e(this.state[a][m],this.stateChanges[a][m]),c[m]=this.state[a][m];o[a]=c}for(let a in this.deletedStates){this.state[a]=this.state[a]||{};let c={};if(this.deletedStates[a]===null)for(let m in this.state[a])c[m]={},this.state[a][m]={};else for(let m in this.deletedStates[a]){if(this.deletedStates[a][m]===null)this.state[a][m]={};else for(let _ of Object.keys(this.deletedStates[a][m]))delete this.state[a][m][_];c[m]=this.state[a][m]}o[a]=o[a]||{},d.e(o[a],c)}if(this.stateChanges={},this.deletedStates={},Object.keys(o).length!==0)for(let a in e)e[a].setFeatureState(o,n)}}class Ze extends d.E{constructor(e,n,o){super(),this.id=e,this.dispatcher=o,this.on("data",(a=>this._dataHandler(a))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((a,c,m,_)=>{let y=new(ds(c.type))(a,c,m,_);if(y.id!==a)throw new Error(`Expected Source id to be ${a} instead of ${y.id}`);return y})(e,n,o,this),this._tiles={},this._cache=new we(0,(a=>this._unloadTile(a))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new rt,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(let e in this._tiles){let n=this._tiles[e];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;let e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,n,o){return d._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,n,o)}catch(a){e.state="errored",a.status!==404?this._source.fire(new d.j(a,{tile:e})):this.update(this.transform,this.terrain)}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new d.k("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(let n in this._tiles){let o=this._tiles[n];o.upload(e),o.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(Pi).map((e=>e.key))}getRenderableIds(e){let n=[];for(let o in this._tiles)this._isIdRenderable(o,e)&&n.push(this._tiles[o]);return e?n.sort(((o,a)=>{let c=o.tileID,m=a.tileID,_=new d.P(c.canonical.x,c.canonical.y)._rotate(this.transform.angle),y=new d.P(m.canonical.x,m.canonical.y)._rotate(this.transform.angle);return c.overscaledZ-m.overscaledZ||y.y-_.y||y.x-_.x})).map((o=>o.tileID.key)):n.map((o=>o.tileID)).sort(Pi).map((o=>o.key))}hasRenderableParent(e){let n=this.findLoadedParent(e,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(e,n){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(n||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(let e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(e,"reloading")}}_reloadTile(e,n){return d._(this,void 0,void 0,(function*(){let o=this._tiles[e];o&&(o.state!=="loading"&&(o.state=n),yield this._loadTile(o,e,n))}))}_tileLoaded(e,n,o){e.timeAdded=ue.now(),o==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),this.getSource().type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new d.k("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){let n=this.getRenderableIds();for(let a=0;a<n.length;a++){let c=n[a];if(e.neighboringTiles&&e.neighboringTiles[c]){let m=this.getTileByID(c);o(e,m),o(m,e)}}function o(a,c){a.needsHillshadePrepare=!0,a.needsTerrainPrepare=!0;let m=c.tileID.canonical.x-a.tileID.canonical.x,_=c.tileID.canonical.y-a.tileID.canonical.y,y=Math.pow(2,a.tileID.canonical.z),b=c.tileID.key;m===0&&_===0||Math.abs(_)>1||(Math.abs(m)>1&&(Math.abs(m+y)===1?m+=y:Math.abs(m-y)===1&&(m-=y)),c.dem&&a.dem&&(a.dem.backfillBorder(c.dem,m,_),a.neighboringTiles&&a.neighboringTiles[b]&&(a.neighboringTiles[b].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,n,o,a){for(let c in this._tiles){let m=this._tiles[c];if(a[c]||!m.hasData()||m.tileID.overscaledZ<=n||m.tileID.overscaledZ>o)continue;let _=m.tileID;for(;m&&m.tileID.overscaledZ>n+1;){let b=m.tileID.scaledTo(m.tileID.overscaledZ-1);m=this._tiles[b.key],m&&m.hasData()&&(_=b)}let y=_;for(;y.overscaledZ>n;)if(y=y.scaledTo(y.overscaledZ-1),e[y.key]){a[_.key]=_;break}}}findLoadedParent(e,n){if(e.key in this._loadedParentTiles){let o=this._loadedParentTiles[e.key];return o&&o.tileID.overscaledZ>=n?o:null}for(let o=e.overscaledZ-1;o>=n;o--){let a=e.scaledTo(o),c=this._getLoadedTile(a);if(c)return c}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){let n=this._tiles[e.key];return n&&n.hasData()?n:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){let n=Math.ceil(e.width/this._source.tileSize)+1,o=Math.ceil(e.height/this._source.tileSize)+1,a=Math.floor(n*o*(this._maxTileCacheZoomLevels===null?d.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),c=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(c)}handleWrapJump(e){let n=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,n){let o={};for(let a in this._tiles){let c=this._tiles[a];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+n),o[c.tileID.key]=c}this._tiles=o;for(let a in this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(let a in this._tiles)this._setTileReloadTimer(a,this._tiles[a])}}_updateCoveredAndRetainedTiles(e,n,o,a,c,m){let _={},y={},b=Object.keys(e),S=ue.now();for(let T of b){let E=e[T],D=this._tiles[T];if(!D||D.fadeEndTime!==0&&D.fadeEndTime<=S)continue;let F=this.findLoadedParent(E,n),V=this.findLoadedSibling(E),$=F||V||null;$&&(this._addTile($.tileID),_[$.tileID.key]=$.tileID),y[T]=E}this._retainLoadedChildren(y,a,o,e);for(let T in _)e[T]||(this._coveredTiles[T]=!0,e[T]=_[T]);if(m){let T={},E={};for(let D of c)this._tiles[D.key].hasData()?T[D.key]=D:E[D.key]=D;for(let D in E){let F=E[D].children(this._source.maxzoom);this._tiles[F[0].key]&&this._tiles[F[1].key]&&this._tiles[F[2].key]&&this._tiles[F[3].key]&&(T[F[0].key]=e[F[0].key]=F[0],T[F[1].key]=e[F[1].key]=F[1],T[F[2].key]=e[F[2].key]=F[2],T[F[3].key]=e[F[3].key]=F[3],delete E[D])}for(let D in E){let F=E[D],V=this.findLoadedParent(F,this._source.minzoom),$=this.findLoadedSibling(F),q=V||$||null;if(q){T[q.tileID.key]=e[q.tileID.key]=q.tileID;for(let G in T)T[G].isChildOf(q.tileID)&&delete T[G]}}for(let D in this._tiles)T[D]||(this._coveredTiles[D]=!0)}}update(e,n){if(!this._sourceLoaded||this._paused)return;let o;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((S=>new d.S(S.canonical.z,S.wrap,S.canonical.z,S.canonical.x,S.canonical.y))):(o=e.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n}),this._source.hasTile&&(o=o.filter((S=>this._source.hasTile(S))))):o=[];let a=e.coveringZoomLevel(this._source),c=Math.max(a-Ze.maxOverzooming,this._source.minzoom),m=Math.max(a+Ze.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){let S={};for(let T of o)if(T.canonical.z>this._source.minzoom){let E=T.scaledTo(T.canonical.z-1);S[E.key]=E;let D=T.scaledTo(Math.max(this._source.minzoom,Math.min(T.canonical.z,5)));S[D.key]=D}o=o.concat(Object.values(S))}let _=o.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,_&&this.fire(new d.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));let y=this._updateRetainedTiles(o,a);sr(this._source.type)&&this._updateCoveredAndRetainedTiles(y,c,m,a,o,n);for(let S in y)this._tiles[S].clearFadeHold();let b=d.ab(this._tiles,y);for(let S of b){let T=this._tiles[S];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(S)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(let e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,n){var o;let a={},c={},m=Math.max(n-Ze.maxOverzooming,this._source.minzoom),_=Math.max(n+Ze.maxUnderzooming,this._source.minzoom),y={};for(let b of e){let S=this._addTile(b);a[b.key]=b,S.hasData()||n<this._source.maxzoom&&(y[b.key]=b)}this._retainLoadedChildren(y,n,_,a);for(let b of e){let S=this._tiles[b.key];if(S.hasData())continue;if(n+1>this._source.maxzoom){let E=b.children(this._source.maxzoom)[0],D=this.getTile(E);if(D&&D.hasData()){a[E.key]=E;continue}}else{let E=b.children(this._source.maxzoom);if(a[E[0].key]&&a[E[1].key]&&a[E[2].key]&&a[E[3].key])continue}let T=S.wasRequested();for(let E=b.overscaledZ-1;E>=m;--E){let D=b.scaledTo(E);if(c[D.key])break;if(c[D.key]=!0,S=this.getTile(D),!S&&T&&(S=this._addTile(D)),S){let F=S.hasData();if((F||!(!((o=this.map)===null||o===void 0)&&o.cancelPendingTileRequestsWhileZooming)||T)&&(a[D.key]=D),T=S.wasRequested(),F)break}}}return a}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(let e in this._tiles){let n=[],o,a=this._tiles[e].tileID;for(;a.overscaledZ>0;){if(a.key in this._loadedParentTiles){o=this._loadedParentTiles[a.key];break}n.push(a.key);let c=a.scaledTo(a.overscaledZ-1);if(o=this._getLoadedTile(c),o)break;a=c}for(let c of n)this._loadedParentTiles[c]=o}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(let e in this._tiles){let n=this._tiles[e].tileID,o=this._getLoadedTile(n);this._loadedSiblingTiles[n.key]=o}}_addTile(e){let n=this._tiles[e.key];if(n)return n;n=this._cache.getAndRemove(e),n&&(this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,n)));let o=n;return n||(n=new $r(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._tiles[e.key]=n,o||this._source.fire(new d.k("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(e,n){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);let o=n.getExpiryTimeout();o&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),o))}_removeTile(e){let n=this._tiles[e];n&&(n.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(e){let n=e.sourceDataType;e.dataType==="source"&&n==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&e.dataType==="source"&&n==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,n,o){let a=[],c=this.transform;if(!c)return a;let m=o?c.getCameraQueryGeometry(e):e,_=e.map((F=>c.pointCoordinate(F,this.terrain))),y=m.map((F=>c.pointCoordinate(F,this.terrain))),b=this.getIds(),S=1/0,T=1/0,E=-1/0,D=-1/0;for(let F of y)S=Math.min(S,F.x),T=Math.min(T,F.y),E=Math.max(E,F.x),D=Math.max(D,F.y);for(let F=0;F<b.length;F++){let V=this._tiles[b[F]];if(V.holdingForFade())continue;let $=V.tileID,q=Math.pow(2,c.zoom-V.tileID.overscaledZ),G=n*V.queryPadding*d.X/V.tileSize/q,B=[$.getTilePoint(new d.Z(S,T)),$.getTilePoint(new d.Z(E,D))];if(B[0].x-G<d.X&&B[0].y-G<d.X&&B[1].x+G>=0&&B[1].y+G>=0){let J=_.map((ne=>$.getTilePoint(ne))),ee=y.map((ne=>$.getTilePoint(ne)));a.push({tile:V,tileID:$,queryGeometry:J,cameraQueryGeometry:ee,scale:q})}}return a}getVisibleCoordinates(e){let n=this.getRenderableIds(e).map((o=>this._tiles[o].tileID));for(let o of n)o.posMatrix=this.transform.calculatePosMatrix(o.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(sr(this._source.type)){let e=ue.now();for(let n in this._tiles)if(this._tiles[n].fadeEndTime>=e)return!0}return!1}setFeatureState(e,n,o){this._state.updateState(e=e||"_geojsonTileLayer",n,o)}removeFeatureState(e,n,o){this._state.removeFeatureState(e=e||"_geojsonTileLayer",n,o)}getFeatureState(e,n){return this._state.getState(e=e||"_geojsonTileLayer",n)}setDependencies(e,n,o){let a=this._tiles[e];a&&a.setDependencies(n,o)}reloadTilesForDependencies(e,n){for(let o in this._tiles)this._tiles[o].hasDependency(e,n)&&this._reloadTile(o,"reloading");this._cache.filter((o=>!o.hasDependency(e,n)))}}function Pi(h,e){let n=Math.abs(2*h.wrap)-+(h.wrap<0),o=Math.abs(2*e.wrap)-+(e.wrap<0);return h.overscaledZ-e.overscaledZ||o-n||e.canonical.y-h.canonical.y||e.canonical.x-h.canonical.x}function sr(h){return h==="raster"||h==="image"||h==="video"}Ze.maxOverzooming=10,Ze.maxUnderzooming=3;class Je{constructor(e,n){this.reset(e,n)}reset(e,n){this.points=e||[],this._distances=[0];for(let o=1;o<this.points.length;o++)this._distances[o]=this._distances[o-1]+this.points[o].dist(this.points[o-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(this.points.length===1)return this.points[0];e=d.ac(e,0,1);let n=1,o=this._distances[n],a=e*this.paddedLength+this.padding;for(;o<a&&n<this._distances.length;)o=this._distances[++n];let c=n-1,m=this._distances[c],_=o-m,y=_>0?(a-m)/_:0;return this.points[c].mult(1-y).add(this.points[n].mult(y))}}function wr(h,e){let n=!0;return h==="always"||h!=="never"&&e!=="never"||(n=!1),n}class Lr{constructor(e,n,o){let a=this.boxCells=[],c=this.circleCells=[];this.xCellCount=Math.ceil(e/o),this.yCellCount=Math.ceil(n/o);for(let m=0;m<this.xCellCount*this.yCellCount;m++)a.push([]),c.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=n,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,n,o,a,c){this._forEachCell(n,o,a,c,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(n),this.bboxes.push(o),this.bboxes.push(a),this.bboxes.push(c)}insertCircle(e,n,o,a){this._forEachCell(n-a,o-a,n+a,o+a,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(n),this.circles.push(o),this.circles.push(a)}_insertBoxCell(e,n,o,a,c,m){this.boxCells[c].push(m)}_insertCircleCell(e,n,o,a,c,m){this.circleCells[c].push(m)}_query(e,n,o,a,c,m,_){if(o<0||e>this.width||a<0||n>this.height)return[];let y=[];if(e<=0&&n<=0&&this.width<=o&&this.height<=a){if(c)return[{key:null,x1:e,y1:n,x2:o,y2:a}];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++){let S=this.circles[3*b],T=this.circles[3*b+1],E=this.circles[3*b+2];y.push({key:this.circleKeys[b],x1:S-E,y1:T-E,x2:S+E,y2:T+E})}}else this._forEachCell(e,n,o,a,this._queryCell,y,{hitTest:c,overlapMode:m,seenUids:{box:{},circle:{}}},_);return y}query(e,n,o,a){return this._query(e,n,o,a,!1,null)}hitTest(e,n,o,a,c,m){return this._query(e,n,o,a,!0,c,m).length>0}hitTestCircle(e,n,o,a,c){let m=e-o,_=e+o,y=n-o,b=n+o;if(_<0||m>this.width||b<0||y>this.height)return!1;let S=[];return this._forEachCell(m,y,_,b,this._queryCellCircle,S,{hitTest:!0,overlapMode:a,circle:{x:e,y:n,radius:o},seenUids:{box:{},circle:{}}},c),S.length>0}_queryCell(e,n,o,a,c,m,_,y){let{seenUids:b,hitTest:S,overlapMode:T}=_,E=this.boxCells[c];if(E!==null){let F=this.bboxes;for(let V of E)if(!b.box[V]){b.box[V]=!0;let $=4*V,q=this.boxKeys[V];if(e<=F[$+2]&&n<=F[$+3]&&o>=F[$+0]&&a>=F[$+1]&&(!y||y(q))&&(!S||!wr(T,q.overlapMode))&&(m.push({key:q,x1:F[$],y1:F[$+1],x2:F[$+2],y2:F[$+3]}),S))return!0}}let D=this.circleCells[c];if(D!==null){let F=this.circles;for(let V of D)if(!b.circle[V]){b.circle[V]=!0;let $=3*V,q=this.circleKeys[V];if(this._circleAndRectCollide(F[$],F[$+1],F[$+2],e,n,o,a)&&(!y||y(q))&&(!S||!wr(T,q.overlapMode))){let G=F[$],B=F[$+1],J=F[$+2];if(m.push({key:q,x1:G-J,y1:B-J,x2:G+J,y2:B+J}),S)return!0}}}return!1}_queryCellCircle(e,n,o,a,c,m,_,y){let{circle:b,seenUids:S,overlapMode:T}=_,E=this.boxCells[c];if(E!==null){let F=this.bboxes;for(let V of E)if(!S.box[V]){S.box[V]=!0;let $=4*V,q=this.boxKeys[V];if(this._circleAndRectCollide(b.x,b.y,b.radius,F[$+0],F[$+1],F[$+2],F[$+3])&&(!y||y(q))&&!wr(T,q.overlapMode))return m.push(!0),!0}}let D=this.circleCells[c];if(D!==null){let F=this.circles;for(let V of D)if(!S.circle[V]){S.circle[V]=!0;let $=3*V,q=this.circleKeys[V];if(this._circlesCollide(F[$],F[$+1],F[$+2],b.x,b.y,b.radius)&&(!y||y(q))&&!wr(T,q.overlapMode))return m.push(!0),!0}}}_forEachCell(e,n,o,a,c,m,_,y){let b=this._convertToXCellCoord(e),S=this._convertToYCellCoord(n),T=this._convertToXCellCoord(o),E=this._convertToYCellCoord(a);for(let D=b;D<=T;D++)for(let F=S;F<=E;F++)if(c.call(this,e,n,o,a,this.xCellCount*F+D,m,_,y))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,n,o,a,c,m){let _=a-e,y=c-n,b=o+m;return b*b>_*_+y*y}_circleAndRectCollide(e,n,o,a,c,m,_){let y=(m-a)/2,b=Math.abs(e-(a+y));if(b>y+o)return!1;let S=(_-c)/2,T=Math.abs(n-(c+S));if(T>S+o)return!1;if(b<=y||T<=S)return!0;let E=b-y,D=T-S;return E*E+D*D<=o*o}}function qr(h,e,n,o,a){let c=d.H();return e?(d.K(c,c,[1/a,1/a,1]),n||d.ad(c,c,o.angle)):d.L(c,o.labelPlaneMatrix,h),c}function Sr(h,e,n,o,a){if(e){let c=d.ae(h);return d.K(c,c,[a,a,1]),n||d.ad(c,c,-o.angle),c}return o.glCoordMatrix}function U(h,e,n,o){let a;o?(a=[h,e,o(h,e),1],d.af(a,a,n)):(a=[h,e,0,1],dt(a,a,n));let c=a[3];return{point:new d.P(a[0]/c,a[1]/c),signedDistanceFromCamera:c,isOccluded:!1}}function M(h,e){return .5+h/e*.5}function P(h,e){return h.x>=-e[0]&&h.x<=e[0]&&h.y>=-e[1]&&h.y<=e[1]}function R(h,e,n,o,a,c,m,_,y,b,S,T,E,D,F){let V=o?h.textSizeData:h.iconSizeData,$=d.ag(V,n.transform.zoom),q=[256/n.width*2+1,256/n.height*2+1],G=o?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;G.clear();let B=h.lineVertexArray,J=o?h.text.placedSymbolArray:h.icon.placedSymbolArray,ee=n.transform.width/n.transform.height,ne=!1;for(let de=0;de<J.length;de++){let ge=J.get(de);if(ge.hidden||ge.writingMode===d.ah.vertical&&!ne){Ue(ge.numGlyphs,G);continue}ne=!1;let Ie=U(ge.anchorX,ge.anchorY,e,F);if(!P(Ie.point,q)){Ue(ge.numGlyphs,G);continue}let Ae=M(n.transform.cameraToCenterDistance,Ie.signedDistanceFromCamera),be=d.ai(V,$,ge),ve=m?be/Ae:be*Ae,Re={getElevation:F,labelPlaneMatrix:a,lineVertexArray:B,pitchWithMap:m,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},projection:b,tileAnchorPoint:new d.P(ge.anchorX,ge.anchorY),unwrappedTileID:S,width:T,height:E,translation:D},We=Y(Re,ge,ve,!1,_,e,c,h.glyphOffsetArray,G,ee,y);ne=We.useVertical,(We.notEnoughRoom||ne||We.needsFlipping&&Y(Re,ge,ve,!0,_,e,c,h.glyphOffsetArray,G,ee,y).notEnoughRoom)&&Ue(ge.numGlyphs,G)}o?h.text.dynamicLayoutVertexBuffer.updateData(G):h.icon.dynamicLayoutVertexBuffer.updateData(G)}function N(h,e,n,o,a,c,m,_){let y=c.glyphStartIndex+c.numGlyphs,b=c.lineStartIndex,S=c.lineStartIndex+c.lineLength,T=e.getoffsetX(c.glyphStartIndex),E=e.getoffsetX(y-1),D=xe(h*T,n,o,a,c.segment,b,S,_,m);if(!D)return null;let F=xe(h*E,n,o,a,c.segment,b,S,_,m);return F?_.projectionCache.anyProjectionOccluded?null:{first:D,last:F}:null}function X(h,e,n,o){return h===d.ah.horizontal&&Math.abs(n.y-e.y)>Math.abs(n.x-e.x)*o?{useVertical:!0}:(h===d.ah.vertical?e.y<n.y:e.x>n.x)?{needsFlipping:!0}:null}function Y(h,e,n,o,a,c,m,_,y,b,S){let T=n/24,E=e.lineOffsetX*T,D=e.lineOffsetY*T,F;if(e.numGlyphs>1){let V=e.glyphStartIndex+e.numGlyphs,$=e.lineStartIndex,q=e.lineStartIndex+e.lineLength,G=N(T,_,E,D,o,e,S,h);if(!G)return{notEnoughRoom:!0};let B=U(G.first.point.x,G.first.point.y,m,h.getElevation).point,J=U(G.last.point.x,G.last.point.y,m,h.getElevation).point;if(a&&!o){let ee=X(e.writingMode,B,J,b);if(ee)return ee}F=[G.first];for(let ee=e.glyphStartIndex+1;ee<V-1;ee++)F.push(xe(T*_.getoffsetX(ee),E,D,o,e.segment,$,q,h,S));F.push(G.last)}else{if(a&&!o){let $=U(h.tileAnchorPoint.x,h.tileAnchorPoint.y,c,h.getElevation).point,q=e.lineStartIndex+e.segment+1,G=new d.P(h.lineVertexArray.getx(q),h.lineVertexArray.gety(q)),B=U(G.x,G.y,c,h.getElevation),J=B.signedDistanceFromCamera>0?B.point:(function(ne,de,ge,Ie,Ae,be){return ie(ne,de,ge,1,Ae,be)})(h.tileAnchorPoint,G,$,0,c,h),ee=X(e.writingMode,$,J,b);if(ee)return ee}let V=xe(T*_.getoffsetX(e.glyphStartIndex),E,D,o,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,h,S);if(!V||h.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};F=[V]}for(let V of F)d.aj(y,V.point,V.angle);return{}}function ie(h,e,n,o,a,c){let m=h.add(h.sub(e)._unit()),_=a!==void 0?U(m.x,m.y,a,c.getElevation).point:ce(m.x,m.y,c).point,y=n.sub(_);return n.add(y._mult(o/y.mag()))}function Z(h,e,n){let o=e.projectionCache;if(o.projections[h])return o.projections[h];let a=new d.P(e.lineVertexArray.getx(h),e.lineVertexArray.gety(h)),c=ce(a.x,a.y,e);if(c.signedDistanceFromCamera>0)return o.projections[h]=c.point,o.anyProjectionOccluded=o.anyProjectionOccluded||c.isOccluded,c.point;let m=h-n.direction;return(function(_,y,b,S,T){return ie(_,y,b,S,void 0,T)})(n.distanceFromAnchor===0?e.tileAnchorPoint:new d.P(e.lineVertexArray.getx(m),e.lineVertexArray.gety(m)),a,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,e)}function ce(h,e,n){let o=h+n.translation[0],a=e+n.translation[1],c;return!n.pitchWithMap&&n.projection.useSpecialProjectionForSymbols?(c=n.projection.projectTileCoordinates(o,a,n.unwrappedTileID,n.getElevation),c.point.x=(.5*c.point.x+.5)*n.width,c.point.y=(.5*-c.point.y+.5)*n.height):(c=U(o,a,n.labelPlaneMatrix,n.getElevation),c.isOccluded=!1),c}function pe(h,e,n){return h._unit()._perp()._mult(e*n)}function se(h,e,n,o,a,c,m,_,y){if(_.projectionCache.offsets[h])return _.projectionCache.offsets[h];let b=n.add(e);if(h+y.direction<o||h+y.direction>=a)return _.projectionCache.offsets[h]=b,b;let S=Z(h+y.direction,_,y),T=pe(S.sub(n),m,y.direction),E=n.add(T),D=S.add(T);return _.projectionCache.offsets[h]=d.ak(c,b,E,D)||b,_.projectionCache.offsets[h]}function xe(h,e,n,o,a,c,m,_,y){let b=o?h-e:h+e,S=b>0?1:-1,T=0;o&&(S*=-1,T=Math.PI),S<0&&(T+=Math.PI);let E,D=S>0?c+a:c+a+1;_.projectionCache.cachedAnchorPoint?E=_.projectionCache.cachedAnchorPoint:(E=ce(_.tileAnchorPoint.x,_.tileAnchorPoint.y,_).point,_.projectionCache.cachedAnchorPoint=E);let F,V,$=E,q=E,G=0,B=0,J=Math.abs(b),ee=[],ne;for(;G+B<=J;){if(D+=S,D<c||D>=m)return null;G+=B,q=$,V=F;let Ie={absOffsetX:J,direction:S,distanceFromAnchor:G,previousVertex:q};if($=Z(D,_,Ie),n===0)ee.push(q),ne=$.sub(q);else{let Ae,be=$.sub(q);Ae=be.mag()===0?pe(Z(D+S,_,Ie).sub($),n,S):pe(be,n,S),V||(V=q.add(Ae)),F=se(D,Ae,$,c,m,V,n,_,Ie),ee.push(V),ne=F.sub(V)}B=ne.mag()}let de=ne._mult((J-G)/B)._add(V||q),ge=T+Math.atan2($.y-q.y,$.x-q.x);return ee.push(de),{point:de,angle:y?ge:0,path:ee}}let Ne=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Ue(h,e){for(let n=0;n<h;n++){let o=e.length;e.resize(o+4),e.float32.set(Ne,3*o)}}function dt(h,e,n){let o=e[0],a=e[1];return h[0]=n[0]*o+n[4]*a+n[12],h[1]=n[1]*o+n[5]*a+n[13],h[3]=n[3]*o+n[7]*a+n[15],h}let Qe=100;class pt{constructor(e,n,o=new Lr(e.width+200,e.height+200,25),a=new Lr(e.width+200,e.height+200,25)){this.transform=e,this.mapProjection=n,this.grid=o,this.ignoredGrid=a,this.pitchFactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Qe,this.screenBottomBoundary=e.height+Qe,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,n,o,a,c,m,_,y,b,S,T){let E=e.anchorPointX+y[0],D=e.anchorPointY+y[1],F=this.projectAndGetPerspectiveRatio(a,E,D,c,S),V=o*F.perspectiveRatio,$;if(m||_)$=this._projectCollisionBox(e,V,a,c,m,_,y,F,S,T);else{let ee=F.point.x+(T?T.x*V:0),ne=F.point.y+(T?T.y*V:0);$={allPointsOccluded:!1,box:[ee+e.x1*V,ne+e.y1*V,ee+e.x2*V,ne+e.y2*V]}}let[q,G,B,J]=$.box;return this.mapProjection.useSpecialProjectionForSymbols&&(m?$.allPointsOccluded:this.mapProjection.isOccluded(E,D,c))||F.perspectiveRatio<this.perspectiveRatioCutoff||!this.isInsideGrid(q,G,B,J)||n!=="always"&&this.grid.hitTest(q,G,B,J,n,b)?{box:[q,G,B,J],placeable:!1,offscreen:!1}:{box:[q,G,B,J],placeable:!0,offscreen:this.isOffscreen(q,G,B,J)}}placeCollisionCircles(e,n,o,a,c,m,_,y,b,S,T,E,D,F,V,$){let q=[],G=new d.P(n.anchorX,n.anchorY),B=this.getPerspectiveRatio(m,G.x,G.y,_,$),J=(T?c/B:c*B)/d.ap,ee={getElevation:$,labelPlaneMatrix:y,lineVertexArray:o,pitchWithMap:T,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},projection:this.mapProjection,tileAnchorPoint:G,unwrappedTileID:_,width:this.transform.width,height:this.transform.height,translation:V},ne=N(J,a,n.lineOffsetX*J,n.lineOffsetY*J,!1,n,!1,ee),de=!1,ge=!1,Ie=!0;if(ne){let Ae=.5*D*B+F,be=new d.P(-100,-100),ve=new d.P(this.screenRightBoundary,this.screenBottomBoundary),Re=new Je,We=ne.first,Se=ne.last,Pe=[];for(let tt=We.path.length-1;tt>=1;tt--)Pe.push(We.path[tt]);for(let tt=1;tt<Se.path.length;tt++)Pe.push(Se.path[tt]);let Ge=2.5*Ae;if(b){let tt=this.projectPathToScreenSpace(Pe,ee,b);Pe=tt.some((lt=>lt.signedDistanceFromCamera<=0))?[]:tt.map((lt=>lt.point))}let Lt=[];if(Pe.length>0){let tt=Pe[0].clone(),lt=Pe[0].clone();for(let Dt=1;Dt<Pe.length;Dt++)tt.x=Math.min(tt.x,Pe[Dt].x),tt.y=Math.min(tt.y,Pe[Dt].y),lt.x=Math.max(lt.x,Pe[Dt].x),lt.y=Math.max(lt.y,Pe[Dt].y);Lt=tt.x>=be.x&&lt.x<=ve.x&&tt.y>=be.y&&lt.y<=ve.y?[Pe]:lt.x<be.x||tt.x>ve.x||lt.y<be.y||tt.y>ve.y?[]:d.al([Pe],be.x,be.y,ve.x,ve.y)}for(let tt of Lt){Re.reset(tt,.25*Ae);let lt=0;lt=Re.length<=.5*Ae?1:Math.ceil(Re.paddedLength/Ge)+1;for(let Dt=0;Dt<lt;Dt++){let pi=Dt/Math.max(lt-1,1),ur=Re.lerp(pi),Rt=ur.x+Qe,Ei=ur.y+Qe;q.push(Rt,Ei,Ae,0);let Si=Rt-Ae,fi=Ei-Ae,Ti=Rt+Ae,Pr=Ei+Ae;if(Ie=Ie&&this.isOffscreen(Si,fi,Ti,Pr),ge=ge||this.isInsideGrid(Si,fi,Ti,Pr),e!=="always"&&this.grid.hitTestCircle(Rt,Ei,Ae,e,E)&&(de=!0,!S))return{circles:[],offscreen:!1,collisionDetected:de}}}}return{circles:!S&&de||!ge||B<this.perspectiveRatioCutoff?[]:q,offscreen:Ie,collisionDetected:de}}projectPathToScreenSpace(e,n,o){return e.map((a=>U(a.x,a.y,o,n.getElevation)))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let n=[],o=1/0,a=1/0,c=-1/0,m=-1/0;for(let S of e){let T=new d.P(S.x+Qe,S.y+Qe);o=Math.min(o,T.x),a=Math.min(a,T.y),c=Math.max(c,T.x),m=Math.max(m,T.y),n.push(T)}let _=this.grid.query(o,a,c,m).concat(this.ignoredGrid.query(o,a,c,m)),y={},b={};for(let S of _){let T=S.key;if(y[T.bucketInstanceId]===void 0&&(y[T.bucketInstanceId]={}),y[T.bucketInstanceId][T.featureIndex])continue;let E=[new d.P(S.x1,S.y1),new d.P(S.x2,S.y1),new d.P(S.x2,S.y2),new d.P(S.x1,S.y2)];d.am(n,E)&&(y[T.bucketInstanceId][T.featureIndex]=!0,b[T.bucketInstanceId]===void 0&&(b[T.bucketInstanceId]=[]),b[T.bucketInstanceId].push(T.featureIndex))}return b}insertCollisionBox(e,n,o,a,c,m){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:a,featureIndex:c,collisionGroupID:m,overlapMode:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,n,o,a,c,m){let _=o?this.ignoredGrid:this.grid,y={bucketInstanceId:a,featureIndex:c,collisionGroupID:m,overlapMode:n};for(let b=0;b<e.length;b+=4)_.insertCircle(y,e[b],e[b+1],e[b+2])}projectAndGetPerspectiveRatio(e,n,o,a,c){let m;c?(m=[n,o,c(n,o),1],d.af(m,m,e)):(m=[n,o,0,1],dt(m,m,e));let _=m[3];return{point:new d.P((m[0]/_+1)/2*this.transform.width+Qe,(-m[1]/_+1)/2*this.transform.height+Qe),perspectiveRatio:.5+this.transform.cameraToCenterDistance/_*.5,isOccluded:!1,signedDistanceFromCamera:_}}getPerspectiveRatio(e,n,o,a,c){let m=this.mapProjection.useSpecialProjectionForSymbols?this.mapProjection.projectTileCoordinates(n,o,a,c):U(n,o,e,c);return .5+this.transform.cameraToCenterDistance/m.signedDistanceFromCamera*.5}isOffscreen(e,n,o,a){return o<Qe||e>=this.screenRightBoundary||a<Qe||n>this.screenBottomBoundary}isInsideGrid(e,n,o,a){return o>=0&&e<this.gridRightBoundary&&a>=0&&n<this.gridBottomBoundary}getViewportMatrix(){let e=d.an([]);return d.J(e,e,[-100,-100,0]),e}_projectCollisionBox(e,n,o,a,c,m,_,y,b,S){let T=new d.P(1,0),E=new d.P(0,1),D=new d.P(e.anchorPointX+_[0],e.anchorPointY+_[1]);if(m&&!c){let Ie=this.projectAndGetPerspectiveRatio(o,D.x+1,D.y,a,b).point.sub(y.point).unit(),Ae=Math.atan(Ie.y/Ie.x)+(Ie.x<0?Math.PI:0),be=Math.sin(Ae),ve=Math.cos(Ae);T=new d.P(ve,be),E=new d.P(-be,ve)}else if(!m&&c){let Ie=-this.transform.angle,Ae=Math.sin(Ie),be=Math.cos(Ie);T=new d.P(be,Ae),E=new d.P(-Ae,be)}let F=y.point,V=n;if(c){F=D;let Ie=this.transform.zoom-Math.floor(this.transform.zoom);V=Math.pow(2,-Ie),V*=this.mapProjection.getPitchedTextCorrection(this.transform,D,a),S||(V*=d.ac(.5+y.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))}S&&(F=F.add(T.mult(S.x*V)).add(E.mult(S.y*V)));let $=e.x1*V,q=e.x2*V,G=($+q)/2,B=e.y1*V,J=e.y2*V,ee=(B+J)/2,ne=[{offsetX:$,offsetY:B},{offsetX:G,offsetY:B},{offsetX:q,offsetY:B},{offsetX:q,offsetY:ee},{offsetX:q,offsetY:J},{offsetX:G,offsetY:J},{offsetX:$,offsetY:J},{offsetX:$,offsetY:ee}],de=[];for(let{offsetX:Ie,offsetY:Ae}of ne)de.push(new d.P(F.x+T.x*Ie+E.x*Ae,F.y+T.y*Ie+E.y*Ae));let ge=!1;if(c){let Ie=de.map((Ae=>this.projectAndGetPerspectiveRatio(o,Ae.x,Ae.y,a,b)));ge=Ie.some((Ae=>!Ae.isOccluded)),de=Ie.map((Ae=>Ae.point))}else ge=!0;return{box:d.ao(de),allPointsOccluded:!ge}}}function at(h,e,n){return e*(d.X/(h.tileSize*Math.pow(2,n-h.tileID.overscaledZ)))}class Jt{constructor(e,n,o,a){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?n:-n))):a&&o?1:0,this.placed=o}isHidden(){return this.opacity===0&&!this.placed}}class Ut{constructor(e,n,o,a,c){this.text=new Jt(e?e.text:null,n,o,c),this.icon=new Jt(e?e.icon:null,n,a,c)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class nt{constructor(e,n,o){this.text=e,this.icon=n,this.skipFade=o}}class vt{constructor(){this.invProjMatrix=d.H(),this.viewportMatrix=d.H(),this.circles=[]}}class Ot{constructor(e,n,o,a,c){this.bucketInstanceId=e,this.featureIndex=n,this.sourceLayerIndex=o,this.bucketIndex=a,this.tileID=c}}class ni{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){let n=++this.maxGroupID;this.collisionGroups[e]={ID:n,predicate:o=>o.collisionGroupID===n}}return this.collisionGroups[e]}}function li(h,e,n,o,a){let{horizontalAlign:c,verticalAlign:m}=d.au(h);return new d.P(-(c-.5)*e+o[0]*a,-(m-.5)*n+o[1]*a)}class wi{constructor(e,n,o,a,c,m){this.transform=e.clone(),this.terrain=o,this.collisionIndex=new pt(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new ni(c),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=m,m&&(m.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let n=this.terrain;return n?(o,a)=>n.getElevation(e,o,a):null}getBucketParts(e,n,o,a){let c=o.getBucket(n),m=o.latestFeatureIndex;if(!c||!m||n.id!==c.layerIds[0])return;let _=o.collisionBoxArray,y=c.layers[0].layout,b=c.layers[0].paint,S=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),T=o.tileSize/d.X,E=o.tileID.toUnwrapped(),D=this.transform.calculatePosMatrix(E),F=y.get("text-pitch-alignment")==="map",V=y.get("text-rotation-alignment")==="map",$=at(o,1,this.transform.zoom),q=this.collisionIndex.mapProjection.translatePosition(this.transform,o,b.get("text-translate"),b.get("text-translate-anchor")),G=this.collisionIndex.mapProjection.translatePosition(this.transform,o,b.get("icon-translate"),b.get("icon-translate-anchor")),B=qr(D,F,V,this.transform,$),J=null;if(F){let ne=Sr(D,F,V,this.transform,$);J=d.L([],this.transform.labelPlaneMatrix,ne)}this.retainedQueryData[c.bucketInstanceId]=new Ot(c.bucketInstanceId,m,c.sourceLayerIndex,c.index,o.tileID);let ee={bucket:c,layout:y,translationText:q,translationIcon:G,posMatrix:D,unwrappedTileID:E,textLabelPlaneMatrix:B,labelToScreenMatrix:J,scale:S,textPixelRatio:T,holdingForFade:o.holdingForFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:d.ag(c.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(c.sourceID)};if(a)for(let ne of c.sortKeyRanges){let{sortKey:de,symbolInstanceStart:ge,symbolInstanceEnd:Ie}=ne;e.push({sortKey:de,symbolInstanceStart:ge,symbolInstanceEnd:Ie,parameters:ee})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:c.symbolInstances.length,parameters:ee})}attemptAnchorPlacement(e,n,o,a,c,m,_,y,b,S,T,E,D,F,V,$,q,G,B){let J=d.aq[e.textAnchor],ee=[e.textOffset0,e.textOffset1],ne=li(J,o,a,ee,c),de=this.collisionIndex.placeCollisionBox(n,E,y,b,S,_,m,$,T.predicate,B,ne);if((!G||this.collisionIndex.placeCollisionBox(G,E,y,b,S,_,m,q,T.predicate,B,ne).placeable)&&de.placeable){let ge;if(this.prevPlacement&&this.prevPlacement.variableOffsets[D.crossTileID]&&this.prevPlacement.placements[D.crossTileID]&&this.prevPlacement.placements[D.crossTileID].text&&(ge=this.prevPlacement.variableOffsets[D.crossTileID].anchor),D.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[D.crossTileID]={textOffset:ee,width:o,height:a,anchor:J,textBoxScale:c,prevAnchor:ge},this.markUsedJustification(F,J,D,V),F.allowVerticalPlacement&&(this.markUsedOrientation(F,V,D),this.placedOrientations[D.crossTileID]=V),{shift:ne,placedGlyphBoxes:de}}}placeLayerBucketPart(e,n,o){let{bucket:a,layout:c,translationText:m,translationIcon:_,posMatrix:y,unwrappedTileID:b,textLabelPlaneMatrix:S,labelToScreenMatrix:T,textPixelRatio:E,holdingForFade:D,collisionBoxArray:F,partiallyEvaluatedTextSize:V,collisionGroup:$}=e.parameters,q=c.get("text-optional"),G=c.get("icon-optional"),B=d.ar(c,"text-overlap","text-allow-overlap"),J=B==="always",ee=d.ar(c,"icon-overlap","icon-allow-overlap"),ne=ee==="always",de=c.get("text-rotation-alignment")==="map",ge=c.get("text-pitch-alignment")==="map",Ie=c.get("icon-text-fit")!=="none",Ae=c.get("symbol-z-order")==="viewport-y",be=J&&(ne||!a.hasIconData()||G),ve=ne&&(J||!a.hasTextData()||q);!a.collisionArrays&&F&&a.deserializeCollisionBoxes(F);let Re=this._getTerrainElevationFunc(this.retainedQueryData[a.bucketInstanceId].tileID),We=(Se,Pe,Ge)=>{var Lt,tt;if(n[Se.crossTileID])return;if(D)return void(this.placements[Se.crossTileID]=new nt(!1,!1,!1));let lt=!1,Dt=!1,pi=!0,ur=null,Rt={box:null,placeable:!1,offscreen:null},Ei={box:null,placeable:!1,offscreen:null},Si=null,fi=null,Ti=null,Pr=0,Gn=0,yo=0;Pe.textFeatureIndex?Pr=Pe.textFeatureIndex:Se.useRuntimeCollisionCircles&&(Pr=Se.featureIndex),Pe.verticalTextFeatureIndex&&(Gn=Pe.verticalTextFeatureIndex);let Hn=Pe.textBox;if(Hn){let Ji=ci=>{let mi=d.ah.horizontal;if(a.allowVerticalPlacement&&!ci&&this.prevPlacement){let ji=this.prevPlacement.placedOrientations[Se.crossTileID];ji&&(this.placedOrientations[Se.crossTileID]=ji,mi=ji,this.markUsedOrientation(a,mi,Se))}return mi},Yi=(ci,mi)=>{if(a.allowVerticalPlacement&&Se.numVerticalGlyphVertices>0&&Pe.verticalTextBox){for(let ji of a.writingModes)if(ji===d.ah.vertical?(Rt=mi(),Ei=Rt):Rt=ci(),Rt&&Rt.placeable)break}else Rt=ci()},Hr=Se.textAnchorOffsetStartIndex,dr=Se.textAnchorOffsetEndIndex;if(dr===Hr){let ci=(mi,ji)=>{let ut=this.collisionIndex.placeCollisionBox(mi,B,E,y,b,ge,de,m,$.predicate,Re);return ut&&ut.placeable&&(this.markUsedOrientation(a,ji,Se),this.placedOrientations[Se.crossTileID]=ji),ut};Yi((()=>ci(Hn,d.ah.horizontal)),(()=>{let mi=Pe.verticalTextBox;return a.allowVerticalPlacement&&Se.numVerticalGlyphVertices>0&&mi?ci(mi,d.ah.vertical):{box:null,offscreen:null}})),Ji(Rt&&Rt.placeable)}else{let ci=d.aq[(tt=(Lt=this.prevPlacement)===null||Lt===void 0?void 0:Lt.variableOffsets[Se.crossTileID])===null||tt===void 0?void 0:tt.anchor],mi=(ut,mn,Wn)=>{let Xn=ut.x2-ut.x1,El=ut.y2-ut.y1,Rc=Se.textBoxScale,kl=Ie&&ee==="never"?mn:null,Wr=null,zl=B==="never"?1:2,vo="never";ci&&zl++;for(let ks=0;ks<zl;ks++){for(let bo=Hr;bo<dr;bo++){let wo=a.textAnchorOffsets.get(bo);if(ci&&wo.textAnchor!==ci)continue;let Kn=this.attemptAnchorPlacement(wo,ut,Xn,El,Rc,de,ge,E,y,b,$,vo,Se,a,Wn,m,_,kl,Re);if(Kn&&(Wr=Kn.placedGlyphBoxes,Wr&&Wr.placeable))return lt=!0,ur=Kn.shift,Wr}ci?ci=null:vo=B}return o&&!Wr&&(Wr={box:this.collisionIndex.placeCollisionBox(Hn,"always",E,y,b,ge,de,m,$.predicate,Re,new d.P(0,0)).box,offscreen:!1,placeable:!1}),Wr};Yi((()=>mi(Hn,Pe.iconBox,d.ah.horizontal)),(()=>{let ut=Pe.verticalTextBox;return a.allowVerticalPlacement&&(!Rt||!Rt.placeable)&&Se.numVerticalGlyphVertices>0&&ut?mi(ut,Pe.verticalIconBox,d.ah.vertical):{box:null,occluded:!0,offscreen:null}})),Rt&&(lt=Rt.placeable,pi=Rt.offscreen);let ji=Ji(Rt&&Rt.placeable);if(!lt&&this.prevPlacement){let ut=this.prevPlacement.variableOffsets[Se.crossTileID];ut&&(this.variableOffsets[Se.crossTileID]=ut,this.markUsedJustification(a,ut.anchor,Se,ji))}}}if(Si=Rt,lt=Si&&Si.placeable,pi=Si&&Si.offscreen,Se.useRuntimeCollisionCircles){let Ji=a.text.placedSymbolArray.get(Se.centerJustifiedTextSymbolIndex),Yi=d.ai(a.textSizeData,V,Ji),Hr=c.get("text-padding");fi=this.collisionIndex.placeCollisionCircles(B,Ji,a.lineVertexArray,a.glyphOffsetArray,Yi,y,b,S,T,o,ge,$.predicate,Se.collisionCircleDiameter,Hr,m,Re),fi.circles.length&&fi.collisionDetected&&!o&&d.w("Collisions detected, but collision boxes are not shown"),lt=J||fi.circles.length>0&&!fi.collisionDetected,pi=pi&&fi.offscreen}if(Pe.iconFeatureIndex&&(yo=Pe.iconFeatureIndex),Pe.iconBox){let Ji=Yi=>this.collisionIndex.placeCollisionBox(Yi,ee,E,y,b,ge,de,_,$.predicate,Re,Ie&&ur?ur:void 0);Ei&&Ei.placeable&&Pe.verticalIconBox?(Ti=Ji(Pe.verticalIconBox),Dt=Ti.placeable):(Ti=Ji(Pe.iconBox),Dt=Ti.placeable),pi=pi&&Ti.offscreen}let Ki=q||Se.numHorizontalGlyphVertices===0&&Se.numVerticalGlyphVertices===0,xo=G||Se.numIconVertices===0;Ki||xo?xo?Ki||(Dt=Dt&&lt):lt=Dt&&lt:Dt=lt=Dt&&lt;let Pa=Dt&&Ti.placeable;if(lt&&Si.placeable&&this.collisionIndex.insertCollisionBox(Si.box,B,c.get("text-ignore-placement"),a.bucketInstanceId,Ei&&Ei.placeable&&Gn?Gn:Pr,$.ID),Pa&&this.collisionIndex.insertCollisionBox(Ti.box,ee,c.get("icon-ignore-placement"),a.bucketInstanceId,yo,$.ID),fi&&lt&&this.collisionIndex.insertCollisionCircles(fi.circles,B,c.get("text-ignore-placement"),a.bucketInstanceId,Pr,$.ID),o&&this.storeCollisionData(a.bucketInstanceId,Ge,Pe,Si,Ti,fi),Se.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(a.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[Se.crossTileID]=new nt(lt||be,Dt||ve,pi||a.justReloaded),n[Se.crossTileID]=!0};if(Ae){if(e.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");let Se=a.getSortedSymbolIndexes(this.transform.angle);for(let Pe=Se.length-1;Pe>=0;--Pe){let Ge=Se[Pe];We(a.symbolInstances.get(Ge),a.collisionArrays[Ge],Ge)}}else for(let Se=e.symbolInstanceStart;Se<e.symbolInstanceEnd;Se++)We(a.symbolInstances.get(Se),a.collisionArrays[Se],Se);if(o&&a.bucketInstanceId in this.collisionCircleArrays){let Se=this.collisionCircleArrays[a.bucketInstanceId];d.as(Se.invProjMatrix,y),Se.viewportMatrix=this.collisionIndex.getViewportMatrix()}a.justReloaded=!1}storeCollisionData(e,n,o,a,c,m){if(o.textBox||o.iconBox){let _,y;this.collisionBoxArrays.has(e)?_=this.collisionBoxArrays.get(e):(_=new Map,this.collisionBoxArrays.set(e,_)),_.has(n)?y=_.get(n):(y={text:null,icon:null},_.set(n,y)),o.textBox&&(y.text=a.box),o.iconBox&&(y.icon=c.box)}if(m){let _=this.collisionCircleArrays[e];_===void 0&&(_=this.collisionCircleArrays[e]=new vt);for(let y=0;y<m.circles.length;y+=4)_.circles.push(m.circles[y+0]),_.circles.push(m.circles[y+1]),_.circles.push(m.circles[y+2]),_.circles.push(m.collisionDetected?1:0)}}markUsedJustification(e,n,o,a){let c;c=a===d.ah.vertical?o.verticalPlacedTextSymbolIndex:{left:o.leftJustifiedTextSymbolIndex,center:o.centerJustifiedTextSymbolIndex,right:o.rightJustifiedTextSymbolIndex}[d.at(n)];let m=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex,o.verticalPlacedTextSymbolIndex];for(let _ of m)_>=0&&(e.text.placedSymbolArray.get(_).crossTileID=c>=0&&_!==c?0:o.crossTileID)}markUsedOrientation(e,n,o){let a=n===d.ah.horizontal||n===d.ah.horizontalOnly?n:0,c=n===d.ah.vertical?n:0,m=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(let _ of m)e.text.placedSymbolArray.get(_).placedOrientation=a;o.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=c)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let n=this.prevPlacement,o=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;let a=n?n.symbolFadeChange(e):1,c=n?n.opacities:{},m=n?n.variableOffsets:{},_=n?n.placedOrientations:{};for(let y in this.placements){let b=this.placements[y],S=c[y];S?(this.opacities[y]=new Ut(S,a,b.text,b.icon),o=o||b.text!==S.text.placed||b.icon!==S.icon.placed):(this.opacities[y]=new Ut(null,a,b.text,b.icon,b.skipFade),o=o||b.text||b.icon)}for(let y in c){let b=c[y];if(!this.opacities[y]){let S=new Ut(b,a,!1,!1);S.isHidden()||(this.opacities[y]=S,o=o||b.text.placed||b.icon.placed)}}for(let y in m)this.variableOffsets[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.variableOffsets[y]=m[y]);for(let y in _)this.placedOrientations[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.placedOrientations[y]=_[y]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");o?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:e)}updateLayerOpacities(e,n){let o={};for(let a of n){let c=a.getBucket(e);c&&a.latestFeatureIndex&&e.id===c.layerIds[0]&&this.updateBucketOpacities(c,a.tileID,o,a.collisionBoxArray)}}updateBucketOpacities(e,n,o,a){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let c=e.layers[0],m=c.layout,_=new Ut(null,0,!1,!1,!0),y=m.get("text-allow-overlap"),b=m.get("icon-allow-overlap"),S=c._unevaluatedLayout.hasValue("text-variable-anchor")||c._unevaluatedLayout.hasValue("text-variable-anchor-offset"),T=m.get("text-rotation-alignment")==="map",E=m.get("text-pitch-alignment")==="map",D=m.get("icon-text-fit")!=="none",F=new Ut(null,0,y&&(b||!e.hasIconData()||m.get("icon-optional")),b&&(y||!e.hasTextData()||m.get("text-optional")),!0);!e.collisionArrays&&a&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(a);let V=(q,G,B)=>{for(let J=0;J<G/4;J++)q.opacityVertexArray.emplaceBack(B);q.hasVisibleVertices=q.hasVisibleVertices||B!==In},$=this.collisionBoxArrays.get(e.bucketInstanceId);for(let q=0;q<e.symbolInstances.length;q++){let G=e.symbolInstances.get(q),{numHorizontalGlyphVertices:B,numVerticalGlyphVertices:J,crossTileID:ee}=G,ne=this.opacities[ee];o[ee]?ne=_:ne||(ne=F,this.opacities[ee]=ne),o[ee]=!0;let de=G.numIconVertices>0,ge=this.placedOrientations[G.crossTileID],Ie=ge===d.ah.vertical,Ae=ge===d.ah.horizontal||ge===d.ah.horizontalOnly;if(B>0||J>0){let ve=Ni(ne.text);V(e.text,B,Ie?In:ve),V(e.text,J,Ae?In:ve);let Re=ne.text.isHidden();[G.rightJustifiedTextSymbolIndex,G.centerJustifiedTextSymbolIndex,G.leftJustifiedTextSymbolIndex].forEach((Pe=>{Pe>=0&&(e.text.placedSymbolArray.get(Pe).hidden=Re||Ie?1:0)})),G.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(G.verticalPlacedTextSymbolIndex).hidden=Re||Ae?1:0);let We=this.variableOffsets[G.crossTileID];We&&this.markUsedJustification(e,We.anchor,G,ge);let Se=this.placedOrientations[G.crossTileID];Se&&(this.markUsedJustification(e,"left",G,Se),this.markUsedOrientation(e,Se,G))}if(de){let ve=Ni(ne.icon),Re=!(D&&G.verticalPlacedIconSymbolIndex&&Ie);G.placedIconSymbolIndex>=0&&(V(e.icon,G.numIconVertices,Re?ve:In),e.icon.placedSymbolArray.get(G.placedIconSymbolIndex).hidden=ne.icon.isHidden()),G.verticalPlacedIconSymbolIndex>=0&&(V(e.icon,G.numVerticalIconVertices,Re?In:ve),e.icon.placedSymbolArray.get(G.verticalPlacedIconSymbolIndex).hidden=ne.icon.isHidden())}let be=$&&$.has(q)?$.get(q):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let ve=e.collisionArrays[q];if(ve){let Re=new d.P(0,0);if(ve.textBox||ve.verticalTextBox){let We=!0;if(S){let Se=this.variableOffsets[ee];Se?(Re=li(Se.anchor,Se.width,Se.height,Se.textOffset,Se.textBoxScale),T&&Re._rotate(E?this.transform.angle:-this.transform.angle)):We=!1}if(ve.textBox||ve.verticalTextBox){let Se;ve.textBox&&(Se=Ie),ve.verticalTextBox&&(Se=Ae),Tn(e.textCollisionBox.collisionVertexArray,ne.text.placed,!We||Se,be.text,Re.x,Re.y)}}if(ve.iconBox||ve.verticalIconBox){let We=!!(!Ae&&ve.verticalIconBox),Se;ve.iconBox&&(Se=We),ve.verticalIconBox&&(Se=!We),Tn(e.iconCollisionBox.collisionVertexArray,ne.icon.placed,Se,be.icon,D?Re.x:0,D?Re.y:0)}}}}if(e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);if(e.bucketInstanceId in this.collisionCircleArrays){let q=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=q.invProjMatrix,e.placementViewportMatrix=q.viewportMatrix,e.collisionCircleArray=q.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(e){return this.fadeDuration===0?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,n){let o=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*o>e}setStale(){this.stale=!0}}function Tn(h,e,n,o,a,c){o&&o.length!==0||(o=[0,0,0,0]);let m=o[0]-Qe,_=o[1]-Qe,y=o[2]-Qe,b=o[3]-Qe;h.emplaceBack(e?1:0,n?1:0,a||0,c||0,m,_),h.emplaceBack(e?1:0,n?1:0,a||0,c||0,y,_),h.emplaceBack(e?1:0,n?1:0,a||0,c||0,y,b),h.emplaceBack(e?1:0,n?1:0,a||0,c||0,m,b)}let bt=Math.pow(2,25),Oo=Math.pow(2,24),No=Math.pow(2,17),Bi=Math.pow(2,16),Oi=Math.pow(2,9),cc=Math.pow(2,8),Gi=Math.pow(2,1);function Ni(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;let e=h.placed?1:0,n=Math.floor(127*h.opacity);return n*bt+e*Oo+n*No+e*Bi+n*Oi+e*cc+n*Gi+e}let In=0;function rn(){return{isOccluded:(h,e,n)=>!1,getPitchedTextCorrection:(h,e,n)=>1,get useSpecialProjectionForSymbols(){return!1},projectTileCoordinates(h,e,n,o){throw new Error("Not implemented.")},translatePosition:(h,e,n,o)=>(function(a,c,m,_,y=!1){if(!m[0]&&!m[1])return[0,0];let b=y?_==="map"?a.angle:0:_==="viewport"?-a.angle:0;if(b){let S=Math.sin(b),T=Math.cos(b);m=[m[0]*T-m[1]*S,m[0]*S+m[1]*T]}return[y?m[0]:at(c,m[0],a.zoom),y?m[1]:at(c,m[1],a.zoom)]})(h,e,n,o),getCircleRadiusCorrection:h=>1}}class Yt{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,n,o,a,c){let m=this._bucketParts;for(;this._currentTileIndex<e.length;)if(n.getBucketParts(m,a,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,c())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,m.sort(((_,y)=>_.sortKey-y.sortKey)));this._currentPartIndex<m.length;)if(n.placeLayerBucketPart(m[this._currentPartIndex],this._seenCrossTileIDs,o),this._currentPartIndex++,c())return!0;return!1}}class ps{constructor(e,n,o,a,c,m,_,y){this.placement=new wi(e,rn(),n,m,_,y),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=a,this._showCollisionBoxes=c,this._done=!1}isDone(){return this._done}continuePlacement(e,n,o){let a=ue.now(),c=()=>!this._forceFullPlacement&&ue.now()-a>2;for(;this._currentPlacementIndex>=0;){let m=n[e[this._currentPlacementIndex]],_=this.placement.collisionIndex.transform.zoom;if(m.type==="symbol"&&(!m.minzoom||m.minzoom<=_)&&(!m.maxzoom||m.maxzoom>_)){if(this._inProgressLayer||(this._inProgressLayer=new Yt(m)),this._inProgressLayer.continuePlacement(o[m.source],this.placement,this._showCollisionBoxes,m,c))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}let or=512/d.X/2;class Xt{constructor(e,n,o){this.tileID=e,this.bucketInstanceId=o,this._symbolsByKey={};let a=new Map;for(let c=0;c<n.length;c++){let m=n.get(c),_=m.key,y=a.get(_);y?y.push(m):a.set(_,[m])}for(let[c,m]of a){let _={positions:m.map((y=>({x:Math.floor(y.anchorX*or),y:Math.floor(y.anchorY*or)}))),crossTileIDs:m.map((y=>y.crossTileID))};if(_.positions.length>128){let y=new d.av(_.positions.length,16,Uint16Array);for(let{x:b,y:S}of _.positions)y.add(b,S);y.finish(),delete _.positions,_.index=y}this._symbolsByKey[c]=_}}getScaledCoordinates(e,n){let{x:o,y:a,z:c}=this.tileID.canonical,{x:m,y:_,z:y}=n.canonical,b=or/Math.pow(2,y-c),S=(_*d.X+e.anchorY)*b,T=a*d.X*or;return{x:Math.floor((m*d.X+e.anchorX)*b-o*d.X*or),y:Math.floor(S-T)}}findMatches(e,n,o){let a=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let c=0;c<e.length;c++){let m=e.get(c);if(m.crossTileID)continue;let _=this._symbolsByKey[m.key];if(!_)continue;let y=this.getScaledCoordinates(m,n);if(_.index){let b=_.index.range(y.x-a,y.y-a,y.x+a,y.y+a).sort();for(let S of b){let T=_.crossTileIDs[S];if(!o[T]){o[T]=!0,m.crossTileID=T;break}}}else if(_.positions)for(let b=0;b<_.positions.length;b++){let S=_.positions[b],T=_.crossTileIDs[b];if(Math.abs(S.x-y.x)<=a&&Math.abs(S.y-y.y)<=a&&!o[T]){o[T]=!0,m.crossTileID=T;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:e})=>e))}}class Vs{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ar{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let n=Math.round((e-this.lng)/360);if(n!==0)for(let o in this.indexes){let a=this.indexes[o],c={};for(let m in a){let _=a[m];_.tileID=_.tileID.unwrapTo(_.tileID.wrap+n),c[_.tileID.key]=_}this.indexes[o]=c}this.lng=e}addBucket(e,n,o){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let c=0;c<n.symbolInstances.length;c++)n.symbolInstances.get(c).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});let a=this.usedCrossTileIDs[e.overscaledZ];for(let c in this.indexes){let m=this.indexes[c];if(Number(c)>e.overscaledZ)for(let _ in m){let y=m[_];y.tileID.isChildOf(e)&&y.findMatches(n.symbolInstances,e,a)}else{let _=m[e.scaledTo(Number(c)).key];_&&_.findMatches(n.symbolInstances,e,a)}}for(let c=0;c<n.symbolInstances.length;c++){let m=n.symbolInstances.get(c);m.crossTileID||(m.crossTileID=o.generate(),a[m.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Xt(e,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(e,n){for(let o of n.getCrossTileIDsLists())for(let a of o)delete this.usedCrossTileIDs[e][a]}removeStaleBuckets(e){let n=!1;for(let o in this.indexes){let a=this.indexes[o];for(let c in a)e[a[c].bucketInstanceId]||(this.removeBucketCrossTileIDs(o,a[c]),delete a[c],n=!0)}return n}}class Vo{constructor(){this.layerIndexes={},this.crossTileIDs=new Vs,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,n,o){let a=this.layerIndexes[e.id];a===void 0&&(a=this.layerIndexes[e.id]=new ar);let c=!1,m={};a.handleWrapJump(o);for(let _ of n){let y=_.getBucket(e);y&&e.id===y.layerIds[0]&&(y.bucketInstanceId||(y.bucketInstanceId=++this.maxBucketInstanceId),a.addBucket(_.tileID,y,this.crossTileIDs)&&(c=!0),m[y.bucketInstanceId]=!0)}return a.removeStaleBuckets(m)&&(c=!0),c}pruneUnusedLayers(e){let n={};e.forEach((o=>{n[o]=!0}));for(let o in this.layerIndexes)n[o]||delete this.layerIndexes[o]}}let lr=(h,e)=>d.t(h,e&&e.filter((n=>n.identifier!=="source.canvas"))),hc=d.aw();class Us extends d.E{constructor(e,n={}){super(),this._rtlPluginLoaded=()=>{for(let o in this.sourceCaches){let a=this.sourceCaches[o].getSource().type;a!=="vector"&&a!=="geojson"||this.sourceCaches[o].reload()}},this.map=e,this.dispatcher=new en(Qr(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((o,a)=>this.getGlyphs(o,a))),this.dispatcher.registerMessageHandler("GI",((o,a)=>this.getImages(o,a))),this.imageManager=new ze,this.imageManager.setEventedParent(this),this.glyphManager=new Ht(e._requestManager,n.localIdeographFontFamily),this.lineAtlas=new vn(256,512),this.crossTileSymbolIndex=new Vo,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new d.ax,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",d.ay()),br().on(ye,this._rtlPluginLoaded),this.on("data",(o=>{if(o.dataType!=="source"||o.sourceDataType!=="metadata")return;let a=this.sourceCaches[o.sourceId];if(!a)return;let c=a.getSource();if(c&&c.vectorLayerIds)for(let m in this._layers){let _=this._layers[m];_.source===c.id&&this._validateLayer(_)}}))}loadURL(e,n={},o){this.fire(new d.k("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;let a=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;let c=this._loadStyleRequest;d.h(a,this._loadStyleRequest).then((m=>{this._loadStyleRequest=null,this._load(m.data,n,o)})).catch((m=>{this._loadStyleRequest=null,m&&!c.signal.aborted&&this.fire(new d.j(m))}))}loadJSON(e,n={},o){this.fire(new d.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,ue.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(e,n,o)})).catch((()=>{}))}loadEmpty(){this.fire(new d.k("dataloading",{dataType:"style"})),this._load(hc,{validate:!1})}_load(e,n,o){var a;let c=n.transformStyle?n.transformStyle(o,e):e;if(!n.validate||!lr(this,d.u(c))){this._loaded=!0,this.stylesheet=c;for(let 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 ui(this.stylesheet.light),this.sky=new rr(this.stylesheet.sky),this.map.setTerrain((a=this.stylesheet.terrain)!==null&&a!==void 0?a:null),this.fire(new d.k("data",{dataType:"style"})),this.fire(new d.k("style.load"))}}_createLayers(){let e=d.az(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map((n=>n.id)),this._layers={},this._serializedLayers=null;for(let n of e){let o=d.aA(n);o.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=o}}_loadSprite(e,n=!1,o=void 0){let a;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,(function(c,m,_,y){return d._(this,void 0,void 0,(function*(){let b=ft(c),S=_>1?"@2x":"",T={},E={};for(let{id:D,url:F}of b){let V=m.transformRequest(vi(F,S,".json"),"SpriteJSON");T[D]=d.h(V,y);let $=m.transformRequest(vi(F,S,".png"),"SpriteImage");E[D]=Ke.getImage($,y)}return yield Promise.all([...Object.values(T),...Object.values(E)]),(function(D,F){return d._(this,void 0,void 0,(function*(){let V={};for(let $ in D){V[$]={};let q=ue.getImageCanvasContext((yield F[$]).data),G=(yield D[$]).data;for(let B in G){let{width:J,height:ee,x:ne,y:de,sdf:ge,pixelRatio:Ie,stretchX:Ae,stretchY:be,content:ve,textFitWidth:Re,textFitHeight:We}=G[B];V[$][B]={data:null,pixelRatio:Ie,sdf:ge,stretchX:Ae,stretchY:be,content:ve,textFitWidth:Re,textFitHeight:We,spriteData:{width:J,height:ee,x:ne,y:de,context:q}}}}return V}))})(T,E)}))})(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((c=>{if(this._spriteRequest=null,c)for(let m in c){this._spritesImagesIds[m]=[];let _=this._spritesImagesIds[m]?this._spritesImagesIds[m].filter((y=>!(y in c))):[];for(let y of _)this.imageManager.removeImage(y),this._changedImages[y]=!0;for(let y in c[m]){let b=m==="default"?y:`${m}:${y}`;this._spritesImagesIds[m].push(b),b in this.imageManager.images?this.imageManager.updateImage(b,c[m][y],!1):this.imageManager.addImage(b,c[m][y]),n&&(this._changedImages[b]=!0)}}})).catch((c=>{this._spriteRequest=null,a=c,this.fire(new d.j(a))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.k("data",{dataType:"style"})),o&&o(a)}))}_unloadSprite(){for(let e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.k("data",{dataType:"style"}))}_validateLayer(e){let n=this.sourceCaches[e.source];if(!n)return;let o=e.sourceLayer;if(!o)return;let a=n.getSource();(a.type==="geojson"||a.vectorLayerIds&&a.vectorLayerIds.indexOf(o)===-1)&&this.fire(new d.j(new Error(`Source layer "${o}" does not exist on source "${a.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,n=!1){let o=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?d.aB(o):o);let a=[];for(let c of e)if(o[c]){let m=n?d.aB(o[c]):o[c];a.push(m)}return a}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let n=Object.keys(this._layers);for(let o of n){let a=this._layers[o];a.type!=="custom"&&(e[o]=a.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition()||this.sky&&this.sky.hasTransition())return!0;for(let e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;let n=this._changed;if(n){let a=Object.keys(this._updatedLayers),c=Object.keys(this._removedLayers);(a.length||c.length)&&this._updateWorkerLayers(a,c);for(let m in this._updatedSources){let _=this._updatedSources[m];if(_==="reload")this._reloadSource(m);else{if(_!=="clear")throw new Error(`Invalid action ${_}`);this._clearSource(m)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let m in this._updatedPaintProps)this._layers[m].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}let o={};for(let a in this.sourceCaches){let c=this.sourceCaches[a];o[a]=c.used,c.used=!1}for(let a of this._order){let c=this._layers[a];c.recalculate(e,this._availableImages),!c.isHidden(e.zoom)&&c.source&&(this.sourceCaches[c.source].used=!0)}for(let a in o){let c=this.sourceCaches[a];!!o[a]!=!!c.used&&c.fire(new d.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:a}))}this.light.recalculate(e),this.sky.recalculate(e),this.z=e.zoom,n&&this.fire(new d.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var o;this._checkLoaded();let a=this.serialize();if(e=n.transformStyle?n.transformStyle(a,e):e,((o=n.validate)===null||o===void 0||o)&&lr(this,d.u(e)))return!1;(e=d.aB(e)).layers=d.az(e.layers);let c=d.aC(a,e),m=this._getOperationsToPerform(c);if(m.unimplemented.length>0)throw new Error(`Unimplemented: ${m.unimplemented.join(", ")}.`);if(m.operations.length===0)return!1;for(let _ of m.operations)_();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){let n=[],o=[];for(let a of e)switch(a.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":n.push((()=>this.addLayer.apply(this,a.args)));break;case"removeLayer":n.push((()=>this.removeLayer.apply(this,a.args)));break;case"setPaintProperty":n.push((()=>this.setPaintProperty.apply(this,a.args)));break;case"setLayoutProperty":n.push((()=>this.setLayoutProperty.apply(this,a.args)));break;case"setFilter":n.push((()=>this.setFilter.apply(this,a.args)));break;case"addSource":n.push((()=>this.addSource.apply(this,a.args)));break;case"removeSource":n.push((()=>this.removeSource.apply(this,a.args)));break;case"setLayerZoomRange":n.push((()=>this.setLayerZoomRange.apply(this,a.args)));break;case"setLight":n.push((()=>this.setLight.apply(this,a.args)));break;case"setGeoJSONSourceData":n.push((()=>this.setGeoJSONSourceData.apply(this,a.args)));break;case"setGlyphs":n.push((()=>this.setGlyphs.apply(this,a.args)));break;case"setSprite":n.push((()=>this.setSprite.apply(this,a.args)));break;case"setSky":n.push((()=>this.setSky.apply(this,a.args)));break;case"setTerrain":n.push((()=>this.map.setTerrain.apply(this,a.args)));break;case"setTransition":n.push((()=>{}));break;default:o.push(a.command)}return{operations:n,unimplemented:o}}addImage(e,n){if(this.getImage(e))return this.fire(new d.j(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,n),this._afterImageUpdated(e)}updateImage(e,n){this.imageManager.updateImage(e,n)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new d.j(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,o={}){if(this._checkLoaded(),this.sourceCaches[e]!==void 0)throw new Error(`Source "${e}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(d.u.source,`sources.${e}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);let a=this.sourceCaches[e]=new Ze(e,n,this.dispatcher);a.style=this,a.setEventedParent(this,(()=>({isSourceLoaded:a.loaded(),source:a.serialize(),sourceId:e}))),a.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error("There is no source with this ID");for(let o in this._layers)if(this._layers[o].source===e)return this.fire(new d.j(new Error(`Source "${e}" cannot be removed while layer "${o}" is using it.`)));let n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new d.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,n){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error(`There is no source with this ID=${e}`);let o=this.sourceCaches[e].getSource();if(o.type!=="geojson")throw new Error(`geojsonSource.type is ${o.type}, which is !== 'geojson`);o.setData(n),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,n,o={}){this._checkLoaded();let a=e.id;if(this.getLayer(a))return void this.fire(new d.j(new Error(`Layer "${a}" already exists on this map.`)));let c;if(e.type==="custom"){if(lr(this,d.aD(e)))return;c=d.aA(e)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(a,e.source),e=d.aB(e),e=d.e(e,{source:a})),this._validate(d.u.layer,`layers.${a}`,e,{arrayIndex:-1},o))return;c=d.aA(e),this._validateLayer(c),c.setEventedParent(this,{layer:{id:a}})}let m=n?this._order.indexOf(n):this._order.length;if(n&&m===-1)this.fire(new d.j(new Error(`Cannot add layer "${a}" before non-existing layer "${n}".`)));else{if(this._order.splice(m,0,a),this._layerOrderChanged=!0,this._layers[a]=c,this._removedLayers[a]&&c.source&&c.type!=="custom"){let _=this._removedLayers[a];delete this._removedLayers[a],_.type!==c.type?this._updatedSources[c.source]="clear":(this._updatedSources[c.source]="reload",this.sourceCaches[c.source].pause())}this._updateLayer(c),c.onAdd&&c.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new d.j(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;let o=this._order.indexOf(e);this._order.splice(o,1);let a=n?this._order.indexOf(n):this._order.length;n&&a===-1?this.fire(new d.j(new Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(a,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();let n=this._layers[e];if(!n)return void this.fire(new d.j(new Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);let o=this._order.indexOf(e);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,o){this._checkLoaded();let a=this.getLayer(e);a?a.minzoom===n&&a.maxzoom===o||(n!=null&&(a.minzoom=n),o!=null&&(a.maxzoom=o),this._updateLayer(a)):this.fire(new d.j(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,o={}){this._checkLoaded();let a=this.getLayer(e);if(a){if(!d.aE(a.filter,n))return n==null?(a.filter=void 0,void this._updateLayer(a)):void(this._validate(d.u.filter,`layers.${a.id}.filter`,n,null,o)||(a.filter=d.aB(n),this._updateLayer(a)))}else this.fire(new d.j(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return d.aB(this.getLayer(e).filter)}setLayoutProperty(e,n,o,a={}){this._checkLoaded();let c=this.getLayer(e);c?d.aE(c.getLayoutProperty(n),o)||(c.setLayoutProperty(n,o,a),this._updateLayer(c)):this.fire(new d.j(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){let o=this.getLayer(e);if(o)return o.getLayoutProperty(n);this.fire(new d.j(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,o,a={}){this._checkLoaded();let c=this.getLayer(e);c?d.aE(c.getPaintProperty(n),o)||(c.setPaintProperty(n,o,a)&&this._updateLayer(c),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new d.j(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(e,n){return this.getLayer(e).getPaintProperty(n)}setFeatureState(e,n){this._checkLoaded();let o=e.source,a=e.sourceLayer,c=this.sourceCaches[o];if(c===void 0)return void this.fire(new d.j(new Error(`The source '${o}' does not exist in the map's style.`)));let m=c.getSource().type;m==="geojson"&&a?this.fire(new d.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):m!=="vector"||a?(e.id===void 0&&this.fire(new d.j(new Error("The feature id parameter must be provided."))),c.setFeatureState(a,e.id,n)):this.fire(new d.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,n){this._checkLoaded();let o=e.source,a=this.sourceCaches[o];if(a===void 0)return void this.fire(new d.j(new Error(`The source '${o}' does not exist in the map's style.`)));let c=a.getSource().type,m=c==="vector"?e.sourceLayer:void 0;c!=="vector"||m?n&&typeof e.id!="string"&&typeof e.id!="number"?this.fire(new d.j(new Error("A feature id is required to remove its specific state property."))):a.removeFeatureState(m,e.id,n):this.fire(new d.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();let n=e.source,o=e.sourceLayer,a=this.sourceCaches[n];if(a!==void 0)return a.getSource().type!=="vector"||o?(e.id===void 0&&this.fire(new d.j(new Error("The feature id parameter must be provided."))),a.getFeatureState(o,e.id)):void this.fire(new d.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new d.j(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return d.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;let e=d.aF(this.sourceCaches,(c=>c.serialize())),n=this._serializeByIds(this._order,!0),o=this.map.getTerrain()||void 0,a=this.stylesheet;return d.aG({version:a.version,name:a.name,metadata:a.metadata,light:a.light,sky:a.sky,center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch,sprite:a.sprite,glyphs:a.glyphs,transition:a.transition,sources:e,layers:n,terrain:o},(c=>c!==void 0))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.sourceCaches[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let n=m=>this._layers[m].type==="fill-extrusion",o={},a=[];for(let m=this._order.length-1;m>=0;m--){let _=this._order[m];if(n(_)){o[_]=m;for(let y of e){let b=y[_];if(b)for(let S of b)a.push(S)}}}a.sort(((m,_)=>_.intersectionZ-m.intersectionZ));let c=[];for(let m=this._order.length-1;m>=0;m--){let _=this._order[m];if(n(_))for(let y=a.length-1;y>=0;y--){let b=a[y].feature;if(o[b.layer.id]<m)break;c.push(b),a.pop()}else for(let y of e){let b=y[_];if(b)for(let S of b)c.push(S.feature)}}return c}queryRenderedFeatures(e,n,o){n&&n.filter&&this._validate(d.u.filter,"queryRenderedFeatures.filter",n.filter,null,n);let a={};if(n&&n.layers){if(!Array.isArray(n.layers))return this.fire(new d.j(new Error("parameters.layers must be an Array."))),[];for(let _ of n.layers){let y=this._layers[_];if(!y)return this.fire(new d.j(new Error(`The layer '${_}' does not exist in the map's style and cannot be queried for features.`))),[];a[y.source]=!0}}let c=[];n.availableImages=this._availableImages;let m=this._serializedAllLayers();for(let _ in this.sourceCaches)n.layers&&!a[_]||c.push(Vr(this.sourceCaches[_],this._layers,m,e,n,o));return this.placement&&c.push((function(_,y,b,S,T,E,D){let F={},V=E.queryRenderedSymbols(S),$=[];for(let q of Object.keys(V).map(Number))$.push(D[q]);$.sort(Ur);for(let q of $){let G=q.featureIndex.lookupSymbolFeatures(V[q.bucketInstanceId],y,q.bucketIndex,q.sourceLayerIndex,T.filter,T.layers,T.availableImages,_);for(let B in G){let J=F[B]=F[B]||[],ee=G[B];ee.sort(((ne,de)=>{let ge=q.featureSortOrder;if(ge){let Ie=ge.indexOf(ne.featureIndex);return ge.indexOf(de.featureIndex)-Ie}return de.featureIndex-ne.featureIndex}));for(let ne of ee)J.push(ne)}}for(let q in F)F[q].forEach((G=>{let B=G.feature,J=b[_[q].source].getFeatureState(B.layer["source-layer"],B.id);B.source=B.layer.source,B.layer["source-layer"]&&(B.sourceLayer=B.layer["source-layer"]),B.state=J}));return F})(this._layers,m,this.sourceCaches,e,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(e,n){n&&n.filter&&this._validate(d.u.filter,"querySourceFeatures.filter",n.filter,null,n);let o=this.sourceCaches[e];return o?(function(a,c){let m=a.getRenderableIds().map((b=>a.getTileByID(b))),_=[],y={};for(let b=0;b<m.length;b++){let S=m[b],T=S.tileID.canonical.key;y[T]||(y[T]=!0,S.querySourceFeatures(_,c))}return _})(o,n):[]}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();let o=this.light.getLight(),a=!1;for(let m in e)if(!d.aE(e[m],o[m])){a=!0;break}if(!a)return;let c={now:ue.now(),transition:d.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,n),this.light.updateTransitions(c)}getSky(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.sky}setSky(e,n={}){let o=this.getSky(),a=!1;if(!e&&!o)return;if(e&&!o)a=!0;else if(!e&&o)a=!0;else for(let m in e)if(!d.aE(e[m],o[m])){a=!0;break}if(!a)return;let c={now:ue.now(),transition:d.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,n),this.sky.updateTransitions(c)}_validate(e,n,o,a,c={}){return(!c||c.validate!==!1)&&lr(this,e.call(d.u,d.e({key:n,style:this.serialize(),value:o,styleSpec:d.v},a)))}_remove(e=!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),br().off(ye,this._rtlPluginLoaded);for(let n in this._layers)this._layers[n].setEventedParent(null);for(let n in this.sourceCaches){let o=this.sourceCaches[n];o.setEventedParent(null),o.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.sourceCaches[e].clearTiles()}_reloadSource(e){this.sourceCaches[e].resume(),this.sourceCaches[e].reload()}_updateSources(e){for(let n in this.sourceCaches)this.sourceCaches[n].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.sourceCaches)this._reloadSource(e)}_updatePlacement(e,n,o,a,c=!1){let m=!1,_=!1,y={};for(let b of this._order){let S=this._layers[b];if(S.type!=="symbol")continue;if(!y[S.source]){let E=this.sourceCaches[S.source];y[S.source]=E.getRenderableIds(!0).map((D=>E.getTileByID(D))).sort(((D,F)=>F.tileID.overscaledZ-D.tileID.overscaledZ||(D.tileID.isLessThan(F.tileID)?-1:1)))}let T=this.crossTileSymbolIndex.addLayer(S,y[S.source],e.center.lng);m=m||T}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((c=c||this._layerOrderChanged||o===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(ue.now(),e.zoom))&&(this.pauseablePlacement=new ps(e,this.map.terrain,this._order,c,n,o,a,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,y),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(ue.now()),_=!0),m&&this.pauseablePlacement.placement.setStale()),_||m)for(let b of this._order){let S=this._layers[b];S.type==="symbol"&&this.placement.updateLayerOpacities(S,y[S.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(ue.now())}_releaseSymbolFadeTiles(){for(let e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,n){return d._(this,void 0,void 0,(function*(){let o=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();let a=this.sourceCaches[n.source];return a&&a.setDependencies(n.tileID.key,n.type,n.icons),o}))}getGlyphs(e,n){return d._(this,void 0,void 0,(function*(){let o=yield this.glyphManager.getGlyphs(n.stacks),a=this.sourceCaches[n.source];return a&&a.setDependencies(n.tileID.key,n.type,[""]),o}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(d.u.glyphs,"glyphs",e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,n,o={},a){this._checkLoaded();let c=[{id:e,url:n}],m=[...ft(this.stylesheet.sprite),...c];this._validate(d.u.sprite,"sprite",m,null,o)||(this.stylesheet.sprite=m,this._loadSprite(c,!0,a))}removeSprite(e){this._checkLoaded();let n=ft(this.stylesheet.sprite);if(n.find((o=>o.id===e))){if(this._spritesImagesIds[e])for(let o of this._spritesImagesIds[e])this.imageManager.removeImage(o),this._changedImages[o]=!0;n.splice(n.findIndex((o=>o.id===e)),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.k("data",{dataType:"style"}))}else this.fire(new d.j(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return ft(this.stylesheet.sprite)}setSprite(e,n={},o){this._checkLoaded(),e&&this._validate(d.u.sprite,"sprite",e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,o):(this._unloadSprite(),o&&o(null)))}}var nn=d.Y([{name:"a_pos",type:"Int16",components:2}]);let Zr={prelude:yt(`#ifdef GL_ES
3
3
  precision mediump float;
4
4
  #else
5
5
  #if !defined(lowp)
@@ -54,15 +54,15 @@ vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=frac
54
54
  #else
55
55
  return 0.0;
56
56
  #endif
57
- }`),background:gt(`uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;
57
+ }`),background:yt(`uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;
58
58
  #ifdef OVERDRAW_INSPECTOR
59
59
  gl_FragColor=vec4(1.0);
60
60
  #endif
61
- }`,"attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:gt(`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;
61
+ }`,"attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:yt(`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;
62
62
  #ifdef OVERDRAW_INSPECTOR
63
63
  gl_FragColor=vec4(1.0);
64
64
  #endif
65
- }`,"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:gt(`varying vec3 v_data;varying float v_visibility;
65
+ }`,"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:yt(`varying vec3 v_data;varying float v_visibility;
66
66
  #pragma mapbox: define highp vec4 color
67
67
  #pragma mapbox: define mediump float radius
68
68
  #pragma mapbox: define lowp float blur
@@ -98,7 +98,7 @@ void main(void) {
98
98
  #pragma mapbox: initialize highp vec4 stroke_color
99
99
  #pragma mapbox: initialize mediump float stroke_width
100
100
  #pragma mapbox: initialize lowp float stroke_opacity
101
- 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:gt("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:gt(`uniform highp float u_intensity;varying vec2 v_extrude;
101
+ 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:yt("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:yt(`uniform highp float u_intensity;varying vec2 v_extrude;
102
102
  #pragma mapbox: define highp float weight
103
103
  #define GAUSS_COEF 0.3989422804014327
104
104
  void main() {
@@ -115,11 +115,11 @@ const highp float ZERO=1.0/255.0/16.0;
115
115
  void main(void) {
116
116
  #pragma mapbox: initialize highp float weight
117
117
  #pragma mapbox: initialize mediump float radius
118
- 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:gt(`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;
118
+ 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:yt(`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;
119
119
  #ifdef OVERDRAW_INSPECTOR
120
120
  gl_FragColor=vec4(0.0);
121
121
  #endif
122
- }`,"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:gt("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:gt("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:gt("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:gt(`#pragma mapbox: define highp vec4 color
122
+ }`,"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:yt("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:yt("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:yt("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:yt(`#pragma mapbox: define highp vec4 color
123
123
  #pragma mapbox: define lowp float opacity
124
124
  void main() {
125
125
  #pragma mapbox: initialize highp vec4 color
@@ -134,7 +134,7 @@ gl_FragColor=vec4(1.0);
134
134
  void main() {
135
135
  #pragma mapbox: initialize highp vec4 color
136
136
  #pragma mapbox: initialize lowp float opacity
137
- gl_Position=u_matrix*vec4(a_pos,0,1);}`),fillOutline:gt(`varying vec2 v_pos;
137
+ gl_Position=u_matrix*vec4(a_pos,0,1);}`),fillOutline:yt(`varying vec2 v_pos;
138
138
  #pragma mapbox: define highp vec4 outline_color
139
139
  #pragma mapbox: define lowp float opacity
140
140
  void main() {
@@ -150,7 +150,7 @@ gl_FragColor=vec4(1.0);
150
150
  void main() {
151
151
  #pragma mapbox: initialize highp vec4 outline_color
152
152
  #pragma mapbox: initialize lowp float opacity
153
- gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillOutlinePattern:gt(`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;
153
+ gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillOutlinePattern:yt(`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;
154
154
  #pragma mapbox: define lowp float opacity
155
155
  #pragma mapbox: define lowp vec4 pattern_from
156
156
  #pragma mapbox: define lowp vec4 pattern_to
@@ -174,7 +174,7 @@ void main() {
174
174
  #pragma mapbox: initialize mediump vec4 pattern_to
175
175
  #pragma mapbox: initialize lowp float pixel_ratio_from
176
176
  #pragma mapbox: initialize lowp float pixel_ratio_to
177
- 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:gt(`#ifdef GL_ES
177
+ 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:yt(`#ifdef GL_ES
178
178
  precision highp float;
179
179
  #endif
180
180
  uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;
@@ -201,7 +201,7 @@ void main() {
201
201
  #pragma mapbox: initialize mediump vec4 pattern_to
202
202
  #pragma mapbox: initialize lowp float pixel_ratio_from
203
203
  #pragma mapbox: initialize lowp float pixel_ratio_to
204
- 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:gt(`varying vec4 v_color;void main() {gl_FragColor=v_color;
204
+ 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:yt(`varying vec4 v_color;void main() {gl_FragColor=v_color;
205
205
  #ifdef OVERDRAW_INSPECTOR
206
206
  gl_FragColor=vec4(1.0);
207
207
  #endif
@@ -223,7 +223,7 @@ float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_off
223
223
  #else
224
224
  float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
225
225
  #endif
226
- 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:gt(`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;
226
+ 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:yt(`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;
227
227
  #pragma mapbox: define lowp float base
228
228
  #pragma mapbox: define lowp float height
229
229
  #pragma mapbox: define lowp vec4 pattern_from
@@ -267,20 +267,20 @@ float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
267
267
  #endif
268
268
  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
269
269
  ? a_pos
270
- : 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:gt(`#ifdef GL_ES
270
+ : 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:yt(`#ifdef GL_ES
271
271
  precision highp float;
272
272
  #endif
273
273
  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);
274
274
  #ifdef OVERDRAW_INSPECTOR
275
275
  gl_FragColor=vec4(1.0);
276
276
  #endif
277
- }`,"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:gt(`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;
277
+ }`,"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:yt(`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;
278
278
  #define PI 3.141592653589793
279
279
  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;
280
280
  #ifdef OVERDRAW_INSPECTOR
281
281
  gl_FragColor=vec4(1.0);
282
282
  #endif
283
- }`,"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:gt(`uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;
283
+ }`,"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:yt(`uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;
284
284
  #pragma mapbox: define highp vec4 color
285
285
  #pragma mapbox: define lowp float blur
286
286
  #pragma mapbox: define lowp float opacity
@@ -314,7 +314,7 @@ v_gamma_scale=1.0;
314
314
  #else
315
315
  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;
316
316
  #endif
317
- v_width2=vec2(outset,inset);}`),lineGradient:gt(`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;
317
+ v_width2=vec2(outset,inset);}`),lineGradient:yt(`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;
318
318
  #pragma mapbox: define lowp float blur
319
319
  #pragma mapbox: define lowp float opacity
320
320
  void main() {
@@ -344,7 +344,7 @@ v_gamma_scale=1.0;
344
344
  #else
345
345
  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;
346
346
  #endif
347
- v_width2=vec2(outset,inset);}`),linePattern:gt(`#ifdef GL_ES
347
+ v_width2=vec2(outset,inset);}`),linePattern:yt(`#ifdef GL_ES
348
348
  precision highp float;
349
349
  #endif
350
350
  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;
@@ -396,7 +396,7 @@ v_gamma_scale=1.0;
396
396
  #else
397
397
  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;
398
398
  #endif
399
- v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:gt(`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;
399
+ v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:yt(`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;
400
400
  #pragma mapbox: define highp vec4 color
401
401
  #pragma mapbox: define lowp float blur
402
402
  #pragma mapbox: define lowp float opacity
@@ -437,11 +437,11 @@ v_gamma_scale=1.0;
437
437
  #else
438
438
  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;
439
439
  #endif
440
- 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:gt(`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);
440
+ 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:yt(`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);
441
441
  #ifdef OVERDRAW_INSPECTOR
442
442
  gl_FragColor=vec4(1.0);
443
443
  #endif
444
- }`,"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:gt(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
444
+ }`,"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:yt(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
445
445
  #pragma mapbox: define lowp float opacity
446
446
  void main() {
447
447
  #pragma mapbox: initialize lowp float opacity
@@ -455,7 +455,7 @@ void main() {
455
455
  #pragma mapbox: initialize lowp float opacity
456
456
  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 ?
457
457
  camera_to_anchor_distance/u_camera_to_center_distance :
458
- 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:gt(`#define SDF_PX 8.0
458
+ 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:yt(`#define SDF_PX 8.0
459
459
  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;
460
460
  #pragma mapbox: define highp vec4 fill_color
461
461
  #pragma mapbox: define highp vec4 halo_color
@@ -486,7 +486,7 @@ void main() {
486
486
  #pragma mapbox: initialize lowp float halo_blur
487
487
  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 ?
488
488
  camera_to_anchor_distance/u_camera_to_center_distance :
489
- 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:gt(`#define SDF_PX 8.0
489
+ 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:yt(`#define SDF_PX 8.0
490
490
  #define SDF 1.0
491
491
  #define ICON 0.0
492
492
  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;
@@ -523,7 +523,7 @@ void main() {
523
523
  #pragma mapbox: initialize lowp float halo_blur
524
524
  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 ?
525
525
  camera_to_anchor_distance/u_camera_to_center_distance :
526
- 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:gt("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:gt("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:gt("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:gt("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 gt(h,e){let n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,o=e.match(/attribute ([\w]+) ([\w]+)/g),a=h.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),c=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),m=c?c.concat(a):a,_={};return{fragmentSource:h=h.replace(n,((y,b,S,T,E)=>(_[E]=!0,b==="define"?`
526
+ 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:yt("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:yt("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:yt("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:yt("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 yt(h,e){let n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,o=e.match(/attribute ([\w]+) ([\w]+)/g),a=h.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),c=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),m=c?c.concat(a):a,_={};return{fragmentSource:h=h.replace(n,((y,b,S,T,E)=>(_[E]=!0,b==="define"?`
527
527
  #ifndef HAS_UNIFORM_u_${E}
528
528
  varying ${S} ${T} ${E};
529
529
  #else
@@ -533,15 +533,15 @@ uniform ${S} ${T} u_${E};
533
533
  #ifdef HAS_UNIFORM_u_${E}
534
534
  ${S} ${T} ${E} = u_${E};
535
535
  #endif
536
- `))),vertexSource:e=e.replace(n,((y,b,S,T,E)=>{let L=T==="float"?"vec2":"vec4",B=E.match(/color/)?"color":L;return _[E]?b==="define"?`
536
+ `))),vertexSource:e=e.replace(n,((y,b,S,T,E)=>{let D=T==="float"?"vec2":"vec4",F=E.match(/color/)?"color":D;return _[E]?b==="define"?`
537
537
  #ifndef HAS_UNIFORM_u_${E}
538
538
  uniform lowp float u_${E}_t;
539
- attribute ${S} ${L} a_${E};
539
+ attribute ${S} ${D} a_${E};
540
540
  varying ${S} ${T} ${E};
541
541
  #else
542
542
  uniform ${S} ${T} u_${E};
543
543
  #endif
544
- `:B==="vec4"?`
544
+ `:F==="vec4"?`
545
545
  #ifndef HAS_UNIFORM_u_${E}
546
546
  ${E} = a_${E};
547
547
  #else
@@ -549,18 +549,18 @@ uniform ${S} ${T} u_${E};
549
549
  #endif
550
550
  `:`
551
551
  #ifndef HAS_UNIFORM_u_${E}
552
- ${E} = unpack_mix_${B}(a_${E}, u_${E}_t);
552
+ ${E} = unpack_mix_${F}(a_${E}, u_${E}_t);
553
553
  #else
554
554
  ${S} ${T} ${E} = u_${E};
555
555
  #endif
556
556
  `:b==="define"?`
557
557
  #ifndef HAS_UNIFORM_u_${E}
558
558
  uniform lowp float u_${E}_t;
559
- attribute ${S} ${L} a_${E};
559
+ attribute ${S} ${D} a_${E};
560
560
  #else
561
561
  uniform ${S} ${T} u_${E};
562
562
  #endif
563
- `:B==="vec4"?`
563
+ `:F==="vec4"?`
564
564
  #ifndef HAS_UNIFORM_u_${E}
565
565
  ${S} ${T} ${E} = a_${E};
566
566
  #else
@@ -568,23 +568,25 @@ uniform ${S} ${T} u_${E};
568
568
  #endif
569
569
  `:`
570
570
  #ifndef HAS_UNIFORM_u_${E}
571
- ${S} ${T} ${E} = unpack_mix_${B}(a_${E}, u_${E}_t);
571
+ ${S} ${T} ${E} = unpack_mix_${F}(a_${E}, u_${E}_t);
572
572
  #else
573
573
  ${S} ${T} ${E} = u_${E};
574
574
  #endif
575
- `})),staticAttributes:o,staticUniforms:m}}class jo{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,n,o,a,c,m,_,y,b){this.context=e;let S=this.boundPaintVertexBuffers.length!==a.length;for(let T=0;!S&&T<a.length;T++)this.boundPaintVertexBuffers[T]!==a[T]&&(S=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==o||S||this.boundIndexBuffer!==c||this.boundVertexOffset!==m||this.boundDynamicVertexBuffer!==_||this.boundDynamicVertexBuffer2!==y||this.boundDynamicVertexBuffer3!==b?this.freshBind(n,o,a,c,m,_,y,b):(e.bindVertexArray.set(this.vao),_&&_.bind(),c&&c.dynamicDraw&&c.bind(),y&&y.bind(),b&&b.bind())}freshBind(e,n,o,a,c,m,_,y){let b=e.numAttributes,S=this.context,T=S.gl;this.vao&&this.destroy(),this.vao=S.createVertexArray(),S.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=o,this.boundIndexBuffer=a,this.boundVertexOffset=c,this.boundDynamicVertexBuffer=m,this.boundDynamicVertexBuffer2=_,this.boundDynamicVertexBuffer3=y,n.enableAttributes(T,e);for(let E of o)E.enableAttributes(T,e);m&&m.enableAttributes(T,e),_&&_.enableAttributes(T,e),y&&y.enableAttributes(T,e),n.bind(),n.setVertexAttribPointers(T,e,c);for(let E of o)E.bind(),E.setVertexAttribPointers(T,e,c);m&&(m.bind(),m.setVertexAttribPointers(T,e,c)),a&&a.bind(),_&&(_.bind(),_.setVertexAttribPointers(T,e,c)),y&&(y.bind(),y.setVertexAttribPointers(T,e,c)),S.currentNumAttributes=b}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}let $o=(h,e,n,o,a)=>({u_matrix:h,u_texture:0,u_ele_delta:e,u_fog_matrix:n,u_fog_color:o?o.properties.get("fog-color"):p.aM.white,u_fog_ground_blend:o?o.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?o.calculateFogBlendOpacity(a):0,u_horizon_color:o?o.properties.get("horizon-color"):p.aM.white,u_horizon_fog_blend:o?o.properties.get("horizon-fog-blend"):1});function In(h){let e=[];for(let n=0;n<h.length;n++){if(h[n]===null)continue;let o=h[n].split(" ");e.push(o.pop())}return e}class qo{constructor(e,n,o,a,c,m){let _=e.gl;this.program=_.createProgram();let y=In(n.staticAttributes),b=o?o.getBinderAttributes():[],S=y.concat(b),T=qr.prelude.staticUniforms?In(qr.prelude.staticUniforms):[],E=n.staticUniforms?In(n.staticUniforms):[],L=o?o.getBinderUniforms():[],B=T.concat(E).concat(L),V=[];for(let ne of B)V.indexOf(ne)<0&&V.push(ne);let $=o?o.defines():[];c&&$.push("#define OVERDRAW_INSPECTOR;"),m&&$.push("#define TERRAIN3D;");let q=$.concat(qr.prelude.fragmentSource,n.fragmentSource).join(`
576
- `),G=$.concat(qr.prelude.vertexSource,n.vertexSource).join(`
577
- `),F=_.createShader(_.FRAGMENT_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(F,q),_.compileShader(F),!_.getShaderParameter(F,_.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${_.getShaderInfoLog(F)}`);_.attachShader(this.program,F);let J=_.createShader(_.VERTEX_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(J,G),_.compileShader(J),!_.getShaderParameter(J,_.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${_.getShaderInfoLog(J)}`);_.attachShader(this.program,J),this.attributes={};let Q={};this.numAttributes=S.length;for(let ne=0;ne<this.numAttributes;ne++)S[ne]&&(_.bindAttribLocation(this.program,ne,S[ne]),this.attributes[S[ne]]=ne);if(_.linkProgram(this.program),!_.getProgramParameter(this.program,_.LINK_STATUS))throw new Error(`Program failed to link: ${_.getProgramInfoLog(this.program)}`);_.deleteShader(J),_.deleteShader(F);for(let ne=0;ne<V.length;ne++){let ue=V[ne];if(ue&&!Q[ue]){let me=_.getUniformLocation(this.program,ue);me&&(Q[ue]=me)}}this.fixedUniforms=a(e,Q),this.terrainUniforms=((ne,ue)=>({u_depth:new p.aH(ne,ue.u_depth),u_terrain:new p.aH(ne,ue.u_terrain),u_terrain_dim:new p.aI(ne,ue.u_terrain_dim),u_terrain_matrix:new p.aJ(ne,ue.u_terrain_matrix),u_terrain_unpack:new p.aK(ne,ue.u_terrain_unpack),u_terrain_exaggeration:new p.aI(ne,ue.u_terrain_exaggeration)}))(e,Q),this.binderUniforms=o?o.getUniforms(e,Q):[]}draw(e,n,o,a,c,m,_,y,b,S,T,E,L,B,V,$,q,G){let F=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(o),e.setStencilMode(a),e.setColorMode(c),e.setCullFace(m),y){e.activeTexture.set(F.TEXTURE2),F.bindTexture(F.TEXTURE_2D,y.depthTexture),e.activeTexture.set(F.TEXTURE3),F.bindTexture(F.TEXTURE_2D,y.texture);for(let Q in this.terrainUniforms)this.terrainUniforms[Q].set(y[Q])}for(let Q in this.fixedUniforms)this.fixedUniforms[Q].set(_[Q]);V&&V.setUniforms(e,this.binderUniforms,L,{zoom:B});let J=0;switch(n){case F.LINES:J=2;break;case F.TRIANGLES:J=3;break;case F.LINE_STRIP:J=1}for(let Q of E.get()){let ne=Q.vaos||(Q.vaos={});(ne[b]||(ne[b]=new jo)).bind(e,this,S,V?V.getPaintVertexBuffers():[],T,Q.vertexOffset,$,q,G),F.drawElements(n,Q.primitiveLength*J,F.UNSIGNED_SHORT,Q.primitiveOffset*J*2)}}}function $s(h,e,n){let o=1/ot(n,1,e.transform.tileZoom),a=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,e.transform.tileZoom)/a,m=c*(n.tileID.canonical.x+n.tileID.wrap*a),_=c*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[o,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_]}}let fs=(h,e,n,o)=>{let a=e.style.light,c=a.properties.get("position"),m=[c.x,c.y,c.z],_=(function(){var b=new p.A(9);return p.A!=Float32Array&&(b[1]=0,b[2]=0,b[3]=0,b[5]=0,b[6]=0,b[7]=0),b[0]=1,b[4]=1,b[8]=1,b})();a.properties.get("anchor")==="viewport"&&(function(b,S){var T=Math.sin(S),E=Math.cos(S);b[0]=E,b[1]=T,b[2]=0,b[3]=-T,b[4]=E,b[5]=0,b[6]=0,b[7]=0,b[8]=1})(_,-e.transform.angle),(function(b,S,T){var E=S[0],L=S[1],B=S[2];b[0]=E*T[0]+L*T[3]+B*T[6],b[1]=E*T[1]+L*T[4]+B*T[7],b[2]=E*T[2]+L*T[5]+B*T[8]})(m,m,_);let y=a.properties.get("color");return{u_matrix:h,u_lightpos:m,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+n,u_opacity:o}},qs=(h,e,n,o,a,c,m)=>p.e(fs(h,e,n,o),$s(c,e,m),{u_height_factor:-Math.pow(2,a.overscaledZ)/m.tileSize/8}),Cn=h=>({u_matrix:h}),Ya=(h,e,n,o)=>p.e(Cn(h),$s(n,e,o)),dc=(h,e)=>({u_matrix:h,u_world:e}),Qa=(h,e,n,o,a)=>p.e(Ya(h,e,n,o),{u_world:a}),pc=(h,e,n,o)=>{let a=h.transform,c,m;if(o.paint.get("circle-pitch-alignment")==="map"){let _=ot(n,1,a.zoom);c=!0,m=[_,_]}else c=!1,m=a.pixelsToGLUnits;return{u_camera_to_center_distance:a.cameraToCenterDistance,u_scale_with_map:+(o.paint.get("circle-pitch-scale")==="map"),u_matrix:h.translatePosMatrix(e.posMatrix,n,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_pitch_with_map:+c,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:m}},nn=(h,e,n)=>({u_matrix:h,u_inv_matrix:e,u_camera_to_center_distance:n.cameraToCenterDistance,u_viewport_size:[n.width,n.height]}),ms=(h,e,n=1)=>({u_matrix:h,u_color:e,u_overlay:0,u_overlay_scale:n}),Ci=h=>({u_matrix:h}),Pi=(h,e,n,o)=>({u_matrix:h,u_extrude_scale:ot(e,1,n),u_intensity:o}),Zs=(h,e,n,o)=>{let a=p.H();p.aP(a,0,h.width,h.height,0,0,1);let c=h.context.gl;return{u_matrix:a,u_world:[c.drawingBufferWidth,c.drawingBufferHeight],u_image:n,u_color_ramp:o,u_opacity:e.paint.get("heatmap-opacity")}};function Gs(h,e){let n=Math.pow(2,e.canonical.z),o=e.canonical.y;return[new p.Z(0,o/n).toLngLat().lat,new p.Z(0,(o+1)/n).toLngLat().lat]}let Hs=(h,e,n,o)=>{let a=h.transform;return{u_matrix:il(h,e,n,o),u_ratio:1/ot(e,1,a.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},el=(h,e,n,o,a)=>p.e(Hs(h,e,n,a),{u_image:0,u_image_height:o}),Pn=(h,e,n,o,a)=>{let c=h.transform,m=tl(e,c);return{u_matrix:il(h,e,n,a),u_texsize:e.imageAtlasTexture.size,u_ratio:1/ot(e,1,c.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[m,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},fc=(h,e,n,o,a,c)=>{let m=h.lineAtlas,_=tl(e,h.transform),y=n.layout.get("line-cap")==="round",b=m.getDash(o.from,y),S=m.getDash(o.to,y),T=b.width*a.fromScale,E=S.width*a.toScale;return p.e(Hs(h,e,n,c),{u_patternscale_a:[_/T,-b.height/2],u_patternscale_b:[_/E,-S.height/2],u_sdfgamma:m.width/(256*Math.min(T,E)*h.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:S.y,u_mix:a.t})};function tl(h,e){return 1/ot(h,1,e.tileZoom)}function il(h,e,n,o){return h.translatePosMatrix(o?o.posMatrix:e.tileID.posMatrix,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}let mc=(h,e,n,o,a)=>{return{u_matrix:h,u_tl_parent:e,u_scale_parent:n,u_buffer_scale:1,u_fade_t:o.mix,u_opacity:o.opacity*a.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:a.paint.get("raster-brightness-min"),u_brightness_high:a.paint.get("raster-brightness-max"),u_saturation_factor:(m=a.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(c=a.paint.get("raster-contrast"),c>0?1/(1-c):1+c),u_spin_weights:gc(a.paint.get("raster-hue-rotate"))};var c,m};function gc(h){h*=Math.PI/180;let e=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}let rl=(h,e,n,o,a,c,m,_,y,b,S,T,E,L)=>{let B=m.transform;return{u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:B.cameraToCenterDistance,u_pitch:B.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:B.width/B.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:_,u_label_plane_matrix:y,u_coord_matrix:b,u_is_text:+T,u_pitch_with_map:+o,u_is_along_line:a,u_is_variable_anchor:c,u_texsize:E,u_texture:0,u_translation:S,u_pitched_scale:L}},gs=(h,e,n,o,a,c,m,_,y,b,S,T,E,L,B)=>{let V=m.transform;return p.e(rl(h,e,n,o,a,c,m,_,y,b,S,T,E,B),{u_gamma_scale:o?Math.cos(V._pitch)*V.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:+L})},Zo=(h,e,n,o,a,c,m,_,y,b,S,T,E,L)=>p.e(gs(h,e,n,o,a,c,m,_,y,b,S,!0,T,!0,L),{u_texsize_icon:E,u_texture_icon:1}),Ws=(h,e,n)=>({u_matrix:h,u_opacity:e,u_color:n}),Go=(h,e,n,o,a,c)=>p.e((function(m,_,y,b){let S=y.imageManager.getPattern(m.from.toString()),T=y.imageManager.getPattern(m.to.toString()),{width:E,height:L}=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),q=V*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:S.tl,u_pattern_br_a:S.br,u_pattern_tl_b:T.tl,u_pattern_br_b:T.br,u_texsize:[E,L],u_mix:_.t,u_pattern_size_a:S.displaySize,u_pattern_size_b:T.displaySize,u_scale_a:_.fromScale,u_scale_b:_.toScale,u_tile_units_to_pixels:1/ot(b,1,y.transform.tileZoom),u_pixel_coord_upper:[$>>16,q>>16],u_pixel_coord_lower:[65535&$,65535&q]}})(o,c,n,a),{u_matrix:h,u_opacity:e}),Ho={fillExtrusion:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_opacity:new p.aI(h,e.u_opacity)}),fillExtrusionPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_height_factor:new p.aI(h,e.u_height_factor),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade),u_opacity:new p.aI(h,e.u_opacity)}),fill:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),fillPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),fillOutline:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world)}),fillOutlinePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),circle:(h,e)=>({u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_scale_with_map:new p.aH(h,e.u_scale_with_map),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_extrude_scale:new p.aO(h,e.u_extrude_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_matrix:new p.aJ(h,e.u_matrix)}),collisionBox:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_pixel_extrude_scale:new p.aO(h,e.u_pixel_extrude_scale)}),collisionCircle:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_inv_matrix:new p.aJ(h,e.u_inv_matrix),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_viewport_size:new p.aO(h,e.u_viewport_size)}),debug:(h,e)=>({u_color:new p.aL(h,e.u_color),u_matrix:new p.aJ(h,e.u_matrix),u_overlay:new p.aH(h,e.u_overlay),u_overlay_scale:new p.aI(h,e.u_overlay_scale)}),clippingMask:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),heatmap:(h,e)=>({u_extrude_scale:new p.aI(h,e.u_extrude_scale),u_intensity:new p.aI(h,e.u_intensity),u_matrix:new p.aJ(h,e.u_matrix)}),heatmapTexture:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_color_ramp:new p.aH(h,e.u_color_ramp),u_opacity:new p.aI(h,e.u_opacity)}),hillshade:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_latrange:new p.aO(h,e.u_latrange),u_light:new p.aO(h,e.u_light),u_shadow:new p.aL(h,e.u_shadow),u_highlight:new p.aL(h,e.u_highlight),u_accent:new p.aL(h,e.u_accent)}),hillshadePrepare:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_dimension:new p.aO(h,e.u_dimension),u_zoom:new p.aI(h,e.u_zoom),u_unpack:new p.aK(h,e.u_unpack)}),line:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels)}),lineGradient:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_image:new p.aH(h,e.u_image),u_image_height:new p.aI(h,e.u_image_height)}),linePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texsize:new p.aO(h,e.u_texsize),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_image:new p.aH(h,e.u_image),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),lineSDF:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_patternscale_a:new p.aO(h,e.u_patternscale_a),u_patternscale_b:new p.aO(h,e.u_patternscale_b),u_sdfgamma:new p.aI(h,e.u_sdfgamma),u_image:new p.aH(h,e.u_image),u_tex_y_a:new p.aI(h,e.u_tex_y_a),u_tex_y_b:new p.aI(h,e.u_tex_y_b),u_mix:new p.aI(h,e.u_mix)}),raster:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_tl_parent:new p.aO(h,e.u_tl_parent),u_scale_parent:new p.aI(h,e.u_scale_parent),u_buffer_scale:new p.aI(h,e.u_buffer_scale),u_fade_t:new p.aI(h,e.u_fade_t),u_opacity:new p.aI(h,e.u_opacity),u_image0:new p.aH(h,e.u_image0),u_image1:new p.aH(h,e.u_image1),u_brightness_low:new p.aI(h,e.u_brightness_low),u_brightness_high:new p.aI(h,e.u_brightness_high),u_saturation_factor:new p.aI(h,e.u_saturation_factor),u_contrast_factor:new p.aI(h,e.u_contrast_factor),u_spin_weights:new p.aN(h,e.u_spin_weights)}),symbolIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolSDF:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolTextAndIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texsize_icon:new p.aO(h,e.u_texsize_icon),u_texture:new p.aH(h,e.u_texture),u_texture_icon:new p.aH(h,e.u_texture_icon),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),background:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_color:new p.aL(h,e.u_color)}),backgroundPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_image:new p.aH(h,e.u_image),u_pattern_tl_a:new p.aO(h,e.u_pattern_tl_a),u_pattern_br_a:new p.aO(h,e.u_pattern_br_a),u_pattern_tl_b:new p.aO(h,e.u_pattern_tl_b),u_pattern_br_b:new p.aO(h,e.u_pattern_br_b),u_texsize:new p.aO(h,e.u_texsize),u_mix:new p.aI(h,e.u_mix),u_pattern_size_a:new p.aO(h,e.u_pattern_size_a),u_pattern_size_b:new p.aO(h,e.u_pattern_size_b),u_scale_a:new p.aI(h,e.u_scale_a),u_scale_b:new p.aI(h,e.u_scale_b),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_tile_units_to_pixels:new p.aI(h,e.u_tile_units_to_pixels)}),terrain:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_ele_delta:new p.aI(h,e.u_ele_delta),u_fog_matrix:new p.aJ(h,e.u_fog_matrix),u_fog_color:new p.aL(h,e.u_fog_color),u_fog_ground_blend:new p.aI(h,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new p.aI(h,e.u_fog_ground_blend_opacity),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon_fog_blend:new p.aI(h,e.u_horizon_fog_blend)}),terrainDepth:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ele_delta:new p.aI(h,e.u_ele_delta)}),terrainCoords:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_terrain_coords_id:new p.aI(h,e.u_terrain_coords_id),u_ele_delta:new p.aI(h,e.u_ele_delta)}),sky:(h,e)=>({u_sky_color:new p.aL(h,e.u_sky_color),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon:new p.aI(h,e.u_horizon),u_sky_horizon_blend:new p.aI(h,e.u_sky_horizon_blend)})};class Sr{constructor(e,n,o){this.context=e;let a=e.gl;this.buffer=a.createBuffer(),this.dynamicDraw=!!o,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let _c={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Wo{constructor(e,n,o,a){this.length=n.length,this.attributes=o,this.itemSize=n.bytesPerElement,this.dynamicDraw=a,this.context=e;let c=e.gl;this.buffer=c.createBuffer(),e.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,n){for(let o=0;o<this.attributes.length;o++){let a=n.attributes[this.attributes[o].name];a!==void 0&&e.enableVertexAttribArray(a)}}setVertexAttribPointers(e,n,o){for(let a=0;a<this.attributes.length;a++){let c=this.attributes[a],m=n.attributes[c.name];m!==void 0&&e.vertexAttribPointer(m,c.components,e[_c[c.type]],!1,this.itemSize,c.offset+this.itemSize*(o||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let sn=new WeakMap;function Zr(h){var e;if(sn.has(h))return sn.get(h);{let n=(e=h.getParameter(h.VERSION))===null||e===void 0?void 0:e.startsWith("WebGL 2.0");return sn.set(h,n),n}}class yt{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Xs extends yt{getDefault(){return p.aM.transparent}set(e){let n=this.current;(e.r!==n.r||e.g!==n.g||e.b!==n.b||e.a!==n.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class yc extends yt{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Mn extends yt{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class xc extends yt{getDefault(){return[!0,!0,!0,!0]}set(e){let n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||e[3]!==n[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class nl extends yt{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class vc extends yt{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class sl extends yt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let n=this.current;(e.func!==n.func||e.ref!==n.ref||e.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class Xo extends yt{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class ol extends yt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;e?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=e,this.dirty=!1}}class al extends yt{getDefault(){return[0,1]}set(e){let n=this.current;(e[0]!==n[0]||e[1]!==n[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class ll extends yt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;e?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=e,this.dirty=!1}}class cl extends yt{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class on extends yt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;e?n.enable(n.BLEND):n.disable(n.BLEND),this.current=e,this.dirty=!1}}class hl extends yt{getDefault(){let e=this.gl;return[e.ONE,e.ZERO]}set(e){let n=this.current;(e[0]!==n[0]||e[1]!==n[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class bc extends yt{getDefault(){return p.aM.transparent}set(e){let n=this.current;(e.r!==n.r||e.g!==n.g||e.b!==n.b||e.a!==n.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class ul extends yt{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class _s extends yt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;e?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=e,this.dirty=!1}}class wc extends yt{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Ks extends yt{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Sc extends yt{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Tc extends yt{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class dl extends yt{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||e[3]!==n[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class pl extends yt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class fl extends yt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Ko extends yt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.bindTexture(n.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class ml extends yt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Js extends yt{getDefault(){return null}set(e){let n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Lr extends yt{getDefault(){return null}set(e){var n;if(e===this.current&&!this.dirty)return;let o=this.gl;Zr(o)?o.bindVertexArray(e):(n=o.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class Jo extends yt{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class Yo extends yt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class Qo extends yt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class Ys extends yt{constructor(e,n){super(e),this.context=e,this.parent=n}getDefault(){return null}}class ea extends Ys{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class an extends Ys{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class ta extends Ys{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Ic{constructor(e,n,o,a,c){this.context=e,this.width=n,this.height=o;let m=e.gl,_=this.framebuffer=m.createFramebuffer();if(this.colorAttachment=new ea(e,_),a)this.depthAttachment=c?new ta(e,_):new an(e,_);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(){let e=this.context.gl,n=this.colorAttachment.get();if(n&&e.deleteTexture(n),this.depthAttachment){let o=this.depthAttachment.get();o&&e.deleteRenderbuffer(o)}e.deleteFramebuffer(this.framebuffer)}}class Ut{constructor(e,n,o){this.blendFunction=e,this.blendColor=n,this.mask=o}}Ut.Replace=[1,0],Ut.disabled=new Ut(Ut.Replace,p.aM.transparent,[!1,!1,!1,!1]),Ut.unblended=new Ut(Ut.Replace,p.aM.transparent,[!0,!0,!0,!0]),Ut.alphaBlended=new Ut([1,771],p.aM.transparent,[!0,!0,!0,!0]);class Cc{constructor(e){var n,o;if(this.gl=e,this.clearColor=new Xs(this),this.clearDepth=new yc(this),this.clearStencil=new Mn(this),this.colorMask=new xc(this),this.depthMask=new nl(this),this.stencilMask=new vc(this),this.stencilFunc=new sl(this),this.stencilOp=new Xo(this),this.stencilTest=new ol(this),this.depthRange=new al(this),this.depthTest=new ll(this),this.depthFunc=new cl(this),this.blend=new on(this),this.blendFunc=new hl(this),this.blendColor=new bc(this),this.blendEquation=new ul(this),this.cullFace=new _s(this),this.cullFaceSide=new wc(this),this.frontFace=new Ks(this),this.program=new Sc(this),this.activeTexture=new Tc(this),this.viewport=new dl(this),this.bindFramebuffer=new pl(this),this.bindRenderbuffer=new fl(this),this.bindTexture=new Ko(this),this.bindVertexBuffer=new ml(this),this.bindElementBuffer=new Js(this),this.bindVertexArray=new Lr(this),this.pixelStoreUnpack=new Jo(this),this.pixelStoreUnpackPremultiplyAlpha=new Yo(this),this.pixelStoreUnpackFlipY=new Qo(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),Zr(e)){this.HALF_FLOAT=e.HALF_FLOAT;let a=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=e.RGBA16F)!==null&&n!==void 0?n:a?.RGBA16F_EXT,this.RGB16F=(o=e.RGB16F)!==null&&o!==void 0?o:a?.RGB16F_EXT,e.getExtension("EXT_color_buffer_float")}else{e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");let a=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=a?.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(e,n){return new Sr(this,e,n)}createVertexBuffer(e,n,o){return new Wo(this,e,n,o)}createRenderbuffer(e,n,o){let a=this.gl,c=a.createRenderbuffer();return this.bindRenderbuffer.set(c),a.renderbufferStorage(a.RENDERBUFFER,e,n,o),this.bindRenderbuffer.set(null),c}createFramebuffer(e,n,o,a){return new Ic(this,e,n,o,a)}clear({color:e,depth:n,stencil:o}){let a=this.gl,c=0;e&&(c|=a.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(c|=a.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),o!==void 0&&(c|=a.STENCIL_BUFFER_BIT,this.clearStencil.set(o),this.stencilMask.set(255)),a.clear(c)}setCullFace(e){e.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){p.aE(e.blendFunction,Ut.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){var e;return Zr(this.gl)?this.gl.createVertexArray():(e=this.gl.getExtension("OES_vertex_array_object"))===null||e===void 0?void 0:e.createVertexArrayOES()}deleteVertexArray(e){var n;return Zr(this.gl)?this.gl.deleteVertexArray(e):(n=this.gl.getExtension("OES_vertex_array_object"))===null||n===void 0?void 0:n.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}class nt{constructor(e,n,o){this.func=e,this.mask=n,this.range=o}}nt.ReadOnly=!1,nt.ReadWrite=!0,nt.disabled=new nt(519,nt.ReadOnly,[0,1]);let Qs=7680;class It{constructor(e,n,o,a,c,m){this.test=e,this.ref=n,this.mask=o,this.fail=a,this.depthFail=c,this.pass=m}}It.disabled=new It({func:519,mask:0},0,0,Qs,Qs,Qs);class bt{constructor(e,n,o){this.enable=e,this.mode=n,this.frontFace=o}}let ln;function ys(h,e,n,o,a){let c=h.context,m=c.gl,_=h.useProgram("collisionBox"),y=[],b=0,S=0;for(let q=0;q<o.length;q++){let G=o[q],F=e.getTile(G).getBucket(n);if(!F)continue;let J=a?F.textCollisionBox:F.iconCollisionBox,Q=F.collisionCircleArray;if(Q.length>0){let ne=p.H();p.aQ(ne,F.placementInvProjMatrix,h.transform.glCoordMatrix),p.aQ(ne,ne,F.placementViewportMatrix),y.push({circleArray:Q,circleOffset:S,transform:G.posMatrix,invTransform:ne,coord:G}),b+=Q.length/4,S=b}J&&_.draw(c,m.LINES,nt.disabled,It.disabled,h.colorModeForRenderPass(),bt.disabled,{u_matrix:G.posMatrix,u_pixel_extrude_scale:[1/(T=h.transform).width,1/T.height]},h.style.map.terrain&&h.style.map.terrain.getTerrainData(G),n.id,J.layoutVertexBuffer,J.indexBuffer,J.segments,null,h.transform.zoom,null,null,J.collisionVertexBuffer)}var T;if(!a||!y.length)return;let E=h.useProgram("collisionCircle"),L=new p.aR;L.resize(4*b),L._trim();let B=0;for(let q of y)for(let G=0;G<q.circleArray.length/4;G++){let F=4*G,J=q.circleArray[F+0],Q=q.circleArray[F+1],ne=q.circleArray[F+2],ue=q.circleArray[F+3];L.emplace(B++,J,Q,ne,ue,0),L.emplace(B++,J,Q,ne,ue,1),L.emplace(B++,J,Q,ne,ue,2),L.emplace(B++,J,Q,ne,ue,3)}(!ln||ln.length<2*b)&&(ln=(function(q){let G=2*q,F=new p.aT;F.resize(G),F._trim();for(let J=0;J<G;J++){let Q=6*J;F.uint16[Q+0]=4*J+0,F.uint16[Q+1]=4*J+1,F.uint16[Q+2]=4*J+2,F.uint16[Q+3]=4*J+2,F.uint16[Q+4]=4*J+3,F.uint16[Q+5]=4*J+0}return F})(b));let V=c.createIndexBuffer(ln,!0),$=c.createVertexBuffer(L,p.aS.members,!0);for(let q of y){let G=nn(q.transform,q.invTransform,h.transform);E.draw(c,m.TRIANGLES,nt.disabled,It.disabled,h.colorModeForRenderPass(),bt.disabled,G,h.style.map.terrain&&h.style.map.terrain.getTerrainData(q.coord),n.id,$,V,p.a0.simpleSegment(0,2*q.circleOffset,q.circleArray.length,q.circleArray.length/2),null,h.transform.zoom,null,null,null)}$.destroy(),V.destroy()}bt.disabled=new bt(!1,1029,2305),bt.backCCW=new bt(!0,1029,2305);let xs=p.an(new Float32Array(16));function ia(h,e,n,o,a,c){let{horizontalAlign:m,verticalAlign:_}=p.au(h);return new p.P((-(m-.5)*e/a+o[0])*c,(-(_-.5)*n/a+o[1])*c)}function cn(h,e,n,o,a,c){let m=e.tileAnchorPoint.add(new p.P(e.translation[0],e.translation[1]));if(e.pitchWithMap){let _=o.mult(c);n||(_=_.rotate(-a));let y=m.add(_);return U(y.x,y.y,e.labelPlaneMatrix,e.getElevation).point}if(n){let _=le(e.tileAnchorPoint.x+1,e.tileAnchorPoint.y,e).point.sub(h),y=Math.atan(_.y/_.x)+(_.x<0?Math.PI:0);return h.add(o.rotate(y))}return h.add(o)}function An(h,e,n,o,a,c,m,_,y,b,S,T,E,L){let B=h.text.placedSymbolArray,V=h.text.dynamicLayoutVertexArray,$=h.icon.dynamicLayoutVertexArray,q={};V.clear();for(let G=0;G<B.length;G++){let F=B.get(G),J=F.hidden||!F.crossTileID||h.allowVerticalPlacement&&!F.placedOrientation?null:o[F.crossTileID];if(J){let Q=new p.P(F.anchorX,F.anchorY),ne={getElevation:L,width:a.width,height:a.height,labelPlaneMatrix:c,lineVertexArray:null,pitchWithMap:n,projection:S,projectionCache:null,tileAnchorPoint:Q,translation:T,unwrappedTileID:E},ue=n?U(Q.x,Q.y,m,L):le(Q.x,Q.y,ne),me=M(a.cameraToCenterDistance,ue.signedDistanceFromCamera),Te=p.ai(h.textSizeData,y,F)*me/p.ap;n&&(Te*=h.tilePixelRatio/_);let{width:Ae,height:xe,anchor:ye,textOffset:Re,textBoxScale:We}=J,be=ia(ye,Ae,xe,Re,We,Te),Pe=S.getPitchedTextCorrection(a,Q.add(new p.P(T[0],T[1])),E),Ze=cn(ue.point,ne,e,be,a.angle,Pe),Et=h.allowVerticalPlacement&&F.placedOrientation===p.ah.vertical?Math.PI/2:0;for(let Qe=0;Qe<F.numGlyphs;Qe++)p.aj(V,Ze,Et);b&&F.associatedIconIndex>=0&&(q[F.associatedIconIndex]={shiftedAnchor:Ze,angle:Et})}else Ve(F.numGlyphs,V)}if(b){$.clear();let G=h.icon.placedSymbolArray;for(let F=0;F<G.length;F++){let J=G.get(F);if(J.hidden)Ve(J.numGlyphs,$);else{let Q=q[F];if(Q)for(let ne=0;ne<J.numGlyphs;ne++)p.aj($,Q.shiftedAnchor,Q.angle);else Ve(J.numGlyphs,$)}}h.icon.dynamicLayoutVertexBuffer.updateData($)}h.text.dynamicLayoutVertexBuffer.updateData(V)}function Gi(h,e,n){return n.iconsInText&&e?"symbolTextAndIcon":h?"symbolSDF":"symbolIcon"}function ra(h,e,n,o,a,c,m,_,y,b,S,T){let E=h.context,L=E.gl,B=h.transform,V=tn(),$=_==="map",q=y==="map",G=_!=="viewport"&&n.layout.get("symbol-placement")!=="point",F=$&&!q&&!G,J=!q&&G,Q=!n.layout.get("symbol-sort-key").isConstant(),ne=!1,ue=h.depthModeForSublayer(0,nt.ReadOnly),me=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Te=[],Ae=V.getCircleRadiusCorrection(B);for(let xe of o){let ye=e.getTile(xe),Re=ye.getBucket(n);if(!Re)continue;let We=a?Re.text:Re.icon;if(!We||!We.segments.get().length||!We.hasVisibleVertices)continue;let be=We.programConfigurations.get(n.id),Pe=a||Re.sdfIcons,Ze=a?Re.textSizeData:Re.iconSizeData,Et=q||B.pitch!==0,Qe=h.useProgram(Gi(Pe,a,Re),be),at=p.ag(Ze,B.zoom),kt=h.style.map.terrain&&h.style.map.terrain.getTerrainData(xe),ui,cr,zt,Mi,bi=[0,0],di=null;if(a)cr=ye.glyphAtlasTexture,zt=L.LINEAR,ui=ye.glyphAtlasTexture.size,Re.iconsInText&&(bi=ye.imageAtlasTexture.size,di=ye.imageAtlasTexture,Mi=Et||h.options.rotating||h.options.zooming||Ze.kind==="composite"||Ze.kind==="camera"?L.LINEAR:L.NEAREST);else{let ct=n.layout.get("icon-size").constantOr(0)!==1||Re.iconsNeedLinear;cr=ye.imageAtlasTexture,zt=Pe||h.options.rotating||h.options.zooming||ct||Et?L.LINEAR:L.NEAREST,ui=ye.imageAtlasTexture.size}let wi=ot(ye,1,h.transform.zoom),Cr=J?xe.posMatrix:xs,Zn=$r(Cr,q,$,h.transform,wi),xo=wr(Cr,q,$,h.transform,wi),Gn=wr(xe.posMatrix,q,$,h.transform,wi),Xi=V.translatePosition(h.transform,ye,c,m),vo=me&&Re.hasTextData(),Ma=n.layout.get("icon-text-fit")!=="none"&&vo&&Re.hasIconData();if(G){let ct=h.style.map.terrain?(Hn,Wn)=>h.style.map.terrain.getElevation(xe,Hn,Wn):null,fn=n.layout.get("text-rotation-alignment")==="map";D(Re,xe.posMatrix,h,a,Zn,Gn,q,b,fn,V,xe.toUnwrapped(),B.width,B.height,Xi,ct)}let Ki=xe.posMatrix,Ji=a&&me||Ma,Gr=G||Ji?xs:Zn,hr=xo,oi=Pe&&n.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1)!==0,pi;pi=Pe?Re.iconsInText?Zo(Ze.kind,at,F,q,G,Ji,h,Ki,Gr,hr,Xi,ui,bi,Ae):gs(Ze.kind,at,F,q,G,Ji,h,Ki,Gr,hr,Xi,a,ui,!0,Ae):rl(Ze.kind,at,F,q,G,Ji,h,Ki,Gr,hr,Xi,a,ui,Ae);let Vi={program:Qe,buffers:We,uniformValues:pi,atlasTexture:cr,atlasTextureIcon:di,atlasInterpolation:zt,atlasInterpolationIcon:Mi,isSDF:Pe,hasHalo:oi};if(Q&&Re.canOverlap){ne=!0;let ct=We.segments.get();for(let fn of ct)Te.push({segments:new p.a0([fn]),sortKey:fn.sortKey,state:Vi,terrainData:kt})}else Te.push({segments:We.segments,sortKey:0,state:Vi,terrainData:kt})}ne&&Te.sort(((xe,ye)=>xe.sortKey-ye.sortKey));for(let xe of Te){let ye=xe.state;if(E.activeTexture.set(L.TEXTURE0),ye.atlasTexture.bind(ye.atlasInterpolation,L.CLAMP_TO_EDGE),ye.atlasTextureIcon&&(E.activeTexture.set(L.TEXTURE1),ye.atlasTextureIcon&&ye.atlasTextureIcon.bind(ye.atlasInterpolationIcon,L.CLAMP_TO_EDGE)),ye.isSDF){let Re=ye.uniformValues;ye.hasHalo&&(Re.u_is_halo=1,na(ye.buffers,xe.segments,n,h,ye.program,ue,S,T,Re,xe.terrainData)),Re.u_is_halo=0}na(ye.buffers,xe.segments,n,h,ye.program,ue,S,T,ye.uniformValues,xe.terrainData)}}function na(h,e,n,o,a,c,m,_,y,b){let S=o.context;a.draw(S,S.gl.TRIANGLES,c,m,_,bt.disabled,y,b,n.id,h.layoutVertexBuffer,h.indexBuffer,e,n.paint,o.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function sa(h,e,n,o){let a=h.context,c=a.gl,m=It.disabled,_=new Ut([c.ONE,c.ONE],p.aM.transparent,[!0,!0,!0,!0]),y=e.getBucket(n);if(!y)return;let b=o.key,S=n.heatmapFbos.get(b);S||(S=vs(a,e.tileSize,e.tileSize),n.heatmapFbos.set(b,S)),a.bindFramebuffer.set(S.framebuffer),a.viewport.set([0,0,e.tileSize,e.tileSize]),a.clear({color:p.aM.transparent});let T=y.programConfigurations.get(n.id),E=h.useProgram("heatmap",T),L=h.style.map.terrain.getTerrainData(o);E.draw(a,c.TRIANGLES,nt.disabled,m,_,bt.disabled,Pi(o.posMatrix,e,h.transform.zoom,n.paint.get("heatmap-intensity")),L,n.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,n.paint,h.transform.zoom,T)}function hn(h,e,n){let o=h.context,a=o.gl;o.setColorMode(h.colorModeForRenderPass());let c=bs(o,e),m=n.key,_=e.heatmapFbos.get(m);_&&(o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,_.colorAttachment.get()),o.activeTexture.set(a.TEXTURE1),c.bind(a.LINEAR,a.CLAMP_TO_EDGE),h.useProgram("heatmapTexture").draw(o,a.TRIANGLES,nt.disabled,It.disabled,h.colorModeForRenderPass(),bt.disabled,Zs(h,e,0,1),null,e.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments,e.paint,h.transform.zoom),_.destroy(),e.heatmapFbos.delete(m))}function vs(h,e,n){var o,a;let c=h.gl,m=c.createTexture();c.bindTexture(c.TEXTURE_2D,m),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);let _=(o=h.HALF_FLOAT)!==null&&o!==void 0?o:c.UNSIGNED_BYTE,y=(a=h.RGBA16F)!==null&&a!==void 0?a:c.RGBA;c.texImage2D(c.TEXTURE_2D,0,y,e,n,0,c.RGBA,_,null);let b=h.createFramebuffer(e,n,!1,!1);return b.colorAttachment.set(m),b}function bs(h,e){return e.colorRampTexture||(e.colorRampTexture=new Ye(h,e.colorRamp,h.gl.RGBA)),e.colorRampTexture}function En(h,e,n,o,a){if(!n||!o||!o.imageAtlas)return;let c=o.imageAtlas.patternPositions,m=c[n.to.toString()],_=c[n.from.toString()];if(!m&&_&&(m=_),!_&&m&&(_=m),!m||!_){let y=a.getPaintProperty(e);m=c[y],_=c[y]}m&&_&&h.setConstantPatternPositions(m,_)}function ws(h,e,n,o,a,c,m){let _=h.context.gl,y="fill-pattern",b=n.paint.get(y),S=b&&b.constantOr(1),T=n.getCrossfadeParameters(),E,L,B,V,$;m?(L=S&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",E=_.LINES):(L=S?"fillPattern":"fill",E=_.TRIANGLES);let q=b.constantOr(null);for(let G of o){let F=e.getTile(G);if(S&&!F.patternsLoaded())continue;let J=F.getBucket(n);if(!J)continue;let Q=J.programConfigurations.get(n.id),ne=h.useProgram(L,Q),ue=h.style.map.terrain&&h.style.map.terrain.getTerrainData(G);S&&(h.context.activeTexture.set(_.TEXTURE0),F.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),Q.updatePaintBuffers(T)),En(Q,y,q,F,n);let me=ue?G:null,Te=h.translatePosMatrix(me?me.posMatrix:G.posMatrix,F,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(m){V=J.indexBuffer2,$=J.segments2;let Ae=[_.drawingBufferWidth,_.drawingBufferHeight];B=L==="fillOutlinePattern"&&S?Qa(Te,h,T,F,Ae):dc(Te,Ae)}else V=J.indexBuffer,$=J.segments,B=S?Ya(Te,h,T,F):Cn(Te);ne.draw(h.context,E,a,h.stencilModeForClipping(G),c,bt.disabled,B,ue,n.id,J.layoutVertexBuffer,V,$,n.paint,h.transform.zoom,Q)}}function eo(h,e,n,o,a,c,m){let _=h.context,y=_.gl,b="fill-extrusion-pattern",S=n.paint.get(b),T=S.constantOr(1),E=n.getCrossfadeParameters(),L=n.paint.get("fill-extrusion-opacity"),B=S.constantOr(null);for(let V of o){let $=e.getTile(V),q=$.getBucket(n);if(!q)continue;let G=h.style.map.terrain&&h.style.map.terrain.getTerrainData(V),F=q.programConfigurations.get(n.id),J=h.useProgram(T?"fillExtrusionPattern":"fillExtrusion",F);T&&(h.context.activeTexture.set(y.TEXTURE0),$.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),F.updatePaintBuffers(E)),En(F,b,B,$,n);let Q=h.translatePosMatrix(V.posMatrix,$,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ne=n.paint.get("fill-extrusion-vertical-gradient"),ue=T?qs(Q,h,ne,L,V,E,$):fs(Q,h,ne,L);J.draw(_,_.gl.TRIANGLES,a,c,m,bt.backCCW,ue,G,n.id,q.layoutVertexBuffer,q.indexBuffer,q.segments,n.paint,h.transform.zoom,F,h.style.map.terrain&&q.centroidVertexBuffer)}}function kn(h,e,n,o,a,c,m){let _=h.context,y=_.gl,b=n.fbo;if(!b)return;let S=h.useProgram("hillshade"),T=h.style.map.terrain&&h.style.map.terrain.getTerrainData(e);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b.colorAttachment.get()),S.draw(_,y.TRIANGLES,a,c,m,bt.disabled,((E,L,B,V)=>{let $=B.paint.get("hillshade-shadow-color"),q=B.paint.get("hillshade-highlight-color"),G=B.paint.get("hillshade-accent-color"),F=B.paint.get("hillshade-illumination-direction")*(Math.PI/180);B.paint.get("hillshade-illumination-anchor")==="viewport"&&(F-=E.transform.angle);let J=!E.options.moving;return{u_matrix:V?V.posMatrix:E.transform.calculatePosMatrix(L.tileID.toUnwrapped(),J),u_image:0,u_latrange:Gs(0,L.tileID),u_light:[B.paint.get("hillshade-exaggeration"),F],u_shadow:$,u_highlight:q,u_accent:G}})(h,n,o,T?e:null),T,o.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments)}function zn(h,e,n,o,a,c){let m=h.context,_=m.gl,y=e.dem;if(y&&y.data){let b=y.dim,S=y.stride,T=y.getPixels();if(m.activeTexture.set(_.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||h.getTileTexture(S),e.demTexture){let L=e.demTexture;L.update(T,{premultiply:!1}),L.bind(_.NEAREST,_.CLAMP_TO_EDGE)}else e.demTexture=new Ye(m,T,_.RGBA,{premultiply:!1}),e.demTexture.bind(_.NEAREST,_.CLAMP_TO_EDGE);m.activeTexture.set(_.TEXTURE0);let E=e.fbo;if(!E){let L=new Ye(m,{width:b,height:b,data:null},_.RGBA);L.bind(_.LINEAR,_.CLAMP_TO_EDGE),E=e.fbo=m.createFramebuffer(b,b,!0,!1),E.colorAttachment.set(L.texture)}m.bindFramebuffer.set(E.framebuffer),m.viewport.set([0,0,b,b]),h.useProgram("hillshadePrepare").draw(m,_.TRIANGLES,o,a,c,bt.disabled,((L,B)=>{let 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:L.overscaledZ,u_unpack:B.getUnpackVector()}})(e.tileID,y),null,n.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments),e.needsHillshadePrepare=!1}}function gl(h,e,n,o,a,c){let m=o.paint.get("raster-fade-duration");if(!c&&m>0){let _=pe.now(),y=(_-h.timeAdded)/m,b=e?(_-e.timeAdded)/m:-1,S=n.getSource(),T=a.coveringZoomLevel({tileSize:S.tileSize,roundZoom:S.roundZoom}),E=!e||Math.abs(e.tileID.overscaledZ-T)>Math.abs(h.tileID.overscaledZ-T),L=E&&h.refreshedUponExpiration?1:p.ac(E?y:1-b,0,1);return h.refreshedUponExpiration&&y>=1&&(h.refreshedUponExpiration=!1),e?{opacity:1,mix:1-L}:{opacity:L,mix:0}}return{opacity:1,mix:0}}let oa=new p.aM(1,0,0,1),pt=new p.aM(0,1,0,1),to=new p.aM(0,0,1,1),Pc=new p.aM(1,0,1,1),_l=new p.aM(0,1,1,1);function Ln(h,e,n,o){io(h,0,e+n/2,h.transform.width,n,o)}function yl(h,e,n,o){io(h,e-n/2,0,n,h.transform.height,o)}function io(h,e,n,o,a,c){let m=h.context,_=m.gl;_.enable(_.SCISSOR_TEST),_.scissor(e*h.pixelRatio,n*h.pixelRatio,o*h.pixelRatio,a*h.pixelRatio),m.clear({color:c}),_.disable(_.SCISSOR_TEST)}function xl(h,e,n){let o=h.context,a=o.gl,c=n.posMatrix,m=h.useProgram("debug"),_=nt.disabled,y=It.disabled,b=h.colorModeForRenderPass(),S="$debug",T=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);o.activeTexture.set(a.TEXTURE0);let E=e.getTileByID(n.key).latestRawTileData,L=Math.floor((E&&E.byteLength||0)/1024),B=e.getTile(n).tileSize,V=512/Math.min(B,512)*(n.overscaledZ/h.transform.zoom)*.5,$=n.canonical.toString();n.overscaledZ!==n.canonical.z&&($+=` => ${n.overscaledZ}`),(function(q,G){q.initDebugOverlayCanvas();let F=q.debugOverlayCanvas,J=q.context.gl,Q=q.debugOverlayCanvas.getContext("2d");Q.clearRect(0,0,F.width,F.height),Q.shadowColor="white",Q.shadowBlur=2,Q.lineWidth=1.5,Q.strokeStyle="white",Q.textBaseline="top",Q.font="bold 36px Open Sans, sans-serif",Q.fillText(G,5,5),Q.strokeText(G,5,5),q.debugOverlayTexture.update(F),q.debugOverlayTexture.bind(J.LINEAR,J.CLAMP_TO_EDGE)})(h,`${$} ${L}kB`),m.draw(o,a.TRIANGLES,_,y,Ut.alphaBlended,bt.disabled,ms(c,p.aM.transparent,V),null,S,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),m.draw(o,a.LINE_STRIP,_,y,b,bt.disabled,ms(c,p.aM.red),T,S,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function vl(h,e,n){let o=h.context,a=o.gl,c=h.colorModeForRenderPass(),m=new nt(a.LEQUAL,nt.ReadWrite,h.depthRangeFor3D),_=h.useProgram("terrain"),y=e.getTerrainMesh();o.bindFramebuffer.set(null),o.viewport.set([0,0,h.width,h.height]);for(let b of n){let S=h.renderToTexture.getTexture(b),T=e.getTerrainData(b.tileID);o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,S.texture);let E=h.transform.calculatePosMatrix(b.tileID.toUnwrapped()),L=e.getMeshFrameDelta(h.transform.zoom),B=h.transform.calculateFogMatrix(b.tileID.toUnwrapped()),V=$o(E,L,B,h.style.sky,h.transform.pitch);_.draw(o,a.TRIANGLES,m,It.disabled,c,bt.backCCW,V,T,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}class ro{constructor(e,n,o){this.vertexBuffer=e,this.indexBuffer=n,this.segments=o}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class no{constructor(e,n){this.context=new Cc(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:p.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=qe.maxUnderzooming+qe.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Uo}resize(e,n,o){if(this.width=Math.floor(e*o),this.height=Math.floor(n*o),this.pixelRatio=o,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let a of this.style._order)this.style._layers[a].resize()}setup(){let e=this.context,n=new p.aX;n.emplaceBack(0,0),n.emplaceBack(p.X,0),n.emplaceBack(0,p.X),n.emplaceBack(p.X,p.X),this.tileExtentBuffer=e.createVertexBuffer(n,rn.members),this.tileExtentSegments=p.a0.simpleSegment(0,0,4,2);let o=new p.aX;o.emplaceBack(0,0),o.emplaceBack(p.X,0),o.emplaceBack(0,p.X),o.emplaceBack(p.X,p.X),this.debugBuffer=e.createVertexBuffer(o,rn.members),this.debugSegments=p.a0.simpleSegment(0,0,4,5);let a=new p.$;a.emplaceBack(0,0,0,0),a.emplaceBack(p.X,0,p.X,0),a.emplaceBack(0,p.X,0,p.X),a.emplaceBack(p.X,p.X,p.X,p.X),this.rasterBoundsBuffer=e.createVertexBuffer(a,Ur.members),this.rasterBoundsSegments=p.a0.simpleSegment(0,0,4,2);let c=new p.aX;c.emplaceBack(0,0),c.emplaceBack(1,0),c.emplaceBack(0,1),c.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(c,rn.members),this.viewportSegments=p.a0.simpleSegment(0,0,4,2);let m=new p.aZ;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(m);let _=new p.aY;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(_);let y=this.context.gl;this.stencilClearMode=new It({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){let e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let o=p.H();p.aP(o,0,this.width,this.height,0,0,1),p.K(o,o,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(e,n.TRIANGLES,nt.disabled,this.stencilClearMode,Ut.disabled,bt.disabled,Ci(o),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,n){if(this.currentStencilSource===e.source||!e.isTileClipped()||!n||!n.length)return;this.currentStencilSource=e.source;let o=this.context,a=o.gl;this.nextStencilID+n.length>256&&this.clearStencil(),o.setColorMode(Ut.disabled),o.setDepthMode(nt.disabled);let c=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(let m of n){let _=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);c.draw(o,a.TRIANGLES,nt.disabled,new It({func:a.ALWAYS,mask:0},_,255,a.KEEP,a.KEEP,a.REPLACE),Ut.disabled,bt.disabled,Ci(m.posMatrix),y,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,n=this.context.gl;return new It({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){let n=this.context.gl;return new It({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(e){let n=this.context.gl,o=e.sort(((m,_)=>_.overscaledZ-m.overscaledZ)),a=o[o.length-1].overscaledZ,c=o[0].overscaledZ-a+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();let m={};for(let _=0;_<c;_++)m[_+a]=new It({func:n.GEQUAL,mask:255},_+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=c,[m,o]}return[{[a]:It.disabled},o]}colorModeForRenderPass(){let e=this.context.gl;return this._showOverdrawInspector?new Ut([e.CONSTANT_COLOR,e.ONE],new p.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?Ut.unblended:Ut.alphaBlended}depthModeForSublayer(e,n,o){if(!this.opaquePassEnabledForLayer())return nt.disabled;let a=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new nt(o||this.context.gl.LEQUAL,n,[a,a])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,n){this.style=e,this.options=n,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(pe.now()),this.imageManager.beginFrame();let o=this.style._order,a=this.style.sourceCaches,c={},m={},_={};for(let y in a){let b=a[y];b.used&&b.prepare(this.context),c[y]=b.getVisibleCoordinates(),m[y]=c[y].slice().reverse(),_[y]=b.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let y=0;y<o.length;y++)if(this.style._layers[o[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(let y of o){let b=this.style._layers[y];if(!b.hasOffscreenPass()||b.isHidden(this.transform.zoom))continue;let S=m[b.source];(b.type==="custom"||S.length)&&this.renderLayer(this,a[b.source],b,S)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?p.aM.black:p.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&(function(y,b){let S=y.context,T=S.gl,E=((q,G,F)=>({u_sky_color:q.properties.get("sky-color"),u_horizon_color:q.properties.get("horizon-color"),u_horizon:(G.height/2+G.getHorizon())*F,u_sky_horizon_blend:q.properties.get("sky-horizon-blend")*G.height/2*F}))(b,y.style.map.transform,y.pixelRatio),L=new nt(T.LEQUAL,nt.ReadWrite,[0,1]),B=It.disabled,V=y.colorModeForRenderPass(),$=y.useProgram("sky");if(!b.mesh){let q=new p.aX;q.emplaceBack(-1,-1),q.emplaceBack(1,-1),q.emplaceBack(1,1),q.emplaceBack(-1,1);let G=new p.aY;G.emplaceBack(0,1,2),G.emplaceBack(0,2,3),b.mesh=new ro(S.createVertexBuffer(q,rn.members),S.createIndexBuffer(G),p.a0.simpleSegment(0,0,q.length,G.length))}$.draw(S,T.TRIANGLES,L,B,V,bt.disabled,E,void 0,"sky",b.mesh.vertexBuffer,b.mesh.indexBuffer,b.mesh.segments)})(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){let y=this.style._layers[o[this.currentLayer]],b=a[y.source],S=c[y.source];this._renderTileClippingMasks(y,S),this.renderLayer(this,b,y,S)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<o.length;this.currentLayer++){let y=this.style._layers[o[this.currentLayer]],b=a[y.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(y))continue;let S=(y.type==="symbol"?_:m)[y.source];this._renderTileClippingMasks(y,c[y.source]),this.renderLayer(this,b,y,S)}if(this.options.showTileBoundaries){let y=(function(b,S){let T=null,E=Object.values(b._layers).flatMap(($=>$.source&&!$.isHidden(S)?[b.sourceCaches[$.source]]:[])),L=E.filter(($=>$.getSource().type==="vector")),B=E.filter(($=>$.getSource().type!=="vector")),V=$=>{(!T||T.getSource().maxzoom<$.getSource().maxzoom)&&(T=$)};return L.forEach(($=>V($))),T||B.forEach(($=>V($))),T})(this.style,this.transform.zoom);y&&(function(b,S,T){for(let E=0;E<T.length;E++)xl(b,S,T[E])})(this,y,y.getVisibleCoordinates())}this.options.showPadding&&(function(y){let b=y.transform.padding;Ln(y,y.transform.height-(b.top||0),3,oa),Ln(y,b.bottom||0,3,pt),yl(y,b.left||0,3,to),yl(y,y.transform.width-(b.right||0),3,Pc);let S=y.transform.centerPoint;(function(T,E,L,B){io(T,E-1,L-10,2,20,B),io(T,E-10,L-1,20,2,B)})(y,S.x,y.transform.height-S.y,_l)})(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;let n=this.terrainFacilitator.matrix,o=this.transform.modelViewProjectionMatrix,a=this.terrainFacilitator.dirty;a||(a=e?!p.a_(n,o):!p.a$(n,o)),a||(a=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),a&&(p.b0(n,o),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(c,m){let _=c.context,y=_.gl,b=Ut.unblended,S=new nt(y.LEQUAL,nt.ReadWrite,[0,1]),T=m.getTerrainMesh(),E=m.sourceCache.getRenderableTiles(),L=c.useProgram("terrainDepth");_.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:p.aM.transparent,depth:1});for(let B of E){let V=m.getTerrainData(B.tileID),$={u_matrix:c.transform.calculatePosMatrix(B.tileID.toUnwrapped()),u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};L.draw(_,y.TRIANGLES,S,It.disabled,b,bt.backCCW,$,V,"terrain",T.vertexBuffer,T.indexBuffer,T.segments)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])})(this,this.style.map.terrain),(function(c,m){let _=c.context,y=_.gl,b=Ut.unblended,S=new nt(y.LEQUAL,nt.ReadWrite,[0,1]),T=m.getTerrainMesh(),E=m.getCoordsTexture(),L=m.sourceCache.getRenderableTiles(),B=c.useProgram("terrainCoords");_.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:p.aM.transparent,depth:1}),m.coordsIndex=[];for(let V of L){let $=m.getTerrainData(V.tileID);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,E.texture);let q={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(_,y.TRIANGLES,S,It.disabled,b,bt.backCCW,q,$,"terrain",T.vertexBuffer,T.indexBuffer,T.segments),m.coordsIndex.push(V.tileID.key)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])})(this,this.style.map.terrain))}renderLayer(e,n,o,a){if(!o.isHidden(this.transform.zoom)&&(o.type==="background"||o.type==="custom"||(a||[]).length))switch(this.id=o.id,o.type){case"symbol":(function(c,m,_,y,b){if(c.renderPass!=="translucent")return;let S=It.disabled,T=c.colorModeForRenderPass();(_._unevaluatedLayout.hasValue("text-variable-anchor")||_._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(E,L,B,V,$,q,G,F,J){let Q=L.transform,ne=tn(),ue=$==="map",me=q==="map";for(let Te of E){let Ae=V.getTile(Te),xe=Ae.getBucket(B);if(!xe||!xe.text||!xe.text.segments.get().length)continue;let ye=p.ag(xe.textSizeData,Q.zoom),Re=ot(Ae,1,L.transform.zoom),We=$r(Te.posMatrix,me,ue,L.transform,Re),be=B.layout.get("icon-text-fit")!=="none"&&xe.hasIconData();if(ye){let Pe=Math.pow(2,Q.zoom-Ae.tileID.overscaledZ),Ze=L.style.map.terrain?(Qe,at)=>L.style.map.terrain.getElevation(Te,Qe,at):null,Et=ne.translatePosition(Q,Ae,G,F);An(xe,ue,me,J,Q,We,Te.posMatrix,Pe,ye,be,ne,Et,Te.toUnwrapped(),Ze)}}})(y,c,_,m,_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),b),_.paint.get("icon-opacity").constantOr(1)!==0&&ra(c,m,_,y,!1,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),_.layout.get("icon-rotation-alignment"),_.layout.get("icon-pitch-alignment"),_.layout.get("icon-keep-upright"),S,T),_.paint.get("text-opacity").constantOr(1)!==0&&ra(c,m,_,y,!0,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.layout.get("text-keep-upright"),S,T),m.map.showCollisionBoxes&&(ys(c,m,_,y,!0),ys(c,m,_,y,!1))})(e,n,o,a,this.style.placement.variableOffsets);break;case"circle":(function(c,m,_,y){if(c.renderPass!=="translucent")return;let b=_.paint.get("circle-opacity"),S=_.paint.get("circle-stroke-width"),T=_.paint.get("circle-stroke-opacity"),E=!_.layout.get("circle-sort-key").isConstant();if(b.constantOr(1)===0&&(S.constantOr(1)===0||T.constantOr(1)===0))return;let L=c.context,B=L.gl,V=c.depthModeForSublayer(0,nt.ReadOnly),$=It.disabled,q=c.colorModeForRenderPass(),G=[];for(let F=0;F<y.length;F++){let J=y[F],Q=m.getTile(J),ne=Q.getBucket(_);if(!ne)continue;let ue=ne.programConfigurations.get(_.id),me=c.useProgram("circle",ue),Te=ne.layoutVertexBuffer,Ae=ne.indexBuffer,xe=c.style.map.terrain&&c.style.map.terrain.getTerrainData(J),ye={programConfiguration:ue,program:me,layoutVertexBuffer:Te,indexBuffer:Ae,uniformValues:pc(c,J,Q,_),terrainData:xe};if(E){let Re=ne.segments.get();for(let We of Re)G.push({segments:new p.a0([We]),sortKey:We.sortKey,state:ye})}else G.push({segments:ne.segments,sortKey:0,state:ye})}E&&G.sort(((F,J)=>F.sortKey-J.sortKey));for(let F of G){let{programConfiguration:J,program:Q,layoutVertexBuffer:ne,indexBuffer:ue,uniformValues:me,terrainData:Te}=F.state;Q.draw(L,B.TRIANGLES,V,$,q,bt.disabled,me,Te,_.id,ne,ue,F.segments,_.paint,c.transform.zoom,J)}})(e,n,o,a);break;case"heatmap":(function(c,m,_,y){if(_.paint.get("heatmap-opacity")===0)return;let b=c.context;if(c.style.map.terrain){for(let S of y){let T=m.getTile(S);m.hasRenderableParent(S)||(c.renderPass==="offscreen"?sa(c,T,_,S):c.renderPass==="translucent"&&hn(c,_,S))}b.viewport.set([0,0,c.width,c.height])}else c.renderPass==="offscreen"?(function(S,T,E,L){let B=S.context,V=B.gl,$=It.disabled,q=new Ut([V.ONE,V.ONE],p.aM.transparent,[!0,!0,!0,!0]);(function(G,F,J){let Q=G.gl;G.activeTexture.set(Q.TEXTURE1),G.viewport.set([0,0,F.width/4,F.height/4]);let ne=J.heatmapFbos.get(p.aU);ne?(Q.bindTexture(Q.TEXTURE_2D,ne.colorAttachment.get()),G.bindFramebuffer.set(ne.framebuffer)):(ne=vs(G,F.width/4,F.height/4),J.heatmapFbos.set(p.aU,ne))})(B,S,E),B.clear({color:p.aM.transparent});for(let G=0;G<L.length;G++){let F=L[G];if(T.hasRenderableParent(F))continue;let J=T.getTile(F),Q=J.getBucket(E);if(!Q)continue;let ne=Q.programConfigurations.get(E.id),ue=S.useProgram("heatmap",ne),{zoom:me}=S.transform;ue.draw(B,V.TRIANGLES,nt.disabled,$,q,bt.disabled,Pi(F.posMatrix,J,me,E.paint.get("heatmap-intensity")),null,E.id,Q.layoutVertexBuffer,Q.indexBuffer,Q.segments,E.paint,S.transform.zoom,ne)}B.viewport.set([0,0,S.width,S.height])})(c,m,_,y):c.renderPass==="translucent"&&(function(S,T){let E=S.context,L=E.gl;E.setColorMode(S.colorModeForRenderPass());let B=T.heatmapFbos.get(p.aU);B&&(E.activeTexture.set(L.TEXTURE0),L.bindTexture(L.TEXTURE_2D,B.colorAttachment.get()),E.activeTexture.set(L.TEXTURE1),bs(E,T).bind(L.LINEAR,L.CLAMP_TO_EDGE),S.useProgram("heatmapTexture").draw(E,L.TRIANGLES,nt.disabled,It.disabled,S.colorModeForRenderPass(),bt.disabled,Zs(S,T,0,1),null,T.id,S.viewportBuffer,S.quadTriangleIndexBuffer,S.viewportSegments,T.paint,S.transform.zoom))})(c,_)})(e,n,o,a);break;case"line":(function(c,m,_,y){if(c.renderPass!=="translucent")return;let b=_.paint.get("line-opacity"),S=_.paint.get("line-width");if(b.constantOr(1)===0||S.constantOr(1)===0)return;let T=c.depthModeForSublayer(0,nt.ReadOnly),E=c.colorModeForRenderPass(),L=_.paint.get("line-dasharray"),B=_.paint.get("line-pattern"),V=B.constantOr(1),$=_.paint.get("line-gradient"),q=_.getCrossfadeParameters(),G=V?"linePattern":L?"lineSDF":$?"lineGradient":"line",F=c.context,J=F.gl,Q=!0;for(let ne of y){let ue=m.getTile(ne);if(V&&!ue.patternsLoaded())continue;let me=ue.getBucket(_);if(!me)continue;let Te=me.programConfigurations.get(_.id),Ae=c.context.program.get(),xe=c.useProgram(G,Te),ye=Q||xe.program!==Ae,Re=c.style.map.terrain&&c.style.map.terrain.getTerrainData(ne),We=B.constantOr(null);if(We&&ue.imageAtlas){let Ze=ue.imageAtlas,Et=Ze.patternPositions[We.to.toString()],Qe=Ze.patternPositions[We.from.toString()];Et&&Qe&&Te.setConstantPatternPositions(Et,Qe)}let be=Re?ne:null,Pe=V?Pn(c,ue,_,q,be):L?fc(c,ue,_,L,q,be):$?el(c,ue,_,me.lineClipsArray.length,be):Hs(c,ue,_,be);if(V)F.activeTexture.set(J.TEXTURE0),ue.imageAtlasTexture.bind(J.LINEAR,J.CLAMP_TO_EDGE),Te.updatePaintBuffers(q);else if(L&&(ye||c.lineAtlas.dirty))F.activeTexture.set(J.TEXTURE0),c.lineAtlas.bind(F);else if($){let Ze=me.gradients[_.id],Et=Ze.texture;if(_.gradientVersion!==Ze.version){let Qe=256;if(_.stepInterpolant){let at=m.getSource().maxzoom,kt=ne.canonical.z===at?Math.ceil(1<<c.transform.maxZoom-ne.canonical.z):1;Qe=p.ac(p.aV(me.maxLineLength/p.X*1024*kt),256,F.maxTextureSize)}Ze.gradient=p.aW({expression:_.gradientExpression(),evaluationKey:"lineProgress",resolution:Qe,image:Ze.gradient||void 0,clips:me.lineClipsArray}),Ze.texture?Ze.texture.update(Ze.gradient):Ze.texture=new Ye(F,Ze.gradient,J.RGBA),Ze.version=_.gradientVersion,Et=Ze.texture}F.activeTexture.set(J.TEXTURE0),Et.bind(_.stepInterpolant?J.NEAREST:J.LINEAR,J.CLAMP_TO_EDGE)}xe.draw(F,J.TRIANGLES,T,c.stencilModeForClipping(ne),E,bt.disabled,Pe,Re,_.id,me.layoutVertexBuffer,me.indexBuffer,me.segments,_.paint,c.transform.zoom,Te,me.layoutVertexBuffer2),Q=!1}})(e,n,o,a);break;case"fill":(function(c,m,_,y){let b=_.paint.get("fill-color"),S=_.paint.get("fill-opacity");if(S.constantOr(1)===0)return;let T=c.colorModeForRenderPass(),E=_.paint.get("fill-pattern"),L=c.opaquePassEnabledForLayer()&&!E.constantOr(1)&&b.constantOr(p.aM.transparent).a===1&&S.constantOr(0)===1?"opaque":"translucent";if(c.renderPass===L){let B=c.depthModeForSublayer(1,c.renderPass==="opaque"?nt.ReadWrite:nt.ReadOnly);ws(c,m,_,y,B,T,!1)}if(c.renderPass==="translucent"&&_.paint.get("fill-antialias")){let B=c.depthModeForSublayer(_.getPaintProperty("fill-outline-color")?2:0,nt.ReadOnly);ws(c,m,_,y,B,T,!0)}})(e,n,o,a);break;case"fill-extrusion":(function(c,m,_,y){let b=_.paint.get("fill-extrusion-opacity");if(b!==0&&c.renderPass==="translucent"){let S=new nt(c.context.gl.LEQUAL,nt.ReadWrite,c.depthRangeFor3D);if(b!==1||_.paint.get("fill-extrusion-pattern").constantOr(1))eo(c,m,_,y,S,It.disabled,Ut.disabled),eo(c,m,_,y,S,c.stencilModeFor3D(),c.colorModeForRenderPass());else{let T=c.colorModeForRenderPass();eo(c,m,_,y,S,It.disabled,T)}}})(e,n,o,a);break;case"hillshade":(function(c,m,_,y){if(c.renderPass!=="offscreen"&&c.renderPass!=="translucent")return;let b=c.context,S=c.depthModeForSublayer(0,nt.ReadOnly),T=c.colorModeForRenderPass(),[E,L]=c.renderPass==="translucent"?c.stencilConfigForOverlap(y):[{},y];for(let B of L){let V=m.getTile(B);V.needsHillshadePrepare!==void 0&&V.needsHillshadePrepare&&c.renderPass==="offscreen"?zn(c,V,_,S,It.disabled,T):c.renderPass==="translucent"&&kn(c,B,V,_,S,E[B.overscaledZ],T)}b.viewport.set([0,0,c.width,c.height])})(e,n,o,a);break;case"raster":(function(c,m,_,y){if(c.renderPass!=="translucent"||_.paint.get("raster-opacity")===0||!y.length)return;let b=c.context,S=b.gl,T=m.getSource(),E=c.useProgram("raster"),L=c.colorModeForRenderPass(),[B,V]=T instanceof kr?[{},y]:c.stencilConfigForOverlap(y),$=V[V.length-1].overscaledZ,q=!c.options.moving;for(let G of V){let F=c.depthModeForSublayer(G.overscaledZ-$,_.paint.get("raster-opacity")===1?nt.ReadWrite:nt.ReadOnly,S.LESS),J=m.getTile(G);J.registerFadeDuration(_.paint.get("raster-fade-duration"));let Q=m.findLoadedParent(G,0),ne=m.findLoadedSibling(G),ue=gl(J,Q||ne||null,m,_,c.transform,c.style.map.terrain),me,Te,Ae=_.paint.get("raster-resampling")==="nearest"?S.NEAREST:S.LINEAR;b.activeTexture.set(S.TEXTURE0),J.texture.bind(Ae,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),b.activeTexture.set(S.TEXTURE1),Q?(Q.texture.bind(Ae,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),me=Math.pow(2,Q.tileID.overscaledZ-J.tileID.overscaledZ),Te=[J.tileID.canonical.x*me%1,J.tileID.canonical.y*me%1]):J.texture.bind(Ae,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),J.texture.useMipmap&&b.extTextureFilterAnisotropic&&c.transform.pitch>20&&S.texParameterf(S.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);let xe=c.style.map.terrain&&c.style.map.terrain.getTerrainData(G),ye=xe?G:null,Re=ye?ye.posMatrix:c.transform.calculatePosMatrix(G.toUnwrapped(),q),We=mc(Re,Te||[0,0],me||1,ue,_);T instanceof kr?E.draw(b,S.TRIANGLES,F,It.disabled,L,bt.disabled,We,xe,_.id,T.boundsBuffer,c.quadTriangleIndexBuffer,T.boundsSegments):E.draw(b,S.TRIANGLES,F,B[G.overscaledZ],L,bt.disabled,We,xe,_.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments)}})(e,n,o,a);break;case"background":(function(c,m,_,y){let b=_.paint.get("background-color"),S=_.paint.get("background-opacity");if(S===0)return;let T=c.context,E=T.gl,L=c.transform,B=L.tileSize,V=_.paint.get("background-pattern");if(c.isPatternMissing(V))return;let $=!V&&b.a===1&&S===1&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==$)return;let q=It.disabled,G=c.depthModeForSublayer(0,$==="opaque"?nt.ReadWrite:nt.ReadOnly),F=c.colorModeForRenderPass(),J=c.useProgram(V?"backgroundPattern":"background"),Q=y||L.coveringTiles({tileSize:B,terrain:c.style.map.terrain});V&&(T.activeTexture.set(E.TEXTURE0),c.imageManager.bind(c.context));let ne=_.getCrossfadeParameters();for(let ue of Q){let me=y?ue.posMatrix:c.transform.calculatePosMatrix(ue.toUnwrapped()),Te=V?Go(me,S,c,V,{tileID:ue,tileSize:B},ne):Ws(me,S,b),Ae=c.style.map.terrain&&c.style.map.terrain.getTerrainData(ue);J.draw(T,E.TRIANGLES,G,q,F,bt.disabled,Te,Ae,_.id,c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}})(e,0,o,a);break;case"custom":(function(c,m,_){let y=c.context,b=_.implementation;if(c.renderPass==="offscreen"){let S=b.prerender;S&&(c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),S.call(b,y.gl,c.transform.customLayerMatrix()),y.setDirty(),c.setBaseState())}else if(c.renderPass==="translucent"){c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),y.setStencilMode(It.disabled);let S=b.renderingMode==="3d"?new nt(c.context.gl.LEQUAL,nt.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,nt.ReadOnly);y.setDepthMode(S),b.render(y.gl,c.transform.customLayerMatrix(),{farZ:c.transform.farZ,nearZ:c.transform.nearZ,fov:c.transform._fov,modelViewProjectionMatrix:c.transform.modelViewProjectionMatrix,projectionMatrix:c.transform.projectionMatrix}),y.setDirty(),c.setBaseState(),y.bindFramebuffer.set(null)}})(e,0,o)}}translatePosMatrix(e,n,o,a,c){if(!o[0]&&!o[1])return e;let m=c?a==="map"?this.transform.angle:0:a==="viewport"?-this.transform.angle:0;if(m){let b=Math.sin(m),S=Math.cos(m);o=[o[0]*S-o[1]*b,o[0]*b+o[1]*S]}let _=[c?o[0]:ot(n,o[0],this.transform.zoom),c?o[1]:ot(n,o[1],this.transform.zoom),0],y=new Float32Array(16);return p.J(y,e,_),y}saveTileTexture(e){let n=this._tileTextures[e.size[0]];n?n.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){let n=this._tileTextures[e];return n&&n.length>0?n.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let n=this.imageManager.getPattern(e.from.toString()),o=this.imageManager.getPattern(e.to.toString());return!n||!o}useProgram(e,n){this.cache=this.cache||{};let o=e+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[o]||(this.cache[o]=new qo(this.context,qr[e],n,Ho[e],this._showOverdrawInspector,this.style.map.terrain)),this.cache[o]}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(){let e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Ye(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:n}=this.context.gl;return this.width!==e||this.height!==n}}class Dn{constructor(e,n){this.points=e,this.planes=n}static fromInvProjectionMatrix(e,n,o){let a=Math.pow(2,o),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((_=>{let y=1/(_=p.af([],_,e))[3]/n*a;return p.b1(_,_,[y,y,1/_[3],y])})),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((_=>{let y=(function(E,L){var B=L[0],V=L[1],$=L[2],q=B*B+V*V+$*$;return q>0&&(q=1/Math.sqrt(q)),E[0]=L[0]*q,E[1]=L[1]*q,E[2]=L[2]*q,E})([],(function(E,L,B){var V=L[0],$=L[1],q=L[2],G=B[0],F=B[1],J=B[2];return E[0]=$*J-q*F,E[1]=q*G-V*J,E[2]=V*F-$*G,E})([],Mt([],c[_[0]],c[_[1]]),Mt([],c[_[2]],c[_[1]]))),b=-((S=y)[0]*(T=c[_[1]])[0]+S[1]*T[1]+S[2]*T[2]);var S,T;return y.concat(b)}));return new Dn(c,m)}}class Rn{constructor(e,n){this.min=e,this.max=n,this.center=(function(o,a,c){return o[0]=.5*a[0],o[1]=.5*a[1],o[2]=.5*a[2],o})([],(function(o,a,c){return o[0]=a[0]+c[0],o[1]=a[1]+c[1],o[2]=a[2]+c[2],o})([],this.min,this.max))}quadrant(e){let n=[e%2==0,e<2],o=Je(this.min),a=Je(this.max);for(let c=0;c<n.length;c++)o[c]=n[c]?this.min[c]:this.center[c],a[c]=n[c]?this.center[c]:this.max[c];return a[2]=this.max[2],new Rn(o,a)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersects(e){let n=[[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]],o=!0;for(let a=0;a<e.planes.length;a++){let c=e.planes[a],m=0;for(let _=0;_<n.length;_++)p.b2(c,n[_])>=0&&m++;if(m===0)return 0;m!==n.length&&(o=!1)}if(o)return 2;for(let a=0;a<3;a++){let c=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let _=0;_<e.points.length;_++){let y=e.points[_][a]-this.min[a];c=Math.min(c,y),m=Math.max(m,y)}if(m<0||c>this.max[a]-this.min[a])return 0}return 1}}class Bn{constructor(e=0,n=0,o=0,a=0){if(isNaN(e)||e<0||isNaN(n)||n<0||isNaN(o)||o<0||isNaN(a)||a<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=n,this.left=o,this.right=a}interpolate(e,n,o){return n.top!=null&&e.top!=null&&(this.top=p.y.number(e.top,n.top,o)),n.bottom!=null&&e.bottom!=null&&(this.bottom=p.y.number(e.bottom,n.bottom,o)),n.left!=null&&e.left!=null&&(this.left=p.y.number(e.left,n.left,o)),n.right!=null&&e.right!=null&&(this.right=p.y.number(e.right,n.right,o)),this}getCenter(e,n){let o=p.ac((this.left+e-this.right)/2,0,e),a=p.ac((this.top+n-this.bottom)/2,0,n);return new p.P(o,a)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Bn(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}let aa=85.051129;class Fn{constructor(e,n,o,a,c){this.tileSize=512,this._renderWorldCopies=c===void 0||!!c,this._minZoom=e||0,this._maxZoom=n||22,this._minPitch=o??0,this._maxPitch=a??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 Bn,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){let e=new Fn(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return e.apply(this),e}apply(e){this.tileSize=e.tileSize,this.latRange=e.latRange,this.lngRange=e.lngRange,this.width=e.width,this.height=e.height,this._center=e._center,this._elevation=e._elevation,this.minElevationForCurrentTile=e.minElevationForCurrentTile,this.zoom=e.zoom,this.angle=e.angle,this._fov=e._fov,this._pitch=e._pitch,this._unmodified=e._unmodified,this._edgeInsets=e._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new p.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(e){let n=-p.b3(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=(function(){var o=new p.A(4);return p.A!=Float32Array&&(o[1]=0,o[2]=0),o[0]=1,o[3]=1,o})(),(function(o,a,c){var m=a[0],_=a[1],y=a[2],b=a[3],S=Math.sin(c),T=Math.cos(c);o[0]=m*T+y*S,o[1]=_*T+b*S,o[2]=m*-S+y*T,o[3]=_*-S+b*T})(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){let n=p.ac(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(e){let n=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,n,o){this._unmodified=!1,this._edgeInsets.interpolate(e,n,o),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){let n=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(e){let n=[new p.b4(0,e)];if(this._renderWorldCopies){let o=this.pointCoordinate(new p.P(0,0)),a=this.pointCoordinate(new p.P(this.width,0)),c=this.pointCoordinate(new p.P(this.width,this.height)),m=this.pointCoordinate(new p.P(0,this.height)),_=Math.floor(Math.min(o.x,a.x,c.x,m.x)),y=Math.floor(Math.max(o.x,a.x,c.x,m.x)),b=1;for(let S=_-b;S<=y+b;S++)S!==0&&n.push(new p.b4(S,e))}return n}coveringTiles(e){var n,o;let a=this.coveringZoomLevel(e),c=a;if(e.minzoom!==void 0&&a<e.minzoom)return[];e.maxzoom!==void 0&&a>e.maxzoom&&(a=e.maxzoom);let m=this.pointCoordinate(this.getCameraPoint()),_=p.Z.fromLngLat(this.center),y=Math.pow(2,a),b=[y*m.x,y*m.y,0],S=[y*_.x,y*_.y,0],T=Dn.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,a),E=e.minzoom||0;!e.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(E=a);let L=e.terrain?2/Math.min(this.tileSize,e.tileSize)*this.tileSize:3,B=F=>({aabb:new Rn([F*y,0,0],[(F+1)*y,y,0]),zoom:0,x:0,y:0,wrap:F,fullyVisible:!1}),V=[],$=[],q=a,G=e.reparseOverscaled?c:a;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;){let F=V.pop(),J=F.x,Q=F.y,ne=F.fullyVisible;if(!ne){let xe=F.aabb.intersects(T);if(xe===0)continue;ne=xe===2}let ue=e.terrain?b:S,me=F.aabb.distanceX(ue),Te=F.aabb.distanceY(ue),Ae=Math.max(Math.abs(me),Math.abs(Te));if(F.zoom===q||Ae>L+(1<<q-F.zoom)-2&&F.zoom>=E){let xe=q-F.zoom,ye=b[0]-.5-(J<<xe),Re=b[1]-.5-(Q<<xe);$.push({tileID:new p.S(F.zoom===q?G:F.zoom,F.wrap,F.zoom,J,Q),distanceSq:Vt([S[0]-.5-J,S[1]-.5-Q]),tileDistanceToCamera:Math.sqrt(ye*ye+Re*Re)})}else for(let xe=0;xe<4;xe++){let ye=(J<<1)+xe%2,Re=(Q<<1)+(xe>>1),We=F.zoom+1,be=F.aabb.quadrant(xe);if(e.terrain){let Pe=new p.S(We,F.wrap,We,ye,Re),Ze=e.terrain.getMinMaxElevation(Pe),Et=(n=Ze.minElevation)!==null&&n!==void 0?n:this.elevation,Qe=(o=Ze.maxElevation)!==null&&o!==void 0?o:this.elevation;be=new Rn([be.min[0],be.min[1],Et],[be.max[0],be.max[1],Qe])}V.push({aabb:be,zoom:We,x:ye,y:Re,wrap:F.wrap,fullyVisible:ne})}}return $.sort(((F,J)=>F.distanceSq-J.distanceSq)).map((F=>F.tileID))}resize(e,n){this.width=e,this.height=n,this.pixelsToGLUnits=[2/e,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){let n=p.ac(e.lat,-85.051129,aa);return new p.P(p.O(e.lng)*this.worldSize,p.Q(n)*this.worldSize)}unproject(e){return new p.Z(e.x/this.worldSize,e.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(e){let n=this.elevation,o=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,a=this.pointLocation(this.centerPoint,e),c=e.getElevationForLngLatZoom(a,this.tileZoom);if(!(this.elevation-c))return;let m=o+n-c,_=Math.cos(this._pitch)*this.cameraToCenterDistance/m/p.b5(1,a.lat),y=this.scaleZoom(_/this.tileSize);this._elevation=c,this._center=a,this.zoom=y}setLocationAtPoint(e,n){let o=this.pointCoordinate(n),a=this.pointCoordinate(this.centerPoint),c=this.locationCoordinate(e),m=new p.Z(c.x-(o.x-a.x),c.y-(o.y-a.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(e,n){return n?this.coordinatePoint(this.locationCoordinate(e),n.getElevationForLngLatZoom(e,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(e))}pointLocation(e,n){return this.coordinateLocation(this.pointCoordinate(e,n))}locationCoordinate(e){return p.Z.fromLngLat(e)}coordinateLocation(e){return e&&e.toLngLat()}pointCoordinate(e,n){if(n){let E=n.pointCoordinate(e);if(E!=null)return E}let o=[e.x,e.y,0,1],a=[e.x,e.y,1,1];p.af(o,o,this.pixelMatrixInverse),p.af(a,a,this.pixelMatrixInverse);let c=o[3],m=a[3],_=o[1]/c,y=a[1]/m,b=o[2]/c,S=a[2]/m,T=b===S?0:(0-b)/(S-b);return new p.Z(p.y.number(o[0]/c,a[0]/m,T)/this.worldSize,p.y.number(_,y,T)/this.worldSize)}coordinatePoint(e,n=0,o=this.pixelMatrix){let a=[e.x*this.worldSize,e.y*this.worldSize,n,1];return p.af(a,a,o),new p.P(a[0]/a[3],a[1]/a[3])}getBounds(){let e=Math.max(0,this.height/2-this.getHorizon());return new oe().extend(this.pointLocation(new p.P(0,e))).extend(this.pointLocation(new p.P(this.width,e))).extend(this.pointLocation(new p.P(this.width,this.height))).extend(this.pointLocation(new p.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new oe([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(e){e?(this.lngRange=[e.getWest(),e.getEast()],this.latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,aa])}calculateTileMatrix(e){let n=e.canonical,o=this.worldSize/this.zoomScale(n.z),a=n.x+Math.pow(2,n.z)*e.wrap,c=p.an(new Float64Array(16));return p.J(c,c,[a*o,n.y*o,0]),p.K(c,c,[o/p.X,o/p.X,1]),c}calculatePosMatrix(e,n=!1){let o=e.key,a=n?this._alignedPosMatrixCache:this._posMatrixCache;if(a[o])return a[o];let c=this.calculateTileMatrix(e);return p.L(c,n?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,c),a[o]=new Float32Array(c),a[o]}calculateFogMatrix(e){let n=e.key,o=this._fogMatrixCache;if(o[n])return o[n];let a=this.calculateTileMatrix(e);return p.L(a,this.fogMatrix,a),o[n]=new Float32Array(a),o[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(e,n){n=p.ac(+n,this.minZoom,this.maxZoom);let o={center:new p.N(e.lng,e.lat),zoom:n},a=this.lngRange;if(!this._renderWorldCopies&&a===null){let F=179.9999999999;a=[-F,F]}let c=this.tileSize*this.zoomScale(o.zoom),m=0,_=c,y=0,b=c,S=0,T=0,{x:E,y:L}=this.size;if(this.latRange){let F=this.latRange;m=p.Q(F[1])*c,_=p.Q(F[0])*c,_-m<L&&(S=L/(_-m))}a&&(y=p.b3(p.O(a[0])*c,0,c),b=p.b3(p.O(a[1])*c,0,c),b<y&&(b+=c),b-y<E&&(T=E/(b-y)));let{x:B,y:V}=this.project.call({worldSize:c},e),$,q,G=Math.max(T||0,S||0);if(G){let F=new p.P(T?(b+y)/2:B,S?(_+m)/2:V);return o.center=this.unproject.call({worldSize:c},F).wrap(),o.zoom+=this.scaleZoom(G),o}if(this.latRange){let F=L/2;V-F<m&&(q=m+F),V+F>_&&(q=_-F)}if(a){let F=(y+b)/2,J=B;this._renderWorldCopies&&(J=p.b3(B,F-c/2,F+c/2));let Q=E/2;J-Q<y&&($=y+Q),J+Q>b&&($=b-Q)}if($!==void 0||q!==void 0){let F=new p.P($??B,q??V);o.center=this.unproject.call({worldSize:c},F).wrap()}return o}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:n,zoom:o}=this.getConstrained(this.center,this.zoom);this.center=n,this.zoom=o,this._unmodified=e,this._constraining=!1}_calcMatrices(){if(!this.height)return;let e=this.centerOffset,n=this.point.x,o=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=p.b5(1,this.center.lat)*this.worldSize;let a=p.an(new Float64Array(16));p.K(a,a,[this.width/2,-this.height/2,1]),p.J(a,a,[1,-1,0]),this.labelPlaneMatrix=a,a=p.an(new Float64Array(16)),p.K(a,a,[1,-1,1]),p.J(a,a,[-1,-1,0]),p.K(a,a,[2/this.width,2/this.height,1]),this.glCoordMatrix=a;let c=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),m=Math.min(this.elevation,this.minElevationForCurrentTile),_=c-m*this._pixelPerMeter/Math.cos(this._pitch),y=m<0?_:c,b=Math.PI/2+this._pitch,S=this._fov*(.5+e.y/this.height),T=Math.sin(S)*y/Math.sin(p.ac(Math.PI-b-S,.01,Math.PI-.01)),E=this.getHorizon(),L=2*Math.atan(E/this.cameraToCenterDistance)*(.5+e.y/(2*E)),B=Math.sin(L)*y/Math.sin(p.ac(Math.PI-b-L,.01,Math.PI-.01)),V=Math.min(T,B);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*V+y),this.nearZ=this.height/50,a=new Float64Array(16),p.b6(a,this._fov,this.width/this.height,this.nearZ,this.farZ),a[8]=2*-e.x/this.width,a[9]=2*e.y/this.height,this.projectionMatrix=p.ae(a),p.K(a,a,[1,-1,1]),p.J(a,a,[0,0,-this.cameraToCenterDistance]),p.b7(a,a,this._pitch),p.ad(a,a,this.angle),p.J(a,a,[-n,-o,0]),this.mercatorMatrix=p.K([],a,[this.worldSize,this.worldSize,this.worldSize]),p.K(a,a,[1,1,this._pixelPerMeter]),this.pixelMatrix=p.L(new Float64Array(16),this.labelPlaneMatrix,a),p.J(a,a,[0,0,-this.elevation]),this.modelViewProjectionMatrix=a,this.invModelViewProjectionMatrix=p.as([],a),this.fogMatrix=new Float64Array(16),p.b6(this.fogMatrix,this._fov,this.width/this.height,c,this.farZ),this.fogMatrix[8]=2*-e.x/this.width,this.fogMatrix[9]=2*e.y/this.height,p.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),p.b7(this.fogMatrix,this.fogMatrix,this._pitch),p.ad(this.fogMatrix,this.fogMatrix,this.angle),p.J(this.fogMatrix,this.fogMatrix,[-n,-o,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,a);let $=this.width%2/2,q=this.height%2/2,G=Math.cos(this.angle),F=Math.sin(this.angle),J=n-Math.round(n)+G*$+F*q,Q=o-Math.round(o)+G*q+F*$,ne=new Float64Array(a);if(p.J(ne,ne,[J>.5?J-1:J,Q>.5?Q-1:Q,0]),this.alignedModelViewProjectionMatrix=ne,a=p.as(new Float64Array(16),this.pixelMatrix),!a)throw new Error("failed to invert matrix");this.pixelMatrixInverse=a,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;let e=this.pointCoordinate(new p.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return p.af(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){let e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new p.P(0,e))}getCameraQueryGeometry(e){let n=this.getCameraPoint();if(e.length===1)return[e[0],n];{let o=n.x,a=n.y,c=n.x,m=n.y;for(let _ of e)o=Math.min(o,_.x),a=Math.min(a,_.y),c=Math.max(c,_.x),m=Math.max(m,_.y);return[new p.P(o,a),new p.P(c,a),new p.P(c,m),new p.P(o,m),new p.P(o,a)]}}lngLatToCameraDepth(e,n){let o=this.locationCoordinate(e),a=[o.x*this.worldSize,o.y*this.worldSize,n,1];return p.af(a,a,this.modelViewProjectionMatrix),a[2]/a[3]}}function Ss(h,e){let n,o=!1,a=null,c=null,m=()=>{a=null,o&&(h.apply(c,n),a=setTimeout(m,e),o=!1)};return(..._)=>(o=!0,c=this,n=_,a||m(),a)}class so{constructor(e){this._getCurrentHash=()=>{let n=window.location.hash.replace("#","");if(this._hashName){let o;return n.split("&").map((a=>a.split("="))).forEach((a=>{a[0]===this._hashName&&(o=a)})),(o&&o[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{let n=this._getCurrentHash();if(n.length>=3&&!n.some((o=>isNaN(o)))){let o=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:o,pitch:+(n[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{let n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{let n=this._getCurrentHash();if(n.length===0)return;let o=n.join("/"),a=o;a.split("&").length>0&&(a=a.split("&")[0]),this._hashName&&(a=`${this._hashName}=${o}`);let c=window.location.hash.replace(a,"");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=Ss(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let n=this._map.getCenter(),o=Math.round(100*this._map.getZoom())/100,a=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,a),m=Math.round(n.lng*c)/c,_=Math.round(n.lat*c)/c,y=this._map.getBearing(),b=this._map.getPitch(),S="";if(S+=e?`/${m}/${_}/${o}`:`${o}/${_}/${m}`,(y||b)&&(S+="/"+Math.round(10*y)/10),b&&(S+=`/${Math.round(b)}`),this._hashName){let T=this._hashName,E=!1,L=window.location.hash.slice(1).split("&").map((B=>{let V=B.split("=")[0];return V===T?(E=!0,`${V}=${S}`):B})).filter((B=>B));return E||L.push(`${T}=${S}`),`#${L.join("&")}`}return`#${S}`}}let oo={linearity:.3,easing:p.b8(0,0,.3,1)},la=p.e({deceleration:2500,maxSpeed:1400},oo),Mc=p.e({deceleration:20,maxSpeed:1400},oo),bl=p.e({deceleration:1e3,maxSpeed:360},oo),ao=p.e({deceleration:1e3,maxSpeed:90},oo);class ca{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:pe.now(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,n=pe.now();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let n={zoom:0,bearing:0,pitch:0,pan:new p.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:c}of this._inertiaBuffer)n.zoom+=c.zoomDelta||0,n.bearing+=c.bearingDelta||0,n.pitch+=c.pitchDelta||0,c.panDelta&&n.pan._add(c.panDelta),c.around&&(n.around=c.around),c.pinchAround&&(n.pinchAround=c.pinchAround);let o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,a={};if(n.pan.mag()){let c=Is(n.pan.mag(),o,p.e({},la,e||{}));a.offset=n.pan.mult(c.amount/n.pan.mag()),a.center=this._map.transform.center,Ts(a,c)}if(n.zoom){let c=Is(n.zoom,o,Mc);a.zoom=this._map.transform.zoom+c.amount,Ts(a,c)}if(n.bearing){let c=Is(n.bearing,o,bl);a.bearing=this._map.transform.bearing+p.ac(c.amount,-179,179),Ts(a,c)}if(n.pitch){let c=Is(n.pitch,o,ao);a.pitch=this._map.transform.pitch+c.amount,Ts(a,c)}if(a.zoom||a.bearing){let c=n.pinchAround===void 0?n.around:n.pinchAround;a.around=c?this._map.unproject(c):this._map.getCenter()}return this.clear(),p.e(a,{noMoveStart:!0})}}function Ts(h,e){(!h.duration||h.duration<e.duration)&&(h.duration=e.duration,h.easing=e.easing)}function Is(h,e,n){let{maxSpeed:o,linearity:a,deceleration:c}=n,m=p.ac(h*a/(e/1e3),-o,o),_=Math.abs(m)/(c*a);return{easing:n.easing,duration:1e3*_,amount:m*(_/2)}}class hi extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o,a={}){let c=K.mousePos(n.getCanvas(),o),m=n.unproject(c);super(e,p.e({point:c,lngLat:m,originalEvent:o},a)),this._defaultPrevented=!1,this.target=n}}class un extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o){let a=e==="touchend"?o.changedTouches:o.touches,c=K.touchPos(n.getCanvasContainer(),a),m=c.map((y=>n.unproject(y))),_=c.reduce(((y,b,S,T)=>y.add(b.div(T.length))),new p.P(0,0));super(e,{points:c,point:_,lngLats:m,lngLat:n.unproject(_),originalEvent:o}),this._defaultPrevented=!1}}class wl extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o){super(e,{originalEvent:o}),this._defaultPrevented=!1}}class Sl{constructor(e,n){this._map=e,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new wl(e.type,this._map,e))}mousedown(e,n){return this._mousedownPos=n,this._firePreventable(new hi(e.type,this._map,e))}mouseup(e){this._map.fire(new hi(e.type,this._map,e))}click(e,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new hi(e.type,this._map,e))}dblclick(e){return this._firePreventable(new hi(e.type,this._map,e))}mouseover(e){this._map.fire(new hi(e.type,this._map,e))}mouseout(e){this._map.fire(new hi(e.type,this._map,e))}touchstart(e){return this._firePreventable(new un(e.type,this._map,e))}touchmove(e){this._map.fire(new un(e.type,this._map,e))}touchend(e){this._map.fire(new un(e.type,this._map,e))}touchcancel(e){this._map.fire(new un(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class jt{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new hi(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new hi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new hi(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ar{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.pointLocation(p.P.convert(e),this._map.terrain)}}class Oi{constructor(e,n){this._map=e,this._tr=new ar(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,n){this.isEnabled()&&e.shiftKey&&e.button===0&&(K.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(e,n){if(!this._active)return;let o=n;if(this._lastPos.equals(o)||!this._box&&o.dist(this._startPos)<this._clickTolerance)return;let a=this._startPos;this._lastPos=o,this._box||(this._box=K.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));let c=Math.min(a.x,o.x),m=Math.max(a.x,o.x),_=Math.min(a.y,o.y),y=Math.max(a.y,o.y);K.setTransform(this._box,`translate(${c}px,${_}px)`),this._box.style.width=m-c+"px",this._box.style.height=y-_+"px"}mouseupWindow(e,n){if(!this._active||e.button!==0)return;let o=this._startPos,a=n;if(this.reset(),K.suppressClick(),o.x!==a.x||o.y!==a.y)return this._map.fire(new p.k("boxzoomend",{originalEvent:e})),{cameraAnimation:c=>c.fitScreenCoordinates(o,a,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(K.remove(this._box),this._box=null),K.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new p.k(e,{originalEvent:n}))}}function Cs(h,e){if(h.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${e.length}`);let n={};for(let o=0;o<h.length;o++)n[h[o].identifier]=e[o];return n}class ha{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,n,o){(this.centroid||o.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),o.length===this.numTouches&&(this.centroid=(function(a){let c=new p.P(0,0);for(let m of a)c._add(m);return c.div(a.length)})(n),this.touches=Cs(o,n)))}touchmove(e,n,o){if(this.aborted||!this.centroid)return;let a=Cs(o,n);for(let c in this.touches){let m=a[c];(!m||m.dist(this.touches[c])>30)&&(this.aborted=!0)}}touchend(e,n,o){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),o.length===0){let a=!this.aborted&&this.centroid;if(this.reset(),a)return a}}}class lo{constructor(e){this.singleTap=new ha(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,n,o){this.singleTap.touchstart(e,n,o)}touchmove(e,n,o){this.singleTap.touchmove(e,n,o)}touchend(e,n,o){let a=this.singleTap.touchend(e,n,o);if(a){let c=e.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(a)<30;if(c&&m||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=a,this.count===this.numTaps)return this.reset(),a}}}class On{constructor(e){this._tr=new ar(e),this._zoomIn=new lo({numTouches:1,numTaps:2}),this._zoomOut=new lo({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,n,o){this._zoomIn.touchstart(e,n,o),this._zoomOut.touchstart(e,n,o)}touchmove(e,n,o){this._zoomIn.touchmove(e,n,o),this._zoomOut.touchmove(e,n,o)}touchend(e,n,o){let a=this._zoomIn.touchend(e,n,o),c=this._zoomOut.touchend(e,n,o),m=this._tr;return a?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(a)},{originalEvent:e})}):c?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(c)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Dr{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let n=this._moveFunction(...e);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(e,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,n){if(!this.isEnabled())return;let o=this._lastPoint;if(!o)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);let a=n.length?n[0]:n;return!this._moved&&a.dist(o)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=a,this._move(o,a))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&K.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let ua={0:1,2:2};class co{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){let n=K.mouseButton(e);this._eventButton=n}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!(function(n,o){let a=ua[o];return n.buttons===void 0||(n.buttons&a)!==a})(e,this._eventButton)}isValidEndEvent(e){return K.mouseButton(e)===this._eventButton}}class da{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}let ho=h=>{h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=e=>{e.preventDefault()}},pa=({enable:h,clickTolerance:e,bearingDegreesPerPixelMoved:n=.8})=>{let o=new co({checkCorrectEvent:a=>K.mouseButton(a)===0&&a.ctrlKey||K.mouseButton(a)===2});return new Dr({clickTolerance:e,move:(a,c)=>({bearingDelta:(c.x-a.x)*n}),moveStateManager:o,enable:h,assignEvents:ho})},fa=({enable:h,clickTolerance:e,pitchDegreesPerPixelMoved:n=-.5})=>{let o=new co({checkCorrectEvent:a=>K.mouseButton(a)===0&&a.ctrlKey||K.mouseButton(a)===2});return new Dr({clickTolerance:e,move:(a,c)=>({pitchDelta:(c.y-a.y)*n}),moveStateManager:o,enable:h,assignEvents:ho})};class dn{constructor(e,n){this._clickTolerance=e.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new p.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,n,o){return this._calculateTransform(e,n,o)}touchmove(e,n,o){if(this._active){if(!this._shouldBePrevented(o.length))return e.preventDefault(),this._calculateTransform(e,n,o);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,n,o){this._calculateTransform(e,n,o),this._active&&this._shouldBePrevented(o.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,o){o.length>0&&(this._active=!0);let a=Cs(o,n),c=new p.P(0,0),m=new p.P(0,0),_=0;for(let b in a){let S=a[b],T=this._touches[b];T&&(c._add(S),m._add(S.sub(T)),_++,a[b]=S)}if(this._touches=a,this._shouldBePrevented(_)||!m.mag())return;let y=m.div(_);return this._sum._add(y),this._sum.mag()<this._clickTolerance?void 0:{around:c.div(_),panDelta:y}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class uo{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,n,o){this._firstTwoTouches||o.length<2||(this._firstTwoTouches=[o[0].identifier,o[1].identifier],this._start([n[0],n[1]]))}touchmove(e,n,o){if(!this._firstTwoTouches)return;e.preventDefault();let[a,c]=this._firstTwoTouches,m=Ps(o,n,a),_=Ps(o,n,c);if(!m||!_)return;let y=this._aroundCenter?null:m.add(_).div(2);return this._move([m,_],y,e)}touchend(e,n,o){if(!this._firstTwoTouches)return;let[a,c]=this._firstTwoTouches,m=Ps(o,n,a),_=Ps(o,n,c);m&&_||(this._active&&K.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Ps(h,e,n){for(let o=0;o<h.length;o++)if(h[o].identifier===n)return e[o]}function ma(h,e){return Math.log(h/e)/Math.LN2}class ga extends uo{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,n){let o=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(ma(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:ma(this._distance,o),pinchAround:n}}}function _a(h,e){return 180*h.angleWith(e)/Math.PI}class ya extends uo{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,n,o){let a=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:_a(this._vector,a),pinchAround:n}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let n=25/(Math.PI*this._minDiameter)*360,o=_a(e,this._startVector);return Math.abs(o)<n}}function po(h){return Math.abs(h.y)>Math.abs(h.x)}class Nn extends uo{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,n,o){super.touchstart(e,n,o),this._currentTouchCount=o.length}_start(e){this._lastPoints=e,po(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,n,o){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let a=e[0].sub(this._lastPoints[0]),c=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(a,c,o.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(a.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(e,n,o){if(this._valid!==void 0)return this._valid;let a=e.mag()>=2,c=n.mag()>=2;if(!a&&!c)return;if(!a||!c)return this._firstMove===void 0&&(this._firstMove=o),o-this._firstMove<100&&void 0;let m=e.y>0==n.y>0;return po(e)&&po(n)&&m}}let Tl={panStep:100,bearingStep:15,pitchStep:10};class Hi{constructor(e){this._tr=new ar(e);let n=Tl;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,o=0,a=0,c=0,m=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?o=-1:(e.preventDefault(),c=-1);break;case 39:e.shiftKey?o=1:(e.preventDefault(),c=1);break;case 38:e.shiftKey?a=1:(e.preventDefault(),m=-1);break;case 40:e.shiftKey?a=-1:(e.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(o=0,a=0),{cameraAnimation:_=>{let y=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:Tr,zoom:n?Math.round(y.zoom)+n*(e.shiftKey?2:1):y.zoom,bearing:y.bearing+o*this._bearingStep,pitch:y.pitch+a*this._pitchStep,offset:[-c*this._panStep,-m*this._panStep],center:y.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Tr(h){return h*(2-h)}let xa=4.000244140625;class lr{constructor(e,n){this._onTimeout=o=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(o)},this._map=e,this._tr=new ar(e),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,o=pe.now(),a=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,n!==0&&n%xa==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":a>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(a*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let n=K.mousePos(this._map.getCanvas(),e),o=this._tr;this._around=n.y>o.transform.height/2-o.transform.getHorizon()?p.N.convert(this._aroundCenter?o.center:o.unproject(n)):p.N.convert(o.center),this._aroundPoint=o.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let e=this._tr.transform;if(this._delta!==0){let y=this._type==="wheel"&&Math.abs(this._delta)>xa?this._wheelZoomRate:this._defaultZoomRate,b=2/(1+Math.exp(-Math.abs(this._delta*y)));this._delta<0&&b!==0&&(b=1/b);let S=typeof this._targetZoom=="number"?e.zoomScale(this._targetZoom):e.scale;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(S*b))),this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let n=typeof this._targetZoom=="number"?this._targetZoom:e.zoom,o=this._startZoom,a=this._easing,c,m=!1,_=pe.now()-this._lastWheelEventTime;if(this._type==="wheel"&&o&&a&&_){let y=Math.min(_/200,1),b=a(y);c=p.y.number(o,n,b),y<1?this._frameId||(this._frameId=!0):m=!0}else c=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:c-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=p.b9;if(this._prevEase){let o=this._prevEase,a=(pe.now()-o.start)/o.duration,c=o.easing(a+.01)-o.easing(a),m=.27/Math.sqrt(c*c+1e-4)*.01,_=Math.sqrt(.0729-m*m);n=p.b8(m,_,.25,1)}return this._prevEase={start:pe.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class pn{constructor(e,n){this._clickZoom=e,this._tapZoom=n}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ac{constructor(e){this._tr=new ar(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:o=>{o.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ec{constructor(){this._tap=new lo({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,n,o){if(!this._swipePoint)if(this._tapTime){let a=n[0],c=e.timeStamp-this._tapTime<500,m=this._tapPoint.dist(a)<30;c&&m?o.length>0&&(this._swipePoint=a,this._swipeTouch=o[0].identifier):this.reset()}else this._tap.touchstart(e,n,o)}touchmove(e,n,o){if(this._tapTime){if(this._swipePoint){if(o[0].identifier!==this._swipeTouch)return;let a=n[0],c=a.y-this._swipePoint.y;return this._swipePoint=a,e.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(e,n,o)}touchend(e,n,o){if(this._tapTime)this._swipePoint&&o.length===0&&this.reset();else{let a=this._tap.touchend(e,n,o);a&&(this._tapTime=e.timeStamp,this._tapPoint=a)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Il{constructor(e,n,o){this._el=e,this._mousePan=n,this._touchPan=o}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Cl{constructor(e,n,o){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=n,this._mousePitch=o}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 va{constructor(e,n,o,a){this._el=e,this._touchZoom=n,this._touchRotate=o,this._tapDragZoom=a,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Vn{constructor(e,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=K.create("div","maplibregl-cooperative-gesture-screen",e);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let o=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),a=document.createElement("div");a.className="maplibregl-desktop-message",a.textContent=n,this._container.appendChild(a);let c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=o,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(K.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new p.k("cooperativegestureprevented",{gestureType:e,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}let Wi=h=>h.zoom||h.drag||h.pitch||h.rotate;class ke extends p.k{}function fo(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta}class ba{constructor(e,n){this.handleWindowEvent=a=>{this.handleEvent(a,`${a.type}Window`)},this.handleEvent=(a,c)=>{if(a.type==="blur")return void this.stop(!0);this._updatingCamera=!0;let m=a.type==="renderFrame"?void 0:a,_={needsRenderFrame:!1},y={},b={},S=a.touches,T=S?this._getMapTouches(S):void 0,E=T?K.touchPos(this._map.getCanvas(),T):K.mousePos(this._map.getCanvas(),a);for(let{handlerName:V,handler:$,allowed:q}of this._handlers){if(!$.isEnabled())continue;let G;this._blockedByActive(b,q,V)?$.reset():$[c||a.type]&&(G=$[c||a.type](a,E,T),this.mergeHandlerResult(_,y,G,V,m),G&&G.needsRenderFrame&&this._triggerRenderFrame()),(G||$.isActive())&&(b[V]=$)}let L={};for(let V in this._previousActiveHandlers)b[V]||(L[V]=m);this._previousActiveHandlers=b,(Object.keys(L).length||fo(_))&&(this._changes.push([_,y,L]),this._triggerRenderFrame()),(Object.keys(b).length||fo(_))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:B}=_;B&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],B(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ca(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);let o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[window,"blur",void 0]];for(let[a,c,m]of this._listeners)K.addEventListener(a,c,a===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(let[e,n,o]of this._listeners)K.removeEventListener(e,n,e===document?this.handleWindowEvent:this.handleEvent,o)}_addDefaultHandlers(e){let n=this._map,o=n.getCanvasContainer();this._add("mapEvent",new Sl(n,e));let a=n.boxZoom=new Oi(n,e);this._add("boxZoom",a),e.interactive&&e.boxZoom&&a.enable();let c=n.cooperativeGestures=new Vn(n,e.cooperativeGestures);this._add("cooperativeGestures",c),e.cooperativeGestures&&c.enable();let m=new On(n),_=new Ac(n);n.doubleClickZoom=new pn(_,m),this._add("tapZoom",m),this._add("clickZoom",_),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();let y=new Ec;this._add("tapDragZoom",y);let b=n.touchPitch=new Nn(n);this._add("touchPitch",b),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);let S=pa(e),T=fa(e);n.dragRotate=new Cl(e,S,T),this._add("mouseRotate",S,["mousePitch"]),this._add("mousePitch",T,["mouseRotate"]),e.interactive&&e.dragRotate&&n.dragRotate.enable();let E=(({enable:G,clickTolerance:F})=>{let J=new co({checkCorrectEvent:Q=>K.mouseButton(Q)===0&&!Q.ctrlKey});return new Dr({clickTolerance:F,move:(Q,ne)=>({around:ne,panDelta:ne.sub(Q)}),activateOnStart:!0,moveStateManager:J,enable:G,assignEvents:ho})})(e),L=new dn(e,n);n.dragPan=new Il(o,E,L),this._add("mousePan",E),this._add("touchPan",L,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);let B=new ya,V=new ga;n.touchZoomRotate=new va(o,V,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",V,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);let $=n.scrollZoom=new lr(n,(()=>this._triggerRenderFrame()));this._add("scrollZoom",$,["mousePan"]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);let q=n.keyboard=new Hi(n);this._add("keyboard",q),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new jt(n))}_add(e,n,o){this._handlers.push({handlerName:e,handler:n,allowed:o}),this._handlersById[e]=n}stop(e){if(!this._updatingCamera){for(let{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Wi(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,n,o){for(let a in e)if(a!==o&&(!n||n.indexOf(a)<0))return!0;return!1}_getMapTouches(e){let n=[];for(let o of e)this._el.contains(o.target)&&n.push(o);return n}mergeHandlerResult(e,n,o,a,c){if(!o)return;p.e(e,o);let m={handlerName:a,originalEvent:o.originalEvent||c};o.zoomDelta!==void 0&&(n.zoom=m),o.panDelta!==void 0&&(n.drag=m),o.pitchDelta!==void 0&&(n.pitch=m),o.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){let e={},n={},o={};for(let[a,c,m]of this._changes)a.panDelta&&(e.panDelta=(e.panDelta||new p.P(0,0))._add(a.panDelta)),a.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+a.zoomDelta),a.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+a.bearingDelta),a.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+a.pitchDelta),a.around!==void 0&&(e.around=a.around),a.pinchAround!==void 0&&(e.pinchAround=a.pinchAround),a.noInertia&&(e.noInertia=a.noInertia),p.e(n,c),p.e(o,m);this._updateMapTransform(e,n,o),this._changes=[]}_updateMapTransform(e,n,o){let a=this._map,c=a._getTransformForUpdate(),m=a.terrain;if(!(fo(e)||m&&this._terrainMovement))return this._fireEvents(n,o,!0);let{panDelta:_,zoomDelta:y,bearingDelta:b,pitchDelta:S,around:T,pinchAround:E}=e;E!==void 0&&(T=E),a._stop(!0),T=T||a.transform.centerPoint;let L=c.pointLocation(_?T.sub(_):T);b&&(c.bearing+=b),S&&(c.pitch+=S),y&&(c.zoom+=y),m?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?c.center=c.pointLocation(c.centerPoint.sub(_)):c.setLocationAtPoint(L,T):(this._terrainMovement=!0,this._map._elevationFreeze=!0,c.setLocationAtPoint(L,T)):c.setLocationAtPoint(L,T),a._applyUpdatedTransform(c),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,o,!0)}_fireEvents(e,n,o){let a=Wi(this._eventsInProgress),c=Wi(e),m={};for(let T in e){let{originalEvent:E}=e[T];this._eventsInProgress[T]||(m[`${T}start`]=E),this._eventsInProgress[T]=e[T]}!a&&c&&this._fireEvent("movestart",c.originalEvent);for(let T in m)this._fireEvent(T,m[T]);c&&this._fireEvent("move",c.originalEvent);for(let T in e){let{originalEvent:E}=e[T];this._fireEvent(T,E)}let _={},y;for(let T in this._eventsInProgress){let{handlerName:E,originalEvent:L}=this._eventsInProgress[T];this._handlersById[E].isActive()||(delete this._eventsInProgress[T],y=n[E]||L,_[`${T}end`]=y)}for(let T in _)this._fireEvent(T,_[T]);let b=Wi(this._eventsInProgress),S=(a||c)&&!b;if(S&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;let T=this._map._getTransformForUpdate();T.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(T)}if(o&&S){this._updatingCamera=!0;let T=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),E=L=>L!==0&&-this._bearingSnap<L&&L<this._bearingSnap;!T||!T.essential&&pe.prefersReducedMotion?(this._map.fire(new p.k("moveend",{originalEvent:y})),E(this._map.getBearing())&&this._map.resetNorth()):(E(T.bearing||this._map.getBearing())&&(T.bearing=0),T.freezeElevation=!0,this._map.easeTo(T,{originalEvent:y})),this._updatingCamera=!1}}_fireEvent(e,n){this._map.fire(new p.k(e,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{delete this._frameId,this.handleEvent(new ke("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Pl extends p.E{constructor(e,n){super(),this._renderFrameCallback=()=>{let o=Math.min((pe.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(o)),o<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState}))}getCenter(){return new p.N(this.transform.center.lng,this.transform.center.lat)}setCenter(e,n){return this.jumpTo({center:e},n)}panBy(e,n,o){return e=p.P.convert(e).mult(-1),this.panTo(this.transform.center,p.e({offset:e},n),o)}panTo(e,n,o){return this.easeTo(p.e({center:e},n),o)}getZoom(){return this.transform.zoom}setZoom(e,n){return this.jumpTo({zoom:e},n),this}zoomTo(e,n,o){return this.easeTo(p.e({zoom:e},n),o)}zoomIn(e,n){return this.zoomTo(this.getZoom()+1,e,n),this}zoomOut(e,n){return this.zoomTo(this.getZoom()-1,e,n),this}getBearing(){return this.transform.bearing}setBearing(e,n){return this.jumpTo({bearing:e},n),this}getPadding(){return this.transform.padding}setPadding(e,n){return this.jumpTo({padding:e},n),this}rotateTo(e,n,o){return this.easeTo(p.e({bearing:e},n),o)}resetNorth(e,n){return this.rotateTo(0,p.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(p.e({bearing:0,pitch:0,duration:1e3},e),n),this}snapToNorth(e,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,n):this}getPitch(){return this.transform.pitch}setPitch(e,n){return this.jumpTo({pitch:e},n),this}cameraForBounds(e,n){e=oe.convert(e).adjustAntiMeridian();let o=n&&n.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),o,n)}_cameraForBoxAndBearing(e,n,o,a){let c={top:0,bottom:0,right:0,left:0};if(typeof(a=p.e({padding:c,offset:[0,0],maxZoom:this.transform.maxZoom},a)).padding=="number"){let xe=a.padding;a.padding={top:xe,bottom:xe,right:xe,left:xe}}a.padding=p.e(c,a.padding);let m=this.transform,_=m.padding,y=new oe(e,n),b=m.project(y.getNorthWest()),S=m.project(y.getNorthEast()),T=m.project(y.getSouthEast()),E=m.project(y.getSouthWest()),L=p.ba(-o),B=b.rotate(L),V=S.rotate(L),$=T.rotate(L),q=E.rotate(L),G=new p.P(Math.max(B.x,V.x,q.x,$.x),Math.max(B.y,V.y,q.y,$.y)),F=new p.P(Math.min(B.x,V.x,q.x,$.x),Math.min(B.y,V.y,q.y,$.y)),J=G.sub(F),Q=(m.width-(_.left+_.right+a.padding.left+a.padding.right))/J.x,ne=(m.height-(_.top+_.bottom+a.padding.top+a.padding.bottom))/J.y;if(ne<0||Q<0)return void p.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");let ue=Math.min(m.scaleZoom(m.scale*Math.min(Q,ne)),a.maxZoom),me=p.P.convert(a.offset),Te=new p.P((a.padding.left-a.padding.right)/2,(a.padding.top-a.padding.bottom)/2).rotate(p.ba(o)),Ae=me.add(Te).mult(m.scale/m.zoomScale(ue));return{center:m.unproject(b.add(T).div(2).sub(Ae)),zoom:ue,bearing:o}}fitBounds(e,n,o){return this._fitInternal(this.cameraForBounds(e,n),n,o)}fitScreenCoordinates(e,n,o,a,c){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(p.P.convert(e)),this.transform.pointLocation(p.P.convert(n)),o,a),a,c)}_fitInternal(e,n,o){return e?(delete(n=p.e(e,n)).padding,n.linear?this.easeTo(n,o):this.flyTo(n,o)):this}jumpTo(e,n){this.stop();let o=this._getTransformForUpdate(),a=!1,c=!1,m=!1;return"zoom"in e&&o.zoom!==+e.zoom&&(a=!0,o.zoom=+e.zoom),e.center!==void 0&&(o.center=p.N.convert(e.center)),"bearing"in e&&o.bearing!==+e.bearing&&(c=!0,o.bearing=+e.bearing),"pitch"in e&&o.pitch!==+e.pitch&&(m=!0,o.pitch=+e.pitch),e.padding==null||o.isPaddingEqual(e.padding)||(o.padding=e.padding),this._applyUpdatedTransform(o),this.fire(new p.k("movestart",n)).fire(new p.k("move",n)),a&&this.fire(new p.k("zoomstart",n)).fire(new p.k("zoom",n)).fire(new p.k("zoomend",n)),c&&this.fire(new p.k("rotatestart",n)).fire(new p.k("rotate",n)).fire(new p.k("rotateend",n)),m&&this.fire(new p.k("pitchstart",n)).fire(new p.k("pitch",n)).fire(new p.k("pitchend",n)),this.fire(new p.k("moveend",n))}calculateCameraOptionsFromTo(e,n,o,a=0){let c=p.Z.fromLngLat(e,n),m=p.Z.fromLngLat(o,a),_=m.x-c.x,y=m.y-c.y,b=m.z-c.z,S=Math.hypot(_,y,b);if(S===0)throw new Error("Can't calculate camera options with same From and To");let T=Math.hypot(_,y),E=this.transform.scaleZoom(this.transform.cameraToCenterDistance/S/this.transform.tileSize),L=180*Math.atan2(_,-y)/Math.PI,B=180*Math.acos(T/S)/Math.PI;return B=b<0?90-B:90+B,{center:m.toLngLat(),zoom:E,pitch:B,bearing:L}}easeTo(e,n){var o;this._stop(!1,e.easeId),((e=p.e({offset:[0,0],duration:500,easing:p.b9},e)).animate===!1||!e.essential&&pe.prefersReducedMotion)&&(e.duration=0);let a=this._getTransformForUpdate(),c=a.zoom,m=a.bearing,_=a.pitch,y=a.padding,b="bearing"in e?this._normalizeBearing(e.bearing,m):m,S="pitch"in e?+e.pitch:_,T="padding"in e?e.padding:a.padding,E=p.P.convert(e.offset),L=a.centerPoint.add(E),B=a.pointLocation(L),{center:V,zoom:$}=a.getConstrained(p.N.convert(e.center||B),(o=e.zoom)!==null&&o!==void 0?o:c);this._normalizeCenter(V,a);let q=a.project(B),G=a.project(V).sub(q),F=a.zoomScale($-c),J,Q;e.around&&(J=p.N.convert(e.around),Q=a.locationPoint(J));let ne={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||S!==_,this._padding=!a.isPaddingEqual(T),this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,ne),this.terrain&&this._prepareElevation(V),this._ease((ue=>{if(this._zooming&&(a.zoom=p.y.number(c,$,ue)),this._rotating&&(a.bearing=p.y.number(m,b,ue)),this._pitching&&(a.pitch=p.y.number(_,S,ue)),this._padding&&(a.interpolatePadding(y,T,ue),L=a.centerPoint.add(E)),this.terrain&&!e.freezeElevation&&this._updateElevation(ue),J)a.setLocationAtPoint(J,Q);else{let me=a.zoomScale(a.zoom-c),Te=$>c?Math.min(2,F):Math.max(.5,F),Ae=Math.pow(Te,1-ue),xe=a.unproject(q.add(G.mult(ue*Ae)).mult(me));a.setLocationAtPoint(a.renderWorldCopies?xe.wrap():xe,L)}this._applyUpdatedTransform(a),this._fireMoveEvents(n)}),(ue=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,ue)}),e),this}_prepareEase(e,n,o={}){this._moving=!0,n||o.moving||this.fire(new p.k("movestart",e)),this._zooming&&!o.zooming&&this.fire(new p.k("zoomstart",e)),this._rotating&&!o.rotating&&this.fire(new p.k("rotatestart",e)),this._pitching&&!o.pitching&&this.fire(new p.k("pitchstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);let n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){let o=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(o-(n-(o*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.elevation=p.y.number(this._elevationStart,this._elevationTarget,e)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){let n=e.getCameraPosition(),o=this.terrain.getElevationForLngLatZoom(n.lngLat,e.zoom);if(n.altitude<o){let a=this.calculateCameraOptionsFromTo(n.lngLat,o,e.center,e.elevation);return{pitch:a.pitch,zoom:a.zoom}}return{}}_applyUpdatedTransform(e){let n=[];if(this.terrain&&n.push((a=>this._elevateCameraIfInsideTerrain(a))),this.transformCameraUpdate&&n.push((a=>this.transformCameraUpdate(a))),!n.length)return;let o=e.clone();for(let a of n){let c=o.clone(),{center:m,zoom:_,pitch:y,bearing:b,elevation:S}=a(c);m&&(c.center=m),_!==void 0&&(c.zoom=_),y!==void 0&&(c.pitch=y),b!==void 0&&(c.bearing=b),S!==void 0&&(c.elevation=S),o.apply(c)}this.transform.apply(o)}_fireMoveEvents(e){this.fire(new p.k("move",e)),this._zooming&&this.fire(new p.k("zoom",e)),this._rotating&&this.fire(new p.k("rotate",e)),this._pitching&&this.fire(new p.k("pitch",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;let o=this._zooming,a=this._rotating,c=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,o&&this.fire(new p.k("zoomend",e)),a&&this.fire(new p.k("rotateend",e)),c&&this.fire(new p.k("pitchend",e)),this.fire(new p.k("moveend",e))}flyTo(e,n){var o;if(!e.essential&&pe.prefersReducedMotion){let Pe=p.M(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Pe,n)}this.stop(),e=p.e({offset:[0,0],speed:1.2,curve:1.42,easing:p.b9},e);let a=this._getTransformForUpdate(),c=a.zoom,m=a.bearing,_=a.pitch,y=a.padding,b="bearing"in e?this._normalizeBearing(e.bearing,m):m,S="pitch"in e?+e.pitch:_,T="padding"in e?e.padding:a.padding,E=p.P.convert(e.offset),L=a.centerPoint.add(E),B=a.pointLocation(L),{center:V,zoom:$}=a.getConstrained(p.N.convert(e.center||B),(o=e.zoom)!==null&&o!==void 0?o:c);this._normalizeCenter(V,a);let q=a.zoomScale($-c),G=a.project(B),F=a.project(V).sub(G),J=e.curve,Q=Math.max(a.width,a.height),ne=Q/q,ue=F.mag();if("minZoom"in e){let Pe=p.ac(Math.min(e.minZoom,c,$),a.minZoom,a.maxZoom),Ze=Q/a.zoomScale(Pe-c);J=Math.sqrt(Ze/ue*2)}let me=J*J;function Te(Pe){let Ze=(ne*ne-Q*Q+(Pe?-1:1)*me*me*ue*ue)/(2*(Pe?ne:Q)*me*ue);return Math.log(Math.sqrt(Ze*Ze+1)-Ze)}function Ae(Pe){return(Math.exp(Pe)-Math.exp(-Pe))/2}function xe(Pe){return(Math.exp(Pe)+Math.exp(-Pe))/2}let ye=Te(!1),Re=function(Pe){return xe(ye)/xe(ye+J*Pe)},We=function(Pe){return Q*((xe(ye)*(Ae(Ze=ye+J*Pe)/xe(Ze))-Ae(ye))/me)/ue;var Ze},be=(Te(!0)-ye)/J;if(Math.abs(ue)<1e-6||!isFinite(be)){if(Math.abs(Q-ne)<1e-6)return this.easeTo(e,n);let Pe=ne<Q?-1:1;be=Math.abs(Math.log(ne/Q))/J,We=()=>0,Re=Ze=>Math.exp(Pe*J*Ze)}return e.duration="duration"in e?+e.duration:1e3*be/("screenSpeed"in e?+e.screenSpeed/J:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=m!==b,this._pitching=S!==_,this._padding=!a.isPaddingEqual(T),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(V),this._ease((Pe=>{let Ze=Pe*be,Et=1/Re(Ze);a.zoom=Pe===1?$:c+a.scaleZoom(Et),this._rotating&&(a.bearing=p.y.number(m,b,Pe)),this._pitching&&(a.pitch=p.y.number(_,S,Pe)),this._padding&&(a.interpolatePadding(y,T,Pe),L=a.centerPoint.add(E)),this.terrain&&!e.freezeElevation&&this._updateElevation(Pe);let Qe=Pe===1?V:a.unproject(G.add(F.mult(We(Ze))).mult(Et));a.setLocationAtPoint(a.renderWorldCopies?Qe.wrap():Qe,L),this._applyUpdatedTransform(a),this._fireMoveEvents(n)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,n){var o;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let a=this._onEaseEnd;delete this._onEaseEnd,a.call(this,n)}return e||(o=this.handlers)===null||o===void 0||o.stop(!1),this}_ease(e,n,o){o.animate===!1||o.duration===0?(e(1),n()):(this._easeStart=pe.now(),this._easeOptions=o,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=p.b3(e,-180,180);let o=Math.abs(e-n);return Math.abs(e-360-n)<o&&(e-=360),Math.abs(e+360-n)<o&&(e+=360),e}_normalizeCenter(e,n){if(!n.renderWorldCopies||n.lngRange)return;let o=e.lng-n.center.lng;e.lng+=o>180?-360:o<-180?360:0}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(p.N.convert(e),this.transform.tileZoom)-this.transform.elevation:null}}let Un={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class jn{constructor(e=Un){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=K.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=K.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=K.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(){K.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,n){let o=this._map._getUIString(`AttributionControl.${n}`);e.title=o,e.setAttribute("aria-label",o)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((a=>typeof a!="string"?"":a))):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let a=this._map.style.stylesheet;this.styleOwner=a.owner,this.styleId=a.id}let n=this._map.style.sourceCaches;for(let a in n){let c=n[a];if(c.used||c.usedForTerrain){let m=c.getSource();m.attribution&&e.indexOf(m.attribution)<0&&e.push(m.attribution)}}e=e.filter((a=>String(a).trim())),e.sort(((a,c)=>a.length-c.length)),e=e.filter(((a,c)=>{for(let m=c+1;m<e.length;m++)if(e[m].indexOf(a)>=0)return!1;return!0}));let o=e.join(" | ");o!==this._attribHTML&&(this._attribHTML=o,e.length?(this._innerContainer.innerHTML=o,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class wa{constructor(e={}){this._updateCompact=()=>{let n=this._container.children;if(n.length){let o=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&o.classList.add("maplibregl-compact"):o.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=K.create("div","maplibregl-ctrl");let n=K.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){K.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class lt{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let n=++this._id;return this._queue.push({callback:e,id:n,cancelled:!1}),n}remove(e){let n=this._currentlyRunning,o=n?this._queue.concat(n):this._queue;for(let a of o)if(a.id===e)return void(a.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");let n=this._currentlyRunning=this._queue;this._queue=[];for(let o of n)if(!o.cancelled&&(o.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Sa=p.Y([{name:"a_pos3d",type:"Int16",components:3}]);class kc extends p.E{constructor(e){super(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,e.usedForTerrain=!0,e.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];let o={};for(let a of e.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))o[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.posMatrix=new Float64Array(16),p.aP(a.posMatrix,0,p.X,0,p.X,0,1),this._tiles[a.key]=new jr(a,this.tileSize));for(let a in this._tiles)o[a]||delete this._tiles[a]}freeRtt(e){for(let n in this._tiles){let o=this._tiles[n];(!e||o.tileID.equals(e)||o.tileID.isChildOf(e)||e.isChildOf(o.tileID))&&(o.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e){let n={};for(let o of this._renderableTilesKeys){let a=this._tiles[o].tileID;if(a.canonical.equals(e.canonical)){let c=e.clone();c.posMatrix=new Float64Array(16),p.aP(c.posMatrix,0,p.X,0,p.X,0,1),n[o]=c}else if(a.canonical.isChildOf(e.canonical)){let c=e.clone();c.posMatrix=new Float64Array(16);let m=a.canonical.z-e.canonical.z,_=a.canonical.x-(a.canonical.x>>m<<m),y=a.canonical.y-(a.canonical.y>>m<<m),b=p.X>>m;p.aP(c.posMatrix,0,b,0,b,0,1),p.J(c.posMatrix,c.posMatrix,[-_*b,-y*b,0]),n[o]=c}else if(e.canonical.isChildOf(a.canonical)){let c=e.clone();c.posMatrix=new Float64Array(16);let m=e.canonical.z-a.canonical.z,_=e.canonical.x-(e.canonical.x>>m<<m),y=e.canonical.y-(e.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,[_*b,y*b,0]),p.K(c.posMatrix,c.posMatrix,[1/2**m,1/2**m,0]),n[o]=c}}return n}getSourceTile(e,n){let o=this.sourceCache._source,a=e.overscaledZ-this.deltaZoom;if(a>o.maxzoom&&(a=o.maxzoom),a<o.minzoom)return null;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(a).key);let c=this.sourceCache.getTileByID(this._sourceTileCache[e.key]);if((!c||!c.dem)&&n)for(;a>=o.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(e.scaledTo(a--).key);return c}tilesAfterTime(e=Date.now()){return Object.values(this._tiles).filter((n=>n.timeAdded>=e))}}class Ta{constructor(e,n,o){this.painter=e,this.sourceCache=new kc(n),this.options=o,this.exaggeration=typeof o.exaggeration=="number"?o.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,o,a=p.X){var c;if(!(n>=0&&n<a&&o>=0&&o<a))return 0;let m=this.getTerrainData(e),_=(c=m.tile)===null||c===void 0?void 0:c.dem;if(!_)return 0;let y=(function(B,V,$){var q=V[0],G=V[1];return B[0]=$[0]*q+$[4]*G+$[12],B[1]=$[1]*q+$[5]*G+$[13],B})([],[n/a*p.X,o/a*p.X],m.u_terrain_matrix),b=[y[0]*_.dim,y[1]*_.dim],S=Math.floor(b[0]),T=Math.floor(b[1]),E=b[0]-S,L=b[1]-T;return _.get(S,T)*(1-E)*(1-L)+_.get(S+1,T)*E*(1-L)+_.get(S,T+1)*(1-E)*L+_.get(S+1,T+1)*E*L}getElevationForLngLatZoom(e,n){if(!p.bb(n,e.wrap()))return 0;let{tileID:o,mercatorX:a,mercatorY:c}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getElevation(o,a%p.X,c%p.X,p.X)}getElevation(e,n,o,a=p.X){return this.getDEMElevation(e,n,o,a)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){let a=this.painter.context,c=new p.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Ye(a,c,a.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Ye(a,new p.R({width:1,height:1}),a.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(a.gl.NEAREST,a.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=p.an([])}let n=this.sourceCache.getSourceTile(e,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){let a=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new Ye(a,n.dem.getPixels(),a.gl.RGBA,{premultiply:!1}),n.demTexture.bind(a.gl.NEAREST,a.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}let o=n&&n+n.tileID.key+e.key;if(o&&!this._demMatrixCache[o]){let a=this.sourceCache.sourceCache._source.maxzoom,c=e.canonical.z-n.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=a?c=e.canonical.z-a:p.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let m=e.canonical.x-(e.canonical.x>>c<<c),_=e.canonical.y-(e.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,_*p.X,0]),this._demMatrixCache[e.key]={matrix:y,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:o?this._demMatrixCache[e.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(e){let n=this.painter,o=n.width/devicePixelRatio,a=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===o&&this._fbo.height===a||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Ye(n.context,{width:o,height:a,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Ye(n.context,{width:o,height:a,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(o,a,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,o,a))),this._fbo.colorAttachment.set(e==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let c=0,m=0;c<this._coordsTextureSize;c++)for(let _=0;_<this._coordsTextureSize;_++,m+=4)n[m+0]=255&_,n[m+1]=255&c,n[m+2]=_>>8<<4|c>>8,n[m+3]=0;let o=new p.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),a=new Ye(e,o,e.gl.RGBA,{premultiply:!1});return a.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=a,a}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);let n=new Uint8Array(4),o=this.painter.context,a=o.gl,c=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),_=Math.round(this.painter.height/devicePixelRatio);o.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),a.readPixels(c,_-m-1,1,1,a.RGBA,a.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null);let y=n[0]+(n[2]>>4<<8),b=n[1]+((15&n[2])<<8),S=this.coordsIndex[255-n[3]],T=S&&this.sourceCache.getTileByID(S);if(!T)return null;let E=this._coordsTextureSize,L=(1<<T.tileID.canonical.z)*E;return new p.Z((T.tileID.canonical.x*E+y)/L+T.tileID.wrap,(T.tileID.canonical.y*E+b)/L,this.getElevation(T.tileID,y,b,E))}depthAtPoint(e){let n=new Uint8Array(4),o=this.painter.context,a=o.gl;return o.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),a.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,a.RGBA,a.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;let e=this.painter.context,n=new p.bd,o=new p.aY,a=this.meshSize,c=p.X/a,m=a*a;for(let T=0;T<=a;T++)for(let E=0;E<=a;E++)n.emplaceBack(E*c,T*c,0);for(let T=0;T<m;T+=a+1)for(let E=0;E<a;E++)o.emplaceBack(E+T,a+E+T+1,a+E+T+2),o.emplaceBack(E+T,a+E+T+2,E+T+1);let _=n.length,y=_+2*(a+1);for(let T of[0,1])for(let E=0;E<=a;E++)for(let L of[0,1])n.emplaceBack(E*c,T*p.X,L);for(let T=0;T<2*a;T+=2)o.emplaceBack(y+T,y+T+1,y+T+3),o.emplaceBack(y+T,y+T+3,y+T+2),o.emplaceBack(_+T,_+T+3,_+T+1),o.emplaceBack(_+T,_+T+2,_+T+3);let b=n.length,S=b+2*(a+1);for(let T of[0,1])for(let E=0;E<=a;E++)for(let L of[0,1])n.emplaceBack(T*p.X,E*c,L);for(let T=0;T<2*a;T+=2)o.emplaceBack(b+T,b+T+1,b+T+3),o.emplaceBack(b+T,b+T+3,b+T+2),o.emplaceBack(S+T,S+T+3,S+T+1),o.emplaceBack(S+T,S+T+2,S+T+3);return this._mesh=new ro(e.createVertexBuffer(n,Sa.members),e.createIndexBuffer(o),p.a0.simpleSegment(0,0,n.length,o.length)),this._mesh}getMeshFrameDelta(e){return 2*Math.PI*p.be/Math.pow(2,e)/5}getMinTileElevationForLngLatZoom(e,n){var o;let{tileID:a}=this._getOverscaledTileIDFromLngLatZoom(e,n);return(o=this.getMinMaxElevation(a).minElevation)!==null&&o!==void 0?o:0}getMinMaxElevation(e){let n=this.getTerrainData(e).tile,o={minElevation:null,maxElevation:null};return n&&n.dem&&(o.minElevation=n.dem.min*this.exaggeration,o.maxElevation=n.dem.max*this.exaggeration),o}_getOverscaledTileIDFromLngLatZoom(e,n){let o=p.Z.fromLngLat(e.wrap()),a=(1<<n)*p.X,c=o.x*a,m=o.y*a,_=Math.floor(c/p.X),y=Math.floor(m/p.X);return{tileID:new p.S(n,0,n,_,y),mercatorX:c,mercatorY:m}}}class zc{constructor(e,n,o){this._context=e,this._size=n,this._tileSize=o,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){let n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),o=new Ye(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return o.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(o.texture),{id:e,fbo:n,texture:o,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((n=>e.id!==n)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(let n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");let e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(let e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&this._objects.some((e=>!e.inUse))===!1}}let $n={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Ml{constructor(e,n){this.painter=e,this.terrain=n,this.pool=new zc(e.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((o=>!e._layers[o].isHidden(n))),this._coordsDescendingInv={};for(let o in e.sourceCaches){this._coordsDescendingInv[o]={};let a=e.sourceCaches[o].getVisibleCoordinates();for(let c of a){let m=this.terrain.sourceCache.getTerrainCoords(c);for(let _ in m)this._coordsDescendingInv[o][_]||(this._coordsDescendingInv[o][_]=[]),this._coordsDescendingInv[o][_].push(m[_])}}this._coordsDescendingInvStr={};for(let o of e._order){let a=e._layers[o],c=a.source;if($n[a.type]&&!this._coordsDescendingInvStr[c]){this._coordsDescendingInvStr[c]={};for(let m in this._coordsDescendingInv[c])this._coordsDescendingInvStr[c][m]=this._coordsDescendingInv[c][m].map((_=>_.key)).sort().join()}}for(let o of this._renderableTiles)for(let a in this._coordsDescendingInvStr){let c=this._coordsDescendingInvStr[a][o.tileID.key];c&&c!==o.rttCoords[a]&&(o.rtt=[])}}renderLayer(e){if(e.isHidden(this.painter.transform.zoom))return!1;let n=e.type,o=this.painter,a=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if($n[n]&&(this._prevType&&$n[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(e.id),!a))return!0;if($n[this._prevType]||$n[n]&&a){this._prevType=n;let c=this._stacks.length-1,m=this._stacks[c]||[];for(let _ of this._renderableTiles){if(this.pool.isFull()&&(vl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(_),_.rtt[c]){let b=this.pool.getObjectForId(_.rtt[c].id);if(b.stamp===_.rtt[c].stamp){this.pool.useObject(b);continue}}let y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),_.rtt[c]={id:y.id,stamp:y.stamp},o.context.bindFramebuffer.set(y.fbo.framebuffer),o.context.clear({color:p.aM.transparent,stencil:0}),o.currentStencilSource=void 0;for(let b=0;b<m.length;b++){let S=o.style._layers[m[b]],T=S.source?this._coordsDescendingInv[S.source][_.tileID.key]:[_.tileID];o.context.viewport.set([0,0,y.fbo.width,y.fbo.height]),o._renderTileClippingMasks(S,T),o.renderLayer(o,o.style.sourceCaches[S.source],S,T),S.source&&(_.rttCoords[S.source]=this._coordsDescendingInvStr[S.source][_.tileID.key])}}return vl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),$n[n]}return!1}}let Ia={"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 \u2318 + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Al=Se,Lc={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Un,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},Ca=h=>{h.touchstart=h.dragStart,h.touchmoveWindow=h.dragMove,h.touchend=h.dragEnd},Dc={showCompass:!0,showZoom:!0,visualizePitch:!1};class Rc{constructor(e,n,o=!1){this.mousedown=m=>{this.startMouse(p.e({},m,{ctrlKey:!0,preventDefault:()=>m.preventDefault()}),K.mousePos(this.element,m)),K.addEventListener(window,"mousemove",this.mousemove),K.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=m=>{this.moveMouse(m,K.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=K.touchPos(this.element,m.targetTouches)[0],this.startTouch(m,this._startPos),K.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),K.addEventListener(window,"touchend",this.touchend))},this.touchmove=m=>{m.targetTouches.length!==1?this.reset():(this._lastPos=K.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;let a=e.dragRotate._mouseRotate.getClickTolerance(),c=e.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=pa({clickTolerance:a,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:_,bearingDegreesPerPixelMoved:y=.8})=>{let b=new da;return new Dr({clickTolerance:_,move:(S,T)=>({bearingDelta:(T.x-S.x)*y}),moveStateManager:b,enable:m,assignEvents:Ca})})({clickTolerance:a,enable:!0}),this.map=e,o&&(this.mousePitch=fa({clickTolerance:c,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:_,pitchDegreesPerPixelMoved:y=-.5})=>{let b=new da;return new Dr({clickTolerance:_,move:(S,T)=>({pitchDelta:(T.y-S.y)*y}),moveStateManager:b,enable:m,assignEvents:Ca})})({clickTolerance:c,enable:!0})),K.addEventListener(n,"mousedown",this.mousedown),K.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),K.addEventListener(n,"touchcancel",this.reset)}startMouse(e,n){this.mouseRotate.dragStart(e,n),this.mousePitch&&this.mousePitch.dragStart(e,n),K.disableDrag()}startTouch(e,n){this.touchRotate.dragStart(e,n),this.touchPitch&&this.touchPitch.dragStart(e,n),K.disableDrag()}moveMouse(e,n){let o=this.map,{bearingDelta:a}=this.mouseRotate.dragMove(e,n)||{};if(a&&o.setBearing(o.getBearing()+a),this.mousePitch){let{pitchDelta:c}=this.mousePitch.dragMove(e,n)||{};c&&o.setPitch(o.getPitch()+c)}}moveTouch(e,n){let o=this.map,{bearingDelta:a}=this.touchRotate.dragMove(e,n)||{};if(a&&o.setBearing(o.getBearing()+a),this.touchPitch){let{pitchDelta:c}=this.touchPitch.dragMove(e,n)||{};c&&o.setPitch(o.getPitch()+c)}}off(){let e=this.element;K.removeEventListener(e,"mousedown",this.mousedown),K.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),K.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),K.removeEventListener(window,"touchend",this.touchend),K.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){K.enableDrag(),K.removeEventListener(window,"mousemove",this.mousemove),K.removeEventListener(window,"mouseup",this.mouseup),K.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),K.removeEventListener(window,"touchend",this.touchend)}}let Ni;function At(h,e,n){let o=new p.N(h.lng,h.lat);if(h=new p.N(h.lng,h.lat),e){let a=new p.N(h.lng-360,h.lat),c=new p.N(h.lng+360,h.lat),m=n.locationPoint(h).distSqr(e);n.locationPoint(a).distSqr(e)<m?h=a:n.locationPoint(c).distSqr(e)<m&&(h=c)}for(;Math.abs(h.lng-n.center.lng)>180;){let a=n.locationPoint(h);if(a.x>=0&&a.y>=0&&a.x<=n.width&&a.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h.lng!==o.lng&&n.locationPoint(h).y>n.height/2-n.getHorizon()?h:o}let qn={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function mo(h,e,n){let o=h.classList;for(let a in qn)o.remove(`maplibregl-${n}-anchor-${a}`);o.add(`maplibregl-${n}-anchor-${e}`)}class go extends p.E{constructor(e){if(super(),this._onKeyPress=n=>{let o=n.code,a=n.charCode||n.keyCode;o!=="Space"&&o!=="Enter"&&a!==32&&a!==13||this.togglePopup()},this._onMapClick=n=>{let o=n.originalEvent.target,a=this._element;this._popup&&(o===a||a.contains(o))&&this.togglePopup()},this._update=n=>{var o;if(!this._map)return;let a=this._map.loaded()&&!this._map.isMoving();(n?.type==="terrain"||n?.type==="render"&&!a)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?At(this._lngLat,this._flatPos,this._map.transform):(o=this._lngLat)===null||o===void 0?void 0:o.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let m="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?m="rotateX(0deg)":this._pitchAlignment==="map"&&(m=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),K.setTransform(this._element,`${qn[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${m} ${c}`),pe.frameAsync(new AbortController).then((()=>{this._updateOpacity(n&&n.type==="moveend")})).catch((()=>{}))},this._onMove=n=>{if(!this._isDragging){let o=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=o}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new p.k("dragstart"))),this.fire(new p.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new p.k("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(e?.opacity,e?.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=p.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=K.create("div");let n=K.createNS("http://www.w3.org/2000/svg","svg"),o=41,a=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${o}px`),n.setAttributeNS(null,"width",`${a}px`),n.setAttributeNS(null,"viewBox",`0 0 ${a} ${o}`);let c=K.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");let m=K.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");let _=K.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");let 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(let q of y){let G=K.createNS("http://www.w3.org/2000/svg","ellipse");G.setAttributeNS(null,"opacity","0.04"),G.setAttributeNS(null,"cx","10.5"),G.setAttributeNS(null,"cy","5.80029008"),G.setAttributeNS(null,"rx",q.rx),G.setAttributeNS(null,"ry",q.ry),_.appendChild(G)}let b=K.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);let S=K.createNS("http://www.w3.org/2000/svg","path");S.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(S);let T=K.createNS("http://www.w3.org/2000/svg","g");T.setAttributeNS(null,"opacity","0.25"),T.setAttributeNS(null,"fill","#000000");let E=K.createNS("http://www.w3.org/2000/svg","path");E.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),T.appendChild(E);let L=K.createNS("http://www.w3.org/2000/svg","g");L.setAttributeNS(null,"transform","translate(6.0, 7.0)"),L.setAttributeNS(null,"fill","#FFFFFF");let B=K.createNS("http://www.w3.org/2000/svg","g");B.setAttributeNS(null,"transform","translate(8.0, 8.0)");let V=K.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");let $=K.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(_),m.appendChild(b),m.appendChild(T),m.appendChild(L),m.appendChild(B),n.appendChild(m),n.setAttributeNS(null,"height",o*this._scale+"px"),n.setAttributeNS(null,"width",a*this._scale+"px"),this._element.appendChild(n),this._offset=p.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(n=>{n.preventDefault()})),this._element.addEventListener("mousedown",(n=>{n.preventDefault()})),mo(this._element,this._anchor,"marker"),e&&e.className)for(let n of e.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),K.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=p.N.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){let a=Math.abs(13.5)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[a,-1*(38.1-13.5+a)],"bottom-right":[-a,-1*(38.1-13.5+a)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){let e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var n,o;if(!(!((n=this._map)===null||n===void 0)&&n.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}let a=this._map,c=a.terrain.depthAtPoint(this._pos),m=a.terrain.getElevationForLngLatZoom(this._lngLat,a.transform.tileZoom);if(a.transform.lngLatToCameraDepth(this._lngLat,m)-c<.006)return void(this._element.style.opacity=this._opacity);let _=-this._offset.y/a.transform._pixelPerMeter,y=Math.sin(a.getPitch()*Math.PI/180)*_,b=a.terrain.depthAtPoint(new p.P(this._pos.x,this._pos.y-this._offset.y)),S=a.transform.lngLatToCameraDepth(this._lngLat,m+y)-b>.006;!((o=this._popup)===null||o===void 0)&&o.isOpen()&&S&&this._popup.remove(),this._element.style.opacity=S?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=p.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,n){return e===void 0&&n===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}let El={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},Ms=0,As=!1,Ir={maxWidth:100,unit:"metric"};function Es(h,e,n){let o=n&&n.maxWidth||100,a=h._container.clientHeight/2,c=h.unproject([0,a]),m=h.unproject([o,a]),_=c.distanceTo(m);if(n&&n.unit==="imperial"){let y=3.2808*_;y>5280?De(e,o,y/5280,h._getUIString("ScaleControl.Miles")):De(e,o,y,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?De(e,o,_/1852,h._getUIString("ScaleControl.NauticalMiles")):_>=1e3?De(e,o,_/1e3,h._getUIString("ScaleControl.Kilometers")):De(e,o,_,h._getUIString("ScaleControl.Meters"))}function De(h,e,n,o){let a=(function(c){let m=Math.pow(10,`${Math.floor(c)}`.length-1),_=c/m;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:(function(y){let b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b})(_),m*_})(n);h.style.width=e*(a/n)+"px",h.innerHTML=`${a}&nbsp;${o}`}let je={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},_o=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function yo(h){if(h){if(typeof h=="number"){let e=Math.round(Math.abs(h)/Math.SQRT2);return{center:new p.P(0,0),top:new p.P(0,h),"top-left":new p.P(e,e),"top-right":new p.P(-e,e),bottom:new p.P(0,-h),"bottom-left":new p.P(e,-e),"bottom-right":new p.P(-e,-e),left:new p.P(h,0),right:new p.P(-h,0)}}if(h instanceof p.P||Array.isArray(h)){let e=p.P.convert(h);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:p.P.convert(h.center||[0,0]),top:p.P.convert(h.top||[0,0]),"top-left":p.P.convert(h["top-left"]||[0,0]),"top-right":p.P.convert(h["top-right"]||[0,0]),bottom:p.P.convert(h.bottom||[0,0]),"bottom-left":p.P.convert(h["bottom-left"]||[0,0]),"bottom-right":p.P.convert(h["bottom-right"]||[0,0]),left:p.P.convert(h.left||[0,0]),right:p.P.convert(h.right||[0,0])}}return yo(new p.P(0,0))}let Pa=Se;I.AJAXError=p.bh,I.Evented=p.E,I.LngLat=p.N,I.MercatorCoordinate=p.Z,I.Point=p.P,I.addProtocol=p.bi,I.config=p.a,I.removeProtocol=p.bj,I.AttributionControl=jn,I.BoxZoomHandler=Oi,I.CanvasSource=qi,I.CooperativeGesturesHandler=Vn,I.DoubleClickZoomHandler=pn,I.DragPanHandler=Il,I.DragRotateHandler=Cl,I.EdgeInsets=Bn,I.FullscreenControl=class extends p.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var e;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=n?.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:p.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=K.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){K.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let h=this._fullscreenButton=K.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);K.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new p.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new p.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},I.GeoJSONSource=hs,I.GeolocateControl=class extends p.E{constructor(h){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new p.k("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new p.k("geolocate",e)),this._finish()}},this._updateCamera=e=>{let n=new p.N(e.coords.longitude,e.coords.latitude),o=e.coords.accuracy,a=this._map.getBearing(),c=p.e({bearing:a},this.options.fitBoundsOptions),m=oe.fromLngLat(n,o);this._map.fitBounds(m,c,{geolocateSource:!0})},this._updateMarker=e=>{if(e){let n=new p.N(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(e.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;let n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&As)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new p.k("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=K.create("button","maplibregl-ctrl-geolocate",this._container),K.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(e===!1){p.w("Geolocation support is not available so the GeolocateControl will be disabled.");let n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{let n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=K.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new go({element:this._dotElement}),this._circleElement=K.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new go({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new p.k("trackuserlocationend")),this.fire(new p.k("userlocationlostfocus")))}))}},this.options=p.e({},El,h)}onAdd(h){return this._map=h,this._container=K.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),(function(){return p._(this,arguments,void 0,(function*(e=!1){if(Ni!==void 0&&!e)return Ni;if(window.navigator.permissions===void 0)return Ni=!!window.navigator.geolocation,Ni;try{Ni=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Ni=!!window.navigator.geolocation}return Ni}))})().then((e=>this._finishSetupUI(e))),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),K.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Ms=0,As=!1}_isOutOfMapMaxBounds(h){let e=this._map.getMaxBounds(),n=h.coords;return e&&(n.longitude<e.getWest()||n.longitude>e.getEast()||n.latitude<e.getSouth()||n.latitude>e.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(){let h=this._map.getBounds(),e=h.getSouthEast(),n=h.getNorthEast(),o=e.distanceTo(n),a=Math.ceil(this._accuracy/(o/this._map._container.clientHeight)*2);this._circleElement.style.width=`${a}px`,this._circleElement.style.height=`${a}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":Ms--,As=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new p.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new p.k("trackuserlocationstart")),this.fire(new p.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let h;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ms++,Ms>1?(h={maximumAge:6e5,timeout:0},As=!0):(h=this.options.positionOptions,As=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,h)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},I.Hash=so,I.ImageSource=kr,I.KeyboardHandler=Hi,I.LngLatBounds=oe,I.LogoControl=wa,I.Map=class extends Pl{constructor(h){p.bf.mark(p.bg.create);let e=Object.assign(Object.assign({},Lc),h);if(e.minZoom!=null&&e.maxZoom!=null&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(e.minPitch!=null&&e.maxPitch!=null&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(e.minPitch!=null&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(e.maxPitch!=null&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Fn(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),{bearingSnap:e.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new lt,this._controls=[],this._mapId=p.a4(),this._contextLost=n=>{n.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new p.k("webglcontextlost",{originalEvent:n}))},this._contextRestored=n=>{this._setupPainter(),this.resize(),this._update(),this.fire(new p.k("webglcontextrestored",{originalEvent:n}))},this._onMapScroll=n=>{if(n.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._maxTileCacheZoomLevels=e.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=e.preserveDrawingBuffer===!0,this._antialias=e.antialias===!0,this._trackResize=e.trackResize===!0,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles===!0,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions===!0,this._collectResourceTiming=e.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Ia),e.locale),this._clickTolerance=e.clickTolerance,this._overridePixelRatio=e.pixelRatio,this._maxCanvasSize=e.maxCanvasSize,this.transformCameraUpdate=e.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=e.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=et.addThrottleControl((()=>this.isMoving())),this._requestManager=new He(e.transformRequest),typeof e.container=="string"){if(this._container=document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))).on("moveend",(()=>this._update(!1))).on("zoom",(()=>this._update(!0))).on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})).once("idle",(()=>{this._idleTriggered=!0})),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let n=!1,o=Ss((a=>{this._trackResize&&!this._removed&&(this.resize(a),this.redraw())}),50);this._resizeObserver=new ResizeObserver((a=>{n?o(a):n=!0})),this._resizeObserver.observe(this._container)}this.handlers=new ba(this,e),this._hash=e.hash&&new so(typeof e.hash=="string"&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,p.e({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,this._validateStyle=e.validateStyle,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new jn(typeof e.attributionControl=="boolean"?void 0:e.attributionControl)),e.maplibreLogo&&this.addControl(new wa,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(n=>{this._update(n.dataType==="style"),this.fire(new p.k(`${n.dataType}data`,n))})),this.on("dataloading",(n=>{this.fire(new p.k(`${n.dataType}dataloading`,n))})),this.on("dataabort",(n=>{this.fire(new p.k("sourcedataabort",n))}))}_getMapId(){return this._mapId}addControl(h,e){if(e===void 0&&(e=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new p.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let n=h.onAdd(this);this._controls.push(h);let o=this._controlPositions[e];return e.indexOf("bottom")!==-1?o.insertBefore(n,o.firstChild):o.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new p.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let e=this._controls.indexOf(h);return e>-1&&this._controls.splice(e,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}calculateCameraOptionsFromTo(h,e,n,o){return o==null&&this.terrain&&(o=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,e,n,o)}resize(h){var e;let n=this._containerDimensions(),o=n[0],a=n[1],c=this._getClampedPixelRatio(o,a);if(this._resizeCanvas(o,a,c),this.painter.resize(o,a,c),this.painter.overLimit()){let _=this.painter.context.gl;this._maxCanvasSize=[_.drawingBufferWidth,_.drawingBufferHeight];let y=this._getClampedPixelRatio(o,a);this._resizeCanvas(o,a,y),this.painter.resize(o,a,y)}this.transform.resize(o,a),(e=this._requestedCameraState)===null||e===void 0||e.resize(o,a);let m=!this._moving;return m&&(this.stop(),this.fire(new p.k("movestart",h)).fire(new p.k("move",h))),this.fire(new p.k("resize",h)),m&&this.fire(new p.k("moveend",h)),this}_getClampedPixelRatio(h,e){let{0:n,1:o}=this._maxCanvasSize,a=this.getPixelRatio(),c=h*a,m=e*a;return Math.min(c>n?n/c:1,m>o?o/m:1)*a}getPixelRatio(){var h;return(h=this._overridePixelRatio)!==null&&h!==void 0?h:devicePixelRatio}setPixelRatio(h){this._overridePixelRatio=h,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(h){return this.transform.setMaxBounds(oe.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.minZoom=h,this._update(),this.getZoom()<h&&this.setZoom(h),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(h){if((h=h??22)>=this.transform.minZoom)return this.transform.maxZoom=h,this._update(),this.getZoom()>h&&this.setZoom(h),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.minPitch=h,this._update(),this.getPitch()<h&&this.setPitch(h),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(h){if((h=h??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(h>=this.transform.minPitch)return this.transform.maxPitch=h,this._update(),this.getPitch()>h&&this.setPitch(h),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.renderWorldCopies=h,this._update()}project(h){return this.transform.locationPoint(p.N.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.pointLocation(p.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,e,n){if(h==="mouseenter"||h==="mouseover"){let o=!1;return{layers:e,listener:n,delegates:{mousemove:c=>{let m=e.filter((y=>this.getLayer(y))),_=m.length!==0?this.queryRenderedFeatures(c.point,{layers:m}):[];_.length?o||(o=!0,n.call(this,new hi(h,this,c.originalEvent,{features:_}))):o=!1},mouseout:()=>{o=!1}}}}if(h==="mouseleave"||h==="mouseout"){let o=!1;return{layers:e,listener:n,delegates:{mousemove:m=>{let _=e.filter((y=>this.getLayer(y)));(_.length!==0?this.queryRenderedFeatures(m.point,{layers:_}):[]).length?o=!0:o&&(o=!1,n.call(this,new hi(h,this,m.originalEvent)))},mouseout:m=>{o&&(o=!1,n.call(this,new hi(h,this,m.originalEvent)))}}}}{let o=a=>{let c=e.filter((_=>this.getLayer(_))),m=c.length!==0?this.queryRenderedFeatures(a.point,{layers:c}):[];m.length&&(a.features=m,n.call(this,a),delete a.features)};return{layers:e,listener:n,delegates:{[h]:o}}}}_saveDelegatedListener(h,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(e)}_removeDelegatedListener(h,e,n){if(!this._delegatedListeners||!this._delegatedListeners[h])return;let o=this._delegatedListeners[h];for(let a=0;a<o.length;a++){let c=o[a];if(c.listener===n&&c.layers.length===e.length&&c.layers.every((m=>e.includes(m)))){for(let m in c.delegates)this.off(m,c.delegates[m]);return void o.splice(a,1)}}}on(h,e,n){if(n===void 0)return super.on(h,e);let o=this._createDelegatedListener(h,typeof e=="string"?[e]:e,n);this._saveDelegatedListener(h,o);for(let a in o.delegates)this.on(a,o.delegates[a]);return this}once(h,e,n){if(n===void 0)return super.once(h,e);let o=typeof e=="string"?[e]:e,a=this._createDelegatedListener(h,o,n);for(let c in a.delegates){let m=a.delegates[c];a.delegates[c]=(..._)=>{this._removeDelegatedListener(h,o,n),m(..._)}}this._saveDelegatedListener(h,a);for(let c in a.delegates)this.once(c,a.delegates[c]);return this}off(h,e,n){return n===void 0?super.off(h,e):(this._removeDelegatedListener(h,typeof e=="string"?[e]:e,n),this)}queryRenderedFeatures(h,e){if(!this.style)return[];let n,o=h instanceof p.P||Array.isArray(h),a=o?h:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(o?{}:h)||{},a instanceof p.P||typeof a[0]=="number")n=[p.P.convert(a)];else{let c=p.P.convert(a[0]),m=p.P.convert(a[1]);n=[c,new p.P(m.x,c.y),m,new p.P(c.x,m.y),c]}return this.style.queryRenderedFeatures(n,e,this.transform)}querySourceFeatures(h,e){return this.style.querySourceFeatures(h,e)}setStyle(h,e){return(e=p.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(h,e))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){let e=this._locale[h];if(e==null)throw new Error(`Missing UI string '${h}'`);return e}_updateStyle(h,e){if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(h,e)));let n=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new js(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,e,n):this.style.loadJSON(h,e,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new js(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,e){if(typeof h=="string"){let n=this._requestManager.transformRequest(h,"Style");p.h(n,new AbortController).then((o=>{this._updateDiff(o.data,e)})).catch((o=>{o&&this.fire(new p.j(o))}))}else typeof h=="object"&&this._updateDiff(h,e)}_updateDiff(h,e){try{this.style.setState(h,e)&&this._update(!0)}catch(n){p.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(h,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():p.w("There is no style added to the map.")}addSource(h,e){return this._lazyInitEmptyStyle(),this.style.addSource(h,e),this._update(!0)}isSourceLoaded(h){let e=this.style&&this.style.sourceCaches[h];if(e!==void 0)return e.loaded();this.fire(new p.j(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){let e=this.style.sourceCaches[h.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&e.reload();for(let n in this.style._layers){let o=this.style._layers[n];o.type==="hillshade"&&o.source===h.source&&p.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Ta(this.painter,e,h),this.painter.renderToTexture=new Ml(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==h.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new p.k("terrain",{terrain:h})),this}getTerrain(){var h,e;return(e=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&e!==void 0?e:null}areTilesLoaded(){let h=this.style&&this.style.sourceCaches;for(let e in h){let n=h[e]._tiles;for(let o in n){let a=n[o];if(a.state!=="loaded"&&a.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}addImage(h,e,n={}){let{pixelRatio:o=1,sdf:a=!1,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b}=n;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||p.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new p.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{let{width:S,height:T,data:E}=e,L=e;return this.style.addImage(h,{data:new p.R({width:S,height:T},new Uint8Array(E)),pixelRatio:o,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:a,version:0,userImage:L}),L.onAdd&&L.onAdd(this,h),this}}{let{width:S,height:T,data:E}=pe.getImageData(e);this.style.addImage(h,{data:new p.R({width:S,height:T},E),pixelRatio:o,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:a,version:0})}}updateImage(h,e){let n=this.style.getImage(h);if(!n)return this.fire(new p.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let o=e instanceof HTMLImageElement||p.b(e)?pe.getImageData(e):e,{width:a,height:c,data:m}=o;if(a===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(a!==n.data.width||c!==n.data.height)return this.fire(new p.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));let _=!(e instanceof HTMLImageElement||p.b(e));return n.data.replace(m,_),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new p.j(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return et.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,e){return this._lazyInitEmptyStyle(),this.style.addLayer(h,e),this._update(!0)}moveLayer(h,e){return this.style.moveLayer(h,e),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,e,n){return this.style.setLayerZoomRange(h,e,n),this._update(!0)}setFilter(h,e,n={}){return this.style.setFilter(h,e,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,e,n,o={}){return this.style.setPaintProperty(h,e,n,o),this._update(!0)}getPaintProperty(h,e){return this.style.getPaintProperty(h,e)}setLayoutProperty(h,e,n,o={}){return this.style.setLayoutProperty(h,e,n,o),this._update(!0)}getLayoutProperty(h,e){return this.style.getLayoutProperty(h,e)}setGlyphs(h,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,e,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,e,n,(o=>{o||this._update(!0)})),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,e,(n=>{n||this._update(!0)})),this}setLight(h,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(h){return this._lazyInitEmptyStyle(),this.style.setSky(h),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,e){return this.style.setFeatureState(h,e),this._update()}removeFeatureState(h,e){return this.style.removeFeatureState(h,e),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,e=0;return this._container&&(h=this._container.clientWidth||400,e=this._container.clientHeight||300),[h,e]}_setupContainer(){let h=this._container;h.classList.add("maplibregl-map");let e=this._canvasContainer=K.create("div","maplibregl-canvas-container",h);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=K.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");let n=this._containerDimensions(),o=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],o);let a=this._controlContainer=K.create("div","maplibregl-control-container",h),c=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((m=>{c[m]=K.create("div",`maplibregl-ctrl-${m} `,a)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,e,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*e),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${e}px`}_setupPainter(){let h={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},e=null;this._canvas.addEventListener("webglcontextcreationerror",(o=>{e={requestedAttributes:h},o&&(e.statusMessage=o.statusMessage,e.type=o.type)}),{once:!0});let n=this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h);if(!n){let o="Failed to initialize WebGL";throw e?(e.message=o,new Error(JSON.stringify(e))):new Error(o)}this.painter=new no(n,this.transform),ht.testSupport(n)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(h){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_render(h){let e=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let a=this.transform.zoom,c=pe.now();this.style.zoomHistory.update(a,c);let m=new p.z(a,{now:c,fadeDuration:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),_=m.crossFadingFactor();_===1&&_===this._crossFadingFactor||(n=!0,this._crossFadingFactor=_),this.style.update(m)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,e,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:e,showPadding:this.showPadding}),this.fire(new p.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.bf.mark(p.bg.load),this.fire(new p.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let o=this._sourcesDirty||this._styleDirty||this._placementDirty;return o||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new p.k("idle")),!this._loaded||this._fullyLoaded||o||(this._fullyLoaded=!0,p.bf.mark(p.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(let n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),et.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();let e=this.painter.context.gl.getExtension("WEBGL_lose_context");e?.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),K.remove(this._canvasContainer),K.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,pe.frameAsync(this._frameRequest).then((h=>{p.bf.frame(h),this._frameRequest=null,this._render(h)})).catch((()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get version(){return Al}getCameraTargetElevation(){return this.transform.elevation}},I.MapMouseEvent=hi,I.MapTouchEvent=un,I.MapWheelEvent=wl,I.Marker=go,I.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{let e=this._map.getZoom(),n=e===this._map.getMaxZoom(),o=e===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.toString())},this._rotateCompassArrow=()=>{let e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=e},this._setButtonTitle=(e,n)=>{let o=this._map._getUIString(`NavigationControl.${n}`);e.title=o,e.setAttribute("aria-label",o)},this.options=p.e({},Dc,h),this._container=K.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),K.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),K.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})})),this._compassIcon=K.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Rc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){K.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,e){let n=K.create("button",h,this._container);return n.type="button",n.addEventListener("click",e),n}},I.Popup=class extends p.E{constructor(h){super(),this.remove=()=>(this._content&&K.remove(this._content),this._container&&(K.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new p.k("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{var n;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=K.create("div","maplibregl-popup",this._map.getContainer()),this._tip=K.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let _ of this.options.className.split(" "))this._container.classList.add(_);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?At(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.wrap(),this._trackPointer&&!e)return;let o=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationPoint(this._lngLat));let a=this.options.anchor,c=yo(this.options.offset);if(!a){let _=this._container.offsetWidth,y=this._container.offsetHeight,b;b=o.y+c.bottom.y<y?["top"]:o.y>this._map.transform.height-y?["bottom"]:[],o.x<_/2?b.push("left"):o.x>this._map.transform.width-_/2&&b.push("right"),a=b.length===0?"bottom":b.join("-")}let m=o.add(c[a]);this.options.subpixelPositioning||(m=m.round()),K.setTransform(this._container,`${qn[a]} translate(${m.x}px,${m.y}px)`),mo(this._container,a,"popup")},this._onClose=()=>{this.remove()},this.options=p.e(Object.create(je),h)}addTo(h){return this._map&&this.remove(),this._map=h,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new p.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=p.N.convert(h),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){let e=document.createDocumentFragment(),n=document.createElement("body"),o;for(n.innerHTML=h;o=n.firstChild,o;)e.appendChild(o);return this.setDOMContent(e)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=K.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=K.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;let h=this._container.querySelector(_o);h&&h.focus()}},I.RasterDEMTileSource=Bt,I.RasterTileSource=mt,I.ScaleControl=class{constructor(h){this._onMove=()=>{Es(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Es(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Ir),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=K.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){K.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},I.ScrollZoomHandler=lr,I.Style=js,I.TerrainControl=class{constructor(h){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=h}onAdd(h){return this._map=h,this._container=K.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=K.create("button","maplibregl-ctrl-terrain",this._container),K.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(){K.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},I.TwoFingersTouchPitchHandler=Nn,I.TwoFingersTouchRotateHandler=ya,I.TwoFingersTouchZoomHandler=ga,I.TwoFingersTouchZoomRotateHandler=va,I.VectorTileSource=cs,I.VideoSource=wn,I.addSourceType=(h,e)=>p._(void 0,void 0,void 0,(function*(){if(ds(h))throw new Error(`A source type called "${h}" already exists.`);((n,o)=>{us[n]=o})(h,e)})),I.clearPrewarmedResources=function(){let h=Di;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(Or),Di=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()"))},I.getMaxParallelImageRequests=function(){return p.a.MAX_PARALLEL_IMAGE_REQUESTS},I.getRTLTextPluginStatus=function(){return vr().getRTLTextPluginStatus()},I.getVersion=function(){return Pa},I.getWorkerCount=function(){return yr.workerCount},I.getWorkerUrl=function(){return p.a.WORKER_URL},I.importScriptInWorkers=function(h){return ls().broadcast("IS",h)},I.prewarm=function(){Yr().acquire(Or)},I.setMaxParallelImageRequests=function(h){p.a.MAX_PARALLEL_IMAGE_REQUESTS=h},I.setRTLTextPlugin=function(h,e){return vr().setRTLTextPlugin(h,e)},I.setWorkerCount=function(h){yr.workerCount=h},I.setWorkerUrl=function(h){p.a.WORKER_URL=h}}));var ce=R;return ce}))});var Bm={};im(Bm,{createImdMap:()=>ip});var Oo=tc(Ha(),1);function Wa(R,X){switch(R){case"all":return"2011";case"england":return X;case"wales":case"scotland":case"northern_ireland":return"2011";default:return"2011"}}function Ph(R,X){return Wa(R,X)!==X}var rs=[{tier:"z0_4",minzoom:0,maxzoom:5},{tier:"z5_7",minzoom:5,maxzoom:8},{tier:"z8_10",minzoom:8,maxzoom:24}];function Xa(R,X){return`public.uk_master_${R}_${X}`}function Bo(R,X){return`${R.replace(/\/$/,"")}/${X}/{z}/{x}/{y}.pbf`}function Mh(R){return R==="all"?null:["==",["get","nation"],R]}function Pd(R="all",X="2021"){return{nation:R,era:X,effectiveEra:Wa(R,X),hasPatients:!1,hasLeadCentre:!1,overlays:{localAuthority:!1,nhser:!1,icb:!1,lhb:!1}}}var Ka=tc(Ha(),1);function ic(R){return`rcpch-imd-${R}`}var ug=rs.map(R=>ic(R.tier)),ns="rcpch-imd-patients",ss="rcpch-imd-lead-centre";function Ah(R,X,re){for(let{tier:ce}of rs){let I=ic(ce),p=Xa(re,ce),Se=Bo(X,p),Ce=R.getSource(I);Ce instanceof Ka.VectorTileSource?Ce.setTiles([Se]):(Ce&&R.removeSource(I),R.addSource(I,{type:"vector",tiles:[Se],minzoom:0,maxzoom:14}))}}function Eh(R,X){let re={type:"FeatureCollection",features:X},ce=R.getSource(ns);ce instanceof Ka.GeoJSONSource?ce.setData(re):(ce&&R.removeSource(ns),R.addSource(ns,{type:"geojson",data:re}))}function kh(R,X){let re={type:"FeatureCollection",features:X?[X]:[]},ce=R.getSource(ss);ce instanceof Ka.GeoJSONSource?ce.setData(re):(ce&&R.removeSource(ss),R.addSource(ss,{type:"geojson",data:re}))}var Ns="#0d0d58",Md="#e00087";var nm="#41b6e6",sm="#3d3d3d",os={england:"#d7191c",wales:"#1a9641",scotland:"#2b83ba",northern_ireland:"#7f7f7f",all:"#d7191c"};function rc(R,X,re){return Math.min(re,Math.max(X,R))}function om(R){let X=R.trim();if(/^#[0-9a-fA-F]{6}$/.test(X))return X;if(/^#[0-9a-fA-F]{3}$/.test(X)){let re=X[1],ce=X[2],I=X[3];return`#${re}${re}${ce}${ce}${I}${I}`}return null}function am(R){let X=om(R);if(!X)return null;let re=parseInt(X.slice(1),16);return{r:re>>16&255,g:re>>8&255,b:re&255}}function lm(R,X,re){let ce=rc(Math.round(R),0,255).toString(16).padStart(2,"0"),I=rc(Math.round(X),0,255).toString(16).padStart(2,"0"),p=rc(Math.round(re),0,255).toString(16).padStart(2,"0");return`#${ce}${I}${p}`}function cm(R,X,re){let ce=R/255,I=X/255,p=re/255,Se=Math.max(ce,I,p),Ce=Math.min(ce,I,p),$e=0,pe=(Se+Ce)/2,K=Se-Ce;if(K!==0)switch(Se){case ce:$e=((I-p)/K+(I<p?6:0))/6;break;case I:$e=((p-ce)/K+2)/6;break;default:$e=((ce-I)/K+4)/6;break}let ht=K===0?0:K/(1-Math.abs(2*pe-1));return{h:$e,s:ht,l:pe}}function hm(R,X,re){let ce=(1-Math.abs(2*re-1))*X,I=R*6,p=ce*(1-Math.abs(I%2-1)),Se=0,Ce=0,$e=0;I>=0&&I<1?(Se=ce,Ce=p,$e=0):I<2?(Se=p,Ce=ce,$e=0):I<3?(Se=0,Ce=ce,$e=p):I<4?(Se=0,Ce=p,$e=ce):I<5?(Se=p,Ce=0,$e=ce):(Se=ce,Ce=0,$e=p);let pe=re-ce/2;return{r:(Se+pe)*255,g:(Ce+pe)*255,b:($e+pe)*255}}function nc(R){let X=am(R);if(!X)return Array(10).fill("#cccccc");let{h:re,s:ce,l:I}=cm(X.r,X.g,X.b),p=10,Se=.34,Ce=(p-1)/2;return Array.from({length:p},($e,pe)=>{let K=(pe-Ce)/Ce,ht=rc(I+K*Se,.08,.92),{r:Dt,g:Nt,b:Jt}=hm(re,ce,ht);return lm(Dt,Nt,Jt)})}var zh={choropleth:{decileColorsByNation:{},baseColorByNation:{england:os.england,wales:os.wales,scotland:os.scotland,northern_ireland:os.northern_ireland},fallbackDecileColors:nc(os.england),fillOpacity:.7,borderColor:"#ffffff",borderWidth:.5,hoverBorderColor:Ns,hoverBorderWidth:2},boundaries:{localAuthorityColor:Ns,localAuthorityWidth:1,nhserColor:Md,nhserWidth:1.5,icbColor:sm,icbWidth:1,lhbColor:nm,lhbWidth:1},patients:{circleColor:Ns,circleRadius:5,circleStrokeColor:"#ffffff",circleStrokeWidth:1,circleOpacity:.8,colorByGroup:{}},leadCentre:{color:Md,radius:10,strokeColor:"#ffffff",strokeWidth:2},tooltip:{backgroundColor:Ns,textColor:"#ffffff",borderColor:Ns,borderRadius:4,areaLabel:"Area",decileLabel:"IMD decile",nationLabel:"Nation",patientLabel:"Patient",leadCentreLabel:"Lead centre",patientTooltipText:"{{patientLabel}}",leadCentreTooltipText:"{{leadCentreLabel}}: {{label}}"},legend:{backgroundColor:"#ffffff",textColor:Ns,borderColor:"#d8dde6",borderRadius:8,fontSize:13,fontFamily:"system-ui, -apple-system, Segoe UI, Roboto, sans-serif",width:220,boxShadow:"0 6px 18px rgba(0, 0, 0, 0.12)",toggleOnColor:Ns,toggleOffColor:"#6b7280"}};function Lh(R,X){return X?{choropleth:{...R.choropleth,...X.choropleth},boundaries:{...R.boundaries,...X.boundaries},patients:{...R.patients,...X.patients},leadCentre:{...R.leadCentre,...X.leadCentre},tooltip:{...R.tooltip,...X.tooltip},legend:{...R.legend,...X.legend}}:R}function Fo(R,X){let ce=(X.choropleth.decileColorsByNation??{})[R];if(ce&&ce.length===10)return ce;let p=(X.choropleth.baseColorByNation??{})[R];if(p)return nc(p);let Se=os[R]??os.england;return nc(Se)??X.choropleth.fallbackDecileColors??nc(os.england)}function Ja(R){return`rcpch-imd-fill-${R}`}function sc(R){return`rcpch-imd-line-${R}`}var Dh=rs.flatMap(R=>[Ja(R.tier),sc(R.tier)]),gr="rcpch-imd-patients",Ar="rcpch-imd-lead-centre",Ed=Ja("z8_10");function Ad(R){let X=R[0]??"#cccccc";return["step",["get","imd_decile"],X,2,R[1]??X,3,R[2]??X,4,R[3]??X,5,R[4]??X,6,R[5]??X,7,R[6]??X,8,R[7]??X,9,R[8]??X,10,R[9]??X]}function kd(R,X){if(R!=="all")return Ad(Fo(R,X));let re=["england","wales","scotland","northern_ireland"].flatMap(ce=>[ce,Ad(Fo(ce,X))]);return["match",["get","nation"],...re,Fo("england",X)[0]??"#cccccc"]}function um(R){for(let X of R.getStyle().layers??[])if(X.type==="symbol")return X.id}function dm(R){let X=R.patients.circleColor??"#0d0d58",re=R.patients.colorByGroup??{},ce=Object.entries(re).filter(([I,p])=>I&&p);return ce.length?["match",["coalesce",["to-string",["get","group"]],""],...ce.flatMap(([I,p])=>[I,p]),X]:X}function Rh(R,X,re,ce){Bh(R);let I=Mh(X),p=I?{filter:I}:{},Se=um(R);for(let{tier:Ce,minzoom:$e,maxzoom:pe}of rs){let K=ic(Ce),ht=Xa(re,Ce),Dt=kd(X,ce);R.addLayer({id:Ja(Ce),type:"fill",source:K,"source-layer":ht,minzoom:$e,maxzoom:pe,...p,paint:{"fill-color":Dt,"fill-opacity":ce.choropleth.fillOpacity??.7}},Se),R.addLayer({id:sc(Ce),type:"line",source:K,"source-layer":ht,minzoom:$e,maxzoom:pe,...p,paint:{"line-color":ce.choropleth.borderColor??"#ffffff","line-width":ce.choropleth.borderWidth??.5}},Se)}}function Bh(R){for(let X of Dh)R.getLayer(X)&&R.removeLayer(X)}function zd(R,X,re){let ce=kd(X,re);for(let{tier:I}of rs){let p=Ja(I),Se=sc(I);R.getLayer(p)&&(R.setPaintProperty(p,"fill-color",ce),R.setPaintProperty(p,"fill-opacity",re.choropleth.fillOpacity??.7),R.setPaintProperty(Se,"line-color",re.choropleth.borderColor??"#ffffff"),R.setPaintProperty(Se,"line-width",re.choropleth.borderWidth??.5))}}function Ld(R,X,re){let ce=Mh(X);for(let{tier:I}of rs){let p=Ja(I),Se=sc(I);if(!R.getLayer(p))continue;let Ce=Xa(re,I);R.setFilter(p,ce),R.setFilter(Se,ce)}}function oc(R,X){let re=X.patients,ce=dm(X);R.getLayer(gr)?(R.setPaintProperty(gr,"circle-color",ce),R.setPaintProperty(gr,"circle-radius",re.circleRadius??5),R.setPaintProperty(gr,"circle-stroke-color",re.circleStrokeColor??"#ffffff"),R.setPaintProperty(gr,"circle-stroke-width",re.circleStrokeWidth??1),R.setPaintProperty(gr,"circle-opacity",re.circleOpacity??.8)):R.addLayer({id:gr,type:"circle",source:ns,paint:{"circle-color":ce,"circle-radius":re.circleRadius??5,"circle-stroke-color":re.circleStrokeColor??"#ffffff","circle-stroke-width":re.circleStrokeWidth??1,"circle-opacity":re.circleOpacity??.8}})}function Dd(R){R.getLayer(gr)&&R.removeLayer(gr)}function ac(R,X){let re=X.leadCentre;R.getLayer(Ar)?(R.setPaintProperty(Ar,"circle-color",re.color??"#e00087"),R.setPaintProperty(Ar,"circle-radius",re.radius??10),R.setPaintProperty(Ar,"circle-stroke-color",re.strokeColor??"#ffffff"),R.setPaintProperty(Ar,"circle-stroke-width",re.strokeWidth??2)):R.addLayer({id:Ar,type:"circle",source:ss,paint:{"circle-color":re.color??"#e00087","circle-radius":re.radius??10,"circle-stroke-color":re.strokeColor??"#ffffff","circle-stroke-width":re.strokeWidth??2}})}function Rd(R){R.getLayer(Ar)&&R.removeLayer(Ar)}var pm={code:["code","lsoa_code","LSOA11CD","lsoa11cd","LSOA21CD","lsoa21cd"],area_name:["area_name","LSOA11NM","lsoa11nm","LSOA21NM","lsoa21nm","name"],imd_decile:["imd_decile","IMD_Decile","IMDDecile","decile","imd_rank_decile"],imd_rank:["imd_rank","IMD_Rank","rank"],imd_year:["imd_year","IMD_Year"],nation:["nation","Nation","country","Country"],year:["year","Year"],la_code:["la_code","LAD_code","lad_code"],la_name:["la_name","LAD_name","lad_name"],nhser_code:["nhser_code","NHSER_code"],nhser_name:["nhser_name","NHSER_name"],icb_code:["icb_code","ICB_code"],icb_name:["icb_name","ICB_name"],lhb_code:["lhb_code","LHB_code"],lhb_name:["lhb_name","LHB_name"]};function _r(R,X){if(!R)return;if(X in R)return R[X];let re=pm[X];if(re){for(let I of re)if(I in R)return R[I]}let ce=X.toLowerCase();for(let[I,p]of Object.entries(R))if(I.toLowerCase()===ce)return p}function Fd(R,X){return R.replace(/{{\s*([a-zA-Z0-9_]+)\s*}}/g,(re,ce)=>{let I=X[ce];return I==null?"":String(I)})}function fm(R,X){let re=X.tooltip,ce=_r(R,"area_name")??"Unknown area",I=_r(R,"imd_decile")??"\u2013",p=_r(R,"nation")??"\u2013",Se=_r(R,"year")??"\u2013",Ce=_r(R,"imd_year")??"\u2013",$e=re.backgroundColor??"#0d0d58",pe=re.textColor??"#ffffff",K=re.borderRadius??4;return`<div style="background:${$e};color:${pe};padding:8px 12px;border-radius:${K}px;font-size:13px;line-height:1.6;font-family:sans-serif;">
578
- <strong style="display:block;margin-bottom:2px;">${String(ce)}</strong>
579
- <span>LSOA year: ${String(Se)}</span><br/>
580
- <span>${re.decileLabel??"IMD decile"}: <strong>${String(I)}</strong></span><br/>
581
- <span>IMD year: ${String(Ce)}</span><br/>
582
- <span>${re.nationLabel??"Nation"}: ${String(p)}</span>
583
- </div>`}function mm(R,X){let re=X.tooltip,ce=_r(R,"id")??"",I=_r(R,"group")??"",p=re.backgroundColor??"#0d0d58",Se=re.textColor??"#ffffff",Ce=re.borderRadius??4,$e=re.patientLabel??"Patient",pe=re.patientTooltipText??"{{patientLabel}}",K={...R??{},patientLabel:$e,id:ce,group:I},ht=Fd(pe,K);return`<div style="background:${p};color:${Se};padding:8px 12px;border-radius:${Ce}px;font-size:13px;line-height:1.6;font-family:sans-serif;">
584
- <span>${ht}</span>
585
- </div>`}function gm(R,X){let re=X.tooltip,ce=_r(R,"label")??"Lead centre",I=re.backgroundColor??"#0d0d58",p=re.textColor??"#ffffff",Se=re.borderRadius??4,Ce=re.leadCentreLabel??"Lead centre",$e=Fd(re.leadCentreTooltipText??"{{leadCentreLabel}}: {{label}}",{leadCentreLabel:Ce,label:ce});return`<div style="background:${I};color:${p};padding:8px 12px;border-radius:${Se}px;font-size:13px;line-height:1.6;font-family:sans-serif;">
586
- <span>${$e}</span>
587
- </div>`}function Bd(R){let X=R.properties??{},re=_r(X,"imd_decile");return{lsoaCode:String(_r(X,"code")??""),lsoaName:String(_r(X,"area_name")??""),imdDecile:typeof re=="number"?re:void 0,nation:String(_r(X,"nation")??""),rawProperties:X}}function Od(R,X,re,ce){let I=Dh.filter(p=>p.startsWith("rcpch-imd-fill-"));for(let p of I)R.on("mousemove",p,Se=>{let Ce=R.queryRenderedFeatures(Se.point,{layers:[p]});if(!Ce.length)return;R.getCanvas().style.cursor="pointer";let $e=Ce[0];X.setLngLat(Se.lngLat).setHTML(fm($e.properties,re)).addTo(R),ce.onAreaHover?.(Bd($e))}),R.on("mouseleave",p,()=>{R.getCanvas().style.cursor="",X.remove()}),R.on("click",p,Se=>{let Ce=R.queryRenderedFeatures(Se.point,{layers:[p]});Ce.length&&ce.onAreaClick?.(Bd(Ce[0]))})}function Fh(R,X,re){R.on("mousemove",gr,ce=>{let I=R.queryRenderedFeatures(ce.point,{layers:[gr]});if(!I.length)return;let p=I[0];R.getCanvas().style.cursor="pointer",X.setLngLat(ce.lngLat).setHTML(mm(p.properties,re)).addTo(R)}),R.on("mouseleave",gr,()=>{R.getCanvas().style.cursor="",X.remove()})}function Oh(R,X,re){R.on("mousemove",Ar,ce=>{let I=R.queryRenderedFeatures(ce.point,{layers:[Ar]});if(!I.length)return;let p=I[0];R.getCanvas().style.cursor="pointer",X.setLngLat(ce.lngLat).setHTML(gm(p.properties,re)).addTo(R)}),R.on("mouseleave",Ar,()=>{R.getCanvas().style.cursor="",X.remove()})}function Nh(R,X){let re=[];return(typeof R!="number"||isNaN(R)||R<-90||R>90)&&re.push(`Invalid latitude: ${String(R)}. Must be a number between -90 and 90.`),(typeof X!="number"||isNaN(X)||X<-180||X>180)&&re.push(`Invalid longitude: ${String(X)}. Must be a number between -180 and 180.`),{valid:re.length===0,errors:re}}var lc={minLat:49.5,maxLat:61.5,minLon:-8.7,maxLon:2.1};function _m(R,X){return R>=lc.minLat&&R<=lc.maxLat&&X>=lc.minLon&&X<=lc.maxLon}function Nd(R){if(!R||typeof R!="object")return{point:null,errors:["Record is not an object."]};let X=R,re=X.lat??X.latitude??X.LAT,ce=X.lon??X.lng??X.longitude??X.LON,{valid:I,errors:p}=Nh(re,ce);if(!I)return{point:null,errors:p};if(!_m(re,ce))return{point:null,errors:[`Point (${String(re)}, ${String(ce)}) is outside UK bounds and will be skipped.`]};let Se=new Set(["lat","lon","id","weight","group","latitude","longitude","lng","LAT","LON"]);return{point:{lat:re,lon:ce,id:X.id!==void 0?String(X.id):void 0,weight:typeof X.weight=="number"?X.weight:void 0,group:typeof X.group=="string"?X.group:void 0,properties:Object.fromEntries(Object.entries(X).filter(([$e])=>!Se.has($e)))},errors:[]}}function ym(R){return typeof R=="object"&&R!==null&&R.type==="FeatureCollection"&&Array.isArray(R.features)}function xm(R){return typeof R=="object"&&R!==null&&R.type==="Feature"}function Vd(R,X){let re=[],ce=[],I=X?.strict===!0,p;if(ym(R))p=R.features.map(Se=>({lat:Se.geometry.coordinates[1],lon:Se.geometry.coordinates[0],...Se.properties}));else if(Array.isArray(R))p=R.map(Se=>xm(Se)?{lat:Se.geometry.coordinates[1],lon:Se.geometry.coordinates[0],...Se.properties}:Se);else{if(I)throw new Error("[rcpch-imd-map] PatientInput must be an array or GeoJSON FeatureCollection.");return ce.push({code:"INVALID_INPUT",message:"PatientInput must be an array or GeoJSON FeatureCollection."}),{features:re,warnings:ce}}for(let Se=0;Se<p.length;Se++){let{point:Ce,errors:$e}=Nd(p[Se]);if(!Ce){if(I)throw new Error(`[rcpch-imd-map] Patient record at index ${Se} is invalid: ${$e.join("; ")}`);ce.push({code:"INVALID_PATIENT_POINT",message:`Patient record at index ${Se} is invalid and will be skipped: ${$e.join("; ")}`,details:{index:Se,errors:$e}});continue}for(let pe of $e)ce.push({code:"PATIENT_POINT_WARNING",message:pe,details:{index:Se}});re.push({type:"Feature",geometry:{type:"Point",coordinates:[Ce.lon,Ce.lat]},properties:{id:Ce.id??`patient-${Se}`,weight:Ce.weight??1,group:Ce.group??null,...Ce.properties}})}return{features:re,warnings:ce}}function Ud(R){if(!R||typeof R!="object")return null;let X,re,ce="Lead centre";if(R.type==="Feature"&&R.geometry?.type==="Point")[re,X]=R.geometry.coordinates,ce=R.properties?.label??ce;else{let p=R;X=p.lat??p.latitude,re=p.lon??p.lng??p.longitude,ce=p.label??ce}let{valid:I}=Nh(X,re);return I?{type:"Feature",geometry:{type:"Point",coordinates:[re,X]},properties:{label:ce}}:null}var jd=tc(Ha(),1);var cc="rcpch-imd-la-overlay",Vs="rcpch-imd-la-overlay-line",vm="public.la_tiles",bm="public.la_tiles";function $d(R,X,re){let ce=Bo(X,vm),I=R.getSource(cc);if(I instanceof jd.VectorTileSource?I.setTiles([ce]):(I&&R.removeSource(cc),R.addSource(cc,{type:"vector",tiles:[ce],minzoom:0,maxzoom:14})),R.getLayer(Vs)){R.setPaintProperty(Vs,"line-color",re.boundaries.localAuthorityColor??"#0d0d58"),R.setPaintProperty(Vs,"line-width",re.boundaries.localAuthorityWidth??1),R.setLayoutProperty(Vs,"visibility","visible");return}R.addLayer({id:Vs,type:"line",source:cc,"source-layer":bm,paint:{"line-color":re.boundaries.localAuthorityColor??"#0d0d58","line-width":re.boundaries.localAuthorityWidth??1},layout:{visibility:"visible"}})}function qd(R){R.getLayer(Vs)&&R.setLayoutProperty(Vs,"visibility","none")}var Zd=tc(Ha(),1);var wm="rcpch-imd-nhser-overlay",Gd="rcpch-imd-nhser-overlay-line",Sm="rcpch-imd-icb-overlay",Hd="rcpch-imd-icb-overlay-line",Tm="rcpch-imd-lhb-overlay",Wd="rcpch-imd-lhb-overlay-line",Im="public.nhser_tiles_2021",Cm="public.nhser_tiles_2021",Pm="public.icb_tiles_2023",Mm="public.icb_tiles_2023",Am="public.lhb_tiles_2022",Em="public.lhb_tiles_2022";function Vh(R,X,re){let ce=Bo(X,re.fullTableName),I=R.getSource(re.sourceId);if(I instanceof Zd.VectorTileSource?I.setTiles([ce]):(I&&R.removeSource(re.sourceId),R.addSource(re.sourceId,{type:"vector",tiles:[ce],minzoom:0,maxzoom:14})),R.getLayer(re.layerId)){R.setPaintProperty(re.layerId,"line-color",re.lineColor),R.setPaintProperty(re.layerId,"line-width",re.lineWidth),R.setLayoutProperty(re.layerId,"visibility","visible");return}R.addLayer({id:re.layerId,type:"line",source:re.sourceId,"source-layer":re.sourceLayer,paint:{"line-color":re.lineColor,"line-width":re.lineWidth},layout:{visibility:"visible"}})}function Xd(R,X,re){Vh(R,X,{sourceId:wm,layerId:Gd,fullTableName:Im,sourceLayer:Cm,lineColor:re.boundaries.nhserColor??"#e00087",lineWidth:re.boundaries.nhserWidth??1.5})}function Kd(R,X,re){Vh(R,X,{sourceId:Sm,layerId:Hd,fullTableName:Pm,sourceLayer:Mm,lineColor:re.boundaries.icbColor??"#57c7f2",lineWidth:re.boundaries.icbWidth??1})}function Jd(R,X,re){Vh(R,X,{sourceId:Tm,layerId:Wd,fullTableName:Am,sourceLayer:Em,lineColor:re.boundaries.lhbColor??"#57c7f2",lineWidth:re.boundaries.lhbWidth??1})}function Uh(R,X){R.getLayer(X)&&R.setLayoutProperty(X,"visibility","none")}function Yd(R){Uh(R,Gd)}function Qd(R){Uh(R,Hd)}function ep(R){Uh(R,Wd)}function km(R,X){let re=R.nation,ce=re==="all"||re==="england",I=re==="all"||re==="england",p=re==="all"||re==="wales";return[{key:"nhser",label:"NHS England regions",isVisible:X.nhser,isEnabled:ce,isActive:R.overlays.nhser,disabledNote:"England only"},{key:"icb",label:"ICBs",isVisible:X.icb,isEnabled:I,isActive:R.overlays.icb,disabledNote:"England only"},{key:"localAuthority",label:"Local authorities",isVisible:X.localAuthority,isEnabled:!0,isActive:R.overlays.localAuthority},{key:"lhb",label:"Local health boards",isVisible:X.lhb,isEnabled:p,isActive:R.overlays.lhb,disabledNote:"Wales only"}].filter(Ce=>Ce.isVisible)}function zm(R,X){switch(R.style.top="",R.style.right="",R.style.bottom="",R.style.left="",X){case"top-left":R.style.top="12px",R.style.left="12px";break;case"bottom-left":R.style.bottom="12px",R.style.left="12px";break;case"bottom-right":R.style.bottom="12px",R.style.right="12px";break;default:R.style.top="12px",R.style.right="12px";break}}function tp(R){window.getComputedStyle(R.container).position==="static"&&(R.container.style.position="relative");let re=R.state,ce=R.style,I=R.collapsed,p=document.createElement("div");p.setAttribute("data-rcpch-legend","true"),p.style.position="absolute",p.style.zIndex="5",p.style.pointerEvents="auto",zm(p,R.position);let Se=document.createElement("div"),Ce=document.createElement("button"),$e=document.createElement("span"),pe=document.createElement("span"),K=document.createElement("div"),ht=document.createElement("div");Ce.type="button",Ce.setAttribute("aria-expanded",String(!I)),$e.textContent=R.title,pe.textContent=I?"+":"-",Ce.appendChild($e),Ce.appendChild(pe),Se.appendChild(Ce),Se.appendChild(K),Se.appendChild(ht),p.appendChild(Se),R.container.appendChild(p);function Dt(){let et=ce.legend,He=et?.backgroundColor??"#ffffff",Je=et?.textColor??"#0d0d58",Pt=et?.borderColor??"#d8dde6",Mt=et?.borderRadius??8,Vt=et?.fontSize??13,_t=et?.fontFamily??"system-ui, -apple-system, Segoe UI, Roboto, sans-serif",yi=et?.width??220,Ye=et?.boxShadow??"0 6px 18px rgba(0, 0, 0, 0.12)";Se.style.background=He,Se.style.color=Je,Se.style.border=`1px solid ${Pt}`,Se.style.borderRadius=`${Mt}px`,Se.style.width=`${yi}px`,Se.style.boxShadow=Ye,Se.style.overflow="hidden",Ce.style.width="100%",Ce.style.border="0",Ce.style.background="transparent",Ce.style.color=Je,Ce.style.display="flex",Ce.style.alignItems="center",Ce.style.justifyContent="space-between",Ce.style.padding="10px 12px",Ce.style.cursor="pointer",Ce.style.fontWeight="600",Ce.style.fontSize=`${Vt}px`,Ce.style.fontFamily=_t,Ce.style.textAlign="left",K.style.padding="0 12px 10px",K.style.display=I?"none":"block",K.style.fontFamily=_t,K.style.fontSize=`${Vt}px`,ht.style.padding="0 12px 10px",ht.style.display=I?"none":"block",ht.style.fontFamily=_t,ht.style.fontSize=`${Math.max(Vt-1,11)}px`,ht.style.borderTop=`1px solid ${Pt}`}function Nt(){K.innerHTML="",ht.innerHTML="";let et=km(re,R.visibility);if(!et.length){p.style.display="none";return}p.style.display="";for(let He of et){let Je=document.createElement("button"),Pt=document.createElement("span"),Mt=document.createElement("span"),Vt=document.createElement("span");if(Je.type="button",Je.style.width="100%",Je.style.border="0",Je.style.background="transparent",Je.style.color=ce.legend?.textColor??"#0d0d58",Je.style.display="flex",Je.style.alignItems="center",Je.style.gap="8px",Je.style.padding="6px 0",Je.style.cursor=He.isEnabled?"pointer":"not-allowed",Je.style.textAlign="left",Je.style.opacity=He.isEnabled?He.isActive?"1":"0.75":"0.5",Pt.style.width="10px",Pt.style.height="10px",Pt.style.borderRadius="999px",Pt.style.flex="0 0 10px",Pt.style.background=He.isActive?ce.legend?.toggleOnColor??"#0d0d58":ce.legend?.toggleOffColor??"#6b7280",Vt.style.display="flex",Vt.style.flexDirection="column",Vt.style.gap="1px",Mt.textContent=He.label,Vt.appendChild(Mt),!He.isEnabled&&He.disabledNote){let _t=document.createElement("span");_t.textContent=He.disabledNote,_t.style.fontSize="11px",_t.style.opacity="0.9",Vt.appendChild(_t)}Je.setAttribute("aria-pressed",String(He.isActive)),Je.setAttribute("aria-disabled",String(!He.isEnabled)),Je.disabled=!He.isEnabled,Je.setAttribute("title",!He.isEnabled&&He.disabledNote?`${He.label} (${He.disabledNote})`:He.isActive?`Hide ${He.label}`:`Show ${He.label}`),Je.addEventListener("click",()=>{He.isEnabled&&R.onToggle(He.key,!He.isActive)}),Je.appendChild(Pt),Je.appendChild(Vt),K.appendChild(Je)}Jt(et)}function Jt(et){let He=document.createElement("div");He.textContent="Key",He.style.paddingTop="8px",He.style.paddingBottom="6px",He.style.fontWeight="600",ht.appendChild(He);for(let Ye of et){let Yt=document.createElement("div"),ze=document.createElement("span"),tt=document.createElement("span");Yt.style.display="flex",Yt.style.alignItems="center",Yt.style.gap="8px",Yt.style.padding="2px 0",ze.style.display="inline-block",ze.style.width="18px",ze.style.height="0",ze.style.borderTopWidth=`${Math.max($i(Ye.key,ce),2)}px`,ze.style.borderTopStyle="solid",ze.style.borderTopColor=li(Ye.key,ce),tt.textContent=Ye.label,Yt.appendChild(ze),Yt.appendChild(tt),ht.appendChild(Yt)}let Je=document.createElement("div");Je.style.paddingTop="8px";let Pt=document.createElement("div");Pt.textContent="IMD decile (1 most deprived, 10 least deprived)",Pt.style.paddingBottom="4px",ht.appendChild(Pt);let Mt=document.createElement("div");Mt.style.display="grid",Mt.style.gridTemplateColumns="repeat(10, minmax(0, 1fr))",Mt.style.gap="2px";let Vt=Fo(re.nation,ce);for(let Ye=0;Ye<10;Ye++){let Yt=document.createElement("span");Yt.style.height="8px",Yt.style.background=Vt[Ye]??Vt[0]??"#cccccc",Yt.style.display="inline-block",Yt.title=`Decile ${Ye+1}`,Mt.appendChild(Yt)}let _t=document.createElement("div");_t.style.display="flex",_t.style.justifyContent="space-between",_t.style.paddingTop="2px",_t.textContent="1";let yi=document.createElement("span");yi.textContent="10",_t.appendChild(yi),Je.appendChild(Mt),Je.appendChild(_t),ht.appendChild(Je)}function li(et,He){return et==="localAuthority"?He.boundaries.localAuthorityColor??"#0d0d58":et==="nhser"?He.boundaries.nhserColor??"#e00087":et==="icb"?He.boundaries.icbColor??"#57c7f2":He.boundaries.lhbColor??"#57c7f2"}function $i(et,He){return et==="localAuthority"?He.boundaries.localAuthorityWidth??1:et==="nhser"?He.boundaries.nhserWidth??1.5:et==="icb"?He.boundaries.icbWidth??1:He.boundaries.lhbWidth??1}return Ce.addEventListener("click",()=>{I=!I,Ce.setAttribute("aria-expanded",String(!I)),pe.textContent=I?"+":"-",K.style.display=I?"none":"block",ht.style.display=I?"none":"block"}),Dt(),Nt(),{update(et,He){re=et,ce=He,Dt(),Nt()},destroy(){p.remove()}}}var Lm=!1;var as={debug(R,...X){Lm&&console.debug(`[rcpch-imd-map] ${R}`,...X)},info(R,...X){console.info(`[rcpch-imd-map] ${R}`,...X)},warn(R,...X){console.warn(`[rcpch-imd-map] ${R}`,...X)},error(R,...X){console.error(`[rcpch-imd-map] ${R}`,...X)}};var Dm=[-2.5,54],Rm=5;function ip(R){let X=typeof R.container=="string"?document.getElementById(R.container):R.container;if(!X)throw new Error(`[rcpch-imd-map] Container not found: "${String(R.container)}". Ensure the element exists in the DOM before calling createImdMap.`);let re=R.tilesBaseUrl??"";re||as.warn("No tilesBaseUrl provided. Choropleth tiles will not load.");let ce=Lh(zh,R.style),I=Pd(R.initialNation??"all",R.initialEra??"2021");R.enableLocalAuthorityOverlay&&(I={...I,overlays:{...I.overlays,localAuthority:!0}}),R.enableHealthOverlays&&(I={...I,overlays:{...I.overlays,nhser:!0,icb:!0,lhb:!0}});let p=R.showLegend??!0,Se=R.legendPosition??"top-right",Ce=R.legendCollapsed??!1,$e=R.legendTitle??"Map layers",pe={localAuthority:R.showLegendLocalAuthority??!0,nhser:R.showLegendNhser??!0,icb:R.showLegendIcb??!0,lhb:R.showLegendLhb??!0};if(R.initialNation&&R.initialEra&&Ph(R.initialNation,R.initialEra)){let ze={code:"ERA_OVERRIDE",message:`Era '${R.initialEra}' is not supported for nation '${R.initialNation}'. Effective era will be '${I.effectiveEra}'.`};as.warn(ze.message),R.onWarning?.(ze)}let K=new Oo.Map({container:X,style:R.mapStyleUrl??"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",center:R.center??Dm,zoom:R.zoom??Rm,attributionControl:!1});K.addControl(new Oo.AttributionControl({compact:!0}));let ht=new Oo.Popup({closeButton:!1,closeOnClick:!1}),Dt=!1,Nt=null,Jt=null,li=null,$i=!1,et=!1,He=null,Je=[];function Pt(){return[...He?[He]:[],...Je]}function Mt(ze,tt){let st=Pt();if(!st.length){as.warn("No patient or lead centre data to fit to.");return}if(st.length===1){let[ci,Zt]=st[0];K.flyTo({center:[ci,Zt],zoom:ze??6});return}let Qt=st[0][0],qt=st[0][1],Qi=st[0][0],er=st[0][1];for(let[ci,Zt]of st)ci<Qt&&(Qt=ci),Zt<qt&&(qt=Zt),ci>Qi&&(Qi=ci),Zt>er&&(er=Zt);K.fitBounds([[Qt,qt],[Qi,er]],{padding:tt??50,maxZoom:ze})}function Vt(){if(!Dt||!re)return;let ze=I.nation,tt=ze==="all"||ze==="england",st=ze==="all"||ze==="england",Qt=ze==="all"||ze==="wales";I.overlays.localAuthority?$d(K,re,ce):qd(K),I.overlays.nhser&&tt?Xd(K,re,ce):Yd(K),I.overlays.icb&&st?Kd(K,re,ce):Qd(K),I.overlays.lhb&&Qt?Jd(K,re,ce):ep(K)}function _t(ze){I={...I,overlays:{...I.overlays,...ze}},Vt(),yi?.update(I,ce)}let yi=null;p&&(yi=tp({container:X,position:Se,title:$e,collapsed:Ce,style:ce,state:I,visibility:pe,onToggle:(ze,tt)=>{ze==="localAuthority"?_t({localAuthority:tt}):ze==="nhser"?_t({nhser:tt}):ze==="icb"?_t({icb:tt}):ze==="lhb"&&_t({lhb:tt})}})),as.debug(`tilesBaseUrl resolved to: "${re}"`),K.on("load",()=>{if(Dt=!0,re&&(Ah(K,re,I.effectiveEra),Rh(K,I.nation,I.effectiveEra,ce)),Vt(),Od(K,ht,ce,R),Nt&&(Je=Nt.map(ze=>ze.geometry.coordinates),Eh(K,Nt),oc(K,ce),$i||(Fh(K,ht,ce),$i=!0),I={...I,hasPatients:!0},Nt=null),Jt&&(He=Jt.geometry.coordinates,kh(K,Jt),ac(K,ce),et||(Oh(K,ht,ce),et=!0),I={...I,hasLeadCentre:!0},Jt=null),li){let{zoom:ze,padding:tt}=li;K.once("idle",()=>{Mt(ze,tt)}),li=null}});function Ye(ze,tt){let st=Wa(ze,tt);if(Ph(ze,tt)){let Qi={code:"ERA_OVERRIDE",message:`Era '${tt}' overridden to '${st}' for nation '${ze}'.`};as.warn(Qi.message),R.onWarning?.(Qi)}let Qt=st!==I.effectiveEra,qt=ze!==I.nation;I={...I,nation:ze,era:tt,effectiveEra:st},Dt&&re&&(Qt?(Bh(K),Ah(K,re,st),Rh(K,ze,st,ce)):qt&&Ld(K,ze,st)),R.onViewChange?.({nation:ze,era:tt,effectiveEra:st})}return{setView({nation:ze,era:tt}={}){Ye(ze??I.nation,tt??I.era)},setNation(ze){Ye(ze,I.era)},setEra(ze){Ye(I.nation,ze)},setStyle(ze){ce=Lh(zh,ze),Dt&&(zd(K,I.nation,ce),Vt(),I.hasPatients&&oc(K,ce),I.hasLeadCentre&&ac(K,ce),yi?.update(I,ce))},setOverlayVisibility(ze){_t(ze)},setPatients(ze,tt){let{features:st,warnings:Qt}=Vd(ze,{strict:tt?.strict});Je=st.map(qt=>qt.geometry.coordinates);for(let qt of Qt)as.warn(qt.message),R.onWarning?.(qt);if(!Dt){Nt=st;return}Eh(K,st),oc(K,ce),$i||(Fh(K,ht,ce),$i=!0),I={...I,hasPatients:!0}},clearPatients(){Nt=null,Je=[],Dt&&(Dd(K),K.getSource(ns)&&K.removeSource(ns),I={...I,hasPatients:!1})},setLeadCentre(ze,tt){let st=Ud(ze);if(!st){let Qt={code:"INVALID_LEAD_CENTRE",message:"Lead centre data could not be resolved to valid coordinates."};as.warn(Qt.message),R.onWarning?.(Qt);return}if(!Dt){Jt=st;return}He=st.geometry.coordinates,kh(K,st),ac(K,ce),et||(Oh(K,ht,ce),et=!0),I={...I,hasLeadCentre:!0}},clearLeadCentre(){Jt=null,He=null,Dt&&(Rd(K),K.getSource(ss)&&K.removeSource(ss),I={...I,hasLeadCentre:!1})},getState(){return{...I}},resize(){K.resize()},fitToData(ze){let tt=ze?.zoom,st=ze?.padding;if(!Dt){li={zoom:tt,padding:st};return}Mt(tt,st)},destroy(){ht.remove(),yi?.destroy(),K.remove()}}}return rm(Bm);})();
575
+ `})),staticAttributes:o,staticUniforms:m}}class Uo{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,n,o,a,c,m,_,y,b){this.context=e;let S=this.boundPaintVertexBuffers.length!==a.length;for(let T=0;!S&&T<a.length;T++)this.boundPaintVertexBuffers[T]!==a[T]&&(S=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==o||S||this.boundIndexBuffer!==c||this.boundVertexOffset!==m||this.boundDynamicVertexBuffer!==_||this.boundDynamicVertexBuffer2!==y||this.boundDynamicVertexBuffer3!==b?this.freshBind(n,o,a,c,m,_,y,b):(e.bindVertexArray.set(this.vao),_&&_.bind(),c&&c.dynamicDraw&&c.bind(),y&&y.bind(),b&&b.bind())}freshBind(e,n,o,a,c,m,_,y){let b=e.numAttributes,S=this.context,T=S.gl;this.vao&&this.destroy(),this.vao=S.createVertexArray(),S.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=o,this.boundIndexBuffer=a,this.boundVertexOffset=c,this.boundDynamicVertexBuffer=m,this.boundDynamicVertexBuffer2=_,this.boundDynamicVertexBuffer3=y,n.enableAttributes(T,e);for(let E of o)E.enableAttributes(T,e);m&&m.enableAttributes(T,e),_&&_.enableAttributes(T,e),y&&y.enableAttributes(T,e),n.bind(),n.setVertexAttribPointers(T,e,c);for(let E of o)E.bind(),E.setVertexAttribPointers(T,e,c);m&&(m.bind(),m.setVertexAttribPointers(T,e,c)),a&&a.bind(),_&&(_.bind(),_.setVertexAttribPointers(T,e,c)),y&&(y.bind(),y.setVertexAttribPointers(T,e,c)),S.currentNumAttributes=b}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}let jo=(h,e,n,o,a)=>({u_matrix:h,u_texture:0,u_ele_delta:e,u_fog_matrix:n,u_fog_color:o?o.properties.get("fog-color"):d.aM.white,u_fog_ground_blend:o?o.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?o.calculateFogBlendOpacity(a):0,u_horizon_color:o?o.properties.get("horizon-color"):d.aM.white,u_horizon_fog_blend:o?o.properties.get("horizon-fog-blend"):1});function Cn(h){let e=[];for(let n=0;n<h.length;n++){if(h[n]===null)continue;let o=h[n].split(" ");e.push(o.pop())}return e}class $o{constructor(e,n,o,a,c,m){let _=e.gl;this.program=_.createProgram();let y=Cn(n.staticAttributes),b=o?o.getBinderAttributes():[],S=y.concat(b),T=Zr.prelude.staticUniforms?Cn(Zr.prelude.staticUniforms):[],E=n.staticUniforms?Cn(n.staticUniforms):[],D=o?o.getBinderUniforms():[],F=T.concat(E).concat(D),V=[];for(let ne of F)V.indexOf(ne)<0&&V.push(ne);let $=o?o.defines():[];c&&$.push("#define OVERDRAW_INSPECTOR;"),m&&$.push("#define TERRAIN3D;");let q=$.concat(Zr.prelude.fragmentSource,n.fragmentSource).join(`
576
+ `),G=$.concat(Zr.prelude.vertexSource,n.vertexSource).join(`
577
+ `),B=_.createShader(_.FRAGMENT_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(B,q),_.compileShader(B),!_.getShaderParameter(B,_.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${_.getShaderInfoLog(B)}`);_.attachShader(this.program,B);let J=_.createShader(_.VERTEX_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(J,G),_.compileShader(J),!_.getShaderParameter(J,_.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${_.getShaderInfoLog(J)}`);_.attachShader(this.program,J),this.attributes={};let ee={};this.numAttributes=S.length;for(let ne=0;ne<this.numAttributes;ne++)S[ne]&&(_.bindAttribLocation(this.program,ne,S[ne]),this.attributes[S[ne]]=ne);if(_.linkProgram(this.program),!_.getProgramParameter(this.program,_.LINK_STATUS))throw new Error(`Program failed to link: ${_.getProgramInfoLog(this.program)}`);_.deleteShader(J),_.deleteShader(B);for(let ne=0;ne<V.length;ne++){let de=V[ne];if(de&&!ee[de]){let ge=_.getUniformLocation(this.program,de);ge&&(ee[de]=ge)}}this.fixedUniforms=a(e,ee),this.terrainUniforms=((ne,de)=>({u_depth:new d.aH(ne,de.u_depth),u_terrain:new d.aH(ne,de.u_terrain),u_terrain_dim:new d.aI(ne,de.u_terrain_dim),u_terrain_matrix:new d.aJ(ne,de.u_terrain_matrix),u_terrain_unpack:new d.aK(ne,de.u_terrain_unpack),u_terrain_exaggeration:new d.aI(ne,de.u_terrain_exaggeration)}))(e,ee),this.binderUniforms=o?o.getUniforms(e,ee):[]}draw(e,n,o,a,c,m,_,y,b,S,T,E,D,F,V,$,q,G){let B=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(o),e.setStencilMode(a),e.setColorMode(c),e.setCullFace(m),y){e.activeTexture.set(B.TEXTURE2),B.bindTexture(B.TEXTURE_2D,y.depthTexture),e.activeTexture.set(B.TEXTURE3),B.bindTexture(B.TEXTURE_2D,y.texture);for(let ee in this.terrainUniforms)this.terrainUniforms[ee].set(y[ee])}for(let ee in this.fixedUniforms)this.fixedUniforms[ee].set(_[ee]);V&&V.setUniforms(e,this.binderUniforms,D,{zoom:F});let J=0;switch(n){case B.LINES:J=2;break;case B.TRIANGLES:J=3;break;case B.LINE_STRIP:J=1}for(let ee of E.get()){let ne=ee.vaos||(ee.vaos={});(ne[b]||(ne[b]=new Uo)).bind(e,this,S,V?V.getPaintVertexBuffers():[],T,ee.vertexOffset,$,q,G),B.drawElements(n,ee.primitiveLength*J,B.UNSIGNED_SHORT,ee.primitiveOffset*J*2)}}}function js(h,e,n){let o=1/at(n,1,e.transform.tileZoom),a=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,e.transform.tileZoom)/a,m=c*(n.tileID.canonical.x+n.tileID.wrap*a),_=c*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[o,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_]}}let fs=(h,e,n,o)=>{let a=e.style.light,c=a.properties.get("position"),m=[c.x,c.y,c.z],_=(function(){var b=new d.A(9);return d.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})();a.properties.get("anchor")==="viewport"&&(function(b,S){var T=Math.sin(S),E=Math.cos(S);b[0]=E,b[1]=T,b[2]=0,b[3]=-T,b[4]=E,b[5]=0,b[6]=0,b[7]=0,b[8]=1})(_,-e.transform.angle),(function(b,S,T){var E=S[0],D=S[1],F=S[2];b[0]=E*T[0]+D*T[3]+F*T[6],b[1]=E*T[1]+D*T[4]+F*T[7],b[2]=E*T[2]+D*T[5]+F*T[8]})(m,m,_);let y=a.properties.get("color");return{u_matrix:h,u_lightpos:m,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+n,u_opacity:o}},$s=(h,e,n,o,a,c,m)=>d.e(fs(h,e,n,o),js(c,e,m),{u_height_factor:-Math.pow(2,a.overscaledZ)/m.tileSize/8}),Pn=h=>({u_matrix:h}),Ja=(h,e,n,o)=>d.e(Pn(h),js(n,e,o)),uc=(h,e)=>({u_matrix:h,u_world:e}),Ya=(h,e,n,o,a)=>d.e(Ja(h,e,n,o),{u_world:a}),dc=(h,e,n,o)=>{let a=h.transform,c,m;if(o.paint.get("circle-pitch-alignment")==="map"){let _=at(n,1,a.zoom);c=!0,m=[_,_]}else c=!1,m=a.pixelsToGLUnits;return{u_camera_to_center_distance:a.cameraToCenterDistance,u_scale_with_map:+(o.paint.get("circle-pitch-scale")==="map"),u_matrix:h.translatePosMatrix(e.posMatrix,n,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_pitch_with_map:+c,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:m}},sn=(h,e,n)=>({u_matrix:h,u_inv_matrix:e,u_camera_to_center_distance:n.cameraToCenterDistance,u_viewport_size:[n.width,n.height]}),ms=(h,e,n=1)=>({u_matrix:h,u_color:e,u_overlay:0,u_overlay_scale:n}),Mi=h=>({u_matrix:h}),Ai=(h,e,n,o)=>({u_matrix:h,u_extrude_scale:at(e,1,n),u_intensity:o}),qs=(h,e,n,o)=>{let a=d.H();d.aP(a,0,h.width,h.height,0,0,1);let c=h.context.gl;return{u_matrix:a,u_world:[c.drawingBufferWidth,c.drawingBufferHeight],u_image:n,u_color_ramp:o,u_opacity:e.paint.get("heatmap-opacity")}};function Zs(h,e){let n=Math.pow(2,e.canonical.z),o=e.canonical.y;return[new d.Z(0,o/n).toLngLat().lat,new d.Z(0,(o+1)/n).toLngLat().lat]}let Gs=(h,e,n,o)=>{let a=h.transform;return{u_matrix:tl(h,e,n,o),u_ratio:1/at(e,1,a.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Qa=(h,e,n,o,a)=>d.e(Gs(h,e,n,a),{u_image:0,u_image_height:o}),Mn=(h,e,n,o,a)=>{let c=h.transform,m=el(e,c);return{u_matrix:tl(h,e,n,a),u_texsize:e.imageAtlasTexture.size,u_ratio:1/at(e,1,c.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[m,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},pc=(h,e,n,o,a,c)=>{let m=h.lineAtlas,_=el(e,h.transform),y=n.layout.get("line-cap")==="round",b=m.getDash(o.from,y),S=m.getDash(o.to,y),T=b.width*a.fromScale,E=S.width*a.toScale;return d.e(Gs(h,e,n,c),{u_patternscale_a:[_/T,-b.height/2],u_patternscale_b:[_/E,-S.height/2],u_sdfgamma:m.width/(256*Math.min(T,E)*h.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:S.y,u_mix:a.t})};function el(h,e){return 1/at(h,1,e.tileZoom)}function tl(h,e,n,o){return h.translatePosMatrix(o?o.posMatrix:e.tileID.posMatrix,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}let fc=(h,e,n,o,a)=>{return{u_matrix:h,u_tl_parent:e,u_scale_parent:n,u_buffer_scale:1,u_fade_t:o.mix,u_opacity:o.opacity*a.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:a.paint.get("raster-brightness-min"),u_brightness_high:a.paint.get("raster-brightness-max"),u_saturation_factor:(m=a.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(c=a.paint.get("raster-contrast"),c>0?1/(1-c):1+c),u_spin_weights:mc(a.paint.get("raster-hue-rotate"))};var c,m};function mc(h){h*=Math.PI/180;let e=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}let il=(h,e,n,o,a,c,m,_,y,b,S,T,E,D)=>{let F=m.transform;return{u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:F.cameraToCenterDistance,u_pitch:F.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:F.width/F.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:_,u_label_plane_matrix:y,u_coord_matrix:b,u_is_text:+T,u_pitch_with_map:+o,u_is_along_line:a,u_is_variable_anchor:c,u_texsize:E,u_texture:0,u_translation:S,u_pitched_scale:D}},gs=(h,e,n,o,a,c,m,_,y,b,S,T,E,D,F)=>{let V=m.transform;return d.e(il(h,e,n,o,a,c,m,_,y,b,S,T,E,F),{u_gamma_scale:o?Math.cos(V._pitch)*V.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:+D})},qo=(h,e,n,o,a,c,m,_,y,b,S,T,E,D)=>d.e(gs(h,e,n,o,a,c,m,_,y,b,S,!0,T,!0,D),{u_texsize_icon:E,u_texture_icon:1}),Hs=(h,e,n)=>({u_matrix:h,u_opacity:e,u_color:n}),Zo=(h,e,n,o,a,c)=>d.e((function(m,_,y,b){let S=y.imageManager.getPattern(m.from.toString()),T=y.imageManager.getPattern(m.to.toString()),{width:E,height:D}=y.imageManager.getPixelSize(),F=Math.pow(2,b.tileID.overscaledZ),V=b.tileSize*Math.pow(2,y.transform.tileZoom)/F,$=V*(b.tileID.canonical.x+b.tileID.wrap*F),q=V*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:S.tl,u_pattern_br_a:S.br,u_pattern_tl_b:T.tl,u_pattern_br_b:T.br,u_texsize:[E,D],u_mix:_.t,u_pattern_size_a:S.displaySize,u_pattern_size_b:T.displaySize,u_scale_a:_.fromScale,u_scale_b:_.toScale,u_tile_units_to_pixels:1/at(b,1,y.transform.tileZoom),u_pixel_coord_upper:[$>>16,q>>16],u_pixel_coord_lower:[65535&$,65535&q]}})(o,c,n,a),{u_matrix:h,u_opacity:e}),Go={fillExtrusion:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_lightpos:new d.aN(h,e.u_lightpos),u_lightintensity:new d.aI(h,e.u_lightintensity),u_lightcolor:new d.aN(h,e.u_lightcolor),u_vertical_gradient:new d.aI(h,e.u_vertical_gradient),u_opacity:new d.aI(h,e.u_opacity)}),fillExtrusionPattern:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_lightpos:new d.aN(h,e.u_lightpos),u_lightintensity:new d.aI(h,e.u_lightintensity),u_lightcolor:new d.aN(h,e.u_lightcolor),u_vertical_gradient:new d.aI(h,e.u_vertical_gradient),u_height_factor:new d.aI(h,e.u_height_factor),u_image:new d.aH(h,e.u_image),u_texsize:new d.aO(h,e.u_texsize),u_pixel_coord_upper:new d.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new d.aO(h,e.u_pixel_coord_lower),u_scale:new d.aN(h,e.u_scale),u_fade:new d.aI(h,e.u_fade),u_opacity:new d.aI(h,e.u_opacity)}),fill:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix)}),fillPattern:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_image:new d.aH(h,e.u_image),u_texsize:new d.aO(h,e.u_texsize),u_pixel_coord_upper:new d.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new d.aO(h,e.u_pixel_coord_lower),u_scale:new d.aN(h,e.u_scale),u_fade:new d.aI(h,e.u_fade)}),fillOutline:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_world:new d.aO(h,e.u_world)}),fillOutlinePattern:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_world:new d.aO(h,e.u_world),u_image:new d.aH(h,e.u_image),u_texsize:new d.aO(h,e.u_texsize),u_pixel_coord_upper:new d.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new d.aO(h,e.u_pixel_coord_lower),u_scale:new d.aN(h,e.u_scale),u_fade:new d.aI(h,e.u_fade)}),circle:(h,e)=>({u_camera_to_center_distance:new d.aI(h,e.u_camera_to_center_distance),u_scale_with_map:new d.aH(h,e.u_scale_with_map),u_pitch_with_map:new d.aH(h,e.u_pitch_with_map),u_extrude_scale:new d.aO(h,e.u_extrude_scale),u_device_pixel_ratio:new d.aI(h,e.u_device_pixel_ratio),u_matrix:new d.aJ(h,e.u_matrix)}),collisionBox:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_pixel_extrude_scale:new d.aO(h,e.u_pixel_extrude_scale)}),collisionCircle:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_inv_matrix:new d.aJ(h,e.u_inv_matrix),u_camera_to_center_distance:new d.aI(h,e.u_camera_to_center_distance),u_viewport_size:new d.aO(h,e.u_viewport_size)}),debug:(h,e)=>({u_color:new d.aL(h,e.u_color),u_matrix:new d.aJ(h,e.u_matrix),u_overlay:new d.aH(h,e.u_overlay),u_overlay_scale:new d.aI(h,e.u_overlay_scale)}),clippingMask:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix)}),heatmap:(h,e)=>({u_extrude_scale:new d.aI(h,e.u_extrude_scale),u_intensity:new d.aI(h,e.u_intensity),u_matrix:new d.aJ(h,e.u_matrix)}),heatmapTexture:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_world:new d.aO(h,e.u_world),u_image:new d.aH(h,e.u_image),u_color_ramp:new d.aH(h,e.u_color_ramp),u_opacity:new d.aI(h,e.u_opacity)}),hillshade:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_image:new d.aH(h,e.u_image),u_latrange:new d.aO(h,e.u_latrange),u_light:new d.aO(h,e.u_light),u_shadow:new d.aL(h,e.u_shadow),u_highlight:new d.aL(h,e.u_highlight),u_accent:new d.aL(h,e.u_accent)}),hillshadePrepare:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_image:new d.aH(h,e.u_image),u_dimension:new d.aO(h,e.u_dimension),u_zoom:new d.aI(h,e.u_zoom),u_unpack:new d.aK(h,e.u_unpack)}),line:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_ratio:new d.aI(h,e.u_ratio),u_device_pixel_ratio:new d.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new d.aO(h,e.u_units_to_pixels)}),lineGradient:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_ratio:new d.aI(h,e.u_ratio),u_device_pixel_ratio:new d.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new d.aO(h,e.u_units_to_pixels),u_image:new d.aH(h,e.u_image),u_image_height:new d.aI(h,e.u_image_height)}),linePattern:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_texsize:new d.aO(h,e.u_texsize),u_ratio:new d.aI(h,e.u_ratio),u_device_pixel_ratio:new d.aI(h,e.u_device_pixel_ratio),u_image:new d.aH(h,e.u_image),u_units_to_pixels:new d.aO(h,e.u_units_to_pixels),u_scale:new d.aN(h,e.u_scale),u_fade:new d.aI(h,e.u_fade)}),lineSDF:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_ratio:new d.aI(h,e.u_ratio),u_device_pixel_ratio:new d.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new d.aO(h,e.u_units_to_pixels),u_patternscale_a:new d.aO(h,e.u_patternscale_a),u_patternscale_b:new d.aO(h,e.u_patternscale_b),u_sdfgamma:new d.aI(h,e.u_sdfgamma),u_image:new d.aH(h,e.u_image),u_tex_y_a:new d.aI(h,e.u_tex_y_a),u_tex_y_b:new d.aI(h,e.u_tex_y_b),u_mix:new d.aI(h,e.u_mix)}),raster:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_tl_parent:new d.aO(h,e.u_tl_parent),u_scale_parent:new d.aI(h,e.u_scale_parent),u_buffer_scale:new d.aI(h,e.u_buffer_scale),u_fade_t:new d.aI(h,e.u_fade_t),u_opacity:new d.aI(h,e.u_opacity),u_image0:new d.aH(h,e.u_image0),u_image1:new d.aH(h,e.u_image1),u_brightness_low:new d.aI(h,e.u_brightness_low),u_brightness_high:new d.aI(h,e.u_brightness_high),u_saturation_factor:new d.aI(h,e.u_saturation_factor),u_contrast_factor:new d.aI(h,e.u_contrast_factor),u_spin_weights:new d.aN(h,e.u_spin_weights)}),symbolIcon:(h,e)=>({u_is_size_zoom_constant:new d.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new d.aH(h,e.u_is_size_feature_constant),u_size_t:new d.aI(h,e.u_size_t),u_size:new d.aI(h,e.u_size),u_camera_to_center_distance:new d.aI(h,e.u_camera_to_center_distance),u_pitch:new d.aI(h,e.u_pitch),u_rotate_symbol:new d.aH(h,e.u_rotate_symbol),u_aspect_ratio:new d.aI(h,e.u_aspect_ratio),u_fade_change:new d.aI(h,e.u_fade_change),u_matrix:new d.aJ(h,e.u_matrix),u_label_plane_matrix:new d.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new d.aJ(h,e.u_coord_matrix),u_is_text:new d.aH(h,e.u_is_text),u_pitch_with_map:new d.aH(h,e.u_pitch_with_map),u_is_along_line:new d.aH(h,e.u_is_along_line),u_is_variable_anchor:new d.aH(h,e.u_is_variable_anchor),u_texsize:new d.aO(h,e.u_texsize),u_texture:new d.aH(h,e.u_texture),u_translation:new d.aO(h,e.u_translation),u_pitched_scale:new d.aI(h,e.u_pitched_scale)}),symbolSDF:(h,e)=>({u_is_size_zoom_constant:new d.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new d.aH(h,e.u_is_size_feature_constant),u_size_t:new d.aI(h,e.u_size_t),u_size:new d.aI(h,e.u_size),u_camera_to_center_distance:new d.aI(h,e.u_camera_to_center_distance),u_pitch:new d.aI(h,e.u_pitch),u_rotate_symbol:new d.aH(h,e.u_rotate_symbol),u_aspect_ratio:new d.aI(h,e.u_aspect_ratio),u_fade_change:new d.aI(h,e.u_fade_change),u_matrix:new d.aJ(h,e.u_matrix),u_label_plane_matrix:new d.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new d.aJ(h,e.u_coord_matrix),u_is_text:new d.aH(h,e.u_is_text),u_pitch_with_map:new d.aH(h,e.u_pitch_with_map),u_is_along_line:new d.aH(h,e.u_is_along_line),u_is_variable_anchor:new d.aH(h,e.u_is_variable_anchor),u_texsize:new d.aO(h,e.u_texsize),u_texture:new d.aH(h,e.u_texture),u_gamma_scale:new d.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new d.aI(h,e.u_device_pixel_ratio),u_is_halo:new d.aH(h,e.u_is_halo),u_translation:new d.aO(h,e.u_translation),u_pitched_scale:new d.aI(h,e.u_pitched_scale)}),symbolTextAndIcon:(h,e)=>({u_is_size_zoom_constant:new d.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new d.aH(h,e.u_is_size_feature_constant),u_size_t:new d.aI(h,e.u_size_t),u_size:new d.aI(h,e.u_size),u_camera_to_center_distance:new d.aI(h,e.u_camera_to_center_distance),u_pitch:new d.aI(h,e.u_pitch),u_rotate_symbol:new d.aH(h,e.u_rotate_symbol),u_aspect_ratio:new d.aI(h,e.u_aspect_ratio),u_fade_change:new d.aI(h,e.u_fade_change),u_matrix:new d.aJ(h,e.u_matrix),u_label_plane_matrix:new d.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new d.aJ(h,e.u_coord_matrix),u_is_text:new d.aH(h,e.u_is_text),u_pitch_with_map:new d.aH(h,e.u_pitch_with_map),u_is_along_line:new d.aH(h,e.u_is_along_line),u_is_variable_anchor:new d.aH(h,e.u_is_variable_anchor),u_texsize:new d.aO(h,e.u_texsize),u_texsize_icon:new d.aO(h,e.u_texsize_icon),u_texture:new d.aH(h,e.u_texture),u_texture_icon:new d.aH(h,e.u_texture_icon),u_gamma_scale:new d.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new d.aI(h,e.u_device_pixel_ratio),u_is_halo:new d.aH(h,e.u_is_halo),u_translation:new d.aO(h,e.u_translation),u_pitched_scale:new d.aI(h,e.u_pitched_scale)}),background:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_opacity:new d.aI(h,e.u_opacity),u_color:new d.aL(h,e.u_color)}),backgroundPattern:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_opacity:new d.aI(h,e.u_opacity),u_image:new d.aH(h,e.u_image),u_pattern_tl_a:new d.aO(h,e.u_pattern_tl_a),u_pattern_br_a:new d.aO(h,e.u_pattern_br_a),u_pattern_tl_b:new d.aO(h,e.u_pattern_tl_b),u_pattern_br_b:new d.aO(h,e.u_pattern_br_b),u_texsize:new d.aO(h,e.u_texsize),u_mix:new d.aI(h,e.u_mix),u_pattern_size_a:new d.aO(h,e.u_pattern_size_a),u_pattern_size_b:new d.aO(h,e.u_pattern_size_b),u_scale_a:new d.aI(h,e.u_scale_a),u_scale_b:new d.aI(h,e.u_scale_b),u_pixel_coord_upper:new d.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new d.aO(h,e.u_pixel_coord_lower),u_tile_units_to_pixels:new d.aI(h,e.u_tile_units_to_pixels)}),terrain:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_texture:new d.aH(h,e.u_texture),u_ele_delta:new d.aI(h,e.u_ele_delta),u_fog_matrix:new d.aJ(h,e.u_fog_matrix),u_fog_color:new d.aL(h,e.u_fog_color),u_fog_ground_blend:new d.aI(h,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new d.aI(h,e.u_fog_ground_blend_opacity),u_horizon_color:new d.aL(h,e.u_horizon_color),u_horizon_fog_blend:new d.aI(h,e.u_horizon_fog_blend)}),terrainDepth:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_ele_delta:new d.aI(h,e.u_ele_delta)}),terrainCoords:(h,e)=>({u_matrix:new d.aJ(h,e.u_matrix),u_texture:new d.aH(h,e.u_texture),u_terrain_coords_id:new d.aI(h,e.u_terrain_coords_id),u_ele_delta:new d.aI(h,e.u_ele_delta)}),sky:(h,e)=>({u_sky_color:new d.aL(h,e.u_sky_color),u_horizon_color:new d.aL(h,e.u_horizon_color),u_horizon:new d.aI(h,e.u_horizon),u_sky_horizon_blend:new d.aI(h,e.u_sky_horizon_blend)})};class Tr{constructor(e,n,o){this.context=e;let a=e.gl;this.buffer=a.createBuffer(),this.dynamicDraw=!!o,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let gc={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ho{constructor(e,n,o,a){this.length=n.length,this.attributes=o,this.itemSize=n.bytesPerElement,this.dynamicDraw=a,this.context=e;let c=e.gl;this.buffer=c.createBuffer(),e.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,n){for(let o=0;o<this.attributes.length;o++){let a=n.attributes[this.attributes[o].name];a!==void 0&&e.enableVertexAttribArray(a)}}setVertexAttribPointers(e,n,o){for(let a=0;a<this.attributes.length;a++){let c=this.attributes[a],m=n.attributes[c.name];m!==void 0&&e.vertexAttribPointer(m,c.components,e[gc[c.type]],!1,this.itemSize,c.offset+this.itemSize*(o||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let on=new WeakMap;function Gr(h){var e;if(on.has(h))return on.get(h);{let n=(e=h.getParameter(h.VERSION))===null||e===void 0?void 0:e.startsWith("WebGL 2.0");return on.set(h,n),n}}class xt{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Ws extends xt{getDefault(){return d.aM.transparent}set(e){let n=this.current;(e.r!==n.r||e.g!==n.g||e.b!==n.b||e.a!==n.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class _c extends xt{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class An extends xt{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class yc extends xt{getDefault(){return[!0,!0,!0,!0]}set(e){let n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||e[3]!==n[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class rl extends xt{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class xc extends xt{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class nl extends xt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let n=this.current;(e.func!==n.func||e.ref!==n.ref||e.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class Wo extends xt{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class sl extends xt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;e?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=e,this.dirty=!1}}class ol extends xt{getDefault(){return[0,1]}set(e){let n=this.current;(e[0]!==n[0]||e[1]!==n[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class al extends xt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;e?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=e,this.dirty=!1}}class ll extends xt{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class an extends xt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;e?n.enable(n.BLEND):n.disable(n.BLEND),this.current=e,this.dirty=!1}}class cl extends xt{getDefault(){let e=this.gl;return[e.ONE,e.ZERO]}set(e){let n=this.current;(e[0]!==n[0]||e[1]!==n[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class vc extends xt{getDefault(){return d.aM.transparent}set(e){let n=this.current;(e.r!==n.r||e.g!==n.g||e.b!==n.b||e.a!==n.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class hl extends xt{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class _s extends xt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;e?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=e,this.dirty=!1}}class bc extends xt{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Xs extends xt{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class wc extends xt{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Sc extends xt{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class ul extends xt{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||e[3]!==n[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class dl extends xt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class pl extends xt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Xo extends xt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.bindTexture(n.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class fl extends xt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Ks extends xt{getDefault(){return null}set(e){let n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Dr extends xt{getDefault(){return null}set(e){var n;if(e===this.current&&!this.dirty)return;let o=this.gl;Gr(o)?o.bindVertexArray(e):(n=o.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class Ko extends xt{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class Jo extends xt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class Yo extends xt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class Js extends xt{constructor(e,n){super(e),this.context=e,this.parent=n}getDefault(){return null}}class Qo extends Js{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class ln extends Js{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class ea extends Js{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Tc{constructor(e,n,o,a,c){this.context=e,this.width=n,this.height=o;let m=e.gl,_=this.framebuffer=m.createFramebuffer();if(this.colorAttachment=new Qo(e,_),a)this.depthAttachment=c?new ea(e,_):new ln(e,_);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(){let e=this.context.gl,n=this.colorAttachment.get();if(n&&e.deleteTexture(n),this.depthAttachment){let o=this.depthAttachment.get();o&&e.deleteRenderbuffer(o)}e.deleteFramebuffer(this.framebuffer)}}class qt{constructor(e,n,o){this.blendFunction=e,this.blendColor=n,this.mask=o}}qt.Replace=[1,0],qt.disabled=new qt(qt.Replace,d.aM.transparent,[!1,!1,!1,!1]),qt.unblended=new qt(qt.Replace,d.aM.transparent,[!0,!0,!0,!0]),qt.alphaBlended=new qt([1,771],d.aM.transparent,[!0,!0,!0,!0]);class Ic{constructor(e){var n,o;if(this.gl=e,this.clearColor=new Ws(this),this.clearDepth=new _c(this),this.clearStencil=new An(this),this.colorMask=new yc(this),this.depthMask=new rl(this),this.stencilMask=new xc(this),this.stencilFunc=new nl(this),this.stencilOp=new Wo(this),this.stencilTest=new sl(this),this.depthRange=new ol(this),this.depthTest=new al(this),this.depthFunc=new ll(this),this.blend=new an(this),this.blendFunc=new cl(this),this.blendColor=new vc(this),this.blendEquation=new hl(this),this.cullFace=new _s(this),this.cullFaceSide=new bc(this),this.frontFace=new Xs(this),this.program=new wc(this),this.activeTexture=new Sc(this),this.viewport=new ul(this),this.bindFramebuffer=new dl(this),this.bindRenderbuffer=new pl(this),this.bindTexture=new Xo(this),this.bindVertexBuffer=new fl(this),this.bindElementBuffer=new Ks(this),this.bindVertexArray=new Dr(this),this.pixelStoreUnpack=new Ko(this),this.pixelStoreUnpackPremultiplyAlpha=new Jo(this),this.pixelStoreUnpackFlipY=new Yo(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),Gr(e)){this.HALF_FLOAT=e.HALF_FLOAT;let a=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=e.RGBA16F)!==null&&n!==void 0?n:a?.RGBA16F_EXT,this.RGB16F=(o=e.RGB16F)!==null&&o!==void 0?o:a?.RGB16F_EXT,e.getExtension("EXT_color_buffer_float")}else{e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");let a=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=a?.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(e,n){return new Tr(this,e,n)}createVertexBuffer(e,n,o){return new Ho(this,e,n,o)}createRenderbuffer(e,n,o){let a=this.gl,c=a.createRenderbuffer();return this.bindRenderbuffer.set(c),a.renderbufferStorage(a.RENDERBUFFER,e,n,o),this.bindRenderbuffer.set(null),c}createFramebuffer(e,n,o,a){return new Tc(this,e,n,o,a)}clear({color:e,depth:n,stencil:o}){let a=this.gl,c=0;e&&(c|=a.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(c|=a.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),o!==void 0&&(c|=a.STENCIL_BUFFER_BIT,this.clearStencil.set(o),this.stencilMask.set(255)),a.clear(c)}setCullFace(e){e.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){d.aE(e.blendFunction,qt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){var e;return Gr(this.gl)?this.gl.createVertexArray():(e=this.gl.getExtension("OES_vertex_array_object"))===null||e===void 0?void 0:e.createVertexArrayOES()}deleteVertexArray(e){var n;return Gr(this.gl)?this.gl.deleteVertexArray(e):(n=this.gl.getExtension("OES_vertex_array_object"))===null||n===void 0?void 0:n.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}class st{constructor(e,n,o){this.func=e,this.mask=n,this.range=o}}st.ReadOnly=!1,st.ReadWrite=!0,st.disabled=new st(519,st.ReadOnly,[0,1]);let Ys=7680;class Et{constructor(e,n,o,a,c,m){this.test=e,this.ref=n,this.mask=o,this.fail=a,this.depthFail=c,this.pass=m}}Et.disabled=new Et({func:519,mask:0},0,0,Ys,Ys,Ys);class St{constructor(e,n,o){this.enable=e,this.mode=n,this.frontFace=o}}let cn;function ys(h,e,n,o,a){let c=h.context,m=c.gl,_=h.useProgram("collisionBox"),y=[],b=0,S=0;for(let q=0;q<o.length;q++){let G=o[q],B=e.getTile(G).getBucket(n);if(!B)continue;let J=a?B.textCollisionBox:B.iconCollisionBox,ee=B.collisionCircleArray;if(ee.length>0){let ne=d.H();d.aQ(ne,B.placementInvProjMatrix,h.transform.glCoordMatrix),d.aQ(ne,ne,B.placementViewportMatrix),y.push({circleArray:ee,circleOffset:S,transform:G.posMatrix,invTransform:ne,coord:G}),b+=ee.length/4,S=b}J&&_.draw(c,m.LINES,st.disabled,Et.disabled,h.colorModeForRenderPass(),St.disabled,{u_matrix:G.posMatrix,u_pixel_extrude_scale:[1/(T=h.transform).width,1/T.height]},h.style.map.terrain&&h.style.map.terrain.getTerrainData(G),n.id,J.layoutVertexBuffer,J.indexBuffer,J.segments,null,h.transform.zoom,null,null,J.collisionVertexBuffer)}var T;if(!a||!y.length)return;let E=h.useProgram("collisionCircle"),D=new d.aR;D.resize(4*b),D._trim();let F=0;for(let q of y)for(let G=0;G<q.circleArray.length/4;G++){let B=4*G,J=q.circleArray[B+0],ee=q.circleArray[B+1],ne=q.circleArray[B+2],de=q.circleArray[B+3];D.emplace(F++,J,ee,ne,de,0),D.emplace(F++,J,ee,ne,de,1),D.emplace(F++,J,ee,ne,de,2),D.emplace(F++,J,ee,ne,de,3)}(!cn||cn.length<2*b)&&(cn=(function(q){let G=2*q,B=new d.aT;B.resize(G),B._trim();for(let J=0;J<G;J++){let ee=6*J;B.uint16[ee+0]=4*J+0,B.uint16[ee+1]=4*J+1,B.uint16[ee+2]=4*J+2,B.uint16[ee+3]=4*J+2,B.uint16[ee+4]=4*J+3,B.uint16[ee+5]=4*J+0}return B})(b));let V=c.createIndexBuffer(cn,!0),$=c.createVertexBuffer(D,d.aS.members,!0);for(let q of y){let G=sn(q.transform,q.invTransform,h.transform);E.draw(c,m.TRIANGLES,st.disabled,Et.disabled,h.colorModeForRenderPass(),St.disabled,G,h.style.map.terrain&&h.style.map.terrain.getTerrainData(q.coord),n.id,$,V,d.a0.simpleSegment(0,2*q.circleOffset,q.circleArray.length,q.circleArray.length/2),null,h.transform.zoom,null,null,null)}$.destroy(),V.destroy()}St.disabled=new St(!1,1029,2305),St.backCCW=new St(!0,1029,2305);let xs=d.an(new Float32Array(16));function ta(h,e,n,o,a,c){let{horizontalAlign:m,verticalAlign:_}=d.au(h);return new d.P((-(m-.5)*e/a+o[0])*c,(-(_-.5)*n/a+o[1])*c)}function hn(h,e,n,o,a,c){let m=e.tileAnchorPoint.add(new d.P(e.translation[0],e.translation[1]));if(e.pitchWithMap){let _=o.mult(c);n||(_=_.rotate(-a));let y=m.add(_);return U(y.x,y.y,e.labelPlaneMatrix,e.getElevation).point}if(n){let _=ce(e.tileAnchorPoint.x+1,e.tileAnchorPoint.y,e).point.sub(h),y=Math.atan(_.y/_.x)+(_.x<0?Math.PI:0);return h.add(o.rotate(y))}return h.add(o)}function En(h,e,n,o,a,c,m,_,y,b,S,T,E,D){let F=h.text.placedSymbolArray,V=h.text.dynamicLayoutVertexArray,$=h.icon.dynamicLayoutVertexArray,q={};V.clear();for(let G=0;G<F.length;G++){let B=F.get(G),J=B.hidden||!B.crossTileID||h.allowVerticalPlacement&&!B.placedOrientation?null:o[B.crossTileID];if(J){let ee=new d.P(B.anchorX,B.anchorY),ne={getElevation:D,width:a.width,height:a.height,labelPlaneMatrix:c,lineVertexArray:null,pitchWithMap:n,projection:S,projectionCache:null,tileAnchorPoint:ee,translation:T,unwrappedTileID:E},de=n?U(ee.x,ee.y,m,D):ce(ee.x,ee.y,ne),ge=M(a.cameraToCenterDistance,de.signedDistanceFromCamera),Ie=d.ai(h.textSizeData,y,B)*ge/d.ap;n&&(Ie*=h.tilePixelRatio/_);let{width:Ae,height:be,anchor:ve,textOffset:Re,textBoxScale:We}=J,Se=ta(ve,Ae,be,Re,We,Ie),Pe=S.getPitchedTextCorrection(a,ee.add(new d.P(T[0],T[1])),E),Ge=hn(de.point,ne,e,Se,a.angle,Pe),Lt=h.allowVerticalPlacement&&B.placedOrientation===d.ah.vertical?Math.PI/2:0;for(let tt=0;tt<B.numGlyphs;tt++)d.aj(V,Ge,Lt);b&&B.associatedIconIndex>=0&&(q[B.associatedIconIndex]={shiftedAnchor:Ge,angle:Lt})}else Ue(B.numGlyphs,V)}if(b){$.clear();let G=h.icon.placedSymbolArray;for(let B=0;B<G.length;B++){let J=G.get(B);if(J.hidden)Ue(J.numGlyphs,$);else{let ee=q[B];if(ee)for(let ne=0;ne<J.numGlyphs;ne++)d.aj($,ee.shiftedAnchor,ee.angle);else Ue(J.numGlyphs,$)}}h.icon.dynamicLayoutVertexBuffer.updateData($)}h.text.dynamicLayoutVertexBuffer.updateData(V)}function Hi(h,e,n){return n.iconsInText&&e?"symbolTextAndIcon":h?"symbolSDF":"symbolIcon"}function ia(h,e,n,o,a,c,m,_,y,b,S,T){let E=h.context,D=E.gl,F=h.transform,V=rn(),$=_==="map",q=y==="map",G=_!=="viewport"&&n.layout.get("symbol-placement")!=="point",B=$&&!q&&!G,J=!q&&G,ee=!n.layout.get("symbol-sort-key").isConstant(),ne=!1,de=h.depthModeForSublayer(0,st.ReadOnly),ge=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Ie=[],Ae=V.getCircleRadiusCorrection(F);for(let be of o){let ve=e.getTile(be),Re=ve.getBucket(n);if(!Re)continue;let We=a?Re.text:Re.icon;if(!We||!We.segments.get().length||!We.hasVisibleVertices)continue;let Se=We.programConfigurations.get(n.id),Pe=a||Re.sdfIcons,Ge=a?Re.textSizeData:Re.iconSizeData,Lt=q||F.pitch!==0,tt=h.useProgram(Hi(Pe,a,Re),Se),lt=d.ag(Ge,F.zoom),Dt=h.style.map.terrain&&h.style.map.terrain.getTerrainData(be),pi,ur,Rt,Ei,Si=[0,0],fi=null;if(a)ur=ve.glyphAtlasTexture,Rt=D.LINEAR,pi=ve.glyphAtlasTexture.size,Re.iconsInText&&(Si=ve.imageAtlasTexture.size,fi=ve.imageAtlasTexture,Ei=Lt||h.options.rotating||h.options.zooming||Ge.kind==="composite"||Ge.kind==="camera"?D.LINEAR:D.NEAREST);else{let ut=n.layout.get("icon-size").constantOr(0)!==1||Re.iconsNeedLinear;ur=ve.imageAtlasTexture,Rt=Pe||h.options.rotating||h.options.zooming||ut||Lt?D.LINEAR:D.NEAREST,pi=ve.imageAtlasTexture.size}let Ti=at(ve,1,h.transform.zoom),Pr=J?be.posMatrix:xs,Gn=qr(Pr,q,$,h.transform,Ti),yo=Sr(Pr,q,$,h.transform,Ti),Hn=Sr(be.posMatrix,q,$,h.transform,Ti),Ki=V.translatePosition(h.transform,ve,c,m),xo=ge&&Re.hasTextData(),Pa=n.layout.get("icon-text-fit")!=="none"&&xo&&Re.hasIconData();if(G){let ut=h.style.map.terrain?(Wn,Xn)=>h.style.map.terrain.getElevation(be,Wn,Xn):null,mn=n.layout.get("text-rotation-alignment")==="map";R(Re,be.posMatrix,h,a,Gn,Hn,q,b,mn,V,be.toUnwrapped(),F.width,F.height,Ki,ut)}let Ji=be.posMatrix,Yi=a&&ge||Pa,Hr=G||Yi?xs:Gn,dr=yo,ci=Pe&&n.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1)!==0,mi;mi=Pe?Re.iconsInText?qo(Ge.kind,lt,B,q,G,Yi,h,Ji,Hr,dr,Ki,pi,Si,Ae):gs(Ge.kind,lt,B,q,G,Yi,h,Ji,Hr,dr,Ki,a,pi,!0,Ae):il(Ge.kind,lt,B,q,G,Yi,h,Ji,Hr,dr,Ki,a,pi,Ae);let ji={program:tt,buffers:We,uniformValues:mi,atlasTexture:ur,atlasTextureIcon:fi,atlasInterpolation:Rt,atlasInterpolationIcon:Ei,isSDF:Pe,hasHalo:ci};if(ee&&Re.canOverlap){ne=!0;let ut=We.segments.get();for(let mn of ut)Ie.push({segments:new d.a0([mn]),sortKey:mn.sortKey,state:ji,terrainData:Dt})}else Ie.push({segments:We.segments,sortKey:0,state:ji,terrainData:Dt})}ne&&Ie.sort(((be,ve)=>be.sortKey-ve.sortKey));for(let be of Ie){let ve=be.state;if(E.activeTexture.set(D.TEXTURE0),ve.atlasTexture.bind(ve.atlasInterpolation,D.CLAMP_TO_EDGE),ve.atlasTextureIcon&&(E.activeTexture.set(D.TEXTURE1),ve.atlasTextureIcon&&ve.atlasTextureIcon.bind(ve.atlasInterpolationIcon,D.CLAMP_TO_EDGE)),ve.isSDF){let Re=ve.uniformValues;ve.hasHalo&&(Re.u_is_halo=1,ra(ve.buffers,be.segments,n,h,ve.program,de,S,T,Re,be.terrainData)),Re.u_is_halo=0}ra(ve.buffers,be.segments,n,h,ve.program,de,S,T,ve.uniformValues,be.terrainData)}}function ra(h,e,n,o,a,c,m,_,y,b){let S=o.context;a.draw(S,S.gl.TRIANGLES,c,m,_,St.disabled,y,b,n.id,h.layoutVertexBuffer,h.indexBuffer,e,n.paint,o.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function na(h,e,n,o){let a=h.context,c=a.gl,m=Et.disabled,_=new qt([c.ONE,c.ONE],d.aM.transparent,[!0,!0,!0,!0]),y=e.getBucket(n);if(!y)return;let b=o.key,S=n.heatmapFbos.get(b);S||(S=vs(a,e.tileSize,e.tileSize),n.heatmapFbos.set(b,S)),a.bindFramebuffer.set(S.framebuffer),a.viewport.set([0,0,e.tileSize,e.tileSize]),a.clear({color:d.aM.transparent});let T=y.programConfigurations.get(n.id),E=h.useProgram("heatmap",T),D=h.style.map.terrain.getTerrainData(o);E.draw(a,c.TRIANGLES,st.disabled,m,_,St.disabled,Ai(o.posMatrix,e,h.transform.zoom,n.paint.get("heatmap-intensity")),D,n.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,n.paint,h.transform.zoom,T)}function un(h,e,n){let o=h.context,a=o.gl;o.setColorMode(h.colorModeForRenderPass());let c=bs(o,e),m=n.key,_=e.heatmapFbos.get(m);_&&(o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,_.colorAttachment.get()),o.activeTexture.set(a.TEXTURE1),c.bind(a.LINEAR,a.CLAMP_TO_EDGE),h.useProgram("heatmapTexture").draw(o,a.TRIANGLES,st.disabled,Et.disabled,h.colorModeForRenderPass(),St.disabled,qs(h,e,0,1),null,e.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments,e.paint,h.transform.zoom),_.destroy(),e.heatmapFbos.delete(m))}function vs(h,e,n){var o,a;let c=h.gl,m=c.createTexture();c.bindTexture(c.TEXTURE_2D,m),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);let _=(o=h.HALF_FLOAT)!==null&&o!==void 0?o:c.UNSIGNED_BYTE,y=(a=h.RGBA16F)!==null&&a!==void 0?a:c.RGBA;c.texImage2D(c.TEXTURE_2D,0,y,e,n,0,c.RGBA,_,null);let b=h.createFramebuffer(e,n,!1,!1);return b.colorAttachment.set(m),b}function bs(h,e){return e.colorRampTexture||(e.colorRampTexture=new et(h,e.colorRamp,h.gl.RGBA)),e.colorRampTexture}function kn(h,e,n,o,a){if(!n||!o||!o.imageAtlas)return;let c=o.imageAtlas.patternPositions,m=c[n.to.toString()],_=c[n.from.toString()];if(!m&&_&&(m=_),!_&&m&&(_=m),!m||!_){let y=a.getPaintProperty(e);m=c[y],_=c[y]}m&&_&&h.setConstantPatternPositions(m,_)}function ws(h,e,n,o,a,c,m){let _=h.context.gl,y="fill-pattern",b=n.paint.get(y),S=b&&b.constantOr(1),T=n.getCrossfadeParameters(),E,D,F,V,$;m?(D=S&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",E=_.LINES):(D=S?"fillPattern":"fill",E=_.TRIANGLES);let q=b.constantOr(null);for(let G of o){let B=e.getTile(G);if(S&&!B.patternsLoaded())continue;let J=B.getBucket(n);if(!J)continue;let ee=J.programConfigurations.get(n.id),ne=h.useProgram(D,ee),de=h.style.map.terrain&&h.style.map.terrain.getTerrainData(G);S&&(h.context.activeTexture.set(_.TEXTURE0),B.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),ee.updatePaintBuffers(T)),kn(ee,y,q,B,n);let ge=de?G:null,Ie=h.translatePosMatrix(ge?ge.posMatrix:G.posMatrix,B,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(m){V=J.indexBuffer2,$=J.segments2;let Ae=[_.drawingBufferWidth,_.drawingBufferHeight];F=D==="fillOutlinePattern"&&S?Ya(Ie,h,T,B,Ae):uc(Ie,Ae)}else V=J.indexBuffer,$=J.segments,F=S?Ja(Ie,h,T,B):Pn(Ie);ne.draw(h.context,E,a,h.stencilModeForClipping(G),c,St.disabled,F,de,n.id,J.layoutVertexBuffer,V,$,n.paint,h.transform.zoom,ee)}}function Qs(h,e,n,o,a,c,m){let _=h.context,y=_.gl,b="fill-extrusion-pattern",S=n.paint.get(b),T=S.constantOr(1),E=n.getCrossfadeParameters(),D=n.paint.get("fill-extrusion-opacity"),F=S.constantOr(null);for(let V of o){let $=e.getTile(V),q=$.getBucket(n);if(!q)continue;let G=h.style.map.terrain&&h.style.map.terrain.getTerrainData(V),B=q.programConfigurations.get(n.id),J=h.useProgram(T?"fillExtrusionPattern":"fillExtrusion",B);T&&(h.context.activeTexture.set(y.TEXTURE0),$.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),B.updatePaintBuffers(E)),kn(B,b,F,$,n);let ee=h.translatePosMatrix(V.posMatrix,$,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ne=n.paint.get("fill-extrusion-vertical-gradient"),de=T?$s(ee,h,ne,D,V,E,$):fs(ee,h,ne,D);J.draw(_,_.gl.TRIANGLES,a,c,m,St.backCCW,de,G,n.id,q.layoutVertexBuffer,q.indexBuffer,q.segments,n.paint,h.transform.zoom,B,h.style.map.terrain&&q.centroidVertexBuffer)}}function zn(h,e,n,o,a,c,m){let _=h.context,y=_.gl,b=n.fbo;if(!b)return;let S=h.useProgram("hillshade"),T=h.style.map.terrain&&h.style.map.terrain.getTerrainData(e);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b.colorAttachment.get()),S.draw(_,y.TRIANGLES,a,c,m,St.disabled,((E,D,F,V)=>{let $=F.paint.get("hillshade-shadow-color"),q=F.paint.get("hillshade-highlight-color"),G=F.paint.get("hillshade-accent-color"),B=F.paint.get("hillshade-illumination-direction")*(Math.PI/180);F.paint.get("hillshade-illumination-anchor")==="viewport"&&(B-=E.transform.angle);let J=!E.options.moving;return{u_matrix:V?V.posMatrix:E.transform.calculatePosMatrix(D.tileID.toUnwrapped(),J),u_image:0,u_latrange:Zs(0,D.tileID),u_light:[F.paint.get("hillshade-exaggeration"),B],u_shadow:$,u_highlight:q,u_accent:G}})(h,n,o,T?e:null),T,o.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments)}function Ln(h,e,n,o,a,c){let m=h.context,_=m.gl,y=e.dem;if(y&&y.data){let b=y.dim,S=y.stride,T=y.getPixels();if(m.activeTexture.set(_.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||h.getTileTexture(S),e.demTexture){let D=e.demTexture;D.update(T,{premultiply:!1}),D.bind(_.NEAREST,_.CLAMP_TO_EDGE)}else e.demTexture=new et(m,T,_.RGBA,{premultiply:!1}),e.demTexture.bind(_.NEAREST,_.CLAMP_TO_EDGE);m.activeTexture.set(_.TEXTURE0);let E=e.fbo;if(!E){let D=new et(m,{width:b,height:b,data:null},_.RGBA);D.bind(_.LINEAR,_.CLAMP_TO_EDGE),E=e.fbo=m.createFramebuffer(b,b,!0,!1),E.colorAttachment.set(D.texture)}m.bindFramebuffer.set(E.framebuffer),m.viewport.set([0,0,b,b]),h.useProgram("hillshadePrepare").draw(m,_.TRIANGLES,o,a,c,St.disabled,((D,F)=>{let V=F.stride,$=d.H();return d.aP($,0,d.X,-d.X,0,0,1),d.J($,$,[0,-d.X,0]),{u_matrix:$,u_image:1,u_dimension:[V,V],u_zoom:D.overscaledZ,u_unpack:F.getUnpackVector()}})(e.tileID,y),null,n.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments),e.needsHillshadePrepare=!1}}function ml(h,e,n,o,a,c){let m=o.paint.get("raster-fade-duration");if(!c&&m>0){let _=ue.now(),y=(_-h.timeAdded)/m,b=e?(_-e.timeAdded)/m:-1,S=n.getSource(),T=a.coveringZoomLevel({tileSize:S.tileSize,roundZoom:S.roundZoom}),E=!e||Math.abs(e.tileID.overscaledZ-T)>Math.abs(h.tileID.overscaledZ-T),D=E&&h.refreshedUponExpiration?1:d.ac(E?y:1-b,0,1);return h.refreshedUponExpiration&&y>=1&&(h.refreshedUponExpiration=!1),e?{opacity:1,mix:1-D}:{opacity:D,mix:0}}return{opacity:1,mix:0}}let sa=new d.aM(1,0,0,1),mt=new d.aM(0,1,0,1),eo=new d.aM(0,0,1,1),Cc=new d.aM(1,0,1,1),gl=new d.aM(0,1,1,1);function Dn(h,e,n,o){to(h,0,e+n/2,h.transform.width,n,o)}function _l(h,e,n,o){to(h,e-n/2,0,n,h.transform.height,o)}function to(h,e,n,o,a,c){let m=h.context,_=m.gl;_.enable(_.SCISSOR_TEST),_.scissor(e*h.pixelRatio,n*h.pixelRatio,o*h.pixelRatio,a*h.pixelRatio),m.clear({color:c}),_.disable(_.SCISSOR_TEST)}function yl(h,e,n){let o=h.context,a=o.gl,c=n.posMatrix,m=h.useProgram("debug"),_=st.disabled,y=Et.disabled,b=h.colorModeForRenderPass(),S="$debug",T=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);o.activeTexture.set(a.TEXTURE0);let E=e.getTileByID(n.key).latestRawTileData,D=Math.floor((E&&E.byteLength||0)/1024),F=e.getTile(n).tileSize,V=512/Math.min(F,512)*(n.overscaledZ/h.transform.zoom)*.5,$=n.canonical.toString();n.overscaledZ!==n.canonical.z&&($+=` => ${n.overscaledZ}`),(function(q,G){q.initDebugOverlayCanvas();let B=q.debugOverlayCanvas,J=q.context.gl,ee=q.debugOverlayCanvas.getContext("2d");ee.clearRect(0,0,B.width,B.height),ee.shadowColor="white",ee.shadowBlur=2,ee.lineWidth=1.5,ee.strokeStyle="white",ee.textBaseline="top",ee.font="bold 36px Open Sans, sans-serif",ee.fillText(G,5,5),ee.strokeText(G,5,5),q.debugOverlayTexture.update(B),q.debugOverlayTexture.bind(J.LINEAR,J.CLAMP_TO_EDGE)})(h,`${$} ${D}kB`),m.draw(o,a.TRIANGLES,_,y,qt.alphaBlended,St.disabled,ms(c,d.aM.transparent,V),null,S,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),m.draw(o,a.LINE_STRIP,_,y,b,St.disabled,ms(c,d.aM.red),T,S,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function xl(h,e,n){let o=h.context,a=o.gl,c=h.colorModeForRenderPass(),m=new st(a.LEQUAL,st.ReadWrite,h.depthRangeFor3D),_=h.useProgram("terrain"),y=e.getTerrainMesh();o.bindFramebuffer.set(null),o.viewport.set([0,0,h.width,h.height]);for(let b of n){let S=h.renderToTexture.getTexture(b),T=e.getTerrainData(b.tileID);o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,S.texture);let E=h.transform.calculatePosMatrix(b.tileID.toUnwrapped()),D=e.getMeshFrameDelta(h.transform.zoom),F=h.transform.calculateFogMatrix(b.tileID.toUnwrapped()),V=jo(E,D,F,h.style.sky,h.transform.pitch);_.draw(o,a.TRIANGLES,m,Et.disabled,c,St.backCCW,V,T,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}class io{constructor(e,n,o){this.vertexBuffer=e,this.indexBuffer=n,this.segments=o}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class ro{constructor(e,n){this.context=new Ic(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:d.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Ze.maxUnderzooming+Ze.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Vo}resize(e,n,o){if(this.width=Math.floor(e*o),this.height=Math.floor(n*o),this.pixelRatio=o,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let a of this.style._order)this.style._layers[a].resize()}setup(){let e=this.context,n=new d.aX;n.emplaceBack(0,0),n.emplaceBack(d.X,0),n.emplaceBack(0,d.X),n.emplaceBack(d.X,d.X),this.tileExtentBuffer=e.createVertexBuffer(n,nn.members),this.tileExtentSegments=d.a0.simpleSegment(0,0,4,2);let o=new d.aX;o.emplaceBack(0,0),o.emplaceBack(d.X,0),o.emplaceBack(0,d.X),o.emplaceBack(d.X,d.X),this.debugBuffer=e.createVertexBuffer(o,nn.members),this.debugSegments=d.a0.simpleSegment(0,0,4,5);let a=new d.$;a.emplaceBack(0,0,0,0),a.emplaceBack(d.X,0,d.X,0),a.emplaceBack(0,d.X,0,d.X),a.emplaceBack(d.X,d.X,d.X,d.X),this.rasterBoundsBuffer=e.createVertexBuffer(a,jr.members),this.rasterBoundsSegments=d.a0.simpleSegment(0,0,4,2);let c=new d.aX;c.emplaceBack(0,0),c.emplaceBack(1,0),c.emplaceBack(0,1),c.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(c,nn.members),this.viewportSegments=d.a0.simpleSegment(0,0,4,2);let m=new d.aZ;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(m);let _=new d.aY;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(_);let y=this.context.gl;this.stencilClearMode=new Et({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){let e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let o=d.H();d.aP(o,0,this.width,this.height,0,0,1),d.K(o,o,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(e,n.TRIANGLES,st.disabled,this.stencilClearMode,qt.disabled,St.disabled,Mi(o),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,n){if(this.currentStencilSource===e.source||!e.isTileClipped()||!n||!n.length)return;this.currentStencilSource=e.source;let o=this.context,a=o.gl;this.nextStencilID+n.length>256&&this.clearStencil(),o.setColorMode(qt.disabled),o.setDepthMode(st.disabled);let c=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(let m of n){let _=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);c.draw(o,a.TRIANGLES,st.disabled,new Et({func:a.ALWAYS,mask:0},_,255,a.KEEP,a.KEEP,a.REPLACE),qt.disabled,St.disabled,Mi(m.posMatrix),y,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,n=this.context.gl;return new Et({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){let n=this.context.gl;return new Et({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(e){let n=this.context.gl,o=e.sort(((m,_)=>_.overscaledZ-m.overscaledZ)),a=o[o.length-1].overscaledZ,c=o[0].overscaledZ-a+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();let m={};for(let _=0;_<c;_++)m[_+a]=new Et({func:n.GEQUAL,mask:255},_+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=c,[m,o]}return[{[a]:Et.disabled},o]}colorModeForRenderPass(){let e=this.context.gl;return this._showOverdrawInspector?new qt([e.CONSTANT_COLOR,e.ONE],new d.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?qt.unblended:qt.alphaBlended}depthModeForSublayer(e,n,o){if(!this.opaquePassEnabledForLayer())return st.disabled;let a=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new st(o||this.context.gl.LEQUAL,n,[a,a])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,n){this.style=e,this.options=n,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(ue.now()),this.imageManager.beginFrame();let o=this.style._order,a=this.style.sourceCaches,c={},m={},_={};for(let y in a){let b=a[y];b.used&&b.prepare(this.context),c[y]=b.getVisibleCoordinates(),m[y]=c[y].slice().reverse(),_[y]=b.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let y=0;y<o.length;y++)if(this.style._layers[o[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(let y of o){let b=this.style._layers[y];if(!b.hasOffscreenPass()||b.isHidden(this.transform.zoom))continue;let S=m[b.source];(b.type==="custom"||S.length)&&this.renderLayer(this,a[b.source],b,S)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?d.aM.black:d.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&(function(y,b){let S=y.context,T=S.gl,E=((q,G,B)=>({u_sky_color:q.properties.get("sky-color"),u_horizon_color:q.properties.get("horizon-color"),u_horizon:(G.height/2+G.getHorizon())*B,u_sky_horizon_blend:q.properties.get("sky-horizon-blend")*G.height/2*B}))(b,y.style.map.transform,y.pixelRatio),D=new st(T.LEQUAL,st.ReadWrite,[0,1]),F=Et.disabled,V=y.colorModeForRenderPass(),$=y.useProgram("sky");if(!b.mesh){let q=new d.aX;q.emplaceBack(-1,-1),q.emplaceBack(1,-1),q.emplaceBack(1,1),q.emplaceBack(-1,1);let G=new d.aY;G.emplaceBack(0,1,2),G.emplaceBack(0,2,3),b.mesh=new io(S.createVertexBuffer(q,nn.members),S.createIndexBuffer(G),d.a0.simpleSegment(0,0,q.length,G.length))}$.draw(S,T.TRIANGLES,D,F,V,St.disabled,E,void 0,"sky",b.mesh.vertexBuffer,b.mesh.indexBuffer,b.mesh.segments)})(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){let y=this.style._layers[o[this.currentLayer]],b=a[y.source],S=c[y.source];this._renderTileClippingMasks(y,S),this.renderLayer(this,b,y,S)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<o.length;this.currentLayer++){let y=this.style._layers[o[this.currentLayer]],b=a[y.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(y))continue;let S=(y.type==="symbol"?_:m)[y.source];this._renderTileClippingMasks(y,c[y.source]),this.renderLayer(this,b,y,S)}if(this.options.showTileBoundaries){let y=(function(b,S){let T=null,E=Object.values(b._layers).flatMap(($=>$.source&&!$.isHidden(S)?[b.sourceCaches[$.source]]:[])),D=E.filter(($=>$.getSource().type==="vector")),F=E.filter(($=>$.getSource().type!=="vector")),V=$=>{(!T||T.getSource().maxzoom<$.getSource().maxzoom)&&(T=$)};return D.forEach(($=>V($))),T||F.forEach(($=>V($))),T})(this.style,this.transform.zoom);y&&(function(b,S,T){for(let E=0;E<T.length;E++)yl(b,S,T[E])})(this,y,y.getVisibleCoordinates())}this.options.showPadding&&(function(y){let b=y.transform.padding;Dn(y,y.transform.height-(b.top||0),3,sa),Dn(y,b.bottom||0,3,mt),_l(y,b.left||0,3,eo),_l(y,y.transform.width-(b.right||0),3,Cc);let S=y.transform.centerPoint;(function(T,E,D,F){to(T,E-1,D-10,2,20,F),to(T,E-10,D-1,20,2,F)})(y,S.x,y.transform.height-S.y,gl)})(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;let n=this.terrainFacilitator.matrix,o=this.transform.modelViewProjectionMatrix,a=this.terrainFacilitator.dirty;a||(a=e?!d.a_(n,o):!d.a$(n,o)),a||(a=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),a&&(d.b0(n,o),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(c,m){let _=c.context,y=_.gl,b=qt.unblended,S=new st(y.LEQUAL,st.ReadWrite,[0,1]),T=m.getTerrainMesh(),E=m.sourceCache.getRenderableTiles(),D=c.useProgram("terrainDepth");_.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:d.aM.transparent,depth:1});for(let F of E){let V=m.getTerrainData(F.tileID),$={u_matrix:c.transform.calculatePosMatrix(F.tileID.toUnwrapped()),u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};D.draw(_,y.TRIANGLES,S,Et.disabled,b,St.backCCW,$,V,"terrain",T.vertexBuffer,T.indexBuffer,T.segments)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])})(this,this.style.map.terrain),(function(c,m){let _=c.context,y=_.gl,b=qt.unblended,S=new st(y.LEQUAL,st.ReadWrite,[0,1]),T=m.getTerrainMesh(),E=m.getCoordsTexture(),D=m.sourceCache.getRenderableTiles(),F=c.useProgram("terrainCoords");_.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:d.aM.transparent,depth:1}),m.coordsIndex=[];for(let V of D){let $=m.getTerrainData(V.tileID);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,E.texture);let q={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)};F.draw(_,y.TRIANGLES,S,Et.disabled,b,St.backCCW,q,$,"terrain",T.vertexBuffer,T.indexBuffer,T.segments),m.coordsIndex.push(V.tileID.key)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])})(this,this.style.map.terrain))}renderLayer(e,n,o,a){if(!o.isHidden(this.transform.zoom)&&(o.type==="background"||o.type==="custom"||(a||[]).length))switch(this.id=o.id,o.type){case"symbol":(function(c,m,_,y,b){if(c.renderPass!=="translucent")return;let S=Et.disabled,T=c.colorModeForRenderPass();(_._unevaluatedLayout.hasValue("text-variable-anchor")||_._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(E,D,F,V,$,q,G,B,J){let ee=D.transform,ne=rn(),de=$==="map",ge=q==="map";for(let Ie of E){let Ae=V.getTile(Ie),be=Ae.getBucket(F);if(!be||!be.text||!be.text.segments.get().length)continue;let ve=d.ag(be.textSizeData,ee.zoom),Re=at(Ae,1,D.transform.zoom),We=qr(Ie.posMatrix,ge,de,D.transform,Re),Se=F.layout.get("icon-text-fit")!=="none"&&be.hasIconData();if(ve){let Pe=Math.pow(2,ee.zoom-Ae.tileID.overscaledZ),Ge=D.style.map.terrain?(tt,lt)=>D.style.map.terrain.getElevation(Ie,tt,lt):null,Lt=ne.translatePosition(ee,Ae,G,B);En(be,de,ge,J,ee,We,Ie.posMatrix,Pe,ve,Se,ne,Lt,Ie.toUnwrapped(),Ge)}}})(y,c,_,m,_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),b),_.paint.get("icon-opacity").constantOr(1)!==0&&ia(c,m,_,y,!1,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),_.layout.get("icon-rotation-alignment"),_.layout.get("icon-pitch-alignment"),_.layout.get("icon-keep-upright"),S,T),_.paint.get("text-opacity").constantOr(1)!==0&&ia(c,m,_,y,!0,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.layout.get("text-keep-upright"),S,T),m.map.showCollisionBoxes&&(ys(c,m,_,y,!0),ys(c,m,_,y,!1))})(e,n,o,a,this.style.placement.variableOffsets);break;case"circle":(function(c,m,_,y){if(c.renderPass!=="translucent")return;let b=_.paint.get("circle-opacity"),S=_.paint.get("circle-stroke-width"),T=_.paint.get("circle-stroke-opacity"),E=!_.layout.get("circle-sort-key").isConstant();if(b.constantOr(1)===0&&(S.constantOr(1)===0||T.constantOr(1)===0))return;let D=c.context,F=D.gl,V=c.depthModeForSublayer(0,st.ReadOnly),$=Et.disabled,q=c.colorModeForRenderPass(),G=[];for(let B=0;B<y.length;B++){let J=y[B],ee=m.getTile(J),ne=ee.getBucket(_);if(!ne)continue;let de=ne.programConfigurations.get(_.id),ge=c.useProgram("circle",de),Ie=ne.layoutVertexBuffer,Ae=ne.indexBuffer,be=c.style.map.terrain&&c.style.map.terrain.getTerrainData(J),ve={programConfiguration:de,program:ge,layoutVertexBuffer:Ie,indexBuffer:Ae,uniformValues:dc(c,J,ee,_),terrainData:be};if(E){let Re=ne.segments.get();for(let We of Re)G.push({segments:new d.a0([We]),sortKey:We.sortKey,state:ve})}else G.push({segments:ne.segments,sortKey:0,state:ve})}E&&G.sort(((B,J)=>B.sortKey-J.sortKey));for(let B of G){let{programConfiguration:J,program:ee,layoutVertexBuffer:ne,indexBuffer:de,uniformValues:ge,terrainData:Ie}=B.state;ee.draw(D,F.TRIANGLES,V,$,q,St.disabled,ge,Ie,_.id,ne,de,B.segments,_.paint,c.transform.zoom,J)}})(e,n,o,a);break;case"heatmap":(function(c,m,_,y){if(_.paint.get("heatmap-opacity")===0)return;let b=c.context;if(c.style.map.terrain){for(let S of y){let T=m.getTile(S);m.hasRenderableParent(S)||(c.renderPass==="offscreen"?na(c,T,_,S):c.renderPass==="translucent"&&un(c,_,S))}b.viewport.set([0,0,c.width,c.height])}else c.renderPass==="offscreen"?(function(S,T,E,D){let F=S.context,V=F.gl,$=Et.disabled,q=new qt([V.ONE,V.ONE],d.aM.transparent,[!0,!0,!0,!0]);(function(G,B,J){let ee=G.gl;G.activeTexture.set(ee.TEXTURE1),G.viewport.set([0,0,B.width/4,B.height/4]);let ne=J.heatmapFbos.get(d.aU);ne?(ee.bindTexture(ee.TEXTURE_2D,ne.colorAttachment.get()),G.bindFramebuffer.set(ne.framebuffer)):(ne=vs(G,B.width/4,B.height/4),J.heatmapFbos.set(d.aU,ne))})(F,S,E),F.clear({color:d.aM.transparent});for(let G=0;G<D.length;G++){let B=D[G];if(T.hasRenderableParent(B))continue;let J=T.getTile(B),ee=J.getBucket(E);if(!ee)continue;let ne=ee.programConfigurations.get(E.id),de=S.useProgram("heatmap",ne),{zoom:ge}=S.transform;de.draw(F,V.TRIANGLES,st.disabled,$,q,St.disabled,Ai(B.posMatrix,J,ge,E.paint.get("heatmap-intensity")),null,E.id,ee.layoutVertexBuffer,ee.indexBuffer,ee.segments,E.paint,S.transform.zoom,ne)}F.viewport.set([0,0,S.width,S.height])})(c,m,_,y):c.renderPass==="translucent"&&(function(S,T){let E=S.context,D=E.gl;E.setColorMode(S.colorModeForRenderPass());let F=T.heatmapFbos.get(d.aU);F&&(E.activeTexture.set(D.TEXTURE0),D.bindTexture(D.TEXTURE_2D,F.colorAttachment.get()),E.activeTexture.set(D.TEXTURE1),bs(E,T).bind(D.LINEAR,D.CLAMP_TO_EDGE),S.useProgram("heatmapTexture").draw(E,D.TRIANGLES,st.disabled,Et.disabled,S.colorModeForRenderPass(),St.disabled,qs(S,T,0,1),null,T.id,S.viewportBuffer,S.quadTriangleIndexBuffer,S.viewportSegments,T.paint,S.transform.zoom))})(c,_)})(e,n,o,a);break;case"line":(function(c,m,_,y){if(c.renderPass!=="translucent")return;let b=_.paint.get("line-opacity"),S=_.paint.get("line-width");if(b.constantOr(1)===0||S.constantOr(1)===0)return;let T=c.depthModeForSublayer(0,st.ReadOnly),E=c.colorModeForRenderPass(),D=_.paint.get("line-dasharray"),F=_.paint.get("line-pattern"),V=F.constantOr(1),$=_.paint.get("line-gradient"),q=_.getCrossfadeParameters(),G=V?"linePattern":D?"lineSDF":$?"lineGradient":"line",B=c.context,J=B.gl,ee=!0;for(let ne of y){let de=m.getTile(ne);if(V&&!de.patternsLoaded())continue;let ge=de.getBucket(_);if(!ge)continue;let Ie=ge.programConfigurations.get(_.id),Ae=c.context.program.get(),be=c.useProgram(G,Ie),ve=ee||be.program!==Ae,Re=c.style.map.terrain&&c.style.map.terrain.getTerrainData(ne),We=F.constantOr(null);if(We&&de.imageAtlas){let Ge=de.imageAtlas,Lt=Ge.patternPositions[We.to.toString()],tt=Ge.patternPositions[We.from.toString()];Lt&&tt&&Ie.setConstantPatternPositions(Lt,tt)}let Se=Re?ne:null,Pe=V?Mn(c,de,_,q,Se):D?pc(c,de,_,D,q,Se):$?Qa(c,de,_,ge.lineClipsArray.length,Se):Gs(c,de,_,Se);if(V)B.activeTexture.set(J.TEXTURE0),de.imageAtlasTexture.bind(J.LINEAR,J.CLAMP_TO_EDGE),Ie.updatePaintBuffers(q);else if(D&&(ve||c.lineAtlas.dirty))B.activeTexture.set(J.TEXTURE0),c.lineAtlas.bind(B);else if($){let Ge=ge.gradients[_.id],Lt=Ge.texture;if(_.gradientVersion!==Ge.version){let tt=256;if(_.stepInterpolant){let lt=m.getSource().maxzoom,Dt=ne.canonical.z===lt?Math.ceil(1<<c.transform.maxZoom-ne.canonical.z):1;tt=d.ac(d.aV(ge.maxLineLength/d.X*1024*Dt),256,B.maxTextureSize)}Ge.gradient=d.aW({expression:_.gradientExpression(),evaluationKey:"lineProgress",resolution:tt,image:Ge.gradient||void 0,clips:ge.lineClipsArray}),Ge.texture?Ge.texture.update(Ge.gradient):Ge.texture=new et(B,Ge.gradient,J.RGBA),Ge.version=_.gradientVersion,Lt=Ge.texture}B.activeTexture.set(J.TEXTURE0),Lt.bind(_.stepInterpolant?J.NEAREST:J.LINEAR,J.CLAMP_TO_EDGE)}be.draw(B,J.TRIANGLES,T,c.stencilModeForClipping(ne),E,St.disabled,Pe,Re,_.id,ge.layoutVertexBuffer,ge.indexBuffer,ge.segments,_.paint,c.transform.zoom,Ie,ge.layoutVertexBuffer2),ee=!1}})(e,n,o,a);break;case"fill":(function(c,m,_,y){let b=_.paint.get("fill-color"),S=_.paint.get("fill-opacity");if(S.constantOr(1)===0)return;let T=c.colorModeForRenderPass(),E=_.paint.get("fill-pattern"),D=c.opaquePassEnabledForLayer()&&!E.constantOr(1)&&b.constantOr(d.aM.transparent).a===1&&S.constantOr(0)===1?"opaque":"translucent";if(c.renderPass===D){let F=c.depthModeForSublayer(1,c.renderPass==="opaque"?st.ReadWrite:st.ReadOnly);ws(c,m,_,y,F,T,!1)}if(c.renderPass==="translucent"&&_.paint.get("fill-antialias")){let F=c.depthModeForSublayer(_.getPaintProperty("fill-outline-color")?2:0,st.ReadOnly);ws(c,m,_,y,F,T,!0)}})(e,n,o,a);break;case"fill-extrusion":(function(c,m,_,y){let b=_.paint.get("fill-extrusion-opacity");if(b!==0&&c.renderPass==="translucent"){let S=new st(c.context.gl.LEQUAL,st.ReadWrite,c.depthRangeFor3D);if(b!==1||_.paint.get("fill-extrusion-pattern").constantOr(1))Qs(c,m,_,y,S,Et.disabled,qt.disabled),Qs(c,m,_,y,S,c.stencilModeFor3D(),c.colorModeForRenderPass());else{let T=c.colorModeForRenderPass();Qs(c,m,_,y,S,Et.disabled,T)}}})(e,n,o,a);break;case"hillshade":(function(c,m,_,y){if(c.renderPass!=="offscreen"&&c.renderPass!=="translucent")return;let b=c.context,S=c.depthModeForSublayer(0,st.ReadOnly),T=c.colorModeForRenderPass(),[E,D]=c.renderPass==="translucent"?c.stencilConfigForOverlap(y):[{},y];for(let F of D){let V=m.getTile(F);V.needsHillshadePrepare!==void 0&&V.needsHillshadePrepare&&c.renderPass==="offscreen"?Ln(c,V,_,S,Et.disabled,T):c.renderPass==="translucent"&&zn(c,F,V,_,S,E[F.overscaledZ],T)}b.viewport.set([0,0,c.width,c.height])})(e,n,o,a);break;case"raster":(function(c,m,_,y){if(c.renderPass!=="translucent"||_.paint.get("raster-opacity")===0||!y.length)return;let b=c.context,S=b.gl,T=m.getSource(),E=c.useProgram("raster"),D=c.colorModeForRenderPass(),[F,V]=T instanceof zr?[{},y]:c.stencilConfigForOverlap(y),$=V[V.length-1].overscaledZ,q=!c.options.moving;for(let G of V){let B=c.depthModeForSublayer(G.overscaledZ-$,_.paint.get("raster-opacity")===1?st.ReadWrite:st.ReadOnly,S.LESS),J=m.getTile(G);J.registerFadeDuration(_.paint.get("raster-fade-duration"));let ee=m.findLoadedParent(G,0),ne=m.findLoadedSibling(G),de=ml(J,ee||ne||null,m,_,c.transform,c.style.map.terrain),ge,Ie,Ae=_.paint.get("raster-resampling")==="nearest"?S.NEAREST:S.LINEAR;b.activeTexture.set(S.TEXTURE0),J.texture.bind(Ae,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),b.activeTexture.set(S.TEXTURE1),ee?(ee.texture.bind(Ae,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),ge=Math.pow(2,ee.tileID.overscaledZ-J.tileID.overscaledZ),Ie=[J.tileID.canonical.x*ge%1,J.tileID.canonical.y*ge%1]):J.texture.bind(Ae,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),J.texture.useMipmap&&b.extTextureFilterAnisotropic&&c.transform.pitch>20&&S.texParameterf(S.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);let be=c.style.map.terrain&&c.style.map.terrain.getTerrainData(G),ve=be?G:null,Re=ve?ve.posMatrix:c.transform.calculatePosMatrix(G.toUnwrapped(),q),We=fc(Re,Ie||[0,0],ge||1,de,_);T instanceof zr?E.draw(b,S.TRIANGLES,B,Et.disabled,D,St.disabled,We,be,_.id,T.boundsBuffer,c.quadTriangleIndexBuffer,T.boundsSegments):E.draw(b,S.TRIANGLES,B,F[G.overscaledZ],D,St.disabled,We,be,_.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments)}})(e,n,o,a);break;case"background":(function(c,m,_,y){let b=_.paint.get("background-color"),S=_.paint.get("background-opacity");if(S===0)return;let T=c.context,E=T.gl,D=c.transform,F=D.tileSize,V=_.paint.get("background-pattern");if(c.isPatternMissing(V))return;let $=!V&&b.a===1&&S===1&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==$)return;let q=Et.disabled,G=c.depthModeForSublayer(0,$==="opaque"?st.ReadWrite:st.ReadOnly),B=c.colorModeForRenderPass(),J=c.useProgram(V?"backgroundPattern":"background"),ee=y||D.coveringTiles({tileSize:F,terrain:c.style.map.terrain});V&&(T.activeTexture.set(E.TEXTURE0),c.imageManager.bind(c.context));let ne=_.getCrossfadeParameters();for(let de of ee){let ge=y?de.posMatrix:c.transform.calculatePosMatrix(de.toUnwrapped()),Ie=V?Zo(ge,S,c,V,{tileID:de,tileSize:F},ne):Hs(ge,S,b),Ae=c.style.map.terrain&&c.style.map.terrain.getTerrainData(de);J.draw(T,E.TRIANGLES,G,q,B,St.disabled,Ie,Ae,_.id,c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}})(e,0,o,a);break;case"custom":(function(c,m,_){let y=c.context,b=_.implementation;if(c.renderPass==="offscreen"){let S=b.prerender;S&&(c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),S.call(b,y.gl,c.transform.customLayerMatrix()),y.setDirty(),c.setBaseState())}else if(c.renderPass==="translucent"){c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),y.setStencilMode(Et.disabled);let S=b.renderingMode==="3d"?new st(c.context.gl.LEQUAL,st.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,st.ReadOnly);y.setDepthMode(S),b.render(y.gl,c.transform.customLayerMatrix(),{farZ:c.transform.farZ,nearZ:c.transform.nearZ,fov:c.transform._fov,modelViewProjectionMatrix:c.transform.modelViewProjectionMatrix,projectionMatrix:c.transform.projectionMatrix}),y.setDirty(),c.setBaseState(),y.bindFramebuffer.set(null)}})(e,0,o)}}translatePosMatrix(e,n,o,a,c){if(!o[0]&&!o[1])return e;let m=c?a==="map"?this.transform.angle:0:a==="viewport"?-this.transform.angle:0;if(m){let b=Math.sin(m),S=Math.cos(m);o=[o[0]*S-o[1]*b,o[0]*b+o[1]*S]}let _=[c?o[0]:at(n,o[0],this.transform.zoom),c?o[1]:at(n,o[1],this.transform.zoom),0],y=new Float32Array(16);return d.J(y,e,_),y}saveTileTexture(e){let n=this._tileTextures[e.size[0]];n?n.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){let n=this._tileTextures[e];return n&&n.length>0?n.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let n=this.imageManager.getPattern(e.from.toString()),o=this.imageManager.getPattern(e.to.toString());return!n||!o}useProgram(e,n){this.cache=this.cache||{};let o=e+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[o]||(this.cache[o]=new $o(this.context,Zr[e],n,Go[e],this._showOverdrawInspector,this.style.map.terrain)),this.cache[o]}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(){let e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new et(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:n}=this.context.gl;return this.width!==e||this.height!==n}}class Rn{constructor(e,n){this.points=e,this.planes=n}static fromInvProjectionMatrix(e,n,o){let a=Math.pow(2,o),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((_=>{let y=1/(_=d.af([],_,e))[3]/n*a;return d.b1(_,_,[y,y,1/_[3],y])})),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((_=>{let y=(function(E,D){var F=D[0],V=D[1],$=D[2],q=F*F+V*V+$*$;return q>0&&(q=1/Math.sqrt(q)),E[0]=D[0]*q,E[1]=D[1]*q,E[2]=D[2]*q,E})([],(function(E,D,F){var V=D[0],$=D[1],q=D[2],G=F[0],B=F[1],J=F[2];return E[0]=$*J-q*B,E[1]=q*G-V*J,E[2]=V*B-$*G,E})([],Mt([],c[_[0]],c[_[1]]),Mt([],c[_[2]],c[_[1]]))),b=-((S=y)[0]*(T=c[_[1]])[0]+S[1]*T[1]+S[2]*T[2]);var S,T;return y.concat(b)}));return new Rn(c,m)}}class Fn{constructor(e,n){this.min=e,this.max=n,this.center=(function(o,a,c){return o[0]=.5*a[0],o[1]=.5*a[1],o[2]=.5*a[2],o})([],(function(o,a,c){return o[0]=a[0]+c[0],o[1]=a[1]+c[1],o[2]=a[2]+c[2],o})([],this.min,this.max))}quadrant(e){let n=[e%2==0,e<2],o=Ye(this.min),a=Ye(this.max);for(let c=0;c<n.length;c++)o[c]=n[c]?this.min[c]:this.center[c],a[c]=n[c]?this.center[c]:this.max[c];return a[2]=this.max[2],new Fn(o,a)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersects(e){let n=[[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]],o=!0;for(let a=0;a<e.planes.length;a++){let c=e.planes[a],m=0;for(let _=0;_<n.length;_++)d.b2(c,n[_])>=0&&m++;if(m===0)return 0;m!==n.length&&(o=!1)}if(o)return 2;for(let a=0;a<3;a++){let c=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let _=0;_<e.points.length;_++){let y=e.points[_][a]-this.min[a];c=Math.min(c,y),m=Math.max(m,y)}if(m<0||c>this.max[a]-this.min[a])return 0}return 1}}class Bn{constructor(e=0,n=0,o=0,a=0){if(isNaN(e)||e<0||isNaN(n)||n<0||isNaN(o)||o<0||isNaN(a)||a<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=n,this.left=o,this.right=a}interpolate(e,n,o){return n.top!=null&&e.top!=null&&(this.top=d.y.number(e.top,n.top,o)),n.bottom!=null&&e.bottom!=null&&(this.bottom=d.y.number(e.bottom,n.bottom,o)),n.left!=null&&e.left!=null&&(this.left=d.y.number(e.left,n.left,o)),n.right!=null&&e.right!=null&&(this.right=d.y.number(e.right,n.right,o)),this}getCenter(e,n){let o=d.ac((this.left+e-this.right)/2,0,e),a=d.ac((this.top+n-this.bottom)/2,0,n);return new d.P(o,a)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Bn(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}let oa=85.051129;class On{constructor(e,n,o,a,c){this.tileSize=512,this._renderWorldCopies=c===void 0||!!c,this._minZoom=e||0,this._maxZoom=n||22,this._minPitch=o??0,this._maxPitch=a??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new d.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Bn,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){let e=new On(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return e.apply(this),e}apply(e){this.tileSize=e.tileSize,this.latRange=e.latRange,this.lngRange=e.lngRange,this.width=e.width,this.height=e.height,this._center=e._center,this._elevation=e._elevation,this.minElevationForCurrentTile=e.minElevationForCurrentTile,this.zoom=e.zoom,this.angle=e.angle,this._fov=e._fov,this._pitch=e._pitch,this._unmodified=e._unmodified,this._edgeInsets=e._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new d.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(e){let n=-d.b3(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=(function(){var o=new d.A(4);return d.A!=Float32Array&&(o[1]=0,o[2]=0),o[0]=1,o[3]=1,o})(),(function(o,a,c){var m=a[0],_=a[1],y=a[2],b=a[3],S=Math.sin(c),T=Math.cos(c);o[0]=m*T+y*S,o[1]=_*T+b*S,o[2]=m*-S+y*T,o[3]=_*-S+b*T})(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){let n=d.ac(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(e){let n=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,n,o){this._unmodified=!1,this._edgeInsets.interpolate(e,n,o),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){let n=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(e){let n=[new d.b4(0,e)];if(this._renderWorldCopies){let o=this.pointCoordinate(new d.P(0,0)),a=this.pointCoordinate(new d.P(this.width,0)),c=this.pointCoordinate(new d.P(this.width,this.height)),m=this.pointCoordinate(new d.P(0,this.height)),_=Math.floor(Math.min(o.x,a.x,c.x,m.x)),y=Math.floor(Math.max(o.x,a.x,c.x,m.x)),b=1;for(let S=_-b;S<=y+b;S++)S!==0&&n.push(new d.b4(S,e))}return n}coveringTiles(e){var n,o;let a=this.coveringZoomLevel(e),c=a;if(e.minzoom!==void 0&&a<e.minzoom)return[];e.maxzoom!==void 0&&a>e.maxzoom&&(a=e.maxzoom);let m=this.pointCoordinate(this.getCameraPoint()),_=d.Z.fromLngLat(this.center),y=Math.pow(2,a),b=[y*m.x,y*m.y,0],S=[y*_.x,y*_.y,0],T=Rn.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,a),E=e.minzoom||0;!e.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(E=a);let D=e.terrain?2/Math.min(this.tileSize,e.tileSize)*this.tileSize:3,F=B=>({aabb:new Fn([B*y,0,0],[(B+1)*y,y,0]),zoom:0,x:0,y:0,wrap:B,fullyVisible:!1}),V=[],$=[],q=a,G=e.reparseOverscaled?c:a;if(this._renderWorldCopies)for(let B=1;B<=3;B++)V.push(F(-B)),V.push(F(B));for(V.push(F(0));V.length>0;){let B=V.pop(),J=B.x,ee=B.y,ne=B.fullyVisible;if(!ne){let be=B.aabb.intersects(T);if(be===0)continue;ne=be===2}let de=e.terrain?b:S,ge=B.aabb.distanceX(de),Ie=B.aabb.distanceY(de),Ae=Math.max(Math.abs(ge),Math.abs(Ie));if(B.zoom===q||Ae>D+(1<<q-B.zoom)-2&&B.zoom>=E){let be=q-B.zoom,ve=b[0]-.5-(J<<be),Re=b[1]-.5-(ee<<be);$.push({tileID:new d.S(B.zoom===q?G:B.zoom,B.wrap,B.zoom,J,ee),distanceSq:Nt([S[0]-.5-J,S[1]-.5-ee]),tileDistanceToCamera:Math.sqrt(ve*ve+Re*Re)})}else for(let be=0;be<4;be++){let ve=(J<<1)+be%2,Re=(ee<<1)+(be>>1),We=B.zoom+1,Se=B.aabb.quadrant(be);if(e.terrain){let Pe=new d.S(We,B.wrap,We,ve,Re),Ge=e.terrain.getMinMaxElevation(Pe),Lt=(n=Ge.minElevation)!==null&&n!==void 0?n:this.elevation,tt=(o=Ge.maxElevation)!==null&&o!==void 0?o:this.elevation;Se=new Fn([Se.min[0],Se.min[1],Lt],[Se.max[0],Se.max[1],tt])}V.push({aabb:Se,zoom:We,x:ve,y:Re,wrap:B.wrap,fullyVisible:ne})}}return $.sort(((B,J)=>B.distanceSq-J.distanceSq)).map((B=>B.tileID))}resize(e,n){this.width=e,this.height=n,this.pixelsToGLUnits=[2/e,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){let n=d.ac(e.lat,-85.051129,oa);return new d.P(d.O(e.lng)*this.worldSize,d.Q(n)*this.worldSize)}unproject(e){return new d.Z(e.x/this.worldSize,e.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(e){let n=this.elevation,o=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,a=this.pointLocation(this.centerPoint,e),c=e.getElevationForLngLatZoom(a,this.tileZoom);if(!(this.elevation-c))return;let m=o+n-c,_=Math.cos(this._pitch)*this.cameraToCenterDistance/m/d.b5(1,a.lat),y=this.scaleZoom(_/this.tileSize);this._elevation=c,this._center=a,this.zoom=y}setLocationAtPoint(e,n){let o=this.pointCoordinate(n),a=this.pointCoordinate(this.centerPoint),c=this.locationCoordinate(e),m=new d.Z(c.x-(o.x-a.x),c.y-(o.y-a.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(e,n){return n?this.coordinatePoint(this.locationCoordinate(e),n.getElevationForLngLatZoom(e,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(e))}pointLocation(e,n){return this.coordinateLocation(this.pointCoordinate(e,n))}locationCoordinate(e){return d.Z.fromLngLat(e)}coordinateLocation(e){return e&&e.toLngLat()}pointCoordinate(e,n){if(n){let E=n.pointCoordinate(e);if(E!=null)return E}let o=[e.x,e.y,0,1],a=[e.x,e.y,1,1];d.af(o,o,this.pixelMatrixInverse),d.af(a,a,this.pixelMatrixInverse);let c=o[3],m=a[3],_=o[1]/c,y=a[1]/m,b=o[2]/c,S=a[2]/m,T=b===S?0:(0-b)/(S-b);return new d.Z(d.y.number(o[0]/c,a[0]/m,T)/this.worldSize,d.y.number(_,y,T)/this.worldSize)}coordinatePoint(e,n=0,o=this.pixelMatrix){let a=[e.x*this.worldSize,e.y*this.worldSize,n,1];return d.af(a,a,o),new d.P(a[0]/a[3],a[1]/a[3])}getBounds(){let e=Math.max(0,this.height/2-this.getHorizon());return new ae().extend(this.pointLocation(new d.P(0,e))).extend(this.pointLocation(new d.P(this.width,e))).extend(this.pointLocation(new d.P(this.width,this.height))).extend(this.pointLocation(new d.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new ae([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(e){e?(this.lngRange=[e.getWest(),e.getEast()],this.latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,oa])}calculateTileMatrix(e){let n=e.canonical,o=this.worldSize/this.zoomScale(n.z),a=n.x+Math.pow(2,n.z)*e.wrap,c=d.an(new Float64Array(16));return d.J(c,c,[a*o,n.y*o,0]),d.K(c,c,[o/d.X,o/d.X,1]),c}calculatePosMatrix(e,n=!1){let o=e.key,a=n?this._alignedPosMatrixCache:this._posMatrixCache;if(a[o])return a[o];let c=this.calculateTileMatrix(e);return d.L(c,n?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,c),a[o]=new Float32Array(c),a[o]}calculateFogMatrix(e){let n=e.key,o=this._fogMatrixCache;if(o[n])return o[n];let a=this.calculateTileMatrix(e);return d.L(a,this.fogMatrix,a),o[n]=new Float32Array(a),o[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(e,n){n=d.ac(+n,this.minZoom,this.maxZoom);let o={center:new d.N(e.lng,e.lat),zoom:n},a=this.lngRange;if(!this._renderWorldCopies&&a===null){let B=179.9999999999;a=[-B,B]}let c=this.tileSize*this.zoomScale(o.zoom),m=0,_=c,y=0,b=c,S=0,T=0,{x:E,y:D}=this.size;if(this.latRange){let B=this.latRange;m=d.Q(B[1])*c,_=d.Q(B[0])*c,_-m<D&&(S=D/(_-m))}a&&(y=d.b3(d.O(a[0])*c,0,c),b=d.b3(d.O(a[1])*c,0,c),b<y&&(b+=c),b-y<E&&(T=E/(b-y)));let{x:F,y:V}=this.project.call({worldSize:c},e),$,q,G=Math.max(T||0,S||0);if(G){let B=new d.P(T?(b+y)/2:F,S?(_+m)/2:V);return o.center=this.unproject.call({worldSize:c},B).wrap(),o.zoom+=this.scaleZoom(G),o}if(this.latRange){let B=D/2;V-B<m&&(q=m+B),V+B>_&&(q=_-B)}if(a){let B=(y+b)/2,J=F;this._renderWorldCopies&&(J=d.b3(F,B-c/2,B+c/2));let ee=E/2;J-ee<y&&($=y+ee),J+ee>b&&($=b-ee)}if($!==void 0||q!==void 0){let B=new d.P($??F,q??V);o.center=this.unproject.call({worldSize:c},B).wrap()}return o}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:n,zoom:o}=this.getConstrained(this.center,this.zoom);this.center=n,this.zoom=o,this._unmodified=e,this._constraining=!1}_calcMatrices(){if(!this.height)return;let e=this.centerOffset,n=this.point.x,o=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=d.b5(1,this.center.lat)*this.worldSize;let a=d.an(new Float64Array(16));d.K(a,a,[this.width/2,-this.height/2,1]),d.J(a,a,[1,-1,0]),this.labelPlaneMatrix=a,a=d.an(new Float64Array(16)),d.K(a,a,[1,-1,1]),d.J(a,a,[-1,-1,0]),d.K(a,a,[2/this.width,2/this.height,1]),this.glCoordMatrix=a;let c=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),m=Math.min(this.elevation,this.minElevationForCurrentTile),_=c-m*this._pixelPerMeter/Math.cos(this._pitch),y=m<0?_:c,b=Math.PI/2+this._pitch,S=this._fov*(.5+e.y/this.height),T=Math.sin(S)*y/Math.sin(d.ac(Math.PI-b-S,.01,Math.PI-.01)),E=this.getHorizon(),D=2*Math.atan(E/this.cameraToCenterDistance)*(.5+e.y/(2*E)),F=Math.sin(D)*y/Math.sin(d.ac(Math.PI-b-D,.01,Math.PI-.01)),V=Math.min(T,F);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*V+y),this.nearZ=this.height/50,a=new Float64Array(16),d.b6(a,this._fov,this.width/this.height,this.nearZ,this.farZ),a[8]=2*-e.x/this.width,a[9]=2*e.y/this.height,this.projectionMatrix=d.ae(a),d.K(a,a,[1,-1,1]),d.J(a,a,[0,0,-this.cameraToCenterDistance]),d.b7(a,a,this._pitch),d.ad(a,a,this.angle),d.J(a,a,[-n,-o,0]),this.mercatorMatrix=d.K([],a,[this.worldSize,this.worldSize,this.worldSize]),d.K(a,a,[1,1,this._pixelPerMeter]),this.pixelMatrix=d.L(new Float64Array(16),this.labelPlaneMatrix,a),d.J(a,a,[0,0,-this.elevation]),this.modelViewProjectionMatrix=a,this.invModelViewProjectionMatrix=d.as([],a),this.fogMatrix=new Float64Array(16),d.b6(this.fogMatrix,this._fov,this.width/this.height,c,this.farZ),this.fogMatrix[8]=2*-e.x/this.width,this.fogMatrix[9]=2*e.y/this.height,d.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),d.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),d.b7(this.fogMatrix,this.fogMatrix,this._pitch),d.ad(this.fogMatrix,this.fogMatrix,this.angle),d.J(this.fogMatrix,this.fogMatrix,[-n,-o,0]),d.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),d.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=d.L(new Float64Array(16),this.labelPlaneMatrix,a);let $=this.width%2/2,q=this.height%2/2,G=Math.cos(this.angle),B=Math.sin(this.angle),J=n-Math.round(n)+G*$+B*q,ee=o-Math.round(o)+G*q+B*$,ne=new Float64Array(a);if(d.J(ne,ne,[J>.5?J-1:J,ee>.5?ee-1:ee,0]),this.alignedModelViewProjectionMatrix=ne,a=d.as(new Float64Array(16),this.pixelMatrix),!a)throw new Error("failed to invert matrix");this.pixelMatrixInverse=a,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;let e=this.pointCoordinate(new d.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return d.af(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){let e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new d.P(0,e))}getCameraQueryGeometry(e){let n=this.getCameraPoint();if(e.length===1)return[e[0],n];{let o=n.x,a=n.y,c=n.x,m=n.y;for(let _ of e)o=Math.min(o,_.x),a=Math.min(a,_.y),c=Math.max(c,_.x),m=Math.max(m,_.y);return[new d.P(o,a),new d.P(c,a),new d.P(c,m),new d.P(o,m),new d.P(o,a)]}}lngLatToCameraDepth(e,n){let o=this.locationCoordinate(e),a=[o.x*this.worldSize,o.y*this.worldSize,n,1];return d.af(a,a,this.modelViewProjectionMatrix),a[2]/a[3]}}function Ss(h,e){let n,o=!1,a=null,c=null,m=()=>{a=null,o&&(h.apply(c,n),a=setTimeout(m,e),o=!1)};return(..._)=>(o=!0,c=this,n=_,a||m(),a)}class no{constructor(e){this._getCurrentHash=()=>{let n=window.location.hash.replace("#","");if(this._hashName){let o;return n.split("&").map((a=>a.split("="))).forEach((a=>{a[0]===this._hashName&&(o=a)})),(o&&o[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{let n=this._getCurrentHash();if(n.length>=3&&!n.some((o=>isNaN(o)))){let o=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:o,pitch:+(n[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{let n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{let n=this._getCurrentHash();if(n.length===0)return;let o=n.join("/"),a=o;a.split("&").length>0&&(a=a.split("&")[0]),this._hashName&&(a=`${this._hashName}=${o}`);let c=window.location.hash.replace(a,"");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=Ss(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let n=this._map.getCenter(),o=Math.round(100*this._map.getZoom())/100,a=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,a),m=Math.round(n.lng*c)/c,_=Math.round(n.lat*c)/c,y=this._map.getBearing(),b=this._map.getPitch(),S="";if(S+=e?`/${m}/${_}/${o}`:`${o}/${_}/${m}`,(y||b)&&(S+="/"+Math.round(10*y)/10),b&&(S+=`/${Math.round(b)}`),this._hashName){let T=this._hashName,E=!1,D=window.location.hash.slice(1).split("&").map((F=>{let V=F.split("=")[0];return V===T?(E=!0,`${V}=${S}`):F})).filter((F=>F));return E||D.push(`${T}=${S}`),`#${D.join("&")}`}return`#${S}`}}let so={linearity:.3,easing:d.b8(0,0,.3,1)},aa=d.e({deceleration:2500,maxSpeed:1400},so),Pc=d.e({deceleration:20,maxSpeed:1400},so),vl=d.e({deceleration:1e3,maxSpeed:360},so),oo=d.e({deceleration:1e3,maxSpeed:90},so);class la{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:ue.now(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,n=ue.now();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let n={zoom:0,bearing:0,pitch:0,pan:new d.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:c}of this._inertiaBuffer)n.zoom+=c.zoomDelta||0,n.bearing+=c.bearingDelta||0,n.pitch+=c.pitchDelta||0,c.panDelta&&n.pan._add(c.panDelta),c.around&&(n.around=c.around),c.pinchAround&&(n.pinchAround=c.pinchAround);let o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,a={};if(n.pan.mag()){let c=Is(n.pan.mag(),o,d.e({},aa,e||{}));a.offset=n.pan.mult(c.amount/n.pan.mag()),a.center=this._map.transform.center,Ts(a,c)}if(n.zoom){let c=Is(n.zoom,o,Pc);a.zoom=this._map.transform.zoom+c.amount,Ts(a,c)}if(n.bearing){let c=Is(n.bearing,o,vl);a.bearing=this._map.transform.bearing+d.ac(c.amount,-179,179),Ts(a,c)}if(n.pitch){let c=Is(n.pitch,o,oo);a.pitch=this._map.transform.pitch+c.amount,Ts(a,c)}if(a.zoom||a.bearing){let c=n.pinchAround===void 0?n.around:n.pinchAround;a.around=c?this._map.unproject(c):this._map.getCenter()}return this.clear(),d.e(a,{noMoveStart:!0})}}function Ts(h,e){(!h.duration||h.duration<e.duration)&&(h.duration=e.duration,h.easing=e.easing)}function Is(h,e,n){let{maxSpeed:o,linearity:a,deceleration:c}=n,m=d.ac(h*a/(e/1e3),-o,o),_=Math.abs(m)/(c*a);return{easing:n.easing,duration:1e3*_,amount:m*(_/2)}}class di extends d.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o,a={}){let c=H.mousePos(n.getCanvas(),o),m=n.unproject(c);super(e,d.e({point:c,lngLat:m,originalEvent:o},a)),this._defaultPrevented=!1,this.target=n}}class dn extends d.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o){let a=e==="touchend"?o.changedTouches:o.touches,c=H.touchPos(n.getCanvasContainer(),a),m=c.map((y=>n.unproject(y))),_=c.reduce(((y,b,S,T)=>y.add(b.div(T.length))),new d.P(0,0));super(e,{points:c,point:_,lngLats:m,lngLat:n.unproject(_),originalEvent:o}),this._defaultPrevented=!1}}class bl extends d.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o){super(e,{originalEvent:o}),this._defaultPrevented=!1}}class wl{constructor(e,n){this._map=e,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new bl(e.type,this._map,e))}mousedown(e,n){return this._mousedownPos=n,this._firePreventable(new di(e.type,this._map,e))}mouseup(e){this._map.fire(new di(e.type,this._map,e))}click(e,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new di(e.type,this._map,e))}dblclick(e){return this._firePreventable(new di(e.type,this._map,e))}mouseover(e){this._map.fire(new di(e.type,this._map,e))}mouseout(e){this._map.fire(new di(e.type,this._map,e))}touchstart(e){return this._firePreventable(new dn(e.type,this._map,e))}touchmove(e){this._map.fire(new dn(e.type,this._map,e))}touchend(e){this._map.fire(new dn(e.type,this._map,e))}touchcancel(e){this._map.fire(new dn(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Zt{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new di(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new di("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new di(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cr{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.pointLocation(d.P.convert(e),this._map.terrain)}}class Vi{constructor(e,n){this._map=e,this._tr=new cr(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,n){this.isEnabled()&&e.shiftKey&&e.button===0&&(H.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(e,n){if(!this._active)return;let o=n;if(this._lastPos.equals(o)||!this._box&&o.dist(this._startPos)<this._clickTolerance)return;let a=this._startPos;this._lastPos=o,this._box||(this._box=H.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));let c=Math.min(a.x,o.x),m=Math.max(a.x,o.x),_=Math.min(a.y,o.y),y=Math.max(a.y,o.y);H.setTransform(this._box,`translate(${c}px,${_}px)`),this._box.style.width=m-c+"px",this._box.style.height=y-_+"px"}mouseupWindow(e,n){if(!this._active||e.button!==0)return;let o=this._startPos,a=n;if(this.reset(),H.suppressClick(),o.x!==a.x||o.y!==a.y)return this._map.fire(new d.k("boxzoomend",{originalEvent:e})),{cameraAnimation:c=>c.fitScreenCoordinates(o,a,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(H.remove(this._box),this._box=null),H.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new d.k(e,{originalEvent:n}))}}function Cs(h,e){if(h.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${e.length}`);let n={};for(let o=0;o<h.length;o++)n[h[o].identifier]=e[o];return n}class ca{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,n,o){(this.centroid||o.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),o.length===this.numTouches&&(this.centroid=(function(a){let c=new d.P(0,0);for(let m of a)c._add(m);return c.div(a.length)})(n),this.touches=Cs(o,n)))}touchmove(e,n,o){if(this.aborted||!this.centroid)return;let a=Cs(o,n);for(let c in this.touches){let m=a[c];(!m||m.dist(this.touches[c])>30)&&(this.aborted=!0)}}touchend(e,n,o){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),o.length===0){let a=!this.aborted&&this.centroid;if(this.reset(),a)return a}}}class ao{constructor(e){this.singleTap=new ca(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,n,o){this.singleTap.touchstart(e,n,o)}touchmove(e,n,o){this.singleTap.touchmove(e,n,o)}touchend(e,n,o){let a=this.singleTap.touchend(e,n,o);if(a){let c=e.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(a)<30;if(c&&m||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=a,this.count===this.numTaps)return this.reset(),a}}}class Nn{constructor(e){this._tr=new cr(e),this._zoomIn=new ao({numTouches:1,numTaps:2}),this._zoomOut=new ao({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,n,o){this._zoomIn.touchstart(e,n,o),this._zoomOut.touchstart(e,n,o)}touchmove(e,n,o){this._zoomIn.touchmove(e,n,o),this._zoomOut.touchmove(e,n,o)}touchend(e,n,o){let a=this._zoomIn.touchend(e,n,o),c=this._zoomOut.touchend(e,n,o),m=this._tr;return a?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(a)},{originalEvent:e})}):c?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(c)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Rr{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let n=this._moveFunction(...e);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(e,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,n){if(!this.isEnabled())return;let o=this._lastPoint;if(!o)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);let a=n.length?n[0]:n;return!this._moved&&a.dist(o)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=a,this._move(o,a))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&H.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let ha={0:1,2:2};class lo{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){let n=H.mouseButton(e);this._eventButton=n}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!(function(n,o){let a=ha[o];return n.buttons===void 0||(n.buttons&a)!==a})(e,this._eventButton)}isValidEndEvent(e){return H.mouseButton(e)===this._eventButton}}class ua{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}let co=h=>{h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=e=>{e.preventDefault()}},da=({enable:h,clickTolerance:e,bearingDegreesPerPixelMoved:n=.8})=>{let o=new lo({checkCorrectEvent:a=>H.mouseButton(a)===0&&a.ctrlKey||H.mouseButton(a)===2});return new Rr({clickTolerance:e,move:(a,c)=>({bearingDelta:(c.x-a.x)*n}),moveStateManager:o,enable:h,assignEvents:co})},pa=({enable:h,clickTolerance:e,pitchDegreesPerPixelMoved:n=-.5})=>{let o=new lo({checkCorrectEvent:a=>H.mouseButton(a)===0&&a.ctrlKey||H.mouseButton(a)===2});return new Rr({clickTolerance:e,move:(a,c)=>({pitchDelta:(c.y-a.y)*n}),moveStateManager:o,enable:h,assignEvents:co})};class pn{constructor(e,n){this._clickTolerance=e.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new d.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,n,o){return this._calculateTransform(e,n,o)}touchmove(e,n,o){if(this._active){if(!this._shouldBePrevented(o.length))return e.preventDefault(),this._calculateTransform(e,n,o);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,n,o){this._calculateTransform(e,n,o),this._active&&this._shouldBePrevented(o.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,o){o.length>0&&(this._active=!0);let a=Cs(o,n),c=new d.P(0,0),m=new d.P(0,0),_=0;for(let b in a){let S=a[b],T=this._touches[b];T&&(c._add(S),m._add(S.sub(T)),_++,a[b]=S)}if(this._touches=a,this._shouldBePrevented(_)||!m.mag())return;let y=m.div(_);return this._sum._add(y),this._sum.mag()<this._clickTolerance?void 0:{around:c.div(_),panDelta:y}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ho{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,n,o){this._firstTwoTouches||o.length<2||(this._firstTwoTouches=[o[0].identifier,o[1].identifier],this._start([n[0],n[1]]))}touchmove(e,n,o){if(!this._firstTwoTouches)return;e.preventDefault();let[a,c]=this._firstTwoTouches,m=Ps(o,n,a),_=Ps(o,n,c);if(!m||!_)return;let y=this._aroundCenter?null:m.add(_).div(2);return this._move([m,_],y,e)}touchend(e,n,o){if(!this._firstTwoTouches)return;let[a,c]=this._firstTwoTouches,m=Ps(o,n,a),_=Ps(o,n,c);m&&_||(this._active&&H.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Ps(h,e,n){for(let o=0;o<h.length;o++)if(h[o].identifier===n)return e[o]}function fa(h,e){return Math.log(h/e)/Math.LN2}class ma extends ho{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,n){let o=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(fa(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:fa(this._distance,o),pinchAround:n}}}function ga(h,e){return 180*h.angleWith(e)/Math.PI}class _a extends ho{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,n,o){let a=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:ga(this._vector,a),pinchAround:n}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let n=25/(Math.PI*this._minDiameter)*360,o=ga(e,this._startVector);return Math.abs(o)<n}}function uo(h){return Math.abs(h.y)>Math.abs(h.x)}class Vn extends ho{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,n,o){super.touchstart(e,n,o),this._currentTouchCount=o.length}_start(e){this._lastPoints=e,uo(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,n,o){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let a=e[0].sub(this._lastPoints[0]),c=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(a,c,o.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(a.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(e,n,o){if(this._valid!==void 0)return this._valid;let a=e.mag()>=2,c=n.mag()>=2;if(!a&&!c)return;if(!a||!c)return this._firstMove===void 0&&(this._firstMove=o),o-this._firstMove<100&&void 0;let m=e.y>0==n.y>0;return uo(e)&&uo(n)&&m}}let Sl={panStep:100,bearingStep:15,pitchStep:10};class Wi{constructor(e){this._tr=new cr(e);let n=Sl;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,o=0,a=0,c=0,m=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?o=-1:(e.preventDefault(),c=-1);break;case 39:e.shiftKey?o=1:(e.preventDefault(),c=1);break;case 38:e.shiftKey?a=1:(e.preventDefault(),m=-1);break;case 40:e.shiftKey?a=-1:(e.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(o=0,a=0),{cameraAnimation:_=>{let y=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:Ir,zoom:n?Math.round(y.zoom)+n*(e.shiftKey?2:1):y.zoom,bearing:y.bearing+o*this._bearingStep,pitch:y.pitch+a*this._pitchStep,offset:[-c*this._panStep,-m*this._panStep],center:y.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Ir(h){return h*(2-h)}let ya=4.000244140625;class hr{constructor(e,n){this._onTimeout=o=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(o)},this._map=e,this._tr=new cr(e),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,o=ue.now(),a=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,n!==0&&n%ya==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":a>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(a*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let n=H.mousePos(this._map.getCanvas(),e),o=this._tr;this._around=n.y>o.transform.height/2-o.transform.getHorizon()?d.N.convert(this._aroundCenter?o.center:o.unproject(n)):d.N.convert(o.center),this._aroundPoint=o.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let e=this._tr.transform;if(this._delta!==0){let y=this._type==="wheel"&&Math.abs(this._delta)>ya?this._wheelZoomRate:this._defaultZoomRate,b=2/(1+Math.exp(-Math.abs(this._delta*y)));this._delta<0&&b!==0&&(b=1/b);let S=typeof this._targetZoom=="number"?e.zoomScale(this._targetZoom):e.scale;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(S*b))),this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let n=typeof this._targetZoom=="number"?this._targetZoom:e.zoom,o=this._startZoom,a=this._easing,c,m=!1,_=ue.now()-this._lastWheelEventTime;if(this._type==="wheel"&&o&&a&&_){let y=Math.min(_/200,1),b=a(y);c=d.y.number(o,n,b),y<1?this._frameId||(this._frameId=!0):m=!0}else c=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:c-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=d.b9;if(this._prevEase){let o=this._prevEase,a=(ue.now()-o.start)/o.duration,c=o.easing(a+.01)-o.easing(a),m=.27/Math.sqrt(c*c+1e-4)*.01,_=Math.sqrt(.0729-m*m);n=d.b8(m,_,.25,1)}return this._prevEase={start:ue.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class fn{constructor(e,n){this._clickZoom=e,this._tapZoom=n}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Mc{constructor(e){this._tr=new cr(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:o=>{o.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ac{constructor(){this._tap=new ao({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,n,o){if(!this._swipePoint)if(this._tapTime){let a=n[0],c=e.timeStamp-this._tapTime<500,m=this._tapPoint.dist(a)<30;c&&m?o.length>0&&(this._swipePoint=a,this._swipeTouch=o[0].identifier):this.reset()}else this._tap.touchstart(e,n,o)}touchmove(e,n,o){if(this._tapTime){if(this._swipePoint){if(o[0].identifier!==this._swipeTouch)return;let a=n[0],c=a.y-this._swipePoint.y;return this._swipePoint=a,e.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(e,n,o)}touchend(e,n,o){if(this._tapTime)this._swipePoint&&o.length===0&&this.reset();else{let a=this._tap.touchend(e,n,o);a&&(this._tapTime=e.timeStamp,this._tapPoint=a)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Tl{constructor(e,n,o){this._el=e,this._mousePan=n,this._touchPan=o}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Il{constructor(e,n,o){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=n,this._mousePitch=o}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 xa{constructor(e,n,o,a){this._el=e,this._touchZoom=n,this._touchRotate=o,this._tapDragZoom=a,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Un{constructor(e,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=H.create("div","maplibregl-cooperative-gesture-screen",e);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let o=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),a=document.createElement("div");a.className="maplibregl-desktop-message",a.textContent=n,this._container.appendChild(a);let c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=o,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(H.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new d.k("cooperativegestureprevented",{gestureType:e,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}let Xi=h=>h.zoom||h.drag||h.pitch||h.rotate;class ke extends d.k{}function po(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta}class va{constructor(e,n){this.handleWindowEvent=a=>{this.handleEvent(a,`${a.type}Window`)},this.handleEvent=(a,c)=>{if(a.type==="blur")return void this.stop(!0);this._updatingCamera=!0;let m=a.type==="renderFrame"?void 0:a,_={needsRenderFrame:!1},y={},b={},S=a.touches,T=S?this._getMapTouches(S):void 0,E=T?H.touchPos(this._map.getCanvas(),T):H.mousePos(this._map.getCanvas(),a);for(let{handlerName:V,handler:$,allowed:q}of this._handlers){if(!$.isEnabled())continue;let G;this._blockedByActive(b,q,V)?$.reset():$[c||a.type]&&(G=$[c||a.type](a,E,T),this.mergeHandlerResult(_,y,G,V,m),G&&G.needsRenderFrame&&this._triggerRenderFrame()),(G||$.isActive())&&(b[V]=$)}let D={};for(let V in this._previousActiveHandlers)b[V]||(D[V]=m);this._previousActiveHandlers=b,(Object.keys(D).length||po(_))&&(this._changes.push([_,y,D]),this._triggerRenderFrame()),(Object.keys(b).length||po(_))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:F}=_;F&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],F(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new la(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);let o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[window,"blur",void 0]];for(let[a,c,m]of this._listeners)H.addEventListener(a,c,a===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(let[e,n,o]of this._listeners)H.removeEventListener(e,n,e===document?this.handleWindowEvent:this.handleEvent,o)}_addDefaultHandlers(e){let n=this._map,o=n.getCanvasContainer();this._add("mapEvent",new wl(n,e));let a=n.boxZoom=new Vi(n,e);this._add("boxZoom",a),e.interactive&&e.boxZoom&&a.enable();let c=n.cooperativeGestures=new Un(n,e.cooperativeGestures);this._add("cooperativeGestures",c),e.cooperativeGestures&&c.enable();let m=new Nn(n),_=new Mc(n);n.doubleClickZoom=new fn(_,m),this._add("tapZoom",m),this._add("clickZoom",_),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();let y=new Ac;this._add("tapDragZoom",y);let b=n.touchPitch=new Vn(n);this._add("touchPitch",b),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);let S=da(e),T=pa(e);n.dragRotate=new Il(e,S,T),this._add("mouseRotate",S,["mousePitch"]),this._add("mousePitch",T,["mouseRotate"]),e.interactive&&e.dragRotate&&n.dragRotate.enable();let E=(({enable:G,clickTolerance:B})=>{let J=new lo({checkCorrectEvent:ee=>H.mouseButton(ee)===0&&!ee.ctrlKey});return new Rr({clickTolerance:B,move:(ee,ne)=>({around:ne,panDelta:ne.sub(ee)}),activateOnStart:!0,moveStateManager:J,enable:G,assignEvents:co})})(e),D=new pn(e,n);n.dragPan=new Tl(o,E,D),this._add("mousePan",E),this._add("touchPan",D,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);let F=new _a,V=new ma;n.touchZoomRotate=new xa(o,V,F,y),this._add("touchRotate",F,["touchPan","touchZoom"]),this._add("touchZoom",V,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);let $=n.scrollZoom=new hr(n,(()=>this._triggerRenderFrame()));this._add("scrollZoom",$,["mousePan"]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);let q=n.keyboard=new Wi(n);this._add("keyboard",q),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new Zt(n))}_add(e,n,o){this._handlers.push({handlerName:e,handler:n,allowed:o}),this._handlersById[e]=n}stop(e){if(!this._updatingCamera){for(let{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Xi(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,n,o){for(let a in e)if(a!==o&&(!n||n.indexOf(a)<0))return!0;return!1}_getMapTouches(e){let n=[];for(let o of e)this._el.contains(o.target)&&n.push(o);return n}mergeHandlerResult(e,n,o,a,c){if(!o)return;d.e(e,o);let m={handlerName:a,originalEvent:o.originalEvent||c};o.zoomDelta!==void 0&&(n.zoom=m),o.panDelta!==void 0&&(n.drag=m),o.pitchDelta!==void 0&&(n.pitch=m),o.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){let e={},n={},o={};for(let[a,c,m]of this._changes)a.panDelta&&(e.panDelta=(e.panDelta||new d.P(0,0))._add(a.panDelta)),a.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+a.zoomDelta),a.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+a.bearingDelta),a.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+a.pitchDelta),a.around!==void 0&&(e.around=a.around),a.pinchAround!==void 0&&(e.pinchAround=a.pinchAround),a.noInertia&&(e.noInertia=a.noInertia),d.e(n,c),d.e(o,m);this._updateMapTransform(e,n,o),this._changes=[]}_updateMapTransform(e,n,o){let a=this._map,c=a._getTransformForUpdate(),m=a.terrain;if(!(po(e)||m&&this._terrainMovement))return this._fireEvents(n,o,!0);let{panDelta:_,zoomDelta:y,bearingDelta:b,pitchDelta:S,around:T,pinchAround:E}=e;E!==void 0&&(T=E),a._stop(!0),T=T||a.transform.centerPoint;let D=c.pointLocation(_?T.sub(_):T);b&&(c.bearing+=b),S&&(c.pitch+=S),y&&(c.zoom+=y),m?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?c.center=c.pointLocation(c.centerPoint.sub(_)):c.setLocationAtPoint(D,T):(this._terrainMovement=!0,this._map._elevationFreeze=!0,c.setLocationAtPoint(D,T)):c.setLocationAtPoint(D,T),a._applyUpdatedTransform(c),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,o,!0)}_fireEvents(e,n,o){let a=Xi(this._eventsInProgress),c=Xi(e),m={};for(let T in e){let{originalEvent:E}=e[T];this._eventsInProgress[T]||(m[`${T}start`]=E),this._eventsInProgress[T]=e[T]}!a&&c&&this._fireEvent("movestart",c.originalEvent);for(let T in m)this._fireEvent(T,m[T]);c&&this._fireEvent("move",c.originalEvent);for(let T in e){let{originalEvent:E}=e[T];this._fireEvent(T,E)}let _={},y;for(let T in this._eventsInProgress){let{handlerName:E,originalEvent:D}=this._eventsInProgress[T];this._handlersById[E].isActive()||(delete this._eventsInProgress[T],y=n[E]||D,_[`${T}end`]=y)}for(let T in _)this._fireEvent(T,_[T]);let b=Xi(this._eventsInProgress),S=(a||c)&&!b;if(S&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;let T=this._map._getTransformForUpdate();T.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(T)}if(o&&S){this._updatingCamera=!0;let T=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),E=D=>D!==0&&-this._bearingSnap<D&&D<this._bearingSnap;!T||!T.essential&&ue.prefersReducedMotion?(this._map.fire(new d.k("moveend",{originalEvent:y})),E(this._map.getBearing())&&this._map.resetNorth()):(E(T.bearing||this._map.getBearing())&&(T.bearing=0),T.freezeElevation=!0,this._map.easeTo(T,{originalEvent:y})),this._updatingCamera=!1}}_fireEvent(e,n){this._map.fire(new d.k(e,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{delete this._frameId,this.handleEvent(new ke("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Cl extends d.E{constructor(e,n){super(),this._renderFrameCallback=()=>{let o=Math.min((ue.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(o)),o<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState}))}getCenter(){return new d.N(this.transform.center.lng,this.transform.center.lat)}setCenter(e,n){return this.jumpTo({center:e},n)}panBy(e,n,o){return e=d.P.convert(e).mult(-1),this.panTo(this.transform.center,d.e({offset:e},n),o)}panTo(e,n,o){return this.easeTo(d.e({center:e},n),o)}getZoom(){return this.transform.zoom}setZoom(e,n){return this.jumpTo({zoom:e},n),this}zoomTo(e,n,o){return this.easeTo(d.e({zoom:e},n),o)}zoomIn(e,n){return this.zoomTo(this.getZoom()+1,e,n),this}zoomOut(e,n){return this.zoomTo(this.getZoom()-1,e,n),this}getBearing(){return this.transform.bearing}setBearing(e,n){return this.jumpTo({bearing:e},n),this}getPadding(){return this.transform.padding}setPadding(e,n){return this.jumpTo({padding:e},n),this}rotateTo(e,n,o){return this.easeTo(d.e({bearing:e},n),o)}resetNorth(e,n){return this.rotateTo(0,d.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(d.e({bearing:0,pitch:0,duration:1e3},e),n),this}snapToNorth(e,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,n):this}getPitch(){return this.transform.pitch}setPitch(e,n){return this.jumpTo({pitch:e},n),this}cameraForBounds(e,n){e=ae.convert(e).adjustAntiMeridian();let o=n&&n.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),o,n)}_cameraForBoxAndBearing(e,n,o,a){let c={top:0,bottom:0,right:0,left:0};if(typeof(a=d.e({padding:c,offset:[0,0],maxZoom:this.transform.maxZoom},a)).padding=="number"){let be=a.padding;a.padding={top:be,bottom:be,right:be,left:be}}a.padding=d.e(c,a.padding);let m=this.transform,_=m.padding,y=new ae(e,n),b=m.project(y.getNorthWest()),S=m.project(y.getNorthEast()),T=m.project(y.getSouthEast()),E=m.project(y.getSouthWest()),D=d.ba(-o),F=b.rotate(D),V=S.rotate(D),$=T.rotate(D),q=E.rotate(D),G=new d.P(Math.max(F.x,V.x,q.x,$.x),Math.max(F.y,V.y,q.y,$.y)),B=new d.P(Math.min(F.x,V.x,q.x,$.x),Math.min(F.y,V.y,q.y,$.y)),J=G.sub(B),ee=(m.width-(_.left+_.right+a.padding.left+a.padding.right))/J.x,ne=(m.height-(_.top+_.bottom+a.padding.top+a.padding.bottom))/J.y;if(ne<0||ee<0)return void d.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");let de=Math.min(m.scaleZoom(m.scale*Math.min(ee,ne)),a.maxZoom),ge=d.P.convert(a.offset),Ie=new d.P((a.padding.left-a.padding.right)/2,(a.padding.top-a.padding.bottom)/2).rotate(d.ba(o)),Ae=ge.add(Ie).mult(m.scale/m.zoomScale(de));return{center:m.unproject(b.add(T).div(2).sub(Ae)),zoom:de,bearing:o}}fitBounds(e,n,o){return this._fitInternal(this.cameraForBounds(e,n),n,o)}fitScreenCoordinates(e,n,o,a,c){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(d.P.convert(e)),this.transform.pointLocation(d.P.convert(n)),o,a),a,c)}_fitInternal(e,n,o){return e?(delete(n=d.e(e,n)).padding,n.linear?this.easeTo(n,o):this.flyTo(n,o)):this}jumpTo(e,n){this.stop();let o=this._getTransformForUpdate(),a=!1,c=!1,m=!1;return"zoom"in e&&o.zoom!==+e.zoom&&(a=!0,o.zoom=+e.zoom),e.center!==void 0&&(o.center=d.N.convert(e.center)),"bearing"in e&&o.bearing!==+e.bearing&&(c=!0,o.bearing=+e.bearing),"pitch"in e&&o.pitch!==+e.pitch&&(m=!0,o.pitch=+e.pitch),e.padding==null||o.isPaddingEqual(e.padding)||(o.padding=e.padding),this._applyUpdatedTransform(o),this.fire(new d.k("movestart",n)).fire(new d.k("move",n)),a&&this.fire(new d.k("zoomstart",n)).fire(new d.k("zoom",n)).fire(new d.k("zoomend",n)),c&&this.fire(new d.k("rotatestart",n)).fire(new d.k("rotate",n)).fire(new d.k("rotateend",n)),m&&this.fire(new d.k("pitchstart",n)).fire(new d.k("pitch",n)).fire(new d.k("pitchend",n)),this.fire(new d.k("moveend",n))}calculateCameraOptionsFromTo(e,n,o,a=0){let c=d.Z.fromLngLat(e,n),m=d.Z.fromLngLat(o,a),_=m.x-c.x,y=m.y-c.y,b=m.z-c.z,S=Math.hypot(_,y,b);if(S===0)throw new Error("Can't calculate camera options with same From and To");let T=Math.hypot(_,y),E=this.transform.scaleZoom(this.transform.cameraToCenterDistance/S/this.transform.tileSize),D=180*Math.atan2(_,-y)/Math.PI,F=180*Math.acos(T/S)/Math.PI;return F=b<0?90-F:90+F,{center:m.toLngLat(),zoom:E,pitch:F,bearing:D}}easeTo(e,n){var o;this._stop(!1,e.easeId),((e=d.e({offset:[0,0],duration:500,easing:d.b9},e)).animate===!1||!e.essential&&ue.prefersReducedMotion)&&(e.duration=0);let a=this._getTransformForUpdate(),c=a.zoom,m=a.bearing,_=a.pitch,y=a.padding,b="bearing"in e?this._normalizeBearing(e.bearing,m):m,S="pitch"in e?+e.pitch:_,T="padding"in e?e.padding:a.padding,E=d.P.convert(e.offset),D=a.centerPoint.add(E),F=a.pointLocation(D),{center:V,zoom:$}=a.getConstrained(d.N.convert(e.center||F),(o=e.zoom)!==null&&o!==void 0?o:c);this._normalizeCenter(V,a);let q=a.project(F),G=a.project(V).sub(q),B=a.zoomScale($-c),J,ee;e.around&&(J=d.N.convert(e.around),ee=a.locationPoint(J));let ne={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||S!==_,this._padding=!a.isPaddingEqual(T),this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,ne),this.terrain&&this._prepareElevation(V),this._ease((de=>{if(this._zooming&&(a.zoom=d.y.number(c,$,de)),this._rotating&&(a.bearing=d.y.number(m,b,de)),this._pitching&&(a.pitch=d.y.number(_,S,de)),this._padding&&(a.interpolatePadding(y,T,de),D=a.centerPoint.add(E)),this.terrain&&!e.freezeElevation&&this._updateElevation(de),J)a.setLocationAtPoint(J,ee);else{let ge=a.zoomScale(a.zoom-c),Ie=$>c?Math.min(2,B):Math.max(.5,B),Ae=Math.pow(Ie,1-de),be=a.unproject(q.add(G.mult(de*Ae)).mult(ge));a.setLocationAtPoint(a.renderWorldCopies?be.wrap():be,D)}this._applyUpdatedTransform(a),this._fireMoveEvents(n)}),(de=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,de)}),e),this}_prepareEase(e,n,o={}){this._moving=!0,n||o.moving||this.fire(new d.k("movestart",e)),this._zooming&&!o.zooming&&this.fire(new d.k("zoomstart",e)),this._rotating&&!o.rotating&&this.fire(new d.k("rotatestart",e)),this._pitching&&!o.pitching&&this.fire(new d.k("pitchstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);let n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){let o=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(o-(n-(o*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.elevation=d.y.number(this._elevationStart,this._elevationTarget,e)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){let n=e.getCameraPosition(),o=this.terrain.getElevationForLngLatZoom(n.lngLat,e.zoom);if(n.altitude<o){let a=this.calculateCameraOptionsFromTo(n.lngLat,o,e.center,e.elevation);return{pitch:a.pitch,zoom:a.zoom}}return{}}_applyUpdatedTransform(e){let n=[];if(this.terrain&&n.push((a=>this._elevateCameraIfInsideTerrain(a))),this.transformCameraUpdate&&n.push((a=>this.transformCameraUpdate(a))),!n.length)return;let o=e.clone();for(let a of n){let c=o.clone(),{center:m,zoom:_,pitch:y,bearing:b,elevation:S}=a(c);m&&(c.center=m),_!==void 0&&(c.zoom=_),y!==void 0&&(c.pitch=y),b!==void 0&&(c.bearing=b),S!==void 0&&(c.elevation=S),o.apply(c)}this.transform.apply(o)}_fireMoveEvents(e){this.fire(new d.k("move",e)),this._zooming&&this.fire(new d.k("zoom",e)),this._rotating&&this.fire(new d.k("rotate",e)),this._pitching&&this.fire(new d.k("pitch",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;let o=this._zooming,a=this._rotating,c=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,o&&this.fire(new d.k("zoomend",e)),a&&this.fire(new d.k("rotateend",e)),c&&this.fire(new d.k("pitchend",e)),this.fire(new d.k("moveend",e))}flyTo(e,n){var o;if(!e.essential&&ue.prefersReducedMotion){let Pe=d.M(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Pe,n)}this.stop(),e=d.e({offset:[0,0],speed:1.2,curve:1.42,easing:d.b9},e);let a=this._getTransformForUpdate(),c=a.zoom,m=a.bearing,_=a.pitch,y=a.padding,b="bearing"in e?this._normalizeBearing(e.bearing,m):m,S="pitch"in e?+e.pitch:_,T="padding"in e?e.padding:a.padding,E=d.P.convert(e.offset),D=a.centerPoint.add(E),F=a.pointLocation(D),{center:V,zoom:$}=a.getConstrained(d.N.convert(e.center||F),(o=e.zoom)!==null&&o!==void 0?o:c);this._normalizeCenter(V,a);let q=a.zoomScale($-c),G=a.project(F),B=a.project(V).sub(G),J=e.curve,ee=Math.max(a.width,a.height),ne=ee/q,de=B.mag();if("minZoom"in e){let Pe=d.ac(Math.min(e.minZoom,c,$),a.minZoom,a.maxZoom),Ge=ee/a.zoomScale(Pe-c);J=Math.sqrt(Ge/de*2)}let ge=J*J;function Ie(Pe){let Ge=(ne*ne-ee*ee+(Pe?-1:1)*ge*ge*de*de)/(2*(Pe?ne:ee)*ge*de);return Math.log(Math.sqrt(Ge*Ge+1)-Ge)}function Ae(Pe){return(Math.exp(Pe)-Math.exp(-Pe))/2}function be(Pe){return(Math.exp(Pe)+Math.exp(-Pe))/2}let ve=Ie(!1),Re=function(Pe){return be(ve)/be(ve+J*Pe)},We=function(Pe){return ee*((be(ve)*(Ae(Ge=ve+J*Pe)/be(Ge))-Ae(ve))/ge)/de;var Ge},Se=(Ie(!0)-ve)/J;if(Math.abs(de)<1e-6||!isFinite(Se)){if(Math.abs(ee-ne)<1e-6)return this.easeTo(e,n);let Pe=ne<ee?-1:1;Se=Math.abs(Math.log(ne/ee))/J,We=()=>0,Re=Ge=>Math.exp(Pe*J*Ge)}return e.duration="duration"in e?+e.duration:1e3*Se/("screenSpeed"in e?+e.screenSpeed/J:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=m!==b,this._pitching=S!==_,this._padding=!a.isPaddingEqual(T),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(V),this._ease((Pe=>{let Ge=Pe*Se,Lt=1/Re(Ge);a.zoom=Pe===1?$:c+a.scaleZoom(Lt),this._rotating&&(a.bearing=d.y.number(m,b,Pe)),this._pitching&&(a.pitch=d.y.number(_,S,Pe)),this._padding&&(a.interpolatePadding(y,T,Pe),D=a.centerPoint.add(E)),this.terrain&&!e.freezeElevation&&this._updateElevation(Pe);let tt=Pe===1?V:a.unproject(G.add(B.mult(We(Ge))).mult(Lt));a.setLocationAtPoint(a.renderWorldCopies?tt.wrap():tt,D),this._applyUpdatedTransform(a),this._fireMoveEvents(n)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,n){var o;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let a=this._onEaseEnd;delete this._onEaseEnd,a.call(this,n)}return e||(o=this.handlers)===null||o===void 0||o.stop(!1),this}_ease(e,n,o){o.animate===!1||o.duration===0?(e(1),n()):(this._easeStart=ue.now(),this._easeOptions=o,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=d.b3(e,-180,180);let o=Math.abs(e-n);return Math.abs(e-360-n)<o&&(e-=360),Math.abs(e+360-n)<o&&(e+=360),e}_normalizeCenter(e,n){if(!n.renderWorldCopies||n.lngRange)return;let o=e.lng-n.center.lng;e.lng+=o>180?-360:o<-180?360:0}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(d.N.convert(e),this.transform.tileZoom)-this.transform.elevation:null}}let jn={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class $n{constructor(e=jn){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=H.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=H.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=H.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){H.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,n){let o=this._map._getUIString(`AttributionControl.${n}`);e.title=o,e.setAttribute("aria-label",o)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((a=>typeof a!="string"?"":a))):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let a=this._map.style.stylesheet;this.styleOwner=a.owner,this.styleId=a.id}let n=this._map.style.sourceCaches;for(let a in n){let c=n[a];if(c.used||c.usedForTerrain){let m=c.getSource();m.attribution&&e.indexOf(m.attribution)<0&&e.push(m.attribution)}}e=e.filter((a=>String(a).trim())),e.sort(((a,c)=>a.length-c.length)),e=e.filter(((a,c)=>{for(let m=c+1;m<e.length;m++)if(e[m].indexOf(a)>=0)return!1;return!0}));let o=e.join(" | ");o!==this._attribHTML&&(this._attribHTML=o,e.length?(this._innerContainer.innerHTML=o,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class ba{constructor(e={}){this._updateCompact=()=>{let n=this._container.children;if(n.length){let o=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&o.classList.add("maplibregl-compact"):o.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=H.create("div","maplibregl-ctrl");let n=H.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){H.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(e){let n=++this._id;return this._queue.push({callback:e,id:n,cancelled:!1}),n}remove(e){let n=this._currentlyRunning,o=n?this._queue.concat(n):this._queue;for(let a of o)if(a.id===e)return void(a.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");let n=this._currentlyRunning=this._queue;this._queue=[];for(let o of n)if(!o.cancelled&&(o.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var wa=d.Y([{name:"a_pos3d",type:"Int16",components:3}]);class Ec extends d.E{constructor(e){super(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,e.usedForTerrain=!0,e.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];let o={};for(let a of e.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))o[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.posMatrix=new Float64Array(16),d.aP(a.posMatrix,0,d.X,0,d.X,0,1),this._tiles[a.key]=new $r(a,this.tileSize));for(let a in this._tiles)o[a]||delete this._tiles[a]}freeRtt(e){for(let n in this._tiles){let o=this._tiles[n];(!e||o.tileID.equals(e)||o.tileID.isChildOf(e)||e.isChildOf(o.tileID))&&(o.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e){let n={};for(let o of this._renderableTilesKeys){let a=this._tiles[o].tileID;if(a.canonical.equals(e.canonical)){let c=e.clone();c.posMatrix=new Float64Array(16),d.aP(c.posMatrix,0,d.X,0,d.X,0,1),n[o]=c}else if(a.canonical.isChildOf(e.canonical)){let c=e.clone();c.posMatrix=new Float64Array(16);let m=a.canonical.z-e.canonical.z,_=a.canonical.x-(a.canonical.x>>m<<m),y=a.canonical.y-(a.canonical.y>>m<<m),b=d.X>>m;d.aP(c.posMatrix,0,b,0,b,0,1),d.J(c.posMatrix,c.posMatrix,[-_*b,-y*b,0]),n[o]=c}else if(e.canonical.isChildOf(a.canonical)){let c=e.clone();c.posMatrix=new Float64Array(16);let m=e.canonical.z-a.canonical.z,_=e.canonical.x-(e.canonical.x>>m<<m),y=e.canonical.y-(e.canonical.y>>m<<m),b=d.X>>m;d.aP(c.posMatrix,0,d.X,0,d.X,0,1),d.J(c.posMatrix,c.posMatrix,[_*b,y*b,0]),d.K(c.posMatrix,c.posMatrix,[1/2**m,1/2**m,0]),n[o]=c}}return n}getSourceTile(e,n){let o=this.sourceCache._source,a=e.overscaledZ-this.deltaZoom;if(a>o.maxzoom&&(a=o.maxzoom),a<o.minzoom)return null;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(a).key);let c=this.sourceCache.getTileByID(this._sourceTileCache[e.key]);if((!c||!c.dem)&&n)for(;a>=o.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(e.scaledTo(a--).key);return c}tilesAfterTime(e=Date.now()){return Object.values(this._tiles).filter((n=>n.timeAdded>=e))}}class Sa{constructor(e,n,o){this.painter=e,this.sourceCache=new Ec(n),this.options=o,this.exaggeration=typeof o.exaggeration=="number"?o.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,o,a=d.X){var c;if(!(n>=0&&n<a&&o>=0&&o<a))return 0;let m=this.getTerrainData(e),_=(c=m.tile)===null||c===void 0?void 0:c.dem;if(!_)return 0;let y=(function(F,V,$){var q=V[0],G=V[1];return F[0]=$[0]*q+$[4]*G+$[12],F[1]=$[1]*q+$[5]*G+$[13],F})([],[n/a*d.X,o/a*d.X],m.u_terrain_matrix),b=[y[0]*_.dim,y[1]*_.dim],S=Math.floor(b[0]),T=Math.floor(b[1]),E=b[0]-S,D=b[1]-T;return _.get(S,T)*(1-E)*(1-D)+_.get(S+1,T)*E*(1-D)+_.get(S,T+1)*(1-E)*D+_.get(S+1,T+1)*E*D}getElevationForLngLatZoom(e,n){if(!d.bb(n,e.wrap()))return 0;let{tileID:o,mercatorX:a,mercatorY:c}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getElevation(o,a%d.X,c%d.X,d.X)}getElevation(e,n,o,a=d.X){return this.getDEMElevation(e,n,o,a)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){let a=this.painter.context,c=new d.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new et(a,c,a.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new et(a,new d.R({width:1,height:1}),a.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(a.gl.NEAREST,a.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=d.an([])}let n=this.sourceCache.getSourceTile(e,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){let a=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new et(a,n.dem.getPixels(),a.gl.RGBA,{premultiply:!1}),n.demTexture.bind(a.gl.NEAREST,a.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}let o=n&&n+n.tileID.key+e.key;if(o&&!this._demMatrixCache[o]){let a=this.sourceCache.sourceCache._source.maxzoom,c=e.canonical.z-n.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=a?c=e.canonical.z-a:d.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let m=e.canonical.x-(e.canonical.x>>c<<c),_=e.canonical.y-(e.canonical.y>>c<<c),y=d.bc(new Float64Array(16),[1/(d.X<<c),1/(d.X<<c),0]);d.J(y,y,[m*d.X,_*d.X,0]),this._demMatrixCache[e.key]={matrix:y,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:o?this._demMatrixCache[e.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(e){let n=this.painter,o=n.width/devicePixelRatio,a=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===o&&this._fbo.height===a||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new et(n.context,{width:o,height:a,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new et(n.context,{width:o,height:a,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(o,a,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,o,a))),this._fbo.colorAttachment.set(e==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let c=0,m=0;c<this._coordsTextureSize;c++)for(let _=0;_<this._coordsTextureSize;_++,m+=4)n[m+0]=255&_,n[m+1]=255&c,n[m+2]=_>>8<<4|c>>8,n[m+3]=0;let o=new d.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),a=new et(e,o,e.gl.RGBA,{premultiply:!1});return a.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=a,a}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);let n=new Uint8Array(4),o=this.painter.context,a=o.gl,c=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),_=Math.round(this.painter.height/devicePixelRatio);o.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),a.readPixels(c,_-m-1,1,1,a.RGBA,a.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null);let y=n[0]+(n[2]>>4<<8),b=n[1]+((15&n[2])<<8),S=this.coordsIndex[255-n[3]],T=S&&this.sourceCache.getTileByID(S);if(!T)return null;let E=this._coordsTextureSize,D=(1<<T.tileID.canonical.z)*E;return new d.Z((T.tileID.canonical.x*E+y)/D+T.tileID.wrap,(T.tileID.canonical.y*E+b)/D,this.getElevation(T.tileID,y,b,E))}depthAtPoint(e){let n=new Uint8Array(4),o=this.painter.context,a=o.gl;return o.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),a.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,a.RGBA,a.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;let e=this.painter.context,n=new d.bd,o=new d.aY,a=this.meshSize,c=d.X/a,m=a*a;for(let T=0;T<=a;T++)for(let E=0;E<=a;E++)n.emplaceBack(E*c,T*c,0);for(let T=0;T<m;T+=a+1)for(let E=0;E<a;E++)o.emplaceBack(E+T,a+E+T+1,a+E+T+2),o.emplaceBack(E+T,a+E+T+2,E+T+1);let _=n.length,y=_+2*(a+1);for(let T of[0,1])for(let E=0;E<=a;E++)for(let D of[0,1])n.emplaceBack(E*c,T*d.X,D);for(let T=0;T<2*a;T+=2)o.emplaceBack(y+T,y+T+1,y+T+3),o.emplaceBack(y+T,y+T+3,y+T+2),o.emplaceBack(_+T,_+T+3,_+T+1),o.emplaceBack(_+T,_+T+2,_+T+3);let b=n.length,S=b+2*(a+1);for(let T of[0,1])for(let E=0;E<=a;E++)for(let D of[0,1])n.emplaceBack(T*d.X,E*c,D);for(let T=0;T<2*a;T+=2)o.emplaceBack(b+T,b+T+1,b+T+3),o.emplaceBack(b+T,b+T+3,b+T+2),o.emplaceBack(S+T,S+T+3,S+T+1),o.emplaceBack(S+T,S+T+2,S+T+3);return this._mesh=new io(e.createVertexBuffer(n,wa.members),e.createIndexBuffer(o),d.a0.simpleSegment(0,0,n.length,o.length)),this._mesh}getMeshFrameDelta(e){return 2*Math.PI*d.be/Math.pow(2,e)/5}getMinTileElevationForLngLatZoom(e,n){var o;let{tileID:a}=this._getOverscaledTileIDFromLngLatZoom(e,n);return(o=this.getMinMaxElevation(a).minElevation)!==null&&o!==void 0?o:0}getMinMaxElevation(e){let n=this.getTerrainData(e).tile,o={minElevation:null,maxElevation:null};return n&&n.dem&&(o.minElevation=n.dem.min*this.exaggeration,o.maxElevation=n.dem.max*this.exaggeration),o}_getOverscaledTileIDFromLngLatZoom(e,n){let o=d.Z.fromLngLat(e.wrap()),a=(1<<n)*d.X,c=o.x*a,m=o.y*a,_=Math.floor(c/d.X),y=Math.floor(m/d.X);return{tileID:new d.S(n,0,n,_,y),mercatorX:c,mercatorY:m}}}class kc{constructor(e,n,o){this._context=e,this._size=n,this._tileSize=o,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){let n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),o=new et(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return o.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(o.texture),{id:e,fbo:n,texture:o,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((n=>e.id!==n)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(let n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");let e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(let e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&this._objects.some((e=>!e.inUse))===!1}}let qn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Pl{constructor(e,n){this.painter=e,this.terrain=n,this.pool=new kc(e.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((o=>!e._layers[o].isHidden(n))),this._coordsDescendingInv={};for(let o in e.sourceCaches){this._coordsDescendingInv[o]={};let a=e.sourceCaches[o].getVisibleCoordinates();for(let c of a){let m=this.terrain.sourceCache.getTerrainCoords(c);for(let _ in m)this._coordsDescendingInv[o][_]||(this._coordsDescendingInv[o][_]=[]),this._coordsDescendingInv[o][_].push(m[_])}}this._coordsDescendingInvStr={};for(let o of e._order){let a=e._layers[o],c=a.source;if(qn[a.type]&&!this._coordsDescendingInvStr[c]){this._coordsDescendingInvStr[c]={};for(let m in this._coordsDescendingInv[c])this._coordsDescendingInvStr[c][m]=this._coordsDescendingInv[c][m].map((_=>_.key)).sort().join()}}for(let o of this._renderableTiles)for(let a in this._coordsDescendingInvStr){let c=this._coordsDescendingInvStr[a][o.tileID.key];c&&c!==o.rttCoords[a]&&(o.rtt=[])}}renderLayer(e){if(e.isHidden(this.painter.transform.zoom))return!1;let n=e.type,o=this.painter,a=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(qn[n]&&(this._prevType&&qn[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(e.id),!a))return!0;if(qn[this._prevType]||qn[n]&&a){this._prevType=n;let c=this._stacks.length-1,m=this._stacks[c]||[];for(let _ of this._renderableTiles){if(this.pool.isFull()&&(xl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(_),_.rtt[c]){let b=this.pool.getObjectForId(_.rtt[c].id);if(b.stamp===_.rtt[c].stamp){this.pool.useObject(b);continue}}let y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),_.rtt[c]={id:y.id,stamp:y.stamp},o.context.bindFramebuffer.set(y.fbo.framebuffer),o.context.clear({color:d.aM.transparent,stencil:0}),o.currentStencilSource=void 0;for(let b=0;b<m.length;b++){let S=o.style._layers[m[b]],T=S.source?this._coordsDescendingInv[S.source][_.tileID.key]:[_.tileID];o.context.viewport.set([0,0,y.fbo.width,y.fbo.height]),o._renderTileClippingMasks(S,T),o.renderLayer(o,o.style.sourceCaches[S.source],S,T),S.source&&(_.rttCoords[S.source]=this._coordsDescendingInvStr[S.source][_.tileID.key])}}return xl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),qn[n]}return!1}}let Ta={"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 \u2318 + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Ml=me,zc={hash:!1,interactive:!0,bearingSnap:7,attributionControl:jn,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:d.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},Ia=h=>{h.touchstart=h.dragStart,h.touchmoveWindow=h.dragMove,h.touchend=h.dragEnd},Lc={showCompass:!0,showZoom:!0,visualizePitch:!1};class Dc{constructor(e,n,o=!1){this.mousedown=m=>{this.startMouse(d.e({},m,{ctrlKey:!0,preventDefault:()=>m.preventDefault()}),H.mousePos(this.element,m)),H.addEventListener(window,"mousemove",this.mousemove),H.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=m=>{this.moveMouse(m,H.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=H.touchPos(this.element,m.targetTouches)[0],this.startTouch(m,this._startPos),H.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),H.addEventListener(window,"touchend",this.touchend))},this.touchmove=m=>{m.targetTouches.length!==1?this.reset():(this._lastPos=H.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;let a=e.dragRotate._mouseRotate.getClickTolerance(),c=e.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=da({clickTolerance:a,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:_,bearingDegreesPerPixelMoved:y=.8})=>{let b=new ua;return new Rr({clickTolerance:_,move:(S,T)=>({bearingDelta:(T.x-S.x)*y}),moveStateManager:b,enable:m,assignEvents:Ia})})({clickTolerance:a,enable:!0}),this.map=e,o&&(this.mousePitch=pa({clickTolerance:c,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:_,pitchDegreesPerPixelMoved:y=-.5})=>{let b=new ua;return new Rr({clickTolerance:_,move:(S,T)=>({pitchDelta:(T.y-S.y)*y}),moveStateManager:b,enable:m,assignEvents:Ia})})({clickTolerance:c,enable:!0})),H.addEventListener(n,"mousedown",this.mousedown),H.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),H.addEventListener(n,"touchcancel",this.reset)}startMouse(e,n){this.mouseRotate.dragStart(e,n),this.mousePitch&&this.mousePitch.dragStart(e,n),H.disableDrag()}startTouch(e,n){this.touchRotate.dragStart(e,n),this.touchPitch&&this.touchPitch.dragStart(e,n),H.disableDrag()}moveMouse(e,n){let o=this.map,{bearingDelta:a}=this.mouseRotate.dragMove(e,n)||{};if(a&&o.setBearing(o.getBearing()+a),this.mousePitch){let{pitchDelta:c}=this.mousePitch.dragMove(e,n)||{};c&&o.setPitch(o.getPitch()+c)}}moveTouch(e,n){let o=this.map,{bearingDelta:a}=this.touchRotate.dragMove(e,n)||{};if(a&&o.setBearing(o.getBearing()+a),this.touchPitch){let{pitchDelta:c}=this.touchPitch.dragMove(e,n)||{};c&&o.setPitch(o.getPitch()+c)}}off(){let e=this.element;H.removeEventListener(e,"mousedown",this.mousedown),H.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),H.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),H.removeEventListener(window,"touchend",this.touchend),H.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){H.enableDrag(),H.removeEventListener(window,"mousemove",this.mousemove),H.removeEventListener(window,"mouseup",this.mouseup),H.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),H.removeEventListener(window,"touchend",this.touchend)}}let Ui;function zt(h,e,n){let o=new d.N(h.lng,h.lat);if(h=new d.N(h.lng,h.lat),e){let a=new d.N(h.lng-360,h.lat),c=new d.N(h.lng+360,h.lat),m=n.locationPoint(h).distSqr(e);n.locationPoint(a).distSqr(e)<m?h=a:n.locationPoint(c).distSqr(e)<m&&(h=c)}for(;Math.abs(h.lng-n.center.lng)>180;){let a=n.locationPoint(h);if(a.x>=0&&a.y>=0&&a.x<=n.width&&a.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h.lng!==o.lng&&n.locationPoint(h).y>n.height/2-n.getHorizon()?h:o}let Zn={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 fo(h,e,n){let o=h.classList;for(let a in Zn)o.remove(`maplibregl-${n}-anchor-${a}`);o.add(`maplibregl-${n}-anchor-${e}`)}class mo extends d.E{constructor(e){if(super(),this._onKeyPress=n=>{let o=n.code,a=n.charCode||n.keyCode;o!=="Space"&&o!=="Enter"&&a!==32&&a!==13||this.togglePopup()},this._onMapClick=n=>{let o=n.originalEvent.target,a=this._element;this._popup&&(o===a||a.contains(o))&&this.togglePopup()},this._update=n=>{var o;if(!this._map)return;let a=this._map.loaded()&&!this._map.isMoving();(n?.type==="terrain"||n?.type==="render"&&!a)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?zt(this._lngLat,this._flatPos,this._map.transform):(o=this._lngLat)===null||o===void 0?void 0:o.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let m="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?m="rotateX(0deg)":this._pitchAlignment==="map"&&(m=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),H.setTransform(this._element,`${Zn[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${m} ${c}`),ue.frameAsync(new AbortController).then((()=>{this._updateOpacity(n&&n.type==="moveend")})).catch((()=>{}))},this._onMove=n=>{if(!this._isDragging){let o=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=o}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new d.k("dragstart"))),this.fire(new d.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 d.k("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(e?.opacity,e?.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=d.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=H.create("div");let n=H.createNS("http://www.w3.org/2000/svg","svg"),o=41,a=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${o}px`),n.setAttributeNS(null,"width",`${a}px`),n.setAttributeNS(null,"viewBox",`0 0 ${a} ${o}`);let c=H.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");let m=H.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");let _=H.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");let 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(let q of y){let G=H.createNS("http://www.w3.org/2000/svg","ellipse");G.setAttributeNS(null,"opacity","0.04"),G.setAttributeNS(null,"cx","10.5"),G.setAttributeNS(null,"cy","5.80029008"),G.setAttributeNS(null,"rx",q.rx),G.setAttributeNS(null,"ry",q.ry),_.appendChild(G)}let b=H.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);let S=H.createNS("http://www.w3.org/2000/svg","path");S.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(S);let T=H.createNS("http://www.w3.org/2000/svg","g");T.setAttributeNS(null,"opacity","0.25"),T.setAttributeNS(null,"fill","#000000");let E=H.createNS("http://www.w3.org/2000/svg","path");E.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),T.appendChild(E);let D=H.createNS("http://www.w3.org/2000/svg","g");D.setAttributeNS(null,"transform","translate(6.0, 7.0)"),D.setAttributeNS(null,"fill","#FFFFFF");let F=H.createNS("http://www.w3.org/2000/svg","g");F.setAttributeNS(null,"transform","translate(8.0, 8.0)");let V=H.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");let $=H.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"),F.appendChild(V),F.appendChild($),m.appendChild(_),m.appendChild(b),m.appendChild(T),m.appendChild(D),m.appendChild(F),n.appendChild(m),n.setAttributeNS(null,"height",o*this._scale+"px"),n.setAttributeNS(null,"width",a*this._scale+"px"),this._element.appendChild(n),this._offset=d.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(n=>{n.preventDefault()})),this._element.addEventListener("mousedown",(n=>{n.preventDefault()})),fo(this._element,this._anchor,"marker"),e&&e.className)for(let n of e.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),H.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=d.N.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){let a=Math.abs(13.5)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[a,-1*(38.1-13.5+a)],"bottom-right":[-a,-1*(38.1-13.5+a)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){let e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var n,o;if(!(!((n=this._map)===null||n===void 0)&&n.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}let a=this._map,c=a.terrain.depthAtPoint(this._pos),m=a.terrain.getElevationForLngLatZoom(this._lngLat,a.transform.tileZoom);if(a.transform.lngLatToCameraDepth(this._lngLat,m)-c<.006)return void(this._element.style.opacity=this._opacity);let _=-this._offset.y/a.transform._pixelPerMeter,y=Math.sin(a.getPitch()*Math.PI/180)*_,b=a.terrain.depthAtPoint(new d.P(this._pos.x,this._pos.y-this._offset.y)),S=a.transform.lngLatToCameraDepth(this._lngLat,m+y)-b>.006;!((o=this._popup)===null||o===void 0)&&o.isOpen()&&S&&this._popup.remove(),this._element.style.opacity=S?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=d.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,n){return e===void 0&&n===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}let Al={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},Ms=0,As=!1,Cr={maxWidth:100,unit:"metric"};function Es(h,e,n){let o=n&&n.maxWidth||100,a=h._container.clientHeight/2,c=h.unproject([0,a]),m=h.unproject([o,a]),_=c.distanceTo(m);if(n&&n.unit==="imperial"){let y=3.2808*_;y>5280?De(e,o,y/5280,h._getUIString("ScaleControl.Miles")):De(e,o,y,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?De(e,o,_/1852,h._getUIString("ScaleControl.NauticalMiles")):_>=1e3?De(e,o,_/1e3,h._getUIString("ScaleControl.Kilometers")):De(e,o,_,h._getUIString("ScaleControl.Meters"))}function De(h,e,n,o){let a=(function(c){let m=Math.pow(10,`${Math.floor(c)}`.length-1),_=c/m;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:(function(y){let b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b})(_),m*_})(n);h.style.width=e*(a/n)+"px",h.innerHTML=`${a}&nbsp;${o}`}let qe={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},go=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function _o(h){if(h){if(typeof h=="number"){let e=Math.round(Math.abs(h)/Math.SQRT2);return{center:new d.P(0,0),top:new d.P(0,h),"top-left":new d.P(e,e),"top-right":new d.P(-e,e),bottom:new d.P(0,-h),"bottom-left":new d.P(e,-e),"bottom-right":new d.P(-e,-e),left:new d.P(h,0),right:new d.P(-h,0)}}if(h instanceof d.P||Array.isArray(h)){let e=d.P.convert(h);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:d.P.convert(h.center||[0,0]),top:d.P.convert(h.top||[0,0]),"top-left":d.P.convert(h["top-left"]||[0,0]),"top-right":d.P.convert(h["top-right"]||[0,0]),bottom:d.P.convert(h.bottom||[0,0]),"bottom-left":d.P.convert(h["bottom-left"]||[0,0]),"bottom-right":d.P.convert(h["bottom-right"]||[0,0]),left:d.P.convert(h.left||[0,0]),right:d.P.convert(h.right||[0,0])}}return _o(new d.P(0,0))}let Ca=me;I.AJAXError=d.bh,I.Evented=d.E,I.LngLat=d.N,I.MercatorCoordinate=d.Z,I.Point=d.P,I.addProtocol=d.bi,I.config=d.a,I.removeProtocol=d.bj,I.AttributionControl=$n,I.BoxZoomHandler=Vi,I.CanvasSource=Zi,I.CooperativeGesturesHandler=Un,I.DoubleClickZoomHandler=fn,I.DragPanHandler=Tl,I.DragRotateHandler=Il,I.EdgeInsets=Bn,I.FullscreenControl=class extends d.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var e;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=n?.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:d.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=H.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){H.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let h=this._fullscreenButton=H.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);H.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new d.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new d.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()}},I.GeoJSONSource=hs,I.GeolocateControl=class extends d.E{constructor(h){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new d.k("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new d.k("geolocate",e)),this._finish()}},this._updateCamera=e=>{let n=new d.N(e.coords.longitude,e.coords.latitude),o=e.coords.accuracy,a=this._map.getBearing(),c=d.e({bearing:a},this.options.fitBoundsOptions),m=ae.fromLngLat(n,o);this._map.fitBounds(m,c,{geolocateSource:!0})},this._updateMarker=e=>{if(e){let n=new d.N(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(e.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;let n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&As)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new d.k("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=H.create("button","maplibregl-ctrl-geolocate",this._container),H.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(e===!1){d.w("Geolocation support is not available so the GeolocateControl will be disabled.");let n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{let n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=H.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new mo({element:this._dotElement}),this._circleElement=H.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new mo({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new d.k("trackuserlocationend")),this.fire(new d.k("userlocationlostfocus")))}))}},this.options=d.e({},Al,h)}onAdd(h){return this._map=h,this._container=H.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),(function(){return d._(this,arguments,void 0,(function*(e=!1){if(Ui!==void 0&&!e)return Ui;if(window.navigator.permissions===void 0)return Ui=!!window.navigator.geolocation,Ui;try{Ui=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Ui=!!window.navigator.geolocation}return Ui}))})().then((e=>this._finishSetupUI(e))),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),H.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Ms=0,As=!1}_isOutOfMapMaxBounds(h){let e=this._map.getMaxBounds(),n=h.coords;return e&&(n.longitude<e.getWest()||n.longitude>e.getEast()||n.latitude<e.getSouth()||n.latitude>e.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(){let h=this._map.getBounds(),e=h.getSouthEast(),n=h.getNorthEast(),o=e.distanceTo(n),a=Math.ceil(this._accuracy/(o/this._map._container.clientHeight)*2);this._circleElement.style.width=`${a}px`,this._circleElement.style.height=`${a}px`}trigger(){if(!this._setup)return d.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 d.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Ms--,As=!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 d.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 d.k("trackuserlocationstart")),this.fire(new d.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let h;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ms++,Ms>1?(h={maximumAge:6e5,timeout:0},As=!0):(h=this.options.positionOptions,As=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,h)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},I.Hash=no,I.ImageSource=zr,I.KeyboardHandler=Wi,I.LngLatBounds=ae,I.LogoControl=ba,I.Map=class extends Cl{constructor(h){d.bf.mark(d.bg.create);let e=Object.assign(Object.assign({},zc),h);if(e.minZoom!=null&&e.maxZoom!=null&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(e.minPitch!=null&&e.maxPitch!=null&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(e.minPitch!=null&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(e.maxPitch!=null&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new On(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),{bearingSnap:e.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new ht,this._controls=[],this._mapId=d.a4(),this._contextLost=n=>{n.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new d.k("webglcontextlost",{originalEvent:n}))},this._contextRestored=n=>{this._setupPainter(),this.resize(),this._update(),this.fire(new d.k("webglcontextrestored",{originalEvent:n}))},this._onMapScroll=n=>{if(n.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._maxTileCacheZoomLevels=e.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=e.preserveDrawingBuffer===!0,this._antialias=e.antialias===!0,this._trackResize=e.trackResize===!0,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles===!0,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions===!0,this._collectResourceTiming=e.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Ta),e.locale),this._clickTolerance=e.clickTolerance,this._overridePixelRatio=e.pixelRatio,this._maxCanvasSize=e.maxCanvasSize,this.transformCameraUpdate=e.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=e.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Ke.addThrottleControl((()=>this.isMoving())),this._requestManager=new $e(e.transformRequest),typeof e.container=="string"){if(this._container=document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))).on("moveend",(()=>this._update(!1))).on("zoom",(()=>this._update(!0))).on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})).once("idle",(()=>{this._idleTriggered=!0})),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let n=!1,o=Ss((a=>{this._trackResize&&!this._removed&&(this.resize(a),this.redraw())}),50);this._resizeObserver=new ResizeObserver((a=>{n?o(a):n=!0})),this._resizeObserver.observe(this._container)}this.handlers=new va(this,e),this._hash=e.hash&&new no(typeof e.hash=="string"&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,d.e({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,this._validateStyle=e.validateStyle,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new $n(typeof e.attributionControl=="boolean"?void 0:e.attributionControl)),e.maplibreLogo&&this.addControl(new ba,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(n=>{this._update(n.dataType==="style"),this.fire(new d.k(`${n.dataType}data`,n))})),this.on("dataloading",(n=>{this.fire(new d.k(`${n.dataType}dataloading`,n))})),this.on("dataabort",(n=>{this.fire(new d.k("sourcedataabort",n))}))}_getMapId(){return this._mapId}addControl(h,e){if(e===void 0&&(e=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new d.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let n=h.onAdd(this);this._controls.push(h);let o=this._controlPositions[e];return e.indexOf("bottom")!==-1?o.insertBefore(n,o.firstChild):o.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new d.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let e=this._controls.indexOf(h);return e>-1&&this._controls.splice(e,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}calculateCameraOptionsFromTo(h,e,n,o){return o==null&&this.terrain&&(o=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,e,n,o)}resize(h){var e;let n=this._containerDimensions(),o=n[0],a=n[1],c=this._getClampedPixelRatio(o,a);if(this._resizeCanvas(o,a,c),this.painter.resize(o,a,c),this.painter.overLimit()){let _=this.painter.context.gl;this._maxCanvasSize=[_.drawingBufferWidth,_.drawingBufferHeight];let y=this._getClampedPixelRatio(o,a);this._resizeCanvas(o,a,y),this.painter.resize(o,a,y)}this.transform.resize(o,a),(e=this._requestedCameraState)===null||e===void 0||e.resize(o,a);let m=!this._moving;return m&&(this.stop(),this.fire(new d.k("movestart",h)).fire(new d.k("move",h))),this.fire(new d.k("resize",h)),m&&this.fire(new d.k("moveend",h)),this}_getClampedPixelRatio(h,e){let{0:n,1:o}=this._maxCanvasSize,a=this.getPixelRatio(),c=h*a,m=e*a;return Math.min(c>n?n/c:1,m>o?o/m:1)*a}getPixelRatio(){var h;return(h=this._overridePixelRatio)!==null&&h!==void 0?h:devicePixelRatio}setPixelRatio(h){this._overridePixelRatio=h,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(h){return this.transform.setMaxBounds(ae.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.minZoom=h,this._update(),this.getZoom()<h&&this.setZoom(h),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(h){if((h=h??22)>=this.transform.minZoom)return this.transform.maxZoom=h,this._update(),this.getZoom()>h&&this.setZoom(h),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.minPitch=h,this._update(),this.getPitch()<h&&this.setPitch(h),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(h){if((h=h??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(h>=this.transform.minPitch)return this.transform.maxPitch=h,this._update(),this.getPitch()>h&&this.setPitch(h),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.renderWorldCopies=h,this._update()}project(h){return this.transform.locationPoint(d.N.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.pointLocation(d.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,e,n){if(h==="mouseenter"||h==="mouseover"){let o=!1;return{layers:e,listener:n,delegates:{mousemove:c=>{let m=e.filter((y=>this.getLayer(y))),_=m.length!==0?this.queryRenderedFeatures(c.point,{layers:m}):[];_.length?o||(o=!0,n.call(this,new di(h,this,c.originalEvent,{features:_}))):o=!1},mouseout:()=>{o=!1}}}}if(h==="mouseleave"||h==="mouseout"){let o=!1;return{layers:e,listener:n,delegates:{mousemove:m=>{let _=e.filter((y=>this.getLayer(y)));(_.length!==0?this.queryRenderedFeatures(m.point,{layers:_}):[]).length?o=!0:o&&(o=!1,n.call(this,new di(h,this,m.originalEvent)))},mouseout:m=>{o&&(o=!1,n.call(this,new di(h,this,m.originalEvent)))}}}}{let o=a=>{let c=e.filter((_=>this.getLayer(_))),m=c.length!==0?this.queryRenderedFeatures(a.point,{layers:c}):[];m.length&&(a.features=m,n.call(this,a),delete a.features)};return{layers:e,listener:n,delegates:{[h]:o}}}}_saveDelegatedListener(h,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(e)}_removeDelegatedListener(h,e,n){if(!this._delegatedListeners||!this._delegatedListeners[h])return;let o=this._delegatedListeners[h];for(let a=0;a<o.length;a++){let c=o[a];if(c.listener===n&&c.layers.length===e.length&&c.layers.every((m=>e.includes(m)))){for(let m in c.delegates)this.off(m,c.delegates[m]);return void o.splice(a,1)}}}on(h,e,n){if(n===void 0)return super.on(h,e);let o=this._createDelegatedListener(h,typeof e=="string"?[e]:e,n);this._saveDelegatedListener(h,o);for(let a in o.delegates)this.on(a,o.delegates[a]);return this}once(h,e,n){if(n===void 0)return super.once(h,e);let o=typeof e=="string"?[e]:e,a=this._createDelegatedListener(h,o,n);for(let c in a.delegates){let m=a.delegates[c];a.delegates[c]=(..._)=>{this._removeDelegatedListener(h,o,n),m(..._)}}this._saveDelegatedListener(h,a);for(let c in a.delegates)this.once(c,a.delegates[c]);return this}off(h,e,n){return n===void 0?super.off(h,e):(this._removeDelegatedListener(h,typeof e=="string"?[e]:e,n),this)}queryRenderedFeatures(h,e){if(!this.style)return[];let n,o=h instanceof d.P||Array.isArray(h),a=o?h:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(o?{}:h)||{},a instanceof d.P||typeof a[0]=="number")n=[d.P.convert(a)];else{let c=d.P.convert(a[0]),m=d.P.convert(a[1]);n=[c,new d.P(m.x,c.y),m,new d.P(c.x,m.y),c]}return this.style.queryRenderedFeatures(n,e,this.transform)}querySourceFeatures(h,e){return this.style.querySourceFeatures(h,e)}setStyle(h,e){return(e=d.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(h,e))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){let e=this._locale[h];if(e==null)throw new Error(`Missing UI string '${h}'`);return e}_updateStyle(h,e){if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(h,e)));let n=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new Us(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,e,n):this.style.loadJSON(h,e,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Us(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,e){if(typeof h=="string"){let n=this._requestManager.transformRequest(h,"Style");d.h(n,new AbortController).then((o=>{this._updateDiff(o.data,e)})).catch((o=>{o&&this.fire(new d.j(o))}))}else typeof h=="object"&&this._updateDiff(h,e)}_updateDiff(h,e){try{this.style.setState(h,e)&&this._update(!0)}catch(n){d.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(h,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():d.w("There is no style added to the map.")}addSource(h,e){return this._lazyInitEmptyStyle(),this.style.addSource(h,e),this._update(!0)}isSourceLoaded(h){let e=this.style&&this.style.sourceCaches[h];if(e!==void 0)return e.loaded();this.fire(new d.j(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){let e=this.style.sourceCaches[h.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&e.reload();for(let n in this.style._layers){let o=this.style._layers[n];o.type==="hillshade"&&o.source===h.source&&d.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 Sa(this.painter,e,h),this.painter.renderToTexture=new Pl(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==h.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new d.k("terrain",{terrain:h})),this}getTerrain(){var h,e;return(e=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&e!==void 0?e:null}areTilesLoaded(){let h=this.style&&this.style.sourceCaches;for(let e in h){let n=h[e]._tiles;for(let o in n){let a=n[o];if(a.state!=="loaded"&&a.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}addImage(h,e,n={}){let{pixelRatio:o=1,sdf:a=!1,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b}=n;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||d.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new d.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`")));{let{width:S,height:T,data:E}=e,D=e;return this.style.addImage(h,{data:new d.R({width:S,height:T},new Uint8Array(E)),pixelRatio:o,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:a,version:0,userImage:D}),D.onAdd&&D.onAdd(this,h),this}}{let{width:S,height:T,data:E}=ue.getImageData(e);this.style.addImage(h,{data:new d.R({width:S,height:T},E),pixelRatio:o,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:a,version:0})}}updateImage(h,e){let n=this.style.getImage(h);if(!n)return this.fire(new d.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let o=e instanceof HTMLImageElement||d.b(e)?ue.getImageData(e):e,{width:a,height:c,data:m}=o;if(a===void 0||c===void 0)return this.fire(new d.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(a!==n.data.width||c!==n.data.height)return this.fire(new d.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));let _=!(e instanceof HTMLImageElement||d.b(e));return n.data.replace(m,_),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new d.j(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return Ke.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,e){return this._lazyInitEmptyStyle(),this.style.addLayer(h,e),this._update(!0)}moveLayer(h,e){return this.style.moveLayer(h,e),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,e,n){return this.style.setLayerZoomRange(h,e,n),this._update(!0)}setFilter(h,e,n={}){return this.style.setFilter(h,e,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,e,n,o={}){return this.style.setPaintProperty(h,e,n,o),this._update(!0)}getPaintProperty(h,e){return this.style.getPaintProperty(h,e)}setLayoutProperty(h,e,n,o={}){return this.style.setLayoutProperty(h,e,n,o),this._update(!0)}getLayoutProperty(h,e){return this.style.getLayoutProperty(h,e)}setGlyphs(h,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,e,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,e,n,(o=>{o||this._update(!0)})),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,e,(n=>{n||this._update(!0)})),this}setLight(h,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(h){return this._lazyInitEmptyStyle(),this.style.setSky(h),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,e){return this.style.setFeatureState(h,e),this._update()}removeFeatureState(h,e){return this.style.removeFeatureState(h,e),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,e=0;return this._container&&(h=this._container.clientWidth||400,e=this._container.clientHeight||300),[h,e]}_setupContainer(){let h=this._container;h.classList.add("maplibregl-map");let e=this._canvasContainer=H.create("div","maplibregl-canvas-container",h);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=H.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");let n=this._containerDimensions(),o=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],o);let a=this._controlContainer=H.create("div","maplibregl-control-container",h),c=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((m=>{c[m]=H.create("div",`maplibregl-ctrl-${m} `,a)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,e,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*e),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${e}px`}_setupPainter(){let h={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},e=null;this._canvas.addEventListener("webglcontextcreationerror",(o=>{e={requestedAttributes:h},o&&(e.statusMessage=o.statusMessage,e.type=o.type)}),{once:!0});let n=this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h);if(!n){let o="Failed to initialize WebGL";throw e?(e.message=o,new Error(JSON.stringify(e))):new Error(o)}this.painter=new ro(n,this.transform),Xe.testSupport(n)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(h){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_render(h){let e=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let a=this.transform.zoom,c=ue.now();this.style.zoomHistory.update(a,c);let m=new d.z(a,{now:c,fadeDuration:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),_=m.crossFadingFactor();_===1&&_===this._crossFadingFactor||(n=!0,this._crossFadingFactor=_),this.style.update(m)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,e,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:e,showPadding:this.showPadding}),this.fire(new d.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,d.bf.mark(d.bg.load),this.fire(new d.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let o=this._sourcesDirty||this._styleDirty||this._placementDirty;return o||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new d.k("idle")),!this._loaded||this._fullyLoaded||o||(this._fullyLoaded=!0,d.bf.mark(d.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(let n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Ke.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();let e=this.painter.context.gl.getExtension("WEBGL_lose_context");e?.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),H.remove(this._canvasContainer),H.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),d.bf.clearMetrics(),this._removed=!0,this.fire(new d.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,ue.frameAsync(this._frameRequest).then((h=>{d.bf.frame(h),this._frameRequest=null,this._render(h)})).catch((()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get version(){return Ml}getCameraTargetElevation(){return this.transform.elevation}},I.MapMouseEvent=di,I.MapTouchEvent=dn,I.MapWheelEvent=bl,I.Marker=mo,I.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{let e=this._map.getZoom(),n=e===this._map.getMaxZoom(),o=e===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.toString())},this._rotateCompassArrow=()=>{let e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=e},this._setButtonTitle=(e,n)=>{let o=this._map._getUIString(`NavigationControl.${n}`);e.title=o,e.setAttribute("aria-label",o)},this.options=d.e({},Lc,h),this._container=H.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),H.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),H.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})})),this._compassIcon=H.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Dc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){H.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,e){let n=H.create("button",h,this._container);return n.type="button",n.addEventListener("click",e),n}},I.Popup=class extends d.E{constructor(h){super(),this.remove=()=>(this._content&&H.remove(this._content),this._container&&(H.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new d.k("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{var n;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=H.create("div","maplibregl-popup",this._map.getContainer()),this._tip=H.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let _ of this.options.className.split(" "))this._container.classList.add(_);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?zt(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.wrap(),this._trackPointer&&!e)return;let o=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationPoint(this._lngLat));let a=this.options.anchor,c=_o(this.options.offset);if(!a){let _=this._container.offsetWidth,y=this._container.offsetHeight,b;b=o.y+c.bottom.y<y?["top"]:o.y>this._map.transform.height-y?["bottom"]:[],o.x<_/2?b.push("left"):o.x>this._map.transform.width-_/2&&b.push("right"),a=b.length===0?"bottom":b.join("-")}let m=o.add(c[a]);this.options.subpixelPositioning||(m=m.round()),H.setTransform(this._container,`${Zn[a]} translate(${m.x}px,${m.y}px)`),fo(this._container,a,"popup")},this._onClose=()=>{this.remove()},this.options=d.e(Object.create(qe),h)}addTo(h){return this._map&&this.remove(),this._map=h,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new d.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=d.N.convert(h),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){let e=document.createDocumentFragment(),n=document.createElement("body"),o;for(n.innerHTML=h;o=n.firstChild,o;)e.appendChild(o);return this.setDOMContent(e)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=H.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=H.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;let h=this._container.querySelector(go);h&&h.focus()}},I.RasterDEMTileSource=Vt,I.RasterTileSource=_t,I.ScaleControl=class{constructor(h){this._onMove=()=>{Es(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Es(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Cr),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=H.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){H.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},I.ScrollZoomHandler=hr,I.Style=Us,I.TerrainControl=class{constructor(h){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=h}onAdd(h){return this._map=h,this._container=H.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=H.create("button","maplibregl-ctrl-terrain",this._container),H.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){H.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},I.TwoFingersTouchPitchHandler=Vn,I.TwoFingersTouchRotateHandler=_a,I.TwoFingersTouchZoomHandler=ma,I.TwoFingersTouchZoomRotateHandler=xa,I.VectorTileSource=cs,I.VideoSource=Sn,I.addSourceType=(h,e)=>d._(void 0,void 0,void 0,(function*(){if(ds(h))throw new Error(`A source type called "${h}" already exists.`);((n,o)=>{us[n]=o})(h,e)})),I.clearPrewarmedResources=function(){let h=Fi;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(Nr),Fi=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()"))},I.getMaxParallelImageRequests=function(){return d.a.MAX_PARALLEL_IMAGE_REQUESTS},I.getRTLTextPluginStatus=function(){return br().getRTLTextPluginStatus()},I.getVersion=function(){return Ca},I.getWorkerCount=function(){return xr.workerCount},I.getWorkerUrl=function(){return d.a.WORKER_URL},I.importScriptInWorkers=function(h){return ls().broadcast("IS",h)},I.prewarm=function(){Qr().acquire(Nr)},I.setMaxParallelImageRequests=function(h){d.a.MAX_PARALLEL_IMAGE_REQUESTS=h},I.setRTLTextPlugin=function(h,e){return br().setRTLTextPlugin(h,e)},I.setWorkerCount=function(h){xr.workerCount=h},I.setWorkerUrl=function(h){d.a.WORKER_URL=h}}));var oe=z;return oe}))});var Om={};nm(Om,{createImdMap:()=>np});var Bo=ec(Ga(),1);function Ha(z,K){switch(z){case"all":return"2011";case"england":return K;case"wales":case"scotland":case"northern_ireland":return"2011";default:return"2011"}}function Ch(z,K){return Ha(z,K)!==K}var er=[{tier:"z0_4",minzoom:0,maxzoom:5},{tier:"z5_7",minzoom:5,maxzoom:8},{tier:"z8_10",minzoom:8,maxzoom:11},{tier:"z11_14",minzoom:11,maxzoom:24}];function Wa(z,K){return`public.uk_master_${z}_${K}`}function Ro(z,K){return`${z.replace(/\/$/,"")}/${K}/{z}/{x}/{y}.pbf`}function Ph(z){return z==="all"?null:["==",["get","nation"],z]}function Pd(z="all",K="2021"){return{nation:z,era:K,effectiveEra:Ha(z,K),hasPatients:!1,hasLeadCentre:!1,overlays:{localAuthority:!1,nhser:!1,icb:!1,lhb:!1}}}var Xa=ec(Ga(),1);function tc(z){return`rcpch-imd-${z}`}var pg=er.map(z=>tc(z.tier)),ns="rcpch-imd-patients",ss="rcpch-imd-lead-centre";function Mh(z,K,Q){for(let{tier:oe}of er){let I=tc(oe),d=Wa(Q,oe),me=Ro(K,d),_e=z.getSource(I);_e instanceof Xa.VectorTileSource?_e.setTiles([me]):(_e&&z.removeSource(I),z.addSource(I,{type:"vector",tiles:[me],minzoom:0,maxzoom:14}))}}function Ah(z,K){let Q={type:"FeatureCollection",features:K},oe=z.getSource(ns);oe instanceof Xa.GeoJSONSource?oe.setData(Q):(oe&&z.removeSource(ns),z.addSource(ns,{type:"geojson",data:Q}))}function Eh(z,K){let Q={type:"FeatureCollection",features:K?[K]:[]},oe=z.getSource(ss);oe instanceof Xa.GeoJSONSource?oe.setData(Q):(oe&&z.removeSource(ss),z.addSource(ss,{type:"geojson",data:Q}))}var Ns="#0d0d58",Md="#e00087";var om="#41b6e6",am="#3d3d3d",os={england:"#d7191c",wales:"#1a9641",scotland:"#2b83ba",northern_ireland:"#7f7f7f",all:"#d7191c"};function ic(z,K,Q){return Math.min(Q,Math.max(K,z))}function lm(z){let K=z.trim();if(/^#[0-9a-fA-F]{6}$/.test(K))return K;if(/^#[0-9a-fA-F]{3}$/.test(K)){let Q=K[1],oe=K[2],I=K[3];return`#${Q}${Q}${oe}${oe}${I}${I}`}return null}function cm(z){let K=lm(z);if(!K)return null;let Q=parseInt(K.slice(1),16);return{r:Q>>16&255,g:Q>>8&255,b:Q&255}}function hm(z,K,Q){let oe=ic(Math.round(z),0,255).toString(16).padStart(2,"0"),I=ic(Math.round(K),0,255).toString(16).padStart(2,"0"),d=ic(Math.round(Q),0,255).toString(16).padStart(2,"0");return`#${oe}${I}${d}`}function um(z,K,Q){let oe=z/255,I=K/255,d=Q/255,me=Math.max(oe,I,d),_e=Math.min(oe,I,d),Ve=0,ue=(me+_e)/2,H=me-_e;if(H!==0)switch(me){case oe:Ve=((I-d)/H+(I<d?6:0))/6;break;case I:Ve=((d-oe)/H+2)/6;break;default:Ve=((oe-I)/H+4)/6;break}let Xe=H===0?0:H/(1-Math.abs(2*ue-1));return{h:Ve,s:Xe,l:ue}}function dm(z,K,Q){let oe=(1-Math.abs(2*Q-1))*K,I=z*6,d=oe*(1-Math.abs(I%2-1)),me=0,_e=0,Ve=0;I>=0&&I<1?(me=oe,_e=d,Ve=0):I<2?(me=d,_e=oe,Ve=0):I<3?(me=0,_e=oe,Ve=d):I<4?(me=0,_e=d,Ve=oe):I<5?(me=d,_e=0,Ve=oe):(me=oe,_e=0,Ve=d);let ue=Q-oe/2;return{r:(me+ue)*255,g:(_e+ue)*255,b:(Ve+ue)*255}}function rc(z){let K=cm(z);if(!K)return Array(10).fill("#cccccc");let{h:Q,s:oe,l:I}=um(K.r,K.g,K.b),d=10,me=.34,_e=(d-1)/2;return Array.from({length:d},(Ve,ue)=>{let H=(ue-_e)/_e,Xe=ic(I+H*me,.08,.92),{r:wt,g:Ct,b:Bt}=dm(Q,oe,Xe);return hm(wt,Ct,Bt)})}var kh={choropleth:{decileColorsByNation:{},baseColorByNation:{england:os.england,wales:os.wales,scotland:os.scotland,northern_ireland:os.northern_ireland},fallbackDecileColors:rc(os.england),fillOpacity:.7,borderColor:"#ffffff",borderWidth:.5,hoverBorderColor:Ns,hoverBorderWidth:2},boundaries:{localAuthorityColor:Ns,localAuthorityWidth:1,nhserColor:Md,nhserWidth:1.5,icbColor:am,icbWidth:1,lhbColor:om,lhbWidth:1},patients:{circleColor:Ns,circleRadius:5,circleStrokeColor:"#ffffff",circleStrokeWidth:1,circleOpacity:.8,colorByGroup:{}},leadCentre:{color:Md,radius:10,strokeColor:"#ffffff",strokeWidth:2},tooltip:{backgroundColor:Ns,textColor:"#ffffff",borderColor:Ns,borderRadius:4,areaLabel:"Area",decileLabel:"IMD decile",nationLabel:"Nation",patientLabel:"Patient",leadCentreLabel:"Lead centre",areaTooltipText:'<strong style="display:block;margin-bottom:2px;">{{areaName}}</strong><span>LSOA year: {{boundaryYear}}</span><br/><span>{{decileLabel}}: <strong>{{imdDecile}}</strong></span><br/><span>IMD year: {{imdYear}}</span><br/><span>{{nationLabel}}: {{nation}}</span>',patientTooltipText:"{{patientLabel}}",leadCentreTooltipText:"{{leadCentreLabel}}: {{label}}"},legend:{backgroundColor:"#ffffff",textColor:Ns,borderColor:"#d8dde6",borderRadius:8,fontSize:13,fontFamily:"system-ui, -apple-system, Segoe UI, Roboto, sans-serif",width:220,boxShadow:"0 6px 18px rgba(0, 0, 0, 0.12)",toggleOnColor:Ns,toggleOffColor:"#6b7280"}};function zh(z,K){return K?{choropleth:{...z.choropleth,...K.choropleth},boundaries:{...z.boundaries,...K.boundaries},patients:{...z.patients,...K.patients},leadCentre:{...z.leadCentre,...K.leadCentre},tooltip:{...z.tooltip,...K.tooltip},legend:{...z.legend,...K.legend}}:z}function Fo(z,K){let oe=(K.choropleth.decileColorsByNation??{})[z];if(oe&&oe.length===10)return oe;let d=(K.choropleth.baseColorByNation??{})[z];if(d)return rc(d);let me=os[z]??os.england;return rc(me)??K.choropleth.fallbackDecileColors??rc(os.england)}function Ka(z){return`rcpch-imd-fill-${z}`}function nc(z){return`rcpch-imd-line-${z}`}var Lh=er.flatMap(z=>[Ka(z.tier),nc(z.tier)]),yr="rcpch-imd-patients",Er="rcpch-imd-lead-centre",Ed=Ka("z8_10");function Ad(z){let K=z[0]??"#cccccc";return["step",["get","imd_decile"],K,2,z[1]??K,3,z[2]??K,4,z[3]??K,5,z[4]??K,6,z[5]??K,7,z[6]??K,8,z[7]??K,9,z[8]??K,10,z[9]??K]}function kd(z,K){if(z!=="all")return Ad(Fo(z,K));let Q=["england","wales","scotland","northern_ireland"].flatMap(oe=>[oe,Ad(Fo(oe,K))]);return["match",["get","nation"],...Q,Fo("england",K)[0]??"#cccccc"]}function pm(z){for(let K of z.getStyle().layers??[])if(K.type==="symbol")return K.id}function fm(z){let K=z.patients.circleColor??"#0d0d58",Q=z.patients.colorByGroup??{},oe=Object.entries(Q).filter(([I,d])=>I&&d);return oe.length?["match",["coalesce",["to-string",["get","group"]],""],...oe.flatMap(([I,d])=>[I,d]),K]:K}function Dh(z,K,Q,oe){Rh(z);let I=Ph(K),d=I?{filter:I}:{},me=pm(z);for(let{tier:_e,minzoom:Ve,maxzoom:ue}of er){let H=tc(_e),Xe=Wa(Q,_e),wt=kd(K,oe);z.addLayer({id:Ka(_e),type:"fill",source:H,"source-layer":Xe,minzoom:Ve,maxzoom:ue,...d,paint:{"fill-color":wt,"fill-opacity":oe.choropleth.fillOpacity??.7}},me),z.addLayer({id:nc(_e),type:"line",source:H,"source-layer":Xe,minzoom:Ve,maxzoom:ue,...d,paint:{"line-color":oe.choropleth.borderColor??"#ffffff","line-width":oe.choropleth.borderWidth??.5}},me)}}function Rh(z){for(let K of Lh)z.getLayer(K)&&z.removeLayer(K)}function zd(z,K,Q){let oe=kd(K,Q);for(let{tier:I}of er){let d=Ka(I),me=nc(I);z.getLayer(d)&&(z.setPaintProperty(d,"fill-color",oe),z.setPaintProperty(d,"fill-opacity",Q.choropleth.fillOpacity??.7),z.setPaintProperty(me,"line-color",Q.choropleth.borderColor??"#ffffff"),z.setPaintProperty(me,"line-width",Q.choropleth.borderWidth??.5))}}function Ld(z,K,Q){let oe=Ph(K);for(let{tier:I}of er){let d=Ka(I),me=nc(I);if(!z.getLayer(d))continue;let _e=Wa(Q,I);z.setFilter(d,oe),z.setFilter(me,oe)}}function sc(z,K){let Q=K.patients,oe=fm(K);z.getLayer(yr)?(z.setPaintProperty(yr,"circle-color",oe),z.setPaintProperty(yr,"circle-radius",Q.circleRadius??5),z.setPaintProperty(yr,"circle-stroke-color",Q.circleStrokeColor??"#ffffff"),z.setPaintProperty(yr,"circle-stroke-width",Q.circleStrokeWidth??1),z.setPaintProperty(yr,"circle-opacity",Q.circleOpacity??.8)):z.addLayer({id:yr,type:"circle",source:ns,paint:{"circle-color":oe,"circle-radius":Q.circleRadius??5,"circle-stroke-color":Q.circleStrokeColor??"#ffffff","circle-stroke-width":Q.circleStrokeWidth??1,"circle-opacity":Q.circleOpacity??.8}})}function Dd(z){z.getLayer(yr)&&z.removeLayer(yr)}function oc(z,K){let Q=K.leadCentre;z.getLayer(Er)?(z.setPaintProperty(Er,"circle-color",Q.color??"#e00087"),z.setPaintProperty(Er,"circle-radius",Q.radius??10),z.setPaintProperty(Er,"circle-stroke-color",Q.strokeColor??"#ffffff"),z.setPaintProperty(Er,"circle-stroke-width",Q.strokeWidth??2)):z.addLayer({id:Er,type:"circle",source:ss,paint:{"circle-color":Q.color??"#e00087","circle-radius":Q.radius??10,"circle-stroke-color":Q.strokeColor??"#ffffff","circle-stroke-width":Q.strokeWidth??2}})}function Rd(z){z.getLayer(Er)&&z.removeLayer(Er)}var mm={code:["code","lsoa_code","LSOA11CD","lsoa11cd","LSOA21CD","lsoa21cd"],area_name:["area_name","LSOA11NM","lsoa11nm","LSOA21NM","lsoa21nm","name"],imd_decile:["imd_decile","IMD_Decile","IMDDecile","decile","imd_rank_decile"],imd_rank:["imd_rank","IMD_Rank","rank"],imd_year:["imd_year","IMD_Year"],nation:["nation","Nation","country","Country"],year:["year","Year"],la_code:["la_code","LAD_code","lad_code"],la_name:["la_name","LAD_name","lad_name"],nhser_code:["nhser_code","NHSER_code"],nhser_name:["nhser_name","NHSER_name"],icb_code:["icb_code","ICB_code"],icb_name:["icb_name","ICB_name"],lhb_code:["lhb_code","LHB_code"],lhb_name:["lhb_name","LHB_name"]};function ct(z,K){if(!z)return;if(K in z)return z[K];let Q=mm[K];if(Q){for(let I of Q)if(I in z)return z[I]}let oe=K.toLowerCase();for(let[I,d]of Object.entries(z))if(I.toLowerCase()===oe)return d}function Fh(z,K){return z.replace(/{{\s*([a-zA-Z0-9_]+)\s*}}/g,(Q,oe)=>{let I=K[oe];return I==null?"":String(I)})}function gm(z,K){let Q=K.tooltip,oe=ct(z,"area_name")??"Unknown area",I=ct(z,"imd_decile")??"\u2013",d=ct(z,"nation")??"\u2013",me=ct(z,"year")??"\u2013",_e=ct(z,"imd_year")??"\u2013",Ve=Q.backgroundColor??"#0d0d58",ue=Q.textColor??"#ffffff",H=Q.borderRadius??4;return`<div style="background:${Ve};color:${ue};padding:8px 12px;border-radius:${H}px;font-size:13px;line-height:1.6;font-family:sans-serif;">
578
+ <strong style="display:block;margin-bottom:2px;">${String(oe)}</strong>
579
+ <span>LSOA year: ${String(me)}</span><br/>
580
+ <span>${Q.decileLabel??"IMD decile"}: <strong>${String(I)}</strong></span><br/>
581
+ <span>IMD year: ${String(_e)}</span><br/>
582
+ <span>${Q.nationLabel??"Nation"}: ${String(d)}</span>
583
+ </div>`}function _m(z,K){let Q=K.tooltip,oe=Q.backgroundColor??"#0d0d58",I=Q.textColor??"#ffffff",d=Q.borderRadius??4,me=ct(z,"code"),_e=ct(z,"area_name")??"Unknown area",Ve=ct(z,"area_type")??"LSOA",ue=ct(z,"nation")??"\u2013",H=ct(z,"imd_decile")??"\u2013",Xe=ct(z,"imd_year")??"\u2013",wt=ct(z,"year")??"\u2013",Ct=ct(z,"la_code")??"",Bt=ct(z,"la_name")??"",$t=ct(z,"la_year")??"",ri=ct(z,"nhser_code")??"",Ke=ct(z,"nhser_name")??"",$e=ct(z,"icb_code")??"",Ye=ct(z,"icb_name")??"",Pt=ct(z,"lhb_code")??"",Mt=ct(z,"lhb_name")??"",Nt=Q.areaTooltipText??"<strong>{{areaName}}</strong><br/><span>{{decileLabel}}: {{imdDecile}}</span>",ft=Fh(Nt,{...z??{},areaCode:me,areaName:_e,areaType:Ve,nation:ue,imdDecile:H,imdYear:Xe,boundaryYear:wt,laCode:Ct,laName:Bt,laYear:$t,nhserCode:ri,nhserName:Ke,icbCode:$e,icbName:Ye,lhbCode:Pt,lhbName:Mt,decileLabel:Q.decileLabel??"IMD decile",nationLabel:Q.nationLabel??"Nation"});return`<div style="background:${oe};color:${I};padding:8px 12px;border-radius:${d}px;font-size:13px;line-height:1.6;font-family:sans-serif;">
584
+ <span>${ft}</span>
585
+ </div>`}function ac(z){if(typeof z=="number"&&Number.isFinite(z))return z;if(typeof z=="string"&&z.trim()!==""){let K=Number(z);if(Number.isFinite(K))return K}}function ym(z,K){let Q=K.tooltip,oe=ct(z,"id")??"",I=ct(z,"group")??"",d=Q.backgroundColor??"#0d0d58",me=Q.textColor??"#ffffff",_e=Q.borderRadius??4,Ve=Q.patientLabel??"Patient",ue=Q.patientTooltipText??"{{patientLabel}}",H={...z??{},patientLabel:Ve,id:oe,group:I},Xe=Fh(ue,H);return`<div style="background:${d};color:${me};padding:8px 12px;border-radius:${_e}px;font-size:13px;line-height:1.6;font-family:sans-serif;">
586
+ <span>${Xe}</span>
587
+ </div>`}function xm(z,K){let Q=K.tooltip,oe=ct(z,"label")??"Lead centre",I=Q.backgroundColor??"#0d0d58",d=Q.textColor??"#ffffff",me=Q.borderRadius??4,_e=Q.leadCentreLabel??"Lead centre",Ve=Fh(Q.leadCentreTooltipText??"{{leadCentreLabel}}: {{label}}",{leadCentreLabel:_e,label:oe});return`<div style="background:${I};color:${d};padding:8px 12px;border-radius:${me}px;font-size:13px;line-height:1.6;font-family:sans-serif;">
588
+ <span>${Ve}</span>
589
+ </div>`}function Fd(z,K){let Q=z.properties??{},oe=ct(Q,"code"),I=ct(Q,"area_name"),d=ct(Q,"area_type"),me=ct(Q,"nation"),_e=ac(ct(Q,"imd_decile")),Ve=ac(ct(Q,"imd_year")),ue=ac(ct(Q,"year")),H=ct(Q,"la_code"),Xe=ct(Q,"la_name"),wt=ac(ct(Q,"la_year")),Ct=ct(Q,"nhser_code"),Bt=ct(Q,"nhser_name"),$t=ct(Q,"icb_code"),ri=ct(Q,"icb_name"),Ke=ct(Q,"lhb_code"),$e=ct(Q,"lhb_name");return{areaCode:oe==null?void 0:String(oe),areaName:I==null?void 0:String(I),areaType:d==null?void 0:String(d),nation:me==null?void 0:String(me),imdDecile:_e,imdYear:Ve,boundaryYear:ue,laCode:H==null?void 0:String(H),laName:Xe==null?void 0:String(Xe),laYear:wt,nhserCode:Ct==null?void 0:String(Ct),nhserName:Bt==null?void 0:String(Bt),icbCode:$t==null?void 0:String($t),icbName:ri==null?void 0:String(ri),lhbCode:Ke==null?void 0:String(Ke),lhbName:$e==null?void 0:String($e),lngLat:K,lsoaCode:oe==null?void 0:String(oe),lsoaName:I==null?void 0:String(I),rawProperties:Q}}function Bd(z,K,Q,oe){let I=Lh.filter(d=>d.startsWith("rcpch-imd-fill-"));for(let d of I)z.on("mousemove",d,me=>{let _e=z.queryRenderedFeatures(me.point,{layers:[d]});if(!_e.length)return;z.getCanvas().style.cursor="pointer";let Ve=_e[0],ue=oe.areaTooltipMode??"default";if(ue!=="none"){let H=ue==="template"?_m(Ve.properties,Q):gm(Ve.properties,Q);K.setLngLat(me.lngLat).setHTML(H).addTo(z)}oe.onAreaHover?.(Fd(Ve,{lng:me.lngLat.lng,lat:me.lngLat.lat}))}),z.on("mouseleave",d,()=>{z.getCanvas().style.cursor="",K.remove()}),z.on("click",d,me=>{let _e=z.queryRenderedFeatures(me.point,{layers:[d]});_e.length&&oe.onAreaClick?.(Fd(_e[0],{lng:me.lngLat.lng,lat:me.lngLat.lat}))})}function Bh(z,K,Q){z.on("mousemove",yr,oe=>{let I=z.queryRenderedFeatures(oe.point,{layers:[yr]});if(!I.length)return;let d=I[0];z.getCanvas().style.cursor="pointer",K.setLngLat(oe.lngLat).setHTML(ym(d.properties,Q)).addTo(z)}),z.on("mouseleave",yr,()=>{z.getCanvas().style.cursor="",K.remove()})}function Oh(z,K,Q){z.on("mousemove",Er,oe=>{let I=z.queryRenderedFeatures(oe.point,{layers:[Er]});if(!I.length)return;let d=I[0];z.getCanvas().style.cursor="pointer",K.setLngLat(oe.lngLat).setHTML(xm(d.properties,Q)).addTo(z)}),z.on("mouseleave",Er,()=>{z.getCanvas().style.cursor="",K.remove()})}function Nh(z,K){let Q=[];return(typeof z!="number"||isNaN(z)||z<-90||z>90)&&Q.push(`Invalid latitude: ${String(z)}. Must be a number between -90 and 90.`),(typeof K!="number"||isNaN(K)||K<-180||K>180)&&Q.push(`Invalid longitude: ${String(K)}. Must be a number between -180 and 180.`),{valid:Q.length===0,errors:Q}}var lc={minLat:49.5,maxLat:61.5,minLon:-8.7,maxLon:2.1};function vm(z,K){return z>=lc.minLat&&z<=lc.maxLat&&K>=lc.minLon&&K<=lc.maxLon}function Od(z){if(!z||typeof z!="object")return{point:null,errors:["Record is not an object."]};let K=z,Q=K.lat??K.latitude??K.LAT,oe=K.lon??K.lng??K.longitude??K.LON,{valid:I,errors:d}=Nh(Q,oe);if(!I)return{point:null,errors:d};if(!vm(Q,oe))return{point:null,errors:[`Point (${String(Q)}, ${String(oe)}) is outside UK bounds and will be skipped.`]};let me=new Set(["lat","lon","id","weight","group","latitude","longitude","lng","LAT","LON"]);return{point:{lat:Q,lon:oe,id:K.id!==void 0?String(K.id):void 0,weight:typeof K.weight=="number"?K.weight:void 0,group:typeof K.group=="string"?K.group:void 0,properties:Object.fromEntries(Object.entries(K).filter(([Ve])=>!me.has(Ve)))},errors:[]}}function bm(z){return typeof z=="object"&&z!==null&&z.type==="FeatureCollection"&&Array.isArray(z.features)}function wm(z){return typeof z=="object"&&z!==null&&z.type==="Feature"}function Nd(z,K){let Q=[],oe=[],I=K?.strict===!0,d;if(bm(z))d=z.features.map(me=>({lat:me.geometry.coordinates[1],lon:me.geometry.coordinates[0],...me.properties}));else if(Array.isArray(z))d=z.map(me=>wm(me)?{lat:me.geometry.coordinates[1],lon:me.geometry.coordinates[0],...me.properties}:me);else{if(I)throw new Error("[rcpch-imd-map] PatientInput must be an array or GeoJSON FeatureCollection.");return oe.push({code:"INVALID_INPUT",message:"PatientInput must be an array or GeoJSON FeatureCollection."}),{features:Q,warnings:oe}}for(let me=0;me<d.length;me++){let{point:_e,errors:Ve}=Od(d[me]);if(!_e){if(I)throw new Error(`[rcpch-imd-map] Patient record at index ${me} is invalid: ${Ve.join("; ")}`);oe.push({code:"INVALID_PATIENT_POINT",message:`Patient record at index ${me} is invalid and will be skipped: ${Ve.join("; ")}`,details:{index:me,errors:Ve}});continue}for(let ue of Ve)oe.push({code:"PATIENT_POINT_WARNING",message:ue,details:{index:me}});Q.push({type:"Feature",geometry:{type:"Point",coordinates:[_e.lon,_e.lat]},properties:{id:_e.id??`patient-${me}`,weight:_e.weight??1,group:_e.group??null,..._e.properties}})}return{features:Q,warnings:oe}}function Vd(z){if(!z||typeof z!="object")return null;let K,Q,oe="Lead centre";if(z.type==="Feature"&&z.geometry?.type==="Point")[Q,K]=z.geometry.coordinates,oe=z.properties?.label??oe;else{let d=z;K=d.lat??d.latitude,Q=d.lon??d.lng??d.longitude,oe=d.label??oe}let{valid:I}=Nh(K,Q);return I?{type:"Feature",geometry:{type:"Point",coordinates:[Q,K]},properties:{label:oe}}:null}var jd=ec(Ga(),1);var Sm="rcpch-imd-la-overlay",Tm="rcpch-imd-la-overlay-line",Ud="la_tiles";function Im(z){return`${Sm}-${z}`}function $d(z){return`${Tm}-${z}`}function qd(z,K,Q){for(let{tier:oe,minzoom:I,maxzoom:d}of er){let me=Im(oe),_e=$d(oe),Ve=`public.${Ud}_${oe}`,ue=`${Ud}_${oe}`,H=Ro(K,Ve),Xe=z.getSource(me);if(Xe instanceof jd.VectorTileSource?Xe.setTiles([H]):(Xe&&z.removeSource(me),z.addSource(me,{type:"vector",tiles:[H],minzoom:0,maxzoom:14})),z.getLayer(_e)){z.setPaintProperty(_e,"line-color",Q.boundaries.localAuthorityColor??"#0d0d58"),z.setPaintProperty(_e,"line-width",Q.boundaries.localAuthorityWidth??1),z.setLayoutProperty(_e,"visibility","visible");continue}z.addLayer({id:_e,type:"line",source:me,"source-layer":ue,minzoom:I,maxzoom:d,paint:{"line-color":Q.boundaries.localAuthorityColor??"#0d0d58","line-width":Q.boundaries.localAuthorityWidth??1},layout:{visibility:"visible"}})}}function Zd(z){for(let{tier:K}of er){let Q=$d(K);z.getLayer(Q)&&z.setLayoutProperty(Q,"visibility","none")}}var Gd=ec(Ga(),1);var Cm="rcpch-imd-nhser-overlay",Hd="rcpch-imd-nhser-overlay-line",Pm="rcpch-imd-icb-overlay",Wd="rcpch-imd-icb-overlay-line",Mm="rcpch-imd-lhb-overlay",Xd="rcpch-imd-lhb-overlay-line",Am="nhser_tiles_2021",Em="icb_tiles_2023",km="lhb_tiles_2022";function zm(z,K){return`${z}-${K}`}function Kd(z,K){return`${z}-${K}`}function Vh(z,K,Q){for(let{tier:oe,minzoom:I,maxzoom:d}of er){let me=zm(Q.sourceId,oe),_e=Kd(Q.layerId,oe),Ve=`public.${Q.tablePrefix}_${oe}`,ue=`${Q.tablePrefix}_${oe}`,H=Ro(K,Ve),Xe=z.getSource(me);if(Xe instanceof Gd.VectorTileSource?Xe.setTiles([H]):(Xe&&z.removeSource(me),z.addSource(me,{type:"vector",tiles:[H],minzoom:0,maxzoom:14})),z.getLayer(_e)){z.setPaintProperty(_e,"line-color",Q.lineColor),z.setPaintProperty(_e,"line-width",Q.lineWidth),z.setLayoutProperty(_e,"visibility","visible");continue}z.addLayer({id:_e,type:"line",source:me,"source-layer":ue,minzoom:I,maxzoom:d,paint:{"line-color":Q.lineColor,"line-width":Q.lineWidth},layout:{visibility:"visible"}})}}function Jd(z,K,Q){Vh(z,K,{sourceId:Cm,layerId:Hd,tablePrefix:Am,lineColor:Q.boundaries.nhserColor??"#e00087",lineWidth:Q.boundaries.nhserWidth??1.5})}function Yd(z,K,Q){Vh(z,K,{sourceId:Pm,layerId:Wd,tablePrefix:Em,lineColor:Q.boundaries.icbColor??"#57c7f2",lineWidth:Q.boundaries.icbWidth??1})}function Qd(z,K,Q){Vh(z,K,{sourceId:Mm,layerId:Xd,tablePrefix:km,lineColor:Q.boundaries.lhbColor??"#57c7f2",lineWidth:Q.boundaries.lhbWidth??1})}function Uh(z,K){for(let{tier:Q}of er){let oe=Kd(K,Q);z.getLayer(oe)&&z.setLayoutProperty(oe,"visibility","none")}}function ep(z){Uh(z,Hd)}function tp(z){Uh(z,Wd)}function ip(z){Uh(z,Xd)}function Lm(z,K){let Q=z.nation,oe=Q==="all"||Q==="england",I=Q==="all"||Q==="england",d=Q==="all"||Q==="wales";return[{key:"nhser",label:"NHS England regions",isVisible:K.nhser,isEnabled:oe,isActive:z.overlays.nhser,disabledNote:"England only"},{key:"icb",label:"ICBs",isVisible:K.icb,isEnabled:I,isActive:z.overlays.icb,disabledNote:"England only"},{key:"localAuthority",label:"Local authorities",isVisible:K.localAuthority,isEnabled:!0,isActive:z.overlays.localAuthority},{key:"lhb",label:"Local health boards",isVisible:K.lhb,isEnabled:d,isActive:z.overlays.lhb,disabledNote:"Wales only"}].filter(_e=>_e.isVisible)}function Dm(z,K){switch(z.style.top="",z.style.right="",z.style.bottom="",z.style.left="",K){case"top-left":z.style.top="12px",z.style.left="12px";break;case"bottom-left":z.style.bottom="12px",z.style.left="12px";break;case"bottom-right":z.style.bottom="12px",z.style.right="12px";break;default:z.style.top="12px",z.style.right="12px";break}}function rp(z){window.getComputedStyle(z.container).position==="static"&&(z.container.style.position="relative");let Q=z.state,oe=z.style,I=z.collapsed,d=document.createElement("div");d.setAttribute("data-rcpch-legend","true"),d.style.position="absolute",d.style.zIndex="5",d.style.pointerEvents="auto",Dm(d,z.position);let me=document.createElement("div"),_e=document.createElement("button"),Ve=document.createElement("span"),ue=document.createElement("span"),H=document.createElement("div"),Xe=document.createElement("div");_e.type="button",_e.setAttribute("aria-expanded",String(!I)),Ve.textContent=z.title,ue.textContent=I?"+":"-",_e.appendChild(Ve),_e.appendChild(ue),me.appendChild(_e),me.appendChild(H),me.appendChild(Xe),d.appendChild(me),z.container.appendChild(d);function wt(){let Ke=oe.legend,$e=Ke?.backgroundColor??"#ffffff",Ye=Ke?.textColor??"#0d0d58",Pt=Ke?.borderColor??"#d8dde6",Mt=Ke?.borderRadius??8,Nt=Ke?.fontSize??13,ft=Ke?.fontFamily??"system-ui, -apple-system, Segoe UI, Roboto, sans-serif",vi=Ke?.width??220,et=Ke?.boxShadow??"0 6px 18px rgba(0, 0, 0, 0.12)";me.style.background=$e,me.style.color=Ye,me.style.border=`1px solid ${Pt}`,me.style.borderRadius=`${Mt}px`,me.style.width=`${vi}px`,me.style.boxShadow=et,me.style.overflow="hidden",_e.style.width="100%",_e.style.border="0",_e.style.background="transparent",_e.style.color=Ye,_e.style.display="flex",_e.style.alignItems="center",_e.style.justifyContent="space-between",_e.style.padding="10px 12px",_e.style.cursor="pointer",_e.style.fontWeight="600",_e.style.fontSize=`${Nt}px`,_e.style.fontFamily=ft,_e.style.textAlign="left",H.style.padding="0 12px 10px",H.style.display=I?"none":"block",H.style.fontFamily=ft,H.style.fontSize=`${Nt}px`,Xe.style.padding="0 12px 10px",Xe.style.display=I?"none":"block",Xe.style.fontFamily=ft,Xe.style.fontSize=`${Math.max(Nt-1,11)}px`,Xe.style.borderTop=`1px solid ${Pt}`}function Ct(){H.innerHTML="",Xe.innerHTML="";let Ke=Lm(Q,z.visibility);if(!Ke.length){d.style.display="none";return}d.style.display="";for(let $e of Ke){let Ye=document.createElement("button"),Pt=document.createElement("span"),Mt=document.createElement("span"),Nt=document.createElement("span");if(Ye.type="button",Ye.style.width="100%",Ye.style.border="0",Ye.style.background="transparent",Ye.style.color=oe.legend?.textColor??"#0d0d58",Ye.style.display="flex",Ye.style.alignItems="center",Ye.style.gap="8px",Ye.style.padding="6px 0",Ye.style.cursor=$e.isEnabled?"pointer":"not-allowed",Ye.style.textAlign="left",Ye.style.opacity=$e.isEnabled?$e.isActive?"1":"0.75":"0.5",Pt.style.width="10px",Pt.style.height="10px",Pt.style.borderRadius="999px",Pt.style.flex="0 0 10px",Pt.style.background=$e.isActive?oe.legend?.toggleOnColor??"#0d0d58":oe.legend?.toggleOffColor??"#6b7280",Nt.style.display="flex",Nt.style.flexDirection="column",Nt.style.gap="1px",Mt.textContent=$e.label,Nt.appendChild(Mt),!$e.isEnabled&&$e.disabledNote){let ft=document.createElement("span");ft.textContent=$e.disabledNote,ft.style.fontSize="11px",ft.style.opacity="0.9",Nt.appendChild(ft)}Ye.setAttribute("aria-pressed",String($e.isActive)),Ye.setAttribute("aria-disabled",String(!$e.isEnabled)),Ye.disabled=!$e.isEnabled,Ye.setAttribute("title",!$e.isEnabled&&$e.disabledNote?`${$e.label} (${$e.disabledNote})`:$e.isActive?`Hide ${$e.label}`:`Show ${$e.label}`),Ye.addEventListener("click",()=>{$e.isEnabled&&z.onToggle($e.key,!$e.isActive)}),Ye.appendChild(Pt),Ye.appendChild(Nt),H.appendChild(Ye)}Bt(Ke)}function Bt(Ke){let $e=document.createElement("div");$e.textContent="Key",$e.style.paddingTop="8px",$e.style.paddingBottom="6px",$e.style.fontWeight="600",Xe.appendChild($e);for(let et of Ke){let ei=document.createElement("div"),ze=document.createElement("span"),it=document.createElement("span");ei.style.display="flex",ei.style.alignItems="center",ei.style.gap="8px",ei.style.padding="2px 0",ze.style.display="inline-block",ze.style.width="18px",ze.style.height="0",ze.style.borderTopWidth=`${Math.max(ri(et.key,oe),2)}px`,ze.style.borderTopStyle="solid",ze.style.borderTopColor=$t(et.key,oe),it.textContent=et.label,ei.appendChild(ze),ei.appendChild(it),Xe.appendChild(ei)}let Ye=document.createElement("div");Ye.style.paddingTop="8px";let Pt=document.createElement("div");Pt.textContent="IMD decile (1 most deprived, 10 least deprived)",Pt.style.paddingBottom="4px",Xe.appendChild(Pt);let Mt=document.createElement("div");Mt.style.display="grid",Mt.style.gridTemplateColumns="repeat(10, minmax(0, 1fr))",Mt.style.gap="2px";let Nt=Fo(Q.nation,oe);for(let et=0;et<10;et++){let ei=document.createElement("span");ei.style.height="8px",ei.style.background=Nt[et]??Nt[0]??"#cccccc",ei.style.display="inline-block",ei.title=`Decile ${et+1}`,Mt.appendChild(ei)}let ft=document.createElement("div");ft.style.display="flex",ft.style.justifyContent="space-between",ft.style.paddingTop="2px",ft.textContent="1";let vi=document.createElement("span");vi.textContent="10",ft.appendChild(vi),Ye.appendChild(Mt),Ye.appendChild(ft),Xe.appendChild(Ye)}function $t(Ke,$e){return Ke==="localAuthority"?$e.boundaries.localAuthorityColor??"#0d0d58":Ke==="nhser"?$e.boundaries.nhserColor??"#e00087":Ke==="icb"?$e.boundaries.icbColor??"#57c7f2":$e.boundaries.lhbColor??"#57c7f2"}function ri(Ke,$e){return Ke==="localAuthority"?$e.boundaries.localAuthorityWidth??1:Ke==="nhser"?$e.boundaries.nhserWidth??1.5:Ke==="icb"?$e.boundaries.icbWidth??1:$e.boundaries.lhbWidth??1}return _e.addEventListener("click",()=>{I=!I,_e.setAttribute("aria-expanded",String(!I)),ue.textContent=I?"+":"-",H.style.display=I?"none":"block",Xe.style.display=I?"none":"block"}),wt(),Ct(),{update(Ke,$e){Q=Ke,oe=$e,wt(),Ct()},destroy(){d.remove()}}}var Rm=!1;var as={debug(z,...K){Rm&&console.debug(`[rcpch-imd-map] ${z}`,...K)},info(z,...K){console.info(`[rcpch-imd-map] ${z}`,...K)},warn(z,...K){console.warn(`[rcpch-imd-map] ${z}`,...K)},error(z,...K){console.error(`[rcpch-imd-map] ${z}`,...K)}};var Fm=[-2.5,54],Bm=5;function np(z){let K=typeof z.container=="string"?document.getElementById(z.container):z.container;if(!K)throw new Error(`[rcpch-imd-map] Container not found: "${String(z.container)}". Ensure the element exists in the DOM before calling createImdMap.`);let Q=z.tilesBaseUrl??"";Q||as.warn("No tilesBaseUrl provided. Choropleth tiles will not load.");let oe=zh(kh,z.style),I=Pd(z.initialNation??"all",z.initialEra??"2021");z.enableLocalAuthorityOverlay&&(I={...I,overlays:{...I.overlays,localAuthority:!0}}),z.enableHealthOverlays&&(I={...I,overlays:{...I.overlays,nhser:!0,icb:!0,lhb:!0}});let d=z.showLegend??!0,me=z.legendPosition??"top-right",_e=z.legendCollapsed??!1,Ve=z.legendTitle??"Map layers",ue={localAuthority:z.showLegendLocalAuthority??!0,nhser:z.showLegendNhser??!0,icb:z.showLegendIcb??!0,lhb:z.showLegendLhb??!0};if(z.initialNation&&z.initialEra&&Ch(z.initialNation,z.initialEra)){let ze={code:"ERA_OVERRIDE",message:`Era '${z.initialEra}' is not supported for nation '${z.initialNation}'. Effective era will be '${I.effectiveEra}'.`};as.warn(ze.message),z.onWarning?.(ze)}let H=new Bo.Map({container:K,style:z.mapStyleUrl??"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",center:z.center??Fm,zoom:z.zoom??Bm,attributionControl:!1});H.addControl(new Bo.AttributionControl({compact:!0}));let Xe=new Bo.Popup({closeButton:!1,closeOnClick:!1}),wt=!1,Ct=null,Bt=null,$t=null,ri=!1,Ke=!1,$e=null,Ye=[];function Pt(){return[...$e?[$e]:[],...Ye]}function Mt(ze,it){let ot=Pt();if(!ot.length){as.warn("No patient or lead centre data to fit to.");return}if(ot.length===1){let[ui,Wt]=ot[0];H.flyTo({center:[ui,Wt],zoom:ze??6});return}let ti=ot[0][0],Ht=ot[0][1],tr=ot[0][0],ir=ot[0][1];for(let[ui,Wt]of ot)ui<ti&&(ti=ui),Wt<Ht&&(Ht=Wt),ui>tr&&(tr=ui),Wt>ir&&(ir=Wt);H.fitBounds([[ti,Ht],[tr,ir]],{padding:it??50,maxZoom:ze})}function Nt(){if(!wt||!Q)return;let ze=I.nation,it=ze==="all"||ze==="england",ot=ze==="all"||ze==="england",ti=ze==="all"||ze==="wales";I.overlays.localAuthority?qd(H,Q,oe):Zd(H),I.overlays.nhser&&it?Jd(H,Q,oe):ep(H),I.overlays.icb&&ot?Yd(H,Q,oe):tp(H),I.overlays.lhb&&ti?Qd(H,Q,oe):ip(H)}function ft(ze){I={...I,overlays:{...I.overlays,...ze}},Nt(),vi?.update(I,oe)}let vi=null;d&&(vi=rp({container:K,position:me,title:Ve,collapsed:_e,style:oe,state:I,visibility:ue,onToggle:(ze,it)=>{ze==="localAuthority"?ft({localAuthority:it}):ze==="nhser"?ft({nhser:it}):ze==="icb"?ft({icb:it}):ze==="lhb"&&ft({lhb:it})}})),as.debug(`tilesBaseUrl resolved to: "${Q}"`),H.on("load",()=>{if(wt=!0,Q&&(Mh(H,Q,I.effectiveEra),Dh(H,I.nation,I.effectiveEra,oe)),Nt(),Bd(H,Xe,oe,z),Ct&&(Ye=Ct.map(ze=>ze.geometry.coordinates),Ah(H,Ct),sc(H,oe),ri||(Bh(H,Xe,oe),ri=!0),I={...I,hasPatients:!0},Ct=null),Bt&&($e=Bt.geometry.coordinates,Eh(H,Bt),oc(H,oe),Ke||(Oh(H,Xe,oe),Ke=!0),I={...I,hasLeadCentre:!0},Bt=null),$t){let{zoom:ze,padding:it}=$t;H.once("idle",()=>{Mt(ze,it)}),$t=null}});function et(ze,it){let ot=Ha(ze,it);if(Ch(ze,it)){let tr={code:"ERA_OVERRIDE",message:`Era '${it}' overridden to '${ot}' for nation '${ze}'.`};as.warn(tr.message),z.onWarning?.(tr)}let ti=ot!==I.effectiveEra,Ht=ze!==I.nation;I={...I,nation:ze,era:it,effectiveEra:ot},wt&&Q&&(ti?(Rh(H),Mh(H,Q,ot),Dh(H,ze,ot,oe)):Ht&&Ld(H,ze,ot)),z.onViewChange?.({nation:ze,era:it,effectiveEra:ot})}return{setView({nation:ze,era:it}={}){et(ze??I.nation,it??I.era)},setNation(ze){et(ze,I.era)},setEra(ze){et(I.nation,ze)},setStyle(ze){oe=zh(kh,ze),wt&&(zd(H,I.nation,oe),Nt(),I.hasPatients&&sc(H,oe),I.hasLeadCentre&&oc(H,oe),vi?.update(I,oe))},setOverlayVisibility(ze){ft(ze)},setPatients(ze,it){let{features:ot,warnings:ti}=Nd(ze,{strict:it?.strict});Ye=ot.map(Ht=>Ht.geometry.coordinates);for(let Ht of ti)as.warn(Ht.message),z.onWarning?.(Ht);if(!wt){Ct=ot;return}Ah(H,ot),sc(H,oe),ri||(Bh(H,Xe,oe),ri=!0),I={...I,hasPatients:!0}},clearPatients(){Ct=null,Ye=[],wt&&(Dd(H),H.getSource(ns)&&H.removeSource(ns),I={...I,hasPatients:!1})},setLeadCentre(ze,it){let ot=Vd(ze);if(!ot){let ti={code:"INVALID_LEAD_CENTRE",message:"Lead centre data could not be resolved to valid coordinates."};as.warn(ti.message),z.onWarning?.(ti);return}if(!wt){Bt=ot;return}$e=ot.geometry.coordinates,Eh(H,ot),oc(H,oe),Ke||(Oh(H,Xe,oe),Ke=!0),I={...I,hasLeadCentre:!0}},clearLeadCentre(){Bt=null,$e=null,wt&&(Rd(H),H.getSource(ss)&&H.removeSource(ss),I={...I,hasLeadCentre:!1})},getState(){return{...I}},resize(){H.resize()},fitToData(ze){let it=ze?.zoom,ot=ze?.padding;if(!wt){$t={zoom:it,padding:ot};return}Mt(it,ot)},destroy(){Xe.remove(),vi?.destroy(),H.remove()}}}return sm(Om);})();
588
590
  /*! Bundled license information:
589
591
 
590
592
  maplibre-gl/dist/maplibre-gl.js: